Skip to content

Commit 1d22885

Browse files
RobertCraigiestainless-app[bot]
authored andcommitted
chore(runs/create_and_poll): add parallel_tool_calls request param
1 parent 195c05a commit 1d22885

File tree

2 files changed

+20
-33
lines changed

2 files changed

+20
-33
lines changed

src/openai/resources/beta/threads/runs/runs.py

+8
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,8 @@ def create_and_poll(
822822
Literal[
823823
"gpt-4o",
824824
"gpt-4o-2024-05-13",
825+
"gpt-4o-mini",
826+
"gpt-4o-mini-2024-07-18",
825827
"gpt-4-turbo",
826828
"gpt-4-turbo-2024-04-09",
827829
"gpt-4-0125-preview",
@@ -844,6 +846,7 @@ def create_and_poll(
844846
None,
845847
]
846848
| NotGiven = NOT_GIVEN,
849+
parallel_tool_calls: bool | NotGiven = NOT_GIVEN,
847850
response_format: Optional[AssistantResponseFormatOptionParam] | NotGiven = NOT_GIVEN,
848851
temperature: Optional[float] | NotGiven = NOT_GIVEN,
849852
tool_choice: Optional[AssistantToolChoiceOptionParam] | NotGiven = NOT_GIVEN,
@@ -877,6 +880,7 @@ def create_and_poll(
877880
response_format=response_format,
878881
temperature=temperature,
879882
tool_choice=tool_choice,
883+
parallel_tool_calls=parallel_tool_calls,
880884
# We assume we are not streaming when polling
881885
stream=False,
882886
tools=tools,
@@ -2404,6 +2408,8 @@ async def create_and_poll(
24042408
Literal[
24052409
"gpt-4o",
24062410
"gpt-4o-2024-05-13",
2411+
"gpt-4o-mini",
2412+
"gpt-4o-mini-2024-07-18",
24072413
"gpt-4-turbo",
24082414
"gpt-4-turbo-2024-04-09",
24092415
"gpt-4-0125-preview",
@@ -2426,6 +2432,7 @@ async def create_and_poll(
24262432
None,
24272433
]
24282434
| NotGiven = NOT_GIVEN,
2435+
parallel_tool_calls: bool | NotGiven = NOT_GIVEN,
24292436
response_format: Optional[AssistantResponseFormatOptionParam] | NotGiven = NOT_GIVEN,
24302437
temperature: Optional[float] | NotGiven = NOT_GIVEN,
24312438
tool_choice: Optional[AssistantToolChoiceOptionParam] | NotGiven = NOT_GIVEN,
@@ -2459,6 +2466,7 @@ async def create_and_poll(
24592466
response_format=response_format,
24602467
temperature=temperature,
24612468
tool_choice=tool_choice,
2469+
parallel_tool_calls=parallel_tool_calls,
24622470
# We assume we are not streaming when polling
24632471
stream=False,
24642472
tools=tools,

tests/lib/test_assistants.py

+12-33
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,9 @@
11
from __future__ import annotations
22

3-
import inspect
4-
from typing import Any, Callable
5-
63
import pytest
74

85
from openai import OpenAI, AsyncOpenAI
9-
10-
11-
def assert_signatures_in_sync(
12-
source_func: Callable[..., Any],
13-
check_func: Callable[..., Any],
14-
*,
15-
exclude_params: set[str] = set(),
16-
) -> None:
17-
check_sig = inspect.signature(check_func)
18-
source_sig = inspect.signature(source_func)
19-
20-
errors: list[str] = []
21-
22-
for name, generated_param in source_sig.parameters.items():
23-
if name in exclude_params:
24-
continue
25-
26-
custom_param = check_sig.parameters.get(name)
27-
if not custom_param:
28-
errors.append(f"the `{name}` param is missing")
29-
continue
30-
31-
if custom_param.annotation != generated_param.annotation:
32-
errors.append(
33-
f"types for the `{name}` param are do not match; generated={repr(generated_param.annotation)} custom={repr(generated_param.annotation)}"
34-
)
35-
continue
36-
37-
if errors:
38-
raise AssertionError(f"{len(errors)} errors encountered when comparing signatures:\n\n" + "\n\n".join(errors))
6+
from openai._utils import assert_signatures_in_sync
397

408

419
@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
5826
checking_client.beta.threads.create_and_run_stream,
5927
exclude_params={"stream"},
6028
)
29+
30+
31+
@pytest.mark.parametrize("sync", [True, False], ids=["sync", "async"])
32+
def test_create_and_poll_method_definition_in_sync(sync: bool, client: OpenAI, async_client: AsyncOpenAI) -> None:
33+
checking_client: OpenAI | AsyncOpenAI = client if sync else async_client
34+
35+
assert_signatures_in_sync(
36+
checking_client.beta.threads.runs.create,
37+
checking_client.beta.threads.runs.create_and_poll,
38+
exclude_params={"stream"},
39+
)

0 commit comments

Comments
 (0)