Skip to content

Commit ef70fc2

Browse files
committed
Add missing modules and module params for
- `baseURL` in `generative-anthropic` - `videoIntervalSeconds` in `multi2vec-google` - `outputEncoding` in `Multi2VecVoyageAIConfig` - the entire `text2vec-nvidia` module
1 parent 2c53fd2 commit ef70fc2

File tree

5 files changed

+83
-0
lines changed

5 files changed

+83
-0
lines changed

src/collections/config/types/generative.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export type GenerativeAWSConfig = {
1515
};
1616

1717
export type GenerativeAnthropicConfig = {
18+
baseURL?: string;
1819
maxTokens?: number;
1920
model?: string;
2021
stopSequences?: string[];

src/collections/config/types/vectorizer.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export type Vectorizer =
3535
| 'text2vec-gpt4all'
3636
| 'text2vec-huggingface'
3737
| 'text2vec-jinaai'
38+
| 'text2vec-nvidia'
3839
| 'text2vec-mistral'
3940
| 'text2vec-ollama'
4041
| 'text2vec-openai'
@@ -169,6 +170,8 @@ export type Multi2VecGoogleConfig = {
169170
textFields?: string[];
170171
/** The video fields used when vectorizing. */
171172
videoFields?: string[];
173+
/** Length of a video interval in seconds. */
174+
videoIntervalSeconds?: number;
172175
/** The model ID in use. */
173176
modelId?: string;
174177
/** The dimensionality of the vector once embedded. */
@@ -223,6 +226,8 @@ export type Multi2VecVoyageAIConfig = {
223226
imageFields?: string[];
224227
/** The model to use. */
225228
model?: string;
229+
/** How the output from the model should be encoded on return. */
230+
outputEncoding?: string;
226231
/** The text fields used when vectorizing. */
227232
textFields?: string[];
228233
/** Whether the input should be truncated to fit in the context window. */
@@ -363,6 +368,22 @@ export type Text2VecJinaAIConfig = {
363368
/** @deprecated Use `Text2VecJinaAIConfig` instead. */
364369
export type Text2VecJinaConfig = Text2VecJinaAIConfig;
365370

371+
/**
372+
* The configuration for text vectorization using the Nvidia module.
373+
*
374+
* See the [documentation](https://weaviate.io/developers/weaviate/model-providers/nvidia/embeddings) for detailed usage.
375+
*/
376+
export type Text2VecNvidiaConfig = {
377+
/** The base URL to use where API requests should go. */
378+
baseURL?: string;
379+
/** The model to use. */
380+
model?: string;
381+
/** Whether to truncate when vectorising. */
382+
truncate?: boolean;
383+
/** Whether to vectorize the collection name. */
384+
vectorizeCollectionName?: boolean;
385+
};
386+
366387
/**
367388
* The configuration for text vectorization using the Mistral module.
368389
*
@@ -541,6 +562,8 @@ export type VectorizerConfigType<V> = V extends 'img2vec-neural'
541562
? Text2VecHuggingFaceConfig | undefined
542563
: V extends 'text2vec-jinaai'
543564
? Text2VecJinaAIConfig | undefined
565+
: V extends 'text2vec-nvidia'
566+
? Text2VecNvidiaConfig | undefined
544567
: V extends 'text2vec-mistral'
545568
? Text2VecMistralConfig | undefined
546569
: V extends 'text2vec-ollama'

src/collections/configure/types/vectorizer.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
Text2VecHuggingFaceConfig,
1414
Text2VecJinaAIConfig,
1515
Text2VecMistralConfig,
16+
Text2VecNvidiaConfig,
1617
Text2VecOllamaConfig,
1718
Text2VecOpenAIConfig,
1819
Text2VecTransformersConfig,
@@ -198,6 +199,8 @@ export type Text2VecHuggingFaceConfigCreate = Text2VecHuggingFaceConfig;
198199

199200
export type Text2VecJinaAIConfigCreate = Text2VecJinaAIConfig;
200201

202+
export type Text2VecNvidiaConfigCreate = Text2VecNvidiaConfig;
203+
201204
export type Text2VecMistralConfigCreate = Text2VecMistralConfig;
202205

203206
export type Text2VecOllamaConfigCreate = Text2VecOllamaConfig;
@@ -247,6 +250,8 @@ export type VectorizerConfigCreateType<V> = V extends 'img2vec-neural'
247250
? Text2VecHuggingFaceConfigCreate | undefined
248251
: V extends 'text2vec-jinaai'
249252
? Text2VecJinaAIConfigCreate | undefined
253+
: V extends 'text2vec-nvidia'
254+
? Text2VecNvidiaConfigCreate | undefined
250255
: V extends 'text2vec-mistral'
251256
? Text2VecMistralConfigCreate | undefined
252257
: V extends 'text2vec-ollama'

src/collections/configure/unit.test.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,6 +1161,47 @@ describe('Unit testing of the vectorizer factory class', () => {
11611161
});
11621162
});
11631163

1164+
it('should create the correct Text2VecNvidiaConfig type with defaults', () => {
1165+
const config = configure.vectorizer.text2VecNvidia();
1166+
expect(config).toEqual<VectorConfigCreate<never, undefined, 'hnsw', 'text2vec-nvidia'>>({
1167+
name: undefined,
1168+
vectorIndex: {
1169+
name: 'hnsw',
1170+
config: undefined,
1171+
},
1172+
vectorizer: {
1173+
name: 'text2vec-nvidia',
1174+
config: undefined,
1175+
},
1176+
});
1177+
});
1178+
1179+
it('should create the correct Text2VecNvidiaConfig type with all values', () => {
1180+
const config = configure.vectorizer.text2VecNvidia({
1181+
name: 'test',
1182+
baseURL: 'base-url',
1183+
model: 'model',
1184+
truncate: true,
1185+
vectorizeCollectionName: true,
1186+
});
1187+
expect(config).toEqual<VectorConfigCreate<never, 'test', 'hnsw', 'text2vec-nvidia'>>({
1188+
name: 'test',
1189+
vectorIndex: {
1190+
name: 'hnsw',
1191+
config: undefined,
1192+
},
1193+
vectorizer: {
1194+
name: 'text2vec-nvidia',
1195+
config: {
1196+
baseURL: 'base-url',
1197+
model: 'model',
1198+
truncate: true,
1199+
vectorizeCollectionName: true,
1200+
},
1201+
},
1202+
});
1203+
});
1204+
11641205
it('should create the correct Text2VecMistralConfig type with defaults', () => {
11651206
const config = configure.vectorizer.text2VecMistral();
11661207
expect(config).toEqual<VectorConfigCreate<never, undefined, 'hnsw', 'text2vec-mistral'>>({

src/collections/configure/vectorizer.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,19 @@ export const vectorizer = {
518518
},
519519
});
520520
},
521+
text2VecNvidia: <T, N extends string | undefined = undefined, I extends VectorIndexType = 'hnsw'>(
522+
opts?: ConfigureTextVectorizerOptions<T, N, I, 'text2vec-nvidia'>
523+
): VectorConfigCreate<PrimitiveKeys<T>, N, I, 'text2vec-nvidia'> => {
524+
const { name, sourceProperties, vectorIndexConfig, ...config } = opts || {};
525+
return makeVectorizer(name, {
526+
sourceProperties,
527+
vectorIndexConfig,
528+
vectorizerConfig: {
529+
name: 'text2vec-nvidia',
530+
config: Object.keys(config).length === 0 ? undefined : config,
531+
},
532+
});
533+
},
521534
/**
522535
* Create a `VectorConfigCreate` object with the vectorizer set to `'text2vec-mistral'`.
523536
*

0 commit comments

Comments
 (0)