Commit 102fce4f
Changed files (10)
src
openai
tests
api_resources
audio
src/openai/resources/audio/transcriptions.py
@@ -8,6 +8,7 @@ from typing_extensions import Literal
import httpx
from ... import _legacy_response
+from ...types import AudioResponseFormat
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven, FileTypes
from ..._utils import (
extract_files,
@@ -22,6 +23,7 @@ from ...types.audio import transcription_create_params
from ..._base_client import make_request_options
from ...types.audio_model import AudioModel
from ...types.audio.transcription import Transcription
+from ...types.audio_response_format import AudioResponseFormat
__all__ = ["Transcriptions", "AsyncTranscriptions"]
@@ -53,7 +55,7 @@ class Transcriptions(SyncAPIResource):
model: Union[str, AudioModel],
language: str | NotGiven = NOT_GIVEN,
prompt: str | NotGiven = NOT_GIVEN,
- response_format: Literal["json", "text", "srt", "verbose_json", "vtt"] | NotGiven = NOT_GIVEN,
+ response_format: AudioResponseFormat | NotGiven = NOT_GIVEN,
temperature: float | NotGiven = NOT_GIVEN,
timestamp_granularities: List[Literal["word", "segment"]] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -83,8 +85,8 @@ class Transcriptions(SyncAPIResource):
[prompt](https://platform.openai.com/docs/guides/speech-to-text/prompting)
should match the audio language.
- response_format: The format of the transcript output, in one of these options: `json`, `text`,
- `srt`, `verbose_json`, or `vtt`.
+ response_format: The format of the output, in one of these options: `json`, `text`, `srt`,
+ `verbose_json`, or `vtt`.
temperature: The sampling temperature, between 0 and 1. Higher values like 0.8 will make the
output more random, while lower values like 0.2 will make it more focused and
@@ -160,7 +162,7 @@ class AsyncTranscriptions(AsyncAPIResource):
model: Union[str, AudioModel],
language: str | NotGiven = NOT_GIVEN,
prompt: str | NotGiven = NOT_GIVEN,
- response_format: Literal["json", "text", "srt", "verbose_json", "vtt"] | NotGiven = NOT_GIVEN,
+ response_format: AudioResponseFormat | NotGiven = NOT_GIVEN,
temperature: float | NotGiven = NOT_GIVEN,
timestamp_granularities: List[Literal["word", "segment"]] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -190,8 +192,8 @@ class AsyncTranscriptions(AsyncAPIResource):
[prompt](https://platform.openai.com/docs/guides/speech-to-text/prompting)
should match the audio language.
- response_format: The format of the transcript output, in one of these options: `json`, `text`,
- `srt`, `verbose_json`, or `vtt`.
+ response_format: The format of the output, in one of these options: `json`, `text`, `srt`,
+ `verbose_json`, or `vtt`.
temperature: The sampling temperature, between 0 and 1. Higher values like 0.8 will make the
output more random, while lower values like 0.2 will make it more focused and
src/openai/resources/audio/translations.py
@@ -7,6 +7,7 @@ from typing import Union, Mapping, cast
import httpx
from ... import _legacy_response
+from ...types import AudioResponseFormat
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven, FileTypes
from ..._utils import (
extract_files,
@@ -21,6 +22,7 @@ from ...types.audio import translation_create_params
from ..._base_client import make_request_options
from ...types.audio_model import AudioModel
from ...types.audio.translation import Translation
+from ...types.audio_response_format import AudioResponseFormat
__all__ = ["Translations", "AsyncTranslations"]
@@ -51,7 +53,7 @@ class Translations(SyncAPIResource):
file: FileTypes,
model: Union[str, AudioModel],
prompt: str | NotGiven = NOT_GIVEN,
- response_format: str | NotGiven = NOT_GIVEN,
+ response_format: AudioResponseFormat | NotGiven = NOT_GIVEN,
temperature: float | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -75,8 +77,8 @@ class Translations(SyncAPIResource):
[prompt](https://platform.openai.com/docs/guides/speech-to-text/prompting)
should be in English.
- response_format: The format of the transcript output, in one of these options: `json`, `text`,
- `srt`, `verbose_json`, or `vtt`.
+ response_format: The format of the output, in one of these options: `json`, `text`, `srt`,
+ `verbose_json`, or `vtt`.
temperature: The sampling temperature, between 0 and 1. Higher values like 0.8 will make the
output more random, while lower values like 0.2 will make it more focused and
@@ -143,7 +145,7 @@ class AsyncTranslations(AsyncAPIResource):
file: FileTypes,
model: Union[str, AudioModel],
prompt: str | NotGiven = NOT_GIVEN,
- response_format: str | NotGiven = NOT_GIVEN,
+ response_format: AudioResponseFormat | NotGiven = NOT_GIVEN,
temperature: float | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -167,8 +169,8 @@ class AsyncTranslations(AsyncAPIResource):
[prompt](https://platform.openai.com/docs/guides/speech-to-text/prompting)
should be in English.
- response_format: The format of the transcript output, in one of these options: `json`, `text`,
- `srt`, `verbose_json`, or `vtt`.
+ response_format: The format of the output, in one of these options: `json`, `text`, `srt`,
+ `verbose_json`, or `vtt`.
temperature: The sampling temperature, between 0 and 1. Higher values like 0.8 will make the
output more random, while lower values like 0.2 will make it more focused and
src/openai/types/audio/transcription_create_params.py
@@ -7,6 +7,7 @@ from typing_extensions import Literal, Required, TypedDict
from ..._types import FileTypes
from ..audio_model import AudioModel
+from ..audio_response_format import AudioResponseFormat
__all__ = ["TranscriptionCreateParams"]
@@ -41,10 +42,10 @@ class TranscriptionCreateParams(TypedDict, total=False):
should match the audio language.
"""
- response_format: Literal["json", "text", "srt", "verbose_json", "vtt"]
+ response_format: AudioResponseFormat
"""
- The format of the transcript output, in one of these options: `json`, `text`,
- `srt`, `verbose_json`, or `vtt`.
+ The format of the output, in one of these options: `json`, `text`, `srt`,
+ `verbose_json`, or `vtt`.
"""
temperature: float
src/openai/types/audio/translation_create_params.py
@@ -7,6 +7,7 @@ from typing_extensions import Required, TypedDict
from ..._types import FileTypes
from ..audio_model import AudioModel
+from ..audio_response_format import AudioResponseFormat
__all__ = ["TranslationCreateParams"]
@@ -33,10 +34,10 @@ class TranslationCreateParams(TypedDict, total=False):
should be in English.
"""
- response_format: str
+ response_format: AudioResponseFormat
"""
- The format of the transcript output, in one of these options: `json`, `text`,
- `srt`, `verbose_json`, or `vtt`.
+ The format of the output, in one of these options: `json`, `text`, `srt`,
+ `verbose_json`, or `vtt`.
"""
temperature: float
src/openai/types/__init__.py
@@ -38,6 +38,7 @@ from .file_create_params import FileCreateParams as FileCreateParams
from .batch_create_params import BatchCreateParams as BatchCreateParams
from .batch_request_counts import BatchRequestCounts as BatchRequestCounts
from .upload_create_params import UploadCreateParams as UploadCreateParams
+from .audio_response_format import AudioResponseFormat as AudioResponseFormat
from .image_generate_params import ImageGenerateParams as ImageGenerateParams
from .upload_complete_params import UploadCompleteParams as UploadCompleteParams
from .embedding_create_params import EmbeddingCreateParams as EmbeddingCreateParams
src/openai/types/audio_response_format.py
@@ -0,0 +1,7 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from typing_extensions import Literal, TypeAlias
+
+__all__ = ["AudioResponseFormat"]
+
+AudioResponseFormat: TypeAlias = Literal["json", "text", "srt", "verbose_json", "vtt"]
tests/api_resources/audio/test_translations.py
@@ -30,8 +30,8 @@ class TestTranslations:
translation = client.audio.translations.create(
file=b"raw file contents",
model="whisper-1",
- prompt="string",
- response_format="string",
+ prompt="prompt",
+ response_format="json",
temperature=0,
)
assert_matches_type(Translation, translation, path=["response"])
@@ -79,8 +79,8 @@ class TestAsyncTranslations:
translation = await async_client.audio.translations.create(
file=b"raw file contents",
model="whisper-1",
- prompt="string",
- response_format="string",
+ prompt="prompt",
+ response_format="json",
temperature=0,
)
assert_matches_type(Translation, translation, path=["response"])
.DS_Store
Binary file
.stats.yml
@@ -1,2 +1,2 @@
configured_endpoints: 68
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-de1981b64ac229493473670d618500c6362c195f1057eb7de00bd1bc9184fbd5.yml
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-073331021d48db6af646a3552ab0c682efe31b7fb4e59a109ed1ba539f9b89c5.yml
api.md
@@ -114,7 +114,7 @@ Methods:
Types:
```python
-from openai.types import AudioModel
+from openai.types import AudioModel, AudioResponseFormat
```
## Transcriptions