pavanmutha commited on
Commit
9e5a0f5
·
verified ·
1 Parent(s): 632978a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -7
app.py CHANGED
@@ -53,12 +53,15 @@ agent = CodeAgent(
53
  additional_authorized_imports=["numpy", "pandas", "matplotlib.pyplot", "seaborn"]
54
  )
55
 
56
- def run_agent(file_data):
57
- # Ensure that the file data is being used here
58
- global df_global # Use the global df_global if required
59
- df_global = file_data # Set the global df to the uploaded data
 
 
 
 
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, # Pass additional notes
73
- "source_file": df_global # Use the uploaded file's dataframe directly
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