LangChain Tutorial 120 lessons · 2:16:24+ of video
LangChain Home Getting Started
What Is LangChain How LLM Apps Work Setting Up Models and Messages
Your First Model Call Messages Conversations Settings, Streaming, Batches
Model Settings Streaming Batch Calls Tokens and Providers
Tokens and Usage Switching Providers Basics Quiz Prompt Templates
Prompt Templates Chat Prompt Templates MessagesPlaceholder Examples, Chains, Parsers
Few-Shot Prompts Chains with the Pipe Output Parsers Runnables
Runnables RunnableLambda RunnableParallel Passthrough, Routing, Fallbacks
RunnablePassthrough Routing Fallbacks and Retries Inside Chains and Practice
Seeing Inside a Chain Practice: Review Summariser Chains Quiz Structured Output
Why Structured Output Pydantic Models with_structured_output Shapes, Labels, Extraction
Lists and Nested Data Classification Extraction Structured Output in Practice
Batch Extraction When Output Goes Wrong Structured Output Quiz Tools
What Are Tools The tool Decorator Tool Schemas Tool Calls by Hand
Binding Tools Reading Tool Calls Running Tools Yourself Agents
The Agent Loop create_agent Several Tools Prompts, Streaming, Memory
Agent System Prompts Streaming Agent Steps Agent Memory Structured Answers and Middleware
Structured Agent Answers Middleware Built-in Middleware Context and Errors
Dynamic Prompts Tool Errors Runtime Context Agent Practice and Approval
Practice: Bookshop Agent Human Approval Agents Quiz RAG Foundations
What Is RAG Documents Loading Files Chunks and Embeddings
Splitting Text Chunk Size and Overlap Embeddings Similarity and Vector Stores
Similarity Vector Stores Search with Scores Retrievers
Retrievers Metadata Filters MMR Search Your First RAG Chain
Your First RAG Chain The RAG Prompt Saying I Don't Know Better RAG
Citing Sources Conversational RAG RAG as a Tool RAG in Practice
Saving a Vector Store Checking RAG Quality RAG Pitfalls FAQ Bot and Async
Practice: Bookshop FAQ Bot RAG Quiz Async Calls Cache, Limits and Timeouts
Caching Model Calls Rate Limiting Timeouts Cost, Logging and Tracing
Tracking Cost Callbacks for Logging Tracing with LangSmith Evaluation
Evaluating Answers Test Sets Comparing Prompts Safety
Prompt Injection Guardrails PII Redaction Reliability
Model Fallbacks Limiting Agent Calls Production Quiz Serving and the Project Plan
Serving with FastAPI Streaming over HTTP Project: Support Bot Plan Project: Building the Bot
Project: Knowledge Base Project: Tools Project: The Agent Project: Memory, Guardrails, Tests
Project: Memory Project: Guardrails Project: Testing Project Review and Good Habits
Project: Review Choosing Models Prompt Habits Images and Long Documents
Multimodal Input Long Documents Map-Reduce Summaries Rewriting and Extraction
Translation and Rewriting Data from Tables Applied Quiz The Bigger Picture
LangChain vs LangGraph The Ecosystem Cheat Sheet: Core Wrapping Up
Cheat Sheet: Agents and RAG Common Mistakes What to Learn Next LangChain · Lesson 29 of 120
Pydantic Models Describing data.
⏱ 2 min read ▶ Video at 31:06 🎓 Free
▶ starts at 31:06 To ask for structured data, we first describe it. The usual way in Python is a Pydantic model, a class that lists each field, and its type.
From the video: Pydantic Models Describe the data Pydantic models Fields and types Here's a book model. Title is a string, year is an integer, and genres is a list of strings. Field adds a description, which the language model will also see. Creating a book checks every field. Run it. The year, written as a string, is converted to a number. And a book with a missing title is rejected.
pydantic_model.py python Copy
from pydantic import BaseModel, Field, ValidationError
class Book ( BaseModel ):
title: str
year: int = Field( description = "year first published" )
genres: list[ str ]
b = Book( title = "Dune" , year = "1965" , genres = [ "sci-fi" ])
print (b.year + 1 , b)
try :
Book( year = 1950 , genres = [])
except ValidationError as e:
print ( "rejected:" , e.errors()[ 0 ][ "msg" ], e.errors()[ 0 ][ "loc" ]) Output
1966 title='Dune' year=1965 genres=['sci-fi']
rejected: Field required ('title',) A few habits help the model fill your fields well. Use clear names. Add a description to any field that could be unclear. Use specific types, like int, or a fixed set of choices. And make fields optional, when the information might not exist.
key value Clear names title, not t Descriptions for unclear fields Specific types int, list, choices Optional if it may be missing
Prefer to watch? The full LangChain course is free All lessons in one video with animations, real code and chapters.
Watch free Pydantic models describe data as a class of typed fields, and check every value. Next, asking the model to fill one in.
Key takeaways class Book(BaseModel) Typed fields Field(description=...)