[Feature] Add Gemini 3 thinking levels and improve model detection#647
Conversation
…factor model detection Add support for tiny, low, medium, and high thinking levels for Gemini 3 models. Refactor model name patterns from 'gemini-3.0' to 'gemini-3' for better version matching. Move model type arrays outside the loop for improved performance. - Add tiny-thinking, low-thinking, and high-thinking variants for gemini-3-pro - Refactor thinking level extraction to handle tiny mode with budget 128 - Update model name patterns to use 'gemini-3' instead of 'gemini-3.0' - Move model type constant arrays outside of the model iteration loop - Bump adapter-gemini version from 1.3.11 to 1.3.12
|
Caution Review failedThe pull request is closed. Walkthrough本PR更新Gemini适配器以支持新的gemini-3模型变体,增强思维级别支持(包括tiny-thinking),将模型检测逻辑从gemini-3.0更新为gemini-3,并改进图像分辨率变体的后缀处理。 Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 分钟
Possibly related PRs
Poem
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
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. Comment |
Summary of ChangesHello @dingyi222666, 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 enhances the Gemini adapter by introducing new 'thinking level' variants for Gemini 3 Pro models, including 'tiny-thinking', 'low-thinking', and 'high-thinking'. It also refines the model detection and parsing logic to accurately handle these new modes and improves overall performance by optimizing constant array declarations. 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
|
There was a problem hiding this comment.
Code Review
This pull request successfully adds support for different Gemini 3 thinking levels and improves the model detection logic. Moving constants out of the loop is a good performance enhancement. However, I've identified a critical bug in the new thinking level parsing logic that could cause a runtime TypeError and have provided a suggested fix. I also have a medium-severity comment regarding an inconsistency in the model variants being generated, which could affect maintainability.
| if (match && match[1]) { | ||
| model = model.replace(`-${match[1]}-thinking`, '') | ||
| } | ||
|
|
||
| if (match && match[1] !== 'tiny') { | ||
| thinkingLevel = match[1] | ||
| } else if (match[1] === 'tiny') { | ||
| thinkingLevel = undefined | ||
| thinkingBudget = 128 | ||
| } else { | ||
| // Default to THINKING_LEVEL_UNSPECIFIED for gemini-3.0 if no level specified | ||
| // Default to THINKING_LEVEL_UNSPECIFIED for gemini-3 if no level specified | ||
| thinkingLevel = 'THINKING_LEVEL_UNSPECIFIED' | ||
| model = model.replace('-thinking', '') | ||
| } |
There was a problem hiding this comment.
This logic block can cause a runtime error. If model includes 'gemini-3' but does not have a thinking level suffix (e.g., 'gemini-3-pro'), match will be null. The condition else if (match[1] === 'tiny') on line 421 will then attempt to access a property on null, causing a TypeError.
The logic can be restructured to be safer and more concise by first checking if match is truthy and then handling the different thinking levels within that block.
| if (match && match[1]) { | |
| model = model.replace(`-${match[1]}-thinking`, '') | |
| } | |
| if (match && match[1] !== 'tiny') { | |
| thinkingLevel = match[1] | |
| } else if (match[1] === 'tiny') { | |
| thinkingLevel = undefined | |
| thinkingBudget = 128 | |
| } else { | |
| // Default to THINKING_LEVEL_UNSPECIFIED for gemini-3.0 if no level specified | |
| // Default to THINKING_LEVEL_UNSPECIFIED for gemini-3 if no level specified | |
| thinkingLevel = 'THINKING_LEVEL_UNSPECIFIED' | |
| model = model.replace('-thinking', '') | |
| } | |
| if (match && match[1]) { | |
| const level = match[1]; | |
| model = model.replace(`-${level}-thinking`, ''); | |
| if (level === 'tiny') { | |
| thinkingLevel = undefined; | |
| thinkingBudget = 128; | |
| } else { | |
| thinkingLevel = level; | |
| } | |
| } else { | |
| // Default to THINKING_LEVEL_UNSPECIFIED for gemini-3 if no level specified | |
| thinkingLevel = 'THINKING_LEVEL_UNSPECIFIED'; | |
| } |
| { ...info, name: model.name + '-low-thinking' }, | ||
| { ...info, name: model.name + '-high-thinking' }, | ||
| { ...info, name: model.name + '-tiny-thinking' }, |
There was a problem hiding this comment.
You've added support for high-thinking and tiny-thinking variants. However, the regex in packages/adapter-gemini/src/utils.ts (line 413) also includes medium as a valid thinking level: /-(low|medium|high|tiny)-thinking/. This means a model name like gemini-3-pro-medium-thinking would be correctly parsed, but it's not discoverable as it's not generated here.
For consistency, if medium is not a supported variant that should be explicitly listed, consider removing it from the regex in utils.ts to avoid confusion. If it is a supported variant, it should be added here.
This PR adds support for Gemini 3 thinking level variants and improves the model detection logic in the Gemini adapter.
New Features
Other Changes
gemini-3.0togemini-3for better version matching