import { ... } from "@langchain/core/runnables";Ensure that a passed config is an object with all required keys present.
Helper function that patches runnable configs with updated properties.
Race a promise with an abort signal. If the signal is aborted, the promise will be rejected with the error from the signal. If the promise is rejected, the signal will be aborted.
A runnable that routes to a set of runnables based on Input['key']. Returns the output of the selected runnable.
A Runnable is a generic unit of work that can be invoked, batched, streamed, and/or transformed.
A runnable that assigns key-value pairs to inputs of type Record<string, unknown>.
Wraps a runnable and applies partial config upon invocation.
Class that represents a runnable branch. The RunnableBranch is initialized with an array of branches and a default branch. When invoked, it evaluates the condition of each branch in order and executes the corresponding branch if the condition is true. If none of the conditions are true, it executes the default branch.
A runnable that delegates calls to another runnable with each element of the input sequence.
A runnable that wraps an arbitrary function that takes a single argument.
A runnable that runs a mapping of runnables in parallel, and returns a mapping of their outputs.
A runnable that runs a mapping of runnables in parallel, and returns a mapping of their outputs.
A runnable to passthrough inputs unchanged or with additional keys.
This runnable behaves almost like the identity function, except that it can be configured to add additional keys to the output, if the input is an object.
The example below demonstrates how to use RunnablePassthrough to passthrough the input from the .invoke()`
A runnable that assigns key-value pairs to inputs of type Record<string, unknown>.
Useful for streaming, can be automatically created and chained by calling runnable.pick();.
Base class for runnables that can be retried a specified number of times.
A sequence of runnables, where the output of each is the input of the next.
Wraps a runnable and applies partial config upon invocation.
A Runnable that can fallback to other Runnables if it fails. External APIs (e.g., APIs for a language model) may at times experience degraded performance or even downtime.
In these cases, it can be useful to have a fallback Runnable that can be used in place of the original Runnable (e.g., fallback to another LLM provider).
Fallbacks can be defined at the level of a single Runnable, or at the level of a chain of Runnables. Fallbacks are tried in order until one succeeds or all fail.
While you can instantiate a RunnableWithFallbacks directly, it is usually
more convenient to use the withFallbacks method on an existing Runnable.
When streaming, fallbacks will only be called on failures during the initial stream creation. Errors that occur after a stream starts will not fallback to the next Runnable.
Wraps a LCEL chain and manages history. It appends input messages and chain outputs as history, and adds the current history messages to the chain input.
Type for a branch in the RunnableBranch. It consists of a condition runnable and a branch runnable. The condition runnable is used to determine whether the branch should be executed, and the branch runnable is executed if the condition is true.