apple_foundation_models 0.2.1
apple_foundation_models: ^0.2.1 copied to clipboard
Run Apple's on-device language model from Flutter. Streaming, tool calling, and schema-constrained structured output — private, offline, and free.
0.2.1 #
Documentation only — no API changes.
- README code blocks now parse. Several listed variants one per line without terminating semicolons, so copying a block gave a syntax error even though each individual line was fine. Every snippet in this README is now checked through the analyser.
0.2.0 #
Renamed LoadingStreamDeltas to ModelStreamDeltas. The old name was
copy-paste from a sibling package and had nothing to do with loading anything.
It matters more than a private misnomer would: this is an extension on
Stream<String>, so importing this package put that wrong name into the tools
of anyone with a string stream anywhere in their app.
Nothing about the behaviour changed, and deltas() is called the same way. You
would only notice if you had written the extension name explicitly, which is
rare — but it is a breaking change, so it gets a minor bump.
- The transcript API is documented now.
session.transcript()andTranscriptRolewere public and appeared in neither the README nor the example, so reading back what a session was told meant reading the source.
0.1.2 #
Packaging only — no API or behaviour changes.
- The demo animations now ship inside the package, so they appear as screenshots on the pub.dev page rather than only in the README on GitHub.
.pubignoreexcludes the raw recorder frames, so shipping them costs about 360 KB rather than the 11 MB the frame directory would have added.
0.1.1 #
Fixes a macOS build failure under Swift Package Manager.
Package.swift declared only .iOS("15.0") and no macOS platform. SPM defaults
an undeclared platform to macOS 10.13, where Swift concurrency's Task does not
exist, so the plugin failed to compile with 'Task' is only available in macOS 10.15 or newer. The podspec had always said osx 10.15, so CocoaPods builds
were unaffected and the two paths disagreed — and SPM is on by default on
current Flutter, so most macOS users would have hit this.
No API changes.
0.1.0 #
Initial release.
-
Generation guides:
Schema.integer(min:, max:),Schema.number(min:, max:),Schema.string(pattern:),Schema.array(exactItems:). Bounds constrain generation itself, so a 1-to-5 rating cannot come back as 47. -
respondInto/streamIntodecode straight into your own types. -
deltas()turns cumulative snapshots into increments. -
ModelUseCase.contentTaggingselects Apple's tagging-tuned model. -
AppleFoundationModels.supportedLanguages()andavailabilityChanges, the latter firing when the model finishes downloading mid-session. -
AppleFoundationModels.availability()with typed reasons —deviceNotEligible,appleIntelligenceNotEnabled,modelNotReady,osTooOld,unsupportedPlatform— each carrying an explanation and, where one exists, a remedy. -
LanguageModelSessionwith instructions, transcript,prewarm, andisResponding. -
Four response modes:
respond,respondAs(schema-constrained),stream, andstreamAs(structured output arriving progressively). -
A Dart schema DSL — objects, arrays, enums, optional fields — rebuilt natively as a
DynamicGenerationSchema, so typed output needs no codegen. -
Tool calling: the model invokes a Dart function mid-generation and waits for the result.
-
GenerationOptionswith temperature, token cap, and greedy / top-k / top-p sampling. -
Every framework error mapped to its own exception type.
-
Compiles and runs on every platform. Non-Apple targets report
unsupportedPlatforminstead of failing the build, and an Xcode without the iOS 26 SDK still compiles.