fix(planner): 当缺少 target_id 时确保设置动作消息
当 LLM 规划器没有为某个动作指定 `target_message_id` 时,系统现在将默认使用上下文中的最新消息。这确保了需要消息上下文的动作(如引用或回复)有一个有效的 `action_message` 对象,从而防止潜在的 `None` 引用错误。
This commit is contained in:
@@ -551,10 +551,24 @@ class ChatterPlanFilter:
|
|||||||
available_actions=plan.available_actions,
|
available_actions=plan.available_actions,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
# 如果LLM没有指定target_message_id,统一使用最新消息
|
||||||
|
target_message_dict = self._get_latest_message(message_id_list)
|
||||||
|
action_message_obj = None
|
||||||
|
if target_message_dict:
|
||||||
|
from src.common.data_models.database_data_model import DatabaseMessages
|
||||||
|
try:
|
||||||
|
action_message_obj = DatabaseMessages(**target_message_dict)
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(
|
||||||
|
f"[{action}] 无法将默认的最新消息转换为 DatabaseMessages 对象: {e}",
|
||||||
|
exc_info=True,
|
||||||
|
)
|
||||||
|
|
||||||
return ActionPlannerInfo(
|
return ActionPlannerInfo(
|
||||||
action_type=action,
|
action_type=action,
|
||||||
reasoning=reasoning,
|
reasoning=reasoning,
|
||||||
action_data=action_data,
|
action_data=action_data,
|
||||||
|
action_message=action_message_obj,
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"解析单个action时出错: {e}")
|
logger.error(f"解析单个action时出错: {e}")
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class TTSVoicePlugin(BasePlugin):
|
|||||||
plugin_description = "基于GPT-SoVITS的文本转语音插件(重构版)"
|
plugin_description = "基于GPT-SoVITS的文本转语音插件(重构版)"
|
||||||
plugin_version = "3.1.2"
|
plugin_version = "3.1.2"
|
||||||
plugin_author = "Kilo Code & 靚仔"
|
plugin_author = "Kilo Code & 靚仔"
|
||||||
enable_plugin = False
|
enable_plugin = True
|
||||||
config_file_name = "config.toml"
|
config_file_name = "config.toml"
|
||||||
dependencies: ClassVar[list[str]] = []
|
dependencies: ClassVar[list[str]] = []
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user