Skip to content
Tutorials Center
My learning

Topics

LangChain Tutorial

Learn LangChain step by step: 32 lessons in 9 chapters with examples, quizzes, diagrams and projects.

Start learning →

of lessons completed

Getting Started

  1. 1 What Is LangChain? Learn what LangChain is, which problems it solves for LLM applications, how its packages fit together, and what this course runs live versus shows read-only.
  2. 2 Installing LangChain and Setting Up Keys Install LangChain in a virtual environment, add a provider package, keep API keys in environment variables and run your first model call safely, step by step.
  3. 3 Messages and Your First Chat Understand LangChain chat messages (system, human, AI, tool), build a conversation as a list, read content and metadata from replies, and practice with a stand-in.
  4. 4 The Runnable Interface: invoke, stream, batch Learn the Runnable interface that every LangChain component shares: invoke, batch, stream and their async versions, plus config, with a runnable stand-in class.

Models, Prompts and Parsers

  1. 5 Chat Models in Depth Work with LangChain chat models in depth: init_chat_model, temperature and other parameters, streaming, token usage, timeouts, retries and switching providers safely.
  2. 6 Prompt Templates Build reusable prompts with LangChain PromptTemplate and ChatPromptTemplate: variables, system and human messages, partial variables, validation and a runnable template engine stand-in.
  3. 7 Few-Shot Prompts and Message Placeholders Teach a model by example with few-shot prompts, select the most relevant examples dynamically, and use MessagesPlaceholder to inject chat history into LangChain prompts.
  4. 8 Output Parsers Turn model replies into usable data with LangChain output parsers: StrOutputParser, JsonOutputParser, PydanticOutputParser and list parsers, with format instructions and error handling.
  5. 9 Structured Output Get reliable typed data from a model with with_structured_output: Pydantic schemas, TypedDict and JSON Schema, extraction patterns, enums, nested data and validation failures.

Chains and LCEL

  1. 10 LCEL and the Pipe Operator Learn the LangChain Expression Language: compose prompts, models and parsers with the | pipe operator, see how RunnableSequence works, and build your own pipe in Python.
  2. 11 RunnableParallel and RunnablePassthrough Run steps side by side with RunnableParallel, carry input forward with RunnablePassthrough and assign, reshape dictionaries and shape chain inputs with runnable stand-ins.
  3. 12 Branching, Routing and RunnableLambda Route a request to different chains with RunnableLambda and RunnableBranch, classify the input first, and build a runnable stand-in router with fallbacks.
  4. 13 Retries, Fallbacks and Config Make chains reliable with with_retry and with_fallbacks, adjust behavior per call with configurable fields and bind, and observe runs with callbacks and tags, plus stand-ins.

Retrieval and Vector Stores

  1. 14 Retrieval-Augmented Generation: The Big Picture Understand retrieval-augmented generation (RAG): why models need your data, the two phases of indexing and answering, the LangChain components involved and typical failure points.
  2. 15 Document Loaders and Text Splitters Load text, PDFs and web pages into LangChain Document objects with metadata, then split them into well-sized overlapping chunks with RecursiveCharacterTextSplitter, plus a runnable splitter.

Agents and Tools

  1. 16 What Is an Agent? Learn what a LangChain agent is: a model that chooses tools in a loop until it can answer. Compare chains and agents, and run a stand-in agent loop in Python.
  2. 17 Defining Tools Define LangChain tools with the @tool decorator, type hints and docstrings. See how a schema is built for the model and run a stand-in tool registry in Python.
  3. 18 The Tool-Calling Loop Understand tool calling in LangChain: bind_tools, AIMessage.tool_calls, ToolMessage and tool_call_id, parallel calls. Run a stand-in message loop in Python.
  4. 19 ReAct Agents and create_agent Learn the ReAct pattern (reason, act, observe) and how LangChain's create_agent implements it with tools, prompts, streaming and structured output. Includes Python stand-ins.
  5. 20 Agent Errors and Guardrails Make LangChain agents safe and reliable: step and call limits, tool error handling, retries, input validation and prompt injection defenses, with runnable Python stand-ins.

Memory and State

  1. 21 Conversation Memory Basics Language models are stateless. Learn how LangChain adds conversation memory with message history, thread ids and checkpointers, with a runnable Python stand-in.
  2. 22 Trimming and Summarizing History Keep long conversations inside the context window: window and token trimming, trim_messages, rolling summaries and deleting messages. Runnable Python stand-ins included.
  3. 23 Persistent Checkpoints and Long-Term Memory Persist agent state with SQLite or Postgres checkpointers, replay and fork threads, and add long-term memory with a store. Stand-ins run in Python with sqlite3.

LangGraph Workflows

  1. 24 LangGraph: State, Nodes and Edges Learn the LangGraph model: a typed state, nodes that return updates, edges that route, and reducers that merge. Run a mini StateGraph stand-in in Python.
  2. 25 Conditional Edges and Loops Route a LangGraph with add_conditional_edges, build loops with a back edge, set recursion limits and rebuild a ReAct agent by hand. Runnable Python stand-ins included.
  3. 26 Human in the Loop Pause a LangGraph run for human approval with interrupt(), resume with Command, and approve, edit or reject tool calls. Runnable Python stand-ins with generators.
  4. 27 Multi-Agent Systems and Supervisors Split work across specialist agents: the supervisor pattern, agents as tools, handoffs and subgraphs in LangGraph. Includes a runnable supervisor stand-in in Python.

Evaluation and Deployment

  1. 28 Evaluating LLM Applications Test LLM apps like software: build a dataset, write evaluators, use LLM-as-judge, check agent trajectories and catch regressions. Runnable Python eval harness included.
  2. 29 Tracing and Observability See inside LLM apps: traces, runs, spans, metadata, tags, latency and token usage. Enable LangSmith tracing, add callbacks and build a tiny tracer in Python.
  3. 30 Serving with FastAPI and Streaming Serve a LangChain agent as an API with FastAPI: async endpoints, token streaming with server-sent events, thread ids, auth and rate limits. Runnable asyncio stand-ins.
  4. 31 Caching, Cost and Latency Cut LLM cost and latency: response caching, prompt caching, smaller prompts, model routing, batching and parallel calls. Runnable Python stand-ins with a cost calculator.

Projects and Practice

  1. 32 Project: A Research Assistant Agent Build a research assistant agent step by step: tools for searching notes, calculating and saving findings, a planning loop, guardrails and tests. Real LangChain code plus runnable stand-in.