diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 6fc89ad7bc..9baafa1759 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "1.37.1" + ".": "1.37.2" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 138180cf6b..824d4d83b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## 1.37.2 (2024-08-01) + +Full Changelog: [v1.37.1...v1.37.2](https://github.com/openai/openai-python/compare/v1.37.1...v1.37.2) + +### Chores + +* **internal:** add type construction helper ([#1584](https://github.com/openai/openai-python/issues/1584)) ([cbb186a](https://github.com/openai/openai-python/commit/cbb186a534b520fa5b11a9b371b175e3f6a6482b)) +* **runs/create_and_poll:** add parallel_tool_calls request param ([04b3e6c](https://github.com/openai/openai-python/commit/04b3e6c39ee5a7088e0e4dfa4c06f3dcce901a57)) + ## 1.37.1 (2024-07-25) Full Changelog: [v1.37.0...v1.37.1](https://github.com/openai/openai-python/compare/v1.37.0...v1.37.1) diff --git a/pyproject.toml b/pyproject.toml index c4d5bbd1aa..3c6dcd409a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "openai" -version = "1.37.1" +version = "1.37.2" description = "The official Python library for the openai API" dynamic = ["readme"] license = "Apache-2.0" diff --git a/src/openai/_models.py b/src/openai/_models.py index eb7ce3bde9..5148d5a7b3 100644 --- a/src/openai/_models.py +++ b/src/openai/_models.py @@ -406,6 +406,15 @@ def build( return cast(_BaseModelT, construct_type(type_=base_model_cls, value=kwargs)) +def construct_type_unchecked(*, value: object, type_: type[_T]) -> _T: + """Loose coercion to the expected type with construction of nested values. + + Note: the returned value from this function is not guaranteed to match the + given type. + """ + return cast(_T, construct_type(value=value, type_=type_)) + + def construct_type(*, value: object, type_: object) -> object: """Loose coercion to the expected type with construction of nested values. diff --git a/src/openai/_version.py b/src/openai/_version.py index 5e58cb3c83..e36be4473a 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.37.1" # x-release-please-version +__version__ = "1.37.2" # x-release-please-version diff --git a/src/openai/resources/beta/threads/runs/runs.py b/src/openai/resources/beta/threads/runs/runs.py index 1759120bfe..7db8b120f9 100644 --- a/src/openai/resources/beta/threads/runs/runs.py +++ b/src/openai/resources/beta/threads/runs/runs.py @@ -822,6 +822,8 @@ def create_and_poll( Literal[ "gpt-4o", "gpt-4o-2024-05-13", + "gpt-4o-mini", + "gpt-4o-mini-2024-07-18", "gpt-4-turbo", "gpt-4-turbo-2024-04-09", "gpt-4-0125-preview", @@ -844,6 +846,7 @@ def create_and_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, tool_choice: Optional[AssistantToolChoiceOptionParam] | NotGiven = NOT_GIVEN, @@ -877,6 +880,7 @@ def create_and_poll( response_format=response_format, temperature=temperature, tool_choice=tool_choice, + parallel_tool_calls=parallel_tool_calls, # We assume we are not streaming when polling stream=False, tools=tools, @@ -2404,6 +2408,8 @@ async def create_and_poll( Literal[ "gpt-4o", "gpt-4o-2024-05-13", + "gpt-4o-mini", + "gpt-4o-mini-2024-07-18", "gpt-4-turbo", "gpt-4-turbo-2024-04-09", "gpt-4-0125-preview", @@ -2426,6 +2432,7 @@ async def create_and_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, tool_choice: Optional[AssistantToolChoiceOptionParam] | NotGiven = NOT_GIVEN, @@ -2459,6 +2466,7 @@ async def create_and_poll( response_format=response_format, temperature=temperature, tool_choice=tool_choice, + parallel_tool_calls=parallel_tool_calls, # We assume we are not streaming when polling stream=False, tools=tools, diff --git a/tests/lib/test_assistants.py b/tests/lib/test_assistants.py index 38a47d4d12..b9d4e8927c 100644 --- a/tests/lib/test_assistants.py +++ b/tests/lib/test_assistants.py @@ -1,41 +1,9 @@ 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)) +from openai._utils import assert_signatures_in_sync @pytest.mark.parametrize("sync", [True, False], ids=["sync", "async"]) @@ -58,3 +26,14 @@ def test_create_and_run_stream_method_definition_in_sync(sync: bool, client: Ope checking_client.beta.threads.create_and_run_stream, exclude_params={"stream"}, ) + + +@pytest.mark.parametrize("sync", [True, False], ids=["sync", "async"]) +def test_create_and_poll_method_definition_in_sync(sync: bool, client: OpenAI, async_client: AsyncOpenAI) -> None: + checking_client: OpenAI | AsyncOpenAI = client if sync else async_client + + assert_signatures_in_sync( + checking_client.beta.threads.runs.create, + checking_client.beta.threads.runs.create_and_poll, + exclude_params={"stream"}, + )