From 70a92059e13440361810bb6cedc0033bf414393f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 25 Jun 2025 16:45:33 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=96=20=E8=87=AA=E5=8A=A8=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E5=8C=96=E4=BB=A3=E7=A0=81=20[skip=20ci]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/chat/express/exprssion_learner.py | 10 +++++----- src/chat/heart_flow/sub_heartflow.py | 16 +++++++++------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/chat/express/exprssion_learner.py b/src/chat/express/exprssion_learner.py index 6b4e254a7..a18961ef1 100644 --- a/src/chat/express/exprssion_learner.py +++ b/src/chat/express/exprssion_learner.py @@ -192,16 +192,16 @@ class ExpressionLearner: """ if time_diff_days <= 0: return 0.0 # 刚激活的表达式不衰减 - + if time_diff_days >= DECAY_DAYS: return 0.01 # 长时间未活跃的表达式大幅衰减 - + # 使用二次函数插值:在0-30天之间从0衰减到0.01 # 使用简单的二次函数:y = a * x^2 # 当x=30时,y=0.01,所以 a = 0.01 / (30^2) = 0.01 / 900 - a = 0.01 / (DECAY_DAYS ** 2) - decay = a * (time_diff_days ** 2) - + a = 0.01 / (DECAY_DAYS**2) + decay = a * (time_diff_days**2) + return min(0.01, decay) def apply_decay_to_expressions( diff --git a/src/chat/heart_flow/sub_heartflow.py b/src/chat/heart_flow/sub_heartflow.py index c815c589e..d602ea3a8 100644 --- a/src/chat/heart_flow/sub_heartflow.py +++ b/src/chat/heart_flow/sub_heartflow.py @@ -412,25 +412,27 @@ class SubHeartflow: def is_in_focus_cooldown(self) -> bool: """检查是否在focus模式的冷却期内 - + Returns: bool: 如果在冷却期内返回True,否则返回False """ if self.last_focus_exit_time == 0: return False - + # 基础冷却时间10分钟,受auto_focus_threshold调控 base_cooldown = 10 * 60 # 10分钟转换为秒 cooldown_duration = base_cooldown / global_config.chat.auto_focus_threshold - + current_time = time.time() elapsed_since_exit = current_time - self.last_focus_exit_time - + is_cooling = elapsed_since_exit < cooldown_duration - + if is_cooling: remaining_time = cooldown_duration - elapsed_since_exit remaining_minutes = remaining_time / 60 - logger.debug(f"[{self.log_prefix}] focus冷却中,剩余时间: {remaining_minutes:.1f}分钟 (阈值: {global_config.chat.auto_focus_threshold})") - + logger.debug( + f"[{self.log_prefix}] focus冷却中,剩余时间: {remaining_minutes:.1f}分钟 (阈值: {global_config.chat.auto_focus_threshold})" + ) + return is_cooling