langchain.js
    Preparing search index...

    A chain managing an agent using tools.


    const executor = AgentExecutor.fromAgentAndTools({
    agent: async () => loadAgentFromLangchainHub(),
    tools: [new SerpAPI(), new Calculator()],
    returnIntermediateSteps: true,
    });

    const result = await executor.invoke({
    input: `Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?`,
    });

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    earlyStoppingMethod: StoppingMethod = "force"
    handleParsingErrors: string | boolean | ((e: any) => string) = false

    How to handle errors raised by the agent's output parser. Defaults to False, which raises the error.

    If true, the error will be sent back to the LLM as an observation. If a string, the string itself will be sent to the LLM as an observation. If a callable function, the function will be called with the exception as an argument, and the result of that function will be passed to the agent as an observation.

    handleToolRuntimeErrors?: (e: Error) => string
    maxIterations?: number = 15
    memory?: any
    returnIntermediateSteps: boolean = false
    returnOnlyOutputs: boolean = true
    tools: StructuredToolInterface[]

    Accessors

    • get inputKeys(): string[]

      Returns string[]

    • get lc_namespace(): string[]

      Returns string[]

    • get outputKeys(): string[]

      Returns string[]

    • get shouldContinueGetter(): (iterations: number) => boolean

      Returns (iterations: number) => boolean

        • (iterations: number): boolean
        • Method that checks if the agent execution should continue based on the number of iterations.

          Parameters

          • iterations: number

            The current number of iterations.

          Returns boolean

          A boolean indicating whether the agent execution should continue.

    Methods

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

      Returns "agent_executor"

    • Parameters

      • values: any

      Returns Promise<any>

    • Parameters

      • nextStepOutput: AgentStep

      Returns Promise<any>

    • Parameters

      • output: AgentFinish
      • intermediateSteps: AgentStep[]
      • OptionalrunManager: any

      Returns Promise<ChainValues>

    • Parameters

      Returns AgentFinish

    • Parameters

      • inputs: Record<string, any>
      • Optionaloptions: any

      Returns AsyncGenerator<ChainValues>

    • Parameters

      • nameToolMap: Record<string, Toolkit>
      • inputs: ChainValues
      • intermediateSteps: AgentStep[]
      • OptionalrunManager: any
      • Optionalconfig: any

      Returns Promise<any>

    • Parameters

      • inputs: ChainValues[]
      • Optionalconfig: any[]

      Returns Promise<ChainValues[]>

      Use .batch() instead. Will be removed in 0.2.0.

      Call the chain on all inputs in the list

    • Parameters

      • values: any
      • Optionalconfig: any
      • Optionaltags: string[]

      Returns Promise<ChainValues>

      Use .invoke() instead. Will be removed in 0.2.0.

      Run the core logic of this chain and add to output if desired.

      Wraps _call and handles memory.

    • Invoke the chain with the provided input and returns the output.

      Parameters

      • input: ChainValues

        Input values for the chain run.

      • Optionaloptions: any

      Returns Promise<ChainValues>

      Promise that resolves with the output of the chain run.

    • Parameters

      • inputs: Record<string, unknown>
      • outputs: Record<string, unknown>
      • returnOnlyOutputs: boolean = false

      Returns Promise<Record<string, unknown>>

    • Parameters

      • input: any
      • Optionalconfig: any

      Returns Promise<string>

      Use .invoke() instead. Will be removed in 0.2.0.

    • Load a chain from a json-like object describing it.

      Parameters

      Returns Promise<BaseChain<ChainValues, ChainValues>>

    • Returns string