feat(planner): 重构动作决策逻辑与参数提取机制
本次提交对动作规划器(Planner)和动作(Action)的执行流程进行了重大重构,旨在提高决策的准确性和可靠性,使机器人能更精确地响应用户指令。 核心变更: - **决策与参数提取分离**: 规划器(Planner)现在专注于根据用户意图选择最合适的动作,不再负责提取动作参数。 - **动作参数自解析**: `RemindAction` 等动作现在通过内部调用 LLM,从用户消息中自行解析所需参数,使其更加独立和健壮。 - **优化决策Prompt**: 引入“最高优先级检查”和“互斥原则”,强制优先执行由明确意图触发的特定动作(如 `set_reminder`),并在此情况下禁止选择 `reply`,避免重复响应。 - **增强调试**: 在处理循环中增加了日志,以清晰地记录LLM最终选择的动作组合,方便调试。
This commit is contained in:
@@ -205,6 +205,13 @@ class CycleProcessor:
|
||||
raise UserWarning(f"插件{result.get_summary().get('stopped_handlers', '')}于规划前中断了内容生成")
|
||||
with Timer("规划器", cycle_timers):
|
||||
actions, _ = await self.action_planner.plan(mode=mode)
|
||||
|
||||
# 在这里添加日志,清晰地显示最终选择的动作
|
||||
if actions:
|
||||
chosen_actions = [a.get("action_type", "unknown") for a in actions]
|
||||
logger.info(f"{self.log_prefix} LLM最终选择的动作: {chosen_actions}")
|
||||
else:
|
||||
logger.info(f"{self.log_prefix} LLM最终没有选择任何动作")
|
||||
|
||||
async def execute_action(action_info):
|
||||
"""执行单个动作的通用函数"""
|
||||
|
||||
Reference in New Issue
Block a user