This directory contains several versions of approximately the same implementation.
The functions can be deployed to Cloud functions and can be modified to supports many different triggers and use cases. Each can also be deployed locally which allows easy experimentation and iteration.
This example is powered by Vertex AI Search which does many different things, including Document & Intranet Search, Recommendations and Grounding and RAG out-of-the-box (For more information, see the blog post Your RAG powered by Google Search).
If you want even more control see Vertex AI Search Component APIs, but first explore the out-of-the-box offering because it's easy to setup.
This example is for the out-of-the-box Vertex AI Search supporting many configurations and data types.
Before you can use these functions to query Vertex AI Search, you need to create and populate a search "data store"; read through instructions in get started with generic search. These functions could easily be adapted to other types of Vertex AI Search like generic recommendations, media search, media recommendations, healthcare search, or even retail product discovery.
You'll need to collect the following details from your search app data store:
PROJECT_ID = "YOUR_PROJECT_ID" # alphanumeric
LOCATION = "global" # or an alternate location
DATA_STORE_ID = "YOUR_DATA_STORE_ID" # not the app id, alphanumeric
Additionally you'll need to keep track of some of the choices you make when you configure Vertex AI Search.
- UNSTRUCTURED
- STRUCTURED
- WEBSITE
- BLENDED
ENGINE_DATA_TYPE = UNSTRUCTURED
- DOCUMENT_WITH_SNIPPETS
- DOCUMENT_WITH_EXTRACTIVE_SEGMENTS
- CHUNK
- NONE
ENGINE_CHUNK_TYPE = DOCUMENT_WITH_EXTRACTIVE_SEGMENTS
- NONE results only
- VERTEX_AI_SEARCH LLM add on provided by Vertex AI Search
SUMMARY_TYPE = VERTEX_AI_SEARCH
- Vertex AI Search is an API hosted on Google Cloud
- You will call that API via a Google Cloud Function, which exposes its own API
- Your users will the Google Cloud Function API, via your custom app or UI
flowchart LR
A[fa:fa-search Vertex AI Search] --> B(Google Cloud Function)
B --> C[My App Server]
C -->|One| D[fa:fa-laptop web]
C -->|Two| E[fa:fa-mobile mobile]
Any time you have more source data than can fit into a LLM context window, you could benefit from RAG (Retrieval Augmented Generation). The more data you have, the more important search is - to get the relevant chunks into the prompt of the LLM.
- Retrieve relevant search results, with text chunks (snippets or segments)
- Augmented Generation uses Gemini to generate an answer or summary grounded on the relevant search results
A natural extension of RAG / Grounding is agentic behavior.
Whether creating a basic chatbot or a sophisticated tool using multi-agent system, you're always going to need search based RAG. The better the search quality the better the agent response based on your source data.
For more on agents, check out Vertex AI Agent Builder Use Cases and https://github.com/GoogleCloudPlatform/generative-ai.