feat(planner): 实现大小脑规划器分离以优化决策流程

将规划器(Planner)拆分为“大脑”和“小脑”两个部分,以实现更精细化的决策控制。

- **大脑(BIG_BRAIN)**: 负责宏观决策,如是否回复、是否需要@人等高层级意图。
- **小脑(SMALL_BRAIN)**: 负责具体的功能性动作执行。

此重构引入了 `PlannerType` 枚举,并更新了动作(Action)定义,允许将动作明确分配给大脑或小脑,从而提升了AI回复的逻辑性和条理性。同时,新增了 `no_action` 类型,用于在规划阶段明确表示“无动作”,提高了处理流程的清晰度。
This commit is contained in:
minecraft1024a
2025-09-06 20:49:56 +08:00
parent c097b5d00b
commit 132354804c
5 changed files with 38 additions and 27 deletions

View File

@@ -6,7 +6,7 @@ from typing import Tuple, Optional
from src.common.logger import get_logger
from src.chat.message_receive.chat_stream import ChatStream
from src.plugin_system.base.component_types import ActionActivationType, ChatMode, ActionInfo, ComponentType, ChatType
from src.plugin_system.base.component_types import ActionActivationType, ChatMode, ActionInfo, ComponentType, ChatType,PlannerType
from src.plugin_system.apis import send_api, database_api, message_api
@@ -92,6 +92,8 @@ class BaseAction(ABC):
self.parallel_action: bool = getattr(self.__class__, "parallel_action", True)
self.associated_types: list[str] = getattr(self.__class__, "associated_types", []).copy()
self.chat_type_allow: ChatType = getattr(self.__class__, "chat_type_allow", ChatType.ALL)
self.planner_type: PlannerType = getattr(self.__class__, "planner_type", ChatType.ALL)
# =============================================================================
# 便捷属性 - 直接在初始化时获取常用聊天信息(带类型注解)

View File

@@ -51,6 +51,17 @@ class ChatMode(Enum):
# 聊天类型枚举
class PlannerType(Enum):
"""规划器类型枚举"""
BIG_BRAIN = "big_brain" # 大脑,负责宏观决策
SMALL_BRAIN = "small_brain" # 小脑,负责具体动作
ALL = "all" # 通用
def __str__(self):
return self.value
class ChatType(Enum):
"""聊天类型枚举,用于限制插件在不同聊天环境中的使用"""
@@ -140,6 +151,7 @@ class ActionInfo(ComponentInfo):
mode_enable: ChatMode = ChatMode.ALL
parallel_action: bool = False
chat_type_allow: ChatType = ChatType.ALL # 允许的聊天类型
planner_type: PlannerType = PlannerType.ALL
def __post_init__(self):
super().__post_init__()
@@ -215,27 +227,7 @@ class EventInfo(ComponentInfo):
def __post_init__(self):
super().__post_init__()
self.component_type = ComponentType.EVENT
# 事件类型枚举
class EventType(Enum):
"""
事件类型枚举类
"""
ON_START = "on_start" # 启动事件,用于调用按时任务
ON_STOP = "on_stop" # 停止事件,用于调用按时任务
ON_MESSAGE = "on_message"
ON_PLAN = "on_plan"
POST_LLM = "post_llm"
AFTER_LLM = "after_llm"
POST_SEND = "post_send"
AFTER_SEND = "after_send"
UNKNOWN = "unknown" # 未知事件类型
def __str__(self) -> str:
return self.value
self.component_type = ComponentType.EVENT_HANDLER
@dataclass