LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
    • Overview
    • Caches
    • Callbacks
    • Documents
    • Document loaders
    • Embeddings
    • Exceptions
    • Language models
    • Serialization
    • Output parsers
    • Prompts
    • Rate limiters
    • Retrievers
    • Runnables
    • Utilities
    • Vector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    OverviewCachesCallbacksDocumentsDocument loadersEmbeddingsExceptionsLanguage modelsSerializationOutput parsersPromptsRate limitersRetrieversRunnablesUtilitiesVector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    Language
    Theme
    Pythonlangchain-corerunnablesbaseRunnablepipe
    Method●Since v0.1

    pipe

    Pipe Runnable objects.

    Compose this Runnable with Runnable-like objects to make a RunnableSequence.

    Equivalent to RunnableSequence(self, *others) or self | others[0] | ...

    Copy
    pipe(
      self,
      *others: Runnable[Any, Other] | Callable[[Any], Other] = (),
      name: str | None = None
    ) -> RunnableSerializable[Input, Other]

    Example:

    from langchain_core.runnables import RunnableLambda
    
    def add_one(x: int) -> int:
        return x + 1
    
    def mul_two(x: int) -> int:
        return x * 2
    
    runnable_1 = RunnableLambda(add_one)
    runnable_2 = RunnableLambda(mul_two)
    sequence = runnable_1.pipe(runnable_2)
    # Or equivalently:
    # sequence = runnable_1 | runnable_2
    # sequence = RunnableSequence(first=runnable_1, last=runnable_2)
    sequence.invoke(1)
    await sequence.ainvoke(1)
    # -> 4
    
    sequence.batch([1, 2, 3])
    await sequence.abatch([1, 2, 3])
    # -> [4, 6, 8]

    Parameters

    NameTypeDescription
    *othersRunnable[Any, Other] | Callable[[Any], Other]
    Default:()

    Other Runnable or Runnable-like objects to compose

    namestr | None
    Default:None

    An optional name for the resulting RunnableSequence.

    View source on GitHub