Skip to content

refactor(deps): migrate ai sdk to v7 - #1825

Merged
zhangmo8 merged 1 commit into
devfrom
refactor/ai-sdk-v7
Jun 26, 2026
Merged

refactor(deps): migrate ai sdk to v7#1825
zhangmo8 merged 1 commit into
devfrom
refactor/ai-sdk-v7

Conversation

@yyhhyyyyyy

@yyhhyyyyyy yyhhyyyyyy commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • Upgraded the app’s AI SDK packages to newer versions, including the main AI library and related provider integrations.
    • Updated AI request handling to use the latest prompt and streaming behavior for more consistent responses.
  • Bug Fixes

    • Improved Gemini and AWS Bedrock provider setup for better compatibility.
    • Refined streaming output handling and response usage tracking to better match returned results.
  • Tests

    • Updated automated tests to reflect the latest AI SDK behavior and response formats.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6165f968-14d2-4ef3-bdb7-50a38a35f16e

📥 Commits

Reviewing files that changed from the base of the PR and between 1d1d896 and 30e2583.

📒 Files selected for processing (6)
  • package.json
  • src/main/presenter/llmProviderPresenter/aiSdk/providerFactory.ts
  • src/main/presenter/llmProviderPresenter/aiSdk/runtime.ts
  • src/main/presenter/llmProviderPresenter/aiSdk/streamAdapter.ts
  • test/main/presenter/llmProviderPresenter/aiSdkProviderFactory.test.ts
  • test/main/presenter/llmProviderPresenter/aiSdkRuntime.test.ts

📝 Walkthrough

Walkthrough

Updated AI SDK package versions and aligned provider construction, prompt propagation, response mapping, and stream consumption with the newer SDK API shapes. Tests were updated to match the new request and result fields.

Changes

AI SDK upgrade and API alignment

Layer / File(s) Summary
Dependency versions
package.json
ai and the @ai-sdk/* packages are bumped to newer pinned releases.
Provider wiring
src/main/presenter/llmProviderPresenter/aiSdk/providerFactory.ts, test/main/presenter/llmProviderPresenter/aiSdkProviderFactory.test.ts
Gemini uses createGoogle, Bedrock calls provider.embeddingModel(...) and provider.imageModel(...) directly, and the Gemini test iterates result.stream.
Runtime prompt and stream flow
src/main/presenter/llmProviderPresenter/aiSdk/runtime.ts, src/main/presenter/llmProviderPresenter/aiSdk/streamAdapter.ts, test/main/presenter/llmProviderPresenter/aiSdkRuntime.test.ts
Leading system messages become instructions, generate and stream calls pass instructions, runAiSdkGenerateText maps reasoning_content and totalUsage from result.finalStep.reasoningText and result.usage, and the runtime tests assert the updated request and result shapes.

Sequence Diagram(s)

sequenceDiagram
  participant splitLeadingSystemMessagesForAiSdk
  participant buildPromptRuntime
  participant runAiSdkGenerateText
  participant generateText
  participant runAiSdkCoreStream
  participant streamText
  participant adaptAiSdkStream

  splitLeadingSystemMessagesForAiSdk->>buildPromptRuntime: instructions
  buildPromptRuntime->>runAiSdkGenerateText: runtime.instructions, messages, tools
  runAiSdkGenerateText->>generateText: instructions option
  generateText-->>runAiSdkGenerateText: result.finalStep.reasoningText, result.usage
  buildPromptRuntime->>runAiSdkCoreStream: runtime.instructions, messages, tools
  runAiSdkCoreStream->>streamText: instructions option
  streamText-->>runAiSdkCoreStream: result.stream
  runAiSdkCoreStream->>adaptAiSdkStream: result.stream
  adaptAiSdkStream-->>runAiSdkCoreStream: LLMCoreStreamEvent
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

I hopped through the SDK with a twitch of my nose,
New instructions in tow where the old system goes.
Gemini sparkled, Bedrock thumped in the rain,
I streamed every carrot of token and strain.
Thump! The moonlit logs sing: "all green again." 🐰

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: migrating the AI SDK dependency and related code to v7.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/ai-sdk-v7

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@zhangmo8
zhangmo8 merged commit 209369d into dev Jun 26, 2026
3 checks passed
@zhangmo8
zhangmo8 deleted the refactor/ai-sdk-v7 branch June 26, 2026 11:43
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.

2 participants