Skip to content

Commit a2fe857

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

File tree

2 files changed

+0
-25
lines changed

2 files changed

+0
-25
lines changed

src/openai/lib/_parsing/_completions.py

Lines changed: 0 additions & 19 deletions
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,

src/openai/resources/beta/chat/completions.py

Lines changed: 0 additions & 6 deletions
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 {}),
@@ -420,8 +417,6 @@ class MathResponse(BaseModel):
420417
print("answer: ", message.parsed.final_answer)
421418
```
422419
"""
423-
_validate_input_tools(tools)
424-
425420
extra_headers = {
426421
"X-Stainless-Helper-Method": "beta.chat.completions.parse",
427422
**(extra_headers or {}),
@@ -545,7 +540,6 @@ def stream(
545540
When the context manager exits, the response will be closed, however the `stream` instance is still available outside
546541
the context manager.
547542
"""
548-
_validate_input_tools(tools)
549543

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

0 commit comments

Comments
 (0)