Chapter 2: The knowledge base
The level 1 agent answers from your shop’s policies. For it to search them, the document has to be prepared first: read it, split it into fragments and store it in a knowledge base, where each fragment can be found by its meaning and not only by its exact words.
Create a blank project, for example Shop customer service. In this chapter you’ll build the part that loads the document, and in the next one, in the same project, the part that serves customers.
The components
| Component | What you’ll use it for |
|---|---|
| Drive File Manager | Reads the document from Google Drive. |
| Parse Data | Prepares the document’s text for splitting. |
| Split Text | Splits it into fragments. |
| Google Generative AI Embeddings | Computes the representation of each fragment that makes searching by meaning possible. |
| Chroma DB | Stores the fragments in the knowledge base. |
Connect them
| From | Output | To | Input |
|---|---|---|---|
| Drive File Manager | Data | Parse Data | Data |
| Parse Data | Processed Data | Split Text | Data Inputs |
| Split Text | Chunks | Chroma DB | Ingest Data |
| Google Generative AI Embeddings | Embeddings | Chroma DB | Embedding |
Configure them
Drive File Manager
- Credential: your Google Drive credential.
- Operation: Get.
- Mode of Input: By Selection.
- Selection Mode: File.
- Select file: choose the policies document.
- In Advanced, turn on Process File Content. That way the component returns the document’s text, not just its details.
Parse Data
- Leave Template at
{text}, its default value: it takes the text that Drive File Manager returns.
Split Text
- Chunk Size and Chunk Overlap come set to 1000 and 200. These values suit ordinary text documents: each fragment has about 1000 characters and shares 200 with the next one so an idea isn’t cut in half.
Google Generative AI Embeddings
- Credential: your Gemini credential.
Chroma DB
- Operation: Add.
- Collection Name:
shop_policies. Note it down: the level 1 agent will search this collection. - Leave Persist Directory empty.
Load the document
- Click the play button on the Chroma DB component. This part of the flow runs up to that point.
- When every component shows the green tick, the document is loaded.
- Select Chroma DB and click Unplug in its toolbar. That way this part isn’t run again every time you test the flow.
If you change the document, undo the unplug and run it again.
In the next chapter you’ll build the part that serves customers.