Skip to content

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

ComponentWhat you’ll use it for
Drive File ManagerReads the document from Google Drive.
Parse DataPrepares the document’s text for splitting.
Split TextSplits it into fragments.
Google Generative AI EmbeddingsComputes the representation of each fragment that makes searching by meaning possible.
Chroma DBStores the fragments in the knowledge base.

Connect them

FromOutputToInput
Drive File ManagerDataParse DataData
Parse DataProcessed DataSplit TextData Inputs
Split TextChunksChroma DBIngest Data
Google Generative AI EmbeddingsEmbeddingsChroma DBEmbedding

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

  1. Click the play button on the Chroma DB component. This part of the flow runs up to that point.
  2. When every component shows the green tick, the document is loaded.
  3. 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.