Home / Function/ pipe() — langchain Function Reference

pipe() — langchain Function Reference

Architecture documentation for the pipe() function in base.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  0ceb56af_9929_a187_7b84_2584155e0d7b["pipe()"]
  4a62481c_02cb_a5de_1833_50669d5351a6["Runnable"]
  0ceb56af_9929_a187_7b84_2584155e0d7b -->|defined in| 4a62481c_02cb_a5de_1833_50669d5351a6
  2826dfcf_5024_bd4d_0268_8f909fbbae0c["batch()"]
  0ceb56af_9929_a187_7b84_2584155e0d7b -->|calls| 2826dfcf_5024_bd4d_0268_8f909fbbae0c
  3e736ea3_30ef_68c3_5f32_b8a49b37d501["abatch()"]
  0ceb56af_9929_a187_7b84_2584155e0d7b -->|calls| 3e736ea3_30ef_68c3_5f32_b8a49b37d501
  style 0ceb56af_9929_a187_7b84_2584155e0d7b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/runnables/base.py lines 660–707

    def pipe(
        self,
        *others: Runnable[Any, Other] | Callable[[Any], Other],
        name: str | None = None,
    ) -> RunnableSerializable[Input, Other]:
        """Pipe `Runnable` objects.

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

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

        Example:
            ```python
            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]
            ```

        Args:
            *others: Other `Runnable` or `Runnable`-like objects to compose
            name: An optional name for the resulting `RunnableSequence`.

        Returns:
            A new `Runnable`.
        """
        return RunnableSequence(self, *others, name=name)

Domain

Subdomains

Frequently Asked Questions

What does pipe() do?
pipe() is a function in the langchain codebase, defined in libs/core/langchain_core/runnables/base.py.
Where is pipe() defined?
pipe() is defined in libs/core/langchain_core/runnables/base.py at line 660.
What does pipe() call?
pipe() calls 2 function(s): abatch, batch.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free