gemini, added model default option for the thinking budget. see #494

This commit is contained in:
Mic 2025-09-08 22:00:00 +02:00
parent a34d3c41e0
commit 9d34ef2cf7

View file

@ -24,24 +24,25 @@ export class GoogleGemini {
model = ''; model = '';
system_instruction = ''; system_instruction = '';
stream = false; stream = false;
thinkingBudget = 0; //Off thinkingBudget = ''; // Model default
constructor({ constructor({
apiKey = '', apiKey = '',
model = '', model = '',
system_instruction = '', system_instruction = '',
stream = false, stream = false,
thinkingBudget = 0 thinkingBudget = '',
} = {}) { } = {}) {
this.apiKey = apiKey; this.apiKey = apiKey;
this.model = model; this.model = model;
this.system_instruction = system_instruction; this.system_instruction = system_instruction;
this.stream = stream; this.stream = stream;
this.thinkingBudget = thinkingBudget; this.thinkingBudget = thinkingBudget.trim();
/* Info from: https://ai.google.dev/gemini-api/docs/thinking?#set-budget /* Info from: https://ai.google.dev/gemini-api/docs/thinking?#set-budget
# Turn on thinking with a specific token limit: "thinkingBudget": 1024 # Turn on thinking with a specific token limit: "thinkingBudget": 1024
# Thinking off: "thinkingBudget": 0 # Thinking off: "thinkingBudget": 0
# Turn on dynamic thinking: "thinkingBudget": -1 # Turn on dynamic thinking: "thinkingBudget": -1
# Keep model default thinking: "thinkingBudget": ""
*/ */
} }
@ -97,6 +98,9 @@ export class GoogleGemini {
text: this.system_instruction text: this.system_instruction
} }
}; };
}
if(this.thinkingBudget !== '') {
google_gemini_body.generationConfig = { google_gemini_body.generationConfig = {
thinkingConfig: { thinkingConfig: {
thinkingBudget: this.thinkingBudget, thinkingBudget: this.thinkingBudget,