Skip to content

Commit ffd923f

Browse files
committed
feat: rename model -> modelId for Google vectorizers
1 parent 5a5819e commit ffd923f

File tree

7 files changed

+58
-35
lines changed

7 files changed

+58
-35
lines changed

src/collections/config/types/generative.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ export type GenerativePaLMConfig = GenerativeGoogleConfig;
8888
export type GenerativeGoogleConfig = {
8989
apiEndpoint?: string;
9090
maxOutputTokens?: number;
91+
model?: string;
92+
/** @deprecated Use `model` instead. */
9193
modelId?: string;
9294
projectId?: string;
9395
temperature?: number;

src/collections/config/types/vectorizer.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ export type Multi2VecGoogleConfig = {
175175
/** Length of a video interval in seconds. */
176176
videoIntervalSeconds?: number;
177177
/** The model ID in use. */
178+
model?: string;
179+
/** The model ID in use.
180+
* @deprecated Use `model` instead.*/
178181
modelId?: string;
179182
/** The dimensionality of the vector once embedded. */
180183
dimensions?: number;
@@ -474,6 +477,9 @@ export type Text2VecGoogleConfig = {
474477
/** The API endpoint to use without a leading scheme such as `http://`. */
475478
apiEndpoint?: string;
476479
/** The model ID to use. */
480+
model?: string;
481+
/** The model ID to use.
482+
* @deprecated Use `model `instead.*/
477483
modelId?: string;
478484
/** The project ID to use. */
479485
projectId?: string;

src/collections/config/unit.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ describe('Unit testing of the MergeWithExisting class', () => {
6565
},
6666
};
6767

68-
6968
it('should merge a full invertedIndexUpdate with existing schema', () => {
7069
const merged = MergeWithExisting.invertedIndex(deepCopy(invertedIndex), {
7170
bm25: {

src/collections/configure/generative.ts

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,13 @@ export default {
118118
name: 'generative-cohere',
119119
config: config
120120
? {
121-
kProperty: config.k,
122-
maxTokensProperty: config.maxTokens,
123-
model: config.model,
124-
returnLikelihoodsProperty: config.returnLikelihoods,
125-
stopSequencesProperty: config.stopSequences,
126-
temperatureProperty: config.temperature,
127-
}
121+
kProperty: config.k,
122+
maxTokensProperty: config.maxTokens,
123+
model: config.model,
124+
returnLikelihoodsProperty: config.returnLikelihoods,
125+
stopSequencesProperty: config.stopSequences,
126+
temperatureProperty: config.temperature,
127+
}
128128
: undefined,
129129
};
130130
},
@@ -220,14 +220,14 @@ export default {
220220
name: 'generative-openai',
221221
config: config
222222
? {
223-
baseURL: config.baseURL,
224-
frequencyPenaltyProperty: config.frequencyPenalty,
225-
maxTokensProperty: config.maxTokens,
226-
model: config.model,
227-
presencePenaltyProperty: config.presencePenalty,
228-
temperatureProperty: config.temperature,
229-
topPProperty: config.topP,
230-
}
223+
baseURL: config.baseURL,
224+
frequencyPenaltyProperty: config.frequencyPenalty,
225+
maxTokensProperty: config.maxTokens,
226+
model: config.model,
227+
presencePenaltyProperty: config.presencePenalty,
228+
temperatureProperty: config.temperature,
229+
topPProperty: config.topP,
230+
}
231231
: undefined,
232232
};
233233
},
@@ -246,7 +246,10 @@ export default {
246246
console.warn('The `generative-palm` module is deprecated. Use `generative-google` instead.');
247247
return {
248248
name: 'generative-palm',
249-
config,
249+
config: config ? {
250+
...config,
251+
...((config?.modelId || config?.model) ? { modelId: config?.model ?? config?.model } : undefined),
252+
} : undefined,
250253
};
251254
},
252255
/**
@@ -262,7 +265,10 @@ export default {
262265
): ModuleConfig<'generative-google', GenerativeGoogleConfig | undefined> => {
263266
return {
264267
name: 'generative-google',
265-
config,
268+
config: config ? {
269+
...config,
270+
...((config?.modelId || config?.model) ? { modelId: config?.model ?? config?.model } : undefined),
271+
} : undefined,
266272
};
267273
},
268274
/**

src/collections/configure/types/vectorizer.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ export type VectorConfigUpdate<N extends string | undefined, I extends VectorInd
6464

6565
export type VectorizersConfigCreate<T, V> = V extends undefined
6666
?
67-
| VectorConfigCreate<PrimitiveKeys<T>, string | undefined, VectorIndexType, Vectorizer>
68-
| VectorConfigCreate<PrimitiveKeys<T>, string, VectorIndexType, Vectorizer>[]
67+
| VectorConfigCreate<PrimitiveKeys<T>, string | undefined, VectorIndexType, Vectorizer>
68+
| VectorConfigCreate<PrimitiveKeys<T>, string, VectorIndexType, Vectorizer>[]
6969
:
70-
| VectorConfigCreate<PrimitiveKeys<T>, (keyof V & string) | undefined, VectorIndexType, Vectorizer>
71-
| VectorConfigCreate<PrimitiveKeys<T>, keyof V & string, VectorIndexType, Vectorizer>[];
70+
| VectorConfigCreate<PrimitiveKeys<T>, (keyof V & string) | undefined, VectorIndexType, Vectorizer>
71+
| VectorConfigCreate<PrimitiveKeys<T>, keyof V & string, VectorIndexType, Vectorizer>[];
7272

7373
export type VectorizersConfigAdd<T> =
7474
| VectorConfigCreate<PrimitiveKeys<T>, string, VectorIndexType, Vectorizer>

src/collections/configure/unit.test.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ describe('Unit testing of the vectorizer factory class', () => {
568568
textFields: ['field3', 'field4'],
569569
videoFields: ['field5', 'field6'],
570570
location: 'location',
571-
modelId: 'model-id',
571+
model: 'model-id',
572572
dimensions: 256,
573573
});
574574
expect(config).toEqual<VectorConfigCreate<never, 'test', 'hnsw', 'multi2vec-google'>>({
@@ -585,6 +585,7 @@ describe('Unit testing of the vectorizer factory class', () => {
585585
textFields: ['field3', 'field4'],
586586
videoFields: ['field5', 'field6'],
587587
location: 'location',
588+
model: 'model-id',
588589
modelId: 'model-id',
589590
dimensions: 256,
590591
},
@@ -609,7 +610,7 @@ describe('Unit testing of the vectorizer factory class', () => {
609610
{ name: 'field6', weight: 0.6 },
610611
],
611612
location: 'location',
612-
modelId: 'model-id',
613+
model: 'model-id',
613614
dimensions: 256,
614615
});
615616
expect(config).toEqual<VectorConfigCreate<never, 'test', 'hnsw', 'multi2vec-google'>>({
@@ -626,6 +627,7 @@ describe('Unit testing of the vectorizer factory class', () => {
626627
textFields: ['field3', 'field4'],
627628
videoFields: ['field5', 'field6'],
628629
location: 'location',
630+
model: 'model-id',
629631
modelId: 'model-id',
630632
dimensions: 256,
631633
weights: {
@@ -1343,7 +1345,7 @@ describe('Unit testing of the vectorizer factory class', () => {
13431345
const config = configure.vectors.text2VecGoogle({
13441346
name: 'test',
13451347
apiEndpoint: 'api-endpoint',
1346-
modelId: 'model-id',
1348+
model: 'model-id',
13471349
projectId: 'project-id',
13481350
});
13491351
expect(config).toEqual<VectorConfigCreate<never, 'test', 'hnsw', 'text2vec-google'>>({
@@ -1356,6 +1358,7 @@ describe('Unit testing of the vectorizer factory class', () => {
13561358
name: 'text2vec-google',
13571359
config: {
13581360
apiEndpoint: 'api-endpoint',
1361+
model: 'model-id',
13591362
modelId: 'model-id',
13601363
projectId: 'project-id',
13611364
},
@@ -1364,7 +1367,7 @@ describe('Unit testing of the vectorizer factory class', () => {
13641367
});
13651368

13661369
it('should create the correct Text2VecPalmConfig type using deprecated method with defaults', () => {
1367-
const config = configure.vectors.text2VecPalm();
1370+
const config = configure.vectorizer.text2VecPalm();
13681371
expect(config).toEqual<VectorConfigCreate<never, undefined, 'hnsw', 'text2vec-palm'>>({
13691372
name: undefined,
13701373
vectorIndex: {
@@ -1379,7 +1382,7 @@ describe('Unit testing of the vectorizer factory class', () => {
13791382
});
13801383

13811384
it('should create the correct Text2VecPalmConfig type using deprecated method with all values', () => {
1382-
const config = configure.vectors.text2VecPalm({
1385+
const config = configure.vectorizer.text2VecPalm({
13831386
name: 'test',
13841387
apiEndpoint: 'api-endpoint',
13851388
modelId: 'model-id',
@@ -1959,7 +1962,7 @@ describe('Unit testing of the generative factory class', () => {
19591962
});
19601963
});
19611964

1962-
it('should create the correct GeneratGoogleConfig type with required & default values', () => {
1965+
it('should create the correct GenerateGoogleConfig type with required & default values', () => {
19631966
const config = configure.generative.google();
19641967
expect(config).toEqual<ModuleConfig<'generative-google', undefined>>({
19651968
name: 'generative-google',
@@ -1979,7 +1982,7 @@ describe('Unit testing of the generative factory class', () => {
19791982
const config = configure.generative.palm({
19801983
apiEndpoint: 'api-endpoint',
19811984
maxOutputTokens: 100,
1982-
modelId: 'model-id',
1985+
model: 'model-id',
19831986
projectId: 'project-id',
19841987
temperature: 0.5,
19851988
topK: 5,
@@ -1990,6 +1993,7 @@ describe('Unit testing of the generative factory class', () => {
19901993
config: {
19911994
apiEndpoint: 'api-endpoint',
19921995
maxOutputTokens: 100,
1996+
model: 'model-id',
19931997
modelId: 'model-id',
19941998
projectId: 'project-id',
19951999
temperature: 0.5,
@@ -2003,7 +2007,7 @@ describe('Unit testing of the generative factory class', () => {
20032007
const config = configure.generative.google({
20042008
apiEndpoint: 'api-endpoint',
20052009
maxOutputTokens: 100,
2006-
modelId: 'model-id',
2010+
model: 'model-id',
20072011
projectId: 'project-id',
20082012
temperature: 0.5,
20092013
topK: 5,
@@ -2014,6 +2018,7 @@ describe('Unit testing of the generative factory class', () => {
20142018
config: {
20152019
apiEndpoint: 'api-endpoint',
20162020
maxOutputTokens: 100,
2021+
model: 'model-id',
20172022
modelId: 'model-id',
20182023
projectId: 'project-id',
20192024
temperature: 0.5,

src/collections/configure/vectorizer.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -814,9 +814,9 @@ export const legacyVectors = {
814814
};
815815

816816
/** __vectors_shaded modifies some parameters in legacy vectorizer configuration.
817-
*
818-
* - Hide `vectorizeCollectionName` parameter from all constructors in `legacyVectors` where it was previously accepted.
819-
* - Rename `modelId` to `model` for `text2vec-google` and `multi2vec-google` vectorizers.
817+
*
818+
* - Hide `vectorizeCollectionName` parameter from all constructors in `legacyVectors` where it was previously accepted.
819+
* - Rename `modelId` to `model` for `text2vec-google` and `multi2vec-google` vectorizers.
820820
* */
821821
// eslint-disable-next-line @typescript-eslint/naming-convention
822822
const __vectors_shaded = {
@@ -840,7 +840,10 @@ const __vectors_shaded = {
840840
model?: string;
841841
modelId?: never; // hard-deprecated in `vectors`
842842
}
843-
) => legacyVectors.text2VecGoogle({ ...opts, modelId: opts?.modelId || opts?.model }),
843+
) => legacyVectors.text2VecGoogle(opts ? {
844+
...opts,
845+
...(opts?.modelId || opts?.model) ? { modelId: opts?.modelId || opts?.model } : undefined,
846+
} : undefined),
844847
text2VecOpenAI: <T, N extends string | undefined = undefined, I extends VectorIndexType = 'hnsw'>(
845848
opts?: Omit<ConfigureTextVectorizerOptions<T, N, I, 'text2vec-openai'>, 'vectorizeCollectionName'>
846849
) => legacyVectors.text2VecOpenAI(opts),
@@ -902,7 +905,9 @@ export const vectorizer = legacyVectors;
902905
// Remove deprecated vectorizers and module configuration parameters:
903906
// - PaLM vectorizers are called -Google now.
904907
// - __vectors_shaded hide/rename some parameters
905-
export const vectors = (({ text2VecPalm, multi2VecPalm, ...rest }) => ({ ...rest, ...__vectors_shaded }))(legacyVectors);
908+
export const vectors = (({ text2VecPalm, multi2VecPalm, ...rest }) => ({ ...rest, ...__vectors_shaded }))(
909+
legacyVectors
910+
);
906911

907912
export const multiVectors = {
908913
/**

0 commit comments

Comments
 (0)