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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -11
app.py CHANGED
@@ -80,11 +80,11 @@ def run_agent(_):
80
  - Insightful relationships between key columns.
81
  - At least 3 visualizations showing important trends.
82
  4. Derive at least 3 actionable real-world insights.
83
- 5. Save all visualizations to ./figures/ directory.
84
- 6. "Ensure that all visualizations have figure size at least 8x6 and saved at 150+ dpi."
85
- Return a JSON object with keys:
86
- - 'insights': clean bullet-point insights.
87
- - 'figures': list of file paths of generated visualizations.
88
  """
89
 
90
  result = agent.run(
@@ -96,15 +96,13 @@ def run_agent(_):
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:
@@ -112,7 +110,8 @@ def run_agent(_):
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
 
@@ -264,7 +263,6 @@ with gr.Blocks() as demo:
264
  lime_img = gr.Image(label="LIME Explanation")
265
 
266
 
267
- #agent_btn.click(fn=run_agent, inputs=df_output, outputs=insights_output)
268
  agent_btn.click(fn=run_agent, inputs=df_output, outputs=[insights_output, visual_output])
269
  train_btn.click(fn=train_model, inputs=df_output, outputs=[metrics_output, trials_output])
270
  explain_btn.click(fn=explainability, inputs=df_output, outputs=[shap_img, lime_img])
 
80
  - Insightful relationships between key columns.
81
  - At least 3 visualizations showing important trends.
82
  4. Derive at least 3 actionable real-world insights.
83
+ 5. Save all visualizations to ./figures/ directory.
84
+ 6. Ensure all visualizations are at least 8x6 and saved at 150+ dpi.
85
+ Return a JSON object with keys:
86
+ - 'insights': clean bullet-point insights.
87
+ - 'figures': list of file paths of generated visualizations.
88
  """
89
 
90
  result = agent.run(
 
96
  try:
97
  result = json.loads(result)
98
  except json.JSONDecodeError:
99
+ return "Failed to parse result from agent.", []
 
100
 
101
  if isinstance(result, dict):
102
  insights = result.get("insights", "No insights generated.")
103
  image_paths = result.get("figures", [])
104
  else:
105
+ return "Error: Unexpected result format from agent.", []
 
106
 
107
  images = []
108
  for path in image_paths:
 
110
  images.append(Image.open(path))
111
  except Exception as e:
112
  print(f"Error loading image {path}: {e}")
113
+ return insights, images # ⚠️ This must be a 2-element tuple
114
+
115
 
116
 
117
 
 
263
  lime_img = gr.Image(label="LIME Explanation")
264
 
265
 
 
266
  agent_btn.click(fn=run_agent, inputs=df_output, outputs=[insights_output, visual_output])
267
  train_btn.click(fn=train_model, inputs=df_output, outputs=[metrics_output, trials_output])
268
  explain_btn.click(fn=explainability, inputs=df_output, outputs=[shap_img, lime_img])