From 3368c38d05362ad2fad116e2257c23331854a198 Mon Sep 17 00:00:00 2001 From: SengokuCola <1026294844@qq.com> Date: Sun, 30 Nov 2025 16:57:15 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E4=BC=98=E5=8C=96=E9=83=A8?= =?UTF-8?q?=E5=88=86Log?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/chat/emoji_system/emoji_manager.py | 2 +- src/chat/utils/memory_forget_task.py | 4 +-- src/express/expression_selector.py | 3 +- .../chat_history_summarizer.py | 4 +-- src/jargon/jargon_explainer.py | 2 +- src/memory_system/memory_retrieval.py | 31 +++++++++++-------- src/plugin_system/apis/emoji_api.py | 2 +- src/plugin_system/core/tool_use.py | 2 +- 8 files changed, 27 insertions(+), 23 deletions(-) diff --git a/src/chat/emoji_system/emoji_manager.py b/src/chat/emoji_system/emoji_manager.py index f2609531..cfa86320 100644 --- a/src/chat/emoji_system/emoji_manager.py +++ b/src/chat/emoji_system/emoji_manager.py @@ -356,7 +356,7 @@ async def clean_unused_emojis(emoji_dir: str, emoji_objects: List["MaiEmoji"], r if cleaned_count > 0: logger.info(f"[清理] 在目录 {emoji_dir} 中清理了 {cleaned_count} 个破损表情包。") else: - logger.info(f"[清理] 目录 {emoji_dir} 中没有需要清理的。") + logger.debug(f"[清理] 目录 {emoji_dir} 中没有需要清理的。") except Exception as e: logger.error(f"[错误] 清理未使用表情包文件时出错 ({emoji_dir}): {str(e)}") diff --git a/src/chat/utils/memory_forget_task.py b/src/chat/utils/memory_forget_task.py index 15a912b4..cd9144a1 100644 --- a/src/chat/utils/memory_forget_task.py +++ b/src/chat/utils/memory_forget_task.py @@ -25,7 +25,7 @@ class MemoryForgetTask(AsyncTask): """执行遗忘检查""" try: current_time = time.time() - logger.info("[记忆遗忘] 开始遗忘检查...") + # logger.info("[记忆遗忘] 开始遗忘检查...") # 执行4个阶段的遗忘检查 await self._forget_stage_1(current_time) @@ -33,7 +33,7 @@ class MemoryForgetTask(AsyncTask): await self._forget_stage_3(current_time) await self._forget_stage_4(current_time) - logger.info("[记忆遗忘] 遗忘检查完成") + # logger.info("[记忆遗忘] 遗忘检查完成") except Exception as e: logger.error(f"[记忆遗忘] 执行遗忘检查时出错: {e}", exc_info=True) diff --git a/src/express/expression_selector.py b/src/express/expression_selector.py index 7ac5ef88..8d586d5d 100644 --- a/src/express/expression_selector.py +++ b/src/express/expression_selector.py @@ -151,7 +151,6 @@ class ExpressionSelector: else: selected_style = [] - logger.info(f"随机选择,为聊天室 {chat_id} 选择了 {len(selected_style)} 个表达方式") return selected_style except Exception as e: @@ -294,7 +293,7 @@ class ExpressionSelector: if valid_expressions: self.update_expressions_last_active_time(valid_expressions) - logger.info(f"classic模式从{len(all_expressions)}个情境中选择了{len(valid_expressions)}个") + logger.debug(f"从{len(all_expressions)}个情境中选择了{len(valid_expressions)}个") return valid_expressions, selected_ids except Exception as e: diff --git a/src/hippo_memorizer/chat_history_summarizer.py b/src/hippo_memorizer/chat_history_summarizer.py index 357f46dd..70847de0 100644 --- a/src/hippo_memorizer/chat_history_summarizer.py +++ b/src/hippo_memorizer/chat_history_summarizer.py @@ -326,7 +326,7 @@ class ChatHistorySummarizer: start_time=new_messages[0].time if new_messages else current_time, end_time=current_time, ) - logger.info(f"{self.log_prefix} 新建聊天检查批次: {len(new_messages)} 条消息") + logger.debug(f"{self.log_prefix} 新建聊天检查批次: {len(new_messages)} 条消息") # 创建批次后持久化 self._persist_topic_cache() @@ -362,7 +362,7 @@ class ChatHistorySummarizer: else: time_str = f"{time_since_last_check / 3600:.1f}小时" - logger.info( + logger.debug( f"{self.log_prefix} 批次状态检查 | 消息数: {message_count} | 距上次检查: {time_str}" ) diff --git a/src/jargon/jargon_explainer.py b/src/jargon/jargon_explainer.py index 67a008b5..02595080 100644 --- a/src/jargon/jargon_explainer.py +++ b/src/jargon/jargon_explainer.py @@ -138,7 +138,7 @@ class JargonExplainer: query_duration = query_time - start_time match_duration = match_time - query_time - logger.info( + logger.debug( f"黑话匹配完成: 查询耗时 {query_duration:.3f}s, 匹配耗时 {match_duration:.3f}s, " f"总耗时 {total_time:.3f}s, 匹配到 {len(matched_jargon)} 个黑话" ) diff --git a/src/memory_system/memory_retrieval.py b/src/memory_system/memory_retrieval.py index a4de5f26..c46036e6 100644 --- a/src/memory_system/memory_retrieval.py +++ b/src/memory_system/memory_retrieval.py @@ -114,9 +114,9 @@ def init_memory_retrieval_prompt(): **执行步骤:** **第一步:思考(Think)** 在思考中分析: -- 当前信息是否足够回答问题? +- 当前信息是否足够回答问题({question})? - **如果信息足够且能找到明确答案**,在思考中直接给出答案,格式为:found_answer(answer="你的答案内容") -- **如果需要尝试搜集更多信息,进一步调用工具,进入第二步行动环节 +- **如果信息不足以解答问题,需要尝试搜集更多信息,进一步调用工具,进入第二步行动环节 - **如果已有信息不足或无法找到答案,决定结束查询**,在思考中给出:not_enough_info(reason="结束查询的原因") **第二步:行动(Action)** @@ -229,6 +229,7 @@ async def _retrieve_concepts_with_jargon(concepts: List[str], chat_id: str) -> s from src.jargon.jargon_miner import search_jargon results = [] + exact_matches = [] # 收集所有精确匹配的概念 for concept in concepts: concept = concept.strip() if not concept: @@ -264,11 +265,15 @@ async def _retrieve_concepts_with_jargon(concepts: List[str], chat_id: str) -> s if meaning: output_parts.append(f"'{concept}' 为黑话或者网络简写,含义为:{meaning}") results.append(";".join(output_parts) if len(output_parts) > 1 else output_parts[0]) - logger.info(f"在jargon库中找到匹配(精确匹配): {concept},找到{len(jargon_results)}条结果") + exact_matches.append(concept) # 收集精确匹配的概念,稍后统一打印 else: # 未找到,不返回占位信息,只记录日志 logger.info(f"在jargon库中未找到匹配: {concept}") + # 合并所有精确匹配的日志 + if exact_matches: + logger.info(f"找到黑话: {', '.join(exact_matches)},共找到{len(exact_matches)}条结果") + if results: return "【概念检索结果】\n" + "\n".join(results) + "\n" return "" @@ -276,7 +281,7 @@ async def _retrieve_concepts_with_jargon(concepts: List[str], chat_id: str) -> s def _match_jargon_from_text(chat_text: str, chat_id: str) -> List[str]: """直接在聊天文本中匹配已知的jargon,返回出现过的黑话列表""" - print(chat_text) + # print(chat_text) if not chat_text or not chat_text.strip(): return [] @@ -310,10 +315,10 @@ def _match_jargon_from_text(chat_text: str, chat_id: str) -> List[str]: if re.search(search_pattern, chat_text, re.IGNORECASE): matched[content] = None - end_time = time.time() + # end_time = time.time() logger.info( - f"记忆检索黑话匹配: 查询耗时 {(query_time - start_time):.3f}s, " - f"匹配耗时 {(end_time - query_time):.3f}s, 总耗时 {(end_time - start_time):.3f}s, " + # f"记忆检索黑话匹配: 查询耗时 {(query_time - start_time):.3f}s, " + # f"匹配耗时 {(end_time - query_time):.3f}s, 总耗时 {(end_time - start_time):.3f}s, " f"匹配到 {len(matched)} 个黑话" ) @@ -827,7 +832,7 @@ def _store_thinking_back( create_time=now, update_time=now, ) - logger.info(f"已创建思考过程到数据库,问题: {question[:50]}...") + # logger.info(f"已创建思考过程到数据库,问题: {question[:50]}...") except Exception as e: logger.error(f"存储思考过程失败: {e}") @@ -851,14 +856,14 @@ async def _process_single_question( Returns: Optional[str]: 如果找到答案,返回格式化的结果字符串,否则返回None """ - logger.info(f"开始处理问题: {question}") + # logger.info(f"开始处理问题: {question}") _cleanup_stale_not_found_thinking_back() question_initial_info = initial_info or "" # 直接使用ReAct Agent查询(不再从thinking_back获取缓存) - logger.info(f"使用ReAct Agent查询,问题: {question[:50]}...") + # logger.info(f"使用ReAct Agent查询,问题: {question[:50]}...") jargon_concepts_for_agent = initial_jargon_concepts if global_config.memory.enable_jargon_detection else None @@ -942,7 +947,7 @@ async def build_memory_retrieval_prompt( if global_config.debug.show_memory_prompt: logger.info(f"记忆检索问题生成提示词: {question_prompt}") - logger.info(f"记忆检索问题生成响应: {response}") + # logger.info(f"记忆检索问题生成响应: {response}") if not success: logger.error(f"LLM生成问题失败: {response}") @@ -972,7 +977,7 @@ async def build_memory_retrieval_prompt( concept_info = await _retrieve_concepts_with_jargon(concepts, chat_id) if concept_info: initial_info += concept_info - logger.info(f"概念检索完成,结果: {concept_info[:200]}...") + logger.info(f"概念检索完成,结果: {concept_info}") else: logger.info("概念检索未找到任何结果") @@ -984,7 +989,7 @@ async def build_memory_retrieval_prompt( # 第二步:并行处理所有问题(使用配置的最大迭代次数/120秒超时) max_iterations = global_config.memory.max_agent_iterations - logger.info(f"问题数量: {len(questions)},设置最大迭代次数: {max_iterations},超时时间: 120秒") + logger.debug(f"问题数量: {len(questions)},设置最大迭代次数: {max_iterations},超时时间: 120秒") # 并行处理所有问题,将概念检索结果作为初始信息传递 question_tasks = [ diff --git a/src/plugin_system/apis/emoji_api.py b/src/plugin_system/apis/emoji_api.py index e1661887..e4d6fcd7 100644 --- a/src/plugin_system/apis/emoji_api.py +++ b/src/plugin_system/apis/emoji_api.py @@ -104,7 +104,7 @@ async def get_random(count: Optional[int] = 1) -> List[Tuple[str, str, str]]: return [] if len(valid_emojis) < count: - logger.warning( + logger.debug( f"[EmojiAPI] 有效表情包数量 ({len(valid_emojis)}) 少于请求的数量 ({count}),将返回所有有效表情包" ) count = len(valid_emojis) diff --git a/src/plugin_system/core/tool_use.py b/src/plugin_system/core/tool_use.py index 915ed7aa..6d60ee77 100644 --- a/src/plugin_system/core/tool_use.py +++ b/src/plugin_system/core/tool_use.py @@ -95,7 +95,7 @@ class ToolExecutor: # 如果没有可用工具,直接返回空内容 if not tools: - logger.info(f"{self.log_prefix}没有可用工具,直接返回空内容") + logger.debug(f"{self.log_prefix}没有可用工具,直接返回空内容") if return_details: return [], [], "" else: