fix: set thinking budget to 0 for gemini-2.5-flash when reasoning effort is off (#6917)

This commit is contained in:
purefkh 2025-06-06 22:11:18 +08:00 committed by GitHub
parent 9ba2dea148
commit 7f12c2f8b8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 2 deletions

View File

@ -2631,7 +2631,8 @@ export function groupQwenModels(models: Model[]): Record<string, Model[]> {
export const THINKING_TOKEN_MAP: Record<string, { min: number; max: number }> = {
// Gemini models
'gemini-.*$': { min: 0, max: 24576 },
'gemini-.*-flash.*$': { min: 0, max: 24576 },
'gemini-.*-pro.*$': { min: 128, max: 32768 },
// Qwen models
'qwen-plus-.*$': { min: 0, max: 38912 },

View File

@ -286,12 +286,14 @@ export default class GeminiProvider extends BaseProvider {
private getBudgetToken(assistant: Assistant, model: Model) {
if (isGeminiReasoningModel(model)) {
const reasoningEffort = assistant?.settings?.reasoning_effort
const GEMINI_FLASH_MODEL_REGEX = new RegExp('gemini-.*-flash.*$')
// 如果thinking_budget是undefined不思考
if (reasoningEffort === undefined) {
return {
thinkingConfig: {
includeThoughts: false
includeThoughts: false,
...(GEMINI_FLASH_MODEL_REGEX.test(model.id) ? { thinkingBudget: 0 } : {})
} as ThinkingConfig
}
}