from typing import Union
import pytest
from openai._models import FinalRequestOptions
from openai.lib.azure import AzureOpenAI, AsyncAzureOpenAI
Client = Union[AzureOpenAI, AsyncAzureOpenAI]
sync_client = AzureOpenAI(
api_version="2023-07-01",
api_key="example API key",
azure_endpoint="https://example-resource.azure.openai.com",
)
async_client = AsyncAzureOpenAI(
api_version="2023-07-01",
api_key="example API key",
azure_endpoint="https://example-resource.azure.openai.com",
)
@pytest.mark.parametrize("client", [sync_client, async_client])
def test_implicit_deployment_path(client: Client) -> None:
req = client._build_request(
FinalRequestOptions.construct(
method="post",
url="/chat/completions",
json_data={"model": "my-deployment-model"},
)
)
assert (
req.url
== "https://example-resource.azure.openai.com/openai/deployments/my-deployment-model/chat/completions?api-version=2023-07-01"
)openai/openai-python
Publicmirrored fromhttps://github.com/openai/openai-pythonAvailable
tests/lib/test_azure.py
36lines · modepreview