Revert: 回退并发消息处理系统的相关提交
由于并发消息处理的实现在测试中暴露出消息重复和目标ID丢失的问题,暂时回退至该功能合并前的稳定状态,以便进一步排查问题。
This commit is contained in:
@@ -53,13 +53,12 @@ class AffinityChatter(BaseChatter):
|
||||
}
|
||||
self.last_activity_time = time.time()
|
||||
|
||||
async def execute(self, context: StreamContext, unread_messages: list | None = None) -> dict:
|
||||
async def execute(self, context: StreamContext) -> dict:
|
||||
"""
|
||||
处理StreamContext对象
|
||||
|
||||
Args:
|
||||
context: StreamContext对象,包含聊天流的所有消息信息
|
||||
unread_messages: (可选) 指定要处理的未读消息列表,用于并发处理
|
||||
|
||||
Returns:
|
||||
处理结果字典
|
||||
@@ -69,12 +68,10 @@ class AffinityChatter(BaseChatter):
|
||||
learner = expression_learner_manager.get_expression_learner(self.stream_id)
|
||||
asyncio.create_task(learner.trigger_learning_for_chat())
|
||||
|
||||
# 如果没有提供未读消息列表,则从上下文中获取
|
||||
if unread_messages is None:
|
||||
unread_messages = context.get_unread_messages()
|
||||
unread_messages = context.get_unread_messages()
|
||||
|
||||
# 使用增强版规划器处理消息
|
||||
actions, target_message = await self.planner.plan(context=context, unread_messages=unread_messages)
|
||||
actions, target_message = await self.planner.plan(context=context)
|
||||
self.stats["plans_created"] += 1
|
||||
|
||||
# 执行动作(如果规划器返回了动作)
|
||||
|
||||
@@ -218,6 +218,10 @@ class ChatterPlanFilter:
|
||||
self.last_obs_time_mark = time.time()
|
||||
|
||||
mentioned_bonus = ""
|
||||
if global_config.chat.mentioned_bot_inevitable_reply:
|
||||
mentioned_bonus = "\n- 有人提到你"
|
||||
if global_config.chat.at_bot_inevitable_reply:
|
||||
mentioned_bonus = "\n- 有人提到你,或者at你"
|
||||
|
||||
if plan.mode == ChatMode.FOCUS:
|
||||
no_action_block = """
|
||||
|
||||
@@ -70,15 +70,12 @@ class ChatterActionPlanner:
|
||||
"other_actions_executed": 0,
|
||||
}
|
||||
|
||||
async def plan(
|
||||
self, context: "StreamContext" = None, unread_messages: Optional[List[Dict]] = None
|
||||
) -> Tuple[List[Dict], Optional[Dict]]:
|
||||
async def plan(self, context: "StreamContext" = None) -> Tuple[List[Dict], Optional[Dict]]:
|
||||
"""
|
||||
执行完整的增强版规划流程。
|
||||
|
||||
Args:
|
||||
context (StreamContext): 包含聊天流消息的上下文对象。
|
||||
unread_messages (Optional[List[Dict]]): (可选) 指定要处理的未读消息列表,用于并发处理
|
||||
|
||||
Returns:
|
||||
Tuple[List[Dict], Optional[Dict]]: 一个元组,包含:
|
||||
@@ -88,16 +85,14 @@ class ChatterActionPlanner:
|
||||
try:
|
||||
self.planner_stats["total_plans"] += 1
|
||||
|
||||
return await self._enhanced_plan_flow(context, unread_messages)
|
||||
|
||||
return await self._enhanced_plan_flow(context)
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"规划流程出错: {e}")
|
||||
self.planner_stats["failed_plans"] += 1
|
||||
return [], None
|
||||
|
||||
async def _enhanced_plan_flow(
|
||||
self, context: "StreamContext", unread_messages: Optional[List[Dict]] = None
|
||||
) -> Tuple[List[Dict], Optional[Dict]]:
|
||||
async def _enhanced_plan_flow(self, context: "StreamContext") -> Tuple[List[Dict], Optional[Dict]]:
|
||||
"""执行增强版规划流程"""
|
||||
try:
|
||||
# 在规划前,先进行动作修改
|
||||
@@ -111,10 +106,7 @@ class ChatterActionPlanner:
|
||||
# 确保Plan中包含所有当前可用的动作
|
||||
initial_plan.available_actions = self.action_manager.get_using_actions()
|
||||
|
||||
# 如果没有提供未读消息列表,则从上下文中获取
|
||||
if unread_messages is None:
|
||||
unread_messages = context.get_unread_messages() if context else []
|
||||
|
||||
unread_messages = context.get_unread_messages() if context else []
|
||||
# 2. 兴趣度评分 - 只对未读消息进行评分
|
||||
if unread_messages:
|
||||
bot_nickname = global_config.bot.nickname
|
||||
|
||||
Reference in New Issue
Block a user