Skip to content

Commit

Permalink
fix(client): ensure path params are non-empty (#1075)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot authored Jan 16, 2024
1 parent 0e93c3b commit 9a25149
Show file tree
Hide file tree
Showing 23 changed files with 870 additions and 10 deletions.
2 changes: 0 additions & 2 deletions src/openai/resources/audio/transcriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down
2 changes: 0 additions & 2 deletions src/openai/resources/audio/translations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down
12 changes: 12 additions & 0 deletions src/openai/resources/beta/assistants/assistants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}",
Expand Down Expand Up @@ -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}",
Expand Down Expand Up @@ -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}",
Expand Down Expand Up @@ -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}",
Expand Down Expand Up @@ -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}",
Expand Down Expand Up @@ -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}",
Expand Down
24 changes: 24 additions & 0 deletions src/openai/resources/beta/assistants/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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}",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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}",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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}",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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}",
Expand Down
20 changes: 20 additions & 0 deletions src/openai/resources/beta/threads/messages/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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}",
Expand Down Expand Up @@ -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",
Expand Down
24 changes: 24 additions & 0 deletions src/openai/resources/beta/threads/messages/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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}",
Expand Down Expand Up @@ -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}",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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}",
Expand Down Expand Up @@ -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}",
Expand Down Expand Up @@ -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",
Expand Down
Loading

0 comments on commit 9a25149

Please sign in to comment.