Skip to content

Commit

Permalink
Add dimensions param to text2vec_azure_openai
Browse files Browse the repository at this point in the history
  • Loading branch information
tsmith023 committed Jan 10, 2025
1 parent c02ed69 commit 945740c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 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 @@ -1267,6 +1269,7 @@ def test_vector_config_flat_pq() -> None:
resource_name="resource",
deployment_id="deployment",
source_properties=["prop"],
dimensions=512,
)
],
{
Expand All @@ -1277,6 +1280,7 @@ def test_vector_config_flat_pq() -> None:
"deploymentId": "deployment",
"vectorizeClassName": True,
"properties": ["prop"],
"dimensions": 512,
}
},
"vectorIndexType": "hnsw",
Expand Down
2 changes: 2 additions & 0 deletions weaviate/collections/classes/config_named_vectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,7 @@ def text2vec_azure_openai(
source_properties: Optional[List[str]] = None,
vectorize_collection_name: bool = True,
base_url: Optional[AnyHttpUrl] = None,
dimensions: Optional[int] = None,
) -> _NamedVectorConfigCreate:
"""Create a named vector using the `text2vec_azure_openai` model.
Expand All @@ -873,6 +874,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 945740c

Please sign in to comment.