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 38 of 120
The tool Decorator Functions become tools.
⏱ 2 min read ▶ Video at 41:33 🎓 Free
▶ starts at 41:33 The easiest way to make a tool is the tool decorator. Put it above a normal Python function, with type hints and a docstring, and it becomes a tool.
From the video: The tool Decorator @tool Type hints A docstring Here's a stock checker. The function takes a book title, and returns the number of copies in stock, from a small dictionary standing in for a database. The tool decorator turns it into a tool. Run it. It has a name, a description taken from the docstring, and argument types taken from the type hints. And we can still invoke it ourselves.
first_tool.py python Copy
from langchain.tools import tool
STOCK = { "Dune" : 3 , "Circe" : 0 , "The Hobbit" : 7 }
@tool
def check_stock (title: str ) -> int :
"""Return how many copies of a book Riverside Books has in stock."""
return STOCK .get(title, 0 )
print ( "name:" , check_stock.name)
print ( "description:" , check_stock.description)
print ( "args:" , check_stock.args)
print ( "Dune ->" , check_stock.invoke({ "title" : "Dune" })) Output
name: check_stock
description: Return how many copies of a book Riverside Books has in stock.
args: {'title': {'title': 'Title', 'type': 'string'}}
Dune -> 3 Good tools have a clear name, like check stock. A docstring that says what the tool does, and when to use it. Simple argument types, like strings and numbers. And a short, clear return value. Think of the docstring as instructions for the model.
key value Name verb + noun Docstring what and when Args simple types Return short and clear
Prefer to watch? The full LangChain course is free All lessons in one video with animations, real code and chapters.
Watch free The tool decorator turns a typed, documented function into a tool, with a name, description, and arguments. Next, what the model actually sees.
Key takeaways @tool Docstring = description Type hints = args