This repository contains exercises to help you deploy a RAG application in GCP.
- Code Quality: Add
Flake8
andPylint
linters to yoursettings.json
and use the warnings to improve your code. - Clean Code Principles:
- Follow the PEP8 standard.
- Adopt the following practices:
- Use type hints.
- Use docstrings only if needed.
- Utilize classes and functions.
- Ensure each function performs a single task.
- GCP Deployed Applications:
- The application should be deployed in GCP.
- The interface should function as expected.
- Avoid deploying multiple applications simultaneously.
- Create a branch with your name :
git checkout -b <your-name>
. - Commit your work in the branch :
git add . && git commit -m "Your message"
. - Push your branch to the repository :
git push origin <your-name>
. - Create a pull request from your branch to the
dev
branch.
- Prefix anything you deploy or create in GCP with your initials.
conda create --name genai_gcp python=3.11
conda activate genai_gcp
pip install -r requirements.txt
gcloud init # Use your email and project settings
gcloud auth login
gcloud auth application-default login # Authenticate on GCP with admin account
gcloud init # Use your email and project settings
gcloud auth application-default login # Authenticate on GCP with admin account
gcloud storage buckets create gs://<my-tfstate-bucket> --project=<my-project-id> --location=<my-region> # You need storage.buckets.create permission (ex: roles/editor)
cd terraform/bootstrap
vim backend.tf
# Edit <my-tfstate-bucket> with the name of the bucket created above
vim terraform.tfvars
# Edit the values of project_id, location, artifactregistry_name, and service_account_name
terraform init # You need storage.buckets.list permission (ex: roles/storage.objectUser)
terraform apply -var gcp_account_email="<my-user-email>"
# Return the service account to be copied next line
export GOOGLE_IMPERSONATE_SERVICE_ACCOUNT=<my-service-account>@<my-project-id>.iam.gserviceaccount.com
This repository contains exercises to help you deploy a RAG application in GCP. Complete the exercises in the following order:
TP Number | Link | Description |
---|---|---|
1 | Open exercice | Create a basic Streamlit app in Cloud Run. |
2 | Open exercice | Split the backend and frontend of your app and deploy in Cloud Run. |
3 | Open exercice | Use Gemini LLM to create a basic question-answering app without external knowledge. |
4 | Open exercice | Create and fill a Cloud SQL instance with the data needed for the RAG model:
|
5 | Open exercice | Use this data hosted in Cloud SQL to improve your question-answering app. |
6 | Open exercice | Use the RAG model to improve your question-answering app. |
7 | Open exercice | Collect user feedback from your app and store it in BigQuery. |
8 | Open exercice | Explore alternative architectures for deploying the RAG model in production, such as using Dialogflow. |
- Terraform Cloud SQL instance and DB ingestion.
- Terraform User IAM.
You will encounter many errors during development. Don't worry: it's part of the learning process. Here are a few hints on how to solve them:
- ERROR: Cannot connect to the Docker daemon # Docker app is not opened
- An env variable is not recognized # Check the .env file, run source .env in the terminal, load_dotenv() in the Python file
Role errors:
# PERMISSION_DENIED: Permission 'iam.serviceAccounts.getIamPolicy' denied on resource
# Command can only be done by an admin
gcloud iam service-accounts add-iam-policy-binding 1021317796643-compute@developer.gserviceaccount.com \
--member="user:bastinflorian1@gmail.com" \
--role="roles/iam.serviceAccountUser"