Skip to content
Open
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
80 changes: 80 additions & 0 deletions test/collection/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,21 @@ def test_basic_config():
}
},
),
(
Configure.Vectorizer.text2vec_openai(
vectorize_collection_name=False,
model="ada",
endpoint="https://api.custom.com/v1/embeddings",
),
{
"text2vec-openai": {
"vectorizeClassName": False,
"model": "ada",
"endpoint": "https://api.custom.com/v1/embeddings",
"isAzure": False,
}
},
),
(
Configure.Vectorizer.text2vec_mistral(
vectorize_collection_name=False,
Expand Down Expand Up @@ -1759,6 +1774,28 @@ def test_vector_config_flat_pq() -> None:
}
},
),
(
[
Configure.NamedVectors.text2vec_openai(
name="test",
source_properties=["prop"],
endpoint="https://api.custom.com/v1/embeddings",
)
],
{
"test": {
"vectorizer": {
"text2vec-openai": {
"properties": ["prop"],
"vectorizeClassName": True,
"endpoint": "https://api.custom.com/v1/embeddings",
"isAzure": False,
}
},
"vectorIndexType": "hnsw",
}
},
),
(
[Configure.NamedVectors.text2vec_mistral(name="test", source_properties=["prop"])],
{
Expand Down Expand Up @@ -2361,6 +2398,28 @@ def test_config_with_named_vectors(
}
},
),
(
[
Configure.Vectors.text2vec_openai(
name="test",
source_properties=["prop"],
endpoint="https://api.custom.com/v1/embeddings",
)
],
{
"test": {
"vectorizer": {
"text2vec-openai": {
"properties": ["prop"],
"vectorizeClassName": True,
"endpoint": "https://api.custom.com/v1/embeddings",
"isAzure": False,
}
},
"vectorIndexType": "hnsw",
}
},
),
(
[Configure.Vectors.text2vec_mistral(name="test", source_properties=["prop"])],
{
Expand Down Expand Up @@ -2408,6 +2467,27 @@ def test_config_with_named_vectors(
}
},
),
(
[
Configure.Vectors.text2vec_morph(
name="test",
source_properties=["prop"],
endpoint="https://api.custom.com/v1/embeddings",
)
],
{
"test": {
"vectorizer": {
"text2vec-morph": {
"vectorizeClassName": True,
"properties": ["prop"],
"endpoint": "https://api.custom.com/v1/embeddings",
}
},
"vectorIndexType": "hnsw",
}
},
),
(
[
Configure.Vectors.text2vec_google(
Expand Down
3 changes: 3 additions & 0 deletions weaviate/collections/classes/config_named_vectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ def text2vec_openai(
*,
base_url: Optional[AnyHttpUrl] = None,
dimensions: Optional[int] = None,
endpoint: Optional[str] = None,
model: Optional[Union[OpenAIModel, str]] = None,
model_version: Optional[str] = None,
type_: Optional[OpenAIType] = None,
Expand All @@ -424,6 +425,7 @@ def text2vec_openai(
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.
dimensions: Number of dimensions. Applicable to v3 OpenAI models only. Defaults to `None`, which uses the server-defined default.
endpoint: The endpoint to use. Defaults to `None`, which uses the server-defined default of `/v1/embeddings`.

Raises:
pydantic.ValidationError: If `type_` is not a valid value from the `OpenAIType` type.
Expand All @@ -438,6 +440,7 @@ def text2vec_openai(
type_=type_,
vectorizeClassName=vectorize_collection_name,
dimensions=dimensions,
endpoint=endpoint,
),
vector_index_config=vector_index_config,
)
Expand Down
5 changes: 5 additions & 0 deletions weaviate/collections/classes/config_vectorizers.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ class _Text2VecMorphConfig(_VectorizerConfigCreate):
model: Optional[str]
vectorizeClassName: bool
baseURL: Optional[AnyHttpUrl]
endpoint: Optional[str]

def _to_dict(self) -> Dict[str, Any]:
ret_dict = super()._to_dict()
Expand All @@ -336,6 +337,7 @@ class _Text2VecOpenAIConfig(_VectorizerConfigCreate):
)
baseURL: Optional[AnyHttpUrl]
dimensions: Optional[int]
endpoint: Optional[str]
model: Optional[str]
modelVersion: Optional[str]
type_: Optional[OpenAIType]
Expand Down Expand Up @@ -1137,6 +1139,7 @@ def text2vec_openai(
vectorize_collection_name: bool = True,
base_url: Optional[AnyHttpUrl] = None,
dimensions: Optional[int] = None,
endpoint: Optional[str] = None,
) -> _VectorizerConfigCreate:
"""Create a `_Text2VecOpenAIConfigCreate` object for use when vectorizing using the `text2vec-openai` model.

Expand All @@ -1150,6 +1153,7 @@ def text2vec_openai(
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.
dimensions: Number of dimensions. Applicable to v3 OpenAI models only. Defaults to `None`, which uses the server-defined default.
endpoint: The endpoint to use. Defaults to `None`, which uses the server-defined default of `/v1/embeddings`.

Raises:
pydantic.ValidationError: If `type_` is not a valid value from the `OpenAIType` type.
Expand All @@ -1161,6 +1165,7 @@ def text2vec_openai(
type_=type_,
vectorizeClassName=vectorize_collection_name,
dimensions=dimensions,
endpoint=endpoint,
)

@staticmethod
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 @@ -664,6 +664,7 @@ def text2vec_morph(
quantizer: Optional[_QuantizerConfigCreate] = None,
base_url: Optional[AnyHttpUrl] = None,
model: Optional[str] = None,
endpoint: Optional[str] = None,
source_properties: Optional[List[str]] = None,
vector_index_config: Optional[_VectorIndexConfigCreate] = None,
vectorize_collection_name: bool = True,
Expand All @@ -678,6 +679,7 @@ def text2vec_morph(
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.
model: The model to use. Defaults to `None`, which uses the server-defined default.
endpoint: The endpoint to use. Defaults to `None`, which uses the server-defined default of `/v1/embeddings`.
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`.
Expand All @@ -688,6 +690,7 @@ def text2vec_morph(
vectorizer=_Text2VecMorphConfig(
baseURL=base_url,
model=model,
endpoint=endpoint,
vectorizeClassName=vectorize_collection_name,
),
vector_index_config=_IndexWrappers.single(vector_index_config, quantizer),
Expand Down Expand Up @@ -739,6 +742,7 @@ def text2vec_openai(
quantizer: Optional[_QuantizerConfigCreate] = None,
base_url: Optional[AnyHttpUrl] = None,
dimensions: Optional[int] = None,
endpoint: Optional[str] = None,
model: Optional[Union[OpenAIModel, str]] = None,
model_version: Optional[str] = None,
type_: Optional[OpenAIType] = None,
Expand All @@ -756,6 +760,7 @@ def text2vec_openai(
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.
dimensions: Number of dimensions. Applicable to v3 OpenAI models only. Defaults to `None`, which uses the server-defined default.
endpoint: The endpoint to use. Defaults to `None`, which uses the server-defined default of `/v1/embeddings`.
model: The model to use. Defaults to `None`, which uses the server-defined default.
model_version: The model version to use. Defaults to `None`, which uses the server-defined default.
type_: The type of model to use. Defaults to `None`, which uses the server-defined default.
Expand All @@ -776,6 +781,7 @@ def text2vec_openai(
type_=type_,
vectorizeClassName=vectorize_collection_name,
dimensions=dimensions,
endpoint=endpoint,
),
vector_index_config=_IndexWrappers.single(vector_index_config, quantizer),
)
Expand Down