-
Notifications
You must be signed in to change notification settings - Fork 5.2k
fix(types): allow find_in_page actions without url #3792
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
984de0d
e414103
1833cd0
914a0e4
aed30ff
e600208
45522f9
c441096
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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__ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This assertion does not verify the intended TypedDict change: both parameter modules use postponed annotations, so Useful? React with 👍 / 👎. |
||
|
|
||
|
|
||
| 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__ | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reported API discrepancy is that
urlmay be omitted, not that a presenturlmay be null; the checked-in contract still defines it as a non-null string URI inapi_reference/openapi.transformed.yml:60837-60841. Because this TypedDict already hastotal=False, declaringurl: strmakes the key optional while continuing to rejectNone; usingOptional[str]instead exposes null as a valid request value to type-checked callers even though the API may reject it. The beta parameter type has the same problem.Useful? React with 👍 / 👎.