import { Runnable, type RunnableBatchOptions } from "./base.js"; import { IterableReadableStream } from "../utils/stream.js"; import { type RunnableConfig } from "./config.js"; export type RouterInput = { key: string; input: any; }; /** * A runnable that routes to a set of runnables based on Input['key']. * Returns the output of the selected runnable. * @example * ```typescript * import { RouterRunnable, RunnableLambda } from "@langchain/core/runnables"; * * const router = new RouterRunnable({ * runnables: { * toUpperCase: RunnableLambda.from((text: string) => text.toUpperCase()), * reverseText: RunnableLambda.from((text: string) => * text.split("").reverse().join("") * ), * }, * }); * * // Invoke the 'reverseText' runnable * const result1 = router.invoke({ key: "reverseText", input: "Hello World" }); * * // "dlroW olleH" * * // Invoke the 'toUpperCase' runnable * const result2 = router.invoke({ key: "toUpperCase", input: "Hello World" }); * * // "HELLO WORLD" * ``` */ export declare class RouterRunnable extends Runnable { static lc_name(): string; lc_namespace: string[]; lc_serializable: boolean; runnables: Record>; constructor(fields: { runnables: Record>; }); invoke(input: RunInput, options?: Partial): Promise; batch(inputs: RunInput[], options?: Partial | Partial[], batchOptions?: RunnableBatchOptions & { returnExceptions?: false; }): Promise; batch(inputs: RunInput[], options?: Partial | Partial[], batchOptions?: RunnableBatchOptions & { returnExceptions: true; }): Promise<(RunOutput | Error)[]>; batch(inputs: RunInput[], options?: Partial | Partial[], batchOptions?: RunnableBatchOptions): Promise<(RunOutput | Error)[]>; stream(input: RunInput, options?: Partial): Promise>; }