Skip to content

Commit 7d68378

Browse files
authored
Merge pull request #321 from weaviate/chore/vector-syntax-amendments
Fix breaking changes from v3.7.0 release
2 parents b67016e + 39c6572 commit 7d68378

File tree

13 files changed

+319
-112
lines changed

13 files changed

+319
-112
lines changed

src/alias/journey.test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ requireAtLeast(1, 32, 0).describe('manages collection aliases', () => {
2121
.then((aliases) => {
2222
expect(aliases).not.toBeUndefined();
2323
expect(aliases).toHaveLength(2);
24-
expect(aliases).toEqual<Alias[]>([
25-
{ collection: 'PaulHewson', alias: 'Bono' },
26-
{ collection: 'GeorgeBarnes', alias: 'MachineGunKelly' },
27-
]);
24+
expect(aliases).toEqual(
25+
expect.arrayContaining<Alias>([
26+
{ collection: 'PaulHewson', alias: 'Bono' },
27+
{ collection: 'GeorgeBarnes', alias: 'MachineGunKelly' },
28+
])
29+
);
2830
});
2931
});
3032

src/collections/aggregate/integration.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ describe('Testing of the collection.aggregate methods', () => {
9090
// },
9191
],
9292
vectorizers: weaviate.configure.vectors.text2VecContextionary({
93-
vectorizeCollectionName: false,
9493
vectorIndexConfig: weaviate.configure.vectorIndex.hnsw({ maxConnections: 64 }),
9594
}),
9695
})

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: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ type Text2VecPalmVectorizer = 'text2vec-palm';
1919

2020
export type Vectorizer =
2121
| 'img2vec-neural'
22+
| 'multi2vec-nvidia'
2223
| 'multi2vec-clip'
2324
| 'multi2vec-cohere'
2425
| 'multi2vec-bind'
@@ -65,6 +66,32 @@ export type Multi2VecField = {
6566
weight?: number;
6667
};
6768

69+
/** The configuration for multi-media vectorization using the NVIDIA module.
70+
*
71+
* See the [documentation](https://weaviate.io/developers/weaviate/model-providers/nvidia/embeddings-multimodal) for detailed usage.
72+
*/
73+
export type Multi2VecNvidiaConfig = {
74+
/** The model to use. Defaults to `None`, which uses the server-defined default. */
75+
model?: string;
76+
/** The base URL where API requests should go. */
77+
baseURL?: string;
78+
/** Whether to apply truncation. */
79+
truncation?: boolean;
80+
/** Format in which the embeddings are encoded. Defaults to `None`, so the embeddings are represented as a list of floating-point numbers. */
81+
output_encoding?: string;
82+
/** The image fields used when vectorizing. */
83+
imageFields?: string[];
84+
/** The text fields used when vectorizing. */
85+
textFields?: string[];
86+
/** The weights of the fields used for vectorization. */
87+
weights?: {
88+
/** The weights of the image fields. */
89+
imageFields?: number[];
90+
/** The weights of the text fields. */
91+
textFields?: number[];
92+
};
93+
};
94+
6895
/** The configuration for multi-media vectorization using the CLIP module.
6996
*
7097
* See the [documentation](https://weaviate.io/developers/weaviate/model-providers/transformers/embeddings-multimodal) for detailed usage.
@@ -175,6 +202,9 @@ export type Multi2VecGoogleConfig = {
175202
/** Length of a video interval in seconds. */
176203
videoIntervalSeconds?: number;
177204
/** The model ID in use. */
205+
model?: string;
206+
/** The model ID in use.
207+
* @deprecated Use `model` instead.*/
178208
modelId?: string;
179209
/** The dimensionality of the vector once embedded. */
180210
dimensions?: number;
@@ -393,8 +423,6 @@ export type Text2MultiVecJinaAIConfig = {
393423
dimensions?: number;
394424
/** The model to use. */
395425
model?: string;
396-
/** Whether to vectorize the collection name. */
397-
vectorizeCollectionName?: boolean;
398426
};
399427

400428
/** @deprecated Use `Text2VecJinaAIConfig` instead. */
@@ -476,6 +504,9 @@ export type Text2VecGoogleConfig = {
476504
/** The API endpoint to use without a leading scheme such as `http://`. */
477505
apiEndpoint?: string;
478506
/** The model ID to use. */
507+
model?: string;
508+
/** The model ID to use.
509+
* @deprecated Use `model `instead.*/
479510
modelId?: string;
480511
/** The project ID to use. */
481512
projectId?: string;
@@ -565,6 +596,8 @@ export type VectorizerConfig =
565596

566597
export type VectorizerConfigType<V> = V extends 'img2vec-neural'
567598
? Img2VecNeuralConfig | undefined
599+
: V extends 'multi2vec-nvidia'
600+
? Multi2VecNvidiaConfig | undefined
568601
: V extends 'multi2vec-clip'
569602
? Multi2VecClipConfig | undefined
570603
: V extends 'multi2vec-cohere'

src/collections/configure/generative.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,14 @@ export default {
246246
console.warn('The `generative-palm` module is deprecated. Use `generative-google` instead.');
247247
return {
248248
name: 'generative-palm',
249-
config,
249+
// Do not populate config key if config === undefined.
250+
config: config
251+
? {
252+
...config,
253+
// Only create modelId key if either config.model or config.modelId are defined.
254+
...(config?.modelId || config?.model ? { modelId: config?.model ?? config?.model } : undefined),
255+
}
256+
: undefined,
250257
};
251258
},
252259
/**
@@ -262,7 +269,14 @@ export default {
262269
): ModuleConfig<'generative-google', GenerativeGoogleConfig | undefined> => {
263270
return {
264271
name: 'generative-google',
265-
config,
272+
// Do not populate config key if config === undefined.
273+
config: config
274+
? {
275+
...config,
276+
// Only create modelId key if either config.model or config.modelId are defined.
277+
...(config?.modelId || config?.model ? { modelId: config?.model ?? config?.model } : undefined),
278+
}
279+
: undefined,
266280
};
267281
},
268282
/**

src/collections/configure/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
import generative from './generative.js';
1616
import reranker from './reranker.js';
1717
import { configure as configureVectorIndex, reconfigure as reconfigureVectorIndex } from './vectorIndex.js';
18-
import { multiVectors, vectors } from './vectorizer.js';
18+
import { multiVectors, vectorizer, vectors } from './vectorizer.js';
1919

2020
import { parseWithDefault } from './parsing.js';
2121

@@ -61,9 +61,9 @@ const configure = {
6161
multiVectors,
6262
reranker,
6363
/**
64-
* @deprecated Use `vectors` instead.
64+
* @deprecated Use `configure.vectors` instead.
6565
*/
66-
vectorizer: vectors,
66+
vectorizer: vectorizer,
6767
vectors,
6868
vectorIndex: configureVectorIndex,
6969
dataType,
@@ -311,5 +311,6 @@ export {
311311
tokenization,
312312
vectorDistances,
313313
configureVectorIndex as vectorIndex,
314+
vectorizer,
314315
vectors,
315316
};

src/collections/configure/types/vectorizer.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,37 @@ export type ConfigureTextMultiVectorizerOptions<
112112

113113
export type Img2VecNeuralConfigCreate = Img2VecNeuralConfig;
114114

115+
// model: Optional[str] = None,
116+
// truncation: Optional[bool] = None,
117+
// output_encoding: Optional[str],
118+
// vectorize_collection_name: bool = True,
119+
// base_url: Optional[AnyHttpUrl] = None,
120+
// image_fields: Optional[Union[List[str], List[Multi2VecField]]] = None,
121+
// text_fields: Optional[Union[List[str], List[Multi2VecField]]] = None,
122+
123+
// model: The model to use. Defaults to `None`, which uses the server-defined default.
124+
// output_encoding: Format in which the embeddings are encoded. Defaults to `None`, so the embeddings are represented as a list of floating-point numbers.
125+
// vectorize_collection_name: Whether to vectorize the collection name. Defaults to `True`.
126+
// base_url: The base URL to use where API requests should go. Defaults to `None`, which uses the server-defined default.
127+
// image_fields: The image fields to use in vectorization.
128+
// text_fields: The text fields to use in vectorization.
129+
130+
/** The configuration for the `multi2vec-nvidia` vectorizer. */
131+
export type Multi2VecNvidiaConfigCreate = {
132+
/** The model to use. Defaults to `None`, which uses the server-defined default. */
133+
model?: string;
134+
/** The base URL where API requests should go. */
135+
baseURL?: string;
136+
/** Whether to apply truncation. */
137+
truncation?: boolean;
138+
/** Format in which the embeddings are encoded. Defaults to `None`, so the embeddings are represented as a list of floating-point numbers. */
139+
outputEncoding?: string;
140+
/** The image fields to use in vectorization. Can be string of `Multi2VecField` type. If string, weight 0 will be assumed. */
141+
imageFields?: string[] | Multi2VecField[];
142+
/** The text fields to use in vectorization. Can be string of `Multi2VecField` type. If string, weight 0 will be assumed. */
143+
textFields?: string[] | Multi2VecField[];
144+
};
145+
115146
/** The configuration for the `multi2vec-clip` vectorizer. */
116147
export type Multi2VecClipConfigCreate = {
117148
/** The image fields to use in vectorization. Can be string of `Multi2VecField` type. If string, weight 0 will be assumed. */
@@ -261,6 +292,8 @@ export type Text2MultiVecJinaAIConfigCreate = Text2MultiVecJinaAIConfig;
261292

262293
export type VectorizerConfigCreateType<V> = V extends 'img2vec-neural'
263294
? Img2VecNeuralConfigCreate | undefined
295+
: V extends 'multi2vec-nvidia'
296+
? Multi2VecNvidiaConfigCreate | undefined
264297
: V extends 'multi2vec-clip'
265298
? Multi2VecClipConfigCreate | undefined
266299
: V extends 'multi2vec-cohere'

0 commit comments

Comments
 (0)