LangChain Tutorial: From Prompts to RAG and AI Agents
Real Python · Nov 23, 2026
LangChain is a framework for Python and JavaScript that lets you build applications powered by large language models (LLMs). Sending a single prompt to a model takes only a couple of lines of code. However, real apps also need reusable instructions, access to your own data, and a way for the model to call your Python code. In this tutorial, you’ll explore how LangChain’s Python library handles each of these.
Say a group of hospitals just handed you a spreadsheet full of patient reviews, together with a short request: Find out what patients are saying about us. You could read through every row yourself, but by the time you’re done, the next batch of reviews will probably have arrived. Instead, you’ll teach an LLM to do the reading for you.
Along the way, you’ll cover chat models, prompt templates, chains, retrieval, and agents. Step by step, you’ll build up to a RAG app that answers questions about what patients said and an agent that picks the right tool to look up exact facts.
Keep reading
Out of respect for the author only the opening is shown here. Read the rest on the original site, or in HorizonReader with highlights, notes and AI help.
AI summaryThe article introduces Altair, a declarative Python visualization library where users describe what their data means—such as which columns map to axes, colors, and interactivity—and the library generates the chart, unlike Matplotlib's approach of scripting every visual detail. Altair produces web-native charts (HTML and JavaScript) that render in notebooks and can be saved as standalone files or embedded in web pages, making it ideal for interactive exploratory analysis. It's not a replacement for Matplotlib, which remains the better choice for pixel-precise publication figures or 3D plots, so the two libraries serve complementary use cases.
AI summaryReal Python's informal AI benchmark asked the Step 5 model to write a turtle program drawing a python reading a book, but the 253-line script failed with an AttributeError and produced zero drawing commands. Across the five tasks, the model scored at Python 3.10 for modernity, passed 7 of 12 modern idiom checkpoints, correctly caught the nonexistent itertools.flatten() function, and made 1 of 10 possible unrelated edits. The full run cost $0.15, used about 49.4k thinking tokens, and took roughly 6 minutes 44 seconds.
In this quiz, you’ll test your understanding of the video course Using Python for Data Analysis. By working through this quiz, you’ll revisit the stages of a data analysis workflow, how to fix missing values, wrong data types, out-of-range
Say you’ve inherited a project with no tests or so few that you can’t refactor it safely. Generating Python tests with AI seems like the quick way out, but a one-line prompt often gives you a suite that passes without catching real bugs. Th
In this quiz, you’ll test your understanding of Generating Python Tests With AI: A Suite You Can Trust. By working through this quiz, you’ll revisit how standing testing conventions guide an AI coding agent, why you review behavior tables b