🤖 自动格式化代码 [skip ci]

This commit is contained in:
github-actions[bot]
2025-05-28 14:42:38 +00:00
parent cd41dcb4cb
commit 8f03be10be
6 changed files with 21 additions and 21 deletions

View File

@@ -406,9 +406,7 @@ class HeartFChatting:
try: try:
# 使用 await task 来获取结果或触发异常 # 使用 await task 来获取结果或触发异常
result_list = await task result_list = await task
logger.info( logger.info(f"{self.log_prefix} 处理器 {processor_name} 已完成!")
f"{self.log_prefix} 处理器 {processor_name} 已完成!"
)
if result_list is not None: if result_list is not None:
all_plan_info.extend(result_list) all_plan_info.extend(result_list)
else: else:

View File

@@ -101,7 +101,7 @@ class ReplyAction(BaseAction):
} }
""" """
logger.info(f"{self.log_prefix} 决定回复: {self.reasoning}") logger.info(f"{self.log_prefix} 决定回复: {self.reasoning}")
# 从聊天观察获取锚定消息 # 从聊天观察获取锚定消息
chatting_observation: ChattingObservation = next( chatting_observation: ChattingObservation = next(
obs for obs in self.observations if isinstance(obs, ChattingObservation) obs for obs in self.observations if isinstance(obs, ChattingObservation)

View File

@@ -277,7 +277,7 @@ class SubHeartflow:
self.history_chat_state.append((current_state, self.chat_state_last_time)) self.history_chat_state.append((current_state, self.chat_state_last_time))
# logger.info( # logger.info(
# f"{log_prefix} 麦麦的聊天状态从 {current_state.value} (持续了 {int(self.chat_state_last_time)} 秒) 变更为 {new_state.value}" # f"{log_prefix} 麦麦的聊天状态从 {current_state.value} (持续了 {int(self.chat_state_last_time)} 秒) 变更为 {new_state.value}"
# ) # )
self.chat_state.chat_status = new_state self.chat_state.chat_status = new_state

View File

@@ -41,7 +41,6 @@ class NormalChat:
self.willing_amplifier = 1 self.willing_amplifier = 1
self.start_time = time.time() self.start_time = time.time()
# Other sync initializations # Other sync initializations
self.gpt = NormalChatGenerator() self.gpt = NormalChatGenerator()
self.mood_manager = mood_manager self.mood_manager = mood_manager
@@ -58,8 +57,6 @@ class NormalChat:
self._disabled = False # 增加停用标志 self._disabled = False # 增加停用标志
async def initialize(self): async def initialize(self):
"""异步初始化,获取聊天类型和目标信息。""" """异步初始化,获取聊天类型和目标信息。"""
if self._initialized: if self._initialized:
@@ -213,10 +210,9 @@ class NormalChat:
try: try:
# 处理消息 # 处理消息
if time.time() - self.start_time > 600: if time.time() - self.start_time > 600:
self.adjust_reply_frequency(duration=600/60) self.adjust_reply_frequency(duration=600 / 60)
else: else:
self.adjust_reply_frequency(duration=(time.time() - self.start_time)/60) self.adjust_reply_frequency(duration=(time.time() - self.start_time) / 60)
await self.normal_response( await self.normal_response(
message=message, message=message,
@@ -491,32 +487,38 @@ class NormalChat:
调整回复频率 调整回复频率
""" """
# 获取最近30分钟内的消息统计 # 获取最近30分钟内的消息统计
stats = get_recent_message_stats(minutes=duration, chat_id=self.stream_id) stats = get_recent_message_stats(minutes=duration, chat_id=self.stream_id)
bot_reply_count = stats["bot_reply_count"] bot_reply_count = stats["bot_reply_count"]
total_message_count = stats["total_message_count"] total_message_count = stats["total_message_count"]
if total_message_count == 0: if total_message_count == 0:
return return
logger.debug(f"[{self.stream_name}]({self.willing_amplifier}) 最近{duration}分钟 回复数量: {bot_reply_count},消息总数: {total_message_count}") logger.debug(
f"[{self.stream_name}]({self.willing_amplifier}) 最近{duration}分钟 回复数量: {bot_reply_count},消息总数: {total_message_count}"
)
# 计算回复频率 # 计算回复频率
_reply_frequency = bot_reply_count / total_message_count _reply_frequency = bot_reply_count / total_message_count
differ = global_config.normal_chat.talk_frequency - (bot_reply_count / duration) differ = global_config.normal_chat.talk_frequency - (bot_reply_count / duration)
# 如果回复频率低于0.5,增加回复概率 # 如果回复频率低于0.5,增加回复概率
if differ > 0.1: if differ > 0.1:
mapped = 1 + (differ - 0.1) * 4 / 0.9 mapped = 1 + (differ - 0.1) * 4 / 0.9
mapped = max(1, min(5, mapped)) mapped = max(1, min(5, mapped))
logger.info(f"[{self.stream_name}] 回复频率低于{global_config.normal_chat.talk_frequency}增加回复概率differ={differ:.3f},映射值={mapped:.2f}") logger.info(
f"[{self.stream_name}] 回复频率低于{global_config.normal_chat.talk_frequency}增加回复概率differ={differ:.3f},映射值={mapped:.2f}"
)
self.willing_amplifier += mapped * 0.1 # 你可以根据实际需要调整系数 self.willing_amplifier += mapped * 0.1 # 你可以根据实际需要调整系数
elif differ < -0.1: elif differ < -0.1:
mapped = 1 - (differ + 0.1) * 4 / 0.9 mapped = 1 - (differ + 0.1) * 4 / 0.9
mapped = max(1, min(5, mapped)) mapped = max(1, min(5, mapped))
logger.info(f"[{self.stream_name}] 回复频率高于{global_config.normal_chat.talk_frequency}减少回复概率differ={differ:.3f},映射值={mapped:.2f}") logger.info(
f"[{self.stream_name}] 回复频率高于{global_config.normal_chat.talk_frequency}减少回复概率differ={differ:.3f},映射值={mapped:.2f}"
)
self.willing_amplifier -= mapped * 0.1 self.willing_amplifier -= mapped * 0.1
if self.willing_amplifier > 5: if self.willing_amplifier > 5:
self.willing_amplifier = 5 self.willing_amplifier = 5
elif self.willing_amplifier < 0.1: elif self.willing_amplifier < 0.1:

View File

@@ -111,8 +111,8 @@ class InfoCatcher:
result = list(messages_between_query) result = list(messages_between_query)
# print(f"查询结果数量: {len(result)}") # print(f"查询结果数量: {len(result)}")
# if result: # if result:
# print(f"第一条消息时间: {result[0].time}") # print(f"第一条消息时间: {result[0].time}")
# print(f"最后一条消息时间: {result[-1].time}") # print(f"最后一条消息时间: {result[-1].time}")
return result return result
except Exception as e: except Exception as e:
print(f"获取消息时出错: {str(e)}") print(f"获取消息时出错: {str(e)}")

View File

@@ -326,7 +326,6 @@ FOCUS_CHAT_STYLE_CONFIG = {
} }
REMOTE_STYLE_CONFIG = { REMOTE_STYLE_CONFIG = {
"advanced": { "advanced": {
"console_format": ( "console_format": (
@@ -992,6 +991,7 @@ NORMAL_CHAT_STYLE_CONFIG = NORMAL_CHAT_STYLE_CONFIG["simple"] if SIMPLE_OUTPUT e
FOCUS_CHAT_STYLE_CONFIG = FOCUS_CHAT_STYLE_CONFIG["simple"] if SIMPLE_OUTPUT else FOCUS_CHAT_STYLE_CONFIG["advanced"] FOCUS_CHAT_STYLE_CONFIG = FOCUS_CHAT_STYLE_CONFIG["simple"] if SIMPLE_OUTPUT else FOCUS_CHAT_STYLE_CONFIG["advanced"]
EXPRESS_STYLE_CONFIG = EXPRESS_STYLE_CONFIG["simple"] if SIMPLE_OUTPUT else EXPRESS_STYLE_CONFIG["advanced"] EXPRESS_STYLE_CONFIG = EXPRESS_STYLE_CONFIG["simple"] if SIMPLE_OUTPUT else EXPRESS_STYLE_CONFIG["advanced"]
def is_registered_module(record: dict) -> bool: def is_registered_module(record: dict) -> bool:
"""检查是否为已注册的模块""" """检查是否为已注册的模块"""
return record["extra"].get("module") in _handler_registry return record["extra"].get("module") in _handler_registry