From 8bec01ca2f3d35b011f4a5fa37c6512b597e11d9 Mon Sep 17 00:00:00 2001 From: Ivan Despot <66276597+g-despot@users.noreply.github.com> Date: Fri, 19 Jun 2026 11:09:02 +0200 Subject: [PATCH] feat: add optional location parameter to text2vec-google vectorizer --- src/collections/config/types/vectorizer.ts | 2 ++ src/collections/configure/unit.test.ts | 29 ++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/collections/config/types/vectorizer.ts b/src/collections/config/types/vectorizer.ts index 1a0e97d3..4083601c 100644 --- a/src/collections/config/types/vectorizer.ts +++ b/src/collections/config/types/vectorizer.ts @@ -586,6 +586,8 @@ export type Text2VecGoogleConfig = { apiEndpoint?: string; /** The dimensionality of the vector once embedded. */ dimensions?: number; + /** The location where the model runs, i.e. the Google Vertex AI region. */ + location?: string; /** The model ID to use. */ model?: string; /** The model ID to use. diff --git a/src/collections/configure/unit.test.ts b/src/collections/configure/unit.test.ts index 637821f3..7c901eac 100644 --- a/src/collections/configure/unit.test.ts +++ b/src/collections/configure/unit.test.ts @@ -1367,6 +1367,7 @@ describe('Unit testing of the vectorizer factory class', () => { const config = configure.vectors.text2VecGoogle({ name: 'test', apiEndpoint: 'api-endpoint', + location: 'us-central1', model: 'model-id', projectId: 'project-id', }); @@ -1376,6 +1377,7 @@ describe('Unit testing of the vectorizer factory class', () => { name: 'text2vec-google', config: { apiEndpoint: 'api-endpoint', + location: 'us-central1', model: 'model-id', modelId: 'model-id', projectId: 'project-id', @@ -1384,6 +1386,33 @@ describe('Unit testing of the vectorizer factory class', () => { }); }); + it('should serialize text2vec-google `location` when set and omit it when unset', () => { + // location set → present in serialized config (Google Vertex AI region) + const withLocation = configure.vectors.text2VecGoogle({ location: 'us-central1' }); + expect(withLocation).toEqual>({ + name: undefined, + vectorizer: { + name: 'text2vec-google', + config: { + location: 'us-central1', + }, + }, + }); + + // location unset → no client-side default; key absent from serialized config (server applies its default) + const withoutLocation = configure.vectors.text2VecGoogle({ projectId: 'project-id' }); + expect(withoutLocation).toEqual>({ + name: undefined, + vectorizer: { + name: 'text2vec-google', + config: { + projectId: 'project-id', + }, + }, + }); + expect((withoutLocation.vectorizer.config as Record).location).toBeUndefined(); + }); + it('should create the correct Text2VecGoogleGeminiConfig type with defaults', () => { const config = configure.vectors.text2VecGoogleGemini(); expect(config).toEqual>({