Skip to content

Commit b6570c0

Browse files
feat(api): api update
1 parent 61d8ed4 commit b6570c0

6 files changed

Lines changed: 29 additions & 2 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 36
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-171b4c39eb26210aad8afd74d63d620bf45f7e0b7f2de3938c7239741ea3f2f4.yml
3-
openapi_spec_hash: 752c05fc817dc766061bd4357bd327ba
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-633097a61ae4e029434e5af07efa3017301fe8b391c27ada3eb68b61d798ef33.yml
3+
openapi_spec_hash: 051b08a4c6530546d520aa7ec18f8123
44
config_hash: 7ec4851ee8d93177947e95df5ae897b5

src/ServiceContracts/WebContract.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ public function webScrapeHTML(
290290
* @api
291291
*
292292
* @param string $url Page URL to inspect. Must include http:// or https://.
293+
* @param bool $dedupe When true, visually duplicate images are removed: every image is loaded and perceptually hashed, and only the highest-resolution copy of each duplicate group is kept. Images that cannot be downloaded or hashed are kept. Default: false.
293294
* @param Enrichment|EnrichmentShape $enrichment optional per-image processing, sent as deep-object query params such as enrichment[resolution]=true
294295
* @param array<string,string> $headers Optional outbound HTTP headers forwarded only to the target URL, sent as deep-object query params such as headers[X-Custom]=value. When provided, caching is bypassed: the result is neither read from nor written to cache.
295296
* @param int $maxAgeMs Reuse a cached result this many milliseconds old or newer. Default: 86400000 (1 day). Set to 0 to bypass cache. Maximum: 2592000000 (30 days).
@@ -301,6 +302,7 @@ public function webScrapeHTML(
301302
*/
302303
public function webScrapeImages(
303304
string $url,
305+
bool $dedupe = false,
304306
Enrichment|array|null $enrichment = null,
305307
?array $headers = null,
306308
int $maxAgeMs = 86400000,

src/Services/WebRawService.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,7 @@ public function webScrapeHTML(
405405
*
406406
* @param array{
407407
* url: string,
408+
* dedupe?: bool,
408409
* enrichment?: Enrichment|EnrichmentShape,
409410
* headers?: array<string,string>,
410411
* maxAgeMs?: int,

src/Services/WebService.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ public function webScrapeHTML(
481481
* Extract image assets from a web page, including standard URLs, inline SVGs, data URIs, responsive image sources, metadata, CSS backgrounds, video posters, and embeds. The base request costs 1 credit. When enrichment is enabled, the entire call costs 5 credits.
482482
*
483483
* @param string $url Page URL to inspect. Must include http:// or https://.
484+
* @param bool $dedupe When true, visually duplicate images are removed: every image is loaded and perceptually hashed, and only the highest-resolution copy of each duplicate group is kept. Images that cannot be downloaded or hashed are kept. Default: false.
484485
* @param Enrichment|EnrichmentShape $enrichment optional per-image processing, sent as deep-object query params such as enrichment[resolution]=true
485486
* @param array<string,string> $headers Optional outbound HTTP headers forwarded only to the target URL, sent as deep-object query params such as headers[X-Custom]=value. When provided, caching is bypassed: the result is neither read from nor written to cache.
486487
* @param int $maxAgeMs Reuse a cached result this many milliseconds old or newer. Default: 86400000 (1 day). Set to 0 to bypass cache. Maximum: 2592000000 (30 days).
@@ -492,6 +493,7 @@ public function webScrapeHTML(
492493
*/
493494
public function webScrapeImages(
494495
string $url,
496+
bool $dedupe = false,
495497
Enrichment|array|null $enrichment = null,
496498
?array $headers = null,
497499
int $maxAgeMs = 86400000,
@@ -502,6 +504,7 @@ public function webScrapeImages(
502504
$params = Util::removeNulls(
503505
[
504506
'url' => $url,
507+
'dedupe' => $dedupe,
505508
'enrichment' => $enrichment,
506509
'headers' => $headers,
507510
'maxAgeMs' => $maxAgeMs,

src/Web/WebWebScrapeImagesParams.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
*
2121
* @phpstan-type WebWebScrapeImagesParamsShape = array{
2222
* url: string,
23+
* dedupe?: bool|null,
2324
* enrichment?: null|Enrichment|EnrichmentShape,
2425
* headers?: array<string,string>|null,
2526
* maxAgeMs?: int|null,
@@ -39,6 +40,12 @@ final class WebWebScrapeImagesParams implements BaseModel
3940
#[Required]
4041
public string $url;
4142

43+
/**
44+
* When true, visually duplicate images are removed: every image is loaded and perceptually hashed, and only the highest-resolution copy of each duplicate group is kept. Images that cannot be downloaded or hashed are kept. Default: false.
45+
*/
46+
#[Optional]
47+
public ?bool $dedupe;
48+
4249
/**
4350
* Optional per-image processing, sent as deep-object query params such as enrichment[resolution]=true.
4451
*/
@@ -100,6 +107,7 @@ public function __construct()
100107
*/
101108
public static function with(
102109
string $url,
110+
?bool $dedupe = null,
103111
Enrichment|array|null $enrichment = null,
104112
?array $headers = null,
105113
?int $maxAgeMs = null,
@@ -110,6 +118,7 @@ public static function with(
110118

111119
$self['url'] = $url;
112120

121+
null !== $dedupe && $self['dedupe'] = $dedupe;
113122
null !== $enrichment && $self['enrichment'] = $enrichment;
114123
null !== $headers && $self['headers'] = $headers;
115124
null !== $maxAgeMs && $self['maxAgeMs'] = $maxAgeMs;
@@ -130,6 +139,17 @@ public function withURL(string $url): self
130139
return $self;
131140
}
132141

142+
/**
143+
* When true, visually duplicate images are removed: every image is loaded and perceptually hashed, and only the highest-resolution copy of each duplicate group is kept. Images that cannot be downloaded or hashed are kept. Default: false.
144+
*/
145+
public function withDedupe(bool $dedupe): self
146+
{
147+
$self = clone $this;
148+
$self['dedupe'] = $dedupe;
149+
150+
return $self;
151+
}
152+
133153
/**
134154
* Optional per-image processing, sent as deep-object query params such as enrichment[resolution]=true.
135155
*

tests/Services/WebTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ public function testWebScrapeImagesWithOptionalParams(): void
314314

315315
$result = $this->client->web->webScrapeImages(
316316
url: 'https://example.com',
317+
dedupe: true,
317318
enrichment: [
318319
'classification' => true,
319320
'hostedURL' => true,

0 commit comments

Comments
 (0)