feat(affinity-flow): 重构消息处理以使用StreamContext对象
重构AFC消息处理系统,将基于字典的消息数据传递改为直接使用StreamContext对象。主要变更包括: - 修改AFCManager的process_message方法为process_stream_context,直接接收StreamContext对象 - 在chatter中重构消息处理逻辑,直接从StreamContext获取未读和历史消息 - 移除批量消息处理功能,改为单次StreamContext处理 - 在message_manager中简化消息处理流程,直接传递StreamContext对象 - 添加未读消息清理机制,防止异常情况下消息一直未读 同时优化兴趣度评分系统的参数: - 调整回复阈值从0.55到0.56 - 增加最大不回复次数从15到20 - 提升每次不回复的概率增加从0.01到0.02 - 优化提及奖励从3.0降到1.0 - 调整回复后的不回复计数减少从1到3 BREAKING CHANGE: AFCManager的process_message方法已重命名为process_stream_context,参数从message_data改为context对象
This commit is contained in:
@@ -64,13 +64,15 @@ class ActionPlanner:
|
||||
"other_actions_executed": 0,
|
||||
}
|
||||
|
||||
async def plan(self, mode: ChatMode = ChatMode.FOCUS, unread_messages: List[Dict] = None) -> Tuple[List[Dict], Optional[Dict]]:
|
||||
async def plan(self, mode: ChatMode = ChatMode.FOCUS, message_data: dict = None) -> Tuple[List[Dict], Optional[Dict]]:
|
||||
"""
|
||||
执行完整的增强版规划流程。
|
||||
|
||||
Args:
|
||||
mode (ChatMode): 当前的聊天模式,默认为 FOCUS。
|
||||
unread_messages (List[Dict]): 未读消息列表,用于兴趣度计算。
|
||||
message_data (dict): 消息数据字典,包含:
|
||||
- unread_messages: 未读消息列表
|
||||
- history_messages: 历史消息列表(可选)
|
||||
|
||||
Returns:
|
||||
Tuple[List[Dict], Optional[Dict]]: 一个元组,包含:
|
||||
@@ -78,6 +80,8 @@ class ActionPlanner:
|
||||
- final_target_message_dict (Optional[Dict]): 最终的目标消息(字典格式)。
|
||||
"""
|
||||
try:
|
||||
# 提取未读消息用于兴趣度计算
|
||||
unread_messages = message_data.get("unread_messages", []) if message_data else []
|
||||
self.planner_stats["total_plans"] += 1
|
||||
|
||||
return await self._enhanced_plan_flow(mode, unread_messages or [])
|
||||
@@ -118,12 +122,13 @@ class ActionPlanner:
|
||||
logger.info(f"❌ 兴趣度不足阈值的80%: {score:.3f} < {threshold_requirement:.3f},直接返回no_action")
|
||||
logger.info(f"📊 最低要求: 阈值({base_threshold:.3f}) × 0.8 = {threshold_requirement:.3f}")
|
||||
# 直接返回 no_action
|
||||
no_action = {
|
||||
"action_type": "no_action",
|
||||
"reason": f"兴趣度评分 {score:.3f} 未达阈值80% {threshold_requirement:.3f}",
|
||||
"action_data": {},
|
||||
"action_message": None,
|
||||
}
|
||||
from src.common.data_models.info_data_model import ActionPlannerInfo
|
||||
no_action = ActionPlannerInfo(
|
||||
action_type="no_action",
|
||||
reasoning=f"兴趣度评分 {score:.3f} 未达阈值80% {threshold_requirement:.3f}",
|
||||
action_data={},
|
||||
action_message=None,
|
||||
)
|
||||
filtered_plan = initial_plan
|
||||
filtered_plan.decided_actions = [no_action]
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user