Package com.hw.langchain.agents.agent
Class AgentExecutor
java.lang.Object
com.hw.langchain.chains.base.Chain
com.hw.langchain.agents.agent.AgentExecutor
Consists of an agent using tools.
- Author:
- HamaWhite
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic AgentExecutor
fromAgentAndTools
(BaseSingleActionAgent agent, List<BaseTool> tools) Create from agent and tools.getToolReturn
(org.apache.commons.lang3.tuple.Pair<AgentAction, String> nextStepOutput) Check if the tool is a returning tool.Run text through and get agent response.Return the input keys.Return the singular output key.processOutput
(AgentFinish output, List<org.apache.commons.lang3.tuple.Pair<AgentAction, String>> intermediateSteps) takeNextStep
(Map<String, BaseTool> nameToToolMap, Map<String, Object> inputs, List<org.apache.commons.lang3.tuple.Pair<AgentAction, String>> intermediateSteps) Take a single step in the thought-action-observation loop.
-
Constructor Details
-
AgentExecutor
public AgentExecutor()
-
-
Method Details
-
fromAgentAndTools
Create from agent and tools. -
chainType
-
inputKeys
Return the input keys. -
outputKeys
Return the singular output key.- Specified by:
outputKeys
in classChain
- Returns:
- the list of output keys
-
processOutput
public Map<String,String> processOutput(AgentFinish output, List<org.apache.commons.lang3.tuple.Pair<AgentAction, String>> intermediateSteps) -
takeNextStep
public Object takeNextStep(Map<String, BaseTool> nameToToolMap, Map<String, Object> inputs, List<org.apache.commons.lang3.tuple.Pair<AgentAction, String>> intermediateSteps) Take a single step in the thought-action-observation loop. Override this to take control of how the agent makes and acts on choices.- Returns:
- AgentFinish or List<Pair<AgentAction, String>>
-
innerCall
Run text through and get agent response. -
getToolReturn
public AgentFinish getToolReturn(org.apache.commons.lang3.tuple.Pair<AgentAction, String> nextStepOutput) Check if the tool is a returning tool.
-