From 4041e4f6ea1e2316179a82031001308be23a2524 Mon Sep 17 00:00:00 2001 From: Robert Craigie Date: Thu, 20 Jun 2024 18:47:34 +0100 Subject: [PATCH 1/2] fix(api): add missing parallel_tool_calls arguments --- src/openai/resources/beta/threads/threads.py | 12 ++++ tests/lib/test_assistants.py | 59 ++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 tests/lib/test_assistants.py diff --git a/src/openai/resources/beta/threads/threads.py b/src/openai/resources/beta/threads/threads.py index c0a908b7a2..a62ee8d1bb 100644 --- a/src/openai/resources/beta/threads/threads.py +++ b/src/openai/resources/beta/threads/threads.py @@ -828,6 +828,7 @@ def create_and_run_poll( None, ] | NotGiven = NOT_GIVEN, + parallel_tool_calls: bool | NotGiven = NOT_GIVEN, response_format: Optional[AssistantResponseFormatOptionParam] | NotGiven = NOT_GIVEN, temperature: Optional[float] | NotGiven = NOT_GIVEN, thread: thread_create_and_run_params.Thread | NotGiven = NOT_GIVEN, @@ -856,6 +857,7 @@ def create_and_run_poll( max_prompt_tokens=max_prompt_tokens, metadata=metadata, model=model, + parallel_tool_calls=parallel_tool_calls, response_format=response_format, temperature=temperature, stream=False, @@ -908,6 +910,7 @@ def create_and_run_stream( None, ] | NotGiven = NOT_GIVEN, + parallel_tool_calls: bool | NotGiven = NOT_GIVEN, response_format: Optional[AssistantResponseFormatOptionParam] | NotGiven = NOT_GIVEN, temperature: Optional[float] | NotGiven = NOT_GIVEN, thread: thread_create_and_run_params.Thread | NotGiven = NOT_GIVEN, @@ -962,6 +965,7 @@ def create_and_run_stream( None, ] | NotGiven = NOT_GIVEN, + parallel_tool_calls: bool | NotGiven = NOT_GIVEN, response_format: Optional[AssistantResponseFormatOptionParam] | NotGiven = NOT_GIVEN, temperature: Optional[float] | NotGiven = NOT_GIVEN, thread: thread_create_and_run_params.Thread | NotGiven = NOT_GIVEN, @@ -1016,6 +1020,7 @@ def create_and_run_stream( None, ] | NotGiven = NOT_GIVEN, + parallel_tool_calls: bool | NotGiven = NOT_GIVEN, response_format: Optional[AssistantResponseFormatOptionParam] | NotGiven = NOT_GIVEN, temperature: Optional[float] | NotGiven = NOT_GIVEN, thread: thread_create_and_run_params.Thread | NotGiven = NOT_GIVEN, @@ -1050,6 +1055,7 @@ def create_and_run_stream( "max_prompt_tokens": max_prompt_tokens, "metadata": metadata, "model": model, + "parallel_tool_calls": parallel_tool_calls, "response_format": response_format, "temperature": temperature, "tool_choice": tool_choice, @@ -1838,6 +1844,7 @@ async def create_and_run_poll( None, ] | NotGiven = NOT_GIVEN, + parallel_tool_calls: bool | NotGiven = NOT_GIVEN, response_format: Optional[AssistantResponseFormatOptionParam] | NotGiven = NOT_GIVEN, temperature: Optional[float] | NotGiven = NOT_GIVEN, thread: thread_create_and_run_params.Thread | NotGiven = NOT_GIVEN, @@ -1866,6 +1873,7 @@ async def create_and_run_poll( max_prompt_tokens=max_prompt_tokens, metadata=metadata, model=model, + parallel_tool_calls=parallel_tool_calls, response_format=response_format, temperature=temperature, stream=False, @@ -1920,6 +1928,7 @@ def create_and_run_stream( None, ] | NotGiven = NOT_GIVEN, + parallel_tool_calls: bool | NotGiven = NOT_GIVEN, response_format: Optional[AssistantResponseFormatOptionParam] | NotGiven = NOT_GIVEN, temperature: Optional[float] | NotGiven = NOT_GIVEN, thread: thread_create_and_run_params.Thread | NotGiven = NOT_GIVEN, @@ -1974,6 +1983,7 @@ def create_and_run_stream( None, ] | NotGiven = NOT_GIVEN, + parallel_tool_calls: bool | NotGiven = NOT_GIVEN, response_format: Optional[AssistantResponseFormatOptionParam] | NotGiven = NOT_GIVEN, temperature: Optional[float] | NotGiven = NOT_GIVEN, thread: thread_create_and_run_params.Thread | NotGiven = NOT_GIVEN, @@ -2028,6 +2038,7 @@ def create_and_run_stream( None, ] | NotGiven = NOT_GIVEN, + parallel_tool_calls: bool | NotGiven = NOT_GIVEN, response_format: Optional[AssistantResponseFormatOptionParam] | NotGiven = NOT_GIVEN, temperature: Optional[float] | NotGiven = NOT_GIVEN, thread: thread_create_and_run_params.Thread | NotGiven = NOT_GIVEN, @@ -2064,6 +2075,7 @@ def create_and_run_stream( "max_prompt_tokens": max_prompt_tokens, "metadata": metadata, "model": model, + "parallel_tool_calls": parallel_tool_calls, "response_format": response_format, "temperature": temperature, "tool_choice": tool_choice, diff --git a/tests/lib/test_assistants.py b/tests/lib/test_assistants.py new file mode 100644 index 0000000000..ac92f17ca3 --- /dev/null +++ b/tests/lib/test_assistants.py @@ -0,0 +1,59 @@ +from __future__ import annotations + +import inspect +from typing import Any, Callable + +import pytest + +from openai import OpenAI, AsyncOpenAI + + +def assert_signatures_in_sync( + source_func: Callable[..., Any], + check_func: Callable[..., Any], + *, + exclude_params: set[str] = set(), +) -> None: + check_sig = inspect.signature(check_func) + source_sig = inspect.signature(source_func) + + errors: list[str] = [] + + for name, generated_param in source_sig.parameters.items(): + if name in exclude_params: + continue + + custom_param = check_sig.parameters.get(name) + if not custom_param: + errors.append(f"the `{name}` param is missing") + continue + + if custom_param.annotation != generated_param.annotation: + errors.append( + f"types for the `{name}` param are do not match; generated={repr(generated_param.annotation)} custom={repr(generated_param.annotation)}" + ) + continue + + if errors: + raise AssertionError(f"{len(errors)} errors encountered when comparing signatures:\n\n" + "\n\n".join(errors)) + + +@pytest.mark.parametrize("sync", [True, False], ids=["sync", "async"]) +def test_create_and_run_poll_method_definition_in_sync(sync: bool, client: OpenAI, async_client: AsyncOpenAI) -> None: + checking_client = client if sync else async_client + + assert_signatures_in_sync( + checking_client.beta.threads.create_and_run, + checking_client.beta.threads.create_and_run_poll, + exclude_params={"stream"}, + ) + +@pytest.mark.parametrize("sync", [True, False], ids=["sync", "async"]) +def test_create_and_run_stream_method_definition_in_sync(sync: bool, client: OpenAI, async_client: AsyncOpenAI) -> None: + checking_client = client if sync else async_client + + assert_signatures_in_sync( + checking_client.beta.threads.create_and_run, + checking_client.beta.threads.create_and_run_stream, + exclude_params={"stream"}, + ) From d6160c5c72fca30003accc63d3b3809d9ad93976 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 20 Jun 2024 17:48:10 +0000 Subject: [PATCH 2/2] release: 1.35.2 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 8 ++++++++ pyproject.toml | 2 +- src/openai/_version.py | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 21b274b18a..5554412dd2 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "1.35.1" + ".": "1.35.2" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index f442ddd2ce..5eede818c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 1.35.2 (2024-06-20) + +Full Changelog: [v1.35.1...v1.35.2](https://github.com/openai/openai-python/compare/v1.35.1...v1.35.2) + +### Bug Fixes + +* **api:** add missing parallel_tool_calls arguments ([4041e4f](https://github.com/openai/openai-python/commit/4041e4f6ea1e2316179a82031001308be23a2524)) + ## 1.35.1 (2024-06-19) Full Changelog: [v1.35.0...v1.35.1](https://github.com/openai/openai-python/compare/v1.35.0...v1.35.1) diff --git a/pyproject.toml b/pyproject.toml index 270c21f4cf..91a3f5d19d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "openai" -version = "1.35.1" +version = "1.35.2" description = "The official Python library for the openai API" dynamic = ["readme"] license = "Apache-2.0" diff --git a/src/openai/_version.py b/src/openai/_version.py index ae8e3fb08d..f053bcea86 100644 --- a/src/openai/_version.py +++ b/src/openai/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "openai" -__version__ = "1.35.1" # x-release-please-version +__version__ = "1.35.2" # x-release-please-version