diff --git a/public/index.html b/public/index.html index 294f70292..69afabe10 100644 --- a/public/index.html +++ b/public/index.html @@ -2108,8 +2108,14 @@
Allocates a portion of the response length for thinking (min: 1024 tokens, low: 10%, medium: 25%, high: 50%, max: 95%), but minimum 1024 tokens. Auto does not request thinking.
-
- Allocates a portion of the response length for thinking (Flash 2.5/Pro 2.5) (min: 0/128 tokens, low: 10%, medium: 25%, high: 50%, max: 24576/32768 tokens). Auto lets the model decide. +
+ + Sets a dynamic reasoning depth level for thinking (Flash 3/Pro 3). High and low are supported by both, minimal and medium are Flash 3 only. Auto lets the model decide. + +
+ + Allocates a portion of the response length for thinking (Flash 2.5/Pro 2.5) (min: 0/128 tokens, low: 10%, medium: 25%, high: 50%, max: 24576/32768 tokens). Auto lets the model decide. +
diff --git a/src/endpoints/backends/chat-completions.js b/src/endpoints/backends/chat-completions.js index dc7ac32d0..4a15e8a9d 100644 --- a/src/endpoints/backends/chat-completions.js +++ b/src/endpoints/backends/chat-completions.js @@ -474,10 +474,14 @@ async function sendMakerSuiteRequest(request, response) { const thinkingConfig = { includeThoughts: includeReasoning }; const thinkingBudget = calculateGoogleBudgetTokens(generationConfig.maxOutputTokens, reasoningEffort, model); - if (Number.isInteger(thinkingBudget)) { + if (typeof thinkingBudget === 'number' && Number.isInteger(thinkingBudget)) { thinkingConfig.thinkingBudget = thinkingBudget; } + if (typeof thinkingBudget === 'string' && thinkingBudget.length > 0) { + thinkingConfig.thinkingLevel = thinkingBudget; + } + // Vertex doesn't allow mixing disabled thinking with includeThoughts if (useVertexAi && thinkingBudget === 0 && thinkingConfig.includeThoughts) { console.info('Thinking budget is 0, but includeThoughts is true. Thoughts will not be included in the response.'); diff --git a/src/prompt-converters.js b/src/prompt-converters.js index e08ff768e..ece5a0509 100644 --- a/src/prompt-converters.js +++ b/src/prompt-converters.js @@ -1145,7 +1145,7 @@ export function calculateClaudeBudgetTokens(maxTokens, reasoningEffort, stream) * @param {number} maxTokens Maximum tokens * @param {string} reasoningEffort Reasoning effort * @param {string} model Model name - * @returns {number?} Budget tokens + * @returns {number|string|null} Budget tokens */ export function calculateGoogleBudgetTokens(maxTokens, reasoningEffort, model) { function getFlashBudget() { @@ -1230,15 +1230,61 @@ export function calculateGoogleBudgetTokens(maxTokens, reasoningEffort, model) { return budgetTokens; } - if (model.includes('flash-lite')) { + function getGemini3FlashBudget() { + switch (reasoningEffort) { + case REASONING_EFFORT.auto: + return null; + case REASONING_EFFORT.min: + return 'minimal'; + case REASONING_EFFORT.low: + return 'low'; + case REASONING_EFFORT.medium: + return 'medium'; + case REASONING_EFFORT.high: + return 'high'; + case REASONING_EFFORT.max: + return 'high'; + } + + return null; + } + + function getGemini3ProBudget() { + switch (reasoningEffort) { + case REASONING_EFFORT.auto: + return null; + case REASONING_EFFORT.min: + return 'low'; + case REASONING_EFFORT.low: + return 'low'; + case REASONING_EFFORT.medium: + return 'low'; + case REASONING_EFFORT.high: + return 'high'; + case REASONING_EFFORT.max: + return 'high'; + } + + return null; + } + + if (/gemini-3-pro/.test(model)) { + return getGemini3ProBudget(); + } + + if (/gemini-3-flash/.test(model) ) { + return getGemini3FlashBudget(); + } + + if (/flash-lite/.test(model)) { return getFlashLiteBudget(); } - if (model.includes('flash')) { + if (/flash/.test(model)) { return getFlashBudget(); } - if (model.includes('pro')) { + if (/pro/.test(model)) { return getProBudget(); }