diff --git a/test/collection/test_config.py b/test/collection/test_config.py index 84bba4a63..07e89aae2 100644 --- a/test/collection/test_config.py +++ b/test/collection/test_config.py @@ -2373,6 +2373,25 @@ def test_config_with_named_vectors( } }, ), + ( + [ + Configure.Vectors.text2vec_digitalocean( + name="test", source_properties=["prop"], model="qwen2" + ) + ], + { + "test": { + "vectorizer": { + "text2vec-digitalocean": { + "vectorizeClassName": True, + "properties": ["prop"], + "model": "qwen2", + } + }, + "vectorIndexType": "hnsw", + } + }, + ), ( [Configure.Vectors.text2vec_morph(name="test", source_properties=["prop"])], { diff --git a/weaviate/collections/classes/config_vectorizers.py b/weaviate/collections/classes/config_vectorizers.py index 60896b417..d96f88f9a 100644 --- a/weaviate/collections/classes/config_vectorizers.py +++ b/weaviate/collections/classes/config_vectorizers.py @@ -119,6 +119,7 @@ class Vectorizers(str, Enum): TEXT2VEC_COHERE = "text2vec-cohere" TEXT2VEC_CONTEXTIONARY = "text2vec-contextionary" TEXT2VEC_DATABRICKS = "text2vec-databricks" + TEXT2VEC_DIGITALOCEAN = "text2vec-digitalocean" TEXT2VEC_GPT4ALL = "text2vec-gpt4all" TEXT2VEC_HUGGINGFACE = "text2vec-huggingface" TEXT2VEC_MISTRAL = "text2vec-mistral" @@ -286,6 +287,21 @@ def _to_dict(self) -> Dict[str, Any]: return ret_dict +class _Text2VecDigitalOceanConfig(_VectorizerConfigCreate): + vectorizer: Union[Vectorizers, _EnumLikeStr] = Field( + default=Vectorizers.TEXT2VEC_DIGITALOCEAN, frozen=True, exclude=True + ) + model: str + vectorizeClassName: bool + baseURL: Optional[AnyHttpUrl] + + def _to_dict(self) -> Dict[str, Any]: + ret_dict = super()._to_dict() + if self.baseURL is not None: + ret_dict["baseURL"] = self.baseURL.unicode_string() + return ret_dict + + class _Text2VecMorphConfig(_VectorizerConfigCreate): vectorizer: Union[Vectorizers, _EnumLikeStr] = Field( default=Vectorizers.TEXT2VEC_MORPH, frozen=True, exclude=True diff --git a/weaviate/collections/classes/config_vectors.py b/weaviate/collections/classes/config_vectors.py index 37ab8a912..0fde62fec 100644 --- a/weaviate/collections/classes/config_vectors.py +++ b/weaviate/collections/classes/config_vectors.py @@ -59,6 +59,7 @@ _Text2VecCohereConfig, _Text2VecContextionaryConfig, _Text2VecDatabricksConfig, + _Text2VecDigitalOceanConfig, _Text2VecGoogleConfig, _Text2VecGPT4AllConfig, _Text2VecHuggingFaceConfig, @@ -620,6 +621,42 @@ def text2vec_mistral( vector_index_config=_IndexWrappers.single(vector_index_config, quantizer), ) + @staticmethod + def text2vec_digitalocean( + *, + name: Optional[str] = None, + quantizer: Optional[_QuantizerConfigCreate] = None, + base_url: Optional[AnyHttpUrl] = None, + model: str, + source_properties: Optional[List[str]] = None, + vector_index_config: Optional[_VectorIndexConfigCreate] = None, + vectorize_collection_name: bool = True, + ) -> _VectorConfigCreate: + """Create a vector using the `text2vec-digitalocean` module. + + See the [documentation](https://weaviate.io/developers/weaviate/model-providers/digitalocean/embeddings) + for detailed usage. + + Args: + name: The name of the vector. + quantizer: The quantizer to use for the vector index. If not provided, no quantization will be applied. + base_url: The base URL to use where API requests should go. Defaults to `None`, which uses the server-defined default of `https://inference.do-ai.run`. + model: The model to use, e.g. `qwen3-embedding-0.6b`. This is a required field on the server. + source_properties: Which properties should be included when vectorizing. By default all text properties are included. + vector_index_config: The configuration for Weaviate's vector index. Use `wvc.config.Configure.VectorIndex` to create a vector index configuration. None by default + vectorize_collection_name: Whether to vectorize the collection name. Defaults to `True`. + """ + return _VectorConfigCreate( + name=name, + source_properties=source_properties, + vectorizer=_Text2VecDigitalOceanConfig( + baseURL=base_url, + model=model, + vectorizeClassName=vectorize_collection_name, + ), + vector_index_config=_IndexWrappers.single(vector_index_config, quantizer), + ) + @staticmethod def text2vec_morph( *,