From d7e2ee63d87bb713231e11d3ff2dabb3b1904e0c Mon Sep 17 00:00:00 2001 From: HyiKi Date: Tue, 6 Aug 2024 10:45:25 +0800 Subject: [PATCH] fix: tencent InvalidParameter error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix "Messages 中 system 角色必须位于列表的最开始" --- app/client/platforms/tencent.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/client/platforms/tencent.ts b/app/client/platforms/tencent.ts index e9e49d3f0b0..579008a9b9d 100644 --- a/app/client/platforms/tencent.ts +++ b/app/client/platforms/tencent.ts @@ -91,8 +91,9 @@ export class HunyuanApi implements LLMApi { async chat(options: ChatOptions) { const visionModel = isVisionModel(options.config.model); - const messages = options.messages.map((v) => ({ - role: v.role, + const messages = options.messages.map((v, index) => ({ + // "Messages 中 system 角色必须位于列表的最开始" + role: index !== 0 && v.role === "system" ? "user" : v.role, content: visionModel ? v.content : getMessageTextContent(v), }));