Base interface implemented by all runnables. Used for cross-compatibility between different versions of LangChain core.

Should not change on patch releases.

interface StructuredToolInterface<T> {
    description: string;
    name: string;
    returnDirect: boolean;
    schema: T | ZodEffects<T, output<T>, input<T>>;
    batch(inputs: (ToolCall | (output<T> extends string
        ? string
        : never) | input<T>)[], options?: Partial<RunnableConfig<Record<string, any>>> | Partial<RunnableConfig<Record<string, any>>>[], batchOptions?: RunnableBatchOptions & {
        returnExceptions?: false;
    }): Promise<any[]>;
    batch(inputs: (ToolCall | (output<T> extends string
        ? string
        : never) | input<T>)[], options?: Partial<RunnableConfig<Record<string, any>>> | Partial<RunnableConfig<Record<string, any>>>[], batchOptions?: RunnableBatchOptions & {
        returnExceptions: true;
    }): Promise<any[]>;
    batch(inputs: (ToolCall | (output<T> extends string
        ? string
        : never) | input<T>)[], options?: Partial<RunnableConfig<Record<string, any>>> | Partial<RunnableConfig<Record<string, any>>>[], batchOptions?: RunnableBatchOptions): Promise<any[]>;
    call(arg: ToolCall | input<T> | (output<T> extends string
        ? string
        : never), configArg?: Callbacks | RunnableConfig<Record<string, any>>, tags?: string[]): Promise<any>;
    getName(suffix?: string): string;
    invoke(input: ToolCall | (output<T> extends string
        ? string
        : never) | input<T>, options?: Partial<RunnableConfig<Record<string, any>>>): Promise<any>;
    stream(input: ToolCall | (output<T> extends string
        ? string
        : never) | input<T>, options?: Partial<RunnableConfig<Record<string, any>>>): Promise<IterableReadableStreamInterface<any>>;
    transform(generator: AsyncGenerator<ToolCall | (output<T> extends string
        ? string
        : never) | input<T>, any, unknown>, options: Partial<RunnableConfig<Record<string, any>>>): AsyncGenerator<any, any, unknown>;
}

Type Parameters

  • T extends ZodObjectAny = ZodObjectAny

Hierarchy (view full)

Properties

description: string

A description of the tool.

name: string

The name of the tool.

returnDirect: boolean
schema: T | ZodEffects<T, output<T>, input<T>>

A Zod schema representing the parameters of the tool.

Methods

  • Parameters

    • arg: ToolCall | input<T> | (output<T> extends string
          ? string
          : never)

      The input argument for the tool.

    • OptionalconfigArg: Callbacks | RunnableConfig<Record<string, any>>

      Optional configuration or callbacks for the tool.

    • Optionaltags: string[]

      Optional tags for the tool.

    Returns Promise<any>

    A Promise that resolves with a string.

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

    Calls the tool with the provided argument, configuration, and tags. It parses the input according to the schema, handles any errors, and manages callbacks.