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

Should not change on patch releases.

interface ToolInterface<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:
        | undefined
        | string
        | ToolCall
        | input<T | ZodEffects<T, output<T>, input<T>>>, callbacks?: RunnableConfig | Callbacks): 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 ZodObjectAny = ZodObjectAny

Hierarchy (view full)

Properties

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

Methods

  • Parameters

    • arg:
          | undefined
          | string
          | ToolCall
          | input<T | ZodEffects<T, output<T>, input<T>>>

      The input argument for the tool, which can be a string, undefined, or an input of the tool's schema.

    • Optionalcallbacks: RunnableConfig | Callbacks

      Optional callbacks 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 and callbacks. It handles string inputs specifically.