Skip to content

Commit f427efa

Browse files
committed
fix(parsing): don't validate input tools in the asynchronous .parse() method
1 parent d16e6ed commit f427efa

File tree

3 files changed

+0
-27
lines changed

3 files changed

+0
-27
lines changed

Diff for: src/openai/lib/_parsing/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
has_parseable_input,
44
has_parseable_input as has_parseable_input,
55
maybe_parse_content as maybe_parse_content,
6-
validate_input_tools as validate_input_tools,
76
parse_chat_completion as parse_chat_completion,
87
get_input_tool_by_name as get_input_tool_by_name,
98
solve_response_format_t as solve_response_format_t,

Diff for: src/openai/lib/_parsing/_completions.py

-19
Original file line numberDiff line numberDiff line change
@@ -36,25 +36,6 @@
3636
_default_response_format: None = None
3737

3838

39-
def validate_input_tools(
40-
tools: Iterable[ChatCompletionToolParam] | NotGiven = NOT_GIVEN,
41-
) -> None:
42-
if not is_given(tools):
43-
return
44-
45-
for tool in tools:
46-
if tool["type"] != "function":
47-
raise ValueError(
48-
f'Currently only `function` tool types support auto-parsing; Received `{tool["type"]}`',
49-
)
50-
51-
strict = tool["function"].get("strict")
52-
if strict is not True:
53-
raise ValueError(
54-
f'`{tool["function"]["name"]}` is not strict. Only `strict` function tools can be auto-parsed'
55-
)
56-
57-
5839
def parse_chat_completion(
5940
*,
6041
response_format: type[ResponseFormatT] | completion_create_params.ResponseFormat | NotGiven,

Diff for: src/openai/resources/beta/chat/completions.py

-7
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
from ...._base_client import make_request_options
2323
from ....lib._parsing import (
2424
ResponseFormatT,
25-
validate_input_tools as _validate_input_tools,
2625
parse_chat_completion as _parse_chat_completion,
2726
type_to_response_format_param as _type_to_response_format,
2827
)
@@ -143,8 +142,6 @@ class MathResponse(BaseModel):
143142
print("answer: ", message.parsed.final_answer)
144143
```
145144
"""
146-
_validate_input_tools(tools)
147-
148145
extra_headers = {
149146
"X-Stainless-Helper-Method": "beta.chat.completions.parse",
150147
**(extra_headers or {}),
@@ -268,7 +265,6 @@ def stream(
268265
When the context manager exits, the response will be closed, however the `stream` instance is still available outside
269266
the context manager.
270267
"""
271-
_validate_input_tools(tools)
272268

273269
extra_headers = {
274270
"X-Stainless-Helper-Method": "beta.chat.completions.stream",
@@ -420,8 +416,6 @@ class MathResponse(BaseModel):
420416
print("answer: ", message.parsed.final_answer)
421417
```
422418
"""
423-
_validate_input_tools(tools)
424-
425419
extra_headers = {
426420
"X-Stainless-Helper-Method": "beta.chat.completions.parse",
427421
**(extra_headers or {}),
@@ -545,7 +539,6 @@ def stream(
545539
When the context manager exits, the response will be closed, however the `stream` instance is still available outside
546540
the context manager.
547541
"""
548-
_validate_input_tools(tools)
549542

550543
extra_headers = {
551544
"X-Stainless-Helper-Method": "beta.chat.completions.stream",

0 commit comments

Comments
 (0)