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<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:
        | undefined
        | string
        | ToolCall
        | input<T | ZodEffects<T, output<T>, input<T>>>, callbacks?: Callbacks | RunnableConfig<Record<string, any>>): 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:
          | 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: Callbacks | RunnableConfig<Record<string, any>>

      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.