feat(model-ratio): add default ratios for new Gemini models and refine flash model handling - #1248
Conversation
WalkthroughThe changes introduce new constants and refine logic for handling Gemini 2.5 model variants, specifically in pricing and model ratio calculations. Conditional checks for model name prefixes are updated to distinguish between production, preview, and lite-preview variants. The thinking budget logic in Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant API
participant ModelLogic
Client->>API: Request with Gemini 2.5 model name
API->>ModelLogic: Determine pricing/ratio for model
ModelLogic->>ModelLogic: Check model name prefix
alt 2.5-flash-preview-lite
ModelLogic->>API: Return lite preview price/ratio
else 2.5-flash-preview
ModelLogic->>API: Return preview price/ratio
else 2.5-flash
ModelLogic->>API: Return production price/ratio
else 2.5-pro
ModelLogic->>API: Return pro ratio
else
ModelLogic->>API: Return default values
end
API->>Client: Respond with calculated values
Possibly related PRs
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
setting/operation_setting/tools.go (1)
20-23: Constant duplication – clarify intent or de-duplicate
Gemini25FlashPreviewInputAudioPriceand the newGemini25FlashProductionInputAudioPriceare both set to1.00.
If the parity is intentional, a short comment explaining why the same price is used helps future maintainers; otherwise, consider using one constant for both to avoid divergence later.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
relay/channel/gemini/relay-gemini.go(1 hunks)setting/operation_setting/tools.go(2 hunks)
🔇 Additional comments (2)
relay/channel/gemini/relay-gemini.go (1)
144-148: Zero-budget now applies to all-nothinkingmodels – verify flash-lite compatibility
is25FlashLitewas removed from the condition, so any model whose name ends with-nothinkingexceptgemini-2.5-pro*will now receiveThinkingBudget = 0, including the flash-lite variants.Given that
clampThinkingBudgetenforces a minimum of 512 tokens for flash-lite models (lines 45–46), forcing0here bypasses that safeguard and might trigger an upstream validation error or silently disable “thoughts” in an unintended way.Please confirm that Gemini accepts
ThinkingBudget: 0for flash-lite models. If not, consider restoring a dedicated flash-lite check or clamping toflash25LiteMinBudget.setting/operation_setting/tools.go (1)
68-74: Guard order looks correct – preview/native branches win over productionThe new branch order prevents the generic
gemini-2.5-flashmatch from shadowing the more specific preview/native-audio prefixes. 👍
feat(model-ratio): add default ratios for new Gemini models and refine flash model handling
增加了默认倍率、音频倍率,修复了 #1247 引入的对2.5 flash lite nothinking的忽视 (参见https://ai.google.dev/gemini-api/docs/thinking?hl=zh-cn#set-budget)
Summary by CodeRabbit
New Features
Improvements