You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit d4ad692
Browse filesBrowse the repository at this point in the historyBrowse files
stlc-bot
committed
feat(scrape): add product extraction format to POST /web/scrape (#1212)
* @param int $maxAgeMs Maximum age of each cached output. Defaults to 1 day; 0 fetches fresh and updates the requested outputs. Compatible outputs are shared with the individual scrape endpoints. Image results with hosted files refresh after 23 hours; other outputs retain their own freshness.
171
173
* @param ParseParams|ParseParamsShape $parseParams Required when formats.parse is true.
* @phpstan-import-type JsonParamsShape from \ContextDev\Web\WebScrapeParams\JsonParams
58
59
* @phpstan-import-type MarkdownParamsShape from \ContextDev\Web\WebScrapeParams\MarkdownParams
59
60
* @phpstan-import-type ParseParamsShape from \ContextDev\Web\WebScrapeParams\ParseParams
61
+
* @phpstan-import-type ProductParamsShape from \ContextDev\Web\WebScrapeParams\ProductParams
60
62
* @phpstan-import-type ScreenshotParamsShape from \ContextDev\Web\WebScrapeParams\ScreenshotParams
61
63
* @phpstan-import-type SharedParamsShape from \ContextDev\Web\WebScrapeParams\SharedParams
62
64
* @phpstan-import-type TimeoutOptsShape from \ContextDev\Web\WebScrapeParams\TimeoutOpts as TimeoutOptsShape4
@@ -238,7 +240,7 @@ public function mapUrls(
238
240
/**
239
241
* @api
240
242
*
241
-
* Reuse cached outputs independently and capture missing formats in one page visit. Each cache key includes only the settings that affect that output. HTML is shared with Markdown, parsed fields, highlights, and JSON extraction. Cached outputs can come from different visits within maxAgeMs; use 0 for a fresh capture. HTML-only requests use the existing fast acquisition path. Highlights return the plain-text passages most relevant to highlightsParams.query. One credit per request, including cache hits and missing pages, or two with browser actions; highlights add 3 credits when passages are returned; JSON extraction adds four credits and runs an LLM over the page Markdown on every request that has text to extract; PDF OCR adds one credit per recovered page on fresh extraction. Original response bytes and screenshots are limited to 20 MiB each, screenshots to 40 megapixels, and the combined browser capture to 60 MiB.
243
+
* Reuse cached outputs independently and capture missing formats in one page visit. Each cache key includes only the settings that affect that output. HTML is shared with Markdown, parsed fields, product data, highlights, and JSON extraction. Cached outputs can come from different visits within maxAgeMs; use 0 for a fresh capture. HTML-only requests use the existing fast acquisition path. Highlights return the plain-text passages most relevant to highlightsParams.query. One credit per request, including cache hits and missing pages, or two with browser actions; highlights add 3 credits when passages are returned; JSON extraction adds four credits and runs an LLM over the page Markdown on every request that has text to extract; PDF OCR adds one credit per recovered page on fresh extraction; the product output adds one credit, plus six more when the specialized model is used. Original response bytes and screenshots are limited to 20 MiB each, screenshots to 40 megapixels, and the combined browser capture to 60 MiB.
* @phpstan-import-type JsonParamsShape from \ContextDev\Web\WebScrapeParams\JsonParams
49
50
* @phpstan-import-type MarkdownParamsShape from \ContextDev\Web\WebScrapeParams\MarkdownParams
50
51
* @phpstan-import-type ParseParamsShape from \ContextDev\Web\WebScrapeParams\ParseParams
52
+
* @phpstan-import-type ProductParamsShape from \ContextDev\Web\WebScrapeParams\ProductParams
51
53
* @phpstan-import-type ScreenshotParamsShape from \ContextDev\Web\WebScrapeParams\ScreenshotParams
52
54
* @phpstan-import-type SharedParamsShape from \ContextDev\Web\WebScrapeParams\SharedParams
53
55
* @phpstan-import-type TimeoutOptsShape from \ContextDev\Web\WebScrapeParams\TimeoutOpts as TimeoutOptsShape4
@@ -253,7 +255,7 @@ public function mapUrls(
253
255
/**
254
256
* @api
255
257
*
256
-
* Reuse cached outputs independently and capture missing formats in one page visit. Each cache key includes only the settings that affect that output. HTML is shared with Markdown, parsed fields, highlights, and JSON extraction. Cached outputs can come from different visits within maxAgeMs; use 0 for a fresh capture. HTML-only requests use the existing fast acquisition path. Highlights return the plain-text passages most relevant to highlightsParams.query. One credit per request, including cache hits and missing pages, or two with browser actions; highlights add 3 credits when passages are returned; JSON extraction adds four credits and runs an LLM over the page Markdown on every request that has text to extract; PDF OCR adds one credit per recovered page on fresh extraction. Original response bytes and screenshots are limited to 20 MiB each, screenshots to 40 megapixels, and the combined browser capture to 60 MiB.
258
+
* Reuse cached outputs independently and capture missing formats in one page visit. Each cache key includes only the settings that affect that output. HTML is shared with Markdown, parsed fields, product data, highlights, and JSON extraction. Cached outputs can come from different visits within maxAgeMs; use 0 for a fresh capture. HTML-only requests use the existing fast acquisition path. Highlights return the plain-text passages most relevant to highlightsParams.query. One credit per request, including cache hits and missing pages, or two with browser actions; highlights add 3 credits when passages are returned; JSON extraction adds four credits and runs an LLM over the page Markdown on every request that has text to extract; PDF OCR adds one credit per recovered page on fresh extraction; the product output adds one credit, plus six more when the specialized model is used. Original response bytes and screenshots are limited to 20 MiB each, screenshots to 40 megapixels, and the combined browser capture to 60 MiB.
257
259
*
258
260
* @param Formats|FormatsShape $formats Outputs to return. Enable at least one; omitted formats are false.
* @param int $maxAgeMs Maximum age of each cached output. Defaults to 1 day; 0 fetches fresh and updates the requested outputs. Compatible outputs are shared with the individual scrape endpoints. Image results with hosted files refresh after 23 hours; other outputs retain their own freshness.
265
267
* @param ParseParams|ParseParamsShape $parseParams Required when formats.parse is true.
* Reuse cached outputs independently and capture missing formats in one page visit. Each cache key includes only the settings that affect that output. HTML is shared with Markdown, parsed fields, highlights, and JSON extraction. Cached outputs can come from different visits within maxAgeMs; use 0 for a fresh capture. HTML-only requests use the existing fast acquisition path. Highlights return the plain-text passages most relevant to highlightsParams.query. One credit per request, including cache hits and missing pages, or two with browser actions; highlights add 3 credits when passages are returned; JSON extraction adds four credits and runs an LLM over the page Markdown on every request that has text to extract; PDF OCR adds one credit per recovered page on fresh extraction. Original response bytes and screenshots are limited to 20 MiB each, screenshots to 40 megapixels, and the combined browser capture to 60 MiB.
25
+
* Reuse cached outputs independently and capture missing formats in one page visit. Each cache key includes only the settings that affect that output. HTML is shared with Markdown, parsed fields, product data, highlights, and JSON extraction. Cached outputs can come from different visits within maxAgeMs; use 0 for a fresh capture. HTML-only requests use the existing fast acquisition path. Highlights return the plain-text passages most relevant to highlightsParams.query. One credit per request, including cache hits and missing pages, or two with browser actions; highlights add 3 credits when passages are returned; JSON extraction adds four credits and runs an LLM over the page Markdown on every request that has text to extract; PDF OCR adds one credit per recovered page on fresh extraction; the product output adds one credit, plus six more when the specialized model is used. Original response bytes and screenshots are limited to 20 MiB each, screenshots to 40 megapixels, and the combined browser capture to 60 MiB.
25
26
*
26
27
* @see ContextDev\Services\WebService::scrape()
27
28
*
@@ -31,6 +32,7 @@
31
32
* @phpstan-import-type JsonParamsShape from \ContextDev\Web\WebScrapeParams\JsonParams
32
33
* @phpstan-import-type MarkdownParamsShape from \ContextDev\Web\WebScrapeParams\MarkdownParams
33
34
* @phpstan-import-type ParseParamsShape from \ContextDev\Web\WebScrapeParams\ParseParams
35
+
* @phpstan-import-type ProductParamsShape from \ContextDev\Web\WebScrapeParams\ProductParams
34
36
* @phpstan-import-type ScreenshotParamsShape from \ContextDev\Web\WebScrapeParams\ScreenshotParams
35
37
* @phpstan-import-type SharedParamsShape from \ContextDev\Web\WebScrapeParams\SharedParams
36
38
* @phpstan-import-type TimeoutOptsShape from \ContextDev\Web\WebScrapeParams\TimeoutOpts
* Extract the product with a specialized model when the page has no structured product data. Adds six credits when the model returns a verdict. If the fallback fails, returns a partial response with the deterministic result and no fallback charge. Request deadlines and client disconnects still apply.
23
+
*/
24
+
#[Optional]
25
+
public ?bool$useAIFallback;
26
+
27
+
publicfunction__construct()
28
+
{
29
+
$this->initialize();
30
+
}
31
+
32
+
/**
33
+
* Construct an instance from the required parameters.
34
+
*
35
+
* You must use named parameters to construct any parameters with a default value.
* Extract the product with a specialized model when the page has no structured product data. Adds six credits when the model returns a verdict. If the fallback fails, returns a partial response with the deterministic result and no fallback charge. Request deadlines and client disconnects still apply.
0 commit comments