Luke31 commited on
Commit
a273e46
·
1 Parent(s): d1a5979

use handle_parsing_errors and send prompt

Browse files
Files changed (1) hide show
  1. pedalo/agents/code_interpreter.py +8 -11
pedalo/agents/code_interpreter.py CHANGED
@@ -14,13 +14,9 @@ model_grand_agent = "gpt-3.5-turbo"
14
  def run(
15
  prompt: str, df: DataFrame, st_callback: StreamlitCallbackHandler, model="gpt-4"
16
  ) -> str:
17
- # python_agent_executor = create_python_agent(
18
- # llm=ChatOpenAI(temperature=0, model=model_python_agent_executor),
19
- # tool=PythonREPLTool(),
20
- # agent_type=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
21
- # verbose=True,
22
- # )
23
-
24
  pandas_agent = create_pandas_dataframe_agent(
25
  llm=ChatOpenAI(
26
  temperature=0,
@@ -29,9 +25,12 @@ def run(
29
  ),
30
  df=df,
31
  verbose=True,
32
- agent_type=AgentType.OPENAI_FUNCTIONS, #AgentType.OPENAI_FUNCTIONS, #
 
 
33
  )
34
 
 
35
  grand_agent = initialize_agent(
36
  tools=[
37
  # Tool(
@@ -53,7 +52,5 @@ def run(
53
  # agent_type=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
54
  verbose=True,
55
  )
56
- cmd = f"""in provided pandas dataframe, answer the provided question.
57
- \n{prompt}"""
58
- response = pandas_agent.run(cmd, callbacks=[st_callback])
59
  return response
 
14
  def run(
15
  prompt: str, df: DataFrame, st_callback: StreamlitCallbackHandler, model="gpt-4"
16
  ) -> str:
17
+ agent_executor_kwargs = {
18
+ "handle_parsing_errors": True,
19
+ }
 
 
 
 
20
  pandas_agent = create_pandas_dataframe_agent(
21
  llm=ChatOpenAI(
22
  temperature=0,
 
25
  ),
26
  df=df,
27
  verbose=True,
28
+ agent_type=AgentType.OPENAI_FUNCTIONS,
29
+ agent_executor_kwargs=agent_executor_kwargs,
30
+ max_iterations=5
31
  )
32
 
33
+ # currently disabled, agent that can call other agent
34
  grand_agent = initialize_agent(
35
  tools=[
36
  # Tool(
 
52
  # agent_type=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
53
  verbose=True,
54
  )
55
+ response = pandas_agent.run(prompt, callbacks=[st_callback])
 
 
56
  return response