openai/openai-python

Public

mirrored fromhttps://github.com/openai/openai-pythonAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v1.0.0

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

tests/lib/test_azure.py

36lines · modecode

1from typing import Union
2
3import pytest
4
5from openai._models import FinalRequestOptions
6from openai.lib.azure import AzureOpenAI, AsyncAzureOpenAI
7
8Client = Union[AzureOpenAI, AsyncAzureOpenAI]
9
10
11sync_client = AzureOpenAI(
12 api_version="2023-07-01",
13 api_key="example API key",
14 azure_endpoint="https://example-resource.azure.openai.com",
15)
16
17async_client = AsyncAzureOpenAI(
18 api_version="2023-07-01",
19 api_key="example API key",
20 azure_endpoint="https://example-resource.azure.openai.com",
21)
22
23
24@pytest.mark.parametrize("client", [sync_client, async_client])
25def test_implicit_deployment_path(client: Client) -> None:
26 req = client._build_request(
27 FinalRequestOptions.construct(
28 method="post",
29 url="/chat/completions",
30 json_data={"model": "my-deployment-model"},
31 )
32 )
33 assert (
34 req.url
35 == "https://example-resource.azure.openai.com/openai/deployments/my-deployment-model/chat/completions?api-version=2023-07-01"
36 )
37