Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dimensions param to text2vec_azure_openai #1508

Merged
merged 2 commits into from
Jan 14, 2025
Merged
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
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
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,
tsmith023 marked this conversation as resolved.
Show resolved Hide resolved
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
Loading