Skip to content

Commit b912108

Browse files
author
Stainless Bot
committed
fix(audio): correct response_format translations type (#1743)
1 parent 2522bd5 commit b912108

File tree

10 files changed

+38
-24
lines changed

10 files changed

+38
-24
lines changed

.DS_Store

6 KB
Binary file not shown.

.stats.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 68
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-de1981b64ac229493473670d618500c6362c195f1057eb7de00bd1bc9184fbd5.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-073331021d48db6af646a3552ab0c682efe31b7fb4e59a109ed1ba539f9b89c5.yml

api.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ Methods:
114114
Types:
115115

116116
```python
117-
from openai.types import AudioModel
117+
from openai.types import AudioModel, AudioResponseFormat
118118
```
119119

120120
## Transcriptions

src/openai/resources/audio/transcriptions.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import httpx
99

1010
from ... import _legacy_response
11+
from ...types import AudioResponseFormat
1112
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven, FileTypes
1213
from ..._utils import (
1314
extract_files,
@@ -22,6 +23,7 @@
2223
from ..._base_client import make_request_options
2324
from ...types.audio_model import AudioModel
2425
from ...types.audio.transcription import Transcription
26+
from ...types.audio_response_format import AudioResponseFormat
2527

2628
__all__ = ["Transcriptions", "AsyncTranscriptions"]
2729

@@ -53,7 +55,7 @@ def create(
5355
model: Union[str, AudioModel],
5456
language: str | NotGiven = NOT_GIVEN,
5557
prompt: str | NotGiven = NOT_GIVEN,
56-
response_format: Literal["json", "text", "srt", "verbose_json", "vtt"] | NotGiven = NOT_GIVEN,
58+
response_format: AudioResponseFormat | NotGiven = NOT_GIVEN,
5759
temperature: float | NotGiven = NOT_GIVEN,
5860
timestamp_granularities: List[Literal["word", "segment"]] | NotGiven = NOT_GIVEN,
5961
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -83,8 +85,8 @@ def create(
8385
[prompt](https://platform.openai.com/docs/guides/speech-to-text/prompting)
8486
should match the audio language.
8587
86-
response_format: The format of the transcript output, in one of these options: `json`, `text`,
87-
`srt`, `verbose_json`, or `vtt`.
88+
response_format: The format of the output, in one of these options: `json`, `text`, `srt`,
89+
`verbose_json`, or `vtt`.
8890
8991
temperature: The sampling temperature, between 0 and 1. Higher values like 0.8 will make the
9092
output more random, while lower values like 0.2 will make it more focused and
@@ -160,7 +162,7 @@ async def create(
160162
model: Union[str, AudioModel],
161163
language: str | NotGiven = NOT_GIVEN,
162164
prompt: str | NotGiven = NOT_GIVEN,
163-
response_format: Literal["json", "text", "srt", "verbose_json", "vtt"] | NotGiven = NOT_GIVEN,
165+
response_format: AudioResponseFormat | NotGiven = NOT_GIVEN,
164166
temperature: float | NotGiven = NOT_GIVEN,
165167
timestamp_granularities: List[Literal["word", "segment"]] | NotGiven = NOT_GIVEN,
166168
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -190,8 +192,8 @@ async def create(
190192
[prompt](https://platform.openai.com/docs/guides/speech-to-text/prompting)
191193
should match the audio language.
192194
193-
response_format: The format of the transcript output, in one of these options: `json`, `text`,
194-
`srt`, `verbose_json`, or `vtt`.
195+
response_format: The format of the output, in one of these options: `json`, `text`, `srt`,
196+
`verbose_json`, or `vtt`.
195197
196198
temperature: The sampling temperature, between 0 and 1. Higher values like 0.8 will make the
197199
output more random, while lower values like 0.2 will make it more focused and

src/openai/resources/audio/translations.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import httpx
88

99
from ... import _legacy_response
10+
from ...types import AudioResponseFormat
1011
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven, FileTypes
1112
from ..._utils import (
1213
extract_files,
@@ -21,6 +22,7 @@
2122
from ..._base_client import make_request_options
2223
from ...types.audio_model import AudioModel
2324
from ...types.audio.translation import Translation
25+
from ...types.audio_response_format import AudioResponseFormat
2426

2527
__all__ = ["Translations", "AsyncTranslations"]
2628

@@ -51,7 +53,7 @@ def create(
5153
file: FileTypes,
5254
model: Union[str, AudioModel],
5355
prompt: str | NotGiven = NOT_GIVEN,
54-
response_format: str | NotGiven = NOT_GIVEN,
56+
response_format: AudioResponseFormat | NotGiven = NOT_GIVEN,
5557
temperature: float | NotGiven = NOT_GIVEN,
5658
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
5759
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -75,8 +77,8 @@ def create(
7577
[prompt](https://platform.openai.com/docs/guides/speech-to-text/prompting)
7678
should be in English.
7779
78-
response_format: The format of the transcript output, in one of these options: `json`, `text`,
79-
`srt`, `verbose_json`, or `vtt`.
80+
response_format: The format of the output, in one of these options: `json`, `text`, `srt`,
81+
`verbose_json`, or `vtt`.
8082
8183
temperature: The sampling temperature, between 0 and 1. Higher values like 0.8 will make the
8284
output more random, while lower values like 0.2 will make it more focused and
@@ -143,7 +145,7 @@ async def create(
143145
file: FileTypes,
144146
model: Union[str, AudioModel],
145147
prompt: str | NotGiven = NOT_GIVEN,
146-
response_format: str | NotGiven = NOT_GIVEN,
148+
response_format: AudioResponseFormat | NotGiven = NOT_GIVEN,
147149
temperature: float | NotGiven = NOT_GIVEN,
148150
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
149151
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -167,8 +169,8 @@ async def create(
167169
[prompt](https://platform.openai.com/docs/guides/speech-to-text/prompting)
168170
should be in English.
169171
170-
response_format: The format of the transcript output, in one of these options: `json`, `text`,
171-
`srt`, `verbose_json`, or `vtt`.
172+
response_format: The format of the output, in one of these options: `json`, `text`, `srt`,
173+
`verbose_json`, or `vtt`.
172174
173175
temperature: The sampling temperature, between 0 and 1. Higher values like 0.8 will make the
174176
output more random, while lower values like 0.2 will make it more focused and

src/openai/types/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
from .batch_create_params import BatchCreateParams as BatchCreateParams
3939
from .batch_request_counts import BatchRequestCounts as BatchRequestCounts
4040
from .upload_create_params import UploadCreateParams as UploadCreateParams
41+
from .audio_response_format import AudioResponseFormat as AudioResponseFormat
4142
from .image_generate_params import ImageGenerateParams as ImageGenerateParams
4243
from .upload_complete_params import UploadCompleteParams as UploadCompleteParams
4344
from .embedding_create_params import EmbeddingCreateParams as EmbeddingCreateParams

src/openai/types/audio/transcription_create_params.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
from ..._types import FileTypes
99
from ..audio_model import AudioModel
10+
from ..audio_response_format import AudioResponseFormat
1011

1112
__all__ = ["TranscriptionCreateParams"]
1213

@@ -41,10 +42,10 @@ class TranscriptionCreateParams(TypedDict, total=False):
4142
should match the audio language.
4243
"""
4344

44-
response_format: Literal["json", "text", "srt", "verbose_json", "vtt"]
45+
response_format: AudioResponseFormat
4546
"""
46-
The format of the transcript output, in one of these options: `json`, `text`,
47-
`srt`, `verbose_json`, or `vtt`.
47+
The format of the output, in one of these options: `json`, `text`, `srt`,
48+
`verbose_json`, or `vtt`.
4849
"""
4950

5051
temperature: float

src/openai/types/audio/translation_create_params.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
from ..._types import FileTypes
99
from ..audio_model import AudioModel
10+
from ..audio_response_format import AudioResponseFormat
1011

1112
__all__ = ["TranslationCreateParams"]
1213

@@ -33,10 +34,10 @@ class TranslationCreateParams(TypedDict, total=False):
3334
should be in English.
3435
"""
3536

36-
response_format: str
37+
response_format: AudioResponseFormat
3738
"""
38-
The format of the transcript output, in one of these options: `json`, `text`,
39-
`srt`, `verbose_json`, or `vtt`.
39+
The format of the output, in one of these options: `json`, `text`, `srt`,
40+
`verbose_json`, or `vtt`.
4041
"""
4142

4243
temperature: float
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from typing_extensions import Literal, TypeAlias
4+
5+
__all__ = ["AudioResponseFormat"]
6+
7+
AudioResponseFormat: TypeAlias = Literal["json", "text", "srt", "verbose_json", "vtt"]

tests/api_resources/audio/test_translations.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ def test_method_create_with_all_params(self, client: OpenAI) -> None:
3030
translation = client.audio.translations.create(
3131
file=b"raw file contents",
3232
model="whisper-1",
33-
prompt="string",
34-
response_format="string",
33+
prompt="prompt",
34+
response_format="json",
3535
temperature=0,
3636
)
3737
assert_matches_type(Translation, translation, path=["response"])
@@ -79,8 +79,8 @@ async def test_method_create_with_all_params(self, async_client: AsyncOpenAI) ->
7979
translation = await async_client.audio.translations.create(
8080
file=b"raw file contents",
8181
model="whisper-1",
82-
prompt="string",
83-
response_format="string",
82+
prompt="prompt",
83+
response_format="json",
8484
temperature=0,
8585
)
8686
assert_matches_type(Translation, translation, path=["response"])

0 commit comments

Comments
 (0)