flutter_ai_provider_gemini 0.1.13
flutter_ai_provider_gemini: ^0.1.13 copied to clipboard
Google Gemini LlmProvider for flutter_ai: streams text, thinking, function calls, and Google Search grounding citations as flutter_ai_core AiStreamEvents.
Changelog #
0.1.13 #
- Formatting-only: reflow
gemini_event_parser.darttodart formatstyle (no behavior change). Restores the pub.dev static-analysis score.
0.1.12 #
- Fix: a mid-stream
errorpayload is now surfaced as aStreamErrorEvent, and a blocked prompt (promptFeedback.blockReason) finishes as content-filtered — instead of both being ignored and rendered as an empty, successful message. - Fix: tool results delivered across consecutive tool messages (one result per
message) are no longer dropped — they coalesce into a single
functionResponseturn in call order. - Fix:
reasoningEffortnow also setsthinkingConfig.includeThoughts, so the paid thinking is actually surfaced asReasoningDeltas instead of being invisible.
0.1.11 #
- Map
AiRequestOptions.reasoningEfforttogenerationConfig.thinkingConfig. thinkingBudget. Requiresflutter_ai_core^0.1.13.
0.1.10 #
- Fix (Web): the default HTTP client now streams token-by-token on Flutter Web.
http.Client()resolves to the XHR-backedBrowserClienton the web, which buffers the entire response body before the stream emits — silently degrading streaming to all-at-once. The default is now afetch-based client (via a conditional import) that reads the responseReadableStreamincrementally. Native platforms are unchanged. Inject your ownclientto override.
0.1.9 #
- Fix: raise the
flutter_ai_corelower bound to^0.1.11— the parser emitsAiUsage(added in core 0.1.3) and later APIs, so the old^0.1.0bound let dependency downgrades resolve a core that couldn't compile. - Docs: shortened the pubspec
descriptioninto pub.dev's 60–180 character window.
0.1.8 #
- Docs: refreshed the README listing with a hero image, screenshot gallery, and badges (consistent across the package family). No code changes.
0.1.7 #
- Implements
EmbeddingProvider(embed→batchEmbedContents, defaulttext-embedding-004) andTokenCounter(countTokens→ thecountTokensendpoint, reusing the request content mapping).
0.1.6 #
- Tool correlation:
functionResponseparts are now emitted in the same order as their turn'sfunctionCalls and keyed by name, so two calls to the same tool in one turn line up with their own results (Gemini matches by name+position, having no id channel). Synthesized call ids are order-distinct. - Declares supported
platforms:(all 6).
0.1.5 #
- Throws typed
LlmExceptions (auth/rate-limit/server/request) on HTTP errors instead of a genericException; retries 408/409 too.
0.1.4 #
- A mid-stream stall surfaces a message-scoped
StreamErrorEventinstead of also finalizing (which masked the timeout). - Asserts a non-empty
apiKeywith an actionable message.
0.1.3 #
- Structured output: maps
AiRequestOptions.responseFormattogenerationConfig.responseSchema+responseMimeType: application/json.
0.1.2 #
- Reports token usage: parses
usageMetadata(prompt/candidates/total, cached content + thoughts tokens) intoAiUsageonMessageFinished.
0.1.1 #
- Docs: added a "Buy me a coffee" (Ko-fi) support section to the README. No code changes.
0.1.0 #
Initial release.
GeminiProvider— anLlmProviderfor the native Gemini API (models/{model}:streamGenerateContent), with an injectable HTTP client and a configurable default model (gemini-2.5-flash).- Supports Google Search grounding (
enableGrounding): grounded answers stream their web sources back asSourcePartcitations. - Maps conversations to Gemini's wire format: system →
systemInstruction, assistant tool calls →functionCall, tool results →functionResponse(function name recovered from the matching call). Streams text, thinking, function calls, citations, and finish reasons asAiStreamEvents. GeminiEventParser— the chunk→event mapping, unit-tested against recorded SSE.- Robustness: configurable connect + idle
timeout(a stalled stream surfaces aStreamErrorEventinstead of hanging); a wrong-shape chunk emits aStreamErrorEventinstead of crashing the stream;close()only closes a client it created; retry backoff is now capped and jittered. When function tools andenableGroundingare both set, grounding is omitted (the API rejects combining them) rather than 400-ing. - Re-exports
flutter_ai_core.
The mapping is unit-tested against recorded SSE chunks; it has not been run against the live Gemini API in this release.