Spaces:
Sleeping
Sleeping
Rajan Sharma
commited on
Update app.py
Browse files
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 |
-
#
|
| 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 #
|
| 115 |
)
|
| 116 |
|
| 117 |
-
# Run the agent with the user's scenario text.
|
| 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 |
|