🤖 自动格式化代码 [skip ci]
This commit is contained in:
@@ -406,9 +406,7 @@ class HeartFChatting:
|
||||
try:
|
||||
# 使用 await task 来获取结果或触发异常
|
||||
result_list = await task
|
||||
logger.info(
|
||||
f"{self.log_prefix} 处理器 {processor_name} 已完成!"
|
||||
)
|
||||
logger.info(f"{self.log_prefix} 处理器 {processor_name} 已完成!")
|
||||
if result_list is not None:
|
||||
all_plan_info.extend(result_list)
|
||||
else:
|
||||
|
||||
@@ -277,7 +277,7 @@ class SubHeartflow:
|
||||
self.history_chat_state.append((current_state, self.chat_state_last_time))
|
||||
|
||||
# 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
|
||||
|
||||
@@ -41,7 +41,6 @@ class NormalChat:
|
||||
self.willing_amplifier = 1
|
||||
self.start_time = time.time()
|
||||
|
||||
|
||||
# Other sync initializations
|
||||
self.gpt = NormalChatGenerator()
|
||||
self.mood_manager = mood_manager
|
||||
@@ -58,8 +57,6 @@ class NormalChat:
|
||||
|
||||
self._disabled = False # 增加停用标志
|
||||
|
||||
|
||||
|
||||
async def initialize(self):
|
||||
"""异步初始化,获取聊天类型和目标信息。"""
|
||||
if self._initialized:
|
||||
@@ -213,10 +210,9 @@ class NormalChat:
|
||||
try:
|
||||
# 处理消息
|
||||
if time.time() - self.start_time > 600:
|
||||
self.adjust_reply_frequency(duration=600/60)
|
||||
self.adjust_reply_frequency(duration=600 / 60)
|
||||
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(
|
||||
message=message,
|
||||
@@ -498,7 +494,9 @@ class NormalChat:
|
||||
total_message_count = stats["total_message_count"]
|
||||
if total_message_count == 0:
|
||||
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
|
||||
@@ -509,12 +507,16 @@ class NormalChat:
|
||||
if differ > 0.1:
|
||||
mapped = 1 + (differ - 0.1) * 4 / 0.9
|
||||
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 # 你可以根据实际需要调整系数
|
||||
elif differ < -0.1:
|
||||
mapped = 1 - (differ + 0.1) * 4 / 0.9
|
||||
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
|
||||
|
||||
if self.willing_amplifier > 5:
|
||||
|
||||
@@ -111,8 +111,8 @@ class InfoCatcher:
|
||||
result = list(messages_between_query)
|
||||
# print(f"查询结果数量: {len(result)}")
|
||||
# if result:
|
||||
# print(f"第一条消息时间: {result[0].time}")
|
||||
# print(f"最后一条消息时间: {result[-1].time}")
|
||||
# print(f"第一条消息时间: {result[0].time}")
|
||||
# print(f"最后一条消息时间: {result[-1].time}")
|
||||
return result
|
||||
except Exception as e:
|
||||
print(f"获取消息时出错: {str(e)}")
|
||||
|
||||
@@ -326,7 +326,6 @@ FOCUS_CHAT_STYLE_CONFIG = {
|
||||
}
|
||||
|
||||
|
||||
|
||||
REMOTE_STYLE_CONFIG = {
|
||||
"advanced": {
|
||||
"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"]
|
||||
EXPRESS_STYLE_CONFIG = EXPRESS_STYLE_CONFIG["simple"] if SIMPLE_OUTPUT else EXPRESS_STYLE_CONFIG["advanced"]
|
||||
|
||||
|
||||
def is_registered_module(record: dict) -> bool:
|
||||
"""检查是否为已注册的模块"""
|
||||
return record["extra"].get("module") in _handler_registry
|
||||
|
||||
Reference in New Issue
Block a user