feat(planner): 实现大小脑规划器分离以优化决策流程
将规划器(Planner)拆分为“大脑”和“小脑”两个部分,以实现更精细化的决策控制。 - **大脑(BIG_BRAIN)**: 负责宏观决策,如是否回复、是否需要@人等高层级意图。 - **小脑(SMALL_BRAIN)**: 负责具体的功能性动作执行。 此重构引入了 `PlannerType` 枚举,并更新了动作(Action)定义,允许将动作明确分配给大脑或小脑,从而提升了AI回复的逻辑性和条理性。同时,新增了 `no_action` 类型,用于在规划阶段明确表示“无动作”,提高了处理流程的清晰度。
This commit is contained in:
committed by
Windpicker-owo
parent
cfffc69e20
commit
a30652b0bc
@@ -23,7 +23,13 @@ from src.chat.utils.chat_message_builder import (
|
||||
from src.chat.utils.utils import get_chat_type_and_target_info
|
||||
from src.chat.planner_actions.action_manager import ActionManager
|
||||
from src.chat.message_receive.chat_stream import get_chat_manager
|
||||
from src.plugin_system.base.component_types import ActionInfo, ChatMode, ComponentType, ActionActivationType
|
||||
from src.plugin_system.base.component_types import (
|
||||
ActionInfo,
|
||||
ChatMode,
|
||||
ComponentType,
|
||||
ActionActivationType,
|
||||
PlannerType,
|
||||
)
|
||||
from src.plugin_system.core.component_registry import component_registry
|
||||
from src.schedule.schedule_manager import schedule_manager
|
||||
from src.mood.mood_manager import mood_manager
|
||||
@@ -503,6 +509,9 @@ class ActionPlanner:
|
||||
try:
|
||||
sub_planner_actions: Dict[str, ActionInfo] = {}
|
||||
for action_name, action_info in available_actions.items():
|
||||
if action_info.planner_type not in [PlannerType.SMALL_BRAIN, PlannerType.ALL]:
|
||||
continue
|
||||
|
||||
if action_info.activation_type in [ActionActivationType.LLM_JUDGE, ActionActivationType.ALWAYS]:
|
||||
sub_planner_actions[action_name] = action_info
|
||||
elif action_info.activation_type == ActionActivationType.RANDOM:
|
||||
@@ -550,10 +559,15 @@ class ActionPlanner:
|
||||
# --- 3. 大脑独立思考是否回复 ---
|
||||
action, reasoning, action_data, target_message = "no_reply", "大脑初始化默认", {}, None
|
||||
try:
|
||||
big_brain_actions = {
|
||||
name: info
|
||||
for name, info in available_actions.items()
|
||||
if info.planner_type in [PlannerType.BIG_BRAIN, PlannerType.ALL]
|
||||
}
|
||||
prompt, _ = await self.build_planner_prompt(
|
||||
is_group_chat=is_group_chat,
|
||||
chat_target_info=chat_target_info,
|
||||
current_available_actions={}, # 大脑不考虑具体action
|
||||
current_available_actions=big_brain_actions,
|
||||
mode=mode,
|
||||
chat_content_block_override=chat_content_block,
|
||||
message_id_list_override=message_id_list,
|
||||
|
||||
Reference in New Issue
Block a user