Skip to content

Commit 034da97

Browse files
committed
docs(sdk): clarify default PDF page cap
1 parent 5215bc5 commit 034da97

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ res = sgai.extract(
140140
Search the web and optionally extract structured data.
141141

142142
```python
143-
from scrapegraph_py import PdfProcessor, ScrapeGraphAI
143+
from scrapegraph_py import ScrapeGraphAI
144144

145145
sgai = ScrapeGraphAI()
146146

@@ -153,13 +153,13 @@ res = sgai.search(
153153
time_range="past_week", # optional
154154
location_geo_code="us", # optional
155155
allowed_types=["text/html", "application/pdf"], # optional MIME allowlist
156-
processors=[PdfProcessor(max_pages=10)], # optional PDF page cap
157156
)
158157
```
159158

160159
By default `search` accepts every supported content type, including PDFs, and processes up to 25
161-
pages per PDF. Use `allowed_types` to restrict accepted MIME types. Configure PDF processing
162-
separately with `processors`; `max_pages` accepts `1``500`, or `-1` for no page limit.
160+
pages per PDF. You do not need to send `processors` or `max_pages` for this default. Use
161+
`allowed_types` to restrict accepted MIME types. Only configure `processors` to override the cap;
162+
`PdfProcessor()` also defaults to 25, while `max_pages` accepts `1``500`, or `-1` for no page limit.
163163

164164
### crawl
165165

tests/test_schemas.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@ def test_documented_pdf_configuration(request_model, base):
2929
]
3030

3131

32+
@pytest.mark.parametrize(("request_model", "base"), REQUESTS)
33+
def test_default_pdf_cap_can_be_omitted(request_model, base):
34+
request = request_model(**base)
35+
assert "processors" not in request.model_dump(by_alias=True, mode="json", exclude_none=True)
36+
37+
request = request_model(**base, processors=[{"type": "pdf"}])
38+
assert request.model_dump(by_alias=True, mode="json", exclude_none=True)["processors"] == [
39+
{"type": "pdf", "maxPages": 25}
40+
]
41+
42+
3243
@pytest.mark.parametrize(("request_model", "base"), REQUESTS)
3344
@pytest.mark.parametrize(
3445
"invalid",

0 commit comments

Comments
 (0)