Commit 3c6eccee
Changed files (54)
src
openai
_extras
_utils
resources
beta
assistants
threads
fine_tuning
types
tests
api_resources
beta
fine_tuning
src/openai/_extras/__init__.py
@@ -1,3 +1,2 @@
-from .numpy_proxy import numpy as numpy
-from .numpy_proxy import has_numpy as has_numpy
+from .numpy_proxy import numpy as numpy, has_numpy as has_numpy
from .pandas_proxy import pandas as pandas
src/openai/_utils/__init__.py
@@ -1,37 +1,41 @@
from ._proxy import LazyProxy as LazyProxy
-from ._utils import flatten as flatten
-from ._utils import is_dict as is_dict
-from ._utils import is_list as is_list
-from ._utils import is_given as is_given
-from ._utils import is_tuple as is_tuple
-from ._utils import is_mapping as is_mapping
-from ._utils import is_tuple_t as is_tuple_t
-from ._utils import parse_date as parse_date
-from ._utils import is_sequence as is_sequence
-from ._utils import coerce_float as coerce_float
-from ._utils import is_list_type as is_list_type
-from ._utils import is_mapping_t as is_mapping_t
-from ._utils import removeprefix as removeprefix
-from ._utils import removesuffix as removesuffix
-from ._utils import extract_files as extract_files
-from ._utils import is_sequence_t as is_sequence_t
-from ._utils import is_union_type as is_union_type
-from ._utils import required_args as required_args
-from ._utils import coerce_boolean as coerce_boolean
-from ._utils import coerce_integer as coerce_integer
-from ._utils import file_from_path as file_from_path
-from ._utils import parse_datetime as parse_datetime
-from ._utils import strip_not_given as strip_not_given
-from ._utils import deepcopy_minimal as deepcopy_minimal
-from ._utils import extract_type_arg as extract_type_arg
-from ._utils import is_required_type as is_required_type
-from ._utils import get_async_library as get_async_library
-from ._utils import is_annotated_type as is_annotated_type
-from ._utils import maybe_coerce_float as maybe_coerce_float
-from ._utils import get_required_header as get_required_header
-from ._utils import maybe_coerce_boolean as maybe_coerce_boolean
-from ._utils import maybe_coerce_integer as maybe_coerce_integer
-from ._utils import strip_annotated_type as strip_annotated_type
-from ._transform import PropertyInfo as PropertyInfo
-from ._transform import transform as transform
-from ._transform import maybe_transform as maybe_transform
+from ._utils import (
+ flatten as flatten,
+ is_dict as is_dict,
+ is_list as is_list,
+ is_given as is_given,
+ is_tuple as is_tuple,
+ is_mapping as is_mapping,
+ is_tuple_t as is_tuple_t,
+ parse_date as parse_date,
+ is_sequence as is_sequence,
+ coerce_float as coerce_float,
+ is_list_type as is_list_type,
+ is_mapping_t as is_mapping_t,
+ removeprefix as removeprefix,
+ removesuffix as removesuffix,
+ extract_files as extract_files,
+ is_sequence_t as is_sequence_t,
+ is_union_type as is_union_type,
+ required_args as required_args,
+ coerce_boolean as coerce_boolean,
+ coerce_integer as coerce_integer,
+ file_from_path as file_from_path,
+ parse_datetime as parse_datetime,
+ strip_not_given as strip_not_given,
+ deepcopy_minimal as deepcopy_minimal,
+ extract_type_arg as extract_type_arg,
+ is_required_type as is_required_type,
+ get_async_library as get_async_library,
+ is_annotated_type as is_annotated_type,
+ maybe_coerce_float as maybe_coerce_float,
+ get_required_header as get_required_header,
+ maybe_coerce_boolean as maybe_coerce_boolean,
+ maybe_coerce_integer as maybe_coerce_integer,
+ strip_annotated_type as strip_annotated_type,
+)
+from ._transform import (
+ PropertyInfo as PropertyInfo,
+ transform as transform,
+ maybe_transform as maybe_transform,
+)
src/openai/_utils/_utils.py
@@ -21,9 +21,7 @@ from typing_extensions import Required, Annotated, TypeGuard, get_args, get_orig
import sniffio
from .._types import Headers, NotGiven, FileTypes, NotGivenOr, HeadersLike
-from .._compat import is_union as _is_union
-from .._compat import parse_date as parse_date
-from .._compat import parse_datetime as parse_datetime
+from .._compat import is_union as _is_union, parse_date as parse_date, parse_datetime as parse_datetime
_T = TypeVar("_T")
_TupleT = TypeVar("_TupleT", bound=Tuple[object, ...])
src/openai/resources/audio/__init__.py
@@ -1,18 +1,8 @@
# File generated from our OpenAPI spec by Stainless.
from .audio import Audio, AsyncAudio, AudioWithRawResponse, AsyncAudioWithRawResponse
-from .speech import (
- Speech,
- AsyncSpeech,
- SpeechWithRawResponse,
- AsyncSpeechWithRawResponse,
-)
-from .translations import (
- Translations,
- AsyncTranslations,
- TranslationsWithRawResponse,
- AsyncTranslationsWithRawResponse,
-)
+from .speech import Speech, AsyncSpeech, SpeechWithRawResponse, AsyncSpeechWithRawResponse
+from .translations import Translations, AsyncTranslations, TranslationsWithRawResponse, AsyncTranslationsWithRawResponse
from .transcriptions import (
Transcriptions,
AsyncTranscriptions,
src/openai/resources/audio/audio.py
@@ -4,19 +4,9 @@ from __future__ import annotations
from typing import TYPE_CHECKING
-from .speech import (
- Speech,
- AsyncSpeech,
- SpeechWithRawResponse,
- AsyncSpeechWithRawResponse,
-)
+from .speech import Speech, AsyncSpeech, SpeechWithRawResponse, AsyncSpeechWithRawResponse
from ..._resource import SyncAPIResource, AsyncAPIResource
-from .translations import (
- Translations,
- AsyncTranslations,
- TranslationsWithRawResponse,
- AsyncTranslationsWithRawResponse,
-)
+from .translations import Translations, AsyncTranslations, TranslationsWithRawResponse, AsyncTranslationsWithRawResponse
from .transcriptions import (
Transcriptions,
AsyncTranscriptions,
src/openai/resources/audio/speech.py
@@ -7,12 +7,21 @@ from typing_extensions import Literal
import httpx
-from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
+from ..._types import (
+ NOT_GIVEN,
+ Body,
+ Query,
+ Headers,
+ NotGiven,
+)
from ..._utils import maybe_transform
from ..._resource import SyncAPIResource, AsyncAPIResource
from ..._response import to_raw_response_wrapper, async_to_raw_response_wrapper
from ...types.audio import speech_create_params
-from ..._base_client import HttpxBinaryResponseContent, make_request_options
+from ..._base_client import (
+ HttpxBinaryResponseContent,
+ make_request_options,
+)
if TYPE_CHECKING:
from ..._client import OpenAI, AsyncOpenAI
src/openai/resources/audio/transcriptions.py
@@ -7,12 +7,21 @@ from typing_extensions import Literal
import httpx
-from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven, FileTypes
+from ..._types import (
+ NOT_GIVEN,
+ Body,
+ Query,
+ Headers,
+ NotGiven,
+ FileTypes,
+)
from ..._utils import extract_files, maybe_transform, deepcopy_minimal
from ..._resource import SyncAPIResource, AsyncAPIResource
from ..._response import to_raw_response_wrapper, async_to_raw_response_wrapper
from ...types.audio import Transcription, transcription_create_params
-from ..._base_client import make_request_options
+from ..._base_client import (
+ make_request_options,
+)
if TYPE_CHECKING:
from ..._client import OpenAI, AsyncOpenAI
src/openai/resources/audio/translations.py
@@ -7,12 +7,21 @@ from typing_extensions import Literal
import httpx
-from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven, FileTypes
+from ..._types import (
+ NOT_GIVEN,
+ Body,
+ Query,
+ Headers,
+ NotGiven,
+ FileTypes,
+)
from ..._utils import extract_files, maybe_transform, deepcopy_minimal
from ..._resource import SyncAPIResource, AsyncAPIResource
from ..._response import to_raw_response_wrapper, async_to_raw_response_wrapper
from ...types.audio import Translation, translation_create_params
-from ..._base_client import make_request_options
+from ..._base_client import (
+ make_request_options,
+)
if TYPE_CHECKING:
from ..._client import OpenAI, AsyncOpenAI
src/openai/resources/beta/assistants/__init__.py
@@ -1,12 +1,7 @@
# File generated from our OpenAPI spec by Stainless.
from .files import Files, AsyncFiles, FilesWithRawResponse, AsyncFilesWithRawResponse
-from .assistants import (
- Assistants,
- AsyncAssistants,
- AssistantsWithRawResponse,
- AsyncAssistantsWithRawResponse,
-)
+from .assistants import Assistants, AsyncAssistants, AssistantsWithRawResponse, AsyncAssistantsWithRawResponse
__all__ = [
"Files",
src/openai/resources/beta/assistants/assistants.py
@@ -8,7 +8,13 @@ from typing_extensions import Literal
import httpx
from .files import Files, AsyncFiles, FilesWithRawResponse, AsyncFilesWithRawResponse
-from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven
+from ...._types import (
+ NOT_GIVEN,
+ Body,
+ Query,
+ Headers,
+ NotGiven,
+)
from ...._utils import maybe_transform
from ...._resource import SyncAPIResource, AsyncAPIResource
from ...._response import to_raw_response_wrapper, async_to_raw_response_wrapper
@@ -20,7 +26,10 @@ from ....types.beta import (
assistant_create_params,
assistant_update_params,
)
-from ...._base_client import AsyncPaginator, make_request_options
+from ...._base_client import (
+ AsyncPaginator,
+ make_request_options,
+)
if TYPE_CHECKING:
from ...._client import OpenAI, AsyncOpenAI
src/openai/resources/beta/assistants/files.py
@@ -7,12 +7,21 @@ from typing_extensions import Literal
import httpx
-from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven
+from ...._types import (
+ NOT_GIVEN,
+ Body,
+ Query,
+ Headers,
+ NotGiven,
+)
from ...._utils import maybe_transform
from ...._resource import SyncAPIResource, AsyncAPIResource
from ...._response import to_raw_response_wrapper, async_to_raw_response_wrapper
from ....pagination import SyncCursorPage, AsyncCursorPage
-from ...._base_client import AsyncPaginator, make_request_options
+from ...._base_client import (
+ AsyncPaginator,
+ make_request_options,
+)
from ....types.beta.assistants import (
AssistantFile,
FileDeleteResponse,
src/openai/resources/beta/threads/messages/__init__.py
@@ -1,12 +1,7 @@
# File generated from our OpenAPI spec by Stainless.
from .files import Files, AsyncFiles, FilesWithRawResponse, AsyncFilesWithRawResponse
-from .messages import (
- Messages,
- AsyncMessages,
- MessagesWithRawResponse,
- AsyncMessagesWithRawResponse,
-)
+from .messages import Messages, AsyncMessages, MessagesWithRawResponse, AsyncMessagesWithRawResponse
__all__ = [
"Files",
src/openai/resources/beta/threads/messages/files.py
@@ -7,12 +7,21 @@ from typing_extensions import Literal
import httpx
-from ....._types import NOT_GIVEN, Body, Query, Headers, NotGiven
+from ....._types import (
+ NOT_GIVEN,
+ Body,
+ Query,
+ Headers,
+ NotGiven,
+)
from ....._utils import maybe_transform
from ....._resource import SyncAPIResource, AsyncAPIResource
from ....._response import to_raw_response_wrapper, async_to_raw_response_wrapper
from .....pagination import SyncCursorPage, AsyncCursorPage
-from ....._base_client import AsyncPaginator, make_request_options
+from ....._base_client import (
+ AsyncPaginator,
+ make_request_options,
+)
from .....types.beta.threads.messages import MessageFile, file_list_params
if TYPE_CHECKING:
src/openai/resources/beta/threads/messages/messages.py
@@ -8,12 +8,21 @@ from typing_extensions import Literal
import httpx
from .files import Files, AsyncFiles, FilesWithRawResponse, AsyncFilesWithRawResponse
-from ....._types import NOT_GIVEN, Body, Query, Headers, NotGiven
+from ....._types import (
+ NOT_GIVEN,
+ Body,
+ Query,
+ Headers,
+ NotGiven,
+)
from ....._utils import maybe_transform
from ....._resource import SyncAPIResource, AsyncAPIResource
from ....._response import to_raw_response_wrapper, async_to_raw_response_wrapper
from .....pagination import SyncCursorPage, AsyncCursorPage
-from ....._base_client import AsyncPaginator, make_request_options
+from ....._base_client import (
+ AsyncPaginator,
+ make_request_options,
+)
from .....types.beta.threads import (
ThreadMessage,
message_list_params,
src/openai/resources/beta/threads/runs/runs.py
@@ -8,12 +8,21 @@ from typing_extensions import Literal
import httpx
from .steps import Steps, AsyncSteps, StepsWithRawResponse, AsyncStepsWithRawResponse
-from ....._types import NOT_GIVEN, Body, Query, Headers, NotGiven
+from ....._types import (
+ NOT_GIVEN,
+ Body,
+ Query,
+ Headers,
+ NotGiven,
+)
from ....._utils import maybe_transform
from ....._resource import SyncAPIResource, AsyncAPIResource
from ....._response import to_raw_response_wrapper, async_to_raw_response_wrapper
from .....pagination import SyncCursorPage, AsyncCursorPage
-from ....._base_client import AsyncPaginator, make_request_options
+from ....._base_client import (
+ AsyncPaginator,
+ make_request_options,
+)
from .....types.beta.threads import (
Run,
run_list_params,
src/openai/resources/beta/threads/runs/steps.py
@@ -7,12 +7,21 @@ from typing_extensions import Literal
import httpx
-from ....._types import NOT_GIVEN, Body, Query, Headers, NotGiven
+from ....._types import (
+ NOT_GIVEN,
+ Body,
+ Query,
+ Headers,
+ NotGiven,
+)
from ....._utils import maybe_transform
from ....._resource import SyncAPIResource, AsyncAPIResource
from ....._response import to_raw_response_wrapper, async_to_raw_response_wrapper
from .....pagination import SyncCursorPage, AsyncCursorPage
-from ....._base_client import AsyncPaginator, make_request_options
+from ....._base_client import (
+ AsyncPaginator,
+ make_request_options,
+)
from .....types.beta.threads.runs import RunStep, step_list_params
if TYPE_CHECKING:
src/openai/resources/beta/threads/__init__.py
@@ -1,18 +1,8 @@
# File generated from our OpenAPI spec by Stainless.
from .runs import Runs, AsyncRuns, RunsWithRawResponse, AsyncRunsWithRawResponse
-from .threads import (
- Threads,
- AsyncThreads,
- ThreadsWithRawResponse,
- AsyncThreadsWithRawResponse,
-)
-from .messages import (
- Messages,
- AsyncMessages,
- MessagesWithRawResponse,
- AsyncMessagesWithRawResponse,
-)
+from .threads import Threads, AsyncThreads, ThreadsWithRawResponse, AsyncThreadsWithRawResponse
+from .messages import Messages, AsyncMessages, MessagesWithRawResponse, AsyncMessagesWithRawResponse
__all__ = [
"Runs",
src/openai/resources/beta/threads/threads.py
@@ -7,13 +7,14 @@ from typing import TYPE_CHECKING, List, Optional
import httpx
from .runs import Runs, AsyncRuns, RunsWithRawResponse, AsyncRunsWithRawResponse
-from .messages import (
- Messages,
- AsyncMessages,
- MessagesWithRawResponse,
- AsyncMessagesWithRawResponse,
+from .messages import Messages, AsyncMessages, MessagesWithRawResponse, AsyncMessagesWithRawResponse
+from ...._types import (
+ NOT_GIVEN,
+ Body,
+ Query,
+ Headers,
+ NotGiven,
)
-from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven
from ...._utils import maybe_transform
from ...._resource import SyncAPIResource, AsyncAPIResource
from ...._response import to_raw_response_wrapper, async_to_raw_response_wrapper
@@ -24,7 +25,9 @@ from ....types.beta import (
thread_update_params,
thread_create_and_run_params,
)
-from ...._base_client import make_request_options
+from ...._base_client import (
+ make_request_options,
+)
from ....types.beta.threads import Run
if TYPE_CHECKING:
src/openai/resources/beta/__init__.py
@@ -1,18 +1,8 @@
# File generated from our OpenAPI spec by Stainless.
from .beta import Beta, AsyncBeta, BetaWithRawResponse, AsyncBetaWithRawResponse
-from .threads import (
- Threads,
- AsyncThreads,
- ThreadsWithRawResponse,
- AsyncThreadsWithRawResponse,
-)
-from .assistants import (
- Assistants,
- AsyncAssistants,
- AssistantsWithRawResponse,
- AsyncAssistantsWithRawResponse,
-)
+from .threads import Threads, AsyncThreads, ThreadsWithRawResponse, AsyncThreadsWithRawResponse
+from .assistants import Assistants, AsyncAssistants, AssistantsWithRawResponse, AsyncAssistantsWithRawResponse
__all__ = [
"Assistants",
src/openai/resources/beta/beta.py
@@ -4,18 +4,8 @@ from __future__ import annotations
from typing import TYPE_CHECKING
-from .threads import (
- Threads,
- AsyncThreads,
- ThreadsWithRawResponse,
- AsyncThreadsWithRawResponse,
-)
-from .assistants import (
- Assistants,
- AsyncAssistants,
- AssistantsWithRawResponse,
- AsyncAssistantsWithRawResponse,
-)
+from .threads import Threads, AsyncThreads, ThreadsWithRawResponse, AsyncThreadsWithRawResponse
+from .assistants import Assistants, AsyncAssistants, AssistantsWithRawResponse, AsyncAssistantsWithRawResponse
from ..._resource import SyncAPIResource, AsyncAPIResource
if TYPE_CHECKING:
src/openai/resources/chat/__init__.py
@@ -1,12 +1,7 @@
# File generated from our OpenAPI spec by Stainless.
from .chat import Chat, AsyncChat, ChatWithRawResponse, AsyncChatWithRawResponse
-from .completions import (
- Completions,
- AsyncCompletions,
- CompletionsWithRawResponse,
- AsyncCompletionsWithRawResponse,
-)
+from .completions import Completions, AsyncCompletions, CompletionsWithRawResponse, AsyncCompletionsWithRawResponse
__all__ = [
"Completions",
src/openai/resources/chat/chat.py
@@ -5,12 +5,7 @@ from __future__ import annotations
from typing import TYPE_CHECKING
from ..._resource import SyncAPIResource, AsyncAPIResource
-from .completions import (
- Completions,
- AsyncCompletions,
- CompletionsWithRawResponse,
- AsyncCompletionsWithRawResponse,
-)
+from .completions import Completions, AsyncCompletions, CompletionsWithRawResponse, AsyncCompletionsWithRawResponse
if TYPE_CHECKING:
from ..._client import OpenAI, AsyncOpenAI
src/openai/resources/chat/completions.py
@@ -7,7 +7,13 @@ from typing_extensions import Literal
import httpx
-from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
+from ..._types import (
+ NOT_GIVEN,
+ Body,
+ Query,
+ Headers,
+ NotGiven,
+)
from ..._utils import required_args, maybe_transform
from ..._resource import SyncAPIResource, AsyncAPIResource
from ..._response import to_raw_response_wrapper, async_to_raw_response_wrapper
@@ -20,7 +26,9 @@ from ...types.chat import (
ChatCompletionToolChoiceOptionParam,
completion_create_params,
)
-from ..._base_client import make_request_options
+from ..._base_client import (
+ make_request_options,
+)
if TYPE_CHECKING:
from ..._client import OpenAI, AsyncOpenAI
src/openai/resources/fine_tuning/__init__.py
@@ -1,12 +1,7 @@
# File generated from our OpenAPI spec by Stainless.
from .jobs import Jobs, AsyncJobs, JobsWithRawResponse, AsyncJobsWithRawResponse
-from .fine_tuning import (
- FineTuning,
- AsyncFineTuning,
- FineTuningWithRawResponse,
- AsyncFineTuningWithRawResponse,
-)
+from .fine_tuning import FineTuning, AsyncFineTuning, FineTuningWithRawResponse, AsyncFineTuningWithRawResponse
__all__ = [
"Jobs",
src/openai/resources/fine_tuning/jobs.py
@@ -7,12 +7,21 @@ from typing_extensions import Literal
import httpx
-from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
+from ..._types import (
+ NOT_GIVEN,
+ Body,
+ Query,
+ Headers,
+ NotGiven,
+)
from ..._utils import maybe_transform
from ..._resource import SyncAPIResource, AsyncAPIResource
from ..._response import to_raw_response_wrapper, async_to_raw_response_wrapper
from ...pagination import SyncCursorPage, AsyncCursorPage
-from ..._base_client import AsyncPaginator, make_request_options
+from ..._base_client import (
+ AsyncPaginator,
+ make_request_options,
+)
from ...types.fine_tuning import (
FineTuningJob,
FineTuningJobEvent,
src/openai/resources/__init__.py
@@ -5,48 +5,13 @@ from .chat import Chat, AsyncChat, ChatWithRawResponse, AsyncChatWithRawResponse
from .audio import Audio, AsyncAudio, AudioWithRawResponse, AsyncAudioWithRawResponse
from .edits import Edits, AsyncEdits, EditsWithRawResponse, AsyncEditsWithRawResponse
from .files import Files, AsyncFiles, FilesWithRawResponse, AsyncFilesWithRawResponse
-from .images import (
- Images,
- AsyncImages,
- ImagesWithRawResponse,
- AsyncImagesWithRawResponse,
-)
-from .models import (
- Models,
- AsyncModels,
- ModelsWithRawResponse,
- AsyncModelsWithRawResponse,
-)
-from .embeddings import (
- Embeddings,
- AsyncEmbeddings,
- EmbeddingsWithRawResponse,
- AsyncEmbeddingsWithRawResponse,
-)
-from .fine_tunes import (
- FineTunes,
- AsyncFineTunes,
- FineTunesWithRawResponse,
- AsyncFineTunesWithRawResponse,
-)
-from .completions import (
- Completions,
- AsyncCompletions,
- CompletionsWithRawResponse,
- AsyncCompletionsWithRawResponse,
-)
-from .fine_tuning import (
- FineTuning,
- AsyncFineTuning,
- FineTuningWithRawResponse,
- AsyncFineTuningWithRawResponse,
-)
-from .moderations import (
- Moderations,
- AsyncModerations,
- ModerationsWithRawResponse,
- AsyncModerationsWithRawResponse,
-)
+from .images import Images, AsyncImages, ImagesWithRawResponse, AsyncImagesWithRawResponse
+from .models import Models, AsyncModels, ModelsWithRawResponse, AsyncModelsWithRawResponse
+from .embeddings import Embeddings, AsyncEmbeddings, EmbeddingsWithRawResponse, AsyncEmbeddingsWithRawResponse
+from .fine_tunes import FineTunes, AsyncFineTunes, FineTunesWithRawResponse, AsyncFineTunesWithRawResponse
+from .completions import Completions, AsyncCompletions, CompletionsWithRawResponse, AsyncCompletionsWithRawResponse
+from .fine_tuning import FineTuning, AsyncFineTuning, FineTuningWithRawResponse, AsyncFineTuningWithRawResponse
+from .moderations import Moderations, AsyncModerations, ModerationsWithRawResponse, AsyncModerationsWithRawResponse
__all__ = [
"Completions",
src/openai/resources/completions.py
@@ -8,12 +8,20 @@ from typing_extensions import Literal
import httpx
from ..types import Completion, completion_create_params
-from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
+from .._types import (
+ NOT_GIVEN,
+ Body,
+ Query,
+ Headers,
+ NotGiven,
+)
from .._utils import required_args, maybe_transform
from .._resource import SyncAPIResource, AsyncAPIResource
from .._response import to_raw_response_wrapper, async_to_raw_response_wrapper
from .._streaming import Stream, AsyncStream
-from .._base_client import make_request_options
+from .._base_client import (
+ make_request_options,
+)
if TYPE_CHECKING:
from .._client import OpenAI, AsyncOpenAI
src/openai/resources/edits.py
@@ -9,11 +9,19 @@ from typing_extensions import Literal
import httpx
from ..types import Edit, edit_create_params
-from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
+from .._types import (
+ NOT_GIVEN,
+ Body,
+ Query,
+ Headers,
+ NotGiven,
+)
from .._utils import maybe_transform
from .._resource import SyncAPIResource, AsyncAPIResource
from .._response import to_raw_response_wrapper, async_to_raw_response_wrapper
-from .._base_client import make_request_options
+from .._base_client import (
+ make_request_options,
+)
if TYPE_CHECKING:
from .._client import OpenAI, AsyncOpenAI
src/openai/resources/embeddings.py
@@ -9,13 +9,20 @@ from typing_extensions import Literal
import httpx
from ..types import CreateEmbeddingResponse, embedding_create_params
-from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
+from .._types import (
+ NOT_GIVEN,
+ Body,
+ Query,
+ Headers,
+ NotGiven,
+)
from .._utils import is_given, maybe_transform
-from .._extras import numpy as np
-from .._extras import has_numpy
+from .._extras import numpy as np, has_numpy
from .._resource import SyncAPIResource, AsyncAPIResource
from .._response import to_raw_response_wrapper, async_to_raw_response_wrapper
-from .._base_client import make_request_options
+from .._base_client import (
+ make_request_options,
+)
if TYPE_CHECKING:
from .._client import OpenAI, AsyncOpenAI
src/openai/resources/files.py
@@ -9,8 +9,20 @@ from typing_extensions import Literal
import httpx
-from ..types import FileObject, FileDeleted, file_list_params, file_create_params
-from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven, FileTypes
+from ..types import (
+ FileObject,
+ FileDeleted,
+ file_list_params,
+ file_create_params,
+)
+from .._types import (
+ NOT_GIVEN,
+ Body,
+ Query,
+ Headers,
+ NotGiven,
+ FileTypes,
+)
from .._utils import extract_files, maybe_transform, deepcopy_minimal
from .._resource import SyncAPIResource, AsyncAPIResource
from .._response import to_raw_response_wrapper, async_to_raw_response_wrapper
src/openai/resources/fine_tunes.py
@@ -14,13 +14,22 @@ from ..types import (
fine_tune_create_params,
fine_tune_list_events_params,
)
-from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
+from .._types import (
+ NOT_GIVEN,
+ Body,
+ Query,
+ Headers,
+ NotGiven,
+)
from .._utils import maybe_transform
from .._resource import SyncAPIResource, AsyncAPIResource
from .._response import to_raw_response_wrapper, async_to_raw_response_wrapper
from .._streaming import Stream, AsyncStream
from ..pagination import SyncPage, AsyncPage
-from .._base_client import AsyncPaginator, make_request_options
+from .._base_client import (
+ AsyncPaginator,
+ make_request_options,
+)
if TYPE_CHECKING:
from .._client import OpenAI, AsyncOpenAI
src/openai/resources/images.py
@@ -13,11 +13,20 @@ from ..types import (
image_generate_params,
image_create_variation_params,
)
-from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven, FileTypes
+from .._types import (
+ NOT_GIVEN,
+ Body,
+ Query,
+ Headers,
+ NotGiven,
+ FileTypes,
+)
from .._utils import extract_files, maybe_transform, deepcopy_minimal
from .._resource import SyncAPIResource, AsyncAPIResource
from .._response import to_raw_response_wrapper, async_to_raw_response_wrapper
-from .._base_client import make_request_options
+from .._base_client import (
+ make_request_options,
+)
if TYPE_CHECKING:
from .._client import OpenAI, AsyncOpenAI
src/openai/resources/models.py
@@ -7,11 +7,20 @@ from typing import TYPE_CHECKING
import httpx
from ..types import Model, ModelDeleted
-from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
+from .._types import (
+ NOT_GIVEN,
+ Body,
+ Query,
+ Headers,
+ NotGiven,
+)
from .._resource import SyncAPIResource, AsyncAPIResource
from .._response import to_raw_response_wrapper, async_to_raw_response_wrapper
from ..pagination import SyncPage, AsyncPage
-from .._base_client import AsyncPaginator, make_request_options
+from .._base_client import (
+ AsyncPaginator,
+ make_request_options,
+)
if TYPE_CHECKING:
from .._client import OpenAI, AsyncOpenAI
src/openai/resources/moderations.py
@@ -8,11 +8,19 @@ from typing_extensions import Literal
import httpx
from ..types import ModerationCreateResponse, moderation_create_params
-from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
+from .._types import (
+ NOT_GIVEN,
+ Body,
+ Query,
+ Headers,
+ NotGiven,
+)
from .._utils import maybe_transform
from .._resource import SyncAPIResource, AsyncAPIResource
from .._response import to_raw_response_wrapper, async_to_raw_response_wrapper
-from .._base_client import make_request_options
+from .._base_client import (
+ make_request_options,
+)
if TYPE_CHECKING:
from .._client import OpenAI, AsyncOpenAI
src/openai/types/audio/__init__.py
@@ -5,9 +5,5 @@ from __future__ import annotations
from .translation import Translation as Translation
from .transcription import Transcription as Transcription
from .speech_create_params import SpeechCreateParams as SpeechCreateParams
-from .translation_create_params import (
- TranslationCreateParams as TranslationCreateParams,
-)
-from .transcription_create_params import (
- TranscriptionCreateParams as TranscriptionCreateParams,
-)
+from .translation_create_params import TranslationCreateParams as TranslationCreateParams
+from .transcription_create_params import TranscriptionCreateParams as TranscriptionCreateParams
src/openai/types/beta/threads/runs/__init__.py
@@ -8,6 +8,4 @@ from .step_list_params import StepListParams as StepListParams
from .function_tool_call import FunctionToolCall as FunctionToolCall
from .retrieval_tool_call import RetrievalToolCall as RetrievalToolCall
from .tool_calls_step_details import ToolCallsStepDetails as ToolCallsStepDetails
-from .message_creation_step_details import (
- MessageCreationStepDetails as MessageCreationStepDetails,
-)
+from .message_creation_step_details import MessageCreationStepDetails as MessageCreationStepDetails
src/openai/types/beta/threads/__init__.py
@@ -11,12 +11,6 @@ from .message_list_params import MessageListParams as MessageListParams
from .message_content_text import MessageContentText as MessageContentText
from .message_create_params import MessageCreateParams as MessageCreateParams
from .message_update_params import MessageUpdateParams as MessageUpdateParams
-from .message_content_image_file import (
- MessageContentImageFile as MessageContentImageFile,
-)
-from .run_submit_tool_outputs_params import (
- RunSubmitToolOutputsParams as RunSubmitToolOutputsParams,
-)
-from .required_action_function_tool_call import (
- RequiredActionFunctionToolCall as RequiredActionFunctionToolCall,
-)
+from .message_content_image_file import MessageContentImageFile as MessageContentImageFile
+from .run_submit_tool_outputs_params import RunSubmitToolOutputsParams as RunSubmitToolOutputsParams
+from .required_action_function_tool_call import RequiredActionFunctionToolCall as RequiredActionFunctionToolCall
src/openai/types/beta/__init__.py
@@ -11,6 +11,4 @@ from .thread_update_params import ThreadUpdateParams as ThreadUpdateParams
from .assistant_list_params import AssistantListParams as AssistantListParams
from .assistant_create_params import AssistantCreateParams as AssistantCreateParams
from .assistant_update_params import AssistantUpdateParams as AssistantUpdateParams
-from .thread_create_and_run_params import (
- ThreadCreateAndRunParams as ThreadCreateAndRunParams,
-)
+from .thread_create_and_run_params import ThreadCreateAndRunParams as ThreadCreateAndRunParams
src/openai/types/chat/__init__.py
@@ -7,27 +7,13 @@ from .chat_completion_role import ChatCompletionRole as ChatCompletionRole
from .chat_completion_chunk import ChatCompletionChunk as ChatCompletionChunk
from .chat_completion_message import ChatCompletionMessage as ChatCompletionMessage
from .completion_create_params import CompletionCreateParams as CompletionCreateParams
-from .chat_completion_tool_param import (
- ChatCompletionToolParam as ChatCompletionToolParam,
-)
-from .chat_completion_message_param import (
- ChatCompletionMessageParam as ChatCompletionMessageParam,
-)
-from .chat_completion_message_tool_call import (
- ChatCompletionMessageToolCall as ChatCompletionMessageToolCall,
-)
-from .chat_completion_content_part_param import (
- ChatCompletionContentPartParam as ChatCompletionContentPartParam,
-)
-from .chat_completion_tool_message_param import (
- ChatCompletionToolMessageParam as ChatCompletionToolMessageParam,
-)
-from .chat_completion_user_message_param import (
- ChatCompletionUserMessageParam as ChatCompletionUserMessageParam,
-)
-from .chat_completion_system_message_param import (
- ChatCompletionSystemMessageParam as ChatCompletionSystemMessageParam,
-)
+from .chat_completion_tool_param import ChatCompletionToolParam as ChatCompletionToolParam
+from .chat_completion_message_param import ChatCompletionMessageParam as ChatCompletionMessageParam
+from .chat_completion_message_tool_call import ChatCompletionMessageToolCall as ChatCompletionMessageToolCall
+from .chat_completion_content_part_param import ChatCompletionContentPartParam as ChatCompletionContentPartParam
+from .chat_completion_tool_message_param import ChatCompletionToolMessageParam as ChatCompletionToolMessageParam
+from .chat_completion_user_message_param import ChatCompletionUserMessageParam as ChatCompletionUserMessageParam
+from .chat_completion_system_message_param import ChatCompletionSystemMessageParam as ChatCompletionSystemMessageParam
from .chat_completion_function_message_param import (
ChatCompletionFunctionMessageParam as ChatCompletionFunctionMessageParam,
)
src/openai/types/chat/chat_completion_content_part_param.py
@@ -5,9 +5,7 @@ from __future__ import annotations
from typing import Union
from .chat_completion_content_part_text_param import ChatCompletionContentPartTextParam
-from .chat_completion_content_part_image_param import (
- ChatCompletionContentPartImageParam,
-)
+from .chat_completion_content_part_image_param import ChatCompletionContentPartImageParam
__all__ = ["ChatCompletionContentPartParam"]
src/openai/types/chat/completion_create_params.py
@@ -8,12 +8,8 @@ from typing_extensions import Literal, Required, TypedDict
from ...types import shared_params
from .chat_completion_tool_param import ChatCompletionToolParam
from .chat_completion_message_param import ChatCompletionMessageParam
-from .chat_completion_tool_choice_option_param import (
- ChatCompletionToolChoiceOptionParam,
-)
-from .chat_completion_function_call_option_param import (
- ChatCompletionFunctionCallOptionParam,
-)
+from .chat_completion_tool_choice_option_param import ChatCompletionToolChoiceOptionParam
+from .chat_completion_function_call_option_param import ChatCompletionFunctionCallOptionParam
__all__ = [
"CompletionCreateParamsBase",
src/openai/types/__init__.py
@@ -5,8 +5,7 @@ from __future__ import annotations
from .edit import Edit as Edit
from .image import Image as Image
from .model import Model as Model
-from .shared import FunctionDefinition as FunctionDefinition
-from .shared import FunctionParameters as FunctionParameters
+from .shared import FunctionDefinition as FunctionDefinition, FunctionParameters as FunctionParameters
from .embedding import Embedding as Embedding
from .fine_tune import FineTune as FineTune
from .completion import Completion as Completion
@@ -28,18 +27,8 @@ from .embedding_create_params import EmbeddingCreateParams as EmbeddingCreatePar
from .fine_tune_create_params import FineTuneCreateParams as FineTuneCreateParams
from .completion_create_params import CompletionCreateParams as CompletionCreateParams
from .moderation_create_params import ModerationCreateParams as ModerationCreateParams
-from .create_embedding_response import (
- CreateEmbeddingResponse as CreateEmbeddingResponse,
-)
-from .moderation_create_response import (
- ModerationCreateResponse as ModerationCreateResponse,
-)
-from .fine_tune_list_events_params import (
- FineTuneListEventsParams as FineTuneListEventsParams,
-)
-from .image_create_variation_params import (
- ImageCreateVariationParams as ImageCreateVariationParams,
-)
-from .fine_tune_events_list_response import (
- FineTuneEventsListResponse as FineTuneEventsListResponse,
-)
+from .create_embedding_response import CreateEmbeddingResponse as CreateEmbeddingResponse
+from .moderation_create_response import ModerationCreateResponse as ModerationCreateResponse
+from .fine_tune_list_events_params import FineTuneListEventsParams as FineTuneListEventsParams
+from .image_create_variation_params import ImageCreateVariationParams as ImageCreateVariationParams
+from .fine_tune_events_list_response import FineTuneEventsListResponse as FineTuneEventsListResponse
src/openai/__init__.py
@@ -72,8 +72,7 @@ __all__ = [
from .lib import azure as _azure
from .version import VERSION as VERSION
-from .lib.azure import AzureOpenAI as AzureOpenAI
-from .lib.azure import AsyncAzureOpenAI as AsyncAzureOpenAI
+from .lib.azure import AzureOpenAI as AzureOpenAI, AsyncAzureOpenAI as AsyncAzureOpenAI
from .lib._old_api import *
_setup_logging()
@@ -330,15 +329,17 @@ def _reset_client() -> None: # type: ignore[reportUnusedFunction]
_client = None
-from ._module_client import beta as beta
-from ._module_client import chat as chat
-from ._module_client import audio as audio
-from ._module_client import edits as edits
-from ._module_client import files as files
-from ._module_client import images as images
-from ._module_client import models as models
-from ._module_client import embeddings as embeddings
-from ._module_client import fine_tunes as fine_tunes
-from ._module_client import completions as completions
-from ._module_client import fine_tuning as fine_tuning
-from ._module_client import moderations as moderations
+from ._module_client import (
+ beta as beta,
+ chat as chat,
+ audio as audio,
+ edits as edits,
+ files as files,
+ images as images,
+ models as models,
+ embeddings as embeddings,
+ fine_tunes as fine_tunes,
+ completions as completions,
+ fine_tuning as fine_tuning,
+ moderations as moderations,
+)
src/openai/_client.py
@@ -22,8 +22,7 @@ from ._types import (
)
from ._utils import is_given, is_mapping, get_async_library
from ._version import __version__
-from ._streaming import Stream as Stream
-from ._streaming import AsyncStream as AsyncStream
+from ._streaming import Stream as Stream, AsyncStream as AsyncStream
from ._exceptions import OpenAIError, APIStatusError
from ._base_client import DEFAULT_MAX_RETRIES, SyncAPIClient, AsyncAPIClient
src/openai/_compat.py
@@ -43,21 +43,23 @@ if TYPE_CHECKING:
else:
if PYDANTIC_V2:
- from pydantic.v1.typing import get_args as get_args
- from pydantic.v1.typing import is_union as is_union
- from pydantic.v1.typing import get_origin as get_origin
- from pydantic.v1.typing import is_typeddict as is_typeddict
- from pydantic.v1.typing import is_literal_type as is_literal_type
- from pydantic.v1.datetime_parse import parse_date as parse_date
- from pydantic.v1.datetime_parse import parse_datetime as parse_datetime
+ from pydantic.v1.typing import (
+ get_args as get_args,
+ is_union as is_union,
+ get_origin as get_origin,
+ is_typeddict as is_typeddict,
+ is_literal_type as is_literal_type,
+ )
+ from pydantic.v1.datetime_parse import parse_date as parse_date, parse_datetime as parse_datetime
else:
- from pydantic.typing import get_args as get_args
- from pydantic.typing import is_union as is_union
- from pydantic.typing import get_origin as get_origin
- from pydantic.typing import is_typeddict as is_typeddict
- from pydantic.typing import is_literal_type as is_literal_type
- from pydantic.datetime_parse import parse_date as parse_date
- from pydantic.datetime_parse import parse_datetime as parse_datetime
+ from pydantic.typing import (
+ get_args as get_args,
+ is_union as is_union,
+ get_origin as get_origin,
+ is_typeddict as is_typeddict,
+ is_literal_type as is_literal_type,
+ )
+ from pydantic.datetime_parse import parse_date as parse_date, parse_datetime as parse_datetime
# refactored config
src/openai/_models.py
@@ -30,17 +30,11 @@ from ._types import (
AnyMapping,
HttpxRequestFiles,
)
-from ._utils import (
- is_list,
- is_given,
- is_mapping,
- parse_date,
- parse_datetime,
- strip_not_given,
-)
-from ._compat import PYDANTIC_V2, ConfigDict
-from ._compat import GenericModel as BaseGenericModel
+from ._utils import is_list, is_given, is_mapping, parse_date, parse_datetime, strip_not_given
from ._compat import (
+ PYDANTIC_V2,
+ ConfigDict,
+ GenericModel as BaseGenericModel,
get_args,
is_union,
parse_obj,
src/openai/_types.py
@@ -19,14 +19,7 @@ from typing import (
Sequence,
AsyncIterator,
)
-from typing_extensions import (
- Literal,
- Protocol,
- TypeAlias,
- TypedDict,
- override,
- runtime_checkable,
-)
+from typing_extensions import Literal, Protocol, TypeAlias, TypedDict, override, runtime_checkable
import pydantic
from httpx import URL, Proxy, Timeout, Response, BaseTransport, AsyncBaseTransport
tests/api_resources/beta/threads/test_runs.py
@@ -10,7 +10,9 @@ from openai import OpenAI, AsyncOpenAI
from tests.utils import assert_matches_type
from openai._client import OpenAI, AsyncOpenAI
from openai.pagination import SyncCursorPage, AsyncCursorPage
-from openai.types.beta.threads import Run
+from openai.types.beta.threads import (
+ Run,
+)
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
api_key = "My API Key"
tests/api_resources/beta/test_assistants.py
@@ -10,7 +10,10 @@ from openai import OpenAI, AsyncOpenAI
from tests.utils import assert_matches_type
from openai._client import OpenAI, AsyncOpenAI
from openai.pagination import SyncCursorPage, AsyncCursorPage
-from openai.types.beta import Assistant, AssistantDeleted
+from openai.types.beta import (
+ Assistant,
+ AssistantDeleted,
+)
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
api_key = "My API Key"
tests/api_resources/beta/test_threads.py
@@ -9,7 +9,10 @@ import pytest
from openai import OpenAI, AsyncOpenAI
from tests.utils import assert_matches_type
from openai._client import OpenAI, AsyncOpenAI
-from openai.types.beta import Thread, ThreadDeleted
+from openai.types.beta import (
+ Thread,
+ ThreadDeleted,
+)
from openai.types.beta.threads import Run
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
tests/api_resources/fine_tuning/test_jobs.py
@@ -10,7 +10,10 @@ from openai import OpenAI, AsyncOpenAI
from tests.utils import assert_matches_type
from openai._client import OpenAI, AsyncOpenAI
from openai.pagination import SyncCursorPage, AsyncCursorPage
-from openai.types.fine_tuning import FineTuningJob, FineTuningJobEvent
+from openai.types.fine_tuning import (
+ FineTuningJob,
+ FineTuningJobEvent,
+)
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
api_key = "My API Key"
tests/utils.py
@@ -8,7 +8,12 @@ from datetime import date, datetime
from typing_extensions import Literal, get_args, get_origin, assert_type
from openai._types import NoneType
-from openai._utils import is_dict, is_list, is_list_type, is_union_type
+from openai._utils import (
+ is_dict,
+ is_list,
+ is_list_type,
+ is_union_type,
+)
from openai._compat import PYDANTIC_V2, field_outer_type, get_model_fields
from openai._models import BaseModel
pyproject.toml
@@ -48,16 +48,16 @@ openai = "openai.cli:main"
[tool.rye]
managed = true
dev-dependencies = [
- "pyright==1.1.332",
- "mypy==1.7.1",
- "black==23.3.0",
- "respx==0.20.2",
- "pytest==7.1.1",
- "pytest-asyncio==0.21.1",
- "ruff==0.0.282",
- "isort==5.10.1",
- "time-machine==2.9.0",
- "nox==2023.4.22",
+ # version pins are in requirements-dev.lock
+ "pyright",
+ "mypy",
+ "black",
+ "respx",
+ "pytest",
+ "pytest-asyncio",
+ "ruff",
+ "time-machine",
+ "nox",
"dirty-equals>=0.6.0",
"azure-identity >=1.14.1",
"types-tqdm > 4"
@@ -68,12 +68,10 @@ format = { chain = [
"format:black",
"format:docs",
"format:ruff",
- "format:isort",
]}
"format:black" = "black ."
"format:docs" = "python bin/blacken-docs.py README.md api.md"
"format:ruff" = "ruff --fix ."
-"format:isort" = "isort ."
"check:ruff" = "ruff ."
@@ -128,16 +126,13 @@ reportImplicitOverride = true
reportImportCycles = false
reportPrivateUsage = false
-[tool.isort]
-profile = "black"
-length_sort = true
-extra_standard_library = ["typing_extensions"]
-
[tool.ruff]
line-length = 120
-format = "grouped"
+output-format = "grouped"
target-version = "py37"
select = [
+ # isort
+ "I",
# remove unused imports
"F401",
# bare except statements
@@ -155,6 +150,12 @@ unfixable = [
]
ignore-init-module-imports = true
+[tool.ruff.lint.isort]
+length-sort = true
+length-sort-straight = true
+combine-as-imports = true
+extra-standard-library = ["typing_extensions"]
+known-first-party = ["openai", "tests"]
[tool.ruff.per-file-ignores]
"bin/**.py" = ["T201", "T203"]
requirements-dev.lock
@@ -30,8 +30,7 @@ httpcore==1.0.2
httpx==0.25.2
idna==3.4
iniconfig==2.0.0
-isort==5.10.1
-msal==1.25.0
+msal==1.26.0
msal-extensions==1.0.0
mypy==1.7.1
mypy-extensions==1.0.0
@@ -57,7 +56,7 @@ python-dateutil==2.8.2
pytz==2023.3.post1
requests==2.31.0
respx==0.20.2
-ruff==0.0.282
+ruff==0.1.7
six==1.16.0
sniffio==1.3.0
time-machine==2.9.0