Skip to content

Conversation

@dingyi222666
Copy link
Member

This PR fixes issues with the Gemini adapter where thinking parameters were incorrectly sent to models that don't support them.

Bug Fixes

  • Disable thinkingBudget and thinkingLevel parameters for non-Gemini 3 models to prevent API errors
  • Fix variable inconsistency by using model instead of params.model for image generation detection

Other Changes

  • Bump version to 1.3.15

Reset thinkingBudget and thinkingLevel to undefined for models that don't support thinking mode to prevent API errors.
…o 1.3.15

Use the local 'model' variable instead of 'params.model' for image generation detection to ensure consistency with earlier variable extraction.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 4, 2025

Caution

Review failed

The pull request is closed.

📋 Walkthrough

修复了 prepareModelConfig 函数中图像生成模式的模型检查逻辑,将对 params.model 的引用改为使用本地变量 model,并在此分支中重置 thinkingBudgetthinkingLevel 为 undefined。

📊 Changes

Cohort / File(s) Summary
Gemini 适配器模型配置修复
packages/adapter-gemini/src/utils.ts
修改 prepareModelConfig 函数:在 imageGeneration 为真时,使用本地 model 变量(而非 params.model)检查是否包含 gemini-2.0-flash-exp 或 image;同时重置 thinkingBudgetthinkingLevel 为 undefined

⏱️ Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • 关注点: 确认 model 本地变量的来源和初始化逻辑正确无误,验证 thinkingBudgetthinkingLevel 重置不会影响其他代码路径,检查这个改动是否完全解决了模型检查的不一致问题

🔗 Possibly related PRs

🐰 Poem

小兔修复了魔法模型,
本地变量终于用对了,
思维预算清空无忧,
Gemini 适配器闪闪发光。✨
聪明的代码蹦蹦跳!

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/gemini-thinking

📜 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 9a965fa and d9620d3.

⛔ Files ignored due to path filters (1)
  • packages/adapter-gemini/package.json is excluded by !**/*.json
📒 Files selected for processing (1)
  • packages/adapter-gemini/src/utils.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 resolves critical issues within the Gemini adapter by preventing the incorrect transmission of 'thinking' parameters to models that do not support them, thereby avoiding API errors. It also enhances code consistency by standardizing model variable usage and includes a routine version update for the package.

Highlights

  • API Error Prevention: Disabled thinkingBudget and thinkingLevel parameters for models that do not support them, specifically non-Gemini 3 models, to prevent API errors.
  • Code Consistency: Corrected a variable inconsistency in the prepareModelConfig function, switching from params.model to model for accurate image generation detection.
  • Version Update: Bumped the package version of koishi-plugin-chatluna-google-gemini-adapter from 1.3.13 to 1.3.15.
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.

@dingyi222666 dingyi222666 merged commit f0b2606 into v1-dev Dec 4, 2025
2 of 3 checks passed
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 aims to prevent sending 'thinking' parameters to unsupported Gemini models, specifically when image generation is active. It correctly switches from using params.model to the processed model variable for consistency. However, the current implementation has a logical flaw where it unconditionally disables thinking parameters for any model if image generation is enabled in the configuration, even if the model doesn't support image generation. This could break the 'thinking' feature for models that support it. I've provided a suggestion to correct this logic. The version bump to 1.3.15 is also noted.

Comment on lines 442 to +446
imageGeneration =
params.model.includes('gemini-2.0-flash-exp') ||
params.model.includes('image')
model.includes('gemini-2.0-flash-exp') || model.includes('image')

thinkingBudget = undefined
thinkingLevel = undefined
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

There's a logical issue here. If imageGeneration is enabled in the config, thinkingBudget and thinkingLevel are reset to undefined regardless of whether the current model actually supports image generation. This can incorrectly disable the 'thinking' feature for models that support it but don't support image generation (e.g., a gemini-3-pro model with thinking enabled).

The reset of thinking parameters should only occur if the model is determined to be an image generation model. The imageGeneration flag should also be set to false if the model does not support it, to prevent issues later.

if (model.includes('gemini-2.0-flash-exp') || model.includes('image')) {
    thinkingBudget = undefined
    thinkingLevel = undefined
} else {
    imageGeneration = false
}

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