I'm getting the same issue with create_pandas_dataframe_agent:
from langchain_experimental.agents import create_pandas_dataframe_agent
from langchain.agents.agent_types import AgentType
agent = create_pandas_dataframe_agent(
llm,
df_chart,
verbose=True,
allow_dangerous_code=True,
agent_type="zero-shot-react-description",
include_df_in_prompt=True,
number_of_head_rows=5
)
agent.invoke("what is the combined remaining balance of patient 3 and patient 39?")
> Entering new AgentExecutor chain...
Thought: I need to find the remaining balance of patient 3 and patient 38 in the dataframe.
Action: python_repl_ast
Action Input: `df.loc[df['Patient Name'] == 'Patient_3', 'Balance Remaining'].values[0]`
ObservSyntaxError: invalid syntax (<unknown>, line 1)The error message indicates that there is a syntax error in the code. Upon reviewing the code, I notice that the column name is actually 'Balance Remaining', not 'Balance'. I will correct the code.
output is causing the input line to have a newline then followed by the word "Observ". It seems like a problem with the embedded system prompt but how do you change this???