-
-
Notifications
You must be signed in to change notification settings - Fork 12.9k
♻️ refactor(google-genai): migrate from @google/generative-ai to @google/genai #7954
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
@kingsword09 is attempting to deploy a commit to the LobeHub Team on Vercel. A member of the Team first needs to authorize it. |
Thank you for raising your pull request and contributing to our Community |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
This PR migrates LobeChat's Google AI integration from deprecated packages to the new @google/genai
SDK, ensuring compatibility with Gemini 2.0 and Vertex AI express mode before the August 2025 deprecation deadline.
- Updated
package.json
to replace@google/generative-ai
and@google-cloud/vertexai
with@google/[email protected]
- Modified stream handling in
src/libs/model-runtime/utils/streams/google-ai.ts
to use direct property access instead of method calls - Updated error handling and type definitions in
src/libs/model-runtime/google/index.ts
to match new SDK structure - Added support for Vertex AI express mode with apiKey-based authentication in
src/libs/model-runtime/vertexai/index.ts
- Enhanced test coverage in
google-ai.test.ts
andindex.test.ts
to verify compatibility with new API structure
💡 (3/5) Reply to the bot's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!
7 file(s) reviewed, 4 comment(s)
Edit PR Review Bot Settings | Greptile
try { | ||
const client = new VertexAI({ ...params }); | ||
const client = new GoogleGenAI({ ...params }); | ||
|
||
return new LobeGoogleAI({ apiKey: 'avoid-error', client, isVertexAi: true }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Consider removing hardcoded 'avoid-error' API key and use a more descriptive placeholder or handle this differently
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure this should be changed.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #7954 +/- ##
==========================================
+ Coverage 88.47% 95.67% +7.20%
==========================================
Files 821 14 -807
Lines 60274 2519 -57755
Branches 3806 444 -3362
==========================================
- Hits 53325 2410 -50915
+ Misses 6949 109 -6840
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Are there any duplication of work? |
Didn't notice 😂 |
💻 变更类型 | Change Type
🔀 变更说明 | Description of Change
Update the codebase to use the new @google/genai package, replacing @google/generative-ai and @google-cloud/vertexai.
closes: #7735
📝 补充信息 | Additional Information