Skip to content

Commit

Permalink
feat: extract out ImageModel, AudioModel, SpeechModel (#1586)
Browse files Browse the repository at this point in the history
  • Loading branch information
Stainless Bot committed Aug 2, 2024
1 parent 5f177dc commit b800316
Show file tree
Hide file tree
Showing 32 changed files with 149 additions and 1,277 deletions.
16 changes: 14 additions & 2 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Methods:
Types:

```python
from openai.types import Image, ImagesResponse
from openai.types import Image, ImageModel, ImagesResponse
```

Methods:
Expand All @@ -103,6 +103,12 @@ Methods:

# Audio

Types:

```python
from openai.types import AudioModel
```

## Transcriptions

Types:
Expand All @@ -129,6 +135,12 @@ Methods:

## Speech

Types:

```python
from openai.types.audio import SpeechModel
```

Methods:

- <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>
Expand All @@ -138,7 +150,7 @@ Methods:
Types:

```python
from openai.types import Moderation, ModerationCreateResponse
from openai.types import Moderation, ModerationModel, ModerationCreateResponse
```

Methods:
Expand Down
9 changes: 4 additions & 5 deletions src/openai/resources/audio/speech.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@
async_to_custom_streamed_response_wrapper,
)
from ...types.audio import speech_create_params
from ..._base_client import (
make_request_options,
)
from ..._base_client import make_request_options
from ...types.audio.speech_model import SpeechModel

__all__ = ["Speech", "AsyncSpeech"]

Expand All @@ -42,7 +41,7 @@ def create(
self,
*,
input: str,
model: Union[str, Literal["tts-1", "tts-1-hd"]],
model: Union[str, SpeechModel],
voice: Literal["alloy", "echo", "fable", "onyx", "nova", "shimmer"],
response_format: Literal["mp3", "opus", "aac", "flac", "wav", "pcm"] | NotGiven = NOT_GIVEN,
speed: float | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -115,7 +114,7 @@ async def create(
self,
*,
input: str,
model: Union[str, Literal["tts-1", "tts-1-hd"]],
model: Union[str, SpeechModel],
voice: Literal["alloy", "echo", "fable", "onyx", "nova", "shimmer"],
response_format: Literal["mp3", "opus", "aac", "flac", "wav", "pcm"] | NotGiven = NOT_GIVEN,
speed: float | NotGiven = NOT_GIVEN,
Expand Down
9 changes: 4 additions & 5 deletions src/openai/resources/audio/transcriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@
from ..._resource import SyncAPIResource, AsyncAPIResource
from ..._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
from ...types.audio import transcription_create_params
from ..._base_client import (
make_request_options,
)
from ..._base_client import make_request_options
from ...types.audio_model import AudioModel
from ...types.audio.transcription import Transcription

__all__ = ["Transcriptions", "AsyncTranscriptions"]
Expand All @@ -40,7 +39,7 @@ def create(
self,
*,
file: FileTypes,
model: Union[str, Literal["whisper-1"]],
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,
Expand Down Expand Up @@ -136,7 +135,7 @@ async def create(
self,
*,
file: FileTypes,
model: Union[str, Literal["whisper-1"]],
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,
Expand Down
10 changes: 4 additions & 6 deletions src/openai/resources/audio/translations.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from __future__ import annotations

from typing import Union, Mapping, cast
from typing_extensions import Literal

import httpx

Expand All @@ -19,9 +18,8 @@
from ..._resource import SyncAPIResource, AsyncAPIResource
from ..._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
from ...types.audio import translation_create_params
from ..._base_client import (
make_request_options,
)
from ..._base_client import make_request_options
from ...types.audio_model import AudioModel
from ...types.audio.translation import Translation

__all__ = ["Translations", "AsyncTranslations"]
Expand All @@ -40,7 +38,7 @@ def create(
self,
*,
file: FileTypes,
model: Union[str, Literal["whisper-1"]],
model: Union[str, AudioModel],
prompt: str | NotGiven = NOT_GIVEN,
response_format: str | NotGiven = NOT_GIVEN,
temperature: float | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -121,7 +119,7 @@ async def create(
self,
*,
file: FileTypes,
model: Union[str, Literal["whisper-1"]],
model: Union[str, AudioModel],
prompt: str | NotGiven = NOT_GIVEN,
response_format: str | NotGiven = NOT_GIVEN,
temperature: float | NotGiven = NOT_GIVEN,
Expand Down
62 changes: 4 additions & 58 deletions src/openai/resources/beta/assistants.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@
assistant_create_params,
assistant_update_params,
)
from ..._base_client import (
AsyncPaginator,
make_request_options,
)
from ..._base_client import AsyncPaginator, make_request_options
from ...types.chat_model import ChatModel
from ...types.beta.assistant import Assistant
from ...types.beta.assistant_deleted import AssistantDeleted
from ...types.beta.assistant_tool_param import AssistantToolParam
Expand All @@ -46,33 +44,7 @@ def with_streaming_response(self) -> AssistantsWithStreamingResponse:
def create(
self,
*,
model: Union[
str,
Literal[
"gpt-4o",
"gpt-4o-2024-05-13",
"gpt-4o-mini",
"gpt-4o-mini-2024-07-18",
"gpt-4-turbo",
"gpt-4-turbo-2024-04-09",
"gpt-4-0125-preview",
"gpt-4-turbo-preview",
"gpt-4-1106-preview",
"gpt-4-vision-preview",
"gpt-4",
"gpt-4-0314",
"gpt-4-0613",
"gpt-4-32k",
"gpt-4-32k-0314",
"gpt-4-32k-0613",
"gpt-3.5-turbo",
"gpt-3.5-turbo-16k",
"gpt-3.5-turbo-0613",
"gpt-3.5-turbo-1106",
"gpt-3.5-turbo-0125",
"gpt-3.5-turbo-16k-0613",
],
],
model: Union[str, ChatModel],
description: Optional[str] | NotGiven = NOT_GIVEN,
instructions: Optional[str] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -437,33 +409,7 @@ def with_streaming_response(self) -> AsyncAssistantsWithStreamingResponse:
async def create(
self,
*,
model: Union[
str,
Literal[
"gpt-4o",
"gpt-4o-2024-05-13",
"gpt-4o-mini",
"gpt-4o-mini-2024-07-18",
"gpt-4-turbo",
"gpt-4-turbo-2024-04-09",
"gpt-4-0125-preview",
"gpt-4-turbo-preview",
"gpt-4-1106-preview",
"gpt-4-vision-preview",
"gpt-4",
"gpt-4-0314",
"gpt-4-0613",
"gpt-4-32k",
"gpt-4-32k-0314",
"gpt-4-32k-0613",
"gpt-3.5-turbo",
"gpt-3.5-turbo-16k",
"gpt-3.5-turbo-0613",
"gpt-3.5-turbo-1106",
"gpt-3.5-turbo-0125",
"gpt-3.5-turbo-16k-0613",
],
],
model: Union[str, ChatModel],
description: Optional[str] | NotGiven = NOT_GIVEN,
instructions: Optional[str] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
Expand Down
Loading

0 comments on commit b800316

Please sign in to comment.