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
169 changes: 169 additions & 0 deletions test/collection/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,66 @@ def test_basic_config():
}
},
),
(
Configure.Vectorizer.multi2vec_google(
image_fields=["image"],
text_fields=["text"],
video_fields=["video"],
project_id="project",
location="us-central1",
),
{
"multi2vec-palm": {
"imageFields": ["image"],
"textFields": ["text"],
"videoFields": ["video"],
"projectId": "project",
"location": "us-central1",
}
},
),
(
Configure.Vectorizer.multi2vec_google(
image_fields=[Multi2VecField(name="image")],
text_fields=[Multi2VecField(name="text")],
video_fields=[Multi2VecField(name="video")],
project_id="project",
location="us-central1",
),
{
"multi2vec-palm": {
"imageFields": ["image"],
"textFields": ["text"],
"videoFields": ["video"],
"projectId": "project",
"location": "us-central1",
}
},
),
(
Configure.Vectorizer.multi2vec_google(
image_fields=[Multi2VecField(name="image", weight=0.5)],
text_fields=[Multi2VecField(name="text", weight=0.5)],
video_fields=[Multi2VecField(name="video", weight=0.5)],
project_id="project",
location="us-central1",
vectorize_collection_name=False,
),
{
"multi2vec-palm": {
"imageFields": ["image"],
"textFields": ["text"],
"videoFields": ["video"],
"projectId": "project",
"location": "us-central1",
"weights": {
"imageFields": [0.5],
"textFields": [0.5],
"videoFields": [0.5],
},
}
},
),
(
Configure.Vectorizer.multi2vec_clip(
image_fields=[Multi2VecField(name="image")],
Expand Down Expand Up @@ -1922,6 +1982,32 @@ def test_vector_config_flat_pq() -> None:
}
},
),
(
[
Configure.NamedVectors.multi2vec_google(
name="test",
audio_fields=["audio"],
image_fields=["image"],
text_fields=["text"],
project_id="project",
location="us-central1",
)
],
{
"test": {
"vectorizer": {
"multi2vec-palm": {
"audioFields": ["audio"],
"imageFields": ["image"],
"textFields": ["text"],
"projectId": "project",
"location": "us-central1",
}
},
"vectorIndexType": "hnsw",
}
},
),
(
[
Configure.NamedVectors.multi2vec_bind(
Expand Down Expand Up @@ -2584,6 +2670,89 @@ def test_config_with_named_vectors(
}
},
),
(
[
Configure.Vectors.multi2vec_google(
name="test",
audio_fields=["audio"],
image_fields=["image"],
text_fields=["text"],
project_id="project",
location="us-central1",
dimensions=768,
)
],
{
"test": {
"vectorizer": {
"multi2vec-palm": {
"audioFields": ["audio"],
"imageFields": ["image"],
"textFields": ["text"],
"projectId": "project",
"location": "us-central1",
"dimensions": 768,
}
},
"vectorIndexType": "hnsw",
}
},
),
(
[
Configure.Vectors.multi2vec_google_gemini(
name="test",
audio_fields=["audio"],
image_fields=["image"],
text_fields=["text"],
dimensions=768,
)
],
{
"test": {
"vectorizer": {
"multi2vec-palm": {
"apiEndpoint": "generativelanguage.googleapis.com",
"audioFields": ["audio"],
"imageFields": ["image"],
"textFields": ["text"],
"dimensions": 768,
}
},
"vectorIndexType": "hnsw",
}
},
),
(
[
Configure.Vectors.multi2vec_google_gemini(
name="test",
audio_fields=[Multi2VecField(name="audio", weight=0.5)],
image_fields=[Multi2VecField(name="image", weight=0.5)],
text_fields=[Multi2VecField(name="text", weight=0.5)],
dimensions=768,
)
],
{
"test": {
"vectorizer": {
"multi2vec-palm": {
"apiEndpoint": "generativelanguage.googleapis.com",
"audioFields": ["audio"],
"imageFields": ["image"],
"textFields": ["text"],
"dimensions": 768,
"weights": {
"audioFields": [0.5],
"imageFields": [0.5],
"textFields": [0.5],
},
}
},
"vectorIndexType": "hnsw",
}
},
),
(
[
Configure.Vectors.multi2vec_bind(
Expand Down
4 changes: 4 additions & 0 deletions weaviate/collections/classes/config_named_vectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,7 @@ def multi2vec_palm(
vectorizer=_Multi2VecGoogleConfig(
projectId=project_id,
location=location,
audioFields=None,
imageFields=_map_multi2vec_fields(image_fields),
textFields=_map_multi2vec_fields(text_fields),
videoFields=_map_multi2vec_fields(video_fields),
Expand All @@ -607,6 +608,7 @@ def multi2vec_google(
*,
location: str,
project_id: str,
audio_fields: Optional[Union[List[str], List[Multi2VecField]]] = None,
image_fields: Optional[Union[List[str], List[Multi2VecField]]] = None,
text_fields: Optional[Union[List[str], List[Multi2VecField]]] = None,
video_fields: Optional[Union[List[str], List[Multi2VecField]]] = None,
Expand All @@ -627,6 +629,7 @@ def multi2vec_google(
vectorize_collection_name: Whether to vectorize the collection name. Defaults to `True`.
location: Where the model runs. REQUIRED.
project_id: The project ID to use, REQUIRED.
audio_fields: The audio fields to use in vectorization.
image_fields: The image fields to use in vectorization.
text_fields: The text fields to use in vectorization.
video_fields: The video fields to use in vectorization.
Expand All @@ -639,6 +642,7 @@ def multi2vec_google(
vectorizer=_Multi2VecGoogleConfig(
projectId=project_id,
location=location,
audioFields=_map_multi2vec_fields(audio_fields),
imageFields=_map_multi2vec_fields(image_fields),
textFields=_map_multi2vec_fields(text_fields),
videoFields=_map_multi2vec_fields(video_fields),
Expand Down
3 changes: 3 additions & 0 deletions weaviate/collections/classes/config_vectorizers.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,7 @@ class _Multi2VecGoogleConfig(_Multi2VecBase, _VectorizerConfigCreate):
vectorizer: Union[Vectorizers, _EnumLikeStr] = Field(
default=Vectorizers.MULTI2VEC_PALM, frozen=True, exclude=True
)
audioFields: Optional[List[Multi2VecField]]
videoFields: Optional[List[Multi2VecField]]
projectId: Optional[str]
location: Optional[str]
Expand Down Expand Up @@ -1292,6 +1293,7 @@ def multi2vec_palm(
return _Multi2VecGoogleConfig(
projectId=project_id,
location=location,
audioFields=None,
imageFields=_map_multi2vec_fields(image_fields),
textFields=_map_multi2vec_fields(text_fields),
videoFields=_map_multi2vec_fields(video_fields),
Expand Down Expand Up @@ -1333,6 +1335,7 @@ def multi2vec_google(
return _Multi2VecGoogleConfig(
projectId=project_id,
location=location,
audioFields=None,
imageFields=_map_multi2vec_fields(image_fields),
textFields=_map_multi2vec_fields(text_fields),
videoFields=_map_multi2vec_fields(video_fields),
Expand Down
6 changes: 6 additions & 0 deletions weaviate/collections/classes/config_vectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,7 @@ def multi2vec_google(
name: Optional[str] = None,
quantizer: Optional[_QuantizerConfigCreate] = None,
dimensions: Optional[int] = None,
audio_fields: Optional[Union[List[str], List[Multi2VecField]]] = None,
image_fields: Optional[Union[List[str], List[Multi2VecField]]] = None,
location: str,
model: Optional[str] = None,
Expand All @@ -1049,6 +1050,7 @@ def multi2vec_google(
name: The name of the vector.
quantizer: The quantizer to use for the vector index. If not provided, no quantization will be applied.
dimensions: The number of dimensions to use. Defaults to `None`, which uses the server-defined default.
audio_fields: The audio fields to use in vectorization.
image_fields: The image fields to use in vectorization.
location: Where the model runs. REQUIRED.
model: The model to use. Defaults to `None`, which uses the server-defined default.
Expand All @@ -1063,6 +1065,7 @@ def multi2vec_google(
vectorizer=_Multi2VecGoogleConfig(
projectId=project_id,
location=location,
audioFields=_map_multi2vec_fields(audio_fields),
imageFields=_map_multi2vec_fields(image_fields),
textFields=_map_multi2vec_fields(text_fields),
videoFields=_map_multi2vec_fields(video_fields),
Expand All @@ -1079,6 +1082,7 @@ def multi2vec_google_gemini(
name: Optional[str] = None,
quantizer: Optional[_QuantizerConfigCreate] = None,
dimensions: Optional[int] = None,
audio_fields: Optional[Union[List[str], List[Multi2VecField]]] = None,
image_fields: Optional[Union[List[str], List[Multi2VecField]]] = None,
model: Optional[str] = None,
text_fields: Optional[Union[List[str], List[Multi2VecField]]] = None,
Expand All @@ -1095,6 +1099,7 @@ def multi2vec_google_gemini(
name: The name of the vector.
quantizer: The quantizer to use for the vector index. If not provided, no quantization will be applied.
dimensions: The number of dimensions to use. Defaults to `None`, which uses the server-defined default.
audio_fields: The audio fields to use in vectorization.
image_fields: The image fields to use in vectorization.
model: The model to use. Defaults to `None`, which uses the server-defined default.
text_fields: The text fields to use in vectorization.
Expand All @@ -1108,6 +1113,7 @@ def multi2vec_google_gemini(
projectId=None,
location=None,
apiEndpoint="generativelanguage.googleapis.com",
audioFields=_map_multi2vec_fields(audio_fields),
imageFields=_map_multi2vec_fields(image_fields),
textFields=_map_multi2vec_fields(text_fields),
videoFields=_map_multi2vec_fields(video_fields),
Expand Down
Loading