Skip to content

Conversation

@dingyi222666
Copy link
Member

This PR fixes the model detection logic for Gemini 3.0 image generation models and adds request parameter override support.

Bug Fixes

  • Fixed incorrect model variant generation for Gemini 3.0 Pro Image models by reordering condition checks
  • Previously, image resolution models were being checked after thinking models, causing them to be incorrectly processed as thinking model variants
  • Now image resolution check is prioritized, ensuring -2K and -4K variants are correctly created for image generation models

Other Changes

  • Added overrideRequestParams option to ChatLunaModelCallOptions for flexible per-request parameter customization

…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.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 4, 2025

Caution

Review failed

The pull request is closed.

Note

Other AI code review bot(s) detected

CodeRabbit 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 适配器的模型判定逻辑进行了重排(将图像分辨率处理提前并生成多种变体),并在核心模型层添加了每请求级别的参数覆盖字段 overrideRequestParams,该字段在调用参数中按优先级传播。

Changes

Cohort / File(s) 变更摘要
Gemini 适配器客户端
packages/adapter-gemini/src/client.ts
将 image-resolution 检测上移至早期分支:遇到图像分辨率标记时立即推送三个变体(-2K-4K、原名)并跳过后续分支;引入 modelNameLower 用于统一小写比较,调整 thinking-model 分支的变体命名(引入 -non-thinking),移除原末尾的 image-resolution 分支。
核心平台模型
packages/core/src/llm-core/platform/model.ts
ChatLunaModelCallOptions 中新增 overrideRequestParams?: Record<string, any>;将该键加入 ChatLunaChatModel.callKeys 并在 invocationParams 中按优先级设置为 options.overrideRequestParams ?? this._options.overrideRequestParams ?? {},实现每请求级别的覆盖。
文案/帮助文本
packages/core/src/index.ts
把帮助/说明字符串从 "## chatluna v1.3 beta" 更新为 "## chatluna v1.3",仅文本修改。

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 分钟

  • 变更聚焦且局部,主要为模型判定逻辑重排与配置字段新增,重复性低但清晰。
  • 重点审查项:
    • packages/adapter-gemini/src/client.ts:确认图像分辨率变体的生成顺序与早期短路逻辑不会影响其他分支。
    • packages/core/src/llm-core/platform/model.ts:确认 overrideRequestParams 的传递优先级与类型预期,并考虑调用处对该字段的校验或深拷贝需求。

Possibly related PRs

诗意庆贺

🐰 我在树下轻轻跳,
早早识别图像标号,
请求参数随手换,
决策分支整整齐,
模型选择更欢跃 🥕

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed 标题准确地反映了主要变更——Gemini图像分辨率模型检测的优先级调整,与代码变更相符。
Description check ✅ Passed 描述与变更集密切相关,涵盖了Gemini模型检测逻辑修复和参数覆盖功能的添加,与实际代码变更一致。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 310db5c and 5fcc72c.

📒 Files selected for processing (2)
  • packages/adapter-gemini/src/client.ts (3 hunks)
  • packages/core/src/index.ts (1 hunks)

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 and usage tips.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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

  • Gemini Model Detection Fix: Corrected the model detection logic for Gemini 3.0 Pro Image models by reordering condition checks, ensuring that image resolution variants ("-2K", "-4K") are correctly generated instead of being misclassified as thinking models.
  • Request Parameter Override: Introduced an "overrideRequestParams" option within "ChatLunaModelCallOptions" to allow for flexible, per-request customization of parameters.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between 81c804a and 310db5c.

📒 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-2Kname-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.
@dingyi222666 dingyi222666 merged commit 7976979 into v1-dev Dec 4, 2025
2 of 3 checks passed
@dingyi222666 dingyi222666 deleted the fix/gemini-image-resolution branch December 4, 2025 04:49
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