A chain managing an agent using tools.

Example


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

Constructors

Properties

earlyStoppingMethod: StoppingMethod = "force"
handleParsingErrors: string | boolean | ((e) => 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.

Type declaration

    • (e): string
    • Parameters

      • e: any

      Returns string

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

Accessors

  • get shouldContinueGetter(): ((iterations) => boolean)
  • Returns ((iterations) => 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[]
    • Optional config: any[]

    Returns Promise<ChainValues[]>

    ⚠️ Deprecated ⚠️

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

    This feature is deprecated and will be removed in the future.

    It is not recommended for use.

    Call the chain on all inputs in the list

  • Parameters

    • values: any
    • Optional config: any
    • Optional tags: string[]

      Deprecated

    Returns Promise<ChainValues>

    Deprecated

    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.

    • Optional config: any

      Optional configuration for the Runnable.

    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
    • Optional config: any

    Returns Promise<string>

    Deprecated

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

Generated using TypeDoc