Skip to content

Commit

Permalink
Merge pull request langchain-ai#193 from langchain-ai/wfh/aexec_tool_…
Browse files Browse the repository at this point in the history
…support

Add tools upport to agentexecutor
  • Loading branch information
nfcampos authored Mar 7, 2024
2 parents 4569be0 + 16970ac commit 069ff06
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions langgraph/prebuilt/agent_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,26 @@ async def arun_agent(data):
def execute_tools(data):
# Get the most recent agent_outcome - this is the key added in the `agent` above
agent_action = data["agent_outcome"]
if isinstance(agent_action, list):
output = tool_executor.batch(agent_action, return_exceptions=True)
return {
"intermediate_steps": [
(action, str(out)) for action, out in zip(agent_action, output)
]
}
output = tool_executor.invoke(agent_action)
return {"intermediate_steps": [(agent_action, str(output))]}

async def aexecute_tools(data):
# Get the most recent agent_outcome - this is the key added in the `agent` above
agent_action = data["agent_outcome"]
if isinstance(agent_action, list):
output = await tool_executor.abatch(agent_action, return_exceptions=True)
return {
"intermediate_steps": [
(action, str(out)) for action, out in zip(agent_action, output)
]
}
output = await tool_executor.ainvoke(agent_action)
return {"intermediate_steps": [(agent_action, str(output))]}

Expand Down

0 comments on commit 069ff06

Please sign in to comment.