From d95f73d52ff90def6fc54101be3c08f5b7f4c7bf Mon Sep 17 00:00:00 2001 From: tt-P607 <68868379+tt-P607@users.noreply.github.com> Date: Wed, 10 Sep 2025 09:43:51 +0800 Subject: [PATCH] =?UTF-8?q?fix(chat):=20=E4=BF=AE=E5=A4=8D=E7=A9=BA?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E5=BC=95=E7=94=A8=E5=B9=B6=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E5=8A=A8=E4=BD=9C=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 `DefaultReplyer` 中增加了对 `reply_message` 的空值检查,以避免在无回复上下文时引发错误。 - 在 `ActionPlanner` 中将 'do_nothing' 添加到非目标动作列表中,以正确处理此新增的无操作指令。 - 将 `EmojiAction` 使用的 LLM 模型从 'utils_small' 更新为 'planner',以适应模型配置的变更。 --- src/chat/planner_actions/planner.py | 4 ++-- src/chat/replyer/default_generator.py | 3 +++ src/plugins/built_in/core_actions/emoji.py | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/chat/planner_actions/planner.py b/src/chat/planner_actions/planner.py index 0ddbfcb73..abf543ec0 100644 --- a/src/chat/planner_actions/planner.py +++ b/src/chat/planner_actions/planner.py @@ -319,7 +319,7 @@ class ActionPlanner: action_data = {k: v for k, v in action_json.items() if k not in ["action", "reason"]} target_message = None - if action not in ["no_action", "no_reply"]: + if action not in ["no_action", "no_reply", "do_nothing"]: if target_message_id := action_json.get("target_message_id"): target_message = self.find_message_by_id(target_message_id, message_id_list) if target_message is None: @@ -329,7 +329,7 @@ class ActionPlanner: logger.warning(f"{self.log_prefix}动作'{action}'缺少target_message_id") available_action_names = [name for name, _ in current_available_actions] - if action not in ["no_action", "no_reply", "reply"] and action not in available_action_names: + if action not in ["no_action", "no_reply", "reply", "do_nothing"] and action not in available_action_names: logger.warning( f"{self.log_prefix}LLM 返回了当前不可用或无效的动作: '{action}' (可用: {available_action_names}),将强制使用 'no_action'" ) diff --git a/src/chat/replyer/default_generator.py b/src/chat/replyer/default_generator.py index 7045b60e6..ef9cce84d 100644 --- a/src/chat/replyer/default_generator.py +++ b/src/chat/replyer/default_generator.py @@ -823,6 +823,9 @@ class DefaultReplyer: sender, target = self._parse_reply_target(reply_to) else: # 获取 platform,如果不存在则从 chat_stream 获取,如果还是 None 则使用默认值 + if reply_message is None: + logger.warning("reply_message 为 None,无法构建prompt") + return "" platform = reply_message.get("chat_info_platform") person_id = person_info_manager.get_person_id( platform, # type: ignore diff --git a/src/plugins/built_in/core_actions/emoji.py b/src/plugins/built_in/core_actions/emoji.py index e040d9c37..154903d4c 100644 --- a/src/plugins/built_in/core_actions/emoji.py +++ b/src/plugins/built_in/core_actions/emoji.py @@ -132,7 +132,7 @@ class EmojiAction(BaseAction): # 5. 调用LLM models = llm_api.get_available_models() - chat_model_config = models.get("utils_small") + chat_model_config = models.get("planner") if not chat_model_config: logger.error(f"{self.log_prefix} 未找到'utils_small'模型配置,无法调用LLM") return False, "未找到'utils_small'模型配置"