Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class ActionFindInPage(BaseModel):
type: Literal["find_in_page"]
"""The action type."""

url: str
url: Optional[str] = None
"""The URL of the page searched for the pattern."""


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class ActionFindInPage(TypedDict, total=False):
type: Required[Literal["find_in_page"]]
"""The action type."""

url: Required[str]
url: str
"""The URL of the page searched for the pattern."""


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class ActionFind(BaseModel):
type: Literal["find_in_page"]
"""The action type."""

url: str
url: Optional[str] = None
"""The URL of the page searched for the pattern."""


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class ActionFind(TypedDict, total=False):
type: Required[Literal["find_in_page"]]
"""The action type."""

url: Required[str]
url: str
"""The URL of the page searched for the pattern."""


Expand Down
26 changes: 24 additions & 2 deletions tests/lib/responses/test_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
from tests.respx2 import MockRouter
from openai._types import omit
from openai._utils import assert_signatures_in_sync
from openai._models import construct_type_unchecked
from openai.types.responses import Response
from openai._compat import parse_obj
from openai._models import BaseModel, construct_type_unchecked
from openai.types.beta import BetaResponseFunctionWebSearch
from openai.types.responses import Response, ResponseFunctionWebSearch
from openai.lib._parsing._responses import parse_response

from ...conftest import base_url
Expand Down Expand Up @@ -72,6 +74,26 @@ def test_parse_response_preserves_program_items(item: dict[str, object]) -> None
assert parsed.output[0].to_dict() == item


@pytest.mark.parametrize(
"response_model",
[ResponseFunctionWebSearch, BetaResponseFunctionWebSearch],
ids=["responses", "beta"],
)
def test_find_in_page_action_allows_missing_url(response_model: type[BaseModel]) -> None:
response = parse_obj(
response_model,
{
"id": "ws_redacted",
"type": "web_search_call",
"status": "completed",
"action": {"type": "find_in_page", "pattern": "og:image"},
},
)

assert response.action.type == "find_in_page"
assert getattr(response.action, "url", None) is None


@pytest.mark.parametrize("sync", [True, False], ids=["sync", "async"])
def test_stream_method_definition_in_sync(sync: bool, client: OpenAI, async_client: AsyncOpenAI) -> None:
checking_client: OpenAI | AsyncOpenAI = client if sync else async_client
Expand Down