history 重构

This commit is contained in:
CakeCN
2025-12-14 14:07:27 +08:00
parent 5438dc99ba
commit 1f6e75f006
4 changed files with 70 additions and 38 deletions

View File

@@ -33,10 +33,15 @@ def on_connect_to_ase(client, entry, init_data, **kwargs):
namespace_entry.emit('message', "Agents服务已连接, 加载教案中", room=init_data['room'], namespace='/agent')
restart = init_data.get("restart", False)
if restart: # 重启时,从-1章进入 0章
ase_client.chatmanager.next_chapter()
# 不再需要手动next_chapter因为已经在on_login中根据mongo进度恢复了正确的章节
# if restart: # 重启时,从-1章进入 0章
# ase_client.chatmanager.next_chapter()
# 根据restart决定是否重新加载代码
ase_client.chatmanager.load_now_chapter(load_code=restart)
print("load_now_chapter with restart:", restart)
# 只有当需要restart时才发送chapter-start
if restart:
ase_client.send_text("chapter-start", "")
namespace_entry.emit('message', "教案加载完毕", room=init_data['room'], namespace='/agent')