Update app.py
Browse files
app.py
CHANGED
|
@@ -92,6 +92,8 @@ def run_agent(_):
|
|
| 92 |
additional_args={"source_file": temp_file.name}
|
| 93 |
)
|
| 94 |
|
|
|
|
|
|
|
| 95 |
insights = "No insights generated."
|
| 96 |
image_paths = []
|
| 97 |
|
|
@@ -102,11 +104,12 @@ def run_agent(_):
|
|
| 102 |
except json.JSONDecodeError:
|
| 103 |
return "Failed to parse result from agent.", []
|
| 104 |
|
|
|
|
| 105 |
if isinstance(result, dict):
|
| 106 |
-
|
|
|
|
| 107 |
image_paths = result.get("figures", [])
|
| 108 |
-
|
| 109 |
-
return "Error: Unexpected result format from agent.", []
|
| 110 |
|
| 111 |
# Load images from paths
|
| 112 |
images = []
|
|
|
|
| 92 |
additional_args={"source_file": temp_file.name}
|
| 93 |
)
|
| 94 |
|
| 95 |
+
os.makedirs("figures", exist_ok=True)
|
| 96 |
+
|
| 97 |
insights = "No insights generated."
|
| 98 |
image_paths = []
|
| 99 |
|
|
|
|
| 104 |
except json.JSONDecodeError:
|
| 105 |
return "Failed to parse result from agent.", []
|
| 106 |
|
| 107 |
+
|
| 108 |
if isinstance(result, dict):
|
| 109 |
+
raw_insights = result.get("insights", "No insights generated.")
|
| 110 |
+
insights = "\n".join(raw_insights) if isinstance(raw_insights, list) else raw_insights
|
| 111 |
image_paths = result.get("figures", [])
|
| 112 |
+
|
|
|
|
| 113 |
|
| 114 |
# Load images from paths
|
| 115 |
images = []
|