Skip to content

Commit 5a5819e

Browse files
committed
chore: rename modelId -> model for -Google vectors
1 parent dabfd0e commit 5a5819e

File tree

4 files changed

+69
-57
lines changed

4 files changed

+69
-57
lines changed

src/collections/config/unit.test.ts

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

68+
6869
it('should merge a full invertedIndexUpdate with existing schema', () => {
6970
const merged = MergeWithExisting.invertedIndex(deepCopy(invertedIndex), {
7071
bm25: {

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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ describe('Unit testing of the vectorizer factory class', () => {
708708
});
709709

710710
it('should create the correct Multi2VecPalmConfig type using deprecated method with defaults', () => {
711-
const config = configure.vectors.multi2VecPalm({
711+
const config = configure.vectorizer.multi2VecPalm({
712712
projectId: 'project-id',
713713
location: 'location',
714714
});
@@ -729,7 +729,7 @@ describe('Unit testing of the vectorizer factory class', () => {
729729
});
730730

731731
it('should create the correct Multi2VecPalmConfig type using deprecated method with all values', () => {
732-
const config = configure.vectors.multi2VecPalm({
732+
const config = configure.vectorizer.multi2VecPalm({
733733
name: 'test',
734734
projectId: 'project-id',
735735
imageFields: ['field1', 'field2'],
@@ -761,7 +761,7 @@ describe('Unit testing of the vectorizer factory class', () => {
761761
});
762762

763763
it('should create the correct Multi2VecPalmConfig type using deprecated method with all values and weights', () => {
764-
const config = configure.vectors.multi2VecPalm({
764+
const config = configure.vectorizer.multi2VecPalm({
765765
name: 'test',
766766
projectId: 'project-id',
767767
imageFields: [

src/collections/configure/vectorizer.ts

Lines changed: 61 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,20 @@ const makeVectorIndex = (opts?: {
3737
}
3838
conf = conf
3939
? {
40-
...conf,
41-
multiVector: conf.multiVector
42-
? {
43-
...conf.multiVector,
44-
encoding: conf.multiVector.encoding
45-
? { ...conf.multiVector.encoding, ...opts.encoding }
46-
: opts.encoding,
47-
}
48-
: vectorIndex.multiVector.multiVector({ encoding: opts.encoding }),
49-
}
40+
...conf,
41+
multiVector: conf.multiVector
42+
? {
43+
...conf.multiVector,
44+
encoding: conf.multiVector.encoding
45+
? { ...conf.multiVector.encoding, ...opts.encoding }
46+
: opts.encoding,
47+
}
48+
: vectorIndex.multiVector.multiVector({ encoding: opts.encoding }),
49+
}
5050
: {
51-
multiVector: vectorIndex.multiVector.multiVector({ encoding: opts.encoding }),
52-
type: 'hnsw',
53-
};
51+
multiVector: vectorIndex.multiVector.multiVector({ encoding: opts.encoding }),
52+
type: 'hnsw',
53+
};
5454
}
5555
if (opts?.quantizer) {
5656
if (!conf) {
@@ -201,16 +201,16 @@ export const legacyVectors = {
201201
Object.keys(config).length === 0
202202
? undefined
203203
: {
204-
...config,
205-
audioFields: audioFields?.map((f) => f.name),
206-
depthFields: depthFields?.map((f) => f.name),
207-
imageFields: imageFields?.map((f) => f.name),
208-
IMUFields: IMUFields?.map((f) => f.name),
209-
textFields: textFields?.map((f) => f.name),
210-
thermalFields: thermalFields?.map((f) => f.name),
211-
videoFields: videoFields?.map((f) => f.name),
212-
weights: Object.keys(weights).length === 0 ? undefined : weights,
213-
},
204+
...config,
205+
audioFields: audioFields?.map((f) => f.name),
206+
depthFields: depthFields?.map((f) => f.name),
207+
imageFields: imageFields?.map((f) => f.name),
208+
IMUFields: IMUFields?.map((f) => f.name),
209+
textFields: textFields?.map((f) => f.name),
210+
thermalFields: thermalFields?.map((f) => f.name),
211+
videoFields: videoFields?.map((f) => f.name),
212+
weights: Object.keys(weights).length === 0 ? undefined : weights,
213+
},
214214
},
215215
});
216216
},
@@ -240,11 +240,11 @@ export const legacyVectors = {
240240
Object.keys(config).length === 0
241241
? undefined
242242
: {
243-
...config,
244-
imageFields: imageFields?.map((f) => f.name),
245-
textFields: textFields?.map((f) => f.name),
246-
weights: Object.keys(weights).length === 0 ? undefined : weights,
247-
},
243+
...config,
244+
imageFields: imageFields?.map((f) => f.name),
245+
textFields: textFields?.map((f) => f.name),
246+
weights: Object.keys(weights).length === 0 ? undefined : weights,
247+
},
248248
},
249249
});
250250
},
@@ -274,11 +274,11 @@ export const legacyVectors = {
274274
Object.keys(config).length === 0
275275
? undefined
276276
: {
277-
...config,
278-
imageFields: imageFields?.map((f) => f.name),
279-
textFields: textFields?.map((f) => f.name),
280-
weights: Object.keys(weights).length === 0 ? undefined : weights,
281-
},
277+
...config,
278+
imageFields: imageFields?.map((f) => f.name),
279+
textFields: textFields?.map((f) => f.name),
280+
weights: Object.keys(weights).length === 0 ? undefined : weights,
281+
},
282282
},
283283
});
284284
},
@@ -309,11 +309,11 @@ export const legacyVectors = {
309309
Object.keys(config).length === 0
310310
? undefined
311311
: {
312-
...config,
313-
imageFields: imageFields?.map((f) => f.name),
314-
textFields: textFields?.map((f) => f.name),
315-
weights: Object.keys(weights).length === 0 ? undefined : weights,
316-
},
312+
...config,
313+
imageFields: imageFields?.map((f) => f.name),
314+
textFields: textFields?.map((f) => f.name),
315+
weights: Object.keys(weights).length === 0 ? undefined : weights,
316+
},
317317
},
318318
});
319319
},
@@ -413,11 +413,11 @@ export const legacyVectors = {
413413
Object.keys(config).length === 0
414414
? undefined
415415
: {
416-
...config,
417-
imageFields: imageFields?.map((f) => f.name),
418-
textFields: textFields?.map((f) => f.name),
419-
weights: Object.keys(weights).length === 0 ? undefined : weights,
420-
},
416+
...config,
417+
imageFields: imageFields?.map((f) => f.name),
418+
textFields: textFields?.map((f) => f.name),
419+
weights: Object.keys(weights).length === 0 ? undefined : weights,
420+
},
421421
},
422422
});
423423
},
@@ -813,8 +813,10 @@ export const legacyVectors = {
813813
},
814814
};
815815

816-
/** __vectors_shaded hide `vectorizeCollectionName` parameter from all constructors in `legacyVectors` where it was previously accepted.
817-
*
816+
/** __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.
818820
* */
819821
// eslint-disable-next-line @typescript-eslint/naming-convention
820822
const __vectors_shaded = {
@@ -834,8 +836,11 @@ const __vectors_shaded = {
834836
opts?: Omit<ConfigureTextVectorizerOptions<T, N, I, 'text2vec-voyageai'>, 'vectorizeCollectionName'>
835837
) => legacyVectors.text2VecVoyageAI(opts),
836838
text2VecGoogle: <T, N extends string | undefined = undefined, I extends VectorIndexType = 'hnsw'>(
837-
opts?: Omit<ConfigureTextVectorizerOptions<T, N, I, 'text2vec-google'>, 'vectorizeCollectionName'>
838-
) => legacyVectors.text2VecGoogle(opts),
839+
opts?: Omit<ConfigureTextVectorizerOptions<T, N, I, 'text2vec-google'>, 'vectorizeCollectionName'> & {
840+
model?: string;
841+
modelId?: never; // hard-deprecated in `vectors`
842+
}
843+
) => legacyVectors.text2VecGoogle({ ...opts, modelId: opts?.modelId || opts?.model }),
839844
text2VecOpenAI: <T, N extends string | undefined = undefined, I extends VectorIndexType = 'hnsw'>(
840845
opts?: Omit<ConfigureTextVectorizerOptions<T, N, I, 'text2vec-openai'>, 'vectorizeCollectionName'>
841846
) => legacyVectors.text2VecOpenAI(opts),
@@ -879,8 +884,11 @@ const __vectors_shaded = {
879884
opts?: Omit<ConfigureNonTextVectorizerOptions<N, I, 'multi2vec-jinaai'>, 'vectorizeCollectionName'>
880885
) => legacyVectors.multi2VecJinaAI(opts),
881886
multi2VecGoogle: <N extends string | undefined = undefined, I extends VectorIndexType = 'hnsw'>(
882-
opts: Omit<ConfigureNonTextVectorizerOptions<N, I, 'multi2vec-google'>, 'vectorizeCollectionName'>
883-
) => legacyVectors.multi2VecGoogle(opts),
887+
opts: Omit<ConfigureNonTextVectorizerOptions<N, I, 'multi2vec-google'>, 'vectorizeCollectionName'> & {
888+
model?: string;
889+
modelId?: never; // hard-deprecated in `vectors`
890+
}
891+
) => legacyVectors.multi2VecGoogle({ ...opts, modelId: opts.modelId || opts.model }),
884892
multi2VecVoyageAI: <N extends string | undefined = undefined, I extends VectorIndexType = 'hnsw'>(
885893
opts?: Omit<ConfigureNonTextVectorizerOptions<N, I, 'multi2vec-voyageai'>, 'vectorizeCollectionName'>
886894
) => legacyVectors.multi2VecVoyageAI(opts),
@@ -891,7 +899,10 @@ const __vectors_shaded = {
891899
* @deprecated Use `vectors` instead. */
892900
export const vectorizer = legacyVectors;
893901

894-
export const vectors = { ...legacyVectors, ...__vectors_shaded };
902+
// Remove deprecated vectorizers and module configuration parameters:
903+
// - PaLM vectorizers are called -Google now.
904+
// - __vectors_shaded hide/rename some parameters
905+
export const vectors = (({ text2VecPalm, multi2VecPalm, ...rest }) => ({ ...rest, ...__vectors_shaded }))(legacyVectors);
895906

896907
export const multiVectors = {
897908
/**

0 commit comments

Comments
 (0)