fix(ai): correct Gemini SDK payload property thinkingBudgetTokens to thinkingBudget
This commit is contained in:
16
vibn-frontend/fix_genai_bug.js
Normal file
16
vibn-frontend/fix_genai_bug.js
Normal file
@@ -0,0 +1,16 @@
|
||||
const fs = require('fs');
|
||||
|
||||
const file1 = 'lib/ai/gemini-chat.ts';
|
||||
let code1 = fs.readFileSync(file1, 'utf8');
|
||||
|
||||
// The correct property name for @google/genai ^1.0.0 is `thinkingBudget`.
|
||||
// `thinkingBudgetTokens` is the old deprecated name that throws the 400 error!
|
||||
code1 = code1.replace(/thinkingBudgetTokens:/g, 'thinkingBudget:');
|
||||
fs.writeFileSync(file1, code1);
|
||||
|
||||
const file2 = 'lib/ai/gemini-client.ts';
|
||||
let code2 = fs.readFileSync(file2, 'utf8');
|
||||
code2 = code2.replace(/thinkingBudgetTokens:/g, 'thinkingBudget:');
|
||||
fs.writeFileSync(file2, code2);
|
||||
|
||||
console.log("Fixed thinkingBudget property error for Gemini");
|
||||
@@ -114,7 +114,7 @@ export async function callGeminiChat(opts: {
|
||||
}
|
||||
|
||||
if (opts.includeThoughts) {
|
||||
config.thinkingConfig = { thinkingBudgetTokens: 1024 };
|
||||
config.thinkingConfig = { thinkingBudget: 1024 };
|
||||
}
|
||||
|
||||
const fns = toGeminiFunctions(opts.tools ?? []);
|
||||
@@ -174,7 +174,7 @@ export async function* streamGeminiChat(opts: {
|
||||
const config: any = {
|
||||
temperature: opts.temperature ?? 0.7,
|
||||
maxOutputTokens: 8192,
|
||||
thinkingConfig: { thinkingBudgetTokens: 1024 },
|
||||
thinkingConfig: { thinkingBudget: 1024 },
|
||||
};
|
||||
|
||||
if (opts.systemPrompt) {
|
||||
|
||||
@@ -88,7 +88,7 @@ export class GeminiLlmClient implements LlmClient {
|
||||
|
||||
if (args.thinking_config) {
|
||||
config.thinkingConfig = {
|
||||
thinkingBudgetTokens: 1024,
|
||||
thinkingBudget: 1024,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user