Update app.py
Browse files
app.py
CHANGED
|
@@ -92,6 +92,10 @@ def run_agent(_):
|
|
| 92 |
additional_args={"source_file": temp_file.name}
|
| 93 |
)
|
| 94 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
if isinstance(result, str):
|
| 96 |
try:
|
| 97 |
result = json.loads(result)
|
|
@@ -104,13 +108,16 @@ def run_agent(_):
|
|
| 104 |
else:
|
| 105 |
return "Error: Unexpected result format from agent.", []
|
| 106 |
|
|
|
|
| 107 |
images = []
|
| 108 |
for path in image_paths:
|
| 109 |
try:
|
| 110 |
images.append(Image.open(path))
|
| 111 |
except Exception as e:
|
| 112 |
print(f"Error loading image {path}: {e}")
|
| 113 |
-
|
|
|
|
|
|
|
| 114 |
|
| 115 |
|
| 116 |
|
|
|
|
| 92 |
additional_args={"source_file": temp_file.name}
|
| 93 |
)
|
| 94 |
|
| 95 |
+
insights = "No insights generated."
|
| 96 |
+
image_paths = []
|
| 97 |
+
|
| 98 |
+
# Handle different return formats from agent
|
| 99 |
if isinstance(result, str):
|
| 100 |
try:
|
| 101 |
result = json.loads(result)
|
|
|
|
| 108 |
else:
|
| 109 |
return "Error: Unexpected result format from agent.", []
|
| 110 |
|
| 111 |
+
# Load images from paths
|
| 112 |
images = []
|
| 113 |
for path in image_paths:
|
| 114 |
try:
|
| 115 |
images.append(Image.open(path))
|
| 116 |
except Exception as e:
|
| 117 |
print(f"Error loading image {path}: {e}")
|
| 118 |
+
|
| 119 |
+
return insights, images # ✅ Must be a 2-element tuple
|
| 120 |
+
|
| 121 |
|
| 122 |
|
| 123 |
|