feat:修改log,优化关系构建逻辑,节省token,
This commit is contained in:
@@ -324,8 +324,6 @@ async def clear_temp_emoji() -> None:
|
||||
os.remove(file_path)
|
||||
logger.debug(f"[清理] 删除: {filename}")
|
||||
|
||||
logger.info("[清理] 完成")
|
||||
|
||||
|
||||
async def clean_unused_emojis(emoji_dir: str, emoji_objects: List["MaiEmoji"], removed_count: int) -> int:
|
||||
"""清理指定目录中未被 emoji_objects 追踪的表情包文件"""
|
||||
@@ -590,7 +588,7 @@ class EmojiManager:
|
||||
"""定期检查表情包完整性和数量"""
|
||||
await self.get_all_emoji_from_db()
|
||||
while True:
|
||||
logger.info("[扫描] 开始检查表情包完整性...")
|
||||
# logger.info("[扫描] 开始检查表情包完整性...")
|
||||
await self.check_emoji_file_integrity()
|
||||
await clear_temp_emoji()
|
||||
logger.info("[扫描] 开始扫描新表情包...")
|
||||
|
||||
@@ -119,15 +119,15 @@ class HeartFCMessageReceiver:
|
||||
# current_time = time.strftime("%H:%M:%S", time.localtime(message.message_info.time))
|
||||
current_talk_frequency = global_config.chat.get_current_talk_frequency(chat.stream_id)
|
||||
|
||||
# 如果消息中包含图片标识,则日志展示为图片
|
||||
# 如果消息中包含图片标识,则将 [picid:...] 替换为 [图片]
|
||||
picid_pattern = r"\[picid:([^\]]+)\]"
|
||||
processed_plain_text = re.sub(picid_pattern, "[图片]", message.processed_plain_text)
|
||||
|
||||
picid_match = re.search(r"\[picid:([^\]]+)\]", message.processed_plain_text)
|
||||
if picid_match:
|
||||
logger.info(f"[{mes_name}]{userinfo.user_nickname}: [图片] [当前回复频率: {current_talk_frequency}]")
|
||||
else:
|
||||
logger.info(
|
||||
f"[{mes_name}]{userinfo.user_nickname}:{message.processed_plain_text}[当前回复频率: {current_talk_frequency}]"
|
||||
)
|
||||
logger.info(
|
||||
f"[{mes_name}]{userinfo.user_nickname}:{processed_plain_text}"
|
||||
)
|
||||
|
||||
logger.debug(f"[{mes_name}][当前时段回复频率: {current_talk_frequency}]")
|
||||
|
||||
# 8. 关系处理
|
||||
if global_config.relationship.enable_relationship:
|
||||
|
||||
@@ -131,7 +131,7 @@ class MessageStorage:
|
||||
if matched_message:
|
||||
# 更新找到的消息记录
|
||||
Messages.update(message_id=qq_message_id).where(Messages.id == matched_message.id).execute()
|
||||
logger.info(f"更新消息ID成功: {matched_message.message_id} -> {qq_message_id}")
|
||||
logger.debug(f"更新消息ID成功: {matched_message.message_id} -> {qq_message_id}")
|
||||
else:
|
||||
logger.debug("未找到匹配的消息")
|
||||
|
||||
|
||||
@@ -585,10 +585,19 @@ class NormalChat:
|
||||
)
|
||||
response_set, plan_result = results
|
||||
except asyncio.TimeoutError:
|
||||
logger.warning(
|
||||
f"[{self.stream_name}] 并行执行回复生成和动作规划超时 ({gather_timeout}秒),正在取消相关任务..."
|
||||
)
|
||||
print(f"111{self.timeout_count}")
|
||||
gen_timed_out = not gen_task.done()
|
||||
plan_timed_out = not plan_task.done()
|
||||
|
||||
timeout_details = []
|
||||
if gen_timed_out:
|
||||
timeout_details.append("回复生成(gen)")
|
||||
if plan_timed_out:
|
||||
timeout_details.append("动作规划(plan)")
|
||||
|
||||
timeout_source = " 和 ".join(timeout_details)
|
||||
|
||||
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:
|
||||
logger.warning(
|
||||
|
||||
@@ -551,6 +551,9 @@ def build_readable_messages(
|
||||
show_actions: 是否显示动作记录
|
||||
"""
|
||||
# 创建messages的深拷贝,避免修改原始列表
|
||||
if not messages:
|
||||
return ""
|
||||
|
||||
copy_messages = [msg.copy() for msg in messages]
|
||||
|
||||
if show_actions and copy_messages:
|
||||
|
||||
Reference in New Issue
Block a user