diff --git a/src/openai/types/beta/beta_response_function_web_search.py b/src/openai/types/beta/beta_response_function_web_search.py index af57015543..dc22916303 100644 --- a/src/openai/types/beta/beta_response_function_web_search.py +++ b/src/openai/types/beta/beta_response_function_web_search.py @@ -62,8 +62,8 @@ class ActionFindInPage(BaseModel): type: Literal["find_in_page"] """The action type.""" - url: str - """The URL of the page searched for the pattern.""" + url: Optional[str] = None + """The URL of the page searched for the pattern, when provided.""" Action: TypeAlias = Annotated[Union[ActionSearch, ActionOpenPage, ActionFindInPage], PropertyInfo(discriminator="type")] diff --git a/src/openai/types/beta/beta_response_function_web_search_param.py b/src/openai/types/beta/beta_response_function_web_search_param.py index 8c8a92c684..e5e2fab50a 100644 --- a/src/openai/types/beta/beta_response_function_web_search_param.py +++ b/src/openai/types/beta/beta_response_function_web_search_param.py @@ -63,8 +63,8 @@ class ActionFindInPage(TypedDict, total=False): type: Required[Literal["find_in_page"]] """The action type.""" - url: Required[str] - """The URL of the page searched for the pattern.""" + url: Optional[str] + """The URL of the page searched for the pattern, when provided.""" Action: TypeAlias = Union[ActionSearch, ActionOpenPage, ActionFindInPage] diff --git a/src/openai/types/responses/response_function_web_search.py b/src/openai/types/responses/response_function_web_search.py index 44c6dd7a99..667441452e 100644 --- a/src/openai/types/responses/response_function_web_search.py +++ b/src/openai/types/responses/response_function_web_search.py @@ -61,8 +61,8 @@ class ActionFind(BaseModel): type: Literal["find_in_page"] """The action type.""" - url: str - """The URL of the page searched for the pattern.""" + url: Optional[str] = None + """The URL of the page searched for the pattern, when provided.""" Action: TypeAlias = Annotated[Union[ActionSearch, ActionOpenPage, ActionFind], PropertyInfo(discriminator="type")] diff --git a/src/openai/types/responses/response_function_web_search_param.py b/src/openai/types/responses/response_function_web_search_param.py index 122ea72ad0..70d5763c21 100644 --- a/src/openai/types/responses/response_function_web_search_param.py +++ b/src/openai/types/responses/response_function_web_search_param.py @@ -62,8 +62,8 @@ class ActionFind(TypedDict, total=False): type: Required[Literal["find_in_page"]] """The action type.""" - url: Required[str] - """The URL of the page searched for the pattern.""" + url: Optional[str] + """The URL of the page searched for the pattern, when provided.""" Action: TypeAlias = Union[ActionSearch, ActionOpenPage, ActionFind] diff --git a/tests/test_web_search_action_types.py b/tests/test_web_search_action_types.py new file mode 100644 index 0000000000..bbee37ae93 --- /dev/null +++ b/tests/test_web_search_action_types.py @@ -0,0 +1,30 @@ +from openai._compat import model_parse +from openai.types.beta.beta_response_function_web_search import BetaResponseFunctionWebSearch +from openai.types.beta.beta_response_function_web_search_param import ActionFindInPage as BetaActionFindParam +from openai.types.responses.response_function_web_search import ResponseFunctionWebSearch +from openai.types.responses.response_function_web_search_param import ActionFind as ActionFindParam + + +def _find_payload() -> dict[str, object]: + return { + "id": "ws_test", + "type": "web_search_call", + "status": "completed", + "action": {"type": "find_in_page", "pattern": "og:image"}, + } + + +def test_find_in_page_action_allows_missing_url() -> None: + item = model_parse(ResponseFunctionWebSearch, _find_payload()) + + assert item.action.type == "find_in_page" + assert item.action.url is None + assert "url" not in ActionFindParam.__required_keys__ + + +def test_beta_find_in_page_action_allows_missing_url() -> None: + item = model_parse(BetaResponseFunctionWebSearch, _find_payload()) + + assert item.action.type == "find_in_page" + assert item.action.url is None + assert "url" not in BetaActionFindParam.__required_keys__