Skip to content

Commit

Permalink
Fixing blank thoughts in verbose for "_Exception" Action (#5331)
Browse files Browse the repository at this point in the history
Fixed the issue of blank Thoughts being printed in verbose when
`handle_parsing_errors=True`, as below:

Before Fix:
```
Observation: There are 38175 accounts available in the dataframe.
Thought:
Observation: Invalid or incomplete response
Thought:
Observation: Invalid or incomplete response
Thought:
```

After Fix:
```
Observation: There are 38175 accounts available in the dataframe.
Thought:AI: {
    "action": "Final Answer",
    "action_input": "There are 38175 accounts available in the dataframe."
}
Observation: Invalid Action or Action Input format
Thought:AI: {
    "action": "Final Answer",
    "action_input": "The number of available accounts is 38175."
}
Observation: Invalid Action or Action Input format
```

@vowelparrot currently I have set the colour of thought to green (same
as the colour when `handle_parsing_errors=False`). If you want to change
the colour of this "_Exception" case to red or something else (when
`handle_parsing_errors=True`), feel free to change it in line 789.
  • Loading branch information
svdeepak99 authored May 28, 2023
1 parent c49c6ac commit c6e5d90
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions langchain/agents/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,8 @@ def _take_next_step(
else:
raise ValueError("Got unexpected type of `handle_parsing_errors`")
output = AgentAction("_Exception", observation, text)
if run_manager:
run_manager.on_agent_action(output, color="green")
tool_run_kwargs = self.agent.tool_run_logging_kwargs()
observation = ExceptionTool().run(
output.tool_input,
Expand Down

0 comments on commit c6e5d90

Please sign in to comment.