Skip to content

Commit 23cc0fb

Browse files
feat(api): api update
1 parent e3419e4 commit 23cc0fb

4 files changed

Lines changed: 26 additions & 2 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: 22
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-c4963b57c26ac1a89f0ce8e04a280ee3d68e82d3fb02205623db6a53787112bc.yml
3-
openapi_spec_hash: e277a9c81fa4a02f838be17487555ead
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-f27c9584f74632a8c9603fce7190e3f63275a4ec4030da2a9475efb619618b3f.yml
3+
openapi_spec_hash: 224cb935536a4d999d9683f8c03ea32f
44
config_hash: ff13935d1231ad44cd3822ffe39904b4

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ def web_crawl_md(
273273
max_pages: int | Omit = omit,
274274
pdf: web_web_crawl_md_params.Pdf | Omit = omit,
275275
shorten_base64_images: bool | Omit = omit,
276+
stop_after_ms: int | Omit = omit,
276277
timeout_ms: int | Omit = omit,
277278
url_regex: str | Omit = omit,
278279
use_main_content_only: bool | Omit = omit,
@@ -315,6 +316,11 @@ def web_crawl_md(
315316
316317
shorten_base64_images: Truncate base64-encoded image data in the Markdown output
317318
319+
stop_after_ms: Soft time budget for the crawl in milliseconds. After each scrape, the crawler
320+
checks the elapsed time and, if exceeded, returns the pages collected so far
321+
instead of continuing. Min: 10000 (10s). Max: 240000 (4 min). Default: 120000 (2
322+
min).
323+
318324
timeout_ms: Optional timeout in milliseconds for the request. If the request takes longer
319325
than this value, it will be aborted with a 408 status code. Maximum allowed
320326
value is 300000ms (5 minutes).
@@ -349,6 +355,7 @@ def web_crawl_md(
349355
"max_pages": max_pages,
350356
"pdf": pdf,
351357
"shorten_base64_images": shorten_base64_images,
358+
"stop_after_ms": stop_after_ms,
352359
"timeout_ms": timeout_ms,
353360
"url_regex": url_regex,
354361
"use_main_content_only": use_main_content_only,
@@ -876,6 +883,7 @@ async def web_crawl_md(
876883
max_pages: int | Omit = omit,
877884
pdf: web_web_crawl_md_params.Pdf | Omit = omit,
878885
shorten_base64_images: bool | Omit = omit,
886+
stop_after_ms: int | Omit = omit,
879887
timeout_ms: int | Omit = omit,
880888
url_regex: str | Omit = omit,
881889
use_main_content_only: bool | Omit = omit,
@@ -918,6 +926,11 @@ async def web_crawl_md(
918926
919927
shorten_base64_images: Truncate base64-encoded image data in the Markdown output
920928
929+
stop_after_ms: Soft time budget for the crawl in milliseconds. After each scrape, the crawler
930+
checks the elapsed time and, if exceeded, returns the pages collected so far
931+
instead of continuing. Min: 10000 (10s). Max: 240000 (4 min). Default: 120000 (2
932+
min).
933+
921934
timeout_ms: Optional timeout in milliseconds for the request. If the request takes longer
922935
than this value, it will be aborted with a 408 status code. Maximum allowed
923936
value is 300000ms (5 minutes).
@@ -952,6 +965,7 @@ async def web_crawl_md(
952965
"max_pages": max_pages,
953966
"pdf": pdf,
954967
"shorten_base64_images": shorten_base64_images,
968+
"stop_after_ms": stop_after_ms,
955969
"timeout_ms": timeout_ms,
956970
"url_regex": url_regex,
957971
"use_main_content_only": use_main_content_only,

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ class WebWebCrawlMdParams(TypedDict, total=False):
5555
shorten_base64_images: Annotated[bool, PropertyInfo(alias="shortenBase64Images")]
5656
"""Truncate base64-encoded image data in the Markdown output"""
5757

58+
stop_after_ms: Annotated[int, PropertyInfo(alias="stopAfterMs")]
59+
"""Soft time budget for the crawl in milliseconds.
60+
61+
After each scrape, the crawler checks the elapsed time and, if exceeded, returns
62+
the pages collected so far instead of continuing. Min: 10000 (10s). Max: 240000
63+
(4 min). Default: 120000 (2 min).
64+
"""
65+
5866
timeout_ms: Annotated[int, PropertyInfo(alias="timeoutMS")]
5967
"""Optional timeout in milliseconds for the request.
6068

‎tests/api_resources/test_web.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ def test_method_web_crawl_md_with_all_params(self, client: ContextDev) -> None:
174174
"start": 1,
175175
},
176176
shorten_base64_images=True,
177+
stop_after_ms=10000,
177178
timeout_ms=1000,
178179
url_regex="^https?://[^/]+/blog/",
179180
use_main_content_only=True,
@@ -563,6 +564,7 @@ async def test_method_web_crawl_md_with_all_params(self, async_client: AsyncCont
563564
"start": 1,
564565
},
565566
shorten_base64_images=True,
567+
stop_after_ms=10000,
566568
timeout_ms=1000,
567569
url_regex="^https?://[^/]+/blog/",
568570
use_main_content_only=True,

0 commit comments

Comments
 (0)