LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
LangChain
  • Browser
  • Universal
  • Hub
  • Node
  • Load
  • Serializable
  • Encoder Backed
  • File System
  • In Memory
LangChain Core
  • Agents
  • Caches
  • Base
  • Dispatch
  • Web
  • Manager
  • Promises
  • Chat History
  • Context
  • Base
  • Langsmith
  • Documents
  • Embeddings
  • Errors
  • Example Selectors
  • Indexing
  • Base
  • Chat Models
  • Llms
  • Profile
  • Structured Output
  • Load
  • Serializable
  • Memory
  • Messages
  • Tool
  • Output Parsers
  • Openai Functions
  • Openai Tools
  • Outputs
  • Prompt Values
  • Prompts
  • Retrievers
  • Document Compressors
  • Runnables
  • Graph
  • Singletons
  • Stores
  • Structured Query
  • Testing
  • Tools
  • Base
  • Console
  • Log Stream
  • Run Collector
  • Tracer Langchain
  • Stream
  • Async Caller
  • Chunk Array
  • Context
  • Env
  • Event Source Parse
  • Format
  • Function Calling
  • Hash
  • Json Patch
  • Json Schema
  • Math
  • Ssrf
  • Standard Schema
  • Stream
  • Testing
  • Tiktoken
  • Types
  • Vectorstores
Text Splitters
MCP Adapters
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

LangChain
BrowserUniversalHubNodeLoadSerializableEncoder BackedFile SystemIn Memory
LangChain Core
AgentsCachesBaseDispatchWebManagerPromisesChat HistoryContextBaseLangsmithDocumentsEmbeddingsErrorsExample SelectorsIndexingBaseChat ModelsLlmsProfileStructured OutputLoadSerializableMemoryMessagesToolOutput ParsersOpenai FunctionsOpenai ToolsOutputsPrompt ValuesPromptsRetrieversDocument CompressorsRunnablesGraphSingletonsStoresStructured QueryTestingToolsBaseConsoleLog StreamRun CollectorTracer LangchainStreamAsync CallerChunk ArrayContextEnvEvent Source ParseFormatFunction CallingHashJson PatchJson SchemaMathSsrfStandard SchemaStreamTestingTiktokenTypesVectorstores
Text Splitters
MCP Adapters
Language
Theme
JavaScript@langchain/corerunnables
Module●Since v0.3

runnables

Copy
import { ... } from "@langchain/core/runnables";

Functions

function
_coerceToRunnable→ Runnable<RunInput, Exclude<RunOutput, Error>, CallOptions>
function
ensureConfig→ CallOptions
function
getCallbackManagerForConfig→ Promise<CallbackManager | undefined>
function
mergeConfigs→ Partial<CallOptions>
function
patchConfig→ Partial<CallOptions>
function
pickRunnableConfigKeys→ Partial<RunnableConfig<Record<string, any>>> | undefined
function
raceWithSignal→ Promise<T>

Classes

class
RouterRunnable
class
Runnable
class
RunnableAssign
class
RunnableBinding
class
RunnableBranch
class
RunnableEach
class
RunnableLambda
class
RunnableMap
class
RunnableParallel
class
RunnablePassthrough
class
RunnablePick
class
RunnableRetry
class
RunnableSequence
class
RunnableToolLike
class
RunnableWithFallbacks
class
RunnableWithMessageHistory

Interfaces

Type Aliases

View source on GitHub
interface
RunnableConfig
interface
RunnableInterface
interface
RunnableToolLikeArgs
interface
RunnableWithMessageHistoryInputs
typeAlias
Branch: [Runnable<RunInput, boolean>, Runnable<RunInput, RunOutput>]
typeAlias
BranchLike: [RunnableLike<RunInput, boolean>, RunnableLike<RunInput, RunOutput>]
typeAlias
RouterInput
typeAlias
RunnableBatchOptions
typeAlias
RunnableBindingArgs
typeAlias
RunnableFunc: (input: RunInput, options: CallOptions | Record<string, any> | Record<string, any> & CallOptions)
typeAlias
RunnableIOSchema
typeAlias
RunnableLike: RunnableInterface<RunInput, RunOutput, CallOptions> | RunnableFunc<RunInput, RunOutput, CallOptions> | RunnableMapLike<RunInput, RunOutput>
typeAlias
RunnableRetryFailedAttemptHandler: (error: any, input: any)

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.

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

Should not change on patch releases.

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.