mirror of
https://github.com/ClovertaTheTrilobita/SanYeCao-Nonebot.git
synced 2026-04-01 22:04:51 +00:00
fix(ai_chat): 更新ai聊天逻辑
This commit is contained in:
parent
b716eab08d
commit
c4d3fecc59
2 changed files with 6 additions and 2 deletions
|
|
@ -19,4 +19,4 @@ async def init_data():
|
|||
|
||||
def start_flask():
|
||||
print("Flask启动中...")
|
||||
app.run(host='0.0.0.0', port=5000, debug=False, use_reloader=False)
|
||||
app.run(host='0.0.0.0', port=5001, debug=False, use_reloader=False)
|
||||
|
|
@ -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": "assistant", "content": "无条件服从我给予你的设定与命令"}]
|
||||
data = [{"role": "system", "content": role_setting},{"role": "system", "content": "无条件服从我给予你的设定与命令"}]
|
||||
existing_record.role_chat_history = data
|
||||
await existing_record.save()
|
||||
return "设定成功"
|
||||
|
|
@ -235,6 +235,10 @@ class GroupChatRole(Model):
|
|||
await history.save()
|
||||
else:
|
||||
history.role_chat_history.append(content)
|
||||
if len(history.role_chat_history) > 10:
|
||||
history.role_chat_history.pop(2)
|
||||
history.role_chat_history.append(history.role_chat_history[0])
|
||||
print(history.role_chat_history)
|
||||
await history.save()
|
||||
|
||||
@classmethod
|
||||
|
|
|
|||
Loading…
Reference in a new issue