diff --git a/scripts/remove_chong.py b/scripts/remove_chong.py index 40ba7428b..95c01389c 100644 --- a/scripts/remove_chong.py +++ b/scripts/remove_chong.py @@ -1,6 +1,7 @@ import difflib import random + def ji_suan_xiang_si_du(wen_ben_yi: str, wen_ben_er: str) -> float: """ 计算两个文本字符串的相似度。 @@ -17,6 +18,7 @@ def ji_suan_xiang_si_du(wen_ben_yi: str, wen_ben_er: str) -> float: xiang_si_bi_lv = xu_lie_pi_pei_qi.ratio() return xiang_si_bi_lv + def ji_suan_ti_huan_gai_lv(xiang_si_du: float) -> float: """ 根据相似度计算替换的概率。 @@ -33,11 +35,12 @@ def ji_suan_ti_huan_gai_lv(xiang_si_du: float) -> float: elif 0.4 < xiang_si_du <= 0.6: # p = 2.5 * s - 1.0 (线性方程 y - 0 = (0.5-0)/(0.6-0.4) * (x - 0.4)) gai_lv = 2.5 * xiang_si_du - 1.0 - return max(0.0, gai_lv) # 确保概率不小于0 + return max(0.0, gai_lv) # 确保概率不小于0 elif 0.6 < xiang_si_du < 0.9: # p = (5/3) * s - 0.5 (线性方程 y - 0.5 = (1-0.5)/(0.9-0.6) * (x - 0.6)) gai_lv = (5 / 3) * xiang_si_du - 0.5 - return min(1.0, max(0.0, gai_lv)) # 确保概率在 0 和 1 之间 + return min(1.0, max(0.0, gai_lv)) # 确保概率在 0 和 1 之间 + # 获取用户输入 shu_ru_yi = "豆豆刚刚回复了我的问候 现在可以等待对方的回应 不需要再主动发言 目前情绪满足 不需要使用工具" @@ -66,7 +69,7 @@ if random.random() < ti_huan_gai_lv: # 更新下一个非匹配部分的起始位置 last_match_end_in_b = j + n - jie_guo = "".join(qu_chong_hou_de_er).strip() # 去除首尾空白 + jie_guo = "".join(qu_chong_hou_de_er).strip() # 去除首尾空白 if jie_guo: # 定义词语列表 @@ -77,9 +80,9 @@ if random.random() < ti_huan_gai_lv: # 根据概率决定是否添加词语 qian_zhui_str = "" - if random.random() < 0.3: # 30% 概率添加语气词 + if random.random() < 0.3: # 30% 概率添加语气词 qian_zhui_str += random.choice(yu_qi_ci_liebiao) - if random.random() < 0.7: # 70% 概率添加转折/承接词 + if random.random() < 0.7: # 70% 概率添加转折/承接词 qian_zhui_str += random.choice(zhuan_jie_ci_liebiao) # 组合最终结果 diff --git a/src/config/config.py b/src/config/config.py index d9d5ce162..f09da9a7e 100644 --- a/src/config/config.py +++ b/src/config/config.py @@ -185,7 +185,7 @@ class BotConfig: reply_trigger_threshold: float = 3.0 # 心流聊天触发阈值,越低越容易触发 probability_decay_factor_per_second: float = 0.2 # 概率衰减因子,越大衰减越快 default_decay_rate_per_second: float = 0.98 # 默认衰减率,越大衰减越慢 - allow_focus_mode: bool = True # 是否允许子心流进入 FOCUSED 状态 + allow_focus_mode: bool = True # 是否允许子心流进入 FOCUSED 状态 # sub_heart_flow_update_interval: int = 60 # 子心流更新频率,间隔 单位秒 # sub_heart_flow_freeze_time: int = 120 # 子心流冻结时间,超过这个时间没有回复,子心流会冻结,间隔 单位秒 @@ -417,6 +417,7 @@ class BotConfig: config.model_normal_probability = response_config.get( "model_normal_probability", config.model_normal_probability ) + def heartflow(parent: dict): heartflow_config = parent["heartflow"] config.sub_heart_flow_stop_time = heartflow_config.get( diff --git a/src/heart_flow/subheartflow_manager.py b/src/heart_flow/subheartflow_manager.py index c355867c5..afa0328e6 100644 --- a/src/heart_flow/subheartflow_manager.py +++ b/src/heart_flow/subheartflow_manager.py @@ -266,9 +266,9 @@ class SubHeartflowManager: # --- 新增:检查是否允许进入 FOCUS 模式 --- # if not global_config.allow_focus_mode: - if int(time.time()) % 60 == 0: # 每60秒输出一次日志避免刷屏 + if int(time.time()) % 60 == 0: # 每60秒输出一次日志避免刷屏 logger.debug(f"{log_prefix} 配置不允许进入 FOCUSED 状态 (allow_focus_mode=False)") - return # 如果不允许,直接返回 + return # 如果不允许,直接返回 # --- 结束新增 --- logger.debug(f"{log_prefix} 当前状态 ({current_state.value}) 开始尝试提升到FOCUSED状态") diff --git a/src/plugins/person_info/relationship_manager.py b/src/plugins/person_info/relationship_manager.py index b66d74d5c..47caaea01 100644 --- a/src/plugins/person_info/relationship_manager.py +++ b/src/plugins/person_info/relationship_manager.py @@ -283,7 +283,7 @@ class RelationshipManager: person_name = await person_info_manager.get_value(person_id, "person_name") relationship_value = await person_info_manager.get_value(person_id, "relationship_value") level_num = self.calculate_level_num(relationship_value) - + if level_num == 0 or level_num == 5: relationship_level = ["厌恶", "冷漠以对", "认识", "友好对待", "喜欢", "暧昧"] relation_prompt2_list = [ diff --git a/src/plugins/utils/chat_message_builder.py b/src/plugins/utils/chat_message_builder.py index 4e807ffaf..a49f4ffa3 100644 --- a/src/plugins/utils/chat_message_builder.py +++ b/src/plugins/utils/chat_message_builder.py @@ -348,7 +348,10 @@ async def build_readable_messages( messages_before_mark, replace_bot_name, merge_messages, timestamp_mode, truncate ) formatted_after, _ = await _build_readable_messages_internal( - messages_after_mark, replace_bot_name, merge_messages, timestamp_mode, + messages_after_mark, + replace_bot_name, + merge_messages, + timestamp_mode, ) readable_read_mark = translate_timestamp_to_human_readable(read_mark, mode=timestamp_mode)