From f2b76f531d5627851bbaaf7773a7f0333f6a2433 Mon Sep 17 00:00:00 2001 From: taylor <=> Date: Mon, 14 Oct 2024 17:46:24 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E4=BF=AE=E6=94=B9anthropic=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E4=BD=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- maubot_llmplus/thrid_platform.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/maubot_llmplus/thrid_platform.py b/maubot_llmplus/thrid_platform.py index 3239ecb..ffc3ced 100644 --- a/maubot_llmplus/thrid_platform.py +++ b/maubot_llmplus/thrid_platform.py @@ -1,4 +1,5 @@ import json +from collections import deque from typing import List @@ -83,15 +84,13 @@ class Anthropic(Platform): async def create_chat_completion(self, plugin: AbsExtraConfigPlugin, evt: MessageEvent) -> ChatCompletion: full_chat_context = [] - system_context = await maubot_llmplus.platforms.get_system_context(plugin, self, evt) - full_system_context = [] + system_context = deque() chat_context = await maubot_llmplus.platforms.get_chat_context(system_context, plugin, self, evt) full_chat_context.extend(list(chat_context)) - full_system_context.extend(list(system_context)) endpoint = f"{self.url}/v1/messages" headers = {"x-api-key": self.api_key, "anthropic-version": "2023-06-01", "content-type": "application/json"} - req_body = {"model": self.model, "max_tokens": self.max_tokens, "system": full_system_context, "messages": full_chat_context} + req_body = {"model": self.model, "max_tokens": self.max_tokens, "system": self.system_prompt, "messages": full_chat_context} async with self.http.post(endpoint, headers=headers, data=json.dumps(req_body)) as response: # plugin.log.debug(f"响应内容:{response.status}, {await response.json()}")