fix(ai_chat): 合并聊天逻辑为单一system块

This commit is contained in:
ClovertaTheTrilobita 2025-12-15 03:51:25 +00:00
parent d9e7cd05ec
commit f60d008241

View file

@ -210,6 +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
role_setting = role_setting + "\n你现在在qq群聊聊天回复一定要口语化这非常重要不要使用markdown。如果在讲解概念、题目请详细回复50字以上如果是闲聊回复严禁超出35个字。"
data = [{"role": "system", "content": role_setting}]
existing_record.role_chat_history = data
await existing_record.save()
@ -235,11 +236,11 @@ class GroupChatRole(Model):
await history.save()
else:
history.role_chat_history.append(content)
if len(history.role_chat_history) > 5:
history.role_chat_history.pop(2)
if len(history.role_chat_history) > 12:
history.role_chat_history.pop(1)
data = {"role": "system", "content": "你现在在qq群聊聊天回复一定要口语化这非常重要不要使用markdown。如果在讲解概念、题目请详细回复50字以上如果是闲聊回复严禁超出35个字。"}
history.role_chat_history.append(data)
#data = {"role": "system", "content": "你现在在qq群聊聊天回复一定要口语化这非常重要不要使用markdown。如果在讲解概念、题目请详细回复50字以上如果是闲聊回复严禁超出35个字。"}
#history.role_chat_history.append(data)
print(history.role_chat_history)
await history.save()