From 9d34ef2cf7c32030c8c0d972033506855999ace1 Mon Sep 17 00:00:00 2001 From: Mic Date: Mon, 8 Sep 2025 22:00:00 +0200 Subject: [PATCH] gemini, added model default option for the thinking budget. see #494 --- js/api/google_gemini.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/js/api/google_gemini.js b/js/api/google_gemini.js index fbcec986..5dad89e0 100644 --- a/js/api/google_gemini.js +++ b/js/api/google_gemini.js @@ -24,24 +24,25 @@ export class GoogleGemini { model = ''; system_instruction = ''; stream = false; - thinkingBudget = 0; //Off + thinkingBudget = ''; // Model default constructor({ apiKey = '', model = '', system_instruction = '', stream = false, - thinkingBudget = 0 + thinkingBudget = '', } = {}) { this.apiKey = apiKey; this.model = model; this.system_instruction = system_instruction; this.stream = stream; - this.thinkingBudget = thinkingBudget; + this.thinkingBudget = thinkingBudget.trim(); /* Info from: https://ai.google.dev/gemini-api/docs/thinking?#set-budget # Turn on thinking with a specific token limit: "thinkingBudget": 1024 # Thinking off: "thinkingBudget": 0 # Turn on dynamic thinking: "thinkingBudget": -1 + # Keep model default thinking: "thinkingBudget": "" */ } @@ -97,6 +98,9 @@ export class GoogleGemini { text: this.system_instruction } }; + } + + if(this.thinkingBudget !== '') { google_gemini_body.generationConfig = { thinkingConfig: { thinkingBudget: this.thinkingBudget,