My agent is constructed as below:
agent = create_csv_agent(
llm,
csv_file,
verbose=True,
agent_type=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
prefix = "Only return me the final Boolean indexing formula. Check your output and make sure it conforms",
handle_parsing_errors=True
)
and in some cases it does return me the indexing formula, e.g. df[df['NAME'].str.contains('ABC', case=False)]
, but sometimes it returns with some newlines together, which is shown in the error:
"An output parsing error occurred.
In order to pass this error back to the agent and have it try again, pass `handle_parsing_errors=True` to the AgentExecutor.
This is the error: Could not parse LLM output: `The final Boolean indexing formula to select all rows with ABC is:nndf[df['LETTERS'] == ABC]`"
In my code, there is handle_parsing_errors=True
as well.
How should I proceed with this? Thank you 🙂