Skip to content

Commit 344590c

Browse files
authored
Merge pull request #2078 from weaviate/feat/text2vec-aws-dimensions
feat(config): add optional dimensions to text2vec-aws vectorizer
2 parents dffcdcb + 0e8620b commit 344590c

4 files changed

Lines changed: 18 additions & 0 deletions

File tree

test/collection/test_config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,13 +238,15 @@ def test_basic_config():
238238
model="cohere.embed-english-v3",
239239
region="us-east-1",
240240
service="bedrock",
241+
dimensions=512,
241242
),
242243
{
243244
"text2vec-aws": {
244245
"vectorizeClassName": False,
245246
"model": "cohere.embed-english-v3",
246247
"region": "us-east-1",
247248
"service": "bedrock",
249+
"dimensions": 512,
248250
}
249251
},
250252
),

weaviate/collections/classes/config_named_vectors.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,7 @@ def text2vec_aws(
453453
source_properties: Optional[List[str]] = None,
454454
vector_index_config: Optional[_VectorIndexConfigCreate] = None,
455455
vectorize_collection_name: bool = True,
456+
dimensions: Optional[int] = None,
456457
) -> _NamedVectorConfigCreate:
457458
"""Create a named vector using the `text2vec_aws` model.
458459
@@ -468,6 +469,7 @@ def text2vec_aws(
468469
source_properties: Which properties should be included when vectorizing. By default all text properties are included.
469470
vector_index_config: The configuration for Weaviate's vector index. Use wvc.config.Configure.VectorIndex to create a vector index configuration. None by default
470471
vectorize_collection_name: Whether to vectorize the collection name. Defaults to `True`.
472+
dimensions: The dimensionality of the vectors. Defaults to `None`, which uses the server-defined default.
471473
"""
472474
return _NamedVectorConfigCreate(
473475
name=name,
@@ -480,6 +482,7 @@ def text2vec_aws(
480482
vectorizeClassName=vectorize_collection_name,
481483
targetModel=None,
482484
targetVariant=None,
485+
dimensions=dimensions,
483486
),
484487
vector_index_config=vector_index_config,
485488
)

weaviate/collections/classes/config_vectorizers.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ class _Text2VecAWSConfig(_VectorizerConfigCreate):
215215
service: str
216216
targetModel: Optional[str]
217217
targetVariant: Optional[str]
218+
dimensions: Optional[int]
218219
vectorizeClassName: bool
219220

220221
@field_validator("region")
@@ -770,6 +771,7 @@ def text2vec_aws(
770771
endpoint: Optional[str] = None,
771772
service: Union[AWSService, str] = "bedrock",
772773
vectorize_collection_name: bool = True,
774+
dimensions: Optional[int] = None,
773775
) -> _VectorizerConfigCreate:
774776
"""Create a `_Text2VecAWSConfigCreate` object for use when vectorizing using the `text2vec-aws` model.
775777
@@ -782,6 +784,7 @@ def text2vec_aws(
782784
endpoint: The model to use, REQUIRED for service "sagemaker".
783785
service: The AWS service to use, options are "bedrock" and "sagemaker".
784786
vectorize_collection_name: Whether to vectorize the collection name. Defaults to `True`.
787+
dimensions: The dimensionality of the vectors. Defaults to `None`, which uses the server-defined default.
785788
"""
786789
return _Text2VecAWSConfig(
787790
model=model,
@@ -791,6 +794,7 @@ def text2vec_aws(
791794
endpoint=endpoint,
792795
targetModel=None,
793796
targetVariant=None,
797+
dimensions=dimensions,
794798
)
795799

796800
@staticmethod

weaviate/collections/classes/config_vectors.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,7 @@ def text2vec_aws(
795795
source_properties: Optional[List[str]] = None,
796796
vector_index_config: Optional[_VectorIndexConfigCreate] = None,
797797
vectorize_collection_name: bool = True,
798+
dimensions: Optional[int] = None,
798799
) -> _VectorConfigCreate:
799800
"""Create a vector using the `text2vec-aws` module.
800801
@@ -811,6 +812,7 @@ def text2vec_aws(
811812
source_properties: Which properties should be included when vectorizing. By default all text properties are included.
812813
vector_index_config: The configuration for Weaviate's vector index. Use `wvc.config.Configure.VectorIndex` to create a vector index configuration. None by default
813814
vectorize_collection_name: Whether to vectorize the collection name. Defaults to `True`.
815+
dimensions: The dimensionality of the vectors. Defaults to `None`, which uses the server-defined default.
814816
"""
815817
return _VectorConfigCreate(
816818
name=name,
@@ -823,6 +825,7 @@ def text2vec_aws(
823825
vectorizeClassName=vectorize_collection_name,
824826
targetModel=None,
825827
targetVariant=None,
828+
dimensions=dimensions,
826829
),
827830
vector_index_config=_IndexWrappers.single(vector_index_config, quantizer),
828831
)
@@ -837,6 +840,7 @@ def text2vec_aws_bedrock(
837840
source_properties: Optional[List[str]] = None,
838841
vector_index_config: Optional[_VectorIndexConfigCreate] = None,
839842
vectorize_collection_name: bool = True,
843+
dimensions: Optional[int] = None,
840844
) -> _VectorConfigCreate:
841845
"""Create a vector using the `text2vec-aws` module.
842846
@@ -851,6 +855,7 @@ def text2vec_aws_bedrock(
851855
source_properties: Which properties should be included when vectorizing. By default all text properties are included.
852856
vector_index_config: The configuration for Weaviate's vector index. Use `wvc.config.Configure.VectorIndex` to create a vector index configuration. None by default
853857
vectorize_collection_name: Whether to vectorize the collection name. Defaults to `True`.
858+
dimensions: The dimensionality of the vectors. Defaults to `None`, which uses the server-defined default.
854859
"""
855860
return _VectorConfigCreate(
856861
name=name,
@@ -863,6 +868,7 @@ def text2vec_aws_bedrock(
863868
vectorizeClassName=vectorize_collection_name,
864869
targetModel=None,
865870
targetVariant=None,
871+
dimensions=dimensions,
866872
),
867873
vector_index_config=_IndexWrappers.single(vector_index_config, quantizer),
868874
)
@@ -879,6 +885,7 @@ def text2vec_aws_sagemaker(
879885
source_properties: Optional[List[str]] = None,
880886
vector_index_config: Optional[_VectorIndexConfigCreate] = None,
881887
vectorize_collection_name: bool = True,
888+
dimensions: Optional[int] = None,
882889
) -> _VectorConfigCreate:
883890
"""Create a vector using the `text2vec-aws` module.
884891
@@ -895,6 +902,7 @@ def text2vec_aws_sagemaker(
895902
source_properties: Which properties should be included when vectorizing. By default all text properties are included.
896903
vector_index_config: The configuration for Weaviate's vector index. Use `wvc.config.Configure.VectorIndex` to create a vector index configuration. None by default
897904
vectorize_collection_name: Whether to vectorize the collection name. Defaults to `True`.
905+
dimensions: The dimensionality of the vectors. Defaults to `None`, which uses the server-defined default.
898906
"""
899907
return _VectorConfigCreate(
900908
name=name,
@@ -907,6 +915,7 @@ def text2vec_aws_sagemaker(
907915
targetVariant=target_variant,
908916
service="sagemaker",
909917
vectorizeClassName=vectorize_collection_name,
918+
dimensions=dimensions,
910919
),
911920
vector_index_config=_IndexWrappers.single(vector_index_config, quantizer),
912921
)

0 commit comments

Comments
 (0)