Skip to content

refactor(llm): add AI SDK, reroute Gemini calls to it#165

Open
LoneRifle wants to merge 3 commits into
willchen96:mainfrom
LoneRifle:refactor/ai-sdk/google
Open

refactor(llm): add AI SDK, reroute Gemini calls to it#165
LoneRifle wants to merge 3 commits into
willchen96:mainfrom
LoneRifle:refactor/ai-sdk/google

Conversation

@LoneRifle
Copy link
Copy Markdown

@LoneRifle LoneRifle commented May 31, 2026

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 above

  • Replace the gemini branch of completeText() with the fallthrough
    to resolveModel() and generateText()

  • Map streamChatWithTools() to streamText()

    • Wire all relevant events from the stream to callbacks
    • Collate full text response as well as all tool calls
    • Append assistant and tool messages at the end

Part 1/3 for #160

@LoneRifle LoneRifle force-pushed the refactor/ai-sdk/google branch 3 times, most recently from 54d5922 to e67cd29 Compare May 31, 2026 13:03
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)

- 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 above
- Replace the `gemini` branch of `completeText()` with the fallthrough
  to `resolveModel()` and `generateText()`
@LoneRifle LoneRifle force-pushed the refactor/ai-sdk/google branch 10 times, most recently from f1c5121 to e1f172c Compare May 31, 2026 14:28
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.

To discuss - at the end, all models would append responses to
what effectively are transformed copies of `params.messages`,
although the intent of that is uncertain.

- Map `streamChatWithTools()` to `streamText()`
  - Wire all relevant events from the stream to callbacks
  - Collate full text response as well as all tool calls
  - Append `assistant` and `tool` messages at the end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant