diff --git a/src/collections/config/types/vectorizer.ts b/src/collections/config/types/vectorizer.ts index 8e4690b1..50b12f59 100644 --- a/src/collections/config/types/vectorizer.ts +++ b/src/collections/config/types/vectorizer.ts @@ -25,6 +25,7 @@ export type Vectorizer = | Multi2VecPalmVectorizer | 'multi2vec-google' | 'multi2vec-jinaai' + | 'multi2multivec-jinaai' | 'multi2vec-voyageai' | 'ref2vec-centroid' | 'text2vec-aws' @@ -190,6 +191,19 @@ export type Multi2VecGoogleConfig = { }; }; +/** The configuration for multi-media-to-multi-vector vectorization using + * the jina-embeddings-v4 model + * + * See the [documentation](https://weaviate.io/developers/weaviate/model-providers/jinaai/embeddings-multimodal) for detailed usage. + */ +export type Multi2MultivecJinaAIConfig = { + /** The image fields used when vectorizing. */ + imageFields?: string[]; + + /** The text fields used when vectorizing. */ + textFields?: string[]; +}; + /** The configuration for multi-media vectorization using the Jina module. * * See the [documentation](https://weaviate.io/developers/weaviate/model-providers/jinaai/embeddings-multimodal) for detailed usage. @@ -205,7 +219,11 @@ export type Multi2VecJinaAIConfig = { model?: string; /** The text fields used when vectorizing. */ textFields?: string[]; - /** Whether the collection name is vectorized. */ + /** + * Whether the collection name is vectorized. + * + * @deprecated This parameter is not applicable and has no effect on the underlying module. + * */ vectorizeCollectionName?: boolean; /** The weights of the fields used for vectorization. */ weights?: { @@ -525,6 +543,7 @@ export type VectorizerConfig = | Multi2VecBindConfig | Multi2VecGoogleConfig | Multi2VecJinaAIConfig + | Multi2MultivecJinaAIConfig | Multi2VecPalmConfig | Multi2VecVoyageAIConfig | Ref2VecCentroidConfig @@ -556,6 +575,8 @@ export type VectorizerConfigType = V extends 'img2vec-neural' ? Multi2VecGoogleConfig : V extends 'multi2vec-jinaai' ? Multi2VecJinaAIConfig | undefined + : V extends 'multi2multivec-jinaai' + ? Multi2MultivecJinaAIConfig | undefined : V extends Multi2VecPalmVectorizer ? Multi2VecPalmConfig : V extends 'multi2vec-voyageai' diff --git a/src/collections/configure/types/vectorizer.ts b/src/collections/configure/types/vectorizer.ts index aa97b63b..d8cf8f7d 100644 --- a/src/collections/configure/types/vectorizer.ts +++ b/src/collections/configure/types/vectorizer.ts @@ -160,6 +160,13 @@ export type Multi2VecCohereConfigCreate = { vectorizeCollectionName?: boolean; }; +export type Multi2MultivecJinaAIConfigCreate = { + /** The image fields to use in vectorization. */ + imageFields?: string[]; + /** The text fields to use in vectorization. */ + textFields?: string[]; +}; + export type Multi2VecJinaAIConfigCreate = { /** The base URL to use where API requests should go. */ baseURL?: string; @@ -262,6 +269,8 @@ export type VectorizerConfigCreateType = V extends 'img2vec-neural' ? Multi2VecBindConfigCreate | undefined : V extends 'multi2vec-jinaai' ? Multi2VecJinaAIConfigCreate | undefined + : V extends 'multi2multivec-jinaai' + ? Multi2MultivecJinaAIConfigCreate | undefined : V extends 'multi2vec-palm' ? Multi2VecPalmConfigCreate : V extends 'multi2vec-google' diff --git a/src/collections/configure/unit.test.ts b/src/collections/configure/unit.test.ts index ad76544f..ac582561 100644 --- a/src/collections/configure/unit.test.ts +++ b/src/collections/configure/unit.test.ts @@ -1,3 +1,4 @@ +import { requireAtLeast } from '../../../test/version.js'; import { GenerativeAWSConfig, GenerativeAnthropicConfig, @@ -702,6 +703,28 @@ describe('Unit testing of the vectorizer factory class', () => { }); }); + requireAtLeast(1, 32, 0).it('should create the correct Multi2MultivecJinaAIConfig with values', () => { + const config = configure.multiVectors.multi2VecJinaAI({ + name: 'multi-jina', + imageFields: ['field1', 'field2'], + textFields: ['field3', 'field4'], + }); + expect(config).toEqual>({ + name: 'multi-jina', + vectorIndex: { + name: 'hnsw', + config: undefined, + }, + vectorizer: { + name: 'multi2multivec-jinaai', + config: { + imageFields: ['field1', 'field2'], + textFields: ['field3', 'field4'], + }, + }, + }); + }); + it('should create the correct Multi2VecPalmConfig type using deprecated method with defaults', () => { const config = configure.vectors.multi2VecPalm({ projectId: 'project-id', diff --git a/src/collections/configure/vectorizer.ts b/src/collections/configure/vectorizer.ts index c7cf9530..e9b50537 100644 --- a/src/collections/configure/vectorizer.ts +++ b/src/collections/configure/vectorizer.ts @@ -265,6 +265,7 @@ export const vectors = { }, }); }, + /** * Create a `VectorConfigCreate` object with the vectorizer set to `'multi2vec-jinaai'`. * @@ -848,4 +849,25 @@ export const multiVectors = { true ); }, + + /** + * Create a `VectorConfigCreate` object with the vectorizer set to `'multi2multivec-jinaai'`. + * + * See the [documentation](https://weaviate.io/developers/weaviate/model-providers/jinaai/embeddings-multimodal) for detailed usage. + * + * @param {ConfigureNonTextVectorizerOptions} [opts] The configuration options for the `multi2multivec-jinaai` vectorizer. + * @returns {VectorConfigCreate[], N, I, 'multi2multivec-jinaai'>} The configuration object. + */ + multi2VecJinaAI: ( + opts?: ConfigureNonTextVectorizerOptions + ): VectorConfigCreate => { + const { name, vectorIndexConfig, ...config } = opts || {}; + return makeVectorizer(name, { + vectorIndexConfig, + vectorizerConfig: { + name: 'multi2multivec-jinaai', + config, + }, + }); + }, };