logger reduce

This commit is contained in:
CakeCN
2025-12-10 19:22:13 +08:00
parent 889399b8aa
commit dba7914e5d
2 changed files with 24 additions and 30 deletions

View File

@@ -86,7 +86,6 @@ class AgentNamespace(Namespace):
chatmanager.function_manager.add_function(next_chapter, {'user_uuid': user_uuid})
if not chatmanager.restart:# 尝试加载用户学习进度
self.app.logger.info(f"尝试加载用户学习进度: {user_id}, {course_id}, {chapter_name}, {lesson_name}")
progress_result = load_learning_progress(user_id, course_id, chapter_name, lesson_name)
need_skip_chapters = 0
@@ -97,7 +96,6 @@ class AgentNamespace(Namespace):
# 根据scores的数量确定需要跳过的章节数
need_skip_chapters = len(progress['scores'])
chatmanager.scores = progress['scores']
self.app.logger.info(f"恢复用户学习进度: {user_id}, 已完成 {need_skip_chapters} 个章节")
# 恢复聊天历史
if 'chat_historys' in progress:
@@ -113,7 +111,6 @@ class AgentNamespace(Namespace):
# 使用默认值,确保有完整的结构
chatmanager.chat_historys = progress_result['data']['chat_historys']
chatmanager.scores = progress_result['data']['scores']
self.app.logger.info(f"未找到学习记录,使用默认值: {progress_result['message']}")
fmd,fmdp,fsp = load_full_markdown_file(course_id, chapter_name, lesson_name)
user_uuid2ase_client[user_uuid] = HSAEngineClient(current_app.config["ASE_ENGINE_URL"], current_app.config["ASE_ENGINE_NAMESPACE"],id=user_id, chatmanager = chatmanager)
@@ -186,10 +183,8 @@ class AgentNamespace(Namespace):
def on_language(self, language):
ex = current_app.extensions
self.app.logger.info(f"Language changed to: {language}")
def on_message(self, data):
self.app.logger.info(f"Message from client: {data}")
ex = current_app.extensions
chatmanager = ex["user_uuid2chatmanager"]
uuid = session.get('user_uuid')
@@ -199,14 +194,11 @@ class AgentNamespace(Namespace):
if data['type'] == 'text':
res = user_uuid2ase_client[uuid].send_text('dialog', data['data'])
chatmanager[uuid].chat_historys.append({'role': 'user', 'content': data['data']})
self.app.logger.info(f"Send text to route 'dialog' success: {res}")
if data['type'] == 'function': # 在这里 前端会发送允许执行的function与参数
self.app.logger.info(f"function_call: {data['data']}")
d = data['data']
res = chatmanager[uuid].function_call(d['data']['name'], d['data'].get('args', {}))
d['data'] = res.to_dict()
self.app.logger.info(f"function_call_res: {d['data']}")
emit(d['route'], d, room=uuid, namespace='/agent')
chatmanager[uuid].chat_historys.append({'role': 'user', 'content': data['data']})
user_uuid2ase_client[uuid].send_text(d['route'], data['data'])
@@ -217,10 +209,9 @@ class AgentNamespace(Namespace):
uuid = session.get('user_uuid')
user_uuid2ase_client = ex["user_uuid2ase_client"]
res = user_uuid2ase_client[uuid].send_voice('voice_in', voice_data['data'])
self.app.logger.info(f"Send voicce to route 'voice_in' success: {res}")
def on_initiative(self,data): # 主动call
self.app.logger.info("User active function call")
ex = current_app.extensions
uuid = session.get('user_uuid')
manager = ex["user_uuid2chatmanager"][uuid]
@@ -248,7 +239,6 @@ class AgentNamespace(Namespace):
chatmanager = user_uuid2chatmanager.get(uuid)
if chatmanager:
save_result = save_learning_progress(chatmanager, user_id)
self.app.logger.info(f"保存学习进度结果: {save_result}")
except Exception as e:
self.app.logger.error(f"保存学习进度时发生异常: {str(e)}")