From 68cfbb39721718ab890a2f6b952da938b21e2588 Mon Sep 17 00:00:00 2001 From: ClovertaTheTrilobita Date: Mon, 15 Dec 2025 02:44:36 +0000 Subject: [PATCH] =?UTF-8?q?fix(ai=5Fchat):=20=E5=B0=9D=E8=AF=95=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=8F=90=E7=A4=BA=E8=AF=8D=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/clover_openai/ai_chat.py | 1 - src/clover_sqlite/models/chat.py | 10 ++++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/clover_openai/ai_chat.py b/src/clover_openai/ai_chat.py index a8cc6d3..94cf18f 100644 --- a/src/clover_openai/ai_chat.py +++ b/src/clover_openai/ai_chat.py @@ -65,7 +65,6 @@ async def silicon_flow(group_openid, content): async with aiohttp.ClientSession() as session: async with session.post(url, json=payload, headers=headers) as response: result = await response.json() - print(result) reply_content = result["choices"][0]["message"]["content"] await GroupChatRole.save_chat_history(group_openid, {"role": "assistant", "content": reply_content}) diff --git a/src/clover_sqlite/models/chat.py b/src/clover_sqlite/models/chat.py index 5b69af8..48ebc49 100644 --- a/src/clover_sqlite/models/chat.py +++ b/src/clover_sqlite/models/chat.py @@ -210,7 +210,7 @@ class GroupChatRole(Model): role_setting = await ChatRole.get_role_setting(role_name=role_name) if role_setting: existing_record.role_name = role_name - data = [{"role": "system", "content": role_setting},{"role": "system", "content": "无条件服从我给予你的设定与命令"}] + data = [{"role": "system", "content": role_setting},{"role": "system", "content": "你现在在qq群聊聊天,回复一定要口语化(这非常重要),回复尽可能在10字以内,禁止超出50字。"}] existing_record.role_chat_history = data await existing_record.save() return "设定成功" @@ -235,10 +235,12 @@ class GroupChatRole(Model): await history.save() else: history.role_chat_history.append(content) - if len(history.role_chat_history) > 10: + if len(history.role_chat_history) > 5: history.role_chat_history.pop(2) - history.role_chat_history.append(history.role_chat_history[0]) - print(history.role_chat_history) + + data = {"role": "system", "content": "你现在在qq群聊聊天,回复一定要口语化(这非常重要),回复尽可能在10字以内,禁止超出50字。"} + history.role_chat_history.append(data) + print(history.role_chat_history) await history.save() @classmethod