|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
| 3 | +import json |
3 | 4 | import logging |
4 | 5 | from typing import Union, cast |
5 | 6 | from typing_extensions import Literal, Protocol |
@@ -47,6 +48,38 @@ def test_implicit_deployment_path(client: Client) -> None: |
47 | 48 | ) |
48 | 49 |
|
49 | 50 |
|
| 51 | +@pytest.mark.parametrize("client", [sync_client, async_client]) |
| 52 | +@pytest.mark.parametrize( |
| 53 | + "endpoint,model", |
| 54 | + [ |
| 55 | + ("/chat/completions", "gpt-4o"), |
| 56 | + ("/completions", "gpt-4o"), |
| 57 | + ("/embeddings", "text-embedding-ada-002"), |
| 58 | + ("/images/generations", "gpt-image-1-5"), |
| 59 | + ("/images/edits", "gpt-image-1-5"), |
| 60 | + ("/audio/transcriptions", "whisper-1"), |
| 61 | + ("/audio/translations", "whisper-1"), |
| 62 | + ("/audio/speech", "tts-1"), |
| 63 | + ], |
| 64 | +) |
| 65 | +def test_implicit_deployment_strips_model_from_body(client: Client, endpoint: str, model: str) -> None: |
| 66 | + req = client._build_request( |
| 67 | + FinalRequestOptions.construct( |
| 68 | + method="post", |
| 69 | + url=endpoint, |
| 70 | + json_data={"model": model, "extra": "value"}, |
| 71 | + ) |
| 72 | + ) |
| 73 | + |
| 74 | + body = json.loads(req.content.decode()) |
| 75 | + assert "model" not in body |
| 76 | + assert body["extra"] == "value" |
| 77 | + assert ( |
| 78 | + str(req.url) |
| 79 | + == f"https://example-resource.azure.openai.com/openai/deployments/{model}{endpoint}?api-version=2023-07-01" |
| 80 | + ) |
| 81 | + |
| 82 | + |
50 | 83 | @pytest.mark.parametrize( |
51 | 84 | "client,method", |
52 | 85 | [ |
|
0 commit comments