优化日志
This commit is contained in:
@@ -75,5 +75,5 @@ class BlockShuffler:
|
||||
return prompt_template, shuffled_context
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Block重排失败: {e}", exc_info=True)
|
||||
logger.error(f"Block重排失败: {e}")
|
||||
return prompt_template, context_data
|
||||
|
||||
@@ -99,7 +99,7 @@ class PromptComponentManager:
|
||||
result = await instance.execute()
|
||||
return str(result) if result is not None else ""
|
||||
except Exception as e:
|
||||
logger.error(f"执行静态规则提供者 '{cls.prompt_name}' 时出错: {e}", exc_info=True)
|
||||
logger.error(f"执行静态规则提供者 '{cls.prompt_name}' 时出错: {e}")
|
||||
return "" # 出错时返回空字符串,避免影响主流程
|
||||
|
||||
return content_provider
|
||||
@@ -313,7 +313,7 @@ class PromptComponentManager:
|
||||
try:
|
||||
content = await provider(params, target_prompt_name)
|
||||
except Exception as e:
|
||||
logger.error(f"执行规则 '{rule}' (来源: {source}) 的内容提供者时失败: {e}", exc_info=True)
|
||||
logger.error(f"执行规则 '{rule}' (来源: {source}) 的内容提供者时失败: {e}")
|
||||
continue
|
||||
|
||||
try:
|
||||
@@ -336,7 +336,7 @@ class PromptComponentManager:
|
||||
except re.error as e:
|
||||
logger.error(f"应用规则时发生正则错误: {e} (pattern: '{rule.target_content}')")
|
||||
except Exception as e:
|
||||
logger.error(f"应用注入规则 '{rule}' (来源: {source}) 失败: {e}", exc_info=True)
|
||||
logger.error(f"应用注入规则 '{rule}' (来源: {source}) 失败: {e}")
|
||||
|
||||
# 4. 占位符恢复
|
||||
final_template = modified_template
|
||||
|
||||
@@ -839,7 +839,7 @@ async def get_chat_type_and_target_info(chat_id: str) -> tuple[bool, dict | None
|
||||
else:
|
||||
logger.warning(f"无法获取 chat_stream for {chat_id} in utils")
|
||||
except Exception as e:
|
||||
logger.error(f"获取聊天类型和目标信息时出错 for {chat_id}: {e}", exc_info=True)
|
||||
logger.error(f"获取聊天类型和目标信息时出错 for {chat_id}: {e}")
|
||||
# Keep defaults on error
|
||||
|
||||
return is_group_chat, chat_target_info
|
||||
|
||||
@@ -214,7 +214,7 @@ class ImageManager:
|
||||
return f"[表情包:{refined_part}]"
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"获取表情包描述失败: {e!s}", exc_info=True)
|
||||
logger.error(f"获取表情包描述失败: {e!s}")
|
||||
return "[表情包(处理失败)]"
|
||||
|
||||
async def get_image_description(self, image_base64: str) -> str:
|
||||
@@ -257,7 +257,7 @@ class ImageManager:
|
||||
if description and description.strip():
|
||||
break # 成功获取描述则跳出循环
|
||||
except Exception as e:
|
||||
logger.error(f"VLM调用失败 (第 {i+1}/3 次): {e}", exc_info=True)
|
||||
logger.error(f"VLM调用失败 (第 {i+1}/3 次): {e}")
|
||||
|
||||
if i < 2: # 如果不是最后一次,则等待1秒
|
||||
logger.warning("识图失败,将在1秒后重试...")
|
||||
@@ -286,7 +286,7 @@ class ImageManager:
|
||||
return f"[图片:{description}]"
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"获取图片描述时发生严重错误: {e!s}", exc_info=True)
|
||||
logger.error(f"获取图片描述时发生严重错误: {e!s}")
|
||||
return "[图片(处理失败)]"
|
||||
|
||||
@staticmethod
|
||||
@@ -388,7 +388,7 @@ class ImageManager:
|
||||
logger.error("GIF转换失败: 内存不足,可能是GIF太大或帧数太多")
|
||||
return None # 内存不够啦
|
||||
except Exception as e:
|
||||
logger.error(f"GIF转换失败: {e!s}", exc_info=True) # 记录详细错误信息
|
||||
logger.error(f"GIF转换失败: {e!s}") # 记录详细错误信息
|
||||
return None # 其他错误也返回None
|
||||
|
||||
async def process_image(self, image_base64: str) -> tuple[str, str]:
|
||||
@@ -459,7 +459,7 @@ class ImageManager:
|
||||
return image_id, description
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"处理图片时发生严重错误: {e!s}", exc_info=True)
|
||||
logger.error(f"处理图片时发生严重错误: {e!s}")
|
||||
return "", "[图片(处理失败)]"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user