Latest / AI Fire Daily / #80 Max: From Zero to RAG Agent – A Complete Beginner's No-Code Course
Transcript
- 0:00Imagine an AI chatbot, you know, brilliant at
- 0:03general conversation. But then you ask it about
- 0:05your company's specific policies or maybe the
- 0:07nuances of your industry. And he either guesses
- 0:10or maybe worse, just kind of makes things up.
- 0:12What if you could give that AI a custom brain,
- 0:16one filled with your verified knowledge? Welcome
- 0:20to the deep dive. Today, we're diving deep into
- 0:23exactly that idea. Retrieval Augmented Generation,
- 0:26or RA for short. And honestly, it's simpler than
- 0:28it sounds, but it fundamentally changes how we
- 0:30can trust and actually use AI. We're going to
- 0:33discover what RA is, how these powerful Mind
- 0:36Palace databases make it possible. We'll break
- 0:38down the two crucial parts of any RA system.
- 0:41Then yeah, we'll walk you through building one,
- 0:42step by step, no code needed. You'll even learn
- 0:45how to give your AI a memory, make it remember
- 0:46stuff, and power its new brain efficiently. It's
- 0:49really about turning a smart... chatbot into
- 0:51a true expert on your stuff. Okay, let's unpack
- 0:54this. So let's start right at the heart of it.
- 0:56What is ARAG? Retrieval Augmented Generation.
- 1:00In plain English, it just means your AI does
- 1:03its own research before it speaks. Think of it
- 1:05like an open book test. When you ask a question,
- 1:07maybe how many feet are in a mile? ARAG system
- 1:11doesn't just pull from its huge general training
- 1:13data. No, it first retrieves specific accurate
- 1:16info like 5 ,280 feet from a source you've given
- 1:20it. Only then does it use that verified fact
- 1:22to augment or, well, significantly improve its
- 1:26answer. This is what transforms a generic AI
- 1:28into one that genuinely knows your company docs,
- 1:31your support tickets, maybe your internal policies.
- 1:34Yeah, it changes the AI from just a generalist
- 1:36into a trusted specialist. OK, so the core idea
- 1:39is that the AI isn't just generating from like
- 1:41its initial programming. It's actively seeking
- 1:44out and pulling in external facts first. Exactly.
- 1:46It finds the facts, then generates with confidence.
- 1:49But where does this AI store all the specific
- 1:52knowledge so it can find it so fast? That's where
- 1:55the vector database comes in. It's truly the
- 1:57brain of a rag agent. Imagine this vast... multi
- 2:01-dimensional space kind of like a galaxy right
- 2:03where every star is a piece of information from
- 2:05your documents each chunk of text becomes a single
- 2:08point of light in this galaxy that's what we
- 2:10call a vector and the really profound insight
- 2:12here is semantic similarity this database doesn't
- 2:16organize things alphabetically not at all it
- 2:18places data points based on their meaning so
- 2:20all the points about say fruits cluster together
- 2:23over here and animals form a totally different
- 2:26constellation over there when you ask what is
- 2:28a kitten your question itself gets turned into
- 2:31a new point of light. And it appears naturally
- 2:33right within that animal constellation. The database
- 2:36then super quickly finds the closest points,
- 2:39maybe cat, puppy, even wolf, and pulls the text
- 2:41link to them. That gives you a perfect, hyper
- 2:44-relevant answer. It's all about asking, what
- 2:45does this mean? And getting an intelligent, context
- 2:48-aware match. For a deep dive today, we'll be
- 2:50using Supabase as our vector database example,
- 2:53which is built right on top of Postgresful. So
- 2:56this database, it really understands concepts.
- 2:59then, not just keywords. Yes, precisely. It's
- 3:02all about meaning and context. Okay. And it's
- 3:04this clever organization that lets the two crucial
- 3:07halves of a RIAG system work so well together.
- 3:10If we kind of connect this to the bigger picture,
- 3:13building a RIAG system, it's like... assembling
- 3:16this, I don't know, magical, intelligent library,
- 3:19it's really a two -phase project, requires two
- 3:21distinct but totally complementary halves of
- 3:23a single brain, you could say. First, you've
- 3:25got what we call the AI librarian. That's your
- 3:27RA pipeline. This is the behind -the -scenes
- 3:29worker. Its job is to meticulously read every
- 3:32single document you give it, understand the content,
- 3:34and then place each piece of information on the
- 3:36correct shelf within your, well, infinitely large
- 3:39perfectly organized vector database. This isn't
- 3:42an ongoing job, mind you. It's a one -time process
- 3:44you run to initially stock the library. Right.
- 3:47And then you have the AI scholar. That's your
- 3:50R agent. This is the public -facing expert. The
- 3:52scholar kind of sits at the front desk, ready
- 3:54to help visitors. When you ask a difficult question,
- 3:57the scholar instantly zips through the library,
- 4:00pulls the exact pages from the correct books,
- 4:02synthesizes the information, and gives you this
- 4:05brilliant custom -written answer. But these two
- 4:08parts, they're completely interdependent. A scholar
- 4:10without a library is, well, just a generic chatbot.
- 4:13No specialized knowledge. And a library without
- 4:16a scholar, that's just a silent... inaccessible
- 4:18database. So one half is organizing all the knowledge
- 4:21and the other half leverages that organization
- 4:23to actually provide the answers. Precisely. A
- 4:26powerful two -phase system, yeah. So let's dig
- 4:28into the librarian's job then, that RAG pipeline.
- 4:31It's really all about transforming raw documents
- 4:33into a searchable, structured knowledge base.
- 4:35And this process has four key steps. First up,
- 4:38document input. This is simple. It's just acquiring
- 4:40the book. It's your source document. It would
- 4:42be a PDF, a text file, or even data you pull
- 4:45from other apps, maybe like a CRM. or something.
- 4:48Then we chunk the document. Think about it. You
- 4:50wouldn't file an entire 500 -page book under
- 4:52just one topic, right? You'd separate it into
- 4:55chapters or sections. Similarly, we split large
- 4:57documents into smaller, more focused pieces of
- 5:01text. This is super critical because it creates
- 5:03these context -rich pages for more accurate searching
- 5:05later on. A pro tip here, aim for chunks of maybe
- 5:09about 1 ,000 characters and use a 200 -character
- 5:11overlap between chunks. That just helps ensure
- 5:13concepts aren't awkwardly cut off right in the
- 5:15middle. Okay, and here's where it gets, well...
- 5:17really interesting. After chunking, you embed.
- 5:21This is I think the most magical part. An embeddings
- 5:23model. It's a sophisticated AI, acts like a universal
- 5:27translator. It converts those text chunks into
- 5:30vectors, which are basically just long strings
- 5:32of numbers. Think of it like giving each chunk
- 5:35a precise coordinate in that huge galaxy of meaning
- 5:38we talked about, that 1536 number you sometimes
- 5:40see. That just refers to the number of dimensions
- 5:43or kind of like traits an AI uses to describe
- 5:45each piece of information. It's like a super
- 5:47detailed profile for every single text chunk.
- 5:50And for your AI to understand your data consistently,
- 5:53this profile format, it has to match across all
- 5:56parts of your system. Finally, you vectorize
- 5:59those chunks. This just means storing these numerical
- 6:01vectors in your Supabase vector database. They
- 6:04get intelligently placed by meaning, right? So
- 6:07all the golf rules about putting are grouped
- 6:08together, far away from rules about driving.
- 6:11In a tool like N8AN, this whole process is actually
- 6:14simplified into like a five -node assembly line.
- 6:16You've got a trigger to start it, maybe a Google
- 6:18Drive node to get the document, a data loader
- 6:20for the chunking part, an embeddings model, like
- 6:23OpenAI's text embedding 3 small to do the translating,
- 6:26and the Supabase vector store node to file it
- 6:29all the way neatly. You just run this workflow
- 6:31once for each document you want to add. Gotcha.
- 6:34So it's about breaking down the info, translating
- 6:36it into this conceptual number language, and
- 6:39then filing it away smartly. Precisely. Creating
- 6:41that structured, searchable knowledge base. Yeah.
- 6:43Okay, to make this all super concrete, let's
- 6:46talk about our mission for today. We're building
- 6:48an AI golf caddy using a 22 -page PDF. It's called
- 6:52The Rules of Golf Simplified. That's our single
- 6:55source of truth. Why golf rules? Well, because
- 6:58they are incredibly dense, super specific, and
- 7:00totally self -contained. A generic AI. You might
- 7:04just guess or even hallucinate, you know, make
- 7:06stuff up if you ask a tricky golf question. But
- 7:09our engagement trained exclusively on this official
- 7:11rulebook. It'll be a true, reliable expert. Our
- 7:14goal is an AI caddy that can instantly and accurately
- 7:17answer very specific questions like, what am
- 7:19I allowed to do for practice? Or maybe, can I
- 7:21hit a practice shot between playing two holes?
- 7:23Yeah, and this isn't really about golf, is it?
- 7:25What's fascinating here is that this golf PDF,
- 7:28it's just a placeholder. This whole process is
- 7:31actually a universal blueprint for any specialized
- 7:33knowledge you want to give your AI. Your data
- 7:36source could be anything. Your last 5 ,000 HubSpot
- 7:39support tickets may be an air table base full
- 7:42of project data or even recent client emails.
- 7:45Imagine asking your AI, what are the top three
- 7:48common product issues we're seeing in the UK?
- 7:50Or, which projects are running over budget this
- 7:53year? and your agent's trigger, how you start
- 7:56the conversation. That can also be anything beyond
- 7:58just a chat window. It could be an email sent
- 8:00to askatyourcompany .com or a submission on your
- 8:03website form, or even a scheduled task that,
- 8:06say, summarizes the week's support tickets automatically.
- 8:08The skills you learn building this simple AI
- 8:11golf caddy, they're absolutely foundational for
- 8:14building really powerful business systems. So
- 8:16this simple golf example, it really unlocks vast
- 8:18possibilities for building custom AI then. Absolutely.
- 8:21It's a template, a template for pretty much any
- 8:23custom AI you can think of. All right, let's
- 8:25get our hands dirty then. Step one, building
- 8:27the library itself using Supabase. This is going
- 8:30to be the home for our AI agent. It's built on
- 8:32Postgresql, which is incredibly solid. Plus,
- 8:35it's pretty user -friendly and has a very generous
- 8:37free tier, which is great for getting started.
- 8:40Think of this step as laying the foundation,
- 8:43putting up the walls, and installing that magical
- 8:46shelving system for all your AI's knowledge.
- 8:49Okay, first up, you'll head over to supebase
- 8:51.com and create a new project. You give it a
- 8:54name, obviously, and critically, create a strong
- 8:56database password. Critical tip. Please, save
- 8:59this password securely right away, put it in
- 9:01a password manager, you will definitely need
- 9:03it later. Once your project is spinning up, might
- 9:06take a minute or two, you'll configure the vector
- 9:08database part. Now, this sounds a bit intimidating
- 9:11because it involves a snippet of code, but trust
- 9:13me, consider it a one -time magic spell. Exactly.
- 9:16A magic spell is a great way to put it. You just
- 9:18navigate to the SQL editor inside Superbase.
- 9:22You copy and paste a provided code block. We'll
- 9:24make sure you have access to that. And you click
- 9:26run that code. It's simply doing three things.
- 9:29First, create extension vector that's telling
- 9:31your database, hey, install the add -on to work
- 9:34with these AI vectors, these numbers representing
- 9:36meaning. Second, create table documents. This
- 9:40sets up the main storage shelf for your document
- 9:42chunks, including that special embedding vector
- 9:441536 column we talked about earlier, the profile.
- 9:48Finally, create function match documents. This
- 9:51creates the magic search tool that finds similar
- 9:53documents by comparing their vectors, their meaning.
- 9:56That little bit that says one, documents .embedding,
- 9:59query embedding. That's just telling the database
- 10:01how to measure the conceptual distance between
- 10:03your question and every piece of info it has.
- 10:05Think of it like a reverse distance meter. The
- 10:08closer the concepts match, the higher the similarity
- 10:10score it gives. And then it brings back the highest
- 10:12scoring, most relevant information. So by running
- 10:14this one script, you instantly upgrade your plan.
- 10:17database into an ai powered knowledge base pretty
- 10:20cool right and the final part of this setup step
- 10:23is just getting the keys to the library so to
- 10:26speak in your super base project settings under
- 10:28the api section you'll find your project url
- 10:31and the service role secret key security warning
- 10:33this service role key it is the master key to
- 10:37your entire database treat it like a password
- 10:39like gold Never, ever share it publicly. You'll
- 10:43need both the URL and that key for connecting
- 10:45it in 8n later on. OK, so we're essentially building
- 10:48the AI's personal research library here, getting
- 10:51it all ready for use. That's it. Building the
- 10:53database and its intelligence shelves ready to
- 10:55be filled. Right. So with our library built and
- 10:59ready to be stocked or maybe already stocked,
- 11:01if we ran the pipeline, it's time to hire the
- 11:03scholar. Our ARIG agent. This is a new separate.
- 11:07and add in workflow. This one's for the interactive
- 11:09conversations. Think about the anatomy of this
- 11:11AI scholar. It's got the ears. That's a chat
- 11:14trigger node. It just listens for user questions.
- 11:17Then there's the central nervous system, an AI
- 11:19agent node that coordinates everything, the thinking
- 11:21and responding. The brain itself is an open AI
- 11:23chat model, maybe like GPT -40 mini, which does
- 11:26the actual thinking and generates the responses.
- 11:30Crucially, we give it the library card. That's
- 11:32a Supabase vector store tool. You add this as
- 11:34a tool specifically for the AI agent. You set
- 11:37its operation to retrieve documents. And you
- 11:39give it a really clear description, something
- 11:41like, use this tool to look up the official rules
- 11:43of golf. The AI needs that clarity. And finally,
- 11:45the universal translator. That's the embeddings
- 11:48model again. This must be the exact same model,
- 11:50say, text embedding three small that you use
- 11:53when you build a pipeline. That ensures consistent
- 11:55understanding for accurate searching. It's got
- 11:57to speak the same language. Now, a brilliant
- 11:59scholar who can't remember what you just said
- 12:01five seconds ago, that's incredibly frustrating,
- 12:03right? It's like the Dory from Finding Nemo problem.
- 12:06By default, your agent has zero short -term memory,
- 12:09so we need to give it a notepad. This is step
- 12:11four, adding conversational memory. And you can
- 12:14actually do this surprisingly easily. Right inside
- 12:17your AI agent node, you add the PostgreSQL chat
- 12:19memory feature. You'll create a new PostgreSQL
- 12:22credential using your Supabase database settings.
- 12:25Quick tip here, use the transaction pooler settings
- 12:27that Supabase provides. It helps with efficiency,
- 12:30especially if you plan to scale this up later.
- 12:33The password you need here is the one you set
- 12:35up for your Supabase project way back at the
- 12:37start. See? Told you you'd need it. You can also
- 12:40set the context window how many past messages
- 12:42it remembers. The default is five recent interactions,
- 12:45which is usually a good starting point. And this
- 12:47whole memory system works using session IDs.
- 12:50Think of it like a unique library card for each
- 12:52user. That ensures everyone gets their own separate
- 12:54continuous conversation. Your chat doesn't get
- 12:57mixed up with someone else's. I still wrestle
- 13:00with remembering to configure these. memory pieces
- 13:03myself sometimes it's just it's easy to miss
- 13:05yeah i can see that and testing this memory is
- 13:07pretty simple right you just start a new chat
- 13:10say hello my name is whatever your name is and
- 13:13then in the next message ask what's my name if
- 13:16it answers correctly bingo its notepad is working
- 13:20you can even double check by looking at the engine
- 13:22histories table directly in superbase if you
- 13:24want proof So this creates that conversational
- 13:27expert, one that can actually remember the previous
- 13:30turns in the conversation. Yes, exactly. It enables
- 13:33those interactive, context -aware conversations
- 13:35that feel much more natural. Okay, makes sense.
- 13:39Mid -roll sponsor read. Now let's talk about
- 13:41the fuel, the stuff that makes our AI engine
- 13:43actually run, the OpenAI API key. This is a step
- 13:47that can sometimes trip up beginners. It's really
- 13:50crucial to understand the difference between
- 13:51your ChatGPT Plus subscription, if you have one,
- 13:54and the OpenAI API. Think of ChatGP Plus like
- 13:57an all -you -can -eat buffet. You pay a flat
- 13:59fee, like $20 a month, for direct human -to -AI
- 14:02chatting through their website. The OpenAI API,
- 14:05though, that's different. It's a la carte. You
- 14:07pay for exactly what you use, usually charged
- 14:10per token, which is kind of like parts of words.
- 14:12This API is specifically designed for programmatic
- 14:15use, you know, machine to AI interaction. And
- 14:17that's exactly what you need for tools like NAI
- 14:19to work. Right. And getting your API key is pretty
- 14:22straightforward. You navigate to platform .opni
- 14:25.com. Notice the platform part. That's the developer
- 14:27side, not the regular chat GPT site. You'll create
- 14:30an account if you don't have one at a payment
- 14:32method. Think of it like opening a tab at a restaurant.
- 14:34You only pay for what you order. When you go
- 14:36to the API keys section, click create new secret
- 14:40key. It'll generate a key that starts with SCET.
- 14:42Security 101. Again, this API key is basically
- 14:45like a credit card number for your AI usage.
- 14:47Guard it fiercely. Copy it immediately. Save
- 14:50it in your secure password manager. Never, ever
- 14:52share it publicly. And once you close that little
- 14:54window where it shows you the key, you'll never
- 14:56see the full key again. If you lose it, you just
- 14:58have to generate a new one. Okay. And the golden
- 15:01rule of cost control here is really start small
- 15:03and set limits. Tip number one, use cheaper models
- 15:08when you're testing and building. GPT -4 -0 Mini
- 15:10is incredibly capable, especially now, and it's
- 15:13significantly cheaper than the bigger models
- 15:14like GPT -4 Turbo. You can always upgrade later
- 15:17once you know it works and you need more power.
- 15:19Tip number two, and this is probably the most
- 15:21important one, set hard usage limits. In your
- 15:24OpenAI billing settings, you can actually set
- 15:27a hard spending limit, maybe just $10 a month
- 15:29to start. If your usage ever hits that limit,
- 15:32the API will simply stop working until the next
- 15:34billing cycle. This is your ultimate safety net.
- 15:36It lets you experiment with total confidence,
- 15:38knowing you won't get a surprise bill. Got it.
- 15:40So the API key is the gateway to the AI's brainpower,
- 15:44and cost control is absolutely essential. Right.
- 15:47Access the brain, but keep that spending firmly
- 15:49in check. All right. The moment of truth, then.
- 15:52Let's test our AI golf caddy. You execute the
- 15:55agent workflow in NA8N. You open the chat interface
- 15:57it provides, and you ask a question. Let's try
- 15:59that one. What am I allowed to do for practice
- 16:01before a round? Now, behind the scenes, here's
- 16:04what happens. The agent gets your query. It identifies
- 16:07its look up the rules of golf tool as the right
- 16:09one to use. It sends your question to the embeddings
- 16:12model to get vectorized, turned into numbers.
- 16:14It searches this super -based database using
- 16:17those vector numbers. It finds the most relevant
- 16:19chunks of text about practice from that PDF we
- 16:21loaded. It feeds those relevant chunks to its
- 16:24GPD 4 .0 mini brain along with your original
- 16:26question. And then, it generates a perfect, context
- 16:30-aware answer based only on the provided rules.
- 16:32Yeah, and the response you'd likely get, pulled
- 16:34straight from the source document, would be pretty
- 16:36detailed. Something like, before a round, you
- 16:38can practice on the course on the day of a match
- 16:40play event, but not before a stroke play tournament
- 16:43or playoff, or between rounds, unless the committee
- 16:46allows it. During the round itself, no practice
- 16:48shots are allowed when playing a hole or between
- 16:51holes. Except for some chipping or putting on
- 16:54or near the last green you finished, a practice
- 16:56green, Or the next D -Box, provided it doesn't
- 16:58hold up play. Let's see. Super specific, right
- 17:02from the rules. And you can even check the agent's
- 17:04execution logs in ADN to see this whole thought
- 17:06process play out, which tool it used, what info
- 17:09it retrieved. It's great for debugging, but really
- 17:12this is just the hello world of RAG, you know.
- 17:14Beyond these basics, you can set up dynamic document
- 17:16updates. Imagine a workflow where any new file
- 17:19dropped in a Google Drive folder automatically
- 17:21triggers an update to the AI's knowledge base.
- 17:24For multi -user systems, you could use unique
- 17:26session IDs, like maybe a user's email address
- 17:29or phone number. to maintain potentially thousands
- 17:31of separate private conversations simultaneously.
- 17:34Beep. Whip. I mean, imagine scaling that. Giving
- 17:38a custom private AI brain to potentially millions
- 17:41of individual users, all running off one core
- 17:43system. That's truly remarkable when you think
- 17:46about it. And of course, there's always performance
- 17:48optimization you can do later. Things like fine
- 17:50-tuning the vector search parameters, maybe caching
- 17:53common queries to reduce API calls and costs.
- 17:55Lots you can do. So this example, it's really
- 17:58just scratching the surface of what's possible
- 18:00with this RAG approach. Absolutely. It's a powerful
- 18:02foundation. You can build almost infinite applications
- 18:05on top of this basic. So let's recap. You've
- 18:08just gone from a general chat bot, one that knows
- 18:11a lot about everything but nothing specific about
- 18:13your stuff, to an AI with a custom specialized
- 18:16brain. RDAG systems, powered by these clever
- 18:20vector databases, allow AI to do its own context
- 18:24-specific research within your data. You got
- 18:26the librarian. building the knowledge base, meticulously
- 18:29organizing the information, and the scholar using
- 18:32that knowledge base, retrieving precise facts
- 18:34to answer your questions accurately. And maybe
- 18:36the best part, you can actually build this all
- 18:38without writing a single line of traditional
- 18:40code, creating powerful, intelligent systems
- 18:43for anything from, well, golf rules to complex
- 18:47business data. Yeah, this isn't just some cool
- 18:49tech demo. It's really about building the future
- 18:52of how AI interacts with your unique world, your
- 18:54specific information. You've now got the foundational
- 18:56skills, the understanding to customize AI and
- 18:59build truly intelligent agents tailored to your
- 19:01needs. This deep dive has hopefully equipped
- 19:04you with a pretty profound understanding of how
- 19:06to give AI both a memory and a personal library.
- 19:09So the question for you is, what specific dense
- 19:12body of knowledge in your life or your work could
- 19:15you give your AI next? Imagine the expertise
- 19:18you could unlock. Thank you for diving deep with
- 19:20us today. Keep exploring, keep building, and
- 19:22yes, stay curious.