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

View File

@@ -32,8 +32,9 @@ class GetRecommendationsTool(MoviePilotTool):
results = recommend_chain.bangumi_calendar(limit=limit)
if results:
return json.dumps([r.dict() for r in results], ensure_ascii=False, indent=2)
# 使用 to_dict() 方法
return json.dumps([r.to_dict() if hasattr(r, 'to_dict') else r.dict() if hasattr(r, 'dict') else r.model_dump() if hasattr(r, 'model_dump') else r for r in results], 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)}"