Welcome to Day 8 of #10DaysOfLangChain โ our daily scoop of LangChain learning, garnished with a hearty Indian storytelling flavor ๐.
Today, weโre going on a nostalgic trip โ to a simple Indian household, filled with chai, chatter, and cutting-edge AI disguised as age-old wisdom.
Weโll explore two powerful concepts:
- RAG: Retrieval-Augmented Generation
- Prompt Templates: A way to structure your AI conversations smartly
Letโs begin with someone who taught us more about "contextual responses" than any machine ever could โ our Dadi (Grandma).
๐ง Dadi and the Never-Wrong Answers
Dadi never claimed to know everything. But somehow, she always gave the perfect answer โ whether you asked how to cure a sore throat, how to impress a college professor, or even why your crush left your message on โseenโ.
Her secret?
She didnโt just speak randomly. She always referred to something โ a home remedy from her diary, a lesson from a bhajan, or wisdom from an old incident. Then she connected that information to your situation and gave you advice that made sense.
This is exactly what RAG brings to Artificial Intelligence.
๐ What is RAG โ Retrieval-Augmented Generation?
Letโs say you ask a basic language model:
โTell me about Indiaโs digital economy.โ
Now, if the AI was trained months ago, it might give you general, outdated facts. Not very useful, right?
But with RAG, the AI first retrieves the most up-to-date and relevant documents โ maybe a news article, a government report, or a research paper. Then it generates a response based on that content.
Think of it like this:
โPehle jaake jaanch karo, fir bolna.โ (First verify, then speak.)
Thatโs exactly what RAG enables:
- Retrieval: It finds accurate, recent, and context-specific information from trusted sources like PDFs, websites, or your private database.
- Augmented Generation: It uses that content to generate a thoughtful, articulate answer โ not a guess, but a grounded explanation.
In Indian homes, this is what elders do โ they donโt shoot in the dark. They dig up the right info, cross-check facts, and then speak. Whether itโs about stock markets or how much ajwain to use for a stomach ache.
With RAG, your AI becomes similarly trustworthy.
๐ Prompt Templates โ The Art of Structured Questions
Now letโs talk about something equally important: how we ask questions.
Back in school, when we wanted a bathroom break, we didnโt shout โToilet!โ We carefully said:
โMaโam, may I go to the washroom?โ
The way we frame a question often decides how well the other person understands it. The same logic applies to AI.
Prompt Templates help us talk to AI in a clear, consistent, and structured way.
Imagine writing emails every day. You donโt want to write the full format from scratch each time. So, you create a template:
- โDear {Name},โ
- โAs per our last discussionโฆโ
- โRegards, {Your Name}โ
Prompt Templates work the same way. You define a structure for your prompts, and just fill in the blanks when needed.
Why is this useful?
- It ensures the AI always understands the context.
- It maintains a professional or polite tone.
- It saves time and reduces confusion.
In short, Prompt Templates help your AI behave more like your well-trained office assistant โ polite, sharp, and on point.
โ Two Types of Prompt Templates โ Desi Home Edition
Letโs go a bit deeper into the types of Prompt Templates youโll use in LangChain.
1. String Prompt Templates โ The Masala Chai Analogy
Everyone in India loves chai. But the base remains the same:
- Water
- Milk
- Tea leaves
- Sugar
What changes? The masala. Some add ginger, others prefer elaichi. But the format is fixed.
String Prompt Templates work the same way. You write a base prompt like:
โTell me about the importance of {topic} in {field}.โ
And then you just plug in values like:
- Topic = Yoga
- Field = Modern healthcare
Useful when you want quick, simple responses with specific variables.
2. Chat Prompt Templates โ Like Our Family WhatsApp Group
In Indian families, the WhatsApp group is pure chaos and pure gold:
- Mummy sends a voice note.
- Papa replies with a thumbs up.
- Cousin drops a cricket meme.
- You respond with a joke.
In this back-and-forth, context matters.
Chat Prompt Templates help structure such multi-turn conversations in LangChain. You can define:
- A system message (e.g., "You are a helpful assistant.")
- A user message (e.g., "How do I file my taxes?")
- An AI reply (e.g., "To file taxes in India, follow these steps...")
Perfect for building chatbots or support agents that need to remember the tone, context, and role.
๐๏ธ Bonus: MessagesPlaceholder โ Keeping the Full Conversation Alive
Ever had a friend say:
โBut you said last week you loved pineapple on pizza!โ
And youโre like, โWait, how do you remember that?!โ
Thatโs context retention.
LangChain gives us a magical tool called MessagesPlaceholder โ it lets your AI remember the entire thread of conversation. This way, your assistant can respond based on what the user said five minutes ago โ or five queries ago.
It brings continuity, natural flow, and memory to your chatbot.
In desi terms, it's like how your mom remembers what you promised last Diwali. You canโt escape it.
๐ When RAG Meets Prompt Templates โ Power Combo, Desi Style
Letโs combine what weโve learned.
- RAG is about getting the facts right. Think of your cousin searching Google mid-conversation to quote something accurately.
- Prompt Templates are about organizing the conversation. Like your mom telling a story step-by-step, with proper beginning, middle, and end.
When you use both together:
โ
You get rich, fact-based answers
โ
Your responses are structured and easy to follow
โ
The whole conversation feels natural and intelligent
Itโs like hosting a well-planned family dinner:
- The food (facts) is fresh
- The order (conversation) is smooth
- The guests (users) leave impressed
๐บ Desi Takeaway
In our Indian culture, weโve always respected two things:
- Gyaan (Knowledge) โ The facts must be correct.
- Vaani (Speech) โ The way you deliver it matters.
LangChain's RAG and Prompt Templates capture this beautifully:
- Donโt speak without substance.
- And when you do speak, say it properly.
Whether you're building a chatbot, a research tool, or a smart Q&A assistant, this combo is your foundation. It's like learning from your elders โ grounded, respectful, and deeply insightful.
๐ Credits
This blog is inspired by the official LangChain Documentation โ an incredible resource for learning how to build context-aware, agent-based applications powered by large language models (LLMs).
โ๏ธ About Me
Hi, Iโm Utkarsh Rastogi โ an AWS Community Builder and Cloud Specialist helping teams build scalable, secure, and innovative solutions in the cloud.
๐ Connect with me on LinkedIn
๐ Follow my blog on Hashnode
๐ Read more on Dev.to
โ ๏ธ Disclaimer
This blog is intended for educational and learning purposes only.
Any characters, analogies, or cultural references are meant to make technical concepts easier to understand โ they are not linked to real people or events.
Letโs learn with fun, facts, and desi flair ๐ฎ๐ณโจ
๐ Shukriya for reading todayโs edition of LangChain with an Indian soul.
May your prompts be structured, your responses relevant, and your AI full of grace and gyaan.
Top comments (2)
Loved the desi analogies! Really curious to knowโwhatโs your next step after RAG and Prompt Templates? Will you be diving into advanced features or showing a real-world project next? Looking forward to the updates!
I have Posted all 10 days blog for langchain series please check and for project part please wait for few weeks