fix(chat): 优化breaking模式下的兴趣值累积逻辑

重构heartFC_chat中的消息处理机制,使用累积兴趣值替代最近三次记录来判断是否进入breaking模式。主要变更包括:

- 将breaking模式判断基于累积兴趣值而非最近3次记录
- 在消息成功处理时重置累积兴趣值
- 调整阈值计算方式,使用聊天频率进行动态调整
- 修复send_api中的消息查找函数,提高回复消息匹配准确性

这些改动提高了对话节奏控制的稳定性,使breaking模式触发更加合理。
This commit is contained in:
Windpicker-owo
2025-09-03 22:19:00 +08:00
parent 18a57d0a74
commit efe81fa346
5 changed files with 105 additions and 137 deletions

View File

@@ -47,6 +47,9 @@ class HfcContext:
self.last_message_time = time.time()
self.last_read_time = time.time() - 10
# 从聊天流恢复breaking累积兴趣值
self.breaking_accumulated_interest = getattr(self.chat_stream, 'breaking_accumulated_interest', 0.0)
self.action_manager = ActionManager()
@@ -63,6 +66,8 @@ class HfcContext:
self.focus_energy = 1
self.no_reply_consecutive = 0
self.total_interest = 0.0
# breaking形式下的累积兴趣值
self.breaking_accumulated_interest = 0.0
# 引用HeartFChatting实例以便其他组件可以调用其方法
self.chat_instance = None
@@ -72,4 +77,5 @@ class HfcContext:
self.chat_stream.energy_value = self.energy_value
self.chat_stream.sleep_pressure = self.sleep_pressure
self.chat_stream.focus_energy = self.focus_energy
self.chat_stream.no_reply_consecutive = self.no_reply_consecutive
self.chat_stream.no_reply_consecutive = self.no_reply_consecutive
self.chat_stream.breaking_accumulated_interest = self.breaking_accumulated_interest