Skip to content

Commit 3c5c2c3

Browse files
feat(api): api update
1 parent 3a29950 commit 3c5c2c3

7 files changed

Lines changed: 174 additions & 19 deletions

File tree

‎.stats.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 41
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-bf7ffa610bd4a02ea5bcb157521d17a041a48f78d87bf8fe8d812d3cbb87b489.yml
3-
openapi_spec_hash: 90142d96969dea44c46a01abb683c426
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-2c3f4e4b357ca78c019a3aacd006e2bb8b332d4172a300ee6c46c076a216ed3f.yml
3+
openapi_spec_hash: b89be415cf6ee594b521885a9deb25ac
44
config_hash: 0fb0ceca5946298c416cec0cca5260c7

‎src/context/dev/resources/web.py‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,10 @@ def extract(
106106
url: The starting website URL to crawl and extract from. Must include http:// or
107107
https://.
108108
109-
actions: Optional browser actions executed in order on the requested page after it loads
110-
and before extraction. Requires a paid plan. When actions are provided and
111-
stopAfterMs is omitted, the crawl budget defaults to 110000 ms.
109+
actions: Optional browser actions executed in order on the requested page after it loads,
110+
before links are discovered or additional pages are crawled. Requires a paid
111+
plan. When actions are provided and stopAfterMs is omitted, the crawl budget
112+
defaults to 110000 ms.
112113
113114
fact_check: When true, every returned value must be grounded in facts stated on the page;
114115
fields that cannot be supported by the page are returned as null/empty. When
@@ -2355,9 +2356,10 @@ async def extract(
23552356
url: The starting website URL to crawl and extract from. Must include http:// or
23562357
https://.
23572358
2358-
actions: Optional browser actions executed in order on the requested page after it loads
2359-
and before extraction. Requires a paid plan. When actions are provided and
2360-
stopAfterMs is omitted, the crawl budget defaults to 110000 ms.
2359+
actions: Optional browser actions executed in order on the requested page after it loads,
2360+
before links are discovered or additional pages are crawled. Requires a paid
2361+
plan. When actions are provided and stopAfterMs is omitted, the crawl budget
2362+
defaults to 110000 ms.
23612363
23622364
fact_check: When true, every returned value must be grounded in facts stated on the page;
23632365
fields that cannot be supported by the page are returned as null/empty. When

‎src/context/dev/types/web_extract_params.py‎

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,14 @@
88
from .._types import SequenceNotStr
99
from .._utils import PropertyInfo
1010

11-
__all__ = ["WebExtractParams", "Action", "ActionWebScrapeWaitAction", "ActionWebScrapePerformAction", "Pdf"]
11+
__all__ = [
12+
"WebExtractParams",
13+
"Action",
14+
"ActionWebScrapeWaitAction",
15+
"ActionWebScrapePerformAction",
16+
"ActionWebScrapeScrollAction",
17+
"Pdf",
18+
]
1219

1320

1421
class WebExtractParams(TypedDict, total=False):
@@ -29,9 +36,10 @@ class WebExtractParams(TypedDict, total=False):
2936

3037
actions: Iterable[Action]
3138
"""
32-
Optional browser actions executed in order on the requested page after it loads
33-
and before extraction. Requires a paid plan. When actions are provided and
34-
stopAfterMs is omitted, the crawl budget defaults to 110000 ms.
39+
Optional browser actions executed in order on the requested page after it loads,
40+
before links are discovered or additional pages are crawled. Requires a paid
41+
plan. When actions are provided and stopAfterMs is omitted, the crawl budget
42+
defaults to 110000 ms.
3543
"""
3644

3745
fact_check: Annotated[bool, PropertyInfo(alias="factCheck")]
@@ -120,7 +128,33 @@ class ActionWebScrapePerformAction(TypedDict, total=False):
120128
do: Required[Literal["perform"]]
121129

122130

123-
Action: TypeAlias = Union[ActionWebScrapeWaitAction, ActionWebScrapePerformAction]
131+
class ActionWebScrapeScrollAction(TypedDict, total=False):
132+
"""
133+
Scroll the page or a selected scrollable container, waiting adaptively for content and dimensions to settle after each iteration.
134+
"""
135+
136+
do: Required[Literal["scroll"]]
137+
138+
amount: Union[int, Literal["viewport", "max"]]
139+
"""Pixels per scroll, one visible viewport, or the current scroll boundary.
140+
141+
Defaults to viewport.
142+
"""
143+
144+
container: str
145+
"""CSS selector for the first matching scroll container. Defaults to the page."""
146+
147+
direction: Literal["up", "down", "left", "right"]
148+
"""Direction to scroll. Defaults to down."""
149+
150+
max_scrolls: Annotated[int, PropertyInfo(alias="maxScrolls")]
151+
"""Maximum scroll iterations.
152+
153+
Stops early when scrolling and scrollable extent stop changing. Defaults to 1.
154+
"""
155+
156+
157+
Action: TypeAlias = Union[ActionWebScrapeWaitAction, ActionWebScrapePerformAction, ActionWebScrapeScrollAction]
124158

125159

126160
class Pdf(TypedDict, total=False):

‎src/context/dev/types/web_web_scrape_html_params.py‎

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,14 @@
88
from .._types import SequenceNotStr
99
from .._utils import PropertyInfo
1010

11-
__all__ = ["WebWebScrapeHTMLParams", "Action", "ActionWebScrapeWaitAction", "ActionWebScrapePerformAction", "Pdf"]
11+
__all__ = [
12+
"WebWebScrapeHTMLParams",
13+
"Action",
14+
"ActionWebScrapeWaitAction",
15+
"ActionWebScrapePerformAction",
16+
"ActionWebScrapeScrollAction",
17+
"Pdf",
18+
]
1219

1320

1421
class WebWebScrapeHTMLParams(TypedDict, total=False):
@@ -330,7 +337,33 @@ class ActionWebScrapePerformAction(TypedDict, total=False):
330337
do: Required[Literal["perform"]]
331338

332339

333-
Action: TypeAlias = Union[ActionWebScrapeWaitAction, ActionWebScrapePerformAction]
340+
class ActionWebScrapeScrollAction(TypedDict, total=False):
341+
"""
342+
Scroll the page or a selected scrollable container, waiting adaptively for content and dimensions to settle after each iteration.
343+
"""
344+
345+
do: Required[Literal["scroll"]]
346+
347+
amount: Union[int, Literal["viewport", "max"]]
348+
"""Pixels per scroll, one visible viewport, or the current scroll boundary.
349+
350+
Defaults to viewport.
351+
"""
352+
353+
container: str
354+
"""CSS selector for the first matching scroll container. Defaults to the page."""
355+
356+
direction: Literal["up", "down", "left", "right"]
357+
"""Direction to scroll. Defaults to down."""
358+
359+
max_scrolls: Annotated[int, PropertyInfo(alias="maxScrolls")]
360+
"""Maximum scroll iterations.
361+
362+
Stops early when scrolling and scrollable extent stop changing. Defaults to 1.
363+
"""
364+
365+
366+
Action: TypeAlias = Union[ActionWebScrapeWaitAction, ActionWebScrapePerformAction, ActionWebScrapeScrollAction]
334367

335368

336369
class Pdf(TypedDict, total=False):

‎src/context/dev/types/web_web_scrape_images_params.py‎

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"Action",
1414
"ActionWebScrapeWaitAction",
1515
"ActionWebScrapePerformAction",
16+
"ActionWebScrapeScrollAction",
1617
"Enrichment",
1718
]
1819

@@ -93,7 +94,33 @@ class ActionWebScrapePerformAction(TypedDict, total=False):
9394
do: Required[Literal["perform"]]
9495

9596

96-
Action: TypeAlias = Union[ActionWebScrapeWaitAction, ActionWebScrapePerformAction]
97+
class ActionWebScrapeScrollAction(TypedDict, total=False):
98+
"""
99+
Scroll the page or a selected scrollable container, waiting adaptively for content and dimensions to settle after each iteration.
100+
"""
101+
102+
do: Required[Literal["scroll"]]
103+
104+
amount: Union[int, Literal["viewport", "max"]]
105+
"""Pixels per scroll, one visible viewport, or the current scroll boundary.
106+
107+
Defaults to viewport.
108+
"""
109+
110+
container: str
111+
"""CSS selector for the first matching scroll container. Defaults to the page."""
112+
113+
direction: Literal["up", "down", "left", "right"]
114+
"""Direction to scroll. Defaults to down."""
115+
116+
max_scrolls: Annotated[int, PropertyInfo(alias="maxScrolls")]
117+
"""Maximum scroll iterations.
118+
119+
Stops early when scrolling and scrollable extent stop changing. Defaults to 1.
120+
"""
121+
122+
123+
Action: TypeAlias = Union[ActionWebScrapeWaitAction, ActionWebScrapePerformAction, ActionWebScrapeScrollAction]
97124

98125

99126
class Enrichment(TypedDict, total=False):

‎src/context/dev/types/web_web_scrape_images_response.py‎

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
from typing import List, Optional
44
from typing_extensions import Literal
55

6+
from pydantic import Field as FieldInfo
7+
68
from .._models import BaseModel
79

8-
__all__ = ["WebWebScrapeImagesResponse", "Image", "ImageEnrichment", "KeyMetadata"]
10+
__all__ = ["WebWebScrapeImagesResponse", "Image", "ImageEnrichment", "ActionsApplied", "KeyMetadata"]
911

1012

1113
class ImageEnrichment(BaseModel):
@@ -46,6 +48,27 @@ class Image(BaseModel):
4648
"""Requested metadata for images that could be processed."""
4749

4850

51+
class ActionsApplied(BaseModel):
52+
instruction: str
53+
54+
status: Literal["applied", "failed", "skipped"]
55+
"""Applied means the requested page state was visibly verified.
56+
57+
Failed means it was not verified. Skipped means it was not attempted.
58+
"""
59+
60+
completion_evidence: Optional[str] = FieldInfo(alias="completionEvidence", default=None)
61+
"""Visible page evidence used to verify an applied action."""
62+
63+
duration_ms: Optional[float] = FieldInfo(alias="durationMs", default=None)
64+
65+
error: Optional[str] = None
66+
67+
method: Optional[str] = None
68+
69+
target_description: Optional[str] = FieldInfo(alias="targetDescription", default=None)
70+
71+
4972
class KeyMetadata(BaseModel):
5073
"""Metadata about the API key used for the request.
5174
@@ -69,6 +92,9 @@ class WebWebScrapeImagesResponse(BaseModel):
6992
url: str
7093
"""Page URL that was scraped."""
7194

95+
actions_applied: Optional[List[ActionsApplied]] = FieldInfo(alias="actionsApplied", default=None)
96+
"""One verified outcome per requested browser action, in request order."""
97+
7298
key_metadata: Optional[KeyMetadata] = None
7399
"""Metadata about the API key used for the request.
74100

‎src/context/dev/types/web_web_scrape_md_params.py‎

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,14 @@
88
from .._types import SequenceNotStr
99
from .._utils import PropertyInfo
1010

11-
__all__ = ["WebWebScrapeMdParams", "Action", "ActionWebScrapeWaitAction", "ActionWebScrapePerformAction", "Pdf"]
11+
__all__ = [
12+
"WebWebScrapeMdParams",
13+
"Action",
14+
"ActionWebScrapeWaitAction",
15+
"ActionWebScrapePerformAction",
16+
"ActionWebScrapeScrollAction",
17+
"Pdf",
18+
]
1219

1320

1421
class WebWebScrapeMdParams(TypedDict, total=False):
@@ -349,7 +356,33 @@ class ActionWebScrapePerformAction(TypedDict, total=False):
349356
do: Required[Literal["perform"]]
350357

351358

352-
Action: TypeAlias = Union[ActionWebScrapeWaitAction, ActionWebScrapePerformAction]
359+
class ActionWebScrapeScrollAction(TypedDict, total=False):
360+
"""
361+
Scroll the page or a selected scrollable container, waiting adaptively for content and dimensions to settle after each iteration.
362+
"""
363+
364+
do: Required[Literal["scroll"]]
365+
366+
amount: Union[int, Literal["viewport", "max"]]
367+
"""Pixels per scroll, one visible viewport, or the current scroll boundary.
368+
369+
Defaults to viewport.
370+
"""
371+
372+
container: str
373+
"""CSS selector for the first matching scroll container. Defaults to the page."""
374+
375+
direction: Literal["up", "down", "left", "right"]
376+
"""Direction to scroll. Defaults to down."""
377+
378+
max_scrolls: Annotated[int, PropertyInfo(alias="maxScrolls")]
379+
"""Maximum scroll iterations.
380+
381+
Stops early when scrolling and scrollable extent stop changing. Defaults to 1.
382+
"""
383+
384+
385+
Action: TypeAlias = Union[ActionWebScrapeWaitAction, ActionWebScrapePerformAction, ActionWebScrapeScrollAction]
353386

354387

355388
class Pdf(TypedDict, total=False):

0 commit comments

Comments
 (0)