feat(planner): 引入双模动作激活机制与混合触发类型
为了更精细地控制动作在不同聊天模式下的行为,并提升决策效率,本次更新引入了全新的动作激活机制。 - **双模激活**: 为 Action 新增 `normal_activation_type` 和 `focus_activation_type` 属性,允许插件在 `NORMAL` 和 `FOCUS` 模式下拥有不同的激活策略,使行为更符合上下文。 - **混合触发**: 新增 `KEYWORD_OR_LLM_JUDGE` 激活类型。该类型会先进行快速的关键词匹配,若未匹配成功,则回退至 LLM 进行判断,兼顾了响应速度和智能化。 - **流程优化**: 重构了 `PlanGenerator` 的动作筛选逻辑,使其在生成计划前,就根据当前聊天模式和简单的激活规则进行预筛选,为后续的 LLM 决策提供更精准、更高效的候选动作列表。
This commit is contained in:
@@ -135,6 +135,16 @@ class CycleProcessor:
|
||||
action_type = "no_action"
|
||||
reply_text = "" # 初始化reply_text变量,避免UnboundLocalError
|
||||
|
||||
|
||||
# 开始新的思考循环
|
||||
cycle_timers, thinking_id = self.cycle_tracker.start_cycle()
|
||||
logger.info(f"{self.log_prefix} 开始第{self.context.cycle_counter}次思考")
|
||||
|
||||
if ENABLE_S4U and self.context.chat_stream and self.context.chat_stream.user_info:
|
||||
await send_typing(self.context.chat_stream.user_info.user_id)
|
||||
|
||||
loop_start_time = time.time()
|
||||
|
||||
# 使用sigmoid函数将interest_value转换为概率
|
||||
# 当interest_value为0时,概率接近0(使用Focus模式)
|
||||
# 当interest_value很高时,概率接近1(使用Normal模式)
|
||||
@@ -188,7 +198,7 @@ class CycleProcessor:
|
||||
# 第一步:动作修改
|
||||
with Timer("动作修改", cycle_timers):
|
||||
try:
|
||||
await self.action_modifier.modify_actions()
|
||||
await self.action_modifier.modify_actions(mode=mode)
|
||||
available_actions = self.context.action_manager.get_using_actions()
|
||||
except Exception as e:
|
||||
logger.error(f"{self.context.log_prefix} 动作修改失败: {e}")
|
||||
|
||||
Reference in New Issue
Block a user