flutter_ai_provider_openai 0.1.11
flutter_ai_provider_openai: ^0.1.11 copied to clipboard
OpenAI-compatible LlmProvider for flutter_ai: streams Chat Completions (text, tool calls, finish reasons) as flutter_ai_core AiStreamEvents over an injectable HTTP client.
Changelog #
0.1.11 #
- Fix:
maxOutputTokensnow maps tomax_completion_tokensinstead of the deprecatedmax_tokens, which reasoning models (o-series, gpt-5) reject with a- A caller targeting an older OpenAI-compatible endpoint can still pass
max_tokensviaextra.
- A caller targeting an older OpenAI-compatible endpoint can still pass
- Fix: a mid-stream
{"error": ...}chunk is now surfaced as aStreamErrorEventinstead of being ignored (which left an empty, apparently successful message).
0.1.10 #
- Map
AiRequestOptions.reasoningEffortto OpenAI'sreasoning_effort. An explicitreasoning_effortinextrastill takes precedence. Requiresflutter_ai_core^0.1.13.
0.1.9 #
- 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.8 #
- 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.
0.1.7 #
- Docs: refreshed the README listing with a hero image, screenshot gallery, and badges (consistent across the package family). No code changes.
0.1.6 #
- Implements
EmbeddingProvider:embed(inputs, {model})POSTs/embeddings(defaulttext-embedding-3-small) and returnsAiEmbeddingvectors. - 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 #
- Readies tool calls on any finish reason (and in
finalize()), so calls can't hang ininputStreaming. - A mid-stream stall now surfaces a message-scoped
StreamErrorEventinstead of also finalizing a terminal event that masked the timeout. - Asserts a non-empty
apiKeywith an actionable message.
0.1.3 #
- Structured output: maps
AiRequestOptions.responseFormatto ajson_schemaresponse_format(withstrict).
0.1.2 #
- Reports token usage: sets
stream_options.include_usageand parses the trailing usage chunk (prompt/completion/total, cached + reasoning token details) 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.
OpenAiProvider— anLlmProviderfor the OpenAI Chat Completions API (or any OpenAI-compatible endpoint via a custom base URL), with an injectable HTTP client and a configurable default model.- Maps conversations (system/user/assistant/tool messages, assistant tool calls,
tool results) into the request, and streams text, tool calls, and finish
reasons back as
AiStreamEvents. OpenAiChunkParser— 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. - Re-exports
flutter_ai_core.
The mapping is unit-tested against recorded SSE chunks; it has not been run against the live OpenAI API in this release.