Update app.py
Browse files
app.py
CHANGED
|
@@ -53,12 +53,15 @@ agent = CodeAgent(
|
|
| 53 |
additional_authorized_imports=["numpy", "pandas", "matplotlib.pyplot", "seaborn"]
|
| 54 |
)
|
| 55 |
|
| 56 |
-
def run_agent(
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
-
# Run the agent analysis logic
|
| 62 |
analysis_result = agent.run(
|
| 63 |
"""
|
| 64 |
You are an expert data analyst. Perform comprehensive analysis including:
|
|
@@ -69,13 +72,14 @@ def run_agent(file_data):
|
|
| 69 |
Generate publication-quality visualizations and save them to './figures/'.
|
| 70 |
""",
|
| 71 |
additional_args={
|
| 72 |
-
"additional_notes": additional_notes,
|
| 73 |
-
"source_file":
|
| 74 |
}
|
| 75 |
)
|
| 76 |
|
| 77 |
return analysis_result
|
| 78 |
|
|
|
|
| 79 |
# Optionally, you can inspect the results
|
| 80 |
print(analysis_result)
|
| 81 |
|
|
|
|
| 53 |
additional_authorized_imports=["numpy", "pandas", "matplotlib.pyplot", "seaborn"]
|
| 54 |
)
|
| 55 |
|
| 56 |
+
def run_agent(_):
|
| 57 |
+
global df_global
|
| 58 |
+
if df_global is None:
|
| 59 |
+
return "No data available. Please upload a file first."
|
| 60 |
+
|
| 61 |
+
# Save the cleaned DataFrame to a temp file for SmolAgent
|
| 62 |
+
temp_path = "./temp_cleaned_data.csv"
|
| 63 |
+
df_global.to_csv(temp_path, index=False)
|
| 64 |
|
|
|
|
| 65 |
analysis_result = agent.run(
|
| 66 |
"""
|
| 67 |
You are an expert data analyst. Perform comprehensive analysis including:
|
|
|
|
| 72 |
Generate publication-quality visualizations and save them to './figures/'.
|
| 73 |
""",
|
| 74 |
additional_args={
|
| 75 |
+
"additional_notes": additional_notes,
|
| 76 |
+
"source_file": temp_path # This is the key fix — pass the CSV file path
|
| 77 |
}
|
| 78 |
)
|
| 79 |
|
| 80 |
return analysis_result
|
| 81 |
|
| 82 |
+
|
| 83 |
# Optionally, you can inspect the results
|
| 84 |
print(analysis_result)
|
| 85 |
|