From ef118009f6646f1580d819e21c07d760189a4a5a Mon Sep 17 00:00:00 2001 From: Marco Beretta <81851188+berry-13@users.noreply.github.com> Date: Wed, 16 Oct 2024 00:10:48 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20Add=20`GOOGLE=5FLOC`=20envi?= =?UTF-8?q?ronment=20variable=20(#4395)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.example | 2 ++ api/app/clients/GoogleClient.js | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.env.example b/.env.example index 0b56317ff3..3e4f4e8845 100644 --- a/.env.example +++ b/.env.example @@ -146,6 +146,8 @@ GOOGLE_KEY=user_provided # GOOGLE_TITLE_MODEL=gemini-pro +# GOOGLE_LOC=us-central1 + # Google Safety Settings # NOTE: These settings apply to both Vertex AI and Gemini API (AI Studio) # diff --git a/api/app/clients/GoogleClient.js b/api/app/clients/GoogleClient.js index 92dd54be8d..99b1242837 100644 --- a/api/app/clients/GoogleClient.js +++ b/api/app/clients/GoogleClient.js @@ -28,7 +28,7 @@ const { } = require('./prompts'); const BaseClient = require('./BaseClient'); -const loc = 'us-central1'; +const loc = process.env.GOOGLE_LOC || 'us-central1'; const publisher = 'google'; const endpointPrefix = `https://${loc}-aiplatform.googleapis.com`; // const apiEndpoint = loc + '-aiplatform.googleapis.com'; @@ -593,6 +593,8 @@ class GoogleClient extends BaseClient { createLLM(clientOptions) { const model = clientOptions.modelName ?? clientOptions.model; + clientOptions.location = loc; + clientOptions.endpoint = `${loc}-aiplatform.googleapis.com`; if (this.project_id && this.isTextModel) { logger.debug('Creating Google VertexAI client'); return new GoogleVertexAI(clientOptions);