liveBook · Manning

Pipe operator

As explained in AI Agents and Applications

The pipe operator is syntax that passes the output of one operation to the next operation in a chain.

The pipe operator (|) passes one component’s output directly into the next component’s input, turning separate operations into a sequential chain. In LangChain Expression Language, a prompt can feed an LLM, whose response then feeds an output parser. section 3.1.3 section 4.8

Use the operator to build progressively richer workflows:

  • Connect a prompt template to an LLM, then parse the model response into clean text. section 3.1.3
  • Apply a chain to every document chunk with .map(), or use RunnableParallel to process independent operations concurrently. section 3.4 section 4.8
  • Choose parallel MapReduce processing for speed and lower token costs, or sequential refinement when preserving more context matters. section 3.4

Summarizing a document chunk

Define a prompt for one chunk, then compose it with the model and a string parser: summarize_chunk_prompt | llm, followed by summarize_chunk_chain | StrOutputParser(). RunnableParallel can apply this chain across chunks. section 3.1.3

summarize_chunk_prompt_template = """
Write a concise summary of the following text, and include the main details.
Text: {chunk}
"""

summarize_chunk_prompt =
PromptTemplate.from_template(summarize_chunk_prompt_template)
summarize_chunk_chain = summarize_chunk_prompt | llm

summarize_map_chain = (
    RunnableParallel (
        {
            'summary': summarize_chunk_chain | StrOutputParser()
        }
    )
)

Inspect the complete prompt-to-model-to-parser chain and its RunnableParallel wrapper. section 3.1.3

How AI Agents and Applications covers it

How deep it goes
Explains sequential chaining, parallel mapping, and processing trade-offs without detailing operator internals.
Examples
Demonstrates chunk summarization by piping a prompt into an LLM and then into StrOutputParser.
What it assumes
Assumes familiarity with prompts, LLM calls, and LangChain components while showing how their inputs and outputs connect.
What you can do after
Apply it via LangChain Expression Language to build sequential, parallel, mapped, and maintainable processing chains.
How it connects
Connects LCEL with RunnableParallel, RunnableLambda, RunnablePassthrough, MapReduce, and output parsing.

Also explained in

Compare how 6 books explain pipe operator →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of AI Agents and Applications. The section links point to the parts of the book it draws on.