feat(chat): 实现 focus_energy 的实时更新与同步机制

为了解决 `focus_energy` 更新不及时,导致其无法准确反映当前对话兴趣度的问题,本次提交引入了一套新的实时更新与同步机制。

这确保了每当消息的兴趣度发生变化时,代表机器人注意力的 `focus_energy` 也能被立即重新计算和更新,使决策更加精准。

主要变更:
1.  **手动更新**: 在 `ChatStream` 中新增 `update_focus_energy` 方法,允许外部逻辑在需要时手动触发 `focus_energy` 的重新计算。
2.  **实时计算**: `ChatterActionPlanner` 在评估并更新消息兴趣度后,会立即调用 `update_focus_energy`,确保了兴趣度到注意力的即时传导。
3.  **状态同步**: `ChatterManager` 在完成一次执行后,会主动将 `mood_manager` 中可能已更新的 `chat_stream` 同步回当前的 `StreamContext`,保证了整个处理流中数据的一致性。
This commit is contained in:
tt-P607
2025-09-26 02:10:43 +08:00
parent 8d725911da
commit 99595f239d
3 changed files with 17 additions and 1 deletions

View File

@@ -257,6 +257,10 @@ class ChatStream:
self.last_interaction_time = time.time()
self.focus_energy = self._calculate_dynamic_focus_energy()
def update_focus_energy(self):
"""手动触发更新focus_energy"""
self.focus_energy = self._calculate_dynamic_focus_energy()
def record_action(self, is_reply: bool = False):
"""记录动作执行"""
self.action_count += 1