From a06cb39ecf937cefdd05e8a56bf294fcdd5166e5 Mon Sep 17 00:00:00 2001 From: Stainless Bot Date: Wed, 17 Jan 2024 17:25:10 +0000 Subject: [PATCH] chore: lazy load raw resource class properties --- src/openai/resources/audio/audio.py | 64 +++++++++++++++---- src/openai/resources/audio/speech.py | 8 +++ src/openai/resources/audio/transcriptions.py | 8 +++ src/openai/resources/audio/translations.py | 8 +++ .../resources/beta/assistants/assistants.py | 24 +++++-- src/openai/resources/beta/assistants/files.py | 8 +++ src/openai/resources/beta/beta.py | 44 ++++++++++--- .../resources/beta/threads/messages/files.py | 8 +++ .../beta/threads/messages/messages.py | 24 +++++-- .../resources/beta/threads/runs/runs.py | 24 +++++-- .../resources/beta/threads/runs/steps.py | 8 +++ src/openai/resources/beta/threads/threads.py | 44 ++++++++++--- src/openai/resources/chat/chat.py | 24 +++++-- src/openai/resources/chat/completions.py | 8 +++ src/openai/resources/completions.py | 8 +++ src/openai/resources/embeddings.py | 8 +++ src/openai/resources/files.py | 8 +++ .../resources/fine_tuning/fine_tuning.py | 24 +++++-- src/openai/resources/fine_tuning/jobs.py | 8 +++ src/openai/resources/images.py | 8 +++ src/openai/resources/models.py | 8 +++ src/openai/resources/moderations.py | 8 +++ 22 files changed, 336 insertions(+), 48 deletions(-) diff --git a/src/openai/resources/audio/audio.py b/src/openai/resources/audio/audio.py index b14e64cff6..bafacf4422 100644 --- a/src/openai/resources/audio/audio.py +++ b/src/openai/resources/audio/audio.py @@ -78,27 +78,67 @@ def with_streaming_response(self) -> AsyncAudioWithStreamingResponse: class AudioWithRawResponse: def __init__(self, audio: Audio) -> None: - self.transcriptions = TranscriptionsWithRawResponse(audio.transcriptions) - self.translations = TranslationsWithRawResponse(audio.translations) - self.speech = SpeechWithRawResponse(audio.speech) + self._audio = audio + + @cached_property + def transcriptions(self) -> TranscriptionsWithRawResponse: + return TranscriptionsWithRawResponse(self._audio.transcriptions) + + @cached_property + def translations(self) -> TranslationsWithRawResponse: + return TranslationsWithRawResponse(self._audio.translations) + + @cached_property + def speech(self) -> SpeechWithRawResponse: + return SpeechWithRawResponse(self._audio.speech) class AsyncAudioWithRawResponse: def __init__(self, audio: AsyncAudio) -> None: - self.transcriptions = AsyncTranscriptionsWithRawResponse(audio.transcriptions) - self.translations = AsyncTranslationsWithRawResponse(audio.translations) - self.speech = AsyncSpeechWithRawResponse(audio.speech) + self._audio = audio + + @cached_property + def transcriptions(self) -> AsyncTranscriptionsWithRawResponse: + return AsyncTranscriptionsWithRawResponse(self._audio.transcriptions) + + @cached_property + def translations(self) -> AsyncTranslationsWithRawResponse: + return AsyncTranslationsWithRawResponse(self._audio.translations) + + @cached_property + def speech(self) -> AsyncSpeechWithRawResponse: + return AsyncSpeechWithRawResponse(self._audio.speech) class AudioWithStreamingResponse: def __init__(self, audio: Audio) -> None: - self.transcriptions = TranscriptionsWithStreamingResponse(audio.transcriptions) - self.translations = TranslationsWithStreamingResponse(audio.translations) - self.speech = SpeechWithStreamingResponse(audio.speech) + self._audio = audio + + @cached_property + def transcriptions(self) -> TranscriptionsWithStreamingResponse: + return TranscriptionsWithStreamingResponse(self._audio.transcriptions) + + @cached_property + def translations(self) -> TranslationsWithStreamingResponse: + return TranslationsWithStreamingResponse(self._audio.translations) + + @cached_property + def speech(self) -> SpeechWithStreamingResponse: + return SpeechWithStreamingResponse(self._audio.speech) class AsyncAudioWithStreamingResponse: def __init__(self, audio: AsyncAudio) -> None: - self.transcriptions = AsyncTranscriptionsWithStreamingResponse(audio.transcriptions) - self.translations = AsyncTranslationsWithStreamingResponse(audio.translations) - self.speech = AsyncSpeechWithStreamingResponse(audio.speech) + self._audio = audio + + @cached_property + def transcriptions(self) -> AsyncTranscriptionsWithStreamingResponse: + return AsyncTranscriptionsWithStreamingResponse(self._audio.transcriptions) + + @cached_property + def translations(self) -> AsyncTranslationsWithStreamingResponse: + return AsyncTranslationsWithStreamingResponse(self._audio.translations) + + @cached_property + def speech(self) -> AsyncSpeechWithStreamingResponse: + return AsyncSpeechWithStreamingResponse(self._audio.speech) diff --git a/src/openai/resources/audio/speech.py b/src/openai/resources/audio/speech.py index 9c051624d5..4e94d4aaef 100644 --- a/src/openai/resources/audio/speech.py +++ b/src/openai/resources/audio/speech.py @@ -170,6 +170,8 @@ async def create( class SpeechWithRawResponse: def __init__(self, speech: Speech) -> None: + self._speech = speech + self.create = _legacy_response.to_raw_response_wrapper( speech.create, ) @@ -177,6 +179,8 @@ def __init__(self, speech: Speech) -> None: class AsyncSpeechWithRawResponse: def __init__(self, speech: AsyncSpeech) -> None: + self._speech = speech + self.create = _legacy_response.async_to_raw_response_wrapper( speech.create, ) @@ -184,6 +188,8 @@ def __init__(self, speech: AsyncSpeech) -> None: class SpeechWithStreamingResponse: def __init__(self, speech: Speech) -> None: + self._speech = speech + self.create = to_custom_streamed_response_wrapper( speech.create, StreamedBinaryAPIResponse, @@ -192,6 +198,8 @@ def __init__(self, speech: Speech) -> None: class AsyncSpeechWithStreamingResponse: def __init__(self, speech: AsyncSpeech) -> None: + self._speech = speech + self.create = async_to_custom_streamed_response_wrapper( speech.create, AsyncStreamedBinaryAPIResponse, diff --git a/src/openai/resources/audio/transcriptions.py b/src/openai/resources/audio/transcriptions.py index 868ce7725f..2c167be395 100644 --- a/src/openai/resources/audio/transcriptions.py +++ b/src/openai/resources/audio/transcriptions.py @@ -199,6 +199,8 @@ async def create( class TranscriptionsWithRawResponse: def __init__(self, transcriptions: Transcriptions) -> None: + self._transcriptions = transcriptions + self.create = _legacy_response.to_raw_response_wrapper( transcriptions.create, ) @@ -206,6 +208,8 @@ def __init__(self, transcriptions: Transcriptions) -> None: class AsyncTranscriptionsWithRawResponse: def __init__(self, transcriptions: AsyncTranscriptions) -> None: + self._transcriptions = transcriptions + self.create = _legacy_response.async_to_raw_response_wrapper( transcriptions.create, ) @@ -213,6 +217,8 @@ def __init__(self, transcriptions: AsyncTranscriptions) -> None: class TranscriptionsWithStreamingResponse: def __init__(self, transcriptions: Transcriptions) -> None: + self._transcriptions = transcriptions + self.create = to_streamed_response_wrapper( transcriptions.create, ) @@ -220,6 +226,8 @@ def __init__(self, transcriptions: Transcriptions) -> None: class AsyncTranscriptionsWithStreamingResponse: def __init__(self, transcriptions: AsyncTranscriptions) -> None: + self._transcriptions = transcriptions + self.create = async_to_streamed_response_wrapper( transcriptions.create, ) diff --git a/src/openai/resources/audio/translations.py b/src/openai/resources/audio/translations.py index 333abfb4cf..d6cbc75886 100644 --- a/src/openai/resources/audio/translations.py +++ b/src/openai/resources/audio/translations.py @@ -185,6 +185,8 @@ async def create( class TranslationsWithRawResponse: def __init__(self, translations: Translations) -> None: + self._translations = translations + self.create = _legacy_response.to_raw_response_wrapper( translations.create, ) @@ -192,6 +194,8 @@ def __init__(self, translations: Translations) -> None: class AsyncTranslationsWithRawResponse: def __init__(self, translations: AsyncTranslations) -> None: + self._translations = translations + self.create = _legacy_response.async_to_raw_response_wrapper( translations.create, ) @@ -199,6 +203,8 @@ def __init__(self, translations: AsyncTranslations) -> None: class TranslationsWithStreamingResponse: def __init__(self, translations: Translations) -> None: + self._translations = translations + self.create = to_streamed_response_wrapper( translations.create, ) @@ -206,6 +212,8 @@ def __init__(self, translations: Translations) -> None: class AsyncTranslationsWithStreamingResponse: def __init__(self, translations: AsyncTranslations) -> None: + self._translations = translations + self.create = async_to_streamed_response_wrapper( translations.create, ) diff --git a/src/openai/resources/beta/assistants/assistants.py b/src/openai/resources/beta/assistants/assistants.py index a40acfb323..3a2418ad90 100644 --- a/src/openai/resources/beta/assistants/assistants.py +++ b/src/openai/resources/beta/assistants/assistants.py @@ -645,7 +645,7 @@ async def delete( class AssistantsWithRawResponse: def __init__(self, assistants: Assistants) -> None: - self.files = FilesWithRawResponse(assistants.files) + self._assistants = assistants self.create = _legacy_response.to_raw_response_wrapper( assistants.create, @@ -663,10 +663,14 @@ def __init__(self, assistants: Assistants) -> None: assistants.delete, ) + @cached_property + def files(self) -> FilesWithRawResponse: + return FilesWithRawResponse(self._assistants.files) + class AsyncAssistantsWithRawResponse: def __init__(self, assistants: AsyncAssistants) -> None: - self.files = AsyncFilesWithRawResponse(assistants.files) + self._assistants = assistants self.create = _legacy_response.async_to_raw_response_wrapper( assistants.create, @@ -684,10 +688,14 @@ def __init__(self, assistants: AsyncAssistants) -> None: assistants.delete, ) + @cached_property + def files(self) -> AsyncFilesWithRawResponse: + return AsyncFilesWithRawResponse(self._assistants.files) + class AssistantsWithStreamingResponse: def __init__(self, assistants: Assistants) -> None: - self.files = FilesWithStreamingResponse(assistants.files) + self._assistants = assistants self.create = to_streamed_response_wrapper( assistants.create, @@ -705,10 +713,14 @@ def __init__(self, assistants: Assistants) -> None: assistants.delete, ) + @cached_property + def files(self) -> FilesWithStreamingResponse: + return FilesWithStreamingResponse(self._assistants.files) + class AsyncAssistantsWithStreamingResponse: def __init__(self, assistants: AsyncAssistants) -> None: - self.files = AsyncFilesWithStreamingResponse(assistants.files) + self._assistants = assistants self.create = async_to_streamed_response_wrapper( assistants.create, @@ -725,3 +737,7 @@ def __init__(self, assistants: AsyncAssistants) -> None: self.delete = async_to_streamed_response_wrapper( assistants.delete, ) + + @cached_property + def files(self) -> AsyncFilesWithStreamingResponse: + return AsyncFilesWithStreamingResponse(self._assistants.files) diff --git a/src/openai/resources/beta/assistants/files.py b/src/openai/resources/beta/assistants/files.py index 12247044c4..c21465036a 100644 --- a/src/openai/resources/beta/assistants/files.py +++ b/src/openai/resources/beta/assistants/files.py @@ -410,6 +410,8 @@ async def delete( class FilesWithRawResponse: def __init__(self, files: Files) -> None: + self._files = files + self.create = _legacy_response.to_raw_response_wrapper( files.create, ) @@ -426,6 +428,8 @@ def __init__(self, files: Files) -> None: class AsyncFilesWithRawResponse: def __init__(self, files: AsyncFiles) -> None: + self._files = files + self.create = _legacy_response.async_to_raw_response_wrapper( files.create, ) @@ -442,6 +446,8 @@ def __init__(self, files: AsyncFiles) -> None: class FilesWithStreamingResponse: def __init__(self, files: Files) -> None: + self._files = files + self.create = to_streamed_response_wrapper( files.create, ) @@ -458,6 +464,8 @@ def __init__(self, files: Files) -> None: class AsyncFilesWithStreamingResponse: def __init__(self, files: AsyncFiles) -> None: + self._files = files + self.create = async_to_streamed_response_wrapper( files.create, ) diff --git a/src/openai/resources/beta/beta.py b/src/openai/resources/beta/beta.py index b11a706d5d..7081cff305 100644 --- a/src/openai/resources/beta/beta.py +++ b/src/openai/resources/beta/beta.py @@ -64,23 +64,51 @@ def with_streaming_response(self) -> AsyncBetaWithStreamingResponse: class BetaWithRawResponse: def __init__(self, beta: Beta) -> None: - self.assistants = AssistantsWithRawResponse(beta.assistants) - self.threads = ThreadsWithRawResponse(beta.threads) + self._beta = beta + + @cached_property + def assistants(self) -> AssistantsWithRawResponse: + return AssistantsWithRawResponse(self._beta.assistants) + + @cached_property + def threads(self) -> ThreadsWithRawResponse: + return ThreadsWithRawResponse(self._beta.threads) class AsyncBetaWithRawResponse: def __init__(self, beta: AsyncBeta) -> None: - self.assistants = AsyncAssistantsWithRawResponse(beta.assistants) - self.threads = AsyncThreadsWithRawResponse(beta.threads) + self._beta = beta + + @cached_property + def assistants(self) -> AsyncAssistantsWithRawResponse: + return AsyncAssistantsWithRawResponse(self._beta.assistants) + + @cached_property + def threads(self) -> AsyncThreadsWithRawResponse: + return AsyncThreadsWithRawResponse(self._beta.threads) class BetaWithStreamingResponse: def __init__(self, beta: Beta) -> None: - self.assistants = AssistantsWithStreamingResponse(beta.assistants) - self.threads = ThreadsWithStreamingResponse(beta.threads) + self._beta = beta + + @cached_property + def assistants(self) -> AssistantsWithStreamingResponse: + return AssistantsWithStreamingResponse(self._beta.assistants) + + @cached_property + def threads(self) -> ThreadsWithStreamingResponse: + return ThreadsWithStreamingResponse(self._beta.threads) class AsyncBetaWithStreamingResponse: def __init__(self, beta: AsyncBeta) -> None: - self.assistants = AsyncAssistantsWithStreamingResponse(beta.assistants) - self.threads = AsyncThreadsWithStreamingResponse(beta.threads) + self._beta = beta + + @cached_property + def assistants(self) -> AsyncAssistantsWithStreamingResponse: + return AsyncAssistantsWithStreamingResponse(self._beta.assistants) + + @cached_property + def threads(self) -> AsyncThreadsWithStreamingResponse: + return AsyncThreadsWithStreamingResponse(self._beta.threads) diff --git a/src/openai/resources/beta/threads/messages/files.py b/src/openai/resources/beta/threads/messages/files.py index 8b6c4581d0..fc8b894d72 100644 --- a/src/openai/resources/beta/threads/messages/files.py +++ b/src/openai/resources/beta/threads/messages/files.py @@ -266,6 +266,8 @@ def list( class FilesWithRawResponse: def __init__(self, files: Files) -> None: + self._files = files + self.retrieve = _legacy_response.to_raw_response_wrapper( files.retrieve, ) @@ -276,6 +278,8 @@ def __init__(self, files: Files) -> None: class AsyncFilesWithRawResponse: def __init__(self, files: AsyncFiles) -> None: + self._files = files + self.retrieve = _legacy_response.async_to_raw_response_wrapper( files.retrieve, ) @@ -286,6 +290,8 @@ def __init__(self, files: AsyncFiles) -> None: class FilesWithStreamingResponse: def __init__(self, files: Files) -> None: + self._files = files + self.retrieve = to_streamed_response_wrapper( files.retrieve, ) @@ -296,6 +302,8 @@ def __init__(self, files: Files) -> None: class AsyncFilesWithStreamingResponse: def __init__(self, files: AsyncFiles) -> None: + self._files = files + self.retrieve = async_to_streamed_response_wrapper( files.retrieve, ) diff --git a/src/openai/resources/beta/threads/messages/messages.py b/src/openai/resources/beta/threads/messages/messages.py index f5a17f902f..c95cdd5d00 100644 --- a/src/openai/resources/beta/threads/messages/messages.py +++ b/src/openai/resources/beta/threads/messages/messages.py @@ -481,7 +481,7 @@ def list( class MessagesWithRawResponse: def __init__(self, messages: Messages) -> None: - self.files = FilesWithRawResponse(messages.files) + self._messages = messages self.create = _legacy_response.to_raw_response_wrapper( messages.create, @@ -496,10 +496,14 @@ def __init__(self, messages: Messages) -> None: messages.list, ) + @cached_property + def files(self) -> FilesWithRawResponse: + return FilesWithRawResponse(self._messages.files) + class AsyncMessagesWithRawResponse: def __init__(self, messages: AsyncMessages) -> None: - self.files = AsyncFilesWithRawResponse(messages.files) + self._messages = messages self.create = _legacy_response.async_to_raw_response_wrapper( messages.create, @@ -514,10 +518,14 @@ def __init__(self, messages: AsyncMessages) -> None: messages.list, ) + @cached_property + def files(self) -> AsyncFilesWithRawResponse: + return AsyncFilesWithRawResponse(self._messages.files) + class MessagesWithStreamingResponse: def __init__(self, messages: Messages) -> None: - self.files = FilesWithStreamingResponse(messages.files) + self._messages = messages self.create = to_streamed_response_wrapper( messages.create, @@ -532,10 +540,14 @@ def __init__(self, messages: Messages) -> None: messages.list, ) + @cached_property + def files(self) -> FilesWithStreamingResponse: + return FilesWithStreamingResponse(self._messages.files) + class AsyncMessagesWithStreamingResponse: def __init__(self, messages: AsyncMessages) -> None: - self.files = AsyncFilesWithStreamingResponse(messages.files) + self._messages = messages self.create = async_to_streamed_response_wrapper( messages.create, @@ -549,3 +561,7 @@ def __init__(self, messages: AsyncMessages) -> None: self.list = async_to_streamed_response_wrapper( messages.list, ) + + @cached_property + def files(self) -> AsyncFilesWithStreamingResponse: + return AsyncFilesWithStreamingResponse(self._messages.files) diff --git a/src/openai/resources/beta/threads/runs/runs.py b/src/openai/resources/beta/threads/runs/runs.py index ac7a1b3330..0ed48b4792 100644 --- a/src/openai/resources/beta/threads/runs/runs.py +++ b/src/openai/resources/beta/threads/runs/runs.py @@ -681,7 +681,7 @@ async def submit_tool_outputs( class RunsWithRawResponse: def __init__(self, runs: Runs) -> None: - self.steps = StepsWithRawResponse(runs.steps) + self._runs = runs self.create = _legacy_response.to_raw_response_wrapper( runs.create, @@ -702,10 +702,14 @@ def __init__(self, runs: Runs) -> None: runs.submit_tool_outputs, ) + @cached_property + def steps(self) -> StepsWithRawResponse: + return StepsWithRawResponse(self._runs.steps) + class AsyncRunsWithRawResponse: def __init__(self, runs: AsyncRuns) -> None: - self.steps = AsyncStepsWithRawResponse(runs.steps) + self._runs = runs self.create = _legacy_response.async_to_raw_response_wrapper( runs.create, @@ -726,10 +730,14 @@ def __init__(self, runs: AsyncRuns) -> None: runs.submit_tool_outputs, ) + @cached_property + def steps(self) -> AsyncStepsWithRawResponse: + return AsyncStepsWithRawResponse(self._runs.steps) + class RunsWithStreamingResponse: def __init__(self, runs: Runs) -> None: - self.steps = StepsWithStreamingResponse(runs.steps) + self._runs = runs self.create = to_streamed_response_wrapper( runs.create, @@ -750,10 +758,14 @@ def __init__(self, runs: Runs) -> None: runs.submit_tool_outputs, ) + @cached_property + def steps(self) -> StepsWithStreamingResponse: + return StepsWithStreamingResponse(self._runs.steps) + class AsyncRunsWithStreamingResponse: def __init__(self, runs: AsyncRuns) -> None: - self.steps = AsyncStepsWithStreamingResponse(runs.steps) + self._runs = runs self.create = async_to_streamed_response_wrapper( runs.create, @@ -773,3 +785,7 @@ def __init__(self, runs: AsyncRuns) -> None: self.submit_tool_outputs = async_to_streamed_response_wrapper( runs.submit_tool_outputs, ) + + @cached_property + def steps(self) -> AsyncStepsWithStreamingResponse: + return AsyncStepsWithStreamingResponse(self._runs.steps) diff --git a/src/openai/resources/beta/threads/runs/steps.py b/src/openai/resources/beta/threads/runs/steps.py index 9b1df10652..539745a594 100644 --- a/src/openai/resources/beta/threads/runs/steps.py +++ b/src/openai/resources/beta/threads/runs/steps.py @@ -264,6 +264,8 @@ def list( class StepsWithRawResponse: def __init__(self, steps: Steps) -> None: + self._steps = steps + self.retrieve = _legacy_response.to_raw_response_wrapper( steps.retrieve, ) @@ -274,6 +276,8 @@ def __init__(self, steps: Steps) -> None: class AsyncStepsWithRawResponse: def __init__(self, steps: AsyncSteps) -> None: + self._steps = steps + self.retrieve = _legacy_response.async_to_raw_response_wrapper( steps.retrieve, ) @@ -284,6 +288,8 @@ def __init__(self, steps: AsyncSteps) -> None: class StepsWithStreamingResponse: def __init__(self, steps: Steps) -> None: + self._steps = steps + self.retrieve = to_streamed_response_wrapper( steps.retrieve, ) @@ -294,6 +300,8 @@ def __init__(self, steps: Steps) -> None: class AsyncStepsWithStreamingResponse: def __init__(self, steps: AsyncSteps) -> None: + self._steps = steps + self.retrieve = async_to_streamed_response_wrapper( steps.retrieve, ) diff --git a/src/openai/resources/beta/threads/threads.py b/src/openai/resources/beta/threads/threads.py index d885404f59..0372ae2f66 100644 --- a/src/openai/resources/beta/threads/threads.py +++ b/src/openai/resources/beta/threads/threads.py @@ -537,8 +537,7 @@ async def create_and_run( class ThreadsWithRawResponse: def __init__(self, threads: Threads) -> None: - self.runs = RunsWithRawResponse(threads.runs) - self.messages = MessagesWithRawResponse(threads.messages) + self._threads = threads self.create = _legacy_response.to_raw_response_wrapper( threads.create, @@ -556,11 +555,18 @@ def __init__(self, threads: Threads) -> None: threads.create_and_run, ) + @cached_property + def runs(self) -> RunsWithRawResponse: + return RunsWithRawResponse(self._threads.runs) + + @cached_property + def messages(self) -> MessagesWithRawResponse: + return MessagesWithRawResponse(self._threads.messages) + class AsyncThreadsWithRawResponse: def __init__(self, threads: AsyncThreads) -> None: - self.runs = AsyncRunsWithRawResponse(threads.runs) - self.messages = AsyncMessagesWithRawResponse(threads.messages) + self._threads = threads self.create = _legacy_response.async_to_raw_response_wrapper( threads.create, @@ -578,11 +584,18 @@ def __init__(self, threads: AsyncThreads) -> None: threads.create_and_run, ) + @cached_property + def runs(self) -> AsyncRunsWithRawResponse: + return AsyncRunsWithRawResponse(self._threads.runs) + + @cached_property + def messages(self) -> AsyncMessagesWithRawResponse: + return AsyncMessagesWithRawResponse(self._threads.messages) + class ThreadsWithStreamingResponse: def __init__(self, threads: Threads) -> None: - self.runs = RunsWithStreamingResponse(threads.runs) - self.messages = MessagesWithStreamingResponse(threads.messages) + self._threads = threads self.create = to_streamed_response_wrapper( threads.create, @@ -600,11 +613,18 @@ def __init__(self, threads: Threads) -> None: threads.create_and_run, ) + @cached_property + def runs(self) -> RunsWithStreamingResponse: + return RunsWithStreamingResponse(self._threads.runs) + + @cached_property + def messages(self) -> MessagesWithStreamingResponse: + return MessagesWithStreamingResponse(self._threads.messages) + class AsyncThreadsWithStreamingResponse: def __init__(self, threads: AsyncThreads) -> None: - self.runs = AsyncRunsWithStreamingResponse(threads.runs) - self.messages = AsyncMessagesWithStreamingResponse(threads.messages) + self._threads = threads self.create = async_to_streamed_response_wrapper( threads.create, @@ -621,3 +641,11 @@ def __init__(self, threads: AsyncThreads) -> None: self.create_and_run = async_to_streamed_response_wrapper( threads.create_and_run, ) + + @cached_property + def runs(self) -> AsyncRunsWithStreamingResponse: + return AsyncRunsWithStreamingResponse(self._threads.runs) + + @cached_property + def messages(self) -> AsyncMessagesWithStreamingResponse: + return AsyncMessagesWithStreamingResponse(self._threads.messages) diff --git a/src/openai/resources/chat/chat.py b/src/openai/resources/chat/chat.py index 467a5e401b..b6effa4e63 100644 --- a/src/openai/resources/chat/chat.py +++ b/src/openai/resources/chat/chat.py @@ -46,19 +46,35 @@ def with_streaming_response(self) -> AsyncChatWithStreamingResponse: class ChatWithRawResponse: def __init__(self, chat: Chat) -> None: - self.completions = CompletionsWithRawResponse(chat.completions) + self._chat = chat + + @cached_property + def completions(self) -> CompletionsWithRawResponse: + return CompletionsWithRawResponse(self._chat.completions) class AsyncChatWithRawResponse: def __init__(self, chat: AsyncChat) -> None: - self.completions = AsyncCompletionsWithRawResponse(chat.completions) + self._chat = chat + + @cached_property + def completions(self) -> AsyncCompletionsWithRawResponse: + return AsyncCompletionsWithRawResponse(self._chat.completions) class ChatWithStreamingResponse: def __init__(self, chat: Chat) -> None: - self.completions = CompletionsWithStreamingResponse(chat.completions) + self._chat = chat + + @cached_property + def completions(self) -> CompletionsWithStreamingResponse: + return CompletionsWithStreamingResponse(self._chat.completions) class AsyncChatWithStreamingResponse: def __init__(self, chat: AsyncChat) -> None: - self.completions = AsyncCompletionsWithStreamingResponse(chat.completions) + self._chat = chat + + @cached_property + def completions(self) -> AsyncCompletionsWithStreamingResponse: + return AsyncCompletionsWithStreamingResponse(self._chat.completions) diff --git a/src/openai/resources/chat/completions.py b/src/openai/resources/chat/completions.py index 53645a9eb9..f461161ab7 100644 --- a/src/openai/resources/chat/completions.py +++ b/src/openai/resources/chat/completions.py @@ -1335,6 +1335,8 @@ async def create( class CompletionsWithRawResponse: def __init__(self, completions: Completions) -> None: + self._completions = completions + self.create = _legacy_response.to_raw_response_wrapper( completions.create, ) @@ -1342,6 +1344,8 @@ def __init__(self, completions: Completions) -> None: class AsyncCompletionsWithRawResponse: def __init__(self, completions: AsyncCompletions) -> None: + self._completions = completions + self.create = _legacy_response.async_to_raw_response_wrapper( completions.create, ) @@ -1349,6 +1353,8 @@ def __init__(self, completions: AsyncCompletions) -> None: class CompletionsWithStreamingResponse: def __init__(self, completions: Completions) -> None: + self._completions = completions + self.create = to_streamed_response_wrapper( completions.create, ) @@ -1356,6 +1362,8 @@ def __init__(self, completions: Completions) -> None: class AsyncCompletionsWithStreamingResponse: def __init__(self, completions: AsyncCompletions) -> None: + self._completions = completions + self.create = async_to_streamed_response_wrapper( completions.create, ) diff --git a/src/openai/resources/completions.py b/src/openai/resources/completions.py index 43a9947524..3d2e10230a 100644 --- a/src/openai/resources/completions.py +++ b/src/openai/resources/completions.py @@ -1052,6 +1052,8 @@ async def create( class CompletionsWithRawResponse: def __init__(self, completions: Completions) -> None: + self._completions = completions + self.create = _legacy_response.to_raw_response_wrapper( completions.create, ) @@ -1059,6 +1061,8 @@ def __init__(self, completions: Completions) -> None: class AsyncCompletionsWithRawResponse: def __init__(self, completions: AsyncCompletions) -> None: + self._completions = completions + self.create = _legacy_response.async_to_raw_response_wrapper( completions.create, ) @@ -1066,6 +1070,8 @@ def __init__(self, completions: AsyncCompletions) -> None: class CompletionsWithStreamingResponse: def __init__(self, completions: Completions) -> None: + self._completions = completions + self.create = to_streamed_response_wrapper( completions.create, ) @@ -1073,6 +1079,8 @@ def __init__(self, completions: Completions) -> None: class AsyncCompletionsWithStreamingResponse: def __init__(self, completions: AsyncCompletions) -> None: + self._completions = completions + self.create = async_to_streamed_response_wrapper( completions.create, ) diff --git a/src/openai/resources/embeddings.py b/src/openai/resources/embeddings.py index 49ce0f2fc8..5bc7ed855e 100644 --- a/src/openai/resources/embeddings.py +++ b/src/openai/resources/embeddings.py @@ -217,6 +217,8 @@ def parser(obj: CreateEmbeddingResponse) -> CreateEmbeddingResponse: class EmbeddingsWithRawResponse: def __init__(self, embeddings: Embeddings) -> None: + self._embeddings = embeddings + self.create = _legacy_response.to_raw_response_wrapper( embeddings.create, ) @@ -224,6 +226,8 @@ def __init__(self, embeddings: Embeddings) -> None: class AsyncEmbeddingsWithRawResponse: def __init__(self, embeddings: AsyncEmbeddings) -> None: + self._embeddings = embeddings + self.create = _legacy_response.async_to_raw_response_wrapper( embeddings.create, ) @@ -231,6 +235,8 @@ def __init__(self, embeddings: AsyncEmbeddings) -> None: class EmbeddingsWithStreamingResponse: def __init__(self, embeddings: Embeddings) -> None: + self._embeddings = embeddings + self.create = to_streamed_response_wrapper( embeddings.create, ) @@ -238,6 +244,8 @@ def __init__(self, embeddings: Embeddings) -> None: class AsyncEmbeddingsWithStreamingResponse: def __init__(self, embeddings: AsyncEmbeddings) -> None: + self._embeddings = embeddings + self.create = async_to_streamed_response_wrapper( embeddings.create, ) diff --git a/src/openai/resources/files.py b/src/openai/resources/files.py index ff924340ac..58a2a217c7 100644 --- a/src/openai/resources/files.py +++ b/src/openai/resources/files.py @@ -580,6 +580,8 @@ async def wait_for_processing( class FilesWithRawResponse: def __init__(self, files: Files) -> None: + self._files = files + self.create = _legacy_response.to_raw_response_wrapper( files.create, ) @@ -604,6 +606,8 @@ def __init__(self, files: Files) -> None: class AsyncFilesWithRawResponse: def __init__(self, files: AsyncFiles) -> None: + self._files = files + self.create = _legacy_response.async_to_raw_response_wrapper( files.create, ) @@ -628,6 +632,8 @@ def __init__(self, files: AsyncFiles) -> None: class FilesWithStreamingResponse: def __init__(self, files: Files) -> None: + self._files = files + self.create = to_streamed_response_wrapper( files.create, ) @@ -653,6 +659,8 @@ def __init__(self, files: Files) -> None: class AsyncFilesWithStreamingResponse: def __init__(self, files: AsyncFiles) -> None: + self._files = files + self.create = async_to_streamed_response_wrapper( files.create, ) diff --git a/src/openai/resources/fine_tuning/fine_tuning.py b/src/openai/resources/fine_tuning/fine_tuning.py index 197d46fb83..33b25baec9 100644 --- a/src/openai/resources/fine_tuning/fine_tuning.py +++ b/src/openai/resources/fine_tuning/fine_tuning.py @@ -46,19 +46,35 @@ def with_streaming_response(self) -> AsyncFineTuningWithStreamingResponse: class FineTuningWithRawResponse: def __init__(self, fine_tuning: FineTuning) -> None: - self.jobs = JobsWithRawResponse(fine_tuning.jobs) + self._fine_tuning = fine_tuning + + @cached_property + def jobs(self) -> JobsWithRawResponse: + return JobsWithRawResponse(self._fine_tuning.jobs) class AsyncFineTuningWithRawResponse: def __init__(self, fine_tuning: AsyncFineTuning) -> None: - self.jobs = AsyncJobsWithRawResponse(fine_tuning.jobs) + self._fine_tuning = fine_tuning + + @cached_property + def jobs(self) -> AsyncJobsWithRawResponse: + return AsyncJobsWithRawResponse(self._fine_tuning.jobs) class FineTuningWithStreamingResponse: def __init__(self, fine_tuning: FineTuning) -> None: - self.jobs = JobsWithStreamingResponse(fine_tuning.jobs) + self._fine_tuning = fine_tuning + + @cached_property + def jobs(self) -> JobsWithStreamingResponse: + return JobsWithStreamingResponse(self._fine_tuning.jobs) class AsyncFineTuningWithStreamingResponse: def __init__(self, fine_tuning: AsyncFineTuning) -> None: - self.jobs = AsyncJobsWithStreamingResponse(fine_tuning.jobs) + self._fine_tuning = fine_tuning + + @cached_property + def jobs(self) -> AsyncJobsWithStreamingResponse: + return AsyncJobsWithStreamingResponse(self._fine_tuning.jobs) diff --git a/src/openai/resources/fine_tuning/jobs.py b/src/openai/resources/fine_tuning/jobs.py index 208591fa47..6b59932982 100644 --- a/src/openai/resources/fine_tuning/jobs.py +++ b/src/openai/resources/fine_tuning/jobs.py @@ -553,6 +553,8 @@ def list_events( class JobsWithRawResponse: def __init__(self, jobs: Jobs) -> None: + self._jobs = jobs + self.create = _legacy_response.to_raw_response_wrapper( jobs.create, ) @@ -572,6 +574,8 @@ def __init__(self, jobs: Jobs) -> None: class AsyncJobsWithRawResponse: def __init__(self, jobs: AsyncJobs) -> None: + self._jobs = jobs + self.create = _legacy_response.async_to_raw_response_wrapper( jobs.create, ) @@ -591,6 +595,8 @@ def __init__(self, jobs: AsyncJobs) -> None: class JobsWithStreamingResponse: def __init__(self, jobs: Jobs) -> None: + self._jobs = jobs + self.create = to_streamed_response_wrapper( jobs.create, ) @@ -610,6 +616,8 @@ def __init__(self, jobs: Jobs) -> None: class AsyncJobsWithStreamingResponse: def __init__(self, jobs: AsyncJobs) -> None: + self._jobs = jobs + self.create = async_to_streamed_response_wrapper( jobs.create, ) diff --git a/src/openai/resources/images.py b/src/openai/resources/images.py index a3eb98574e..91530e47ca 100644 --- a/src/openai/resources/images.py +++ b/src/openai/resources/images.py @@ -518,6 +518,8 @@ async def generate( class ImagesWithRawResponse: def __init__(self, images: Images) -> None: + self._images = images + self.create_variation = _legacy_response.to_raw_response_wrapper( images.create_variation, ) @@ -531,6 +533,8 @@ def __init__(self, images: Images) -> None: class AsyncImagesWithRawResponse: def __init__(self, images: AsyncImages) -> None: + self._images = images + self.create_variation = _legacy_response.async_to_raw_response_wrapper( images.create_variation, ) @@ -544,6 +548,8 @@ def __init__(self, images: AsyncImages) -> None: class ImagesWithStreamingResponse: def __init__(self, images: Images) -> None: + self._images = images + self.create_variation = to_streamed_response_wrapper( images.create_variation, ) @@ -557,6 +563,8 @@ def __init__(self, images: Images) -> None: class AsyncImagesWithStreamingResponse: def __init__(self, images: AsyncImages) -> None: + self._images = images + self.create_variation = async_to_streamed_response_wrapper( images.create_variation, ) diff --git a/src/openai/resources/models.py b/src/openai/resources/models.py index e4a0d84810..3536f083d2 100644 --- a/src/openai/resources/models.py +++ b/src/openai/resources/models.py @@ -225,6 +225,8 @@ async def delete( class ModelsWithRawResponse: def __init__(self, models: Models) -> None: + self._models = models + self.retrieve = _legacy_response.to_raw_response_wrapper( models.retrieve, ) @@ -238,6 +240,8 @@ def __init__(self, models: Models) -> None: class AsyncModelsWithRawResponse: def __init__(self, models: AsyncModels) -> None: + self._models = models + self.retrieve = _legacy_response.async_to_raw_response_wrapper( models.retrieve, ) @@ -251,6 +255,8 @@ def __init__(self, models: AsyncModels) -> None: class ModelsWithStreamingResponse: def __init__(self, models: Models) -> None: + self._models = models + self.retrieve = to_streamed_response_wrapper( models.retrieve, ) @@ -264,6 +270,8 @@ def __init__(self, models: Models) -> None: class AsyncModelsWithStreamingResponse: def __init__(self, models: AsyncModels) -> None: + self._models = models + self.retrieve = async_to_streamed_response_wrapper( models.retrieve, ) diff --git a/src/openai/resources/moderations.py b/src/openai/resources/moderations.py index e7681f6263..540d089071 100644 --- a/src/openai/resources/moderations.py +++ b/src/openai/resources/moderations.py @@ -143,6 +143,8 @@ async def create( class ModerationsWithRawResponse: def __init__(self, moderations: Moderations) -> None: + self._moderations = moderations + self.create = _legacy_response.to_raw_response_wrapper( moderations.create, ) @@ -150,6 +152,8 @@ def __init__(self, moderations: Moderations) -> None: class AsyncModerationsWithRawResponse: def __init__(self, moderations: AsyncModerations) -> None: + self._moderations = moderations + self.create = _legacy_response.async_to_raw_response_wrapper( moderations.create, ) @@ -157,6 +161,8 @@ def __init__(self, moderations: AsyncModerations) -> None: class ModerationsWithStreamingResponse: def __init__(self, moderations: Moderations) -> None: + self._moderations = moderations + self.create = to_streamed_response_wrapper( moderations.create, ) @@ -164,6 +170,8 @@ def __init__(self, moderations: Moderations) -> None: class AsyncModerationsWithStreamingResponse: def __init__(self, moderations: AsyncModerations) -> None: + self._moderations = moderations + self.create = async_to_streamed_response_wrapper( moderations.create, )