diff --git a/backend.py b/backend.py index e40b09c..d39b073 100644 --- a/backend.py +++ b/backend.py @@ -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) \ No newline at end of file + app.run(host='0.0.0.0', port=5001, debug=False, use_reloader=False) \ No newline at end of file diff --git a/src/clover_sqlite/models/chat.py b/src/clover_sqlite/models/chat.py index 9ef7156..5b69af8 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": "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