refactor(planner): 采用统一的多动作决策模型取代大脑/小脑架构

本次更新彻底重构了动作规划器(Planner)的核心架构,废弃了原有的“大脑/小脑”并行决策模型,转而采用一个更简洁、高效的统一决策模型。

主要变更:
- **统一决策**: 单个LLM调用现在可以一次性决策出所有需要执行的动作,并以JSON列表的形式返回。
- **架构简化**: 完全移除了 `sub_plan`(小脑)逻辑、`planner_small` 模型以及相关的并行处理和结果合并代码,大幅降低了复杂性。
- **配置精简**: 从配置文件中删除了与小脑相关的 `planner_size` 和 `include_personality` 选项,简化了用户配置。
- **提示词更新**: 更新了规划器的Prompt,明确指示LLM返回一个动作列表,即使只有一个动作或没有动作。

带来的好处:
- **性能提升**: 减少了LLM API的调用次数,显著降低了单次规划的延迟和成本。
- **可维护性**: 代码逻辑更清晰、线性,易于理解和后续维护。
- **稳定性**: 减少了多路并发带来的不确定性和潜在的竞态问题。

BREAKING CHANGE: 移除了大脑/小脑规划器架构。
用户需要从 `model_config.toml` 中移除 `[model_task_config.planner_small]` 配置节,并从 `bot_config.toml` 中移除 `planner_size` 和 `include_personality` 配置项。
This commit is contained in:
tt-P607
2025-09-09 09:25:25 +08:00
parent 76646e5d85
commit 2a82dfb703
7 changed files with 59 additions and 302 deletions

View File

@@ -90,20 +90,20 @@ class CycleTracker:
timer_strings.append(f"{name}: {formatted_time}")
# 获取动作类型,兼容新旧格式
# 获取动作类型
action_type = "未知动作"
if hasattr(self, "_current_cycle_detail") and self._current_cycle_detail:
loop_plan_info = self._current_cycle_detail.loop_plan_info
if isinstance(loop_plan_info, dict):
action_result = loop_plan_info.get("action_result", {})
if isinstance(action_result, dict):
# 旧格式action_result是字典
action_type = action_result.get("action_type", "未知动作")
elif isinstance(action_result, list) and action_result:
# 新格式action_result是actions列表
action_type = action_result[0].get("action_type", "未知动作")
elif isinstance(loop_plan_info, list) and loop_plan_info:
# 直接是actions列表的情况
action_type = loop_plan_info[0].get("action_type", "未知动作")
if self.context.current_cycle_detail:
loop_plan_info = self.context.current_cycle_detail.loop_plan_info
actions = loop_plan_info.get("action_result")
if isinstance(actions, list) and actions:
# 从actions列表中提取所有action_type
action_types = [a.get("action_type", "未知") for a in actions]
action_type = ", ".join(action_types)
elif isinstance(actions, dict):
# 兼容旧格式
action_type = actions.get("action_type", "未知动作")
if self.context.current_cycle_detail.end_time and self.context.current_cycle_detail.start_time:
duration = self.context.current_cycle_detail.end_time - self.context.current_cycle_detail.start_time

View File

@@ -43,7 +43,7 @@ class SmartReminderAnalyzer:
self.confidence_threshold = 0.7
# 使用规划器模型进行分析
self.analyzer_llm = LLMRequest(
model_set=model_config.model_task_config.planner_small,
model_set=model_config.model_task_config.utils_small,
request_type="reminder_analyzer"
)