From d49a6b840e1328e4a667f0f3e5be89190803ee4e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 7 Jul 2025 18:04:52 +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 --- .../heart_flow/heartflow_message_processor.py | 4 +-- src/chat/normal_chat/normal_chat.py | 4 ++- src/person_info/relationship_manager.py | 26 +++++++------------ src/plugins/built_in/core_actions/no_reply.py | 9 ++++--- 4 files changed, 19 insertions(+), 24 deletions(-) diff --git a/src/chat/heart_flow/heartflow_message_processor.py b/src/chat/heart_flow/heartflow_message_processor.py index 5de0d7015..52a9751ea 100644 --- a/src/chat/heart_flow/heartflow_message_processor.py +++ b/src/chat/heart_flow/heartflow_message_processor.py @@ -123,9 +123,7 @@ class HeartFCMessageReceiver: picid_pattern = r"\[picid:([^\]]+)\]" processed_plain_text = re.sub(picid_pattern, "[图片]", message.processed_plain_text) - logger.info( - f"[{mes_name}]{userinfo.user_nickname}:{processed_plain_text}" - ) + logger.info(f"[{mes_name}]{userinfo.user_nickname}:{processed_plain_text}") logger.debug(f"[{mes_name}][当前时段回复频率: {current_talk_frequency}]") diff --git a/src/chat/normal_chat/normal_chat.py b/src/chat/normal_chat/normal_chat.py index 43ab5803e..51642a700 100644 --- a/src/chat/normal_chat/normal_chat.py +++ b/src/chat/normal_chat/normal_chat.py @@ -596,7 +596,9 @@ class NormalChat: timeout_source = " 和 ".join(timeout_details) - logger.warning(f"[{self.stream_name}] {timeout_source} 任务超时 ({global_config.chat.thinking_timeout}秒),正在取消相关任务...") + logger.warning( + f"[{self.stream_name}] {timeout_source} 任务超时 ({global_config.chat.thinking_timeout}秒),正在取消相关任务..." + ) # print(f"111{self.timeout_count}") self.timeout_count += 1 if self.timeout_count > 5: diff --git a/src/person_info/relationship_manager.py b/src/person_info/relationship_manager.py index 813036c69..12891235c 100644 --- a/src/person_info/relationship_manager.py +++ b/src/person_info/relationship_manager.py @@ -1,12 +1,10 @@ from src.common.logger import get_logger -import math from src.person_info.person_info import PersonInfoManager, get_person_info_manager import time import random from src.llm_models.utils_model import LLMRequest from src.config.config import global_config from src.chat.utils.chat_message_builder import build_readable_messages -from src.manager.mood_manager import mood_manager import json from json_repair import repair_json from datetime import datetime @@ -26,7 +24,6 @@ class RelationshipManager: request_type="relationship", # 用于动作规划 ) - @staticmethod async def is_known_some_one(platform, user_id): """判断是否认识某人""" @@ -113,7 +110,6 @@ class RelationshipManager: return relation_prompt - async def update_person_impression(self, person_id, timestamp, bot_engaged_messages=None): """更新用户印象 @@ -173,7 +169,7 @@ class RelationshipManager: user_count += 1 name_mapping[replace_person_name] = f"用户{current_user}{user_count if user_count > 1 else ''}" current_user = chr(ord(current_user) + 1) - + readable_messages = build_readable_messages( messages=user_messages, replace_bot_name=True, timestamp_mode="normal_no_YMD", truncate=True ) @@ -327,7 +323,7 @@ class RelationshipManager: await person_info_manager.update_one_field( person_id, "points", json.dumps(current_points, ensure_ascii=False, indent=None) ) - + await person_info_manager.update_one_field(person_id, "know_times", know_times + 1) know_since = await person_info_manager.get_value(person_id, "know_since") or 0 if know_since == 0: @@ -335,17 +331,16 @@ class RelationshipManager: await person_info_manager.update_one_field(person_id, "last_know", timestamp) logger.debug(f"{person_name} 的印象更新完成") - + async def _update_impression(self, person_id, current_points, timestamp): # 获取现有forgotten_points person_info_manager = get_person_info_manager() - - + person_name = await person_info_manager.get_value(person_id, "person_name") nickname = await person_info_manager.get_value(person_id, "nickname") know_times = await person_info_manager.get_value(person_id, "know_times") or 0 attitude = await person_info_manager.get_value(person_id, "attitude") or 50 - + # 根据熟悉度,调整印象和简短印象的最大长度 if know_times > 300: max_impression_length = 2000 @@ -362,14 +357,12 @@ class RelationshipManager: else: max_impression_length = 100 max_short_impression_length = 50 - + # 根据好感度,调整印象和简短印象的最大长度 - attitude_multiplier = (abs(100-attitude) / 100) + 1 + attitude_multiplier = (abs(100 - attitude) / 100) + 1 max_impression_length = max_impression_length * attitude_multiplier max_short_impression_length = max_short_impression_length * attitude_multiplier - - - + forgotten_points = await person_info_manager.get_value(person_id, "forgotten_points") or [] if isinstance(forgotten_points, str): try: @@ -539,9 +532,8 @@ class RelationshipManager: await person_info_manager.update_one_field( person_id, "forgotten_points", json.dumps(forgotten_points, ensure_ascii=False, indent=None) ) - - return current_points + return current_points def calculate_time_weight(self, point_time: str, current_time: str) -> float: """计算基于时间的权重系数""" diff --git a/src/plugins/built_in/core_actions/no_reply.py b/src/plugins/built_in/core_actions/no_reply.py index a5c8d637b..a573a39fd 100644 --- a/src/plugins/built_in/core_actions/no_reply.py +++ b/src/plugins/built_in/core_actions/no_reply.py @@ -103,7 +103,6 @@ class NoReplyAction(BaseAction): logger.info(f"{self.log_prefix} 选择不回复(第{count}次),开始摸鱼,原因: {reason}") - # 进入等待状态 while True: current_time = time.time() @@ -387,7 +386,9 @@ class NoReplyAction(BaseAction): f"{self.log_prefix} 发言过多(超过{over_count}条),随机决定跳过此次LLM判断(概率{skip_probability * 100:.0f}%)" ) - logger.info(f"{self.log_prefix} 过去10分钟发言{bot_message_count}条,超过阈值{talk_frequency_threshold},添加疲惫提示") + logger.info( + f"{self.log_prefix} 过去10分钟发言{bot_message_count}条,超过阈值{talk_frequency_threshold},添加疲惫提示" + ) return frequency_block, should_skip_judge else: # 回复次数少时的正向提示 @@ -398,7 +399,9 @@ class NoReplyAction(BaseAction): elif under_count >= talk_frequency_threshold * 0.5: frequency_block = "你感觉状态不错。\n" - logger.info(f"{self.log_prefix} 过去10分钟发言{bot_message_count}条,未超过阈值{talk_frequency_threshold},添加正向提示") + logger.info( + f"{self.log_prefix} 过去10分钟发言{bot_message_count}条,未超过阈值{talk_frequency_threshold},添加正向提示" + ) return frequency_block, False except Exception as e: