Simple Sequential Chains
Sequential Chains kept both tag and explanation for step 2 — that needed RunnablePassthrough.assign. Here step 2 only gets the string from step 1. Pick a tag from a feature name (links → a), then explain it. No assign — just more pipes.
Previous output only
Step 1 takes {"feature": "links"} and returns a tag string like "a". Step 2 never sees feature — only that string, passed into {tag}.
A straight line — step 2 never sees the original input:
input
{ feature: "links" }
step 1
pick_chain
string
"a"
step 2
explain
output
explanation
Compared to Sequential Chains
Need the original dict plus a new key? Use assign, as in the previous lesson. Step 2 only needs the last string? Pipe the chains — no extra wiring.
# Step 2 needs tag AND explanation
RunnablePassthrough.assign(
explanation=explain_chain
)
| tip_prompt | model | parserKeeps original input + adds new keys
Simple Sequential
# Step 2 only needs step 1 output
chain = pick_chain
| explain_prompt
| model
| parserPrevious output flows straight through
The chain line
The full chain is one line:
What happens inside one invoke call
{tag}) — LangChain maps the incoming string to it.What each step does
pick_chain— input{"feature": "links"}, output tag string"a".explain_prompt | model | parser— input that string as{tag}, output the explanation.
The demo script
simple_sequential_chains_demo.py runs the chain for links and images.
Download the code
simple_sequential_chains_demo.py
pick_chain → explain
langchain-course folder. Needs venv, .env, and packages from Project Setup.Run it
Activate the venv from Project Setup, then:
python simple_sequential_chains_demo.pyinvoke — two model calls under the hood.When to pick this pattern
- Step 2 only needs the text step 1 produced — pick tag, then explain, like in this demo.
- You do not need to keep keys from the original input dict for the second prompt.
- Official reference: Sequence runnables.
What's Next
Next: Multi-LLM Workflows — use a different model on each step.