cupertino_fundations_models 0.1.1
cupertino_fundations_models: ^0.1.1 copied to clipboard
Apple Intelligence Foundation Models for Flutter: on-device AI, streaming, live speech-to-text, Private Cloud Compute, and hybrid routing to Gemini or ChatGPT.
0.1.1 #
Added #
FoundationModelsRoutingPolicy.privateCloudFirst(): prefers Apple Private Cloud Compute (iOS 27+) with optional fallback to the Apple local model and to the external provider.
Changed #
- Live transcription locale matching: regional locales such as
es_COoren_AUnow match any supported variant of the same language, so they keep the modernSpeechAnalyzerengine instead of silently falling back to the legacySFSpeechRecognizerengine. Only truly unsupported languages fall back. - Example app: added a backend selector in the AppBar (Auto hybrid / Apple on-device / Private Cloud Compute / Gemini), rewrote the session instructions to allow complete same-language answers, raised the token limit, and used the device locale for orchestration and live transcription defaults with an on-screen caption showing the active speech engine.
Fixed #
- Streaming generation no longer hangs after the first completion. The native event channel never emitted end-of-stream, so
FoundationModelsChatSession.sendStream()awaited forever and chat UIs stayed locked in a sending state. The native side now closes the event channel after completion and error events, and the Dart stream also closes defensively when a completion or failure event arrives. - The iOS plugin now compiles with both Xcode 26 and Xcode 27 beta. The Swift 6.4 compiler (iOS 27 SDK) renamed the
GenerationOptionsinitializer label fromsampling:tosamplingMode:, and the plugin previously used a single label unconditionally, so the build failed on the toolchain that did not match it. The initializer call is now selected with#if compiler(>=6.4): Xcode 27 builds usesamplingMode:(plustoolCallingMode:when running on iOS 27), and older toolchains keep the iOS 26 SDK labelsampling:. No Dart API changes; generation options (sampling mode, temperature, and maximum response tokens) behave the same on every supported toolchain.
0.1.0 #
Hybrid orchestration and live speech release. All changes are additive; no existing public API changed.
Added #
FoundationModelsOrchestratorfor local-only, Apple-first, external-first, and hybrid routing between Apple Foundation Models and an app-provided external provider such as Gemini, ChatGPT, or a custom backend.FoundationModelsChatSessionthroughorchestrator.startChat(): a multi-turn hybrid chat that reuses one persistent native Apple session and replays the shared history to external providers throughFoundationModelsRequest.history, so the conversation survives fallback between local and remote routes.FoundationModelsChatSession.sendStream()withOrchestratedChatTextEventandOrchestratedChatCompletionEventfor streaming chat UIs.FoundationModelsChatMessageandFoundationModelsChatRoleto model conversation turns shared across providers.FoundationModelsExternalProvider.respondStream()so external adapters can stream cumulative text snapshots; the default implementation emits one snapshot fromrespond().- Live microphone transcription:
CupertinoFoundationModels.liveTranscription()returns aStream<LiveTranscriptionEvent>of partial and final speech-to-text snapshots, backed by a new nativeLiveTranscriptionService(AVAudioEngine+ Apple Speech) and a dedicated event channel. Cancelling the subscription stops the microphone. LiveTranscriptionRequestandLiveTranscriptionEventtypes.- Optional external provider adapter contracts for text generation and audio transcription.
- Runtime context generation (
buildRuntimePromptContext()) so a larger app orchestrator can know when Apple local and Private Cloud Compute routes are available. - API documentation across the public surface.
- Swift Package Manager support for the iOS plugin (hybrid layout: SPM and CocoaPods both supported), including a
PrivacyInfo.xcprivacyprivacy manifest. - Native tool calling: tools declared with
ModelToolare now registered on the nativeLanguageModelSession; the on-device or PCC model calls back into Dart through the method channel, with per-tool timeouts enforced in Dart. - Native guided structured generation:
generateStructured()now builds a realDynamicGenerationSchema/GenerationSchemafrom the DartStructuredSchemaand returns the model-validated JSON instructuredValue(previously the schema was ignored). SessionOptions.useCasewithFoundationModelsUseCase.contentTaggingto use Apple's specialized content-tagging on-device model.FoundationModelSession.prewarm()now calls the nativeprewarm(promptPrefix:)to preload model resources for lower first-token latency.FoundationModelSession.cancelActiveRequest()now cancels the in-flight native respond, structured, or streaming request; cancellations map to thecancellederror code.- Live microphone transcription now prefers the modern
SpeechAnalyzer/SpeechTranscriberpipeline on iOS 26+, with on-device asset management and automatic fallback toSFSpeechRecognizeron older systems, unsupported locales, or explicit server mode. Event metadata reports which engine was used.
Changed #
- Example app rewritten as a chat: streaming message bubbles, conversation context, live microphone transcription into the input field, image attachments, a demo
get_current_timetool, and an optional Gemini fallback enabled with--dart-define=GEMINI_API_KEY=your_key. - pub.dev metadata: tuned package description and topics for discoverability.
Fixed #
- Concurrent generation streams no longer cancel each other: native stream tasks are now tracked per session instead of a single shared task.
0.0.2 #
- Marked the package as iOS-only in
pubspec.yaml. - Added pub.dev metadata for repository, issues, documentation, topics, and platform support.
- Expanded the README with iOS-only support, conversation context, advanced example links, source code links, and the agent skill guide.
- Expanded the example README so pub.dev can display a useful Example tab while still linking to
example/lib/main.dart. - Removed generated test scaffolding to comply with the repository rule of not creating tests.
0.0.1 #
- Initial release of Cupertino Foundations Models.
- Added the Dart API surface for capabilities, diagnostics, availability, sessions, generation, streaming, schemas, tools, file selection, audio transcription, and typed errors.
- Added the iOS plugin shell with MethodChannel, EventChannel, session registry, availability service, document picker, Speech transcription service, and Foundation Models text generation hooks.
- Added local conversation context through reusable
FoundationModelSessionhandles. - Added iOS 27 hooks for image attachments, reasoning options, usage metadata, and Private Cloud Compute availability.