Session 11 / 15๐Ÿ”Žืขื‘

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

  1. 00:00โ€“00:15 Review: Noa
  2. 00:15โ€“00:40 What RAG is and why
  3. 00:40โ€“01:05 Embeddings and vector stores
  4. 01:05โ€“01:20 โ˜• Break
  5. 01:20โ€“01:50 Ingestion: Drive โ†’ chunks โ†’ vectors
  6. 01:50โ€“02:15 Query + citing sources
  7. 02:15โ€“02:50 Building together: an organizational knowledge bot
  8. 02:50โ€“03:00 Summary and practice

Lecture parts and activity type

PartActivity type
What is RAG?Explanation + simulation
An agent's knowledge or a full RAG?Comparison
Embeddings โ€” meaning as numbersExplanation
Ingestion โ€” putting documents into the storeSimulation
Query โ€” retrieval and an answer with sourcesSimulation
RAG as a tool for the agentExplanation

The 3 messages that must get across

  1. Answer only from the sources.
  2. A fixed ID + metadata.
  3. 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

  1. Upload โ€” In the agent โ†’ Knowledge โ†’ Upload.
  2. Instructions โ€” Add the sources rule.
  3. Test โ€” 5 questions, document them.

Ingestion from Drive

  1. Pinecone โ€” Create index โ†’ dimensions by the model โ†’ cosine.
  2. Drive โ€” Google Drive โ†’ Search files in the folder โ†’ Download (convert to text).
  3. Chunks โ€” A Repeater + substring (or Make Code).
  4. Embeddings โ€” OpenAI โ†’ Create embeddings โ†’ Input = chunk.
  5. Upsert โ€” Pinecone โ†’ Upsert vectors: ID {{fileId}}-{{i}}, Values = embedding, Metadata = source, url, text.

A query that cites sources

  1. Question โ€” Webhook / Telegram.
  2. Embedding โ€” The same model!
  3. Query โ€” Pinecone โ†’ Query, topK 4.
  4. Filtering โ€” Iterator โ†’ Filter score โ†’ Text aggregator.
  5. Answer โ€” An LLM with the prompt from the lecture.

Problems students will run into

ProblemQuick fix
It makes up an answerStrengthen: "If it's not in the documents โ€” say you didn't find it".
A file wasn't taken inAn unsupported type/size โ€” convert to PDF/TXT.
Dimension mismatchThe index was created with a different number of dimensions than the model.
DuplicatesThe ID isn't fixed (it includes a timestamp).
High CreditsIngestion 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 sourcesThe LLM didn't get the file name in the context.
The agent doesn't searchThe 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
1A vector of numbers that represents meaning
2A few fixed documents
3So an update overwrites and doesn't duplicate
4You need to rebuild the store
5The number of similar passages retrieved
6Citing and filtering (department, file)
7A filter by department in the query
8Credits โ€” a module per chunk

Homework

  1. A working knowledge bot with 15 test questions.
  2. Preparing for session 12: make sure the Telegram bot works, and download WhatsApp Business (optional).