flutter_foundation_models 0.3.0
flutter_foundation_models: ^0.3.0 copied to clipboard
Flutter plugin for Apple's on-device Foundation Models. Generate text, structured output, and use tools with the on-device language model.
0.3.0 #
Breaking Changes #
respondTo()now returnsTextResponseinstead ofString- Use
response.contentto get the text - Also provides
response.transcriptEntriesfor entries created during this response
- Use
respondToWithSchema()now returnsStructuredResponseinstead ofGeneratedContent- Use
response.contentto get the generated content - Also provides
response.rawContentandresponse.transcriptEntries
- Use
New Features #
- Response wrappers -
TextResponseandStructuredResponseprovide content plus metadata - List generation - Generate arrays of @Generable types
GenerationSchema.array(schema)- Create array schema from item schemacontent.toList(fromContent)- Convert array content to typedList<T>content.toPartialList(fromPartialContent)- For streaming arrays
- Generation errors - Typed
GenerationExceptionmatching Swift'sGenerationErrorGenerationErrorTypeenum with all Swift error typesdebugDescriptionfor additional debugging info
0.2.2 #
- Transcript support - Access conversation history and continue sessions
session.transcript- Get the current conversation transcriptLanguageModelSession.createWithTranscript()- Create a session from a previous transcriptTranscript.toJson()/Transcript.fromJson()- Serialize/deserialize transcripts- Type-safe transcript entries:
TranscriptPrompt,TranscriptResponse,TranscriptToolCalls,TranscriptToolOutput,TranscriptInstructions
0.2.1 #
- Update documentation
0.2.0 #
Breaking Changes #
LanguageModelSessionnow uses async factory methodLanguageModelSession.create()instead of constructor- Moved
isAvailablefromLanguageModelSessiontoSystemLanguageModel.isAvailable
New Features #
- Swift Package Manager support - Plugin now supports both SPM and CocoaPods
- SystemLanguageModel class - Manage language models with configuration options
SystemLanguageModel.defaultModel- Access the default system modelSystemLanguageModel.create()- Create custom model with adapter, useCase, or guardrailsSystemLanguageModel.isAvailable- Check if Foundation Models API is availableSystemLanguageModel.availability- Get detailed availability info with unavailability reason
- Adapter support - Load custom adapters
Adapter.create(name:)- Create adapter by nameAdapter.fromAsset(assetPath)- Create adapter from Flutter asset
- UseCase configuration -
UseCase.generalandUseCase.contentTagging - Guardrails configuration -
Guardrails.defaultGuardrailsandGuardrails.permissiveContentTransformations - Text streaming -
streamResponseTo()for plain text streaming without schema - Session prewarm -
session.prewarm()to reduce latency on first request - Session state -
session.isRespondingto check if session is actively generating
0.1.1 #
- Add runtime availability check with
LanguageModelSession.isAvailable() - Lower minimum iOS version to 16.0 (API requires iOS 26+ at runtime)
- Improve documentation
- Clean up published package (exclude unnecessary example files)
0.1.0 #
- Initial release
- Text generation with
respondTo() - Structured output with
respondToWithSchema() - Streaming support with
streamResponseToWithSchema() - Tool use support
- Generation options (sampling mode, temperature, max tokens)
- System instructions support
- Availability checking with
LanguageModelSession.isAvailable() - Supports iOS 16+ (Foundation Models API requires iOS 26+ at runtime)