diff --git a/src/openai/resources/audio/transcriptions.py b/src/openai/resources/audio/transcriptions.py index 053ac30095..868ce7725f 100644 --- a/src/openai/resources/audio/transcriptions.py +++ b/src/openai/resources/audio/transcriptions.py @@ -98,7 +98,6 @@ def create( # sent to the server will contain a `boundary` parameter, e.g. # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} - return self._post( "/audio/transcriptions", body=maybe_transform(body, transcription_create_params.TranscriptionCreateParams), @@ -187,7 +186,6 @@ async def create( # sent to the server will contain a `boundary` parameter, e.g. # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} - return await self._post( "/audio/transcriptions", body=maybe_transform(body, transcription_create_params.TranscriptionCreateParams), diff --git a/src/openai/resources/audio/translations.py b/src/openai/resources/audio/translations.py index db41b194b6..333abfb4cf 100644 --- a/src/openai/resources/audio/translations.py +++ b/src/openai/resources/audio/translations.py @@ -91,7 +91,6 @@ def create( # sent to the server will contain a `boundary` parameter, e.g. # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} - return self._post( "/audio/translations", body=maybe_transform(body, translation_create_params.TranslationCreateParams), @@ -173,7 +172,6 @@ async def create( # sent to the server will contain a `boundary` parameter, e.g. # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} - return await self._post( "/audio/translations", body=maybe_transform(body, translation_create_params.TranslationCreateParams), diff --git a/src/openai/resources/beta/assistants/assistants.py b/src/openai/resources/beta/assistants/assistants.py index 176bf05516..a40acfb323 100644 --- a/src/openai/resources/beta/assistants/assistants.py +++ b/src/openai/resources/beta/assistants/assistants.py @@ -148,6 +148,8 @@ def retrieve( timeout: Override the client-level default timeout for this request, in seconds """ + if not assistant_id: + raise ValueError(f"Expected a non-empty value for `assistant_id` but received {assistant_id!r}") extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} return self._get( f"/assistants/{assistant_id}", @@ -215,6 +217,8 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if not assistant_id: + raise ValueError(f"Expected a non-empty value for `assistant_id` but received {assistant_id!r}") extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} return self._post( f"/assistants/{assistant_id}", @@ -324,6 +328,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if not assistant_id: + raise ValueError(f"Expected a non-empty value for `assistant_id` but received {assistant_id!r}") extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} return self._delete( f"/assistants/{assistant_id}", @@ -445,6 +451,8 @@ async def retrieve( timeout: Override the client-level default timeout for this request, in seconds """ + if not assistant_id: + raise ValueError(f"Expected a non-empty value for `assistant_id` but received {assistant_id!r}") extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} return await self._get( f"/assistants/{assistant_id}", @@ -512,6 +520,8 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if not assistant_id: + raise ValueError(f"Expected a non-empty value for `assistant_id` but received {assistant_id!r}") extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} return await self._post( f"/assistants/{assistant_id}", @@ -621,6 +631,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if not assistant_id: + raise ValueError(f"Expected a non-empty value for `assistant_id` but received {assistant_id!r}") extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} return await self._delete( f"/assistants/{assistant_id}", diff --git a/src/openai/resources/beta/assistants/files.py b/src/openai/resources/beta/assistants/files.py index 9e45ce46d3..12247044c4 100644 --- a/src/openai/resources/beta/assistants/files.py +++ b/src/openai/resources/beta/assistants/files.py @@ -61,6 +61,8 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if not assistant_id: + raise ValueError(f"Expected a non-empty value for `assistant_id` but received {assistant_id!r}") extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} return self._post( f"/assistants/{assistant_id}/files", @@ -95,6 +97,10 @@ def retrieve( timeout: Override the client-level default timeout for this request, in seconds """ + if not assistant_id: + raise ValueError(f"Expected a non-empty value for `assistant_id` but received {assistant_id!r}") + if not file_id: + raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}") extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} return self._get( f"/assistants/{assistant_id}/files/{file_id}", @@ -147,6 +153,8 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if not assistant_id: + raise ValueError(f"Expected a non-empty value for `assistant_id` but received {assistant_id!r}") extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} return self._get_api_list( f"/assistants/{assistant_id}/files", @@ -193,6 +201,10 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if not assistant_id: + raise ValueError(f"Expected a non-empty value for `assistant_id` but received {assistant_id!r}") + if not file_id: + raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}") extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} return self._delete( f"/assistants/{assistant_id}/files/{file_id}", @@ -242,6 +254,8 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if not assistant_id: + raise ValueError(f"Expected a non-empty value for `assistant_id` but received {assistant_id!r}") extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} return await self._post( f"/assistants/{assistant_id}/files", @@ -276,6 +290,10 @@ async def retrieve( timeout: Override the client-level default timeout for this request, in seconds """ + if not assistant_id: + raise ValueError(f"Expected a non-empty value for `assistant_id` but received {assistant_id!r}") + if not file_id: + raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}") extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} return await self._get( f"/assistants/{assistant_id}/files/{file_id}", @@ -328,6 +346,8 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if not assistant_id: + raise ValueError(f"Expected a non-empty value for `assistant_id` but received {assistant_id!r}") extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} return self._get_api_list( f"/assistants/{assistant_id}/files", @@ -374,6 +394,10 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if not assistant_id: + raise ValueError(f"Expected a non-empty value for `assistant_id` but received {assistant_id!r}") + if not file_id: + raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}") extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} return await self._delete( f"/assistants/{assistant_id}/files/{file_id}", diff --git a/src/openai/resources/beta/threads/messages/files.py b/src/openai/resources/beta/threads/messages/files.py index d0a963f1ae..8b6c4581d0 100644 --- a/src/openai/resources/beta/threads/messages/files.py +++ b/src/openai/resources/beta/threads/messages/files.py @@ -56,6 +56,12 @@ def retrieve( timeout: Override the client-level default timeout for this request, in seconds """ + if not thread_id: + raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}") + if not message_id: + raise ValueError(f"Expected a non-empty value for `message_id` but received {message_id!r}") + if not file_id: + raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}") extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} return self._get( f"/threads/{thread_id}/messages/{message_id}/files/{file_id}", @@ -110,6 +116,10 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if not thread_id: + raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}") + if not message_id: + raise ValueError(f"Expected a non-empty value for `message_id` but received {message_id!r}") extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} return self._get_api_list( f"/threads/{thread_id}/messages/{message_id}/files", @@ -167,6 +177,12 @@ async def retrieve( timeout: Override the client-level default timeout for this request, in seconds """ + if not thread_id: + raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}") + if not message_id: + raise ValueError(f"Expected a non-empty value for `message_id` but received {message_id!r}") + if not file_id: + raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}") extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} return await self._get( f"/threads/{thread_id}/messages/{message_id}/files/{file_id}", @@ -221,6 +237,10 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if not thread_id: + raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}") + if not message_id: + raise ValueError(f"Expected a non-empty value for `message_id` but received {message_id!r}") extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} return self._get_api_list( f"/threads/{thread_id}/messages/{message_id}/files", diff --git a/src/openai/resources/beta/threads/messages/messages.py b/src/openai/resources/beta/threads/messages/messages.py index 1a15dd36ca..f5a17f902f 100644 --- a/src/openai/resources/beta/threads/messages/messages.py +++ b/src/openai/resources/beta/threads/messages/messages.py @@ -86,6 +86,8 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if not thread_id: + raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}") extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} return self._post( f"/threads/{thread_id}/messages", @@ -128,6 +130,10 @@ def retrieve( timeout: Override the client-level default timeout for this request, in seconds """ + if not thread_id: + raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}") + if not message_id: + raise ValueError(f"Expected a non-empty value for `message_id` but received {message_id!r}") extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} return self._get( f"/threads/{thread_id}/messages/{message_id}", @@ -167,6 +173,10 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if not thread_id: + raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}") + if not message_id: + raise ValueError(f"Expected a non-empty value for `message_id` but received {message_id!r}") extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} return self._post( f"/threads/{thread_id}/messages/{message_id}", @@ -220,6 +230,8 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if not thread_id: + raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}") extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} return self._get_api_list( f"/threads/{thread_id}/messages", @@ -298,6 +310,8 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if not thread_id: + raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}") extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} return await self._post( f"/threads/{thread_id}/messages", @@ -340,6 +354,10 @@ async def retrieve( timeout: Override the client-level default timeout for this request, in seconds """ + if not thread_id: + raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}") + if not message_id: + raise ValueError(f"Expected a non-empty value for `message_id` but received {message_id!r}") extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} return await self._get( f"/threads/{thread_id}/messages/{message_id}", @@ -379,6 +397,10 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if not thread_id: + raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}") + if not message_id: + raise ValueError(f"Expected a non-empty value for `message_id` but received {message_id!r}") extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} return await self._post( f"/threads/{thread_id}/messages/{message_id}", @@ -432,6 +454,8 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if not thread_id: + raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}") extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} return self._get_api_list( f"/threads/{thread_id}/messages", diff --git a/src/openai/resources/beta/threads/runs/runs.py b/src/openai/resources/beta/threads/runs/runs.py index eb6c974eaa..ac7a1b3330 100644 --- a/src/openai/resources/beta/threads/runs/runs.py +++ b/src/openai/resources/beta/threads/runs/runs.py @@ -104,6 +104,8 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + if not thread_id: + raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}") extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} return self._post( f"/threads/{thread_id}/runs", @@ -148,6 +150,10 @@ def retrieve( timeout: Override the client-level default timeout for this request, in seconds """ + if not thread_id: + raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}") + if not run_id: + raise ValueError(f"Expected a non-empty value for `run_id` but received {run_id!r}") extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} return self._get( f"/threads/{thread_id}/runs/{run_id}", @@ -187,6 +193,10 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if not thread_id: + raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}") + if not run_id: + raise ValueError(f"Expected a non-empty value for `run_id` but received {run_id!r}") extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} return self._post( f"/threads/{thread_id}/runs/{run_id}", @@ -240,6 +250,8 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if not thread_id: + raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}") extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} return self._get_api_list( f"/threads/{thread_id}/runs", @@ -286,6 +298,10 @@ def cancel( timeout: Override the client-level default timeout for this request, in seconds """ + if not thread_id: + raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}") + if not run_id: + raise ValueError(f"Expected a non-empty value for `run_id` but received {run_id!r}") extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} return self._post( f"/threads/{thread_id}/runs/{run_id}/cancel", @@ -325,6 +341,10 @@ def submit_tool_outputs( timeout: Override the client-level default timeout for this request, in seconds """ + if not thread_id: + raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}") + if not run_id: + raise ValueError(f"Expected a non-empty value for `run_id` but received {run_id!r}") extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} return self._post( f"/threads/{thread_id}/runs/{run_id}/submit_tool_outputs", @@ -405,6 +425,8 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + if not thread_id: + raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}") extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} return await self._post( f"/threads/{thread_id}/runs", @@ -449,6 +471,10 @@ async def retrieve( timeout: Override the client-level default timeout for this request, in seconds """ + if not thread_id: + raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}") + if not run_id: + raise ValueError(f"Expected a non-empty value for `run_id` but received {run_id!r}") extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} return await self._get( f"/threads/{thread_id}/runs/{run_id}", @@ -488,6 +514,10 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if not thread_id: + raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}") + if not run_id: + raise ValueError(f"Expected a non-empty value for `run_id` but received {run_id!r}") extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} return await self._post( f"/threads/{thread_id}/runs/{run_id}", @@ -541,6 +571,8 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if not thread_id: + raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}") extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} return self._get_api_list( f"/threads/{thread_id}/runs", @@ -587,6 +619,10 @@ async def cancel( timeout: Override the client-level default timeout for this request, in seconds """ + if not thread_id: + raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}") + if not run_id: + raise ValueError(f"Expected a non-empty value for `run_id` but received {run_id!r}") extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} return await self._post( f"/threads/{thread_id}/runs/{run_id}/cancel", @@ -626,6 +662,10 @@ async def submit_tool_outputs( timeout: Override the client-level default timeout for this request, in seconds """ + if not thread_id: + raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}") + if not run_id: + raise ValueError(f"Expected a non-empty value for `run_id` but received {run_id!r}") extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} return await self._post( f"/threads/{thread_id}/runs/{run_id}/submit_tool_outputs", diff --git a/src/openai/resources/beta/threads/runs/steps.py b/src/openai/resources/beta/threads/runs/steps.py index 566ad9e4dc..9b1df10652 100644 --- a/src/openai/resources/beta/threads/runs/steps.py +++ b/src/openai/resources/beta/threads/runs/steps.py @@ -56,6 +56,12 @@ def retrieve( timeout: Override the client-level default timeout for this request, in seconds """ + if not thread_id: + raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}") + if not run_id: + raise ValueError(f"Expected a non-empty value for `run_id` but received {run_id!r}") + if not step_id: + raise ValueError(f"Expected a non-empty value for `step_id` but received {step_id!r}") extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} return self._get( f"/threads/{thread_id}/runs/{run_id}/steps/{step_id}", @@ -109,6 +115,10 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if not thread_id: + raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}") + if not run_id: + raise ValueError(f"Expected a non-empty value for `run_id` but received {run_id!r}") extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} return self._get_api_list( f"/threads/{thread_id}/runs/{run_id}/steps", @@ -166,6 +176,12 @@ async def retrieve( timeout: Override the client-level default timeout for this request, in seconds """ + if not thread_id: + raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}") + if not run_id: + raise ValueError(f"Expected a non-empty value for `run_id` but received {run_id!r}") + if not step_id: + raise ValueError(f"Expected a non-empty value for `step_id` but received {step_id!r}") extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} return await self._get( f"/threads/{thread_id}/runs/{run_id}/steps/{step_id}", @@ -219,6 +235,10 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if not thread_id: + raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}") + if not run_id: + raise ValueError(f"Expected a non-empty value for `run_id` but received {run_id!r}") extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} return self._get_api_list( f"/threads/{thread_id}/runs/{run_id}/steps", diff --git a/src/openai/resources/beta/threads/threads.py b/src/openai/resources/beta/threads/threads.py index 14bfbe9bba..d885404f59 100644 --- a/src/openai/resources/beta/threads/threads.py +++ b/src/openai/resources/beta/threads/threads.py @@ -133,6 +133,8 @@ def retrieve( timeout: Override the client-level default timeout for this request, in seconds """ + if not thread_id: + raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}") extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} return self._get( f"/threads/{thread_id}", @@ -171,6 +173,8 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if not thread_id: + raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}") extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} return self._post( f"/threads/{thread_id}", @@ -204,6 +208,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if not thread_id: + raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}") extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} return self._delete( f"/threads/{thread_id}", @@ -372,6 +378,8 @@ async def retrieve( timeout: Override the client-level default timeout for this request, in seconds """ + if not thread_id: + raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}") extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} return await self._get( f"/threads/{thread_id}", @@ -410,6 +418,8 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if not thread_id: + raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}") extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} return await self._post( f"/threads/{thread_id}", @@ -443,6 +453,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if not thread_id: + raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}") extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} return await self._delete( f"/threads/{thread_id}", diff --git a/src/openai/resources/files.py b/src/openai/resources/files.py index f435e70a2f..ff924340ac 100644 --- a/src/openai/resources/files.py +++ b/src/openai/resources/files.py @@ -99,7 +99,6 @@ def create( # sent to the server will contain a `boundary` parameter, e.g. # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} - return self._post( "/files", body=maybe_transform(body, file_create_params.FileCreateParams), @@ -133,6 +132,8 @@ def retrieve( timeout: Override the client-level default timeout for this request, in seconds """ + if not file_id: + raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}") return self._get( f"/files/{file_id}", options=make_request_options( @@ -202,6 +203,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if not file_id: + raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}") return self._delete( f"/files/{file_id}", options=make_request_options( @@ -233,6 +236,8 @@ def content( timeout: Override the client-level default timeout for this request, in seconds """ + if not file_id: + raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}") return self._get( f"/files/{file_id}/content", options=make_request_options( @@ -265,6 +270,8 @@ def retrieve_content( timeout: Override the client-level default timeout for this request, in seconds """ + if not file_id: + raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}") extra_headers = {"Accept": "application/json", **(extra_headers or {})} return self._get( f"/files/{file_id}/content", @@ -365,7 +372,6 @@ async def create( # sent to the server will contain a `boundary` parameter, e.g. # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} - return await self._post( "/files", body=maybe_transform(body, file_create_params.FileCreateParams), @@ -399,6 +405,8 @@ async def retrieve( timeout: Override the client-level default timeout for this request, in seconds """ + if not file_id: + raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}") return await self._get( f"/files/{file_id}", options=make_request_options( @@ -468,6 +476,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if not file_id: + raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}") return await self._delete( f"/files/{file_id}", options=make_request_options( @@ -499,6 +509,8 @@ async def content( timeout: Override the client-level default timeout for this request, in seconds """ + if not file_id: + raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}") return await self._get( f"/files/{file_id}/content", options=make_request_options( @@ -531,6 +543,8 @@ async def retrieve_content( timeout: Override the client-level default timeout for this request, in seconds """ + if not file_id: + raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}") extra_headers = {"Accept": "application/json", **(extra_headers or {})} return await self._get( f"/files/{file_id}/content", diff --git a/src/openai/resources/fine_tuning/jobs.py b/src/openai/resources/fine_tuning/jobs.py index f337b136a6..208591fa47 100644 --- a/src/openai/resources/fine_tuning/jobs.py +++ b/src/openai/resources/fine_tuning/jobs.py @@ -149,6 +149,8 @@ def retrieve( timeout: Override the client-level default timeout for this request, in seconds """ + if not fine_tuning_job_id: + raise ValueError(f"Expected a non-empty value for `fine_tuning_job_id` but received {fine_tuning_job_id!r}") return self._get( f"/fine_tuning/jobs/{fine_tuning_job_id}", options=make_request_options( @@ -227,6 +229,8 @@ def cancel( timeout: Override the client-level default timeout for this request, in seconds """ + if not fine_tuning_job_id: + raise ValueError(f"Expected a non-empty value for `fine_tuning_job_id` but received {fine_tuning_job_id!r}") return self._post( f"/fine_tuning/jobs/{fine_tuning_job_id}/cancel", options=make_request_options( @@ -264,6 +268,8 @@ def list_events( timeout: Override the client-level default timeout for this request, in seconds """ + if not fine_tuning_job_id: + raise ValueError(f"Expected a non-empty value for `fine_tuning_job_id` but received {fine_tuning_job_id!r}") return self._get_api_list( f"/fine_tuning/jobs/{fine_tuning_job_id}/events", page=SyncCursorPage[FineTuningJobEvent], @@ -404,6 +410,8 @@ async def retrieve( timeout: Override the client-level default timeout for this request, in seconds """ + if not fine_tuning_job_id: + raise ValueError(f"Expected a non-empty value for `fine_tuning_job_id` but received {fine_tuning_job_id!r}") return await self._get( f"/fine_tuning/jobs/{fine_tuning_job_id}", options=make_request_options( @@ -482,6 +490,8 @@ async def cancel( timeout: Override the client-level default timeout for this request, in seconds """ + if not fine_tuning_job_id: + raise ValueError(f"Expected a non-empty value for `fine_tuning_job_id` but received {fine_tuning_job_id!r}") return await self._post( f"/fine_tuning/jobs/{fine_tuning_job_id}/cancel", options=make_request_options( @@ -519,6 +529,8 @@ def list_events( timeout: Override the client-level default timeout for this request, in seconds """ + if not fine_tuning_job_id: + raise ValueError(f"Expected a non-empty value for `fine_tuning_job_id` but received {fine_tuning_job_id!r}") return self._get_api_list( f"/fine_tuning/jobs/{fine_tuning_job_id}/events", page=AsyncCursorPage[FineTuningJobEvent], diff --git a/src/openai/resources/images.py b/src/openai/resources/images.py index 6f1de221e2..a3eb98574e 100644 --- a/src/openai/resources/images.py +++ b/src/openai/resources/images.py @@ -98,7 +98,6 @@ def create_variation( # sent to the server will contain a `boundary` parameter, e.g. # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} - return self._post( "/images/variations", body=maybe_transform(body, image_create_variation_params.ImageCreateVariationParams), @@ -182,7 +181,6 @@ def edit( # sent to the server will contain a `boundary` parameter, e.g. # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} - return self._post( "/images/edits", body=maybe_transform(body, image_edit_params.ImageEditParams), @@ -345,7 +343,6 @@ async def create_variation( # sent to the server will contain a `boundary` parameter, e.g. # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} - return await self._post( "/images/variations", body=maybe_transform(body, image_create_variation_params.ImageCreateVariationParams), @@ -429,7 +426,6 @@ async def edit( # sent to the server will contain a `boundary` parameter, e.g. # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} - return await self._post( "/images/edits", body=maybe_transform(body, image_edit_params.ImageEditParams), diff --git a/src/openai/resources/models.py b/src/openai/resources/models.py index b431ef84fc..e4a0d84810 100644 --- a/src/openai/resources/models.py +++ b/src/openai/resources/models.py @@ -52,6 +52,8 @@ def retrieve( timeout: Override the client-level default timeout for this request, in seconds """ + if not model: + raise ValueError(f"Expected a non-empty value for `model` but received {model!r}") return self._get( f"/models/{model}", options=make_request_options( @@ -108,6 +110,8 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if not model: + raise ValueError(f"Expected a non-empty value for `model` but received {model!r}") return self._delete( f"/models/{model}", options=make_request_options( @@ -150,6 +154,8 @@ async def retrieve( timeout: Override the client-level default timeout for this request, in seconds """ + if not model: + raise ValueError(f"Expected a non-empty value for `model` but received {model!r}") return await self._get( f"/models/{model}", options=make_request_options( @@ -206,6 +212,8 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ + if not model: + raise ValueError(f"Expected a non-empty value for `model` but received {model!r}") return await self._delete( f"/models/{model}", options=make_request_options( diff --git a/tests/api_resources/beta/assistants/test_files.py b/tests/api_resources/beta/assistants/test_files.py index 443408bd44..7db1368ccb 100644 --- a/tests/api_resources/beta/assistants/test_files.py +++ b/tests/api_resources/beta/assistants/test_files.py @@ -56,6 +56,14 @@ def test_streaming_response_create(self, client: OpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + def test_path_params_create(self, client: OpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `assistant_id` but received ''"): + client.beta.assistants.files.with_raw_response.create( + "", + file_id="string", + ) + @parametrize def test_method_retrieve(self, client: OpenAI) -> None: file = client.beta.assistants.files.retrieve( @@ -90,6 +98,20 @@ def test_streaming_response_retrieve(self, client: OpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + def test_path_params_retrieve(self, client: OpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `assistant_id` but received ''"): + client.beta.assistants.files.with_raw_response.retrieve( + "string", + assistant_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `file_id` but received ''"): + client.beta.assistants.files.with_raw_response.retrieve( + "", + assistant_id="string", + ) + @parametrize def test_method_list(self, client: OpenAI) -> None: file = client.beta.assistants.files.list( @@ -132,6 +154,13 @@ def test_streaming_response_list(self, client: OpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + def test_path_params_list(self, client: OpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `assistant_id` but received ''"): + client.beta.assistants.files.with_raw_response.list( + "", + ) + @parametrize def test_method_delete(self, client: OpenAI) -> None: file = client.beta.assistants.files.delete( @@ -166,6 +195,20 @@ def test_streaming_response_delete(self, client: OpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + def test_path_params_delete(self, client: OpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `assistant_id` but received ''"): + client.beta.assistants.files.with_raw_response.delete( + "string", + assistant_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `file_id` but received ''"): + client.beta.assistants.files.with_raw_response.delete( + "", + assistant_id="string", + ) + class TestAsyncFiles: strict_client = AsyncOpenAI(base_url=base_url, api_key=api_key, _strict_response_validation=True) @@ -206,6 +249,14 @@ async def test_streaming_response_create(self, client: AsyncOpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + async def test_path_params_create(self, client: AsyncOpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `assistant_id` but received ''"): + await client.beta.assistants.files.with_raw_response.create( + "", + file_id="string", + ) + @parametrize async def test_method_retrieve(self, client: AsyncOpenAI) -> None: file = await client.beta.assistants.files.retrieve( @@ -240,6 +291,20 @@ async def test_streaming_response_retrieve(self, client: AsyncOpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + async def test_path_params_retrieve(self, client: AsyncOpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `assistant_id` but received ''"): + await client.beta.assistants.files.with_raw_response.retrieve( + "string", + assistant_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `file_id` but received ''"): + await client.beta.assistants.files.with_raw_response.retrieve( + "", + assistant_id="string", + ) + @parametrize async def test_method_list(self, client: AsyncOpenAI) -> None: file = await client.beta.assistants.files.list( @@ -282,6 +347,13 @@ async def test_streaming_response_list(self, client: AsyncOpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + async def test_path_params_list(self, client: AsyncOpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `assistant_id` but received ''"): + await client.beta.assistants.files.with_raw_response.list( + "", + ) + @parametrize async def test_method_delete(self, client: AsyncOpenAI) -> None: file = await client.beta.assistants.files.delete( @@ -315,3 +387,17 @@ async def test_streaming_response_delete(self, client: AsyncOpenAI) -> None: assert_matches_type(FileDeleteResponse, file, path=["response"]) assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_delete(self, client: AsyncOpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `assistant_id` but received ''"): + await client.beta.assistants.files.with_raw_response.delete( + "string", + assistant_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `file_id` but received ''"): + await client.beta.assistants.files.with_raw_response.delete( + "", + assistant_id="string", + ) diff --git a/tests/api_resources/beta/test_assistants.py b/tests/api_resources/beta/test_assistants.py index fbafac03c9..fa09769622 100644 --- a/tests/api_resources/beta/test_assistants.py +++ b/tests/api_resources/beta/test_assistants.py @@ -100,6 +100,13 @@ def test_streaming_response_retrieve(self, client: OpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + def test_path_params_retrieve(self, client: OpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `assistant_id` but received ''"): + client.beta.assistants.with_raw_response.retrieve( + "", + ) + @parametrize def test_method_update(self, client: OpenAI) -> None: assistant = client.beta.assistants.update( @@ -145,6 +152,13 @@ def test_streaming_response_update(self, client: OpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + def test_path_params_update(self, client: OpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `assistant_id` but received ''"): + client.beta.assistants.with_raw_response.update( + "", + ) + @parametrize def test_method_list(self, client: OpenAI) -> None: assistant = client.beta.assistants.list() @@ -211,6 +225,13 @@ def test_streaming_response_delete(self, client: OpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + def test_path_params_delete(self, client: OpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `assistant_id` but received ''"): + client.beta.assistants.with_raw_response.delete( + "", + ) + class TestAsyncAssistants: strict_client = AsyncOpenAI(base_url=base_url, api_key=api_key, _strict_response_validation=True) @@ -292,6 +313,13 @@ async def test_streaming_response_retrieve(self, client: AsyncOpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + async def test_path_params_retrieve(self, client: AsyncOpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `assistant_id` but received ''"): + await client.beta.assistants.with_raw_response.retrieve( + "", + ) + @parametrize async def test_method_update(self, client: AsyncOpenAI) -> None: assistant = await client.beta.assistants.update( @@ -337,6 +365,13 @@ async def test_streaming_response_update(self, client: AsyncOpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + async def test_path_params_update(self, client: AsyncOpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `assistant_id` but received ''"): + await client.beta.assistants.with_raw_response.update( + "", + ) + @parametrize async def test_method_list(self, client: AsyncOpenAI) -> None: assistant = await client.beta.assistants.list() @@ -402,3 +437,10 @@ async def test_streaming_response_delete(self, client: AsyncOpenAI) -> None: assert_matches_type(AssistantDeleted, assistant, path=["response"]) assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_delete(self, client: AsyncOpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `assistant_id` but received ''"): + await client.beta.assistants.with_raw_response.delete( + "", + ) diff --git a/tests/api_resources/beta/test_threads.py b/tests/api_resources/beta/test_threads.py index 488ce38c1b..ba55cc85da 100644 --- a/tests/api_resources/beta/test_threads.py +++ b/tests/api_resources/beta/test_threads.py @@ -108,6 +108,13 @@ def test_streaming_response_retrieve(self, client: OpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + def test_path_params_retrieve(self, client: OpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): + client.beta.threads.with_raw_response.retrieve( + "", + ) + @parametrize def test_method_update(self, client: OpenAI) -> None: thread = client.beta.threads.update( @@ -147,6 +154,13 @@ def test_streaming_response_update(self, client: OpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + def test_path_params_update(self, client: OpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): + client.beta.threads.with_raw_response.update( + "", + ) + @parametrize def test_method_delete(self, client: OpenAI) -> None: thread = client.beta.threads.delete( @@ -178,6 +192,13 @@ def test_streaming_response_delete(self, client: OpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + def test_path_params_delete(self, client: OpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): + client.beta.threads.with_raw_response.delete( + "", + ) + @parametrize def test_method_create_and_run(self, client: OpenAI) -> None: thread = client.beta.threads.create_and_run( @@ -332,6 +353,13 @@ async def test_streaming_response_retrieve(self, client: AsyncOpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + async def test_path_params_retrieve(self, client: AsyncOpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): + await client.beta.threads.with_raw_response.retrieve( + "", + ) + @parametrize async def test_method_update(self, client: AsyncOpenAI) -> None: thread = await client.beta.threads.update( @@ -371,6 +399,13 @@ async def test_streaming_response_update(self, client: AsyncOpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + async def test_path_params_update(self, client: AsyncOpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): + await client.beta.threads.with_raw_response.update( + "", + ) + @parametrize async def test_method_delete(self, client: AsyncOpenAI) -> None: thread = await client.beta.threads.delete( @@ -402,6 +437,13 @@ async def test_streaming_response_delete(self, client: AsyncOpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + async def test_path_params_delete(self, client: AsyncOpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): + await client.beta.threads.with_raw_response.delete( + "", + ) + @parametrize async def test_method_create_and_run(self, client: AsyncOpenAI) -> None: thread = await client.beta.threads.create_and_run( diff --git a/tests/api_resources/beta/threads/messages/test_files.py b/tests/api_resources/beta/threads/messages/test_files.py index 5de352c0d2..2d248642e9 100644 --- a/tests/api_resources/beta/threads/messages/test_files.py +++ b/tests/api_resources/beta/threads/messages/test_files.py @@ -59,6 +59,29 @@ def test_streaming_response_retrieve(self, client: OpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + def test_path_params_retrieve(self, client: OpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): + client.beta.threads.messages.files.with_raw_response.retrieve( + "file-abc123", + thread_id="", + message_id="msg_abc123", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `message_id` but received ''"): + client.beta.threads.messages.files.with_raw_response.retrieve( + "file-abc123", + thread_id="thread_abc123", + message_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `file_id` but received ''"): + client.beta.threads.messages.files.with_raw_response.retrieve( + "", + thread_id="thread_abc123", + message_id="msg_abc123", + ) + @parametrize def test_method_list(self, client: OpenAI) -> None: file = client.beta.threads.messages.files.list( @@ -105,6 +128,20 @@ def test_streaming_response_list(self, client: OpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + def test_path_params_list(self, client: OpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): + client.beta.threads.messages.files.with_raw_response.list( + "string", + thread_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `message_id` but received ''"): + client.beta.threads.messages.files.with_raw_response.list( + "", + thread_id="string", + ) + class TestAsyncFiles: strict_client = AsyncOpenAI(base_url=base_url, api_key=api_key, _strict_response_validation=True) @@ -148,6 +185,29 @@ async def test_streaming_response_retrieve(self, client: AsyncOpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + async def test_path_params_retrieve(self, client: AsyncOpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): + await client.beta.threads.messages.files.with_raw_response.retrieve( + "file-abc123", + thread_id="", + message_id="msg_abc123", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `message_id` but received ''"): + await client.beta.threads.messages.files.with_raw_response.retrieve( + "file-abc123", + thread_id="thread_abc123", + message_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `file_id` but received ''"): + await client.beta.threads.messages.files.with_raw_response.retrieve( + "", + thread_id="thread_abc123", + message_id="msg_abc123", + ) + @parametrize async def test_method_list(self, client: AsyncOpenAI) -> None: file = await client.beta.threads.messages.files.list( @@ -193,3 +253,17 @@ async def test_streaming_response_list(self, client: AsyncOpenAI) -> None: assert_matches_type(AsyncCursorPage[MessageFile], file, path=["response"]) assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_list(self, client: AsyncOpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): + await client.beta.threads.messages.files.with_raw_response.list( + "string", + thread_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `message_id` but received ''"): + await client.beta.threads.messages.files.with_raw_response.list( + "", + thread_id="string", + ) diff --git a/tests/api_resources/beta/threads/runs/test_steps.py b/tests/api_resources/beta/threads/runs/test_steps.py index f13970fc14..2ec164a535 100644 --- a/tests/api_resources/beta/threads/runs/test_steps.py +++ b/tests/api_resources/beta/threads/runs/test_steps.py @@ -59,6 +59,29 @@ def test_streaming_response_retrieve(self, client: OpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + def test_path_params_retrieve(self, client: OpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): + client.beta.threads.runs.steps.with_raw_response.retrieve( + "string", + thread_id="", + run_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): + client.beta.threads.runs.steps.with_raw_response.retrieve( + "string", + thread_id="string", + run_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `step_id` but received ''"): + client.beta.threads.runs.steps.with_raw_response.retrieve( + "", + thread_id="string", + run_id="string", + ) + @parametrize def test_method_list(self, client: OpenAI) -> None: step = client.beta.threads.runs.steps.list( @@ -105,6 +128,20 @@ def test_streaming_response_list(self, client: OpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + def test_path_params_list(self, client: OpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): + client.beta.threads.runs.steps.with_raw_response.list( + "string", + thread_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): + client.beta.threads.runs.steps.with_raw_response.list( + "", + thread_id="string", + ) + class TestAsyncSteps: strict_client = AsyncOpenAI(base_url=base_url, api_key=api_key, _strict_response_validation=True) @@ -148,6 +185,29 @@ async def test_streaming_response_retrieve(self, client: AsyncOpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + async def test_path_params_retrieve(self, client: AsyncOpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): + await client.beta.threads.runs.steps.with_raw_response.retrieve( + "string", + thread_id="", + run_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): + await client.beta.threads.runs.steps.with_raw_response.retrieve( + "string", + thread_id="string", + run_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `step_id` but received ''"): + await client.beta.threads.runs.steps.with_raw_response.retrieve( + "", + thread_id="string", + run_id="string", + ) + @parametrize async def test_method_list(self, client: AsyncOpenAI) -> None: step = await client.beta.threads.runs.steps.list( @@ -193,3 +253,17 @@ async def test_streaming_response_list(self, client: AsyncOpenAI) -> None: assert_matches_type(AsyncCursorPage[RunStep], step, path=["response"]) assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_list(self, client: AsyncOpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): + await client.beta.threads.runs.steps.with_raw_response.list( + "string", + thread_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): + await client.beta.threads.runs.steps.with_raw_response.list( + "", + thread_id="string", + ) diff --git a/tests/api_resources/beta/threads/test_messages.py b/tests/api_resources/beta/threads/test_messages.py index 87b6eca03a..508e9b96c9 100644 --- a/tests/api_resources/beta/threads/test_messages.py +++ b/tests/api_resources/beta/threads/test_messages.py @@ -70,6 +70,15 @@ def test_streaming_response_create(self, client: OpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + def test_path_params_create(self, client: OpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): + client.beta.threads.messages.with_raw_response.create( + "", + content="x", + role="user", + ) + @parametrize def test_method_retrieve(self, client: OpenAI) -> None: message = client.beta.threads.messages.retrieve( @@ -104,6 +113,20 @@ def test_streaming_response_retrieve(self, client: OpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + def test_path_params_retrieve(self, client: OpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): + client.beta.threads.messages.with_raw_response.retrieve( + "string", + thread_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `message_id` but received ''"): + client.beta.threads.messages.with_raw_response.retrieve( + "", + thread_id="string", + ) + @parametrize def test_method_update(self, client: OpenAI) -> None: message = client.beta.threads.messages.update( @@ -147,6 +170,20 @@ def test_streaming_response_update(self, client: OpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + def test_path_params_update(self, client: OpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): + client.beta.threads.messages.with_raw_response.update( + "string", + thread_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `message_id` but received ''"): + client.beta.threads.messages.with_raw_response.update( + "", + thread_id="string", + ) + @parametrize def test_method_list(self, client: OpenAI) -> None: message = client.beta.threads.messages.list( @@ -189,6 +226,13 @@ def test_streaming_response_list(self, client: OpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + def test_path_params_list(self, client: OpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): + client.beta.threads.messages.with_raw_response.list( + "", + ) + class TestAsyncMessages: strict_client = AsyncOpenAI(base_url=base_url, api_key=api_key, _strict_response_validation=True) @@ -243,6 +287,15 @@ async def test_streaming_response_create(self, client: AsyncOpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + async def test_path_params_create(self, client: AsyncOpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): + await client.beta.threads.messages.with_raw_response.create( + "", + content="x", + role="user", + ) + @parametrize async def test_method_retrieve(self, client: AsyncOpenAI) -> None: message = await client.beta.threads.messages.retrieve( @@ -277,6 +330,20 @@ async def test_streaming_response_retrieve(self, client: AsyncOpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + async def test_path_params_retrieve(self, client: AsyncOpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): + await client.beta.threads.messages.with_raw_response.retrieve( + "string", + thread_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `message_id` but received ''"): + await client.beta.threads.messages.with_raw_response.retrieve( + "", + thread_id="string", + ) + @parametrize async def test_method_update(self, client: AsyncOpenAI) -> None: message = await client.beta.threads.messages.update( @@ -320,6 +387,20 @@ async def test_streaming_response_update(self, client: AsyncOpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + async def test_path_params_update(self, client: AsyncOpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): + await client.beta.threads.messages.with_raw_response.update( + "string", + thread_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `message_id` but received ''"): + await client.beta.threads.messages.with_raw_response.update( + "", + thread_id="string", + ) + @parametrize async def test_method_list(self, client: AsyncOpenAI) -> None: message = await client.beta.threads.messages.list( @@ -361,3 +442,10 @@ async def test_streaming_response_list(self, client: AsyncOpenAI) -> None: assert_matches_type(AsyncCursorPage[ThreadMessage], message, path=["response"]) assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_list(self, client: AsyncOpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): + await client.beta.threads.messages.with_raw_response.list( + "", + ) diff --git a/tests/api_resources/beta/threads/test_runs.py b/tests/api_resources/beta/threads/test_runs.py index e0070c3395..66a9edd5c0 100644 --- a/tests/api_resources/beta/threads/test_runs.py +++ b/tests/api_resources/beta/threads/test_runs.py @@ -71,6 +71,14 @@ def test_streaming_response_create(self, client: OpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + def test_path_params_create(self, client: OpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): + client.beta.threads.runs.with_raw_response.create( + "", + assistant_id="string", + ) + @parametrize def test_method_retrieve(self, client: OpenAI) -> None: run = client.beta.threads.runs.retrieve( @@ -105,6 +113,20 @@ def test_streaming_response_retrieve(self, client: OpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + def test_path_params_retrieve(self, client: OpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): + client.beta.threads.runs.with_raw_response.retrieve( + "string", + thread_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): + client.beta.threads.runs.with_raw_response.retrieve( + "", + thread_id="string", + ) + @parametrize def test_method_update(self, client: OpenAI) -> None: run = client.beta.threads.runs.update( @@ -148,6 +170,20 @@ def test_streaming_response_update(self, client: OpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + def test_path_params_update(self, client: OpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): + client.beta.threads.runs.with_raw_response.update( + "string", + thread_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): + client.beta.threads.runs.with_raw_response.update( + "", + thread_id="string", + ) + @parametrize def test_method_list(self, client: OpenAI) -> None: run = client.beta.threads.runs.list( @@ -190,6 +226,13 @@ def test_streaming_response_list(self, client: OpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + def test_path_params_list(self, client: OpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): + client.beta.threads.runs.with_raw_response.list( + "", + ) + @parametrize def test_method_cancel(self, client: OpenAI) -> None: run = client.beta.threads.runs.cancel( @@ -224,6 +267,20 @@ def test_streaming_response_cancel(self, client: OpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + def test_path_params_cancel(self, client: OpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): + client.beta.threads.runs.with_raw_response.cancel( + "string", + thread_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): + client.beta.threads.runs.with_raw_response.cancel( + "", + thread_id="string", + ) + @parametrize def test_method_submit_tool_outputs(self, client: OpenAI) -> None: run = client.beta.threads.runs.submit_tool_outputs( @@ -261,6 +318,22 @@ def test_streaming_response_submit_tool_outputs(self, client: OpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + def test_path_params_submit_tool_outputs(self, client: OpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): + client.beta.threads.runs.with_raw_response.submit_tool_outputs( + "string", + thread_id="", + tool_outputs=[{}, {}, {}], + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): + client.beta.threads.runs.with_raw_response.submit_tool_outputs( + "", + thread_id="string", + tool_outputs=[{}, {}, {}], + ) + class TestAsyncRuns: strict_client = AsyncOpenAI(base_url=base_url, api_key=api_key, _strict_response_validation=True) @@ -314,6 +387,14 @@ async def test_streaming_response_create(self, client: AsyncOpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + async def test_path_params_create(self, client: AsyncOpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): + await client.beta.threads.runs.with_raw_response.create( + "", + assistant_id="string", + ) + @parametrize async def test_method_retrieve(self, client: AsyncOpenAI) -> None: run = await client.beta.threads.runs.retrieve( @@ -348,6 +429,20 @@ async def test_streaming_response_retrieve(self, client: AsyncOpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + async def test_path_params_retrieve(self, client: AsyncOpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): + await client.beta.threads.runs.with_raw_response.retrieve( + "string", + thread_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): + await client.beta.threads.runs.with_raw_response.retrieve( + "", + thread_id="string", + ) + @parametrize async def test_method_update(self, client: AsyncOpenAI) -> None: run = await client.beta.threads.runs.update( @@ -391,6 +486,20 @@ async def test_streaming_response_update(self, client: AsyncOpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + async def test_path_params_update(self, client: AsyncOpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): + await client.beta.threads.runs.with_raw_response.update( + "string", + thread_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): + await client.beta.threads.runs.with_raw_response.update( + "", + thread_id="string", + ) + @parametrize async def test_method_list(self, client: AsyncOpenAI) -> None: run = await client.beta.threads.runs.list( @@ -433,6 +542,13 @@ async def test_streaming_response_list(self, client: AsyncOpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + async def test_path_params_list(self, client: AsyncOpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): + await client.beta.threads.runs.with_raw_response.list( + "", + ) + @parametrize async def test_method_cancel(self, client: AsyncOpenAI) -> None: run = await client.beta.threads.runs.cancel( @@ -467,6 +583,20 @@ async def test_streaming_response_cancel(self, client: AsyncOpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + async def test_path_params_cancel(self, client: AsyncOpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): + await client.beta.threads.runs.with_raw_response.cancel( + "string", + thread_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): + await client.beta.threads.runs.with_raw_response.cancel( + "", + thread_id="string", + ) + @parametrize async def test_method_submit_tool_outputs(self, client: AsyncOpenAI) -> None: run = await client.beta.threads.runs.submit_tool_outputs( @@ -503,3 +633,19 @@ async def test_streaming_response_submit_tool_outputs(self, client: AsyncOpenAI) assert_matches_type(Run, run, path=["response"]) assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_submit_tool_outputs(self, client: AsyncOpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): + await client.beta.threads.runs.with_raw_response.submit_tool_outputs( + "string", + thread_id="", + tool_outputs=[{}, {}, {}], + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): + await client.beta.threads.runs.with_raw_response.submit_tool_outputs( + "", + thread_id="string", + tool_outputs=[{}, {}, {}], + ) diff --git a/tests/api_resources/fine_tuning/test_jobs.py b/tests/api_resources/fine_tuning/test_jobs.py index 3db0cdc0a5..50c7278855 100644 --- a/tests/api_resources/fine_tuning/test_jobs.py +++ b/tests/api_resources/fine_tuning/test_jobs.py @@ -105,6 +105,13 @@ def test_streaming_response_retrieve(self, client: OpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + def test_path_params_retrieve(self, client: OpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `fine_tuning_job_id` but received ''"): + client.fine_tuning.jobs.with_raw_response.retrieve( + "", + ) + @parametrize def test_method_list(self, client: OpenAI) -> None: job = client.fine_tuning.jobs.list() @@ -169,6 +176,13 @@ def test_streaming_response_cancel(self, client: OpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + def test_path_params_cancel(self, client: OpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `fine_tuning_job_id` but received ''"): + client.fine_tuning.jobs.with_raw_response.cancel( + "", + ) + @parametrize def test_method_list_events(self, client: OpenAI) -> None: job = client.fine_tuning.jobs.list_events( @@ -209,6 +223,13 @@ def test_streaming_response_list_events(self, client: OpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + def test_path_params_list_events(self, client: OpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `fine_tuning_job_id` but received ''"): + client.fine_tuning.jobs.with_raw_response.list_events( + "", + ) + class TestAsyncJobs: strict_client = AsyncOpenAI(base_url=base_url, api_key=api_key, _strict_response_validation=True) @@ -295,6 +316,13 @@ async def test_streaming_response_retrieve(self, client: AsyncOpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + async def test_path_params_retrieve(self, client: AsyncOpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `fine_tuning_job_id` but received ''"): + await client.fine_tuning.jobs.with_raw_response.retrieve( + "", + ) + @parametrize async def test_method_list(self, client: AsyncOpenAI) -> None: job = await client.fine_tuning.jobs.list() @@ -359,6 +387,13 @@ async def test_streaming_response_cancel(self, client: AsyncOpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + async def test_path_params_cancel(self, client: AsyncOpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `fine_tuning_job_id` but received ''"): + await client.fine_tuning.jobs.with_raw_response.cancel( + "", + ) + @parametrize async def test_method_list_events(self, client: AsyncOpenAI) -> None: job = await client.fine_tuning.jobs.list_events( @@ -398,3 +433,10 @@ async def test_streaming_response_list_events(self, client: AsyncOpenAI) -> None assert_matches_type(AsyncCursorPage[FineTuningJobEvent], job, path=["response"]) assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_list_events(self, client: AsyncOpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `fine_tuning_job_id` but received ''"): + await client.fine_tuning.jobs.with_raw_response.list_events( + "", + ) diff --git a/tests/api_resources/test_files.py b/tests/api_resources/test_files.py index e36a7839f2..89ad9e222f 100644 --- a/tests/api_resources/test_files.py +++ b/tests/api_resources/test_files.py @@ -92,6 +92,13 @@ def test_streaming_response_retrieve(self, client: OpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + def test_path_params_retrieve(self, client: OpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `file_id` but received ''"): + client.files.with_raw_response.retrieve( + "", + ) + @parametrize def test_method_list(self, client: OpenAI) -> None: file = client.files.list() @@ -155,6 +162,13 @@ def test_streaming_response_delete(self, client: OpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + def test_path_params_delete(self, client: OpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `file_id` but received ''"): + client.files.with_raw_response.delete( + "", + ) + @parametrize @pytest.mark.respx(base_url=base_url) def test_method_content(self, client: OpenAI, respx_mock: MockRouter) -> None: @@ -194,6 +208,14 @@ def test_streaming_response_content(self, client: OpenAI, respx_mock: MockRouter assert cast(Any, response.is_closed) is True + @parametrize + @pytest.mark.respx(base_url=base_url) + def test_path_params_content(self, client: OpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `file_id` but received ''"): + client.files.with_raw_response.content( + "", + ) + @parametrize def test_method_retrieve_content(self, client: OpenAI) -> None: with pytest.warns(DeprecationWarning): @@ -229,6 +251,14 @@ def test_streaming_response_retrieve_content(self, client: OpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + def test_path_params_retrieve_content(self, client: OpenAI) -> None: + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `file_id` but received ''"): + client.files.with_raw_response.retrieve_content( + "", + ) + class TestAsyncFiles: strict_client = AsyncOpenAI(base_url=base_url, api_key=api_key, _strict_response_validation=True) @@ -300,6 +330,13 @@ async def test_streaming_response_retrieve(self, client: AsyncOpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + async def test_path_params_retrieve(self, client: AsyncOpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `file_id` but received ''"): + await client.files.with_raw_response.retrieve( + "", + ) + @parametrize async def test_method_list(self, client: AsyncOpenAI) -> None: file = await client.files.list() @@ -363,6 +400,13 @@ async def test_streaming_response_delete(self, client: AsyncOpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + async def test_path_params_delete(self, client: AsyncOpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `file_id` but received ''"): + await client.files.with_raw_response.delete( + "", + ) + @parametrize @pytest.mark.respx(base_url=base_url) async def test_method_content(self, client: AsyncOpenAI, respx_mock: MockRouter) -> None: @@ -402,6 +446,14 @@ async def test_streaming_response_content(self, client: AsyncOpenAI, respx_mock: assert cast(Any, response.is_closed) is True + @parametrize + @pytest.mark.respx(base_url=base_url) + async def test_path_params_content(self, client: AsyncOpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `file_id` but received ''"): + await client.files.with_raw_response.content( + "", + ) + @parametrize async def test_method_retrieve_content(self, client: AsyncOpenAI) -> None: with pytest.warns(DeprecationWarning): @@ -436,3 +488,11 @@ async def test_streaming_response_retrieve_content(self, client: AsyncOpenAI) -> assert_matches_type(str, file, path=["response"]) assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_retrieve_content(self, client: AsyncOpenAI) -> None: + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `file_id` but received ''"): + await client.files.with_raw_response.retrieve_content( + "", + ) diff --git a/tests/api_resources/test_models.py b/tests/api_resources/test_models.py index 5afda86a7a..b41e50eb71 100644 --- a/tests/api_resources/test_models.py +++ b/tests/api_resources/test_models.py @@ -53,6 +53,13 @@ def test_streaming_response_retrieve(self, client: OpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + def test_path_params_retrieve(self, client: OpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `model` but received ''"): + client.models.with_raw_response.retrieve( + "", + ) + @parametrize def test_method_list(self, client: OpenAI) -> None: model = client.models.list() @@ -109,6 +116,13 @@ def test_streaming_response_delete(self, client: OpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + def test_path_params_delete(self, client: OpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `model` but received ''"): + client.models.with_raw_response.delete( + "", + ) + class TestAsyncModels: strict_client = AsyncOpenAI(base_url=base_url, api_key=api_key, _strict_response_validation=True) @@ -146,6 +160,13 @@ async def test_streaming_response_retrieve(self, client: AsyncOpenAI) -> None: assert cast(Any, response.is_closed) is True + @parametrize + async def test_path_params_retrieve(self, client: AsyncOpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `model` but received ''"): + await client.models.with_raw_response.retrieve( + "", + ) + @parametrize async def test_method_list(self, client: AsyncOpenAI) -> None: model = await client.models.list() @@ -201,3 +222,10 @@ async def test_streaming_response_delete(self, client: AsyncOpenAI) -> None: assert_matches_type(ModelDeleted, model, path=["response"]) assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_delete(self, client: AsyncOpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `model` but received ''"): + await client.models.with_raw_response.delete( + "", + )