fix(small-model): omit thinkingConfig for non-reasoning Google models

This commit is contained in:
Zeying Tian
2026-08-09 03:10:31 -04:00
parent 493a618efc
commit 0bbbcd6445
3 changed files with 25 additions and 9 deletions
+7 -8
View File
@@ -402,9 +402,10 @@ const getCopilotEndpoint = async ({ baseURL, headers, modelID }) => {
const callGoogle = async ({ apiKey, modelID, prompt, system, maxOutputTokens, responseSchema, timeoutMs, signal }) => {
const url = `https://generativelanguage.googleapis.com/v1beta/models/${encodeURIComponent(modelID)}:generateContent`;
const thinkingConfig = modelID.toLowerCase().startsWith('gemini-3')
? { thinkingLevel: modelID.toLowerCase().includes('flash') ? 'minimal' : 'low' }
: { thinkingBudget: 0 };
const lowerModelID = modelID.toLowerCase();
const thinkingConfig = lowerModelID.startsWith('gemini-3')
? { thinkingLevel: lowerModelID.includes('flash') ? 'minimal' : 'low' }
: lowerModelID.startsWith('gemini-2') ? { thinkingBudget: 0 } : null;
const response = await fetch(url, {
method: 'POST',
headers: {
@@ -414,13 +415,11 @@ const callGoogle = async ({ apiKey, modelID, prompt, system, maxOutputTokens, re
},
body: JSON.stringify({
contents: [{ role: 'user', parts: [{ text: prompt }] }],
...(system ? { systemInstruction: { parts: [{ text: system }] } } : {}),
...(system && { systemInstruction: { parts: [{ text: system }] } }),
generationConfig: {
maxOutputTokens,
thinkingConfig,
...(responseSchema
? { responseMimeType: 'application/json', responseSchema: toGoogleSchema(responseSchema) }
: {}),
...(thinkingConfig && { thinkingConfig }),
...(responseSchema && { responseMimeType: 'application/json', responseSchema: toGoogleSchema(responseSchema) }),
},
}),
signal: requestSignal(timeoutMs, signal),