What LangChain Is (and a Tiny Chain You Can Run)
By Isaiah Daniel·
LangChain as orchestration glue for LLM apps, not magic: prompts, models, parsers, and a runnable mini chain for a fictional FAQ desk.
The first time someone asked me to "add LangChain" to a product, the request sounded like a feature. It was not. LangChain does not answer questions by itself. It is a way to wire prompts, models, parsers, retrievers, and tools into a path you can call like a function. If you treat it as magic, you get a demo that is hard to debug. If you treat it as glue, you get something you can measure and replace piece by piece.
This is part 1 of a five-part build guide. Across the series we will assemble Kora Desk: a small, usable FAQ assistant for Nigerian small businesses (fictional product under the Kora Assist umbrella). By part 5 you should have a local app that answers from your own markdown docs, with citations, a bounded tool loop, and a FastAPI entrypoint. Today we only answer: what LangChain is, what it is not, and how to run the smallest useful chain.
What LangChain actually is
LangChain is a Python (and JS) toolkit for composing LLM applications. The useful mental model is a pipeline:
- Take structured inputs (a question, a user id, maybe retrieved docs).
- Build a prompt.
- Call a model.
- Parse the output into text or typed data.
- Optionally loop with tools or retrieval.
That composition style is often written with LCEL (LangChain Expression Language): objects connected with |, left to right, like Unix pipes.
| Piece | Job |
|---|---|
| Prompt template | Turns variables into messages the model sees |
| Chat model | Calls OpenAI, Ollama, Anthropic, etc. |
| Output parser | Turns model text into str, JSON, or a Pydantic model |
| Retriever | Finds relevant chunks from your docs (later parts) |
| Tool / agent | Lets the model call functions you allow (later parts) |
It sits next to the architecture in Node.js + Python Architecture for AI Applications: Node (or Nest) still owns auth, billing, and the public API. Python owns the chain. LangChain lives on the Python side.
What it is not
- Not a hosted model. You still need Ollama, OpenAI, or another provider.
- Not a substitute for evaluation. A chain that "feels smart" can still invent CAC rules.
- Not mandatory. For one prompt and one API call, the provider SDK is often clearer. Reach for LangChain when you have retrieval, tools, retries, or several steps you want to swap independently.
The series project: Kora Desk
End state (part 5): a local FAQ desk that:
- Reads markdown files you own (business registration, tax basics, bank account FAQs).
- Answers with short, cited replies.
- Refuses or escalates when the docs do not support an answer.
- Exposes
POST /askbehind FastAPI for a Nest or Expo client later.
Part 1 only builds the "brain stub": question in, short answer out, no docs yet.
A tiny chain you can run
Install (Python 3.11+):
pip install langchain-core langchain-ollama
# or: pip install langchain-openai if you prefer a hosted model
Pull a free local model if you use Ollama (good fit on a 32GB Mac):
ollama pull qwen2.5:7b
from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import ChatPromptTemplate
from langchain_ollama import ChatOllama
prompt = ChatPromptTemplate.from_messages(
[
(
"system",
"You are Kora Desk, a concise assistant for Nigerian small businesses. "
"If you are unsure, say you are unsure. Do not invent legal advice.",
),
("human", "{question}"),
]
)
model = ChatOllama(model="qwen2.5:7b", temperature=0)
chain = prompt | model | StrOutputParser()
answer = chain.invoke(
{
"question": (
"In one short paragraph: why do people register a business name "
"with CAC before opening a business bank account?"
)
}
)
print(answer)
What each part does:
ChatPromptTemplatefills{question}and builds chat messages.ChatOllamaruns the local model. Swap toChatOpenAIif you have an API key; the chain shape stays the same.StrOutputParserreturns plain text instead of a message object.prompt | model | parseris LCEL: invoke once, get a string.
That is enough to feel the library. It is not enough to ship. Without docs and checks, the model will guess.
Hosted model variant
If you are not running Ollama yet:
from langchain_openai import ChatOpenAI
model = ChatOpenAI(model="gpt-4.1-mini", temperature=0)
chain = prompt | model | StrOutputParser()
Keep temperature=0 for FAQ-style work until you have evals. Creativity is rarely what you want when the answer should track a document.
Failure modes to expect early
- Silent wrong answers. The chain returns confident prose with no source. Parts 3 and 5 add retrieval and scoring for that.
- Provider lock-in in your head. If every tutorial hardcodes one vendor, you will rewrite the app to switch. Keep the model behind the chain interface from day one.
- Prompt sprawl. Copy-pasted system strings across files. Put the system text in one template (or one module) so Kora Desk has one voice.
- Calling the chain from the mobile app. Do not. Put FastAPI (or Nest calling Python) in front, as in the Node/Python split post.
What we will build next
| Part | Focus | Usable slice |
|---|---|---|
| 1 (this) | What LangChain is + LCEL hello chain | CLI Q&A stub |
| 2 | Messages, few-shot, structured output | Typed JSON answers (answer, confidence) |
| 3 | RAG over a markdown folder | Cited replies from your docs |
| 4 | Tools + bounded agent | "Search docs" + "escalate" tools, no open-ended loops |
| 5 | FastAPI, timeouts, simple evals | POST /ask + a tiny regression set |
If you only want one takeaway today: LangChain is how you compose steps. The product quality still comes from your data, your constraints, and your tests.
Takeaways
- LangChain is orchestration glue (prompt → model → parse → optional retrieve/tools), not a model.
- LCEL (
a | b | c) makes that pipeline explicit and swappable. - Start with a tiny chain and a local model (Ollama) so cost and privacy stay under your control.
- Kora Desk is the through-line: by part 5, a cited FAQ desk behind FastAPI.
- Prefer the raw SDK until you need composition; then LangChain earns its keep.