Skip to content

Commit fbc8fbc

Browse files
Stainless Botmegamanics
Stainless Bot
authored andcommitted
feat: extract out ImageModel, AudioModel, SpeechModel (openai#1586)
1 parent 5a4384b commit fbc8fbc

32 files changed

+149
-1277
lines changed

Diff for: api.md

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

9494
```python
95-
from openai.types import Image, ImagesResponse
95+
from openai.types import Image, ImageModel, ImagesResponse
9696
```
9797

9898
Methods:
@@ -103,6 +103,12 @@ Methods:
103103

104104
# Audio
105105

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

108114
Types:
@@ -129,6 +135,12 @@ Methods:
129135

130136
## Speech
131137

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

134146
- <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>
@@ -138,7 +150,7 @@ Methods:
138150
Types:
139151

140152
```python
141-
from openai.types import Moderation, ModerationCreateResponse
153+
from openai.types import Moderation, ModerationModel, ModerationCreateResponse
142154
```
143155

144156
Methods:

Diff for: src/openai/resources/audio/speech.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@
2222
async_to_custom_streamed_response_wrapper,
2323
)
2424
from ...types.audio import speech_create_params
25-
from ..._base_client import (
26-
make_request_options,
27-
)
25+
from ..._base_client import make_request_options
26+
from ...types.audio.speech_model import SpeechModel
2827

2928
__all__ = ["Speech", "AsyncSpeech"]
3029

@@ -42,7 +41,7 @@ def create(
4241
self,
4342
*,
4443
input: str,
45-
model: Union[str, Literal["tts-1", "tts-1-hd"]],
44+
model: Union[str, SpeechModel],
4645
voice: Literal["alloy", "echo", "fable", "onyx", "nova", "shimmer"],
4746
response_format: Literal["mp3", "opus", "aac", "flac", "wav", "pcm"] | NotGiven = NOT_GIVEN,
4847
speed: float | NotGiven = NOT_GIVEN,
@@ -115,7 +114,7 @@ async def create(
115114
self,
116115
*,
117116
input: str,
118-
model: Union[str, Literal["tts-1", "tts-1-hd"]],
117+
model: Union[str, SpeechModel],
119118
voice: Literal["alloy", "echo", "fable", "onyx", "nova", "shimmer"],
120119
response_format: Literal["mp3", "opus", "aac", "flac", "wav", "pcm"] | NotGiven = NOT_GIVEN,
121120
speed: float | NotGiven = NOT_GIVEN,

Diff for: src/openai/resources/audio/transcriptions.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@
1919
from ..._resource import SyncAPIResource, AsyncAPIResource
2020
from ..._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
2121
from ...types.audio import transcription_create_params
22-
from ..._base_client import (
23-
make_request_options,
24-
)
22+
from ..._base_client import make_request_options
23+
from ...types.audio_model import AudioModel
2524
from ...types.audio.transcription import Transcription
2625

2726
__all__ = ["Transcriptions", "AsyncTranscriptions"]
@@ -40,7 +39,7 @@ def create(
4039
self,
4140
*,
4241
file: FileTypes,
43-
model: Union[str, Literal["whisper-1"]],
42+
model: Union[str, AudioModel],
4443
language: str | NotGiven = NOT_GIVEN,
4544
prompt: str | NotGiven = NOT_GIVEN,
4645
response_format: Literal["json", "text", "srt", "verbose_json", "vtt"] | NotGiven = NOT_GIVEN,
@@ -136,7 +135,7 @@ async def create(
136135
self,
137136
*,
138137
file: FileTypes,
139-
model: Union[str, Literal["whisper-1"]],
138+
model: Union[str, AudioModel],
140139
language: str | NotGiven = NOT_GIVEN,
141140
prompt: str | NotGiven = NOT_GIVEN,
142141
response_format: Literal["json", "text", "srt", "verbose_json", "vtt"] | NotGiven = NOT_GIVEN,

Diff for: src/openai/resources/audio/translations.py

+4-6
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

@@ -19,9 +18,8 @@
1918
from ..._resource import SyncAPIResource, AsyncAPIResource
2019
from ..._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
2120
from ...types.audio import translation_create_params
22-
from ..._base_client import (
23-
make_request_options,
24-
)
21+
from ..._base_client import make_request_options
22+
from ...types.audio_model import AudioModel
2523
from ...types.audio.translation import Translation
2624

2725
__all__ = ["Translations", "AsyncTranslations"]
@@ -40,7 +38,7 @@ def create(
4038
self,
4139
*,
4240
file: FileTypes,
43-
model: Union[str, Literal["whisper-1"]],
41+
model: Union[str, AudioModel],
4442
prompt: str | NotGiven = NOT_GIVEN,
4543
response_format: str | NotGiven = NOT_GIVEN,
4644
temperature: float | NotGiven = NOT_GIVEN,
@@ -121,7 +119,7 @@ async def create(
121119
self,
122120
*,
123121
file: FileTypes,
124-
model: Union[str, Literal["whisper-1"]],
122+
model: Union[str, AudioModel],
125123
prompt: str | NotGiven = NOT_GIVEN,
126124
response_format: str | NotGiven = NOT_GIVEN,
127125
temperature: float | NotGiven = NOT_GIVEN,

Diff for: src/openai/resources/beta/assistants.py

+4-58
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@
2222
assistant_create_params,
2323
assistant_update_params,
2424
)
25-
from ..._base_client import (
26-
AsyncPaginator,
27-
make_request_options,
28-
)
25+
from ..._base_client import AsyncPaginator, make_request_options
26+
from ...types.chat_model import ChatModel
2927
from ...types.beta.assistant import Assistant
3028
from ...types.beta.assistant_deleted import AssistantDeleted
3129
from ...types.beta.assistant_tool_param import AssistantToolParam
@@ -46,33 +44,7 @@ def with_streaming_response(self) -> AssistantsWithStreamingResponse:
4644
def create(
4745
self,
4846
*,
49-
model: Union[
50-
str,
51-
Literal[
52-
"gpt-4o",
53-
"gpt-4o-2024-05-13",
54-
"gpt-4o-mini",
55-
"gpt-4o-mini-2024-07-18",
56-
"gpt-4-turbo",
57-
"gpt-4-turbo-2024-04-09",
58-
"gpt-4-0125-preview",
59-
"gpt-4-turbo-preview",
60-
"gpt-4-1106-preview",
61-
"gpt-4-vision-preview",
62-
"gpt-4",
63-
"gpt-4-0314",
64-
"gpt-4-0613",
65-
"gpt-4-32k",
66-
"gpt-4-32k-0314",
67-
"gpt-4-32k-0613",
68-
"gpt-3.5-turbo",
69-
"gpt-3.5-turbo-16k",
70-
"gpt-3.5-turbo-0613",
71-
"gpt-3.5-turbo-1106",
72-
"gpt-3.5-turbo-0125",
73-
"gpt-3.5-turbo-16k-0613",
74-
],
75-
],
47+
model: Union[str, ChatModel],
7648
description: Optional[str] | NotGiven = NOT_GIVEN,
7749
instructions: Optional[str] | NotGiven = NOT_GIVEN,
7850
metadata: Optional[object] | NotGiven = NOT_GIVEN,
@@ -437,33 +409,7 @@ def with_streaming_response(self) -> AsyncAssistantsWithStreamingResponse:
437409
async def create(
438410
self,
439411
*,
440-
model: Union[
441-
str,
442-
Literal[
443-
"gpt-4o",
444-
"gpt-4o-2024-05-13",
445-
"gpt-4o-mini",
446-
"gpt-4o-mini-2024-07-18",
447-
"gpt-4-turbo",
448-
"gpt-4-turbo-2024-04-09",
449-
"gpt-4-0125-preview",
450-
"gpt-4-turbo-preview",
451-
"gpt-4-1106-preview",
452-
"gpt-4-vision-preview",
453-
"gpt-4",
454-
"gpt-4-0314",
455-
"gpt-4-0613",
456-
"gpt-4-32k",
457-
"gpt-4-32k-0314",
458-
"gpt-4-32k-0613",
459-
"gpt-3.5-turbo",
460-
"gpt-3.5-turbo-16k",
461-
"gpt-3.5-turbo-0613",
462-
"gpt-3.5-turbo-1106",
463-
"gpt-3.5-turbo-0125",
464-
"gpt-3.5-turbo-16k-0613",
465-
],
466-
],
412+
model: Union[str, ChatModel],
467413
description: Optional[str] | NotGiven = NOT_GIVEN,
468414
instructions: Optional[str] | NotGiven = NOT_GIVEN,
469415
metadata: Optional[object] | NotGiven = NOT_GIVEN,

0 commit comments

Comments
 (0)