-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Description
Confirm this is an issue with the Python library and not an underlying OpenAI API
- This is an issue with the Python library
Describe the bug
Output items like
{
"id": "ws_redacted",
"type": "web_search_call",
"status": "completed",
"action": {
"type": "find_in_page",
"pattern": "USD",
"url": "https://www.example.com"
}
}
were rejected due to not present in
Action: TypeAlias = Annotated[Union[ActionSearch, ActionOpenPage, ActionFind], PropertyInfo(discriminator="type")] |
To Reproduce
from openai.types.responses.response_function_web_search import ResponseFunctionWebSearch
obj = ResponseFunctionWebSearch.model_validate({
"id": "ws_redacted",
"type": "web_search_call",
"status": "completed",
"action": {
"type": "find_in_page",
"pattern": "USD",
"url": "https://www.example.com"
}
})
print(obj)
uv run test_minimal.py
Traceback (most recent call last):
File "test_minimal.py", line 2, in
obj = ResponseFunctionWebSearch.model_validate({
"id": "ws_redacted",
...<6 lines>...
}
})
File ".venv\Lib\site-packages\pydantic\main.py", line 705, in model_validate
return cls.pydantic_validator.validate_python(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
obj, strict=strict, from_attributes=from_attributes, context=context, by_alias=by_alias, by_name=by_name
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
pydantic_core._pydantic_core.ValidationError: 4 validation errors for ResponseFunctionWebSearch
action.ActionSearch.query
Field required [type=missing, input_value={'type': 'find_in_page', ...ttps://www.example.com'}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.11/v/missing
action.ActionSearch.type
Input should be 'search' [type=literal_error, input_value='find_in_page', input_type=str]
For further information visit https://errors.pydantic.dev/2.11/v/literal_error
action.ActionOpenPage.type
Input should be 'open_page' [type=literal_error, input_value='find_in_page', input_type=str]
For further information visit https://errors.pydantic.dev/2.11/v/literal_error
action.ActionFind.type
Input should be 'find' [type=literal_error, input_value='find_in_page', input_type=str]
For further information visit https://errors.pydantic.dev/2.11/v/literal_error
Code snippets
OS
Windows
Python version
3.13.5
Library version
1.107.1