Skip to content

Latest commit

 

History

History
59 lines (35 loc) · 2.39 KB

README.md

File metadata and controls

59 lines (35 loc) · 2.39 KB

Example for Gemini and VertexAI

Example for using Gemini LLM and Embeddings with textembedding-gecko on VertexAI.

const llmApplication = await new RAGApplicationBuilder()
    .setModel(new VertexAI({ modelName: 'gemini-1.5-pro-preview-0409'}))
    .setEmbeddingModel(new GeckoEmbedding())

List of Gemini LLM models: https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models.

VertexAI on Google Cloud Platform

Setup VertexAI

1. Setup GCP Project, gcloud CLI and Vertex AI

Instructions: (https://cloud.google.com/vertex-ai/docs/start/cloud-environment)

2. (Optional) Create a new Service Account with least permissive role.

You can use role Vertex AI User roles/aiplatform.user.

3. Authentication

Documentation: VertexAI Authentication

Option 1) gcloud CLI Application Default Login. Prefered for local development.

Documentation: https://cloud.google.com/docs/authentication/application-default-credentials#personal

You should be logged in an account, which have permissions for the project.

gcloud auth application-default login

Option 2) On Google Cloud Platform: using a service account which have permissions to the project and VertexAI

Documentation: https://cloud.google.com/vertex-ai/docs/authentication#on-gcp

Option 3) Environment variable with path to JSON key for Service Account

Documentation: https://cloud.google.com/docs/authentication/application-default-credentials#GAC

  • Download the Service Account's key after you have created it in Step 2.

  • Setup GOOGLE_APPLICATION_CREDENTIALS .env variable with the path to the downloaded JSON credentials:

GOOGLE_APPLICATION_CREDENTIALS=/path/to/credentials.json

NOTE: Using service account with JSON key can impose security risk if not stored correctly. Please revise Best Practices.