From f3d5b7766df7dcf0e101f902d04cab30795099ef Mon Sep 17 00:00:00 2001 From: Henry Heng Date: Thu, 30 Oct 2025 22:01:15 +0000 Subject: [PATCH] Feat/add thinking budget to gemini (#5395) add thinking budget to gemini --- .../ChatGoogleGenerativeAI.ts | 14 ++++++++++++++ .../FlowiseChatGoogleGenerativeAI.ts | 16 ++++++++++++++++ .../ChatGoogleGenerativeAI/utils/common.ts | 2 ++ 3 files changed, 32 insertions(+) diff --git a/packages/components/nodes/chatmodels/ChatGoogleGenerativeAI/ChatGoogleGenerativeAI.ts b/packages/components/nodes/chatmodels/ChatGoogleGenerativeAI/ChatGoogleGenerativeAI.ts index 95d669e1..d618254c 100644 --- a/packages/components/nodes/chatmodels/ChatGoogleGenerativeAI/ChatGoogleGenerativeAI.ts +++ b/packages/components/nodes/chatmodels/ChatGoogleGenerativeAI/ChatGoogleGenerativeAI.ts @@ -174,6 +174,18 @@ class GoogleGenerativeAI_ChatModels implements INode { optional: true, additionalParams: true }, + { + label: 'Thinking Budget', + name: 'thinkingBudget', + type: 'number', + description: 'Guides the number of thinking tokens. -1 for dynamic, 0 to disable, or positive integer (Gemini 2.5 models).', + step: 1, + optional: true, + additionalParams: true, + show: { + modelName: ['gemini-2.5-pro', 'gemini-2.5-flash', 'gemini-2.5-flash-lite'] + } + }, { label: 'Base URL', name: 'baseUrl', @@ -216,6 +228,7 @@ class GoogleGenerativeAI_ChatModels implements INode { const cache = nodeData.inputs?.cache as BaseCache const streaming = nodeData.inputs?.streaming as boolean const baseUrl = nodeData.inputs?.baseUrl as string | undefined + const thinkingBudget = nodeData.inputs?.thinkingBudget as string const allowImageUploads = nodeData.inputs?.allowImageUploads as boolean @@ -235,6 +248,7 @@ class GoogleGenerativeAI_ChatModels implements INode { if (cache) obj.cache = cache if (temperature) obj.temperature = parseFloat(temperature) if (baseUrl) obj.baseUrl = baseUrl + if (thinkingBudget) obj.thinkingBudget = parseInt(thinkingBudget, 10) let safetySettings: SafetySetting[] = [] if (_safetySettings) { diff --git a/packages/components/nodes/chatmodels/ChatGoogleGenerativeAI/FlowiseChatGoogleGenerativeAI.ts b/packages/components/nodes/chatmodels/ChatGoogleGenerativeAI/FlowiseChatGoogleGenerativeAI.ts index 5c21fa4c..cdf3ac11 100644 --- a/packages/components/nodes/chatmodels/ChatGoogleGenerativeAI/FlowiseChatGoogleGenerativeAI.ts +++ b/packages/components/nodes/chatmodels/ChatGoogleGenerativeAI/FlowiseChatGoogleGenerativeAI.ts @@ -174,6 +174,9 @@ export interface GoogleGenerativeAIChatInput extends BaseChatModelParams, Pick