Rajan Sharma commited on
Commit
5093d54
·
verified ·
1 Parent(s): cdd97de

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -4
app.py CHANGED
@@ -98,7 +98,7 @@ def handle(user_msg: str, history_messages: List[Dict[str, str]], files: list) -
98
  # --- NEW LOGIC: Activate data agent if files are uploaded ---
99
  if file_paths:
100
  try:
101
- # For this example, we'll load the first CSV file.
102
  df = pd.read_csv(file_paths[0])
103
 
104
  # Initialize the Cohere Chat LLM for the agent
@@ -111,11 +111,10 @@ def handle(user_msg: str, history_messages: List[Dict[str, str]], files: list) -
111
  agent_type=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
112
  verbose=True,
113
  allow_dangerous_code=True,
114
- handle_parsing_errors=True # Make the agent robust to LLM formatting errors
115
  )
116
 
117
- # Run the agent with the user's scenario text. The agent will
118
- # write and execute code to answer the query based on the dataframe.
119
  reply = agent.run(safe_in)
120
  reply = _sanitize_text(reply)
121
 
 
98
  # --- NEW LOGIC: Activate data agent if files are uploaded ---
99
  if file_paths:
100
  try:
101
+ # Load the first uploaded CSV into a pandas DataFrame.
102
  df = pd.read_csv(file_paths[0])
103
 
104
  # Initialize the Cohere Chat LLM for the agent
 
111
  agent_type=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
112
  verbose=True,
113
  allow_dangerous_code=True,
114
+ handle_parsing_errors=True # <-- THE FINAL FIX IS HERE
115
  )
116
 
117
+ # Run the agent with the user's scenario text.
 
118
  reply = agent.run(safe_in)
119
  reply = _sanitize_text(reply)
120