refactor(interest-system): 移除旧兴趣度管理系统,迁移到插件内部实现

移除旧的集中式兴趣度管理系统(interest_manager.py),将兴趣度计算功能迁移到affinity_flow_chatter插件内部实现。主要包括:

- 删除interest_manager.py及其相关导入引用
- 修改RelationshipEnergyCalculator使用插件内部的关系分计算
- 重构StreamContextManager使用插件内部的兴趣度评分系统
- 更新ChatStream、PlanFilter、Planner等组件使用新的插件接口
- 简化上下文管理器,移除事件系统和验证器相关代码

此次重构提高了模块独立性,减少了核心代码对插件功能的直接依赖,符合"高内聚低耦合"的设计原则。
This commit is contained in:
Windpicker-owo
2025-09-27 19:07:24 +08:00
parent 0fe052dd37
commit 80d34f3130
11 changed files with 92 additions and 997 deletions

View File

@@ -18,7 +18,7 @@ from src.plugin_system.base.component_types import ChatMode
from .sleep_manager.sleep_manager import SleepManager
from .sleep_manager.wakeup_manager import WakeUpManager
from src.config.config import global_config
from . import context_manager
from .context_manager import context_manager
if TYPE_CHECKING:
from src.common.data_models.message_manager_data_model import StreamContext
@@ -46,7 +46,7 @@ class MessageManager:
self.wakeup_manager = WakeUpManager(self.sleep_manager)
# 初始化上下文管理器
self.context_manager = context_manager.context_manager
self.context_manager = context_manager
async def start(self):
"""启动消息管理器"""
@@ -84,11 +84,9 @@ class MessageManager:
if not context:
# 创建新的流上下文
from src.common.data_models.message_manager_data_model import StreamContext
new_context = StreamContext(stream_id=stream_id)
success = self.context_manager.add_stream_context(stream_id, new_context)
if not success:
logger.error(f"无法为流 {stream_id} 创建上下文")
return
context = StreamContext(stream_id=stream_id)
# 将创建的上下文添加到管理器
self.context_manager.add_stream_context(stream_id, context)
# 使用 context_manager 添加消息
success = self.context_manager.add_message_to_context(stream_id, message)
@@ -98,7 +96,7 @@ class MessageManager:
else:
logger.warning(f"添加消息到聊天流 {stream_id} 失败")
def update_message_and_refresh_energy(
def update_message(
self,
stream_id: str,
message_id: str,
@@ -112,7 +110,7 @@ class MessageManager:
if context:
context.update_message_info(message_id, interest_value, actions, should_reply)
def add_action_and_refresh_energy(self, stream_id: str, message_id: str, action: str):
def add_action(self, stream_id: str, message_id: str, action: str):
"""添加动作到消息"""
# 使用 context_manager 添加动作到消息
context = self.context_manager.get_stream_context(stream_id)