In one sentence
Students build a real RAG from Drive that cites sources, and connect it as a tool for the agent.
Preparation before the session
Time plan
- 00:00โ00:15 Review: Noa
- 00:15โ00:40 What RAG is and why
- 00:40โ01:05 Embeddings and vector stores
- 01:05โ01:20 โ Break
- 01:20โ01:50 Ingestion: Drive โ chunks โ vectors
- 01:50โ02:15 Query + citing sources
- 02:15โ02:50 Building together: an organizational knowledge bot
- 02:50โ03:00 Summary and practice
Lecture parts and activity type
| Part | Activity type |
|---|---|
| What is RAG? | Explanation + simulation |
| An agent's knowledge or a full RAG? | Comparison |
| Embeddings โ meaning as numbers | Explanation |
| Ingestion โ putting documents into the store | Simulation |
| Query โ retrieval and an answer with sources | Simulation |
| RAG as a tool for the agent | Explanation |
The 3 messages that must get across
- Answer only from the sources.
- A fixed ID + metadata.
- Measure quality.
Questions for class discussion
- Which organizational knowledge "lives in people's heads"?
- Who is responsible for keeping the documents up to date?
- What's the risk when a bot answers about procedures?
Live demo script
Knowledge files for the agent
- Upload โ In the agent โ Knowledge โ Upload.
- Instructions โ Add the sources rule.
- Test โ 5 questions, document them.
Ingestion from Drive
- Pinecone โ Create index โ dimensions by the model โ cosine.
- Drive โ Google Drive โ Search files in the folder โ Download (convert to text).
- Chunks โ A Repeater + substring (or Make Code).
- Embeddings โ OpenAI โ Create embeddings โ Input = chunk.
- Upsert โ Pinecone โ Upsert vectors: ID {{fileId}}-{{i}}, Values = embedding, Metadata = source, url, text.
A query that cites sources
- Question โ Webhook / Telegram.
- Embedding โ The same model!
- Query โ Pinecone โ Query, topK 4.
- Filtering โ Iterator โ Filter score โ Text aggregator.
- Answer โ An LLM with the prompt from the lecture.
Problems students will run into
| Problem | Quick fix |
|---|---|
| It makes up an answer | Strengthen: "If it's not in the documents โ say you didn't find it". |
| A file wasn't taken in | An unsupported type/size โ convert to PDF/TXT. |
| Dimension mismatch | The index was created with a different number of dimensions than the model. |
| Duplicates | The ID isn't fixed (it includes a timestamp). |
| High Credits | Ingestion runs on every file every time โ watch only new/updated ones. |
| Always "I didn't find it" | The threshold is too high or the embeddings model differs from ingestion. |
| Wrong sources | The LLM didn't get the file name in the context. |
| The agent doesn't search | The tool's description and the instructions aren't clear. |
Tips from the classroom
- Start with knowledge files for a quick win.
- Show a hallucination without RAG and the same question with RAG.
- Ingestion Credits โ calculate in advance.
Adapting to different levels
For students who struggle: Knowledge files only.
For fast students: Permissions + pgvector.
Answer key โ multiple-choice questions
Students see the answers in shuffled order, so the key gives the wording of the right answer.
| # | Right answer |
|---|---|
| 1 | A vector of numbers that represents meaning |
| 2 | A few fixed documents |
| 3 | So an update overwrites and doesn't duplicate |
| 4 | You need to rebuild the store |
| 5 | The number of similar passages retrieved |
| 6 | Citing and filtering (department, file) |
| 7 | A filter by department in the query |
| 8 | Credits โ a module per chunk |
Homework
- A working knowledge bot with 15 test questions.
- Preparing for session 12: make sure the Telegram bot works, and download WhatsApp Business (optional).