Skip to content

Commit c8ff8a5

Browse files
committed
fix(types): allow missing find-in-page URLs
1 parent b24aeda commit c8ff8a5

6 files changed

Lines changed: 26 additions & 8 deletions

File tree

api_reference/openapi.transformed.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60845,7 +60845,6 @@ components:
6084560845
The pattern or text to search for within the page.
6084660846
required:
6084760847
- type
60848-
- url
6084960848
- pattern
6085060849
WebSearchActionOpenPage:
6085160850
type: object
@@ -72435,7 +72434,6 @@ components:
7243572434
The pattern or text to search for within the page.
7243672435
required:
7243772436
- type
72438-
- url
7243972437
- pattern
7244072438
BetaWebSearchActionOpenPage:
7244172439
type: object

src/openai/types/beta/beta_response_function_web_search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class ActionFindInPage(BaseModel):
6262
type: Literal["find_in_page"]
6363
"""The action type."""
6464

65-
url: str
65+
url: Optional[str] = None
6666
"""The URL of the page searched for the pattern."""
6767

6868

src/openai/types/beta/beta_response_function_web_search_param.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class ActionFindInPage(TypedDict, total=False):
6363
type: Required[Literal["find_in_page"]]
6464
"""The action type."""
6565

66-
url: Required[str]
66+
url: str
6767
"""The URL of the page searched for the pattern."""
6868

6969

src/openai/types/responses/response_function_web_search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class ActionFind(BaseModel):
6161
type: Literal["find_in_page"]
6262
"""The action type."""
6363

64-
url: str
64+
url: Optional[str] = None
6565
"""The URL of the page searched for the pattern."""
6666

6767

src/openai/types/responses/response_function_web_search_param.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class ActionFind(TypedDict, total=False):
6262
type: Required[Literal["find_in_page"]]
6363
"""The action type."""
6464

65-
url: Required[str]
65+
url: str
6666
"""The URL of the page searched for the pattern."""
6767

6868

tests/lib/responses/test_responses.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
from tests.respx2 import MockRouter
1010
from openai._types import omit
1111
from openai._utils import assert_signatures_in_sync
12-
from openai._models import construct_type_unchecked
13-
from openai.types.responses import Response
12+
from openai._models import BaseModel, construct_type_unchecked
13+
from openai.types.beta import BetaResponseFunctionWebSearch
14+
from openai.types.responses import Response, ResponseFunctionWebSearch
1415
from openai.lib._parsing._responses import parse_response
1516

1617
from ...conftest import base_url
@@ -72,6 +73,25 @@ def test_parse_response_preserves_program_items(item: dict[str, object]) -> None
7273
assert parsed.output[0].to_dict() == item
7374

7475

76+
@pytest.mark.parametrize(
77+
"response_model",
78+
[ResponseFunctionWebSearch, BetaResponseFunctionWebSearch],
79+
ids=["responses", "beta"],
80+
)
81+
def test_find_in_page_action_allows_missing_url(response_model: type[BaseModel]) -> None:
82+
response = response_model.model_validate(
83+
{
84+
"id": "ws_redacted",
85+
"type": "web_search_call",
86+
"status": "completed",
87+
"action": {"type": "find_in_page", "pattern": "og:image"},
88+
}
89+
)
90+
91+
assert response.action.type == "find_in_page"
92+
assert getattr(response.action, "url", None) is None
93+
94+
7595
@pytest.mark.parametrize("sync", [True, False], ids=["sync", "async"])
7696
def test_stream_method_definition_in_sync(sync: bool, client: OpenAI, async_client: AsyncOpenAI) -> None:
7797
checking_client: OpenAI | AsyncOpenAI = client if sync else async_client

0 commit comments

Comments
 (0)