From e2242720125f9bb02a4e2e9271538fc5373f77d7 Mon Sep 17 00:00:00 2001 From: ikechan8370 Date: Tue, 4 Feb 2025 12:13:58 +0800 Subject: [PATCH] fix: gemini system cannot be empty --- client/CustomGoogleGeminiClient.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/client/CustomGoogleGeminiClient.js b/client/CustomGoogleGeminiClient.js index 871abfe..8853063 100644 --- a/client/CustomGoogleGeminiClient.js +++ b/client/CustomGoogleGeminiClient.js @@ -169,11 +169,6 @@ export class CustomGoogleGeminiClient extends GoogleGeminiClient { * @type Array */ contents: history, - system_instruction: { - parts: { - text: systemMessage - } - }, safetySettings: [ { category: HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT, @@ -204,6 +199,13 @@ export class CustomGoogleGeminiClient extends GoogleGeminiClient { }, tools: [] } + if (systemMessage) { + body.system_instruction = { + parts: { + text: systemMessage + } + } + } if (this.tools?.length > 0) { body.tools.push({ function_declarations: this.tools.map(tool => tool.function())