pavanmutha commited on
Commit
66f42c4
·
verified ·
1 Parent(s): 1bc6e4d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -21
app.py CHANGED
@@ -92,27 +92,28 @@ 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)
98
- except json.JSONDecodeError:
99
- insights = "Failed to parse result from agent."
100
- return insights, []
101
-
102
- if isinstance(result, dict):
103
- insights = result.get("insights", "No insights generated.")
104
- image_paths = result.get("figures", [])
105
- else:
106
- insights = "Error: Unexpected result format from agent."
107
- image_paths = []
108
-
109
- images = []
110
- for path in image_paths:
111
- try:
112
- images.append(Image.open(path))
113
- except Exception as e:
114
- print(f"Error loading image {path}: {e}")
115
- return insights, images
 
116
 
117
 
118
  def train_model(_):
 
92
  additional_args={"source_file": temp_file.name}
93
  )
94
 
95
+ if isinstance(result, str):
96
+ try:
97
+ result = json.loads(result)
98
+ except json.JSONDecodeError:
99
+ insights = "Failed to parse result from agent."
100
+ return insights, []
101
+
102
+ if isinstance(result, dict):
103
+ insights = result.get("insights", "No insights generated.")
104
+ image_paths = result.get("figures", [])
105
+ else:
106
+ insights = "Error: Unexpected result format from agent."
107
+ image_paths = []
108
+
109
+ images = []
110
+ for path in image_paths:
111
+ try:
112
+ images.append(Image.open(path))
113
+ except Exception as e:
114
+ print(f"Error loading image {path}: {e}")
115
+ return insights, images
116
+
117
 
118
 
119
  def train_model(_):