8000 GitHub - g-emarco/advanced-rag
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

g-emarco/advanced-rag

Repository files navigation

Advanced RAG

Alt Text

Tech Stack

Client: Streamlit

Server Side: LangChain 🦜🔗

Vectorstore: PGVector

Embeddings: GCP VertexAI

LLMS: PaLM 2, AI21 Contextual Answers

Runtime: Cloud Run

Environment Variables

To run this project, you will need to add the following environment variables to your .env file

AI21_API_KEY, CONNECTION_STRING

Run Locally

Clone the project

  git clone https://github.com/g-emarco/advanced-rag.git

Go to the project directory

  cd advanced-rag

Install dependencies

  pipenv install

Start the Streamlit server

  streamlit run app.py

NOTE: When running locally make sure GOOGLE_APPLICATION_CREDENTIALS is set to a service account with permissions to use VertexAI

Deployment to cloud run

CI/CD via Cloud build is availale in cloudbuild.yaml

Please replace $PROJECT_ID with your actual Google Cloud project ID.

To deploy manually:

  1. Make sure you enable GCP APIs:
gcloud services enable cloudbuild.googleapis.com
gcloud services enable run.googleapis.com
gcloud services enable secretmanager.googleapis.com
gcloud services enable artifactregistry.googleapis.com
gcloud services enable vertexai.googleapis.com
  1. Create a service account rag-app-sa with the following roles:
gcloud iam service-accounts create rag-app-sa \
    --display-name="SA For Application"

gcloud projects add-iam-policy-binding PROJECT_ID \
    --member="serviceAccount:rag-app-sa@PROJECT_ID.iam.gserviceaccount.com" \
    --role="roles/run.invoker"

gcloud projects add-iam-policy-binding PROJECT_ID \
    --member="serviceAccount:rag-app-sa@PROJECT_ID.iam.gserviceaccount.com" \
    --role="roles/serviceusage.serviceUsageConsumer"

gcloud projects add-iam-policy-binding PROJECT_ID \
    --member="serviceAccount:rag-app-sa@PROJECT_ID.iam.gserviceaccount.com" \
    --role="roles/ml.admin"

gcloud projects add-iam-policy-binding PROJECT_ID \
    --member=<
63AD
span class="pl-s">"serviceAccount:rag-app-sa@PROJECT_ID.iam.gserviceaccount.com" \
    --role="roles/vertexai.admin"
  1. Create the secrets:

AI21_API_KEY

and for each secret grant the SA rag-app-sa@$PROJECT_ID.iam.gserviceaccount.com Secret Manager Secret Accessor role to th secrets

  1. Build Image
docker build . -t us-east1-docker.pkg.dev/$PROJECT_ID/app/documentation-assistant:latest
  1. Push to Artifact Registry
docker push us-east1-docker.pkg.dev/$PROJECT_ID/app/documentation-assistant:latest
  1. Deploy to cloud run
    --image=us-east1-docker.pkg.dev/PROJECT_ID/app/documentation-assistant:latest \
    --region=us-east1 \
    --service-account=rag-app-sa@$PROJECT_ID.iam.gserviceaccount.com \
    --allow-unauthenticated \
    --set-secrets="GOOGLE_API_KEY=projects/PROJECT_ID/secrets/AI21_API_KEY/versions/latest 

🚀 About Me

Eden Marco, LLM Lead @ Google Cloud, Tel Aviv🇮🇱

linkedin

twitter

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0