mirror of
https://github.com/hwchase17/langchain.git
synced 2025-05-29 11:09:07 +00:00
fix get_tool_return (#11346)
This commit is contained in:
parent
49b34e2293
commit
88bad37ec2
@ -1229,11 +1229,14 @@ class AgentExecutor(Chain):
|
|||||||
"""Check if the tool is a returning tool."""
|
"""Check if the tool is a returning tool."""
|
||||||
agent_action, observation = next_step_output
|
agent_action, observation = next_step_output
|
||||||
name_to_tool_map = {tool.name: tool for tool in self.tools}
|
name_to_tool_map = {tool.name: tool for tool in self.tools}
|
||||||
|
return_value_key = "output"
|
||||||
|
if len(self.agent.return_values) > 0:
|
||||||
|
return_value_key = self.agent.return_values[0]
|
||||||
# Invalid tools won't be in the map, so we return False.
|
# Invalid tools won't be in the map, so we return False.
|
||||||
if agent_action.tool in name_to_tool_map:
|
if agent_action.tool in name_to_tool_map:
|
||||||
if name_to_tool_map[agent_action.tool].return_direct:
|
if name_to_tool_map[agent_action.tool].return_direct:
|
||||||
return AgentFinish(
|
return AgentFinish(
|
||||||
{self.agent.return_values[0]: observation},
|
{return_value_key: observation},
|
||||||
"",
|
"",
|
||||||
)
|
)
|
||||||
return None
|
return None
|
||||||
|
Loading…
Reference in New Issue
Block a user