flutter_ai_core 0.1.13
flutter_ai_core: ^0.1.13 copied to clipboard
Dependency-free Dart foundation for AI chat: message models, a streaming MessageProcessor, and the provider and renderer contracts the flutter_ai family builds on.
Changelog #
0.1.13 #
ReasoningEffort(minimal/low/medium/high) +AiRequestOptions.reasoningEffort: a provider-neutral knob for how hard a reasoning model should think. ExposesbudgetTokens(a canonical effort→budget heuristic) andopenAiValuefor providers to map onto their native control. Additive and opt-in.
0.1.12 #
- Docs: shortened the pubspec
descriptioninto pub.dev's 60–180 character window so it renders in full in search results. No code changes.
0.1.11 #
- Docs: refreshed the README listing with a hero image, screenshot gallery, and badges (consistent across the package family). No code changes.
0.1.10 #
- New AI primitives (opt-in, additive):
EmbeddingProvider/AiEmbeddingandTokenCountercapability interfaces a provider may implement (check withprovider is ...).GenerateObjectextension onLlmProvider:generateObjectreturns a decodedMapconstrained to anAiResponseFormat;streamObjectyields the evolving partial object as it streams (viaJsonAccumulator).
0.1.9 #
validateJsonSchema: a tiny, dependency-free validator for the JSON-Schema subset LLM tool declarations use (type,properties,required,items,enum,additionalProperties: false, numeric/string/array bounds, union types). Returns human-readable violation messages.UseChatControlleruses it to validate tool-call args before execution.
0.1.8 #
- Perf: streaming text/reasoning deltas accumulate into a per-part
StringBufferand materialize theStringlazily, instead oflast.text + deltareallocating the whole answer on every token (was quadratic on long responses — the hottest path in the stack). Observably identical:TextPart.text/ReasoningPart.textstill return a plainString. AiUsage.cacheCreationTokens: carries prompt-cache write tokens (a subset ofinputTokens) distinctly;estimateCostbills them atcacheWritePer1M(defaulting to1.25 * inputPer1M) so cache writes aren't billed at the base input rate.- Declares supported
platforms:(all 6).
0.1.7 #
- Typed errors:
LlmExceptionhierarchy (LlmAuthException,LlmRateLimitException,LlmServerException,LlmRequestException) + allmExceptionFormapper, surfaced onStreamErrorEvent.errorso hosts can branch on the failure type instead of string-matching.
0.1.6 #
ReasoningPart/ReasoningDeltagain an optionalsignature(preserved and replayed so providers like Anthropic accept thinking blocks on tool rounds).MessageProcessorkeeps the last good partial tool-call args instead of clobbering them to{}mid-stream.
0.1.5 #
AiRequestOptions.cachePrompt: hint that the stable prompt prefix (system + tools) should be cached. Anthropic appliescache_control; OpenAI/Gemini cache automatically (no-op).
0.1.4 #
AiResponseFormat(+AiRequestOptions.responseFormat): request structured output constrained to a JSON schema. Providers route it to their native mechanism; the assistant's text is the JSON object.
0.1.3 #
AiUsagemodel (input/output/cached/reasoning/total tokens) with+to accumulate andestimateCost(...)for cost from per-million prices. Carried onMessageFinishedand stored on the completedAiMessage; the processor applies it on finish.
0.1.2 #
- Docs: added a "Buy me a coffee" (Ko-fi) support section to the README. No code changes.
0.1.1 #
Bug fixes in MessageProcessor:
- Zero-argument tool calls (a
ToolCallReadywith no streamed arguments) now resolve to empty args +inputAvailableinstead of being marked errored. - A
ToolResultReceivedwhosemessageIddiffers from the call's message (the normal case — results arrive in a separate tool-role message) now correctly advances the original call tooutputAvailable. - A tool-scoped
StreamErrorEvent(withtoolCallId) now marks only that call errored and lets generation continue, instead of failing the whole message — matchingUseChatController. - Doc fix: corrected a stale reference to
flutter_markdown_plus. JsonAccumulatorno longer surfaces an unterminated trailing number/keyword (e.g.1234from{"n": 1234) as a complete value — a literal must be delimiter-terminated, preserving the "a partial is always a prefix" contract.MessageProcessorresolves a tool result to its owning call by scanning the conversation when the in-memory map misses (afterreset()/rehydration).deepHashuses order-independent hashing for maps (better distribution).
0.1.0 #
Initial release.
- Models:
AiConversation,AiMessage,AiMessageStatus,AiRole,FinishReason, and the sealedAiParthierarchy (TextPart,ReasoningPart,ToolCallPart,ToolResultPart,FilePart,SourcePart,DataPart) with manual JSON serialization and value equality. - Streaming: sealed
AiStreamEventset,MessageProcessorreducer with granularMutationResults, and the tolerantJsonAccumulatorfor partial tool-call arguments. - Contracts:
LlmProvider,TextRenderer,AiRequestOptions,ToolDefinition. - Zero runtime dependencies (
dart:core+dart:convertonly).