/github-assistant

Primary LanguagePythonApache License 2.0Apache-2.0

Generative AI Github Assistant for Your Repository

Chat with your repository GenAI project

Alt Text

Tech Stack

Client: Streamlit

Server Side: LangChain 🦜🔗

Vectorstore: Pinecone 🌲

Embeddings: GCP VertexAI

Runtime: Cloud Run

Environment Variables

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

PINECONE_API_KEY PINECONE_ENVIRONMENT_REGION PINECONE_INDEX_NAME

GOOGLE_API_KEY STREAMLIT_SERVER_PORT

Run Locally

Clone the project

  git clone https://github.com/emarco177/github-assistant.git

Go to the project directory

  cd github-assistant

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 vertex-ai-consumer with the following roles:
gcloud iam service-accounts create vertex-ai-consumer \
    --display-name="Vertex AI Consumer"

gcloud projects add-iam-policy-binding PROJECT_ID \
    --member="serviceAccount:vertex-ai-consumer@PROJECT_ID.iam.gserviceaccount.com" \
    --role="roles/run.invoker"

gcloud projects add-iam-policy-binding PROJECT_ID \
    --member="serviceAccount:vertex-ai-consumer@PROJECT_ID.iam.gserviceaccount.com" \
    --role="roles/serviceusage.serviceUsageConsumer"

gcloud projects add-iam-policy-binding PROJECT_ID \
    --member="serviceAccount:vertex-ai-consumer@PROJECT_ID.iam.gserviceaccount.com" \
    --role="roles/ml.admin"

gcloud projects add-iam-policy-binding PROJECT_ID \
    --member="serviceAccount:vertex-ai-consumer@PROJECT_ID.iam.gserviceaccount.com" \
    --role="roles/vertexai.admin"
  1. Create the secrets: PINECONE_API_KEY PINECONE_ENVIRONMENT_REGION PALM2_API_KEY

and for each secret grant the SA vertex-ai-consumer@$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/github-assitant:latest
  1. Push to Artifact Registry
docker push us-east1-docker.pkg.dev/$PROJECT_ID/app/github-assitant:latest
  1. Deploy to cloud run
    --image=us-east1-docker.pkg.dev/PROJECT_ID/app/github-assitant:latest \
    --region=us-east1 \
    --service-account=vertex-ai-consumer@$PROJECT_ID.iam.gserviceaccount.com \
    --allow-unauthenticated \
    --set-env-vars="STREAMLIT_SERVER_PORT=8080,PINECONE_INDEX_NAME=wordblend-ai-index" \
    --set-secrets="GOOGLE_API_KEY=projects/PROJECT_ID/secrets/PALM2_API_KEY/versions/latest,PINECONE_API_KEY=projects/PROJECT_ID/secrets/ 
    PINECONE_API_KEY/versions/latest,PINECONE_ENVIRONMENT_REGION=projects/PROJECT_ID/secrets/PINECONE_ENVIRONMENT_REGION/versions/latest"

🚀 About Me

Eden Marco, Customer Engineer @ Google Cloud, Tel Aviv🇮🇱

linkedin

twitter