Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 6 additions & 4 deletions src/alias/journey.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ requireAtLeast(1, 32, 0).describe('manages collection aliases', () => {
.then((aliases) => {
expect(aliases).not.toBeUndefined();
expect(aliases).toHaveLength(2);
expect(aliases).toEqual<Alias[]>([
{ collection: 'PaulHewson', alias: 'Bono' },
{ collection: 'GeorgeBarnes', alias: 'MachineGunKelly' },
]);
expect(aliases).toEqual(
expect.arrayContaining<Alias>([
{ collection: 'PaulHewson', alias: 'Bono' },
{ collection: 'GeorgeBarnes', alias: 'MachineGunKelly' },
])
);
});
});

Expand Down
1 change: 0 additions & 1 deletion src/collections/aggregate/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ describe('Testing of the collection.aggregate methods', () => {
// },
],
vectorizers: weaviate.configure.vectors.text2VecContextionary({
vectorizeCollectionName: false,
vectorIndexConfig: weaviate.configure.vectorIndex.hnsw({ maxConnections: 64 }),
}),
})
Expand Down
2 changes: 2 additions & 0 deletions src/collections/config/types/generative.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ export type GenerativePaLMConfig = GenerativeGoogleConfig;
export type GenerativeGoogleConfig = {
apiEndpoint?: string;
maxOutputTokens?: number;
model?: string;
/** @deprecated Use `model` instead. */
modelId?: string;
projectId?: string;
temperature?: number;
Expand Down
37 changes: 35 additions & 2 deletions src/collections/config/types/vectorizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type Text2VecPalmVectorizer = 'text2vec-palm';

export type Vectorizer =
| 'img2vec-neural'
| 'multi2vec-nvidia'
| 'multi2vec-clip'
| 'multi2vec-cohere'
| 'multi2vec-bind'
Expand Down Expand Up @@ -65,6 +66,32 @@ export type Multi2VecField = {
weight?: number;
};

/** The configuration for multi-media vectorization using the NVIDIA module.
*
* See the [documentation](https://weaviate.io/developers/weaviate/model-providers/nvidia/embeddings-multimodal) for detailed usage.
*/
export type Multi2VecNvidiaConfig = {
/** The model to use. Defaults to `None`, which uses the server-defined default. */
model?: string;
/** The base URL where API requests should go. */
baseURL?: string;
/** Whether to apply truncation. */
truncation?: boolean;
/** Format in which the embeddings are encoded. Defaults to `None`, so the embeddings are represented as a list of floating-point numbers. */
output_encoding?: string;
/** The image fields used when vectorizing. */
imageFields?: string[];
/** The text fields used when vectorizing. */
textFields?: string[];
/** The weights of the fields used for vectorization. */
weights?: {
/** The weights of the image fields. */
imageFields?: number[];
/** The weights of the text fields. */
textFields?: number[];
};
};

/** The configuration for multi-media vectorization using the CLIP module.
*
* See the [documentation](https://weaviate.io/developers/weaviate/model-providers/transformers/embeddings-multimodal) for detailed usage.
Expand Down Expand Up @@ -175,6 +202,9 @@ export type Multi2VecGoogleConfig = {
/** Length of a video interval in seconds. */
videoIntervalSeconds?: number;
/** The model ID in use. */
model?: string;
/** The model ID in use.
* @deprecated Use `model` instead.*/
modelId?: string;
/** The dimensionality of the vector once embedded. */
dimensions?: number;
Expand Down Expand Up @@ -393,8 +423,6 @@ export type Text2MultiVecJinaAIConfig = {
dimensions?: number;
/** The model to use. */
model?: string;
/** Whether to vectorize the collection name. */
vectorizeCollectionName?: boolean;
};

/** @deprecated Use `Text2VecJinaAIConfig` instead. */
Expand Down Expand Up @@ -476,6 +504,9 @@ export type Text2VecGoogleConfig = {
/** The API endpoint to use without a leading scheme such as `http://`. */
apiEndpoint?: string;
/** The model ID to use. */
model?: string;
/** The model ID to use.
* @deprecated Use `model `instead.*/
modelId?: string;
/** The project ID to use. */
projectId?: string;
Expand Down Expand Up @@ -565,6 +596,8 @@ export type VectorizerConfig =

export type VectorizerConfigType<V> = V extends 'img2vec-neural'
? Img2VecNeuralConfig | undefined
: V extends 'multi2vec-nvidia'
? Multi2VecNvidiaConfig | undefined
: V extends 'multi2vec-clip'
? Multi2VecClipConfig | undefined
: V extends 'multi2vec-cohere'
Expand Down
18 changes: 16 additions & 2 deletions src/collections/configure/generative.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,14 @@ export default {
console.warn('The `generative-palm` module is deprecated. Use `generative-google` instead.');
return {
name: 'generative-palm',
config,
// Do not populate config key if config === undefined.
config: config
? {
...config,
// Only create modelId key if either config.model or config.modelId are defined.
...(config?.modelId || config?.model ? { modelId: config?.model ?? config?.model } : undefined),
}
: undefined,
};
},
/**
Expand All @@ -262,7 +269,14 @@ export default {
): ModuleConfig<'generative-google', GenerativeGoogleConfig | undefined> => {
return {
name: 'generative-google',
config,
// Do not populate config key if config === undefined.
config: config
? {
...config,
// Only create modelId key if either config.model or config.modelId are defined.
...(config?.modelId || config?.model ? { modelId: config?.model ?? config?.model } : undefined),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This syntax is fairly dense. My intention was to copy the model name into the modelId variable (for b/c) but preserve the previous behavior for config === undefined

}
: undefined,
};
},
/**
Expand Down
7 changes: 4 additions & 3 deletions src/collections/configure/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
import generative from './generative.js';
import reranker from './reranker.js';
import { configure as configureVectorIndex, reconfigure as reconfigureVectorIndex } from './vectorIndex.js';
import { multiVectors, vectors } from './vectorizer.js';
import { multiVectors, vectorizer, vectors } from './vectorizer.js';

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

Expand Down Expand Up @@ -61,9 +61,9 @@ const configure = {
multiVectors,
reranker,
/**
* @deprecated Use `vectors` instead.
* @deprecated Use `configure.vectors` instead.
*/
vectorizer: vectors,
vectorizer: vectorizer,
vectors,
vectorIndex: configureVectorIndex,
dataType,
Expand Down Expand Up @@ -311,5 +311,6 @@ export {
tokenization,
vectorDistances,
configureVectorIndex as vectorIndex,
vectorizer,
vectors,
};
33 changes: 33 additions & 0 deletions src/collections/configure/types/vectorizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,37 @@ export type ConfigureTextMultiVectorizerOptions<

export type Img2VecNeuralConfigCreate = Img2VecNeuralConfig;

// model: Optional[str] = None,
// truncation: Optional[bool] = None,
// output_encoding: Optional[str],
// vectorize_collection_name: bool = True,
// base_url: Optional[AnyHttpUrl] = None,
// image_fields: Optional[Union[List[str], List[Multi2VecField]]] = None,
// text_fields: Optional[Union[List[str], List[Multi2VecField]]] = None,

// model: The model to use. Defaults to `None`, which uses the server-defined default.
// output_encoding: Format in which the embeddings are encoded. Defaults to `None`, so the embeddings are represented as a list of floating-point numbers.
// vectorize_collection_name: Whether to vectorize the collection name. Defaults to `True`.
// base_url: The base URL to use where API requests should go. Defaults to `None`, which uses the server-defined default.
// image_fields: The image fields to use in vectorization.
// text_fields: The text fields to use in vectorization.

/** The configuration for the `multi2vec-nvidia` vectorizer. */
export type Multi2VecNvidiaConfigCreate = {
/** The model to use. Defaults to `None`, which uses the server-defined default. */
model?: string;
/** The base URL where API requests should go. */
baseURL?: string;
/** Whether to apply truncation. */
truncation?: boolean;
/** Format in which the embeddings are encoded. Defaults to `None`, so the embeddings are represented as a list of floating-point numbers. */
outputEncoding?: string;
/** The image fields to use in vectorization. Can be string of `Multi2VecField` type. If string, weight 0 will be assumed. */
imageFields?: string[] | Multi2VecField[];
/** The text fields to use in vectorization. Can be string of `Multi2VecField` type. If string, weight 0 will be assumed. */
textFields?: string[] | Multi2VecField[];
};

/** The configuration for the `multi2vec-clip` vectorizer. */
export type Multi2VecClipConfigCreate = {
/** The image fields to use in vectorization. Can be string of `Multi2VecField` type. If string, weight 0 will be assumed. */
Expand Down Expand Up @@ -261,6 +292,8 @@ export type Text2MultiVecJinaAIConfigCreate = Text2MultiVecJinaAIConfig;

export type VectorizerConfigCreateType<V> = V extends 'img2vec-neural'
? Img2VecNeuralConfigCreate | undefined
: V extends 'multi2vec-nvidia'
? Multi2VecNvidiaConfigCreate | undefined
: V extends 'multi2vec-clip'
? Multi2VecClipConfigCreate | undefined
: V extends 'multi2vec-cohere'
Expand Down
Loading