refactor: enhance tool message handling and improve error logging

- Updated _send_tool_message to accept a title parameter for better message context.
- Modified various tool implementations to utilize the new title parameter for clearer messaging.
- Improved error logging across multiple tools to include exception details for better debugging.
This commit is contained in:
jxxghp
2025-10-31 09:16:53 +08:00
parent c6baf43986
commit 055117d83d
9 changed files with 115 additions and 50 deletions
+2 -2
View File
@@ -26,8 +26,8 @@ class QueryMediaLibraryTool(MoviePilotTool):
continue
filtered_medias.append(media)
if filtered_medias:
return json.dumps([m.dict() for m in filtered_medias], ensure_ascii=False, indent=2)
return json.dumps([m.to_dict() if hasattr(m, 'to_dict') else m.dict() if hasattr(m, 'dict') else m.model_dump() if hasattr(m, 'model_dump') else m for m in filtered_medias], ensure_ascii=False, indent=2)
return "媒体库中未找到相关媒体。"
except Exception as e:
logger.error(f"查询媒体库失败: {e}")
logger.error(f"查询媒体库失败: {e}", exc_info=True)
return f"查询媒体库时发生错误: {str(e)}"