From cbbb5746cece990511e35af6c0492f543ae5ea1a Mon Sep 17 00:00:00 2001 From: minecraft1024a Date: Sun, 14 Sep 2025 14:59:32 +0800 Subject: [PATCH] =?UTF-8?q?chore(log):=20=E7=A7=BB=E9=99=A4=E8=B0=83?= =?UTF-8?q?=E8=AF=95=E6=97=A5=E5=BF=97=E5=B9=B6=E5=B0=86=E9=83=A8=E5=88=86?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E7=BA=A7=E5=88=AB=E9=99=8D=E4=B8=BAdebug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将规划器和过滤器中的临时调试日志移除,并将部分用于追踪流程的info级别日志调整为debug级别,以减少在生产环境中的日志噪音。 同时,在`cycle_processor.py`中增加了对事件处理结果的空值检查,以增强代码的健壮性。(也许是bug真的能修好了——) --- src/chat/chat_loop/cycle_processor.py | 13 ++++++++----- src/chat/planner_actions/plan_filter.py | 10 +++++----- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/chat/chat_loop/cycle_processor.py b/src/chat/chat_loop/cycle_processor.py index 849602367..3748c5780 100644 --- a/src/chat/chat_loop/cycle_processor.py +++ b/src/chat/chat_loop/cycle_processor.py @@ -201,11 +201,11 @@ class CycleProcessor: result = await event_manager.trigger_event( EventType.ON_PLAN, permission_group="SYSTEM", stream_id=self.context.chat_stream ) - if not result.all_continue_process(): + if result and not result.all_continue_process(): raise UserWarning(f"插件{result.get_summary().get('stopped_handlers', '')}于规划前中断了内容生成") with Timer("规划器", cycle_timers): actions, _ = await self.action_planner.plan(mode=mode) - logger.info(f"如果你探到这条日志请把它复制下来发到Q群里,如果你探到这条日志请把它复制下来发到Q群里,如果你探到这条日志请把它复制下来发到Q群里,调试内容",str(actions)) + async def execute_action(action_info): """执行单个动作的通用函数""" try: @@ -298,9 +298,12 @@ class CycleProcessor: if reply_actions: logger.info(f"{self.log_prefix} 正在执行文本回复...") for action in reply_actions: - target_user_id = action.get("action_message",{}).get("chat_info_user_id","") - action_message_test =action.get("action_message",{}) - logger.info(f"如果你探到这条日志请把它复制下来发到Q群里,如果你探到这条日志请把它复制下来发到Q群里,如果你探到这条日志请把它复制下来发到Q群里,调试内容:{action_message_test}") + action_message = action.get("action_message") + if not action_message: + logger.warning(f"{self.log_prefix} reply 动作缺少 action_message,跳过") + continue + + target_user_id = action_message.get("chat_info_user_id","") if target_user_id == global_config.bot.qq_account and not global_config.chat.allow_reply_self: logger.warning("选取的reply的目标为bot自己,跳过reply action") continue diff --git a/src/chat/planner_actions/plan_filter.py b/src/chat/planner_actions/plan_filter.py index a99c2ad03..d76f1aa04 100644 --- a/src/chat/planner_actions/plan_filter.py +++ b/src/chat/planner_actions/plan_filter.py @@ -42,18 +42,18 @@ class PlanFilter: """ 执行筛选逻辑,并填充 Plan 对象的 decided_actions 字段。 """ - logger.info(f"墨墨在这里加了日志 -> filter 入口 plan: {plan}") + logger.debug(f"墨墨在这里加了日志 -> filter 入口 plan: {plan}") try: prompt, used_message_id_list = await self._build_prompt(plan) plan.llm_prompt = prompt - logger.info(f"墨墨在这里加了日志 -> LLM prompt: {prompt}") + logger.debug(f"墨墨在这里加了日志 -> LLM prompt: {prompt}") llm_content, _ = await self.planner_llm.generate_response_async(prompt=prompt) if llm_content: - logger.warning(f"墨墨在这里加了日志 -> LLM a原始返回: {llm_content}") + logger.debug(f"墨墨在这里加了日志 -> LLM a原始返回: {llm_content}") parsed_json = orjson.loads(repair_json(llm_content)) - logger.info(f"墨墨在这里加了日志 -> 解析后的 JSON: {parsed_json}") + logger.debug(f"墨墨在这里加了日志 -> 解析后的 JSON: {parsed_json}") if isinstance(parsed_json, dict): parsed_json = [parsed_json] @@ -95,7 +95,7 @@ class PlanFilter: ActionPlannerInfo(action_type="no_action", reasoning=f"筛选时出错: {e}") ] - logger.info(f"墨墨在这里加了日志 -> filter 出口 decided_actions: {plan.decided_actions}") + logger.debug(f"墨墨在这里加了日志 -> filter 出口 decided_actions: {plan.decided_actions}") return plan async def _build_prompt(self, plan: Plan) -> tuple[str, list]: