fix(ai_chat): 尝试修改提示词逻辑

This commit is contained in:
ClovertaTheTrilobita 2025-12-15 02:44:36 +00:00
parent 869dbd16b3
commit 68cfbb3972
2 changed files with 6 additions and 5 deletions

View file

@ -65,7 +65,6 @@ async def silicon_flow(group_openid, content):
async with aiohttp.ClientSession() as session: async with aiohttp.ClientSession() as session:
async with session.post(url, json=payload, headers=headers) as response: async with session.post(url, json=payload, headers=headers) as response:
result = await response.json() result = await response.json()
print(result)
reply_content = result["choices"][0]["message"]["content"] reply_content = result["choices"][0]["message"]["content"]
await GroupChatRole.save_chat_history(group_openid, {"role": "assistant", "content": reply_content}) await GroupChatRole.save_chat_history(group_openid, {"role": "assistant", "content": reply_content})

View file

@ -210,7 +210,7 @@ class GroupChatRole(Model):
role_setting = await ChatRole.get_role_setting(role_name=role_name) role_setting = await ChatRole.get_role_setting(role_name=role_name)
if role_setting: if role_setting:
existing_record.role_name = role_name 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 existing_record.role_chat_history = data
await existing_record.save() await existing_record.save()
return "设定成功" return "设定成功"
@ -235,10 +235,12 @@ class GroupChatRole(Model):
await history.save() await history.save()
else: else:
history.role_chat_history.append(content) 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.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() await history.save()
@classmethod @classmethod