Generative AI backed Contact Form written in Python/Streamlit.
To create a corpus and generate a <project_id>_config_corpus.json
file, follow these steps:
-
Ensure you have the necessary dependencies installed. You can install them using:
pip install -r requirements.txt
-
Run the
create_google_rag.py
script with the required arguments:python create_google_rag.py -d <directory> -p <project_id> -c <credentials_path> -n <corpus_display_name> -g <gcs_source_uri> -l <location>
-d, --directory
: Directory to upload files from (default: [./upload
])-p, --project_id
: Your Google Cloud project ID (default: [vsp-genai
])-c, --credentials_path
: Path to your service account key.json (default: [./key.json
])-n, --corpus_display_name
: Display name for your dataset-g, --gcs_source_uri
: GCS URI for your data file (default: [gs://vision_benefits_docs
])-l, --location
: Location for the operation (default: [us-central1
])
-
This script will:
- Upload files to Google Cloud Storage (GCS)
- Create a RAG Corpus
- Import files into the RAG Corpus
- Generate a
config_corpus.json
file for use in the query script
To query the corpus using the generated config_corpus.json
file, follow these steps:
-
Run the [
google_rag_query.py
] script with the required arguments:python google_rag_query.py -c <config_corpus.json> -q <query_text>
-c, --corpus_config
: Path to the corpus configuration file-q, --query_text
: The query text to search in the corpus
-
This script will:
- Initialize Vertex AI
- Query the corpus using the provided query text
- Return the response from the RAG model and Gemini using Vertex AI form google.
See sql_tables.sql for example database layout.
You will need a google service account key as key.json (or change that in code)
The full streamlit demo uses Baserun.AI and OpenAI you get setup free accounts or
Recode these sections as needed.
- [
contact_helpdesk.py
] contact_helpdesk.py"): Handles the contact form submission and response. This is full demo in streamlit and can use OpenAI via Baserun. It includes asgoogle_rag_query.py
as an import. - [
contact_utils.py
] Contains utility functions for loading configurations and connecting to MySQL. - [
sql_tables.sql
] Contains the sql to create the 2 tables used in this demo.
This project is licensed under the MIT License.# genai_contact_form_demo Generative AI backed Contact Form written in Python/Streamlit.