mirror of
https://github.com/ClovertaTheTrilobita/SanYeCao-Nonebot.git
synced 2026-04-01 22:04:51 +00:00
fix(ai_chat): 尝试修改提示词逻辑
This commit is contained in:
parent
869dbd16b3
commit
68cfbb3972
2 changed files with 6 additions and 5 deletions
|
|
@ -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})
|
||||||
|
|
|
||||||
|
|
@ -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,9 +235,11 @@ 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])
|
|
||||||
|
data = {"role": "system", "content": "你现在在qq群聊聊天,回复一定要口语化(这非常重要),回复尽可能在10字以内,禁止超出50字。"}
|
||||||
|
history.role_chat_history.append(data)
|
||||||
print(history.role_chat_history)
|
print(history.role_chat_history)
|
||||||
await history.save()
|
await history.save()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue