openai/openai-python

Public

mirrored from https://github.com/openai/openai-pythonAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v1.0.1

Branches

Tags

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

Clone

HTTPS

Download ZIP

tests/lib/test_azure.py

36lines · modeblame

08b8179aDavid Schnurr2 years ago1from 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(
12api_version="2023-07-01",
13api_key="example API key",
14azure_endpoint="https://example-resource.azure.openai.com",
15)
16
17async_client = AsyncAzureOpenAI(
18api_version="2023-07-01",
19api_key="example API key",
20azure_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:
26req = client._build_request(
27FinalRequestOptions.construct(
28method="post",
29url="/chat/completions",
30json_data={"model": "my-deployment-model"},
31)
32)
33assert (
34req.url
35== "https://example-resource.azure.openai.com/openai/deployments/my-deployment-model/chat/completions?api-version=2023-07-01"
36)