Fix: Map all reasoning efforts to Google thinkingLevel

This commit is contained in:
2025-11-25 13:38:41 -08:00
parent 0da27a8c5c
commit 230e9e2b8b

View File

@@ -283,7 +283,7 @@ export class MyDurableObject {
async streamGoogle({ apiKey, body }) { async streamGoogle({ apiKey, body }) {
const generationConfig = Object.entries({ temperature: body.temperature, topP: body.top_p, maxOutputTokens: body.max_tokens }).reduce((acc, [k, v]) => (Number.isFinite(+v) && +v >= 0 ? { ...acc, [k]: +v } : acc), {}); const generationConfig = Object.entries({ temperature: body.temperature, topP: body.top_p, maxOutputTokens: body.max_tokens }).reduce((acc, [k, v]) => (Number.isFinite(+v) && +v >= 0 ? { ...acc, [k]: +v } : acc), {});
if (body.reasoning) generationConfig.thinkingConfig = { includeThoughts: body.reasoning.exclude !== true, ...(body.reasoning.effort && body.reasoning.effort !== 'default' && { thinkingLevel: body.reasoning.effort === 'low' ? 'low' : 'high' }) }; if (body.reasoning) generationConfig.thinkingConfig = { includeThoughts: body.reasoning.exclude !== true, ...(body.reasoning.effort && body.reasoning.effort !== 'default' && { thinkingLevel: body.reasoning.effort }) };
if (body.response_format?.type?.startsWith('json')) { if (body.response_format?.type?.startsWith('json')) {
generationConfig.responseMimeType = 'application/json'; generationConfig.responseMimeType = 'application/json';
if (body.response_format.json_schema) { if (body.response_format.json_schema) {