-
-
Notifications
You must be signed in to change notification settings - Fork 41
[Fix] Prioritize Gemini image resolution model detection #645
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
Conversation
…ng model detection Move image resolution model check before thinking model check to prevent Gemini 3.0 image models from being incorrectly processed as thinking models. Also add overrideRequestParams option to ChatLunaModelCallOptions for flexible request parameter customization.
|
Caution Review failedThe pull request is closed. Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. Walkthrough对 Gemini 适配器的模型判定逻辑进行了重排(将图像分辨率处理提前并生成多种变体),并在核心模型层添加了每请求级别的参数覆盖字段 Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 分钟
Possibly related PRs
诗意庆贺
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 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 addresses an issue in Gemini model detection where image resolution models were incorrectly identified, leading to improper variant generation. It reorders the detection logic to prioritize image resolution models, ensuring accurate "-2K" and "-4K" variants. Additionally, it enhances model call options by introducing a new "overrideRequestParams" field, providing greater flexibility for customizing request parameters on a per-call basis. 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.
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 correctly addresses a bug in the Gemini model detection logic by prioritizing image resolution models. The reordering of the conditional checks ensures that models like gemini-3.0-pro-image are correctly identified and their variants (-2K, -4K) are generated. Additionally, the PR introduces a overrideRequestParams option in ChatLunaModelCallOptions, allowing for more flexible per-request parameter customization. The implementation for this new option is sound, propagating it correctly through the call stack. I have one suggestion to improve code readability and performance in the model detection logic.
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/core/src/llm-core/platform/model.ts (1)
88-92: overrideRequestParams 接线完整,但当前是“整对象覆盖”,可考虑改为浅合并这几个改动把
overrideRequestParams从类型、callKeys 到invocationParams都串联好了,整体设计合理,能满足“单次调用自定义请求参数”的需求。不过现在的优先级是:
- 单次调用:
options?.overrideRequestParams- 否则:实例级:
this._options.overrideRequestParams- 否则:
{}一旦在某次调用中提供了
overrideRequestParams,就会完全替换掉实例级的默认配置,无法做到“在全局默认参数上只改动部分 key”。如果你期望的是“默认为 adapter 全局参数,单次调用只覆盖部分字段”,建议在这里做一次浅合并,会更符合“override”的直觉语义,例如:- overrideRequestParams: - options?.overrideRequestParams ?? - this._options.overrideRequestParams ?? - {}, + overrideRequestParams: { + ...(this._options.overrideRequestParams ?? {}), + ...(options?.overrideRequestParams ?? {}), + },这样:
- 仅配置全局时仍然生效;
- 单次调用可以只传入需要覆写的 key,未显式提供的字段仍继承全局默认。
Also applies to: 147-147, 189-192
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/adapter-gemini/src/client.ts(1 hunks)packages/core/src/llm-core/platform/model.ts(3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
packages/adapter-gemini/src/client.ts (1)
packages/adapter-gemini/src/index.ts (1)
name(102-102)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: build
- GitHub Check: lint
🔇 Additional comments (1)
packages/adapter-gemini/src/client.ts (1)
82-90: Image 分辨率模型优先分支逻辑合理,能避免被误判为 thinking 模型这一段把
gemini-3.0-pro-image等分辨率模型提前分支处理,并一次性注册name-2K、name-4K以及原始name,同时跳过后续 thinking / low-thinking 分支,能够有效避免 image 变体被错误当成 thinking 模型,行为符合 PR 描述。目前用
includes+toLowerCase()做匹配,对未来可能出现的诸如gemini-3.0-pro-image-001之类后缀版本也比较友好;如果后续只希望精确匹配,也可以改成等号比较,这里现在可以先保持现状。
… loop Cache the lowercase model name at the start of the loop to avoid repeated toLowerCase() calls. This improves performance and readability by reducing the number of string operations from up to 4 calls per model to just 1.
Remove 'beta' designation from v1.3 version string.
This PR fixes the model detection logic for Gemini 3.0 image generation models and adds request parameter override support.
Bug Fixes
-2Kand-4Kvariants are correctly created for image generation modelsOther Changes
overrideRequestParamsoption toChatLunaModelCallOptionsfor flexible per-request parameter customization