Skip to content

Commit d4d77b3

Browse files
author
stlc-bot
committed
feat(parse): support WARC archives in parsing and scraping (#2761)
Stainless-Generated-From: 1093f815e6b080ff11e05431a6bef3055ae7c0fd
1 parent 394b842 commit d4d77b3

5 files changed

Lines changed: 25 additions & 10 deletions

File tree

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

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ def handle(
6363
*,
6464
client: str | Omit = omit,
6565
extension: Literal[
66+
"warc",
67+
"warc.gz",
6668
"txt",
6769
"text",
6870
"md",
@@ -151,14 +153,18 @@ def handle(
151153
extra_body: Body | None = None,
152154
timeout: float | httpx.Timeout | None | NotGiven = not_given,
153155
) -> ParseHandleResponse:
154-
"""
155-
Convert uploaded file bytes into Markdown and optional HTML.
156+
"""Convert uploaded file bytes into Markdown and optional HTML.
157+
158+
WARC and WARC.GZ
159+
archives combine HTTP response, resource, and conversion records in archive
160+
order. Revisit and segmented records are skipped. Decoded WARC content is
161+
limited to 50 MiB.
156162
157163
Args:
158164
client: Optional client identifier used for usage attribution.
159165
160166
extension: Optional file extension hint, such as pdf, docx, xlsx, pptx, html, json, csv,
161-
md, py, rtf, jpg, png, or txt.
167+
md, py, rtf, jpg, png, txt, warc, or warc.gz.
162168
163169
include_images: Include image references in Markdown output
164170
@@ -244,6 +250,8 @@ async def handle(
244250
*,
245251
client: str | Omit = omit,
246252
extension: Literal[
253+
"warc",
254+
"warc.gz",
247255
"txt",
248256
"text",
249257
"md",
@@ -332,14 +340,18 @@ async def handle(
332340
extra_body: Body | None = None,
333341
timeout: float | httpx.Timeout | None | NotGiven = not_given,
334342
) -> ParseHandleResponse:
335-
"""
336-
Convert uploaded file bytes into Markdown and optional HTML.
343+
"""Convert uploaded file bytes into Markdown and optional HTML.
344+
345+
WARC and WARC.GZ
346+
archives combine HTTP response, resource, and conversion records in archive
347+
order. Revisit and segmented records are skipped. Decoded WARC content is
348+
limited to 50 MiB.
337349
338350
Args:
339351
client: Optional client identifier used for usage attribution.
340352
341353
extension: Optional file extension hint, such as pdf, docx, xlsx, pptx, html, json, csv,
342-
md, py, rtf, jpg, png, or txt.
354+
md, py, rtf, jpg, png, txt, warc, or warc.gz.
343355
344356
include_images: Include image references in Markdown output
345357

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ class ParseHandleParams(TypedDict, total=False):
1515
"""Optional client identifier used for usage attribution."""
1616

1717
extension: Literal[
18+
"warc",
19+
"warc.gz",
1820
"txt",
1921
"text",
2022
"md",
@@ -88,7 +90,7 @@ class ParseHandleParams(TypedDict, total=False):
8890
]
8991
"""
9092
Optional file extension hint, such as pdf, docx, xlsx, pptx, html, json, csv,
91-
md, py, rtf, jpg, png, or txt.
93+
md, py, rtf, jpg, png, txt, warc, or warc.gz.
9294
"""
9395

9496
include_images: Annotated[bool, PropertyInfo(alias="includeImages")]

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class ParseHandleResponse(BaseModel):
3232
"""Indicates success"""
3333

3434
type: Literal[
35+
"warc",
3536
"html",
3637
"xml",
3738
"json",

‎tests/api_resources/test_parse.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def test_method_handle_with_all_params(self, client: ContextDev) -> None:
3131
parse = client.parse.handle(
3232
body=b"Example data",
3333
client="x",
34-
extension="txt",
34+
extension="warc",
3535
include_images=True,
3636
include_links=True,
3737
include_numbered_pages=True,
@@ -93,7 +93,7 @@ async def test_method_handle_with_all_params(self, async_client: AsyncContextDev
9393
parse = await async_client.parse.handle(
9494
body=b"Example data",
9595
client="x",
96-
extension="txt",
96+
extension="warc",
9797
include_images=True,
9898
include_links=True,
9999
include_numbered_pages=True,

‎uv.lock‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)