Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/collections/config/types/vectorizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
29 changes: 29 additions & 0 deletions src/collections/configure/unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
});
Expand All @@ -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',
Expand All @@ -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<VectorConfigCreate<never, undefined, 'hnsw', 'text2vec-google'>>({
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<VectorConfigCreate<never, undefined, 'hnsw', 'text2vec-google'>>({
name: undefined,
vectorizer: {
name: 'text2vec-google',
config: {
projectId: 'project-id',
},
},
});
expect((withoutLocation.vectorizer.config as Record<string, unknown>).location).toBeUndefined();
});

it('should create the correct Text2VecGoogleGeminiConfig type with defaults', () => {
const config = configure.vectors.text2VecGoogleGemini();
expect(config).toEqual<VectorConfigCreate<never, undefined, 'hnsw', 'text2vec-google'>>({
Expand Down
Loading