mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-03-19 19:46:55 +08:00
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:
@@ -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)}"
|
||||
|
||||
Reference in New Issue
Block a user