refactor(llm): add AI SDK, reroute Gemini calls to it
From the PR description
Motivation
Provide the plumbing needed to interact with providers through Vercel's
AI SDK. Use it to direct Gemini-driven completeText() calls
(mostly invoked for titles and summaries)
Provide an implementation for stream chat with tools using AI SDK, wiring Gemini calls to this. Take reference from the other LLM integrations and faithfully reproduce impl as close as possible.
Define
MODEL_PROVIDER_CONFIGS, each Provider mapping to:- a AI SDK ProviderV3 factory function
- the Provider default API key, or an empty str if not set
- the env var name for the key, for error messages
Implement
resolveModel(), using the aboveReplace the
geminibranch ofcompleteText()with the fallthrough toresolveModel()andgenerateText()Map
streamChatWithTools()tostreamText()- Wire all relevant events from the stream to callbacks
- Collate full text response as well as all tool calls
- Append
assistantandtoolmessages at the end
Part 1/3 for #160
Our analysis
Wire Gemini through the Vercel AI SDK — read the full analysis →
Think the analysis missed something the PR description covers?
Capture this PR into my fork
Download a Markdown prompt that tells Claude how to port every
commit in this PR into your working tree. Run it via
claude -p < capture-pull-165.md from
inside the repo you want the changes in.