langchain.js
    Preparing search index...

    Class responsible for calling a language model and deciding an action.

    This is driven by an LLMChain. The prompt in the LLMChain must include a variable called "agent_scratchpad" where the agent can put its intermediary work.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    llmChain: LLMChain
    outputParser: undefined | AgentActionOutputParser
    ToolType: StructuredToolInterface

    Accessors

    • get allowedTools(): undefined | string[]

      Returns undefined | string[]

    • get inputKeys(): string[]

      Returns string[]

    • get returnValues(): string[]

      Returns string[]

    Methods

    • Return the string type key uniquely identifying multi or single action agents.

      Returns string

    • Return the string type key uniquely identifying this class of agent.

      Returns string

    • Returns string[]

    • Construct a scratchpad to let the agent continue its thought process

      Parameters

      • steps: AgentStep[]

      Returns Promise<string | BaseMessage[]>

    • Name of tool to use to terminate the chain.

      Returns string

    • Prefix to append the LLM call with.

      Returns string

    • Prefix to append the observation with.

      Returns string

    • Decide what to do given some input.

      Parameters

      • steps: AgentStep[]

        Steps the LLM has taken so far, along with observations from each.

      • inputs: ChainValues

        User inputs.

      • OptionalcallbackManager: any

        Callback manager to use for this call.

      Returns Promise<any>

      Action specifying what tool to use.

    • Prepare the agent for output, if needed

      Parameters

      • _returnValues: AgentFinish
      • _steps: AgentStep[]

      Returns Promise<AgentFinish>

    • Return response when agent has been stopped due to max iterations

      Parameters

      • earlyStoppingMethod: StoppingMethod
      • steps: AgentStep[]
      • inputs: ChainValues
      • OptionalcallbackManager: any

      Returns Promise<AgentFinish>

    • Create a prompt for this class

      Parameters

      • _tools: StructuredToolInterface[]

        List of tools the agent will have access to, used to format the prompt.

      • Optional_fields: Record<string, any>

        Additional fields used to format the prompt.

      Returns BasePromptTemplate

      A PromptTemplate assembled from the given tools and fields.

    • Load an agent from a json-like object describing it.

      Parameters

      Returns Promise<Agent>

    • Construct an agent from an LLM and a list of tools

      Parameters

      • _llm: BaseLanguageModelInterface
      • _tools: StructuredToolInterface[]
      • Optional_args: AgentArgs

      Returns Agent

    • Validate that appropriate tools are passed in

      Parameters

      • _tools: StructuredToolInterface[]

      Returns void