From ae75d1c3a6df2c59dc91ab7742b491f28102e64b Mon Sep 17 00:00:00 2001 From: Archeb Date: Mon, 8 Apr 2024 17:53:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B9=20anthropic=20api=20system?= =?UTF-8?q?=20=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/index.js b/index.js index 17144cc..d25c0b3 100644 --- a/index.js +++ b/index.js @@ -49,6 +49,10 @@ app.post("/v1/messages", (req, res) => { let userMessage = [{ question: "", answer: "" }]; let userQuery = ""; let lastUpdate = true; + if(jsonBody.system) { + // 把系统消息加入messages的首条 + jsonBody.messages.unshift({role: "system", content: jsonBody.system}); + } jsonBody.messages.forEach((msg) => { if (msg.role == "system" || msg.role == "user") { if (lastUpdate) {