Skip to content

Commit

Permalink
Merge pull request #1508 from weaviate/#1445/add-dimensions-param-to-…
Browse files Browse the repository at this point in the history
…text2vec-azure-openai

Add dimensions param to `text2vec_azure_openai`
  • Loading branch information
tsmith023 authored Jan 14, 2025
2 parents 1999c7e + 924d878 commit 6c1c995
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
4 changes: 4 additions & 0 deletions test/collection/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,15 @@ def test_basic_config():
resource_name="resource",
deployment_id="deployment",
base_url="https://api.openai.com",
dimensions=356,
),
{
"text2vec-openai": {
"resourceName": "resource",
"deploymentId": "deployment",
"vectorizeClassName": True,
"baseURL": "https://api.openai.com/",
"dimensions": 356,
}
},
),
Expand Down Expand Up @@ -1276,6 +1278,7 @@ def test_vector_config_flat_pq() -> None:
resource_name="resource",
deployment_id="deployment",
source_properties=["prop"],
dimensions=512,
)
],
{
Expand All @@ -1286,6 +1289,7 @@ def test_vector_config_flat_pq() -> None:
"deploymentId": "deployment",
"vectorizeClassName": True,
"properties": ["prop"],
"dimensions": 512,
}
},
"vectorIndexType": "hnsw",
Expand Down
14 changes: 12 additions & 2 deletions weaviate/collections/classes/config_named_vectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -848,10 +848,11 @@ def text2vec_azure_openai(
resource_name: str,
deployment_id: str,
*,
vector_index_config: Optional[_VectorIndexConfigCreate] = None,
base_url: Optional[AnyHttpUrl] = None,
dimensions: Optional[int] = None,
source_properties: Optional[List[str]] = None,
vector_index_config: Optional[_VectorIndexConfigCreate] = None,
vectorize_collection_name: bool = True,
base_url: Optional[AnyHttpUrl] = None,
) -> _NamedVectorConfigCreate:
"""Create a named vector using the `text2vec_azure_openai` model.
Expand All @@ -861,6 +862,14 @@ def text2vec_azure_openai(
Arguments:
`name`
The name of the named vector.
`resource_name`
The resource name to use, REQUIRED.
`deployment_id`
The deployment ID to use, REQUIRED.
`base_url`
The base URL to use where API requests should go. Defaults to `None`, which uses the server-defined default.
`dimensions`
The dimensionality of the vectors. Defaults to `None`, which uses the server-defined default.
`source_properties`
Which properties should be included when vectorizing. By default all text properties are included.
`vector_index_config`
Expand All @@ -873,6 +882,7 @@ def text2vec_azure_openai(
source_properties=source_properties,
vectorizer=_Text2VecAzureOpenAIConfig(
baseURL=base_url,
dimensions=dimensions,
resourceName=resource_name,
deploymentId=deployment_id,
vectorizeClassName=vectorize_collection_name,
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 @@ -209,6 +209,7 @@ class _Text2VecAzureOpenAIConfig(_VectorizerConfigCreate):
resourceName: str
deploymentId: str
vectorizeClassName: bool
dimensions: Optional[int]

def _to_dict(self) -> Dict[str, Any]:
ret_dict = super()._to_dict()
Expand Down Expand Up @@ -685,6 +686,7 @@ def text2vec_azure_openai(
deployment_id: str,
vectorize_collection_name: bool = True,
base_url: Optional[AnyHttpUrl] = None,
dimensions: Optional[int] = None,
) -> _VectorizerConfigCreate:
"""Create a `_Text2VecAzureOpenAIConfigCreate` object for use when vectorizing using the `text2vec-azure-openai` model.
Expand All @@ -700,12 +702,15 @@ def text2vec_azure_openai(
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`
The dimensionality of the vectors. Defaults to `None`, which uses the server-defined default.
Raises:
`pydantic.ValidationError` if `resource_name` or `deployment_id` are not `str`.
"""
return _Text2VecAzureOpenAIConfig(
baseURL=base_url,
dimensions=dimensions,
resourceName=resource_name,
deploymentId=deployment_id,
vectorizeClassName=vectorize_collection_name,
Expand Down

0 comments on commit 6c1c995

Please sign in to comment.