1. The Same 3 Steps Every Time
Every app we built repeats the same three steps by hand.
Step 1: prompt
template.invoke({...})→
Step 2: model
model.invoke(prompt)→
Step 3: parser
parser.invoke(res)Three calls, every time. The output of one is the input of the next.
2. LLMChain: One Prompt, One Model
LangChain's first answer (2022) was to join the steps into one object called a chain. An LLMChain joins one prompt and one model. You give it the blank, and it gives back the answer as text.
from langchain_classic.chains.llm import LLMChain from langchain_core.prompts import ChatPromptTemplate from langchain.chat_models import init_chat_model model = init_chat_model(model="mistralai:open-mistral-nemo") prompt1 = ChatPromptTemplate.from_template( "What is a catchy company name for a business that makes {product}? Give ONLY the name in 2-3 words." ) chain1 = LLMChain(llm=model, prompt=prompt1) result = chain1.invoke({"product": "AI model"}) print(result["text"])
Two examples. Change the product, run again. Nothing else changes.
| You give | You get |
|---|---|
| AI model | Neural Nexus Labs |
| Electric Skateboard | Volt Glide |
Example answers. Yours will be different.
Why use it? The prompt and the model run together, in one call. You do not fill the prompt, call the model and read the reply by hand.
Why plain text? An LLMChain has a
StrOutputParser inside. It takes the text out of the model's reply and gives it back under the key 'text'.3. SimpleSequentialChain: Chain 1 Into Chain 2
A SimpleSequentialChain runs chains one after another. The answer of chain 1 goes into chain 2.
from langchain_classic.chains.sequential import SimpleSequentialChain prompt2 = ChatPromptTemplate.from_template( "Write a punchy 1-line advertising slogan for a company named {company_name}." ) chain2 = LLMChain(llm=model, prompt=prompt2) overall_legacy_chain = SimpleSequentialChain( chains=[chain1, chain2] ) final_slogan = overall_legacy_chain.run("Electric Skateboard") print(final_slogan)
Two examples. Chain 1 writes a company name. Chain 2 writes a slogan for that name.
| You give | You get |
|---|---|
| Electric Skateboard | Volt Glide: Power Up, Glide On. |
| AI model | QuantumSynth AI: Amplify Your Ideas with Quantum Precision. |
Example answers. Yours will be different.
Why use it? Use it when the answer of one step is the input of the next step. Here the name from chain 1 fills the blank
{company_name} in chain 2.What comes back? Only the last answer. The company name in the middle is not shown.
.run shows a deprecation warning. It still works.4. What's the Issue, Then?
Old chains worked, but they had real problems.
Issue 1
40+ chain classes
A new class for almost every job. You had to know all the names:
LLMChainone prompt + one modelSimpleSequentialChainthe output of chain 1 goes into chain 2SequentialChainmany chains, with named inputs and outputsConversationChaina chat that remembersConversationalRetrievalChaina chat over your documentsRetrievalQAWithSourcesChainanswers from documents, with sourcesStuffDocumentsChainput all documents into one promptMapReduceDocumentsChainsummarise each document, then combineRefineDocumentsChainimprove the answer document by documentLLMMathChainsolve a maths question with the modelMultiPromptChainpick the right prompt for the questionTransformChainrun a plain Python function as a stepConstitutionalChaincheck an answer against rulesOpenAIModerationChainflag unsafe text…and 25+ more.
Issue 2
A black box
You could not put your own step inside a chain. For example: clean the company name before chain 2 uses it.
Issue 3
Different methods
One job, three names:
chain.run(…)chain.predict(…)chain.apply(…)Issue 4
Hard to stream
Some chains could not stream the answer, or run many inputs at once.
What happened next
Deprecated
2024: old chains deprecated. Oct 2025: LangChain 1.0 moved them to
langchain-classic. You only need them to read old code.Code
01_legacy_chains.py01_legacy_chains.py · 29 linesShow code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | from dotenv import load_dotenv load_dotenv() from langchain_classic.chains import LLMChain, SimpleSequentialChain from langchain_core.prompts import ChatPromptTemplate from langchain.chat_models import init_chat_model model = init_chat_model(model="mistralai:open-mistral-nemo") """Old way (2023): LLMChain = prompt + model in one ready-made class""" prompt1 = ChatPromptTemplate.from_template( "What is a catchy company name for a business that makes {product}? Give ONLY the name in 2-3 words." ) chain1 = LLMChain(llm=model, prompt=prompt1) prompt2 = ChatPromptTemplate.from_template( "Write a punchy 1-line advertising slogan for a company named {company_name}." ) chain2 = LLMChain(llm=model, prompt=prompt2) """SimpleSequentialChain: output of chain1 goes into chain2, called with .run()""" overall_legacy_chain = SimpleSequentialChain( chains=[chain1, chain2] ) final_slogan = overall_legacy_chain.run("Electric Skateboard") print(final_slogan) |