load now chapter with restart
This commit is contained in:
@@ -70,10 +70,8 @@ class ASEngineClient:
|
||||
# ACK事件处理
|
||||
@self.sio.on('ack', namespace=self.namespace)
|
||||
def on_ack(data):
|
||||
print(f"Received ACK: {data}")
|
||||
ack_id = data.get('ack_id')
|
||||
if ack_id and ack_id in self.ack_events:
|
||||
print(f"Received ACK for message: {ack_id}")
|
||||
event = self.ack_events[ack_id]
|
||||
event.set() # 触发事件,通知等待的线程
|
||||
|
||||
|
||||
@@ -2,15 +2,15 @@ import requests
|
||||
from flask_socketio import Namespace
|
||||
|
||||
|
||||
def clear_user_session(namespace_entry, user_id):
|
||||
def clear_user_session(asengine_url, asengine_token, user_id):
|
||||
'''
|
||||
快速清理用户会话的函数
|
||||
'''
|
||||
try:
|
||||
base_url = namespace_entry.app.config['ASE_ENGINE_URL']
|
||||
base_url = asengine_url
|
||||
clear_url = f"{base_url}/clear_user_session"
|
||||
payload = {
|
||||
'namespace_url': namespace_entry.app.config['ASE_ENGINE_URL_TOKEN'], # WebSocket命名空间URL
|
||||
'namespace_url': asengine_token, # WebSocket命名空间URL
|
||||
'user_id': user_id, # 用户ID,对应session_info.id
|
||||
'clear_type': 'all' # 清理类型,默认为全部
|
||||
}
|
||||
@@ -31,10 +31,11 @@ def on_connect_to_ase(client, entry, init_data, **kwargs):
|
||||
namespace_entry.emit('open-iframe',"", room=init_data['room'], namespace='/agent')
|
||||
namespace_entry.emit('message', "Agents服务已连接, 加载教案中", room=init_data['room'], namespace='/agent')
|
||||
|
||||
clear_user_session(namespace_entry, init_data['room'])
|
||||
clear_user_session(init_data['asengine_url'], init_data['asengine_token'], init_data['room'])
|
||||
|
||||
restart = init_data.get("restart", False)
|
||||
ase_client.chatmanager.load_now_chapter(load_code=restart)
|
||||
print("load_now_chapter with restart:", restart)
|
||||
if restart:
|
||||
ase_client.send_text("chapter-start", "")
|
||||
namespace_entry.emit('message', "教案加载完毕", room=init_data['room'], namespace='/agent')
|
||||
|
||||
@@ -150,7 +150,7 @@ class AgentNamespace(Namespace):
|
||||
user_uuid2ase_client[user_uuid].register_on_connect_entry(
|
||||
callback=on_connect_to_ase,
|
||||
entry=(self, user_uuid2ase_client[user_uuid]),
|
||||
init_data={'room':user_uuid, 'restart':chatmanager.restart}
|
||||
init_data={'room':user_uuid, 'restart':chatmanager.restart, 'asengine_url':current_app.config["ASE_ENGINE_URL"], 'asengine_token':current_app.config["ASE_ENGINE_URL_TOKEN"]}
|
||||
)
|
||||
user_uuid2ase_client[user_uuid].register_route_with_entry(
|
||||
route='dialog',
|
||||
|
||||
Reference in New Issue
Block a user