diff --git a/portkey_ai/api_resources/apis/assistants.py b/portkey_ai/api_resources/apis/assistants.py index be39ed8..7953860 100644 --- a/portkey_ai/api_resources/apis/assistants.py +++ b/portkey_ai/api_resources/apis/assistants.py @@ -48,9 +48,14 @@ def create( return data def retrieve(self, assistant_id, **kwargs) -> Assistant: - response = self.openai_client.with_raw_response.beta.assistants.retrieve( - assistant_id=assistant_id, **kwargs - ) + if kwargs: + response = self.openai_client.with_raw_response.beta.assistants.retrieve( + assistant_id=assistant_id, extra_body=kwargs + ) + else: + response = self.openai_client.with_raw_response.beta.assistants.retrieve( + assistant_id=assistant_id + ) data = Assistant(**json.loads(response.text)) data._headers = response.headers @@ -156,9 +161,18 @@ async def create( return data async def retrieve(self, assistant_id, **kwargs) -> Assistant: - response = await self.openai_client.with_raw_response.beta.assistants.retrieve( - assistant_id=assistant_id, **kwargs - ) + if kwargs: + response = ( + await self.openai_client.with_raw_response.beta.assistants.retrieve( + assistant_id=assistant_id, extra_body=kwargs + ) + ) + else: + response = ( + await self.openai_client.with_raw_response.beta.assistants.retrieve( + assistant_id=assistant_id + ) + ) data = Assistant(**json.loads(response.text)) data._headers = response.headers diff --git a/portkey_ai/api_resources/apis/batches.py b/portkey_ai/api_resources/apis/batches.py index e2ef81a..7ceea62 100644 --- a/portkey_ai/api_resources/apis/batches.py +++ b/portkey_ai/api_resources/apis/batches.py @@ -36,9 +36,14 @@ def create( return data def retrieve(self, batch_id, **kwargs) -> Batch: - response = self.openai_client.with_raw_response.batches.retrieve( - batch_id=batch_id, extra_body=kwargs - ) + if kwargs: + response = self.openai_client.with_raw_response.batches.retrieve( + batch_id=batch_id, extra_body=kwargs + ) + else: + response = self.openai_client.with_raw_response.batches.retrieve( + batch_id=batch_id + ) data = Batch(**json.loads(response.text)) data._headers = response.headers @@ -97,9 +102,14 @@ async def create( return data async def retrieve(self, batch_id, **kwargs) -> Batch: - response = await self.openai_client.with_raw_response.batches.retrieve( - batch_id=batch_id, extra_body=kwargs - ) + if kwargs: + response = await self.openai_client.with_raw_response.batches.retrieve( + batch_id=batch_id, extra_body=kwargs + ) + else: + response = await self.openai_client.with_raw_response.batches.retrieve( + batch_id=batch_id + ) data = Batch(**json.loads(response.text)) data._headers = response.headers diff --git a/portkey_ai/api_resources/apis/fine_tuning.py b/portkey_ai/api_resources/apis/fine_tuning.py index 9f0572c..237ca92 100644 --- a/portkey_ai/api_resources/apis/fine_tuning.py +++ b/portkey_ai/api_resources/apis/fine_tuning.py @@ -56,9 +56,14 @@ def create( return data def retrieve(self, fine_tuning_job_id: str, **kwargs) -> FineTuningJob: - response = self.openai_client.with_raw_response.fine_tuning.jobs.retrieve( - fine_tuning_job_id=fine_tuning_job_id, extra_body=kwargs - ) + if kwargs: + response = self.openai_client.with_raw_response.fine_tuning.jobs.retrieve( + fine_tuning_job_id=fine_tuning_job_id, extra_body=kwargs + ) + else: + response = self.openai_client.with_raw_response.fine_tuning.jobs.retrieve( + fine_tuning_job_id=fine_tuning_job_id + ) data = FineTuningJob(**json.loads(response.text)) data._headers = response.headers @@ -179,9 +184,19 @@ async def create( return data async def retrieve(self, fine_tuning_job_id: str, **kwargs) -> FineTuningJob: - response = await self.openai_client.with_raw_response.fine_tuning.jobs.retrieve( - fine_tuning_job_id=fine_tuning_job_id, extra_body=kwargs - ) + if kwargs: + response = ( + await self.openai_client.with_raw_response.fine_tuning.jobs.retrieve( + fine_tuning_job_id=fine_tuning_job_id, extra_body=kwargs + ) + ) + else: + response = ( + await self.openai_client.with_raw_response.fine_tuning.jobs.retrieve( + fine_tuning_job_id=fine_tuning_job_id + ) + ) + data = FineTuningJob(**json.loads(response.text)) data._headers = response.headers diff --git a/portkey_ai/api_resources/apis/main_files.py b/portkey_ai/api_resources/apis/main_files.py index aceba3d..f5063ef 100644 --- a/portkey_ai/api_resources/apis/main_files.py +++ b/portkey_ai/api_resources/apis/main_files.py @@ -35,9 +35,14 @@ def list(self, purpose: Union[str, NotGiven] = NOT_GIVEN, **kwargs) -> FileList: return data def retrieve(self, file_id, **kwargs) -> FileObject: - response = self.openai_client.with_raw_response.files.retrieve( - file_id=file_id, extra_body=kwargs - ) + if kwargs: + response = self.openai_client.with_raw_response.files.retrieve( + file_id=file_id, extra_body=kwargs + ) + else: + response = self.openai_client.with_raw_response.files.retrieve( + file_id=file_id + ) data = FileObject(**json.loads(response.text)) data._headers = response.headers @@ -53,11 +58,21 @@ def delete(self, file_id, **kwargs) -> FileDeleted: return data def content(self, file_id, **kwargs) -> Any: - response = self.openai_client.files.content(file_id=file_id, extra_body=kwargs) + if kwargs: + response = self.openai_client.files.content( + file_id=file_id, extra_body=kwargs + ) + else: + response = self.openai_client.files.content(file_id=file_id) return response def retrieve_content(self, file_id, **kwargs) -> Any: - response = self.openai_client.files.content(file_id=file_id, extra_body=kwargs) + if kwargs: + response = self.openai_client.files.content( + file_id=file_id, extra_body=kwargs + ) + else: + response = self.openai_client.files.content(file_id=file_id) return response def wait_for_processing( @@ -102,9 +117,14 @@ async def list( return data async def retrieve(self, file_id, **kwargs) -> FileObject: - response = await self.openai_client.with_raw_response.files.retrieve( - file_id=file_id, extra_body=kwargs - ) + if kwargs: + response = await self.openai_client.with_raw_response.files.retrieve( + file_id=file_id, extra_body=kwargs + ) + else: + response = await self.openai_client.with_raw_response.files.retrieve( + file_id=file_id + ) data = FileObject(**json.loads(response.text)) data._headers = response.headers @@ -120,15 +140,21 @@ async def delete(self, file_id, **kwargs) -> FileDeleted: return data async def content(self, file_id, **kwargs) -> Any: - response = await self.openai_client.files.content( - file_id=file_id, extra_body=kwargs - ) + if kwargs: + response = await self.openai_client.files.content( + file_id=file_id, extra_body=kwargs + ) + else: + response = await self.openai_client.files.content(file_id=file_id) return response async def retrieve_content(self, file_id, **kwargs) -> Any: - response = await self.openai_client.files.content( - file_id=file_id, extra_body=kwargs - ) + if kwargs: + response = await self.openai_client.files.content( + file_id=file_id, extra_body=kwargs + ) + else: + response = await self.openai_client.files.content(file_id=file_id) return response async def wait_for_processing( diff --git a/portkey_ai/api_resources/apis/models.py b/portkey_ai/api_resources/apis/models.py index 18ddf67..8b4e932 100644 --- a/portkey_ai/api_resources/apis/models.py +++ b/portkey_ai/api_resources/apis/models.py @@ -20,9 +20,14 @@ def list(self, **kwargs) -> ModelList: def retrieve( self, model: str, *, timeout: Union[float, NotGiven] = NOT_GIVEN, **kwargs ) -> Model: - response = self.openai_client.with_raw_response.models.retrieve( - model=model, timeout=timeout, extra_body=kwargs - ) + if kwargs: + response = self.openai_client.with_raw_response.models.retrieve( + model=model, timeout=timeout, extra_body=kwargs + ) + else: + response = self.openai_client.with_raw_response.models.retrieve( + model=model, timeout=timeout + ) data = Model(**json.loads(response.text)) data._headers = response.headers return data @@ -52,9 +57,14 @@ async def list(self, **kwargs) -> ModelList: async def retrieve( self, model: str, *, timeout: Union[float, NotGiven] = NOT_GIVEN, **kwargs ) -> Model: - response = await self.openai_client.with_raw_response.models.retrieve( - model=model, timeout=timeout, extra_body=kwargs - ) + if kwargs: + response = await self.openai_client.with_raw_response.models.retrieve( + model=model, timeout=timeout, extra_body=kwargs + ) + else: + response = await self.openai_client.with_raw_response.models.retrieve( + model=model, timeout=timeout + ) data = Model(**json.loads(response.text)) data._headers = response.headers return data diff --git a/portkey_ai/api_resources/apis/threads.py b/portkey_ai/api_resources/apis/threads.py index b1b46dd..7c4c360 100644 --- a/portkey_ai/api_resources/apis/threads.py +++ b/portkey_ai/api_resources/apis/threads.py @@ -69,9 +69,14 @@ def create( return data def retrieve(self, thread_id, **kwargs) -> Thread: - response = self.openai_client.with_raw_response.beta.threads.retrieve( - thread_id=thread_id, **kwargs - ) + if kwargs: + response = self.openai_client.with_raw_response.beta.threads.retrieve( + thread_id=thread_id, extra_body=kwargs + ) + else: + response = self.openai_client.with_raw_response.beta.threads.retrieve( + thread_id=thread_id + ) data = Thread(**json.loads(response.text)) data._headers = response.headers @@ -303,9 +308,18 @@ def list( return data def retrieve(self, thread_id, message_id, **kwargs) -> ThreadMessage: - response = self.openai_client.with_raw_response.beta.threads.messages.retrieve( - thread_id=thread_id, message_id=message_id, **kwargs - ) + if kwargs: + response = ( + self.openai_client.with_raw_response.beta.threads.messages.retrieve( + thread_id=thread_id, message_id=message_id, extra_body=kwargs + ) + ) + else: + response = ( + self.openai_client.with_raw_response.beta.threads.messages.retrieve( + thread_id=thread_id, message_id=message_id + ) + ) data = ThreadMessage(**json.loads(response.text)) data._headers = response.headers return data @@ -391,9 +405,14 @@ def create( ) def retrieve(self, thread_id, run_id, **kwargs) -> Run: - response = self.openai_client.with_raw_response.beta.threads.runs.retrieve( - thread_id=thread_id, run_id=run_id, extra_body=kwargs - ) + if kwargs: + response = self.openai_client.with_raw_response.beta.threads.runs.retrieve( + thread_id=thread_id, run_id=run_id, extra_body=kwargs + ) + else: + response = self.openai_client.with_raw_response.beta.threads.runs.retrieve( + thread_id=thread_id, run_id=run_id + ) data = Run(**json.loads(response.text)) data._headers = response.headers @@ -678,11 +697,21 @@ def list(self, thread_id, run_id, **kwargs) -> RunStepList: return data def retrieve(self, thread_id, run_id, step_id, **kwargs) -> RunStep: - response = ( - self.openai_client.with_raw_response.beta.threads.runs.steps.retrieve( - thread_id=thread_id, run_id=run_id, step_id=step_id, extra_body=kwargs + if kwargs: + response = ( + self.openai_client.with_raw_response.beta.threads.runs.steps.retrieve( + thread_id=thread_id, + run_id=run_id, + step_id=step_id, + extra_body=kwargs, + ) + ) + else: + response = ( + self.openai_client.with_raw_response.beta.threads.runs.steps.retrieve( + thread_id=thread_id, run_id=run_id, step_id=step_id + ) ) - ) data = RunStep(**json.loads(response.text)) data._headers = response.headers @@ -716,9 +745,14 @@ async def create( return data async def retrieve(self, thread_id, **kwargs) -> Thread: - response = await self.openai_client.with_raw_response.beta.threads.retrieve( - thread_id=thread_id, **kwargs - ) + if kwargs: + response = await self.openai_client.with_raw_response.beta.threads.retrieve( + thread_id=thread_id, extra_body=kwargs + ) + else: + response = await self.openai_client.with_raw_response.beta.threads.retrieve( + thread_id=thread_id + ) data = Thread(**json.loads(response.text)) data._headers = response.headers @@ -958,11 +992,14 @@ async def list( return data async def retrieve(self, thread_id, message_id, **kwargs) -> ThreadMessage: - response = ( - await self.openai_client.with_raw_response.beta.threads.messages.retrieve( - thread_id=thread_id, message_id=message_id, **kwargs + if kwargs: + response = await self.openai_client.with_raw_response.beta.threads.messages.retrieve( # noqa: E501 + thread_id=thread_id, message_id=message_id, extra_body=kwargs + ) + else: + response = await self.openai_client.with_raw_response.beta.threads.messages.retrieve( # noqa: E501 + thread_id=thread_id, message_id=message_id ) - ) data = ThreadMessage(**json.loads(response.text)) data._headers = response.headers return data @@ -1050,11 +1087,18 @@ async def create( return await self.normal_create(thread_id, assistant_id, **kwargs) async def retrieve(self, thread_id, run_id, **kwargs) -> Run: - response = ( - await self.openai_client.with_raw_response.beta.threads.runs.retrieve( - thread_id=thread_id, run_id=run_id, extra_body=kwargs + if kwargs: + response = ( + await self.openai_client.with_raw_response.beta.threads.runs.retrieve( + thread_id=thread_id, run_id=run_id, extra_body=kwargs + ) + ) + else: + response = ( + await self.openai_client.with_raw_response.beta.threads.runs.retrieve( + thread_id=thread_id, run_id=run_id + ) ) - ) data = Run(**json.loads(response.text)) data._headers = response.headers @@ -1357,11 +1401,14 @@ async def list(self, thread_id, run_id, **kwargs) -> RunStepList: return data async def retrieve(self, thread_id, run_id, step_id, **kwargs) -> RunStep: - response = ( - await self.openai_client.with_raw_response.beta.threads.runs.steps.retrieve( + if kwargs: + response = await self.openai_client.with_raw_response.beta.threads.runs.steps.retrieve( # noqa: E501 thread_id=thread_id, run_id=run_id, step_id=step_id, extra_body=kwargs ) - ) + else: + response = await self.openai_client.with_raw_response.beta.threads.runs.steps.retrieve( # noqa: E501 + thread_id=thread_id, run_id=run_id, step_id=step_id + ) data = RunStep(**json.loads(response.text)) data._headers = response.headers diff --git a/portkey_ai/api_resources/apis/vector_stores.py b/portkey_ai/api_resources/apis/vector_stores.py index 290b8c2..9258822 100644 --- a/portkey_ai/api_resources/apis/vector_stores.py +++ b/portkey_ai/api_resources/apis/vector_stores.py @@ -55,10 +55,15 @@ def retrieve( vector_store_id: str, **kwargs, ) -> VectorStore: - response = self.openai_client.with_raw_response.beta.vector_stores.retrieve( - vector_store_id=vector_store_id, - **kwargs, - ) + if kwargs: + response = self.openai_client.with_raw_response.beta.vector_stores.retrieve( + vector_store_id=vector_store_id, + extra_body=kwargs, + ) + else: + response = self.openai_client.with_raw_response.beta.vector_stores.retrieve( + vector_store_id=vector_store_id, + ) data = VectorStore(**json.loads(response.text)) data._headers = response.headers @@ -153,13 +158,21 @@ def retrieve( vector_store_id: str, **kwargs, ) -> VectorStoreFile: - response = ( - self.openai_client.with_raw_response.beta.vector_stores.files.retrieve( - file_id=file_id, - vector_store_id=vector_store_id, - **kwargs, + if kwargs: + response = ( + self.openai_client.with_raw_response.beta.vector_stores.files.retrieve( + file_id=file_id, + vector_store_id=vector_store_id, + extra_body=kwargs, + ) + ) + else: + response = ( + self.openai_client.with_raw_response.beta.vector_stores.files.retrieve( + file_id=file_id, + vector_store_id=vector_store_id, + ) ) - ) data = VectorStoreFile(**json.loads(response.text)) data._headers = response.headers @@ -312,11 +325,17 @@ def create( def retrieve( self, batch_id: str, *, vector_store_id: str, **kwargs ) -> VectorStoreFileBatch: - response = self.openai_client.with_raw_response.beta.vector_stores.file_batches.retrieve( # noqa: E501 - batch_id=batch_id, - vector_store_id=vector_store_id, - **kwargs, - ) + if kwargs: + response = self.openai_client.with_raw_response.beta.vector_stores.file_batches.retrieve( # noqa: E501 + batch_id=batch_id, + vector_store_id=vector_store_id, + extra_body=kwargs, + ) + else: + response = self.openai_client.with_raw_response.beta.vector_stores.file_batches.retrieve( # noqa: E501 + batch_id=batch_id, + vector_store_id=vector_store_id, + ) data = VectorStoreFileBatch(**json.loads(response.text)) data._headers = response.headers @@ -462,12 +481,19 @@ async def retrieve( vector_store_id: str, **kwargs, ) -> VectorStore: - response = ( - await self.openai_client.with_raw_response.beta.vector_stores.retrieve( - vector_store_id=vector_store_id, - **kwargs, + if kwargs: + response = ( + await self.openai_client.with_raw_response.beta.vector_stores.retrieve( + vector_store_id=vector_store_id, + extra_body=kwargs, + ) + ) + else: + response = ( + await self.openai_client.with_raw_response.beta.vector_stores.retrieve( + vector_store_id=vector_store_id, + ) ) - ) data = VectorStore(**json.loads(response.text)) data._headers = response.headers @@ -564,11 +590,17 @@ async def retrieve( vector_store_id: str, **kwargs, ) -> VectorStoreFile: - response = await self.openai_client.with_raw_response.beta.vector_stores.files.retrieve( # noqa: E501 - file_id=file_id, - vector_store_id=vector_store_id, - **kwargs, - ) + if kwargs: + response = await self.openai_client.with_raw_response.beta.vector_stores.files.retrieve( # noqa: E501 + file_id=file_id, + vector_store_id=vector_store_id, + extra_body=kwargs, + ) + else: + response = await self.openai_client.with_raw_response.beta.vector_stores.files.retrieve( # noqa: E501 + file_id=file_id, + vector_store_id=vector_store_id, + ) data = VectorStoreFile(**json.loads(response.text)) data._headers = response.headers @@ -723,11 +755,17 @@ async def create( async def retrieve( self, batch_id: str, *, vector_store_id: str, **kwargs ) -> VectorStoreFileBatch: - response = await self.openai_client.with_raw_response.beta.vector_stores.file_batches.retrieve( # noqa: E501 - batch_id=batch_id, - vector_store_id=vector_store_id, - **kwargs, - ) + if kwargs: + response = await self.openai_client.with_raw_response.beta.vector_stores.file_batches.retrieve( # noqa: E501 + batch_id=batch_id, + vector_store_id=vector_store_id, + extra_body=kwargs, + ) + else: + response = await self.openai_client.with_raw_response.beta.vector_stores.file_batches.retrieve( # noqa: E501 + batch_id=batch_id, + vector_store_id=vector_store_id, + ) data = VectorStoreFileBatch(**json.loads(response.text)) data._headers = response.headers