Every time you type the same kind of request to an AI, you’re doing a template by hand. In episode 03 of his LangChain agent course, Ariel shows how to stop doing that: write the prompt once, leave holes in it, and let your code fill the holes from whatever the user typed. Then he goes one step further and teaches the AI by example, and finally peeks under the hood to see what LangChain really sends to the model.
Quick recap: the messages array is the meat
Before the new material, Ariel rewinds to the previous lesson. The heart of everything is one array of messages: a system message at the top, then human message, AI message, human, AI, and so on. Temperature, streaming, which model, which provider: nice to know, but those are settings around the edges. The core loop is simple: send the array to the model, get a response, print it, and append it to the array as a new AI message. That append is the whole trick behind “the agent remembers what we talked about.” It’s just keeping the conversation history inside the context window.
Templates: like slash commands, but for your own app
Lesson three is about prompts, messages and output structure, and it opens with templates. Ariel’s analogy for Claude users: when you notice you keep writing the same message over and over, you make a slash command or a skill. When you build your own harness (your own Claude Code, so to speak) and spot something repeating, that’s a template.
The course’s example is a translator. Think Google Translate: a text box, a “from” language dropdown and a “to” language dropdown. Those are three fixed inputs, and the translated text is the output. Since the inputs are always the same three things, the prompt to the AI is always the same sentence too: “translate this text from this language to that language.” So you write it once, put each changing part in curly braces, and the template knows it has to be filled before it’s sent. You can define the system message, the human message, and as many messages and parameters as you want this way.
Setup is the usual: step into the virtual environment, and refresh the OpenRouter key. Ariel creates his keys with a one-day expiration, so the key shown on screen is already dead by the time you watch. His reminder: an API key is top secret. His budget advice: “$10 is plenty.”
A better example: what’s in your kitchen?
Ariel didn’t love the translator demo (“it doesn’t explain the point”), so he copies the file and builds his own. Imagine a recipe site for whatever you have at home. The system message: you are a creative cook who suggests simple recipes. The UI has three text boxes: what’s in your fridge, what’s in your cabinet, and what spices you have. The user hits send, the JavaScript in the browser sends the three values to the backend, and the code drops them into the template as real parameters. Eggs in the fridge, peas in the cabinet, pepper in the spices.
The AI comes back with scrambled eggs with peas. And it tells him to use butter or oil, which he never said he had. Lesson on the side: if you don’t want ingredients you don’t have, say so explicitly in the system prompt. But the main lesson is the one Ariel keeps hammering: the code gathers the parts of the full prompt from some UI, the template is the full prompt, and you fill it and send it. He bets Claude Code does the same thing: some full prompt along the lines of “you’re a coding agent, here’s what the user asked, understand it, break it into tasks, start working,” built from a template like this.
Teaching the AI by example
The next example builds a conversation on purpose: a system message plus a few fake question-and-answer pairs, then the real question. The course does it with an emoji translator (when I’m happy answer like this, when I’m sad answer like that). Ariel almost makes it a Yemenite chef (“Yemenites love spicy, right? Forget it, not interesting, deleted”) and settles on an expert in hot and spicy food. The example answers are spicy dishes like shakshuka and a hot fish dish, and then the real question asks for pizza. The model gets the pattern and returns a fiery inferno pizza with chili seeds.
A student asks the obvious question: how do I teach the AI to answer more accurately? Ariel’s answer: that’s not necessarily training a new model. Give it good enough data of correct questions and answers. After two or three of those, it understands what a good answer looks like. You can even write why each answer is correct, put it in a skill, and call it when you need it. If you want it baked into the model’s general knowledge, that’s post-training: take a good open-source model, give it a dataset of at least a thousand to three thousand questions with answers and explanations, and pay for the compute. For her case, the practical route is to collect real questions and answers from the field and tell the model: read these first, understand the reasoning behind them, and only then answer. Like a kid doing homework before the final exam.
Two ways to write a template
Then the course combines both ideas: a template plus a dynamically built messages array. The translator returns, this time defining input and output language once, and then feeding text after text. One run goes English to French, another English to Spanish, same template. Ariel also shows there are two ways to write it: ChatPromptTemplate.from_messages, where you list the messages, which suits templates with many turns stacked on each other, and from_template, where you just write the template as plain text and LangChain sorts it out. Same result, two styles.
Few-shot templates, and what really gets sent
The fifth example uses FewShotChatMessagePromptTemplate. Instead of building the whole array of example turns yourself, you hand it a list of input/output examples and a template, and it assembles the blocks for you. Ariel got curious: does it really turn this into a messages array, or something cleverer? So he called in “the big guns” and asked Claude to add logging that shows the full story of what goes out. His motto for the moment: what doesn’t work by force works by brains, and what doesn’t work by brains works with more force.
The log answers it. Every message ends up as a pair of role and content: the system message becomes role system, a human message becomes user, and an AI message becomes assistant. No matter which LangChain objects you use, the actual provider request is always content and role, content and role.
Ariel then plays with the example keys to show the mapping. The examples don’t have to be called “input” and “output”. In the course they’re named code and comment, and the template decides which key becomes the human message and which the AI message. You can even add fixed words in the template, like a label in front of every user message. The iron rule of AI in general: help the model understand what you want through examples. Those examples can come from a ready file, or be pulled dynamically from a database, and the few-shot template replaces the function you’d otherwise write to build the array.
Templates on top of templates
Last topic: you can chain templates. Start with a base template of instructions (say, always be positive and professional), then extend it once into an educator template and once into a support template. Each one inherits the base and adds its own parts, and at the end you still fill in the role, the style and the question. Next lesson: templates with Pydantic, where the code itself declares that a variable must be a string or a number.
🔥 Roast Corner
Ariel teaches templates like a man who has never once used one on himself. “When you repeat the same message, make it a template.” Then he renews the OpenRouter key, again, by hand, live on camera, because the last one expired after a day. He set a self-destruct timer on his own key and then acted surprised that it self-destructed. That’s not a secret, Ariel, that’s a recurring cron job with extra steps and a credit card.
And the Yemenite chef deserves a moment of silence. Born, justified (“Yemenites love spicy”), judged “not interesting,” and deleted, all in the same sentence. Shortest career in AI history. Meanwhile the fake cook he did keep invented butter out of thin air, because he forgot the line “don’t use what isn’t in the fridge.” The whole lesson is “give the AI your exact inputs,” and the AI’s first act was to raid a fridge that doesn’t exist.
But the crown goes to his debugging method: “what doesn’t work by brains works with more force.” To find out what LangChain sends to the AI, he asked a second AI to explain the first one. Templates all the way down. Full disclosure: this roast also came from a template. Mine just has a slot labeled {ariel_mistake}, and it has never once been empty.
🤖 AI for Humans
Here’s what a well-built template looks like when it actually changes lives. In the UK, the charity Mencap and Google DeepMind just launched the Easy Read Co-Creator Tool, which uses AI to turn dense documents into Easy Read: short, simple sentences, an accessible layout, and helpful images, made for people with learning disabilities. Producing Easy Read by hand can take weeks and cost around £100 to £200 per page, so most letters, bills and appointment notices simply never get one. The tool cuts that from weeks to minutes.
The idea came from a family car ride. Sarah Cowen-Rivers works at Mencap, her brother Ali is a research engineer at DeepMind, and Ali’s twin Danny has a learning disability and usually asks family to read wordy energy bills and government letters for him. In Mencap’s survey, almost half of people with a learning disability said they had missed important information, and one in three had missed information about a doctor’s appointment. An NHS trust is already testing the tool, and a $1m Google.org grant is inviting another 50 organizations to get trained on it. Same idea as this lesson: one fixed set of instructions, any document in, a clear answer out.

💬 Comments