Fixed OpenAIFunctionsAgent not returning when receiving AgentFinish (#14236)

**Description:** The way the condition is checked in the
`return_stopped_response` function of `OpenAIAgent` may not be correct,
when the value returned is `AgentFinish` from the tools it does not work
properly.


Thanks for review, @baskaryan, @eyurtsev, @hwchase17.
This commit is contained in:
Hieu Lam 2023-12-05 02:43:04 +07:00 committed by GitHub
parent 6826feea14
commit ca8a022cd9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -162,7 +162,7 @@ class OpenAIFunctionsAgent(BaseSingleActionAgent):
agent_decision = self.plan( agent_decision = self.plan(
intermediate_steps, with_functions=False, **kwargs intermediate_steps, with_functions=False, **kwargs
) )
if type(agent_decision) == AgentFinish: if isinstance(agent_decision, AgentFinish):
return agent_decision return agent_decision
else: else:
raise ValueError( raise ValueError(