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

    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.