DEV Community

Cover image for ๐ŸŒŸ Day 8: RAG & Prompt Templates โ€” Wisdom Meets AI the Indian Way
Utkarsh Rastogi for AWS Community Builders

Posted on • Edited on

๐ŸŒŸ Day 8: RAG & Prompt Templates โ€” Wisdom Meets AI the Indian Way

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:

  1. Gyaan (Knowledge) โ€“ The facts must be correct.
  2. 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)

Collapse
 
hammglad profile image
Hamm Gladius

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!

Collapse
 
awslearnerdaily profile image
Utkarsh Rastogi AWS Community Builders

I have Posted all 10 days blog for langchain series please check and for project part please wait for few weeks