cloudscomputes commited on
Commit
7829090
·
verified ·
1 Parent(s): 4a4e18f

启动AGENT前对于图像的检查

Browse files
Files changed (1) hide show
  1. app.py +17 -0
app.py CHANGED
@@ -76,5 +76,22 @@ agent = CodeAgent(
76
  prompt_templates=prompt_templates
77
  )
78
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
 
80
  GradioUI(agent).launch()
 
76
  prompt_templates=prompt_templates
77
  )
78
 
79
+ # 在你的 agent 定义之后,GradioUI 启动之前添加:
80
+ try:
81
+ # 直接调用工具,绕过 agent 的推理步骤,看是否能得到有效的 AgentImage
82
+ test_image = image_generation_tool("a cute cat avatar")
83
+
84
+ # 打印原始图片信息
85
+ if hasattr(test_image, 'to_raw'):
86
+ raw_pil_image = test_image.to_raw()
87
+ print(f"✅ 原始图片验证成功!尺寸: {raw_pil_image.size}, 模式: {raw_pil_image.mode}")
88
+ # 将图片保存到文件,以便你手动查看
89
+ raw_pil_image.save("test_cat_avatar.png")
90
+ print("📁 图片已保存为 'test_cat_avatar.png',请去文件系统中查看。")
91
+ else:
92
+ print("❌ 工具返回的对象没有 'to_raw' 方法,其类型为:", type(test_image))
93
+
94
+ except Exception as e:
95
+ print(f"❌ 直接调用工具时发生错误: {e}")
96
 
97
  GradioUI(agent).launch()