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 full)

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.

returnIntermediateSteps: boolean = false
returnOnlyOutputs: boolean = true
tools: StructuredToolInterface[]
maxIterations?: number = 15
memory?: any

Accessors

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

      • (iterations): 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

  • 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.