hotfix(models): support hosted Gemma 4 thinking mode - #14793
Conversation
Signed-off-by: ousugo <dkzydkzyxh@gmail.com>
GeorgeDong32
left a comment
There was a problem hiding this comment.
Code Review Summary
✅ 优点
- 精准修复:只针对 Gemini provider 的 hosted Gemma 4,不影响其他 provider
- 代码质量:函数命名清晰,实现简洁
- 测试覆盖:添加了完整的测试用例
- API 参数处理:正确映射 reasoning_effort 到 thinkingLevel
🔶 需关注的问题
- 缺少
none选项:用户无法显式关闭 thinking mode(详见 inline comment) - OpenRouter 场景未解决:原始 issue #14870 用户报告的是 OpenRouter 场景,但此 PR 仅修复 Gemini provider(详见 inline comment)
建议在 PR description 中说明此 PR 仅修复 Gemini provider 场景,OpenRouter 可能需要后续处理。
GeorgeDong32
left a comment
There was a problem hiding this comment.
补充说明:关于 OpenRouter 和 "none" 选项
经过文档调研后的补充说明:
OpenRouter 场景
OpenRouter 文档确认 google/gemma-4-31b-it 支持 reasoning 控制,使用 reasoning.effort 参数(支持 none/minimal/low/medium/high/xhigh)。但此 PR 有意只修复 Gemini provider 场景,OpenRouter 需要后续单独处理 —— 这个设计决策是合理的。
关于缺少 "none" 选项
OpenRouter 支持 effort: "none" 来完全禁用推理。但对于 Google hosted Gemma 4,需要确认:
- Google Gemini API 是否支持完全关闭 hosted Gemma 4 的 thinking?
- 类似于 Gemini 3 Pro 不支持关闭 thinking 的限制?
如果 Google API 支持关闭 thinking,建议添加 none 选项。如果不支持,建议在代码注释或文档中说明原因。
参考资料
- OpenRouter reasoning 文档: https://openrouter.ai/docs/guides/best-practices/reasoning-tokens
- Gemma 4 thinking 文档: https://ai.google.dev/gemma/docs/capabilities/thinking
|
Note This comment was translated by Claude. Additional clarification on these two review points:
Original Content补充说明一下这两个 review 点:
|
Signed-off-by: ousugo <dkzyxh@gmail.com>
GeorgeDong32
left a comment
There was a problem hiding this comment.
LGTM. 设计决策清晰文档化,向后兼容处理得当。
What this PR does
Before this PR:
After this PR:
minimal/highoptions for hosted Gemma 4 and maps them to the matching GeminithinkingLevelrequest parameters.noneoption for Google-hosted Gemma 4, because Google documentsminimalas the closest supported near-off setting for most requests but does not guarantee that thinking is fully disabled.Fixes #14776
Why we need it and why it was done in this way
The following tradeoffs were made:
gemma4_hostedthinking model type instead of overloading existing Gemini types, so the change stays provider-scoped and avoids affecting Ollama or OpenRouter Gemma 4 behavior.minimal/highrather than exposingnoneas a formal hosted Gemma 4 option on the Gemini provider, because the Google API does not document a distinct hard-off mode for this route.reasoning_effort: 'none'inputs by normalizing them tothinkingLevel: 'minimal'withincludeThoughts: false.The following alternatives were considered:
noneas an official hosted Gemma 4 option despite the Gemini API not guaranteeing hard-off behavior.gemini2_prothinking options and budget mapping.Links to places where the discussion took place: #14776
Breaking changes
N/A
If this PR introduces breaking changes, please describe the changes and the impact on users.
Special notes for your reviewer
noneoption.src/renderer/src/config/models/__tests__/reasoning.test.tssrc/renderer/src/aiCore/utils/__tests__/reasoning.test.tssrc/renderer/src/pages/home/Inputbar/tools/components/__tests__/ThinkingButton.test.tsxChecklist
This checklist is not enforcing, but it's a reminder of items that could be relevant to every PR.
Approvers are expected to review this list.
/gh-pr-review,gh pr diff, or GitHub UI) before requesting review from othersRelease note