-
Notifications
You must be signed in to change notification settings - Fork 1
Python SDK 3.1.2: lazy imports, attribution header, SSE forward-compat, answer safesearch #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -91,4 +91,38 @@ The `extraction` parameter replaces the deprecated `livecrawl` / | |||||||||||||
| Unknown keys inside `extraction` raise `ValidationError` locally, and passing | ||||||||||||||
| `extraction` together with `livecrawl` / `livecrawl_formats` raises | ||||||||||||||
| `ValueError` — both mirror the server's 422 contract so callers fail-fast. | ||||||||||||||
| <!-- End SDK Example Usage [extraction] --> | ||||||||||||||
| <!-- End SDK Example Usage [extraction] --> | ||||||||||||||
|
|
||||||||||||||
| <!-- Start SDK Example Usage [attribution] --> | ||||||||||||||
| ```python | ||||||||||||||
| # Tag every outbound request with a caller-identity header so the | ||||||||||||||
| # analytics layer can split SDK traffic from MCP traffic. | ||||||||||||||
| import os | ||||||||||||||
| from youdotcom import You | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
| with You( | ||||||||||||||
| api_key_auth=os.getenv("YDC_API_KEY"), | ||||||||||||||
| app_name="acme-bot", | ||||||||||||||
| app_version="2.4.0", | ||||||||||||||
| app_title="Acme Bot", | ||||||||||||||
| app_url="https://acme.example", | ||||||||||||||
| timeout_ms=60_000, | ||||||||||||||
| ) as you: | ||||||||||||||
|
|
||||||||||||||
| res = you.search(query="What did OpenAI announce this week?") | ||||||||||||||
|
|
||||||||||||||
| # Handle response | ||||||||||||||
| print(res) | ||||||||||||||
| ``` | ||||||||||||||
|
|
||||||||||||||
| `X-Client-Info` sent on the wire: | ||||||||||||||
|
|
||||||||||||||
| ``` | ||||||||||||||
| sdk; client=acme-bot/2.4.0; title=Acme Bot; url=https://acme.example; ua=python/<V> httpx/<V> | ||||||||||||||
| ``` | ||||||||||||||
|
|
||||||||||||||
| `app_name`, `app_version`, `app_title` and `app_url` are all optional. When | ||||||||||||||
| omitted, those segments are dropped entirely. Values must be printable ASCII (excluding `;`); invalid | ||||||||||||||
| values raise `ValueError` at construction time. | ||||||||||||||
|
Comment on lines
+125
to
+127
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P1] Document the The attribution example says values must exclude only
Suggested change
|
||||||||||||||
| <!-- End SDK Example Usage [attribution] --> | ||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P1] Update MIGRATION streaming guidance for open-enum SSE
MIGRATION.md now states unknown SSE event names no longer raise
ResponseValidationErroras of 3.1.2, but the later “Note on streaming” still claimsyou.stream_research_task()validates against a fixedEventenum and will raise on intermediate events; please update or qualify that note so the docs match the new open-enum behavior and do not steer users away fromstream_research_taskfor a problem that is now fixed.