LangChain is the most popular open-source framework for building Large Language Model applications.
Launched in 2022 and with more than 90,000 stars on GitHub, it simplifies integrating LLMs with
external tools, databases, APIs, and complex workflows.
Instead of writing low-level code for every call to an LLM, LangChain provides
reusable abstractions: chains for sequences, agents for
dynamic decisions, memory for context, and retrievers for RAG.
The modern way to use LangChain is LCEL, a declarative style using the
| operator to compose components like Unix pipes:
chain = prompt | llm | output_parser
LCEL's advantages: native streaming, automatic batching, async/await, logging integrated with
LangSmith, and clean composition of complex components.
Without memory, every call to the LLM is independent. LangChain offers:
The RAG (Retrieval-Augmented Generation) pattern is the most widely used one in enterprises for connecting
LLMs to their own data. The pipeline:
# LangChain LCEL - Modern chain with RAG
from langchain_anthropic import ChatAnthropic
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.output_parsers import StrOutputParser
from langchain_community.vectorstores import PGVector
from langchain_core.runnables import RunnablePassthrough
llm = ChatAnthropic(model="claude-sonnet-4-6")
# Simple chain with LCEL (pipe operator)
prompt = ChatPromptTemplate.from_messages([
("system", "You are an expert assistant in {domain}."),
("human", "{question}")
])
chain = prompt | llm | StrOutputParser()
response = chain.invoke({"domain": "corporate law", "question": "What is a non-disclosure agreement?"})
# Full RAG chain
rag_chain = (
{"context": retriever, "question": RunnablePassthrough()}
| prompt
| llm
| StrOutputParser()
)
answer = rag_chain.invoke("What does the contract say about penalties?")Carlos Montiel is an enterprise AI solutions architect with experience in LLMs, Agents, RAG, and orchestration across Guatemala and Latin America.
Contact Carlos Montiel