From fc50f2308bde252775096f5d88f32d357ea5bf37 Mon Sep 17 00:00:00 2001 From: toi500 Date: Thu, 18 Sep 2025 10:26:44 +0200 Subject: [PATCH] fix: ensure Gemini always receives a non-empty contents array (#5229) --- .../FlowiseChatGoogleGenerativeAI.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/components/nodes/chatmodels/ChatGoogleGenerativeAI/FlowiseChatGoogleGenerativeAI.ts b/packages/components/nodes/chatmodels/ChatGoogleGenerativeAI/FlowiseChatGoogleGenerativeAI.ts index dcc3c5c5d..5c21fa4ca 100644 --- a/packages/components/nodes/chatmodels/ChatGoogleGenerativeAI/FlowiseChatGoogleGenerativeAI.ts +++ b/packages/components/nodes/chatmodels/ChatGoogleGenerativeAI/FlowiseChatGoogleGenerativeAI.ts @@ -770,6 +770,12 @@ export class LangchainChatGoogleGenerativeAI this.client.systemInstruction = systemInstruction actualPrompt = prompt.slice(1) } + + // Ensure actualPrompt is never empty + if (actualPrompt.length === 0) { + actualPrompt = [{ role: 'user', parts: [{ text: '...' }] }] + } + const parameters = this.invocationParams(options) // Handle streaming @@ -834,6 +840,12 @@ export class LangchainChatGoogleGenerativeAI this.client.systemInstruction = systemInstruction actualPrompt = prompt.slice(1) } + + // Ensure actualPrompt is never empty + if (actualPrompt.length === 0) { + actualPrompt = [{ role: 'user', parts: [{ text: '...' }] }] + } + const parameters = this.invocationParams(options) const request = { ...parameters,