Generative AIby Dhruv Narang

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 giveYou get
AI modelNeural Nexus Labs
Electric SkateboardVolt 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 giveYou get
Electric SkateboardVolt Glide: Power Up, Glide On.
AI modelQuantumSynth 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 model
SimpleSequentialChainthe output of chain 1 goes into chain 2
SequentialChainmany chains, with named inputs and outputs
ConversationChaina chat that remembers
ConversationalRetrievalChaina chat over your documents
RetrievalQAWithSourcesChainanswers from documents, with sources
StuffDocumentsChainput all documents into one prompt
MapReduceDocumentsChainsummarise each document, then combine
RefineDocumentsChainimprove the answer document by document
LLMMathChainsolve a maths question with the model
MultiPromptChainpick the right prompt for the question
TransformChainrun a plain Python function as a step
ConstitutionalChaincheck an answer against rules
OpenAIModerationChainflag 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)