Update app.py
Browse files
app.py
CHANGED
|
@@ -53,20 +53,32 @@ agent = CodeAgent(
|
|
| 53 |
additional_authorized_imports=["numpy", "pandas", "matplotlib.pyplot", "seaborn"]
|
| 54 |
)
|
| 55 |
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
|
| 71 |
# Optionally, you can inspect the results
|
| 72 |
print(analysis_result)
|
|
|
|
| 53 |
additional_authorized_imports=["numpy", "pandas", "matplotlib.pyplot", "seaborn"]
|
| 54 |
)
|
| 55 |
|
| 56 |
+
# Modify `run_agent` to directly use the cleaned `df_global`
|
| 57 |
+
def run_agent(_):
|
| 58 |
+
if df_global is None or df_global.empty:
|
| 59 |
+
return "No data available for analysis."
|
| 60 |
+
|
| 61 |
+
# Use the cleaned data (df_global) for analysis
|
| 62 |
+
analysis_result = agent.run(
|
| 63 |
+
"""
|
| 64 |
+
You are an expert data analyst. Perform comprehensive analysis including:
|
| 65 |
+
1. Basic statistics and data quality checks.
|
| 66 |
+
2. Three insightful analytical questions about relationships in the data.
|
| 67 |
+
3. Visualization of key patterns and correlations.
|
| 68 |
+
4. Actionable real-world insights derived from findings.
|
| 69 |
+
Generate publication-quality visualizations and save them to './figures/'.
|
| 70 |
+
""",
|
| 71 |
+
additional_args={
|
| 72 |
+
"additional_notes": additional_notes, # Pass additional notes
|
| 73 |
+
"source_file": "uploaded_file.csv" # Use the appropriate file name or path if needed
|
| 74 |
+
}
|
| 75 |
+
)
|
| 76 |
+
return analysis_result
|
| 77 |
+
|
| 78 |
+
# Update the Gradio button to pass the cleaned data (df_global)
|
| 79 |
+
agent_btn.click(fn=run_agent, inputs=None, outputs=insights_output)
|
| 80 |
+
|
| 81 |
+
|
| 82 |
|
| 83 |
# Optionally, you can inspect the results
|
| 84 |
print(analysis_result)
|