-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat: migrate to new google-genai SDK with Gemini 3 support #417
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?
feat: migrate to new google-genai SDK with Gemini 3 support #417
Conversation
- Migrate from deprecated google-generativeai to google-genai SDK - Add support for thinking_level config (Gemini 3 models) - Update default model to gemini-3-flash-preview with thinking_level: high - Update embedder to use gemini-embedding-001 (replacing deprecated text-embedding-004) - Set embedding output_dimensionality to 3072 for optimal quality - Remove unused google.generativeai imports from api.py and main.py - Update pyproject.toml dependencies Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
…ct architecture - Added 5 new documentation files in .ai/docs/ directory covering: - API analysis: Complete overview of FastAPI endpoints, authentication, and external dependencies - Data flow analysis: Data models, Pydantic schemas, and information flow patterns - Dependency analysis: External service integrations and configuration requirements - Request flow analysis: End-to-end request processing and streaming implementation - Structure analysis: High-level system architecture and component interactions These AI-generated docs provide developers with a comprehensive understanding of the project's architecture, API contracts, data models, and integration patterns, serving as both onboarding material and architectural reference documentation.
Summary of ChangesHello @quantmind-br, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly upgrades the project's integration with Google's Generative AI services by adopting the latest Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Remove CLAUDE.md, AGENTS.md, and .ai/docs/ as these are project-specific configuration files not suitable for upstream. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
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.
Code Review
This pull request primarily focuses on updating the Google Generative AI integration, migrating from the deprecated google-generativeai SDK to the newer google-genai SDK for LLM generation. This involved updating api/pyproject.toml and api/poetry.lock to include the new SDK and update related dependencies, removing global configuration in api/main.py, and modifying api/simple_chat.py and api/websocket_wiki.py to use the new client instantiation pattern, including support for thinking_level in Gemini 3 models. The default Google model in api/config/generator.json was updated to gemini-3-flash-preview, and the Google embedder model in api/config/embedder.json was changed to gemini-embedding-001 with added output_dimensionality. Additionally, the pull request introduces extensive new documentation files under .ai/docs/ covering API analysis, data flow, dependency analysis, and request flow, along with new .cursor/rules/ files defining backend, frontend, and project overview conventions, and AGENTS.md and CLAUDE.md for AI agent configuration. Review comments suggest updating the example model in api_analysis.md to reflect the new gemini-3-flash-preview default and clarifying the documentation in api_analysis.md to distinguish between the new google-genai for generation and the continued use of google-generativeai for embeddings, and to fully migrate the embedder client to google-genai for consistency.
I am having trouble creating individual review comments. Click here to see my feedback.
api/pyproject.toml (15-16)
The PR description states that it migrates from the deprecated google-generativeai SDK to the new google-genai. However, google-generativeai is still listed as a dependency and has been updated. The google_embedder_client.py file still uses this deprecated package.
For consistency and future-proofing, it would be best to migrate the embedder client to the new google-genai SDK as well and remove the google-generativeai dependency entirely. This would complete the migration and align with the goal of moving away from the deprecated package.
.ai/docs/api_analysis.md (55)
The documentation mentions gemini-2.5-flash as an example model. Since this PR updates the default model to gemini-3-flash-preview, it would be good to update this example to reflect the new default.
"models": [{"id": "gemini-3-flash-preview", "name": "gemini-3-flash-preview"}]
.ai/docs/dependency_analysis.md (35-49)
The documentation lists google-generativeai as the dependency for LLM SDKs and Gemini models. This PR migrates to the new google-genai SDK for generation. The documentation should be updated to reflect this change. While google-generativeai is still used for embeddings, google-genai should be listed as the primary SDK for generation.
- Migrate GoogleEmbedderClient from deprecated google-generativeai to google-genai SDK - Use new client.models.embed_content() API with EmbedContentConfig - Remove google-generativeai dependency entirely from pyproject.toml - Update poetry.lock to remove deprecated package This completes the SDK migration, ensuring consistency across all Google AI integrations (both generation and embeddings now use google-genai). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
|
seems like we still have dependency from adalflow? |
…mpatibility The adalflow framework's GoogleGenAIClient still requires the deprecated google-generativeai package internally. This is a temporary dependency until adalflow migrates to the new google-genai SDK. Our custom code (simple_chat.py, websocket_wiki.py, google_embedder_client.py) uses the new google-genai SDK directly. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
|
Thanks for catching this @secret104278! Root cause: The Solution: I've added Important clarification: Our custom code ( The |
Summary
This PR completely migrates the Google Generative AI integration from the deprecated
google-generativeaiSDK to the new officialgoogle-genaiSDK, covering both LLM generation and embeddings.Key Changes
🔄 SDK Migration (Complete)
google-generativeaiwithgoogle-genaiSDK across all files:simple_chat.py- LLM generationwebsocket_wiki.py- LLM generationgoogle_embedder_client.py- Embeddingsgoogle-generativeaidependency entirely frompyproject.toml🧠 Gemini 3 Thinking Support
thinking_levelconfiguration parameter for Gemini 3 modelsLOW,MEDIUM, andHIGHthinking levels viaThinkingConfiggemini-3-flash-previewwiththinking_level: high📊 Embedding Model Update
text-embedding-004togemini-embedding-001output_dimensionality: 3072for optimal embedding qualityGoogleEmbedderClientto use newclient.models.embed_content()APIConfiguration Changes
generator.json
{ "google": { "default_model": "gemini-3-flash-preview", "models": { "gemini-3-flash-preview": { "temperature": 1.0, "top_p": 0.8, "top_k": 20, "thinking_level": "high" } } } }embedder.json
{ "google": { "model_kwargs": { "model": "gemini-embedding-001", "task_type": "SEMANTIC_SIMILARITY", "output_dimensionality": 3072 } } }Why This Change?
google-generativeaipackage is being deprecated in favor ofgoogle-genaiFiles Changed
api/simple_chat.pyapi/websocket_wiki.pyapi/google_embedder_client.pyapi/config/generator.jsonapi/config/embedder.jsonapi/pyproject.tomlgoogle-generativeaiapi/poetry.lockapi/api.py,api/main.py.cursor/rules/*Test Plan
thinking_levelvaluesgoogle-generativeai🤖 Generated with Claude Code