Skip to content

Latest commit

 

History

History
 
 

web-app

Vertex AI Search Web App Demo

NOTE: Some of the features in this demo require allowlist access. If you would like early access, apply to become a Trusted Tester for Google Cloud Generative AI.

This demo illustrates how to search through a corpus of documents using Vertex AI Search (formerly known as Enterprise Search).

Additional features include how to search the public Cloud Knowledge Graph using the Enterprise Knowledge Graph API.

Video Walkthrough

VAIS Web App Walkthrough

Architecture

Google Cloud Products Used

Setup

Dependencies

  1. Install Python

  2. Install the Google Cloud SDK

  3. Install the prerequisites:

    • pip install -r requirements.txt
  4. Run gcloud init, create a new project, and enable billing

  5. Enable the Vertex AI Search API:

    • gcloud services enable discoveryengine.googleapis.com
  6. Enable the Enterprise Knowledge Graph API:

    • gcloud services enable enterpriseknowledgegraph.googleapis.com
  7. Enable Cloud Run:

    • gcloud services enable run.googleapis.com
  8. Setup application default authentication, run:

    • gcloud auth application-default login
  9. Give the Cloud Run service account required permissions:

    gcloud projects add-iam-policy-binding [PROJECT_ID or PROJECT_NUMBER] \
       --member='serviceAccount:[PROJECT_NUMBER][email protected]' \
       --role='roles/discoveryengine.viewer'
  10. (Optional) If your Google Cloud organization has polices to restrict sharing by domain, then you'll need to change this to allow all domains for the Cloud Run application to be open to the public Internet.

Demo Deployment

  1. Update the consts.py file with your own PROJECT_ID and LOCATION.

  2. Configure Vertex AI Search

    • To use the prebuilt widget, copy the configId from the <gen-search-widget> in the Integration > Widget tab in the Cloud Console.
      • configId
      • Be sure to set authorization type as Public Access and add your web application url to the Allowed Domains once it's deployed.
      • Add the configId for your Search Engines to WIDGET_CONFIGS in consts.py
    • To use the Custom UI, add the engine id for your search engine to CUSTOM_UI_ENGINE_IDS in consts.py
      • This is the string after /engines/ in the Cloud Console URL.
        • https://console.cloud.google.com/gen-app-builder/engines/website-search-engine_1681248733152/...
        • Engine ID is website-search-engine_1681248733152
  3. Configure Recommendations

    • Add the datastore id and engine id for your recommendations engine to RECOMMENDATIONS_DATASTORE_IDs in consts.py.
    • The datastore id is visible on the Data > Details page.
    • The engine id is the string after /engines/ in the Cloud Console URL.
      • https://console.cloud.google.com/gen-app-builder/engines/contracts-personalize_1687884886933/data/records
      • Engine ID is contracts-personalize_1687884886933
  4. Configure Image Search

  5. Deploy the Cloud Run app in your project.

    • gcloud run deploy vertex-ai-search-demo --source .

    • To test locally: flask --app main run

  6. Visit the deployed web page


Copyright 2023 Google LLC Author: Holt Skinner @holtskinner