Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Pass `extraction` to attach page content to each result. Two modes:
```python
import os
from youdotcom import You
from youdotcom.models import Extraction, ExtractionMode
from youdotcom.models import Extraction, ExtractionFormat, ExtractionMode

with You(api_key_auth=os.getenv("YDC_API_KEY"), timeout_ms=60_000) as you:
# Query-relevant excerpts in `contents.highlights` (snippets are omitted).
Expand All @@ -121,18 +121,20 @@ with You(api_key_auth=os.getenv("YDC_API_KEY"), timeout_ms=60_000) as you:
# Full HTML and/or Markdown in `contents.html` / `contents.markdown`.
res = you.search(
query="latest quantum computing breakthroughs",
extraction={
"extraction_mode": "full_page",
"full_page": {"extraction_formats": ["markdown"]},
},
extraction=Extraction(
extraction_mode=ExtractionMode.FULL_PAGE,
full_page={"extraction_formats": [ExtractionFormat.MARKDOWN]},
),
)
```

`extraction` replaces the deprecated `livecrawl` / `livecrawl_formats`
parameters. Passing both raises `ValueError`, and top-level `crawl_timeout`
is ignored (stripped from the request body) when `extraction_mode == "highlights"`.
Unknown keys inside
`extraction` raise `ValidationError` locally, matching the server's 422.
You can also pass a dict matching `ExtractionTypedDict` — the SDK
normalizes at the method layer. `extraction` replaces the deprecated
Comment on lines +131 to +132

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Fix misleading “normalizes” claim for ExtractionTypedDict

The README currently says the SDK “normalizes at the method layer”, but the implementation validates via Extraction.model_validate(...) and does not perform casing normalization, so dict inputs must use the exact enum value spellings (e.g., "full_page", "markdown") or enums or callers will hit a ValidationError.

Suggested change
You can also pass a dict matching `ExtractionTypedDict` — the SDK
normalizes at the method layer. `extraction` replaces the deprecated
You can also pass a dict matching `ExtractionTypedDict` — the SDK
validates it via Pydantic (strings must match the enum values). `extraction` replaces the deprecated

`livecrawl` / `livecrawl_formats` parameters. Passing both raises
`ValueError`, and top-level `crawl_timeout` is ignored (stripped from
the request body) when `extraction_mode == "highlights"`. Unknown keys
inside `extraction` raise `ValidationError` locally, matching the
server's 422.

### Contents

Expand Down
11 changes: 6 additions & 5 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ asyncio.run(main())
```python
# Attach full Markdown content to each result via the new `extraction` parameter.
import os
from youdotcom import You, models
from youdotcom import You
from youdotcom.models import Extraction, ExtractionFormat, ExtractionMode


with You(
Expand All @@ -68,10 +69,10 @@ with You(

res = you.search(
query="latest quantum computing breakthroughs",
extraction={
"extraction_mode": "full_page",
"full_page": {"extraction_formats": ["markdown"]},
},
extraction=Extraction(
extraction_mode=ExtractionMode.FULL_PAGE,
full_page={"extraction_formats": [ExtractionFormat.MARKDOWN]},
),
)

for hit in res.results.web or []:
Expand Down
13 changes: 8 additions & 5 deletions docs/models/extraction.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The `extraction` parameter on `POST /v1/search` controls how page content is att
```python
import os
from youdotcom import You
from youdotcom.models import Extraction, ExtractionMode
from youdotcom.models import Extraction, ExtractionFormat, ExtractionMode

with You(api_key_auth=os.getenv("YDC_API_KEY"), timeout_ms=60_000) as you:
# Query-relevant excerpts in contents.highlights
Expand All @@ -24,13 +24,16 @@ with You(api_key_auth=os.getenv("YDC_API_KEY"), timeout_ms=60_000) as you:
# Full Markdown in contents.markdown
res = you.search(
query="latest quantum computing breakthroughs",
extraction={
"extraction_mode": "full_page",
"full_page": {"extraction_formats": ["markdown"]},
},
extraction=Extraction(
extraction_mode=ExtractionMode.FULL_PAGE,
full_page={"extraction_formats": [ExtractionFormat.MARKDOWN]},
),
)
```

You can also pass a dict matching `ExtractionTypedDict`; the SDK
normalizes at the method layer.

## Fields

| Field | Type | Required | Description |
Expand Down
Loading