Last Updated: May 1, 2025
Core Components
| Item | Description |
|---|---|
LLMs/Chat Models | Interface to any model — OpenAI, Anthropic, HuggingFace, local via Ollama |
Prompt Templates | Parameterized prompts with input variables — reuse and compose |
Chains | Sequence of calls — prompt → LLM → parser → output. LCEL: prompt | llm | parser |
Retrievers | Fetch relevant documents from vector stores — RAG backbone |
Agents | LLM decides which tool to use and when — ReAct, OpenAI functions, structured chat |
Memory | Persist conversation state — buffer, summary, vector-store backed |
LCEL (Expression Language)
chain = prompt | llm | StrOutputParser()Basic chain: template → generate → parse string
chain = prompt | llm | JsonOutputParser()JSON output chain — LLM returns structured data
chain = {'context': retriever, 'question': RunnablePassthrough()} | prompt | llmRAG chain — retrieves + passes context
chain.with_config(run_name='MyChain')Name for tracing in LangSmith
chain.stream(input)Stream response token-by-token
chain.batch([input1, input2])Process multiple inputs in parallel
Retrieval (RAG) Patterns
| Item | Description |
|---|---|
Document Loaders | Load from 100+ sources: PDF, web, database, Notion, GitHub |
Text Splitters | RecursiveCharacterTextSplitter — chunk by paragraph/sentence with overlap |
Embeddings | OpenAI, Cohere, HuggingFace — convert text to vectors |
Vector Stores | Chroma (local), Pinecone (cloud), Weaviate, Qdrant, FAISS |
RetrievalQA | Question-answering over documents with source attribution |
ConversationalRetrieval | RAG with chat history — rephrase question using history then retrieve |
Ecosystem
| Item | Description |
|---|---|
LangSmith | Observability platform — traces, evals, datasets, prompt hub |
LangServe | Deploy chains as REST APIs — FastAPI + chain = production endpoint |
LangGraph | Stateful multi-actor applications — graph-based agent workflows |
LangChain Hub | Community prompt templates — import, fork, customize |
Pro Tip: Use LCEL (LangChain Expression Language) for all new chains — it's more composable, supports streaming, and is easier to debug than the legacy Chain classes.