Thought:The answer to the question is that Leo DiCaprio's current girlfriend is Gigi Hadid. 
Final Answer: Gigi Hadid.
> Finished chain.
'Gigi Hadid.'
Custom Error Function#
You can also customize the error to be a function that takes the error in and outputs a string.
def _handle_error(error) -> str:
    return str(error)[:50]
mrkl = initialize_agent(
    tools, 
    ChatOpenAI(temperature=0), 
    agent=AgentType.CHAT_ZERO_SHOT_REACT_DESCRIPTION, 
    verbose=True,
    handle_parsing_errors=_handle_error
)
mrkl.run("Who is Leo DiCaprio's girlfriend? No need to add Action")
> Entering new AgentExecutor chain...
Observation: Could not parse LLM output: I'm sorry, but I canno
Thought:I need to use the Search tool to find the answer to the question.
Action:
```
{
  "action": "Search",
  "action_input": "Who is Leo DiCaprio's girlfriend?"
}
```
Observation: DiCaprio broke up with girlfriend Camila Morrone, 25, in the summer of 2022, after dating for four years. He's since been linked to another famous supermodel – Gigi Hadid. The power couple were first supposedly an item in September after being spotted getting cozy during a party at New York Fashion Week.
Thought:The current girlfriend of Leonardo DiCaprio is Gigi Hadid. 
Final Answer: Gigi Hadid.
> Finished chain.
'Gigi Hadid.'
previous
How to create ChatGPT Clone
next
How to access intermediate steps
 Contents
  
Setup
Error
Default error handling
Custom Error Message
Custom Error Function
By Harrison Chase
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/agent_executors/examples/handle_parsing_errors.html