refactor(chat): 重构消息管理器以使用集中式聊天流API

移除对context.chat_stream的直接依赖,改为通过get_chat_manager().get_stream()统一获取聊天流实例。这提高了模块独立性,符合"高内聚、低耦合"原则。

- 在MessageManager中统一使用chat_api获取stream实例
- 移除mood_manager中直接更新chat_stream的逻辑
- 在affinity_flow_chatter中统一处理兴趣度更新
- 消除直接属性访问带来的强耦合依赖
This commit is contained in:
Windpicker-owo
2025-09-26 11:45:20 +08:00
parent a2baec088e
commit ad36a6c48f
3 changed files with 29 additions and 24 deletions

View File

@@ -149,12 +149,7 @@ class ChatMood:
self.mood_state = response
self.last_change_time = message_time
# 更新ChatStream的兴趣度数据
if hasattr(self, 'chat_stream') and self.chat_stream:
self.chat_stream.add_message_interest(interested_rate)
logger.debug(f"{self.log_prefix} 已更新ChatStream兴趣度当前focus_energy: {self.chat_stream.focus_energy:.3f}")
async def regress_mood(self):
message_time = time.time()
message_list_before_now = get_raw_msg_by_timestamp_with_chat_inclusive(