Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion src/collections/config/types/vectorizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export type Vectorizer =
| Multi2VecPalmVectorizer
| 'multi2vec-google'
| 'multi2vec-jinaai'
| 'multi2multivec-jinaai'
| 'multi2vec-voyageai'
| 'ref2vec-centroid'
| 'text2vec-aws'
Expand Down Expand Up @@ -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.
Expand All @@ -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?: {
Expand Down Expand Up @@ -525,6 +543,7 @@ export type VectorizerConfig =
| Multi2VecBindConfig
| Multi2VecGoogleConfig
| Multi2VecJinaAIConfig
| Multi2MultivecJinaAIConfig
| Multi2VecPalmConfig
| Multi2VecVoyageAIConfig
| Ref2VecCentroidConfig
Expand Down Expand Up @@ -556,6 +575,8 @@ export type VectorizerConfigType<V> = 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'
Expand Down
9 changes: 9 additions & 0 deletions src/collections/configure/types/vectorizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -262,6 +269,8 @@ export type VectorizerConfigCreateType<V> = 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'
Expand Down
23 changes: 23 additions & 0 deletions src/collections/configure/unit.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { requireAtLeast } from '../../../test/version.js';
import {
GenerativeAWSConfig,
GenerativeAnthropicConfig,
Expand Down Expand Up @@ -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.vectorizer.multi2MultivecJinaAI({
name: 'multi-jina',
imageFields: ['field1', 'field2'],
textFields: ['field3', 'field4'],
});
expect(config).toEqual<VectorConfigCreate<never, string, 'hnsw', 'multi2multivec-jinaai'>>({
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',
Expand Down
22 changes: 22 additions & 0 deletions src/collections/configure/vectorizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,28 @@ export const vectors = {
},
});
},

/**
* Create a `VectorConfigCreate` object with the vectorizer set to `'multi2vec-jinaai'`.
*
* See the [documentation](https://weaviate.io/developers/weaviate/model-providers/jinaai/embeddings-multimodal) for detailed usage.
*
* @param {ConfigureNonTextVectorizerOptions<N, I, 'multi2multivec-jinaai'>} [opts] The configuration options for the `multi2multivec-jinaai` vectorizer.
* @returns {VectorConfigCreate<PrimitiveKeys<T>[], N, I, 'multi2multivec-jinaai'>} The configuration object.
*/
multi2MultivecJinaAI: <N extends string | undefined = undefined, I extends VectorIndexType = 'hnsw'>(
opts?: ConfigureNonTextVectorizerOptions<N, I, 'multi2multivec-jinaai'>
): VectorConfigCreate<never, N, I, 'multi2multivec-jinaai'> => {
const { name, vectorIndexConfig, ...config } = opts || {};
return makeVectorizer(name, {
vectorIndexConfig,
vectorizerConfig: {
name: 'multi2multivec-jinaai',
config,
},
});
},

/**
* Create a `VectorConfigCreate` object with the vectorizer set to `'multi2vec-jinaai'`.
*
Expand Down