Skip to content

Commit 7432188

Browse files
author
Michelangelo Partipilo
authored
Merge pull request #431 from weaviate/text2vec-digitalocean
Add text2vec-digitalocean vectorizer module
2 parents 292ed88 + c2fbd92 commit 7432188

4 files changed

Lines changed: 86 additions & 0 deletions

File tree

src/collections/config/types/vectorizer.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export type Vectorizer =
4040
| 'text2vec-huggingface'
4141
| 'text2vec-jinaai'
4242
| 'text2vec-nvidia'
43+
| 'text2vec-digitalocean'
4344
| 'text2vec-mistral'
4445
| 'text2vec-model2vec'
4546
| 'text2vec-morph'
@@ -524,6 +525,20 @@ export type Text2VecMistralConfig = {
524525
vectorizeCollectionName?: boolean;
525526
};
526527

528+
/**
529+
* The configuration for text vectorization using the DigitalOcean module.
530+
*
531+
* See the [documentation](https://weaviate.io/developers/weaviate/model-providers/digitalocean/embeddings) for detailed usage.
532+
*/
533+
export type Text2VecDigitalOceanConfig = {
534+
/** The base URL to use where API requests should go. Defaults to `https://inference.do-ai.run` on the server. */
535+
baseURL?: string;
536+
/** The model to use, e.g. `qwen3-embedding-0.6b`. Required by the server. */
537+
model: string;
538+
/** Whether to vectorize the collection name. */
539+
vectorizeCollectionName?: boolean;
540+
};
541+
527542
/**
528543
* The configuration for text vectorization using the Ollama module.
529544
*
@@ -741,6 +756,8 @@ export type VectorizerConfigType<V> = V extends 'img2vec-neural'
741756
? Text2VecJinaAIConfig | undefined
742757
: V extends 'text2vec-nvidia'
743758
? Text2VecNvidiaConfig | undefined
759+
: V extends 'text2vec-digitalocean'
760+
? Text2VecDigitalOceanConfig | undefined
744761
: V extends 'text2vec-mistral'
745762
? Text2VecMistralConfig | undefined
746763
: V extends 'text2vec-model2vec'

src/collections/configure/types/vectorizer.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
Text2VecCohereConfig,
2121
Text2VecContextionaryConfig,
2222
Text2VecDatabricksConfig,
23+
Text2VecDigitalOceanConfig,
2324
Text2VecGPT4AllConfig,
2425
Text2VecGoogleConfig,
2526
Text2VecGoogleGeminiConfig,
@@ -268,6 +269,8 @@ export type Text2VecJinaAIConfigCreate = Text2VecJinaAIConfig;
268269

269270
export type Text2VecNvidiaConfigCreate = Text2VecNvidiaConfig;
270271

272+
export type Text2VecDigitalOceanConfigCreate = Text2VecDigitalOceanConfig;
273+
271274
export type Text2VecMistralConfigCreate = Text2VecMistralConfig;
272275

273276
export type Text2VecModel2VecConfigCreate = Text2VecModel2Vec;
@@ -338,6 +341,8 @@ export type VectorizerConfigCreateType<V> = V extends 'img2vec-neural'
338341
? Text2VecJinaAIConfigCreate | undefined
339342
: V extends 'text2vec-nvidia'
340343
? Text2VecNvidiaConfigCreate | undefined
344+
: V extends 'text2vec-digitalocean'
345+
? Text2VecDigitalOceanConfigCreate | undefined
341346
: V extends 'text2vec-mistral'
342347
? Text2VecMistralConfigCreate | undefined
343348
: V extends 'text2vec-model2vec'

src/collections/configure/unit.test.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,6 +1422,45 @@ describe('Unit testing of the vectorizer factory class', () => {
14221422
});
14231423
});
14241424

1425+
it('should create the correct Text2VecDigitalOceanConfig type with only the required model', () => {
1426+
const config = configure.vectors.text2VecDigitalOcean({ model: 'qwen3-embedding-0.6b' });
1427+
expect(config).toEqual<VectorConfigCreate<never, undefined, 'hnsw', 'text2vec-digitalocean'>>({
1428+
name: undefined,
1429+
vectorIndex: {
1430+
name: 'hnsw',
1431+
config: undefined,
1432+
},
1433+
vectorizer: {
1434+
name: 'text2vec-digitalocean',
1435+
config: {
1436+
model: 'qwen3-embedding-0.6b',
1437+
},
1438+
},
1439+
});
1440+
});
1441+
1442+
it('should create the correct Text2VecDigitalOceanConfig type with all values', () => {
1443+
const config = configure.vectors.text2VecDigitalOcean({
1444+
baseURL: 'https://inference.do-ai.run',
1445+
name: 'test',
1446+
model: 'qwen3-embedding-0.6b',
1447+
});
1448+
expect(config).toEqual<VectorConfigCreate<never, 'test', 'hnsw', 'text2vec-digitalocean'>>({
1449+
name: 'test',
1450+
vectorIndex: {
1451+
name: 'hnsw',
1452+
config: undefined,
1453+
},
1454+
vectorizer: {
1455+
name: 'text2vec-digitalocean',
1456+
config: {
1457+
baseURL: 'https://inference.do-ai.run',
1458+
model: 'qwen3-embedding-0.6b',
1459+
},
1460+
},
1461+
});
1462+
});
1463+
14251464
it('should create the correct Text2VecOllamaConfig type with defaults', () => {
14261465
const config = configure.vectors.text2VecOllama();
14271466
expect(config).toEqual<VectorConfigCreate<never, undefined, 'hnsw', 'text2vec-ollama'>>({

src/collections/configure/vectorizer.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,28 @@ const legacyVectors = {
637637
},
638638
});
639639
},
640+
/**
641+
* Create a `VectorConfigCreate` object with the vectorizer set to `'text2vec-digitalocean'`.
642+
*
643+
* See the [documentation](https://weaviate.io/developers/weaviate/model-providers/digitalocean/embeddings) for detailed usage.
644+
*
645+
* @param {ConfigureTextVectorizerOptions<T, N, I, 'text2vec-digitalocean'>} opts The configuration for the `text2vec-digitalocean` vectorizer. `model` is required by the server.
646+
* @returns {VectorConfigCreate<PrimitiveKeys<T>, N, I, 'text2vec-digitalocean'>} The configuration object.
647+
*/
648+
text2VecDigitalOcean: <T, N extends string | undefined = undefined, I extends VectorIndexType = 'hnsw'>(
649+
opts: ConfigureTextVectorizerOptions<T, N, I, 'text2vec-digitalocean'>
650+
): VectorConfigCreate<PrimitiveKeys<T>, N, I, 'text2vec-digitalocean'> => {
651+
const { name, quantizer, sourceProperties, vectorIndexConfig, ...config } = opts;
652+
return makeVectorizer(name, {
653+
quantizer,
654+
sourceProperties,
655+
vectorIndexConfig,
656+
vectorizerConfig: {
657+
name: 'text2vec-digitalocean',
658+
config: Object.keys(config).length === 0 ? undefined : config,
659+
},
660+
});
661+
},
640662
/**
641663
* Create a `VectorConfigCreate` object with the vectorizer set to `'text2vec-mistral'`.
642664
*
@@ -882,6 +904,9 @@ const __vectors_shaded = {
882904
text2VecOllama: <T, N extends string | undefined = undefined, I extends VectorIndexType = 'hnsw'>(
883905
opts?: Omit<ConfigureTextVectorizerOptions<T, N, I, 'text2vec-ollama'>, 'vectorizeCollectionName'>
884906
) => legacyVectors.text2VecOllama(opts),
907+
text2VecDigitalOcean: <T, N extends string | undefined = undefined, I extends VectorIndexType = 'hnsw'>(
908+
opts: Omit<ConfigureTextVectorizerOptions<T, N, I, 'text2vec-digitalocean'>, 'vectorizeCollectionName'>
909+
) => legacyVectors.text2VecDigitalOcean(opts),
885910
text2VecMistral: <T, N extends string | undefined = undefined, I extends VectorIndexType = 'hnsw'>(
886911
opts?: Omit<ConfigureTextVectorizerOptions<T, N, I, 'text2vec-mistral'>, 'vectorizeCollectionName'>
887912
) => legacyVectors.text2VecMistral(opts),

0 commit comments

Comments
 (0)