Class AgentExecutor

java.lang.Object
com.hw.langchain.chains.base.Chain
com.hw.langchain.agents.agent.AgentExecutor

public class AgentExecutor extends Chain
Consists of an agent using tools.
Author:
HamaWhite
  • Constructor Details

    • AgentExecutor

      public AgentExecutor()
  • Method Details

    • fromAgentAndTools

      public static AgentExecutor fromAgentAndTools(BaseSingleActionAgent agent, List<BaseTool> tools)
      Create from agent and tools.
    • chainType

      public String chainType()
      Specified by:
      chainType in class Chain
    • inputKeys

      public List<String> inputKeys()
      Return the input keys.
      Specified by:
      inputKeys in class Chain
      Returns:
      the list of input keys
    • outputKeys

      public List<String> outputKeys()
      Return the singular output key.
      Specified by:
      outputKeys in class Chain
      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

      protected Map<String,String> innerCall(Map<String,Object> inputs)
      Run text through and get agent response.
      Specified by:
      innerCall in class Chain
      Parameters:
      inputs - the inputs to be processed by the chain
      Returns:
      a map containing the output generated by the chain
    • getToolReturn

      public AgentFinish getToolReturn(org.apache.commons.lang3.tuple.Pair<AgentAction,String> nextStepOutput)
      Check if the tool is a returning tool.