Spaces:
Sleeping
Sleeping
Rajan Sharma
commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -99,7 +99,6 @@ def handle(user_msg: str, history_messages: List[Dict[str, str]], files: list) -
|
|
| 99 |
if file_paths:
|
| 100 |
try:
|
| 101 |
# For this example, we'll load the first CSV file.
|
| 102 |
-
# This can be extended to handle multiple DataFrames.
|
| 103 |
df = pd.read_csv(file_paths[0])
|
| 104 |
|
| 105 |
# Initialize the Cohere Chat LLM for the agent
|
|
@@ -109,9 +108,9 @@ def handle(user_msg: str, history_messages: List[Dict[str, str]], files: list) -
|
|
| 109 |
agent = create_pandas_dataframe_agent(
|
| 110 |
llm,
|
| 111 |
df,
|
| 112 |
-
agent_type=AgentType.
|
| 113 |
verbose=True,
|
| 114 |
-
allow_dangerous_code=True
|
| 115 |
)
|
| 116 |
|
| 117 |
# Run the agent with the user's scenario text. The agent will
|
|
@@ -193,7 +192,7 @@ with gr.Blocks(analytics_enabled=False) as demo:
|
|
| 193 |
ping_out = gr.Markdown()
|
| 194 |
|
| 195 |
def _on_send(m, h, f):
|
| 196 |
-
h2, _ = handle(m, h
|
| 197 |
return h2, ""
|
| 198 |
|
| 199 |
send.click(_on_send, inputs=[msg, chat, files], outputs=[chat, msg])
|
|
|
|
| 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
|
|
|
|
| 108 |
agent = create_pandas_dataframe_agent(
|
| 109 |
llm,
|
| 110 |
df,
|
| 111 |
+
agent_type=AgentType.ZERO_SHOT_REACT_DESCRIPTION, # Use a model-agnostic agent type
|
| 112 |
verbose=True,
|
| 113 |
+
allow_dangerous_code=True
|
| 114 |
)
|
| 115 |
|
| 116 |
# Run the agent with the user's scenario text. The agent will
|
|
|
|
| 192 |
ping_out = gr.Markdown()
|
| 193 |
|
| 194 |
def _on_send(m, h, f):
|
| 195 |
+
h2, _ = handle(m, h, f or [])
|
| 196 |
return h2, ""
|
| 197 |
|
| 198 |
send.click(_on_send, inputs=[msg, chat, files], outputs=[chat, msg])
|