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> | Partial<RunnableConfig>[], batchOptions?: RunnableBatchOptions & {
        returnExceptions?: false;
    }): Promise<any[]>;
    batch(inputs: (ToolCall | (output<T> extends string
        ? string
        : never) | input<T>)[], options?: Partial<RunnableConfig> | Partial<RunnableConfig>[], batchOptions?: RunnableBatchOptions & {
        returnExceptions: true;
    }): Promise<any[]>;
    batch(inputs: (ToolCall | (output<T> extends string
        ? string
        : never) | input<T>)[], options?: Partial<RunnableConfig> | Partial<RunnableConfig>[], batchOptions?: RunnableBatchOptions): Promise<any[]>;
    call(arg: ToolCall | input<T> | (output<T> extends string
        ? string
        : never), configArg?: Callbacks | RunnableConfig, tags?: string[]): Promise<any>;
    getName(suffix?: string): string;
    invoke(input: ToolCall | (output<T> extends string
        ? string
        : never) | input<T>, options?: Partial<RunnableConfig>): Promise<any>;
    stream(input: ToolCall | (output<T> extends string
        ? string
        : never) | input<T>, options?: Partial<RunnableConfig>): Promise<IterableReadableStreamInterface<any>>;
    transform(generator: AsyncGenerator<ToolCall | (output<T> extends string
        ? string
        : never) | input<T>, any, unknown>, options: Partial<RunnableConfig>): AsyncGenerator<any, any, unknown>;
}

Type Parameters

  • T extends ZodAny = ZodAny

Hierarchy (view full)

Properties

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

Methods

  • Parameters

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

      The input argument for the tool.

    • OptionalconfigArg: Callbacks | RunnableConfig

      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.