Skip to content

Commit 1de0e82

Browse files
feat: extract out ImageModel, AudioModel, SpeechModel (#1586)
1 parent b31a7f3 commit 1de0e82

25 files changed

+111
-630
lines changed

api.md

+14-2
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ Methods:
9191
Types:
9292

9393
```python
94-
from openai.types import Image, ImagesResponse
94+
from openai.types import Image, ImageModel, ImagesResponse
9595
```
9696

9797
Methods:
@@ -102,6 +102,12 @@ Methods:
102102

103103
# Audio
104104

105+
Types:
106+
107+
```python
108+
from openai.types import AudioModel
109+
```
110+
105111
## Transcriptions
106112

107113
Types:
@@ -128,6 +134,12 @@ Methods:
128134

129135
## Speech
130136

137+
Types:
138+
139+
```python
140+
from openai.types.audio import SpeechModel
141+
```
142+
131143
Methods:
132144

133145
- <code title="post /audio/speech">client.audio.speech.<a href="./src/openai/resources/audio/speech.py">create</a>(\*\*<a href="src/openai/types/audio/speech_create_params.py">params</a>) -> HttpxBinaryResponseContent</code>
@@ -137,7 +149,7 @@ Methods:
137149
Types:
138150

139151
```python
140-
from openai.types import Moderation, ModerationCreateResponse
152+
from openai.types import Moderation, ModerationModel, ModerationCreateResponse
141153
```
142154

143155
Methods:

src/openai/resources/audio/speech.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
)
2424
from ...types.audio import speech_create_params
2525
from ..._base_client import make_request_options
26+
from ...types.audio.speech_model import SpeechModel
2627

2728
__all__ = ["Speech", "AsyncSpeech"]
2829

@@ -40,7 +41,7 @@ def create(
4041
self,
4142
*,
4243
input: str,
43-
model: Union[str, Literal["tts-1", "tts-1-hd"]],
44+
model: Union[str, SpeechModel],
4445
voice: Literal["alloy", "echo", "fable", "onyx", "nova", "shimmer"],
4546
response_format: Literal["mp3", "opus", "aac", "flac", "wav", "pcm"] | NotGiven = NOT_GIVEN,
4647
speed: float | NotGiven = NOT_GIVEN,
@@ -113,7 +114,7 @@ async def create(
113114
self,
114115
*,
115116
input: str,
116-
model: Union[str, Literal["tts-1", "tts-1-hd"]],
117+
model: Union[str, SpeechModel],
117118
voice: Literal["alloy", "echo", "fable", "onyx", "nova", "shimmer"],
118119
response_format: Literal["mp3", "opus", "aac", "flac", "wav", "pcm"] | NotGiven = NOT_GIVEN,
119120
speed: float | NotGiven = NOT_GIVEN,

src/openai/resources/audio/transcriptions.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from ..._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
2121
from ...types.audio import transcription_create_params
2222
from ..._base_client import make_request_options
23+
from ...types.audio_model import AudioModel
2324
from ...types.audio.transcription import Transcription
2425

2526
__all__ = ["Transcriptions", "AsyncTranscriptions"]
@@ -38,7 +39,7 @@ def create(
3839
self,
3940
*,
4041
file: FileTypes,
41-
model: Union[str, Literal["whisper-1"]],
42+
model: Union[str, AudioModel],
4243
language: str | NotGiven = NOT_GIVEN,
4344
prompt: str | NotGiven = NOT_GIVEN,
4445
response_format: Literal["json", "text", "srt", "verbose_json", "vtt"] | NotGiven = NOT_GIVEN,
@@ -134,7 +135,7 @@ async def create(
134135
self,
135136
*,
136137
file: FileTypes,
137-
model: Union[str, Literal["whisper-1"]],
138+
model: Union[str, AudioModel],
138139
language: str | NotGiven = NOT_GIVEN,
139140
prompt: str | NotGiven = NOT_GIVEN,
140141
response_format: Literal["json", "text", "srt", "verbose_json", "vtt"] | NotGiven = NOT_GIVEN,

src/openai/resources/audio/translations.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from __future__ import annotations
44

55
from typing import Union, Mapping, cast
6-
from typing_extensions import Literal
76

87
import httpx
98

@@ -20,6 +19,7 @@
2019
from ..._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
2120
from ...types.audio import translation_create_params
2221
from ..._base_client import make_request_options
22+
from ...types.audio_model import AudioModel
2323
from ...types.audio.translation import Translation
2424

2525
__all__ = ["Translations", "AsyncTranslations"]
@@ -38,7 +38,7 @@ def create(
3838
self,
3939
*,
4040
file: FileTypes,
41-
model: Union[str, Literal["whisper-1"]],
41+
model: Union[str, AudioModel],
4242
prompt: str | NotGiven = NOT_GIVEN,
4343
response_format: str | NotGiven = NOT_GIVEN,
4444
temperature: float | NotGiven = NOT_GIVEN,
@@ -119,7 +119,7 @@ async def create(
119119
self,
120120
*,
121121
file: FileTypes,
122-
model: Union[str, Literal["whisper-1"]],
122+
model: Union[str, AudioModel],
123123
prompt: str | NotGiven = NOT_GIVEN,
124124
response_format: str | NotGiven = NOT_GIVEN,
125125
temperature: float | NotGiven = NOT_GIVEN,

src/openai/resources/beta/assistants.py

+3-54
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
assistant_update_params,
2424
)
2525
from ..._base_client import AsyncPaginator, make_request_options
26+
from ...types.chat_model import ChatModel
2627
from ...types.beta.assistant import Assistant
2728
from ...types.beta.assistant_deleted import AssistantDeleted
2829
from ...types.beta.assistant_tool_param import AssistantToolParam
@@ -43,33 +44,7 @@ def with_streaming_response(self) -> AssistantsWithStreamingResponse:
4344
def create(
4445
self,
4546
*,
46-
model: Union[
47-
str,
48-
Literal[
49-
"gpt-4o",
50-
"gpt-4o-2024-05-13",
51-
"gpt-4o-mini",
52-
"gpt-4o-mini-2024-07-18",
53-
"gpt-4-turbo",
54-
"gpt-4-turbo-2024-04-09",
55-
"gpt-4-0125-preview",
56-
"gpt-4-turbo-preview",
57-
"gpt-4-1106-preview",
58-
"gpt-4-vision-preview",
59-
"gpt-4",
60-
"gpt-4-0314",
61-
"gpt-4-0613",
62-
"gpt-4-32k",
63-
"gpt-4-32k-0314",
64-
"gpt-4-32k-0613",
65-
"gpt-3.5-turbo",
66-
"gpt-3.5-turbo-16k",
67-
"gpt-3.5-turbo-0613",
68-
"gpt-3.5-turbo-1106",
69-
"gpt-3.5-turbo-0125",
70-
"gpt-3.5-turbo-16k-0613",
71-
],
72-
],
47+
model: Union[str, ChatModel],
7348
description: Optional[str] | NotGiven = NOT_GIVEN,
7449
instructions: Optional[str] | NotGiven = NOT_GIVEN,
7550
metadata: Optional[object] | NotGiven = NOT_GIVEN,
@@ -434,33 +409,7 @@ def with_streaming_response(self) -> AsyncAssistantsWithStreamingResponse:
434409
async def create(
435410
self,
436411
*,
437-
model: Union[
438-
str,
439-
Literal[
440-
"gpt-4o",
441-
"gpt-4o-2024-05-13",
442-
"gpt-4o-mini",
443-
"gpt-4o-mini-2024-07-18",
444-
"gpt-4-turbo",
445-
"gpt-4-turbo-2024-04-09",
446-
"gpt-4-0125-preview",
447-
"gpt-4-turbo-preview",
448-
"gpt-4-1106-preview",
449-
"gpt-4-vision-preview",
450-
"gpt-4",
451-
"gpt-4-0314",
452-
"gpt-4-0613",
453-
"gpt-4-32k",
454-
"gpt-4-32k-0314",
455-
"gpt-4-32k-0613",
456-
"gpt-3.5-turbo",
457-
"gpt-3.5-turbo-16k",
458-
"gpt-3.5-turbo-0613",
459-
"gpt-3.5-turbo-1106",
460-
"gpt-3.5-turbo-0125",
461-
"gpt-3.5-turbo-16k-0613",
462-
],
463-
],
412+
model: Union[str, ChatModel],
464413
description: Optional[str] | NotGiven = NOT_GIVEN,
465414
instructions: Optional[str] | NotGiven = NOT_GIVEN,
466415
metadata: Optional[object] | NotGiven = NOT_GIVEN,

0 commit comments

Comments
 (0)