Skip to content

Commit 5e090db

Browse files
feat(api): api update
1 parent 3503b7b commit 5e090db

18 files changed

Lines changed: 163 additions & 351 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: 29
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-fa5c7cd62da1c7cb2eddf8c6bb1f32ca7f958be5c3c315ade6ca0a669814d75a.yml
3-
openapi_spec_hash: 8358c1a467ab971afd59d615d1e731ee
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-b075e5704110b3c03bd81b41f62b836d7624eceed7feb0ac63720dec9a4cbba4.yml
3+
openapi_spec_hash: 5efb926e6e99163e3e42a98986da8335
44
config_hash: ff35e224e809656528c44163aa41bebd

src/Monitors/MonitorCreateParams/ChangeDetection/MonitorsSemanticChangeDetection.php

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
use ContextDev\Core\Contracts\BaseModel;
1111

1212
/**
13-
* Detect meaning-level changes that match a natural language query.
13+
* Detect meaning-level changes to the extracted data, ignoring cosmetic or paraphrase-only differences. What is watched is determined by the extract target's `schema` and `instructions`.
1414
*
1515
* @phpstan-type MonitorsSemanticChangeDetectionShape = array{
16-
* query: string, type: 'semantic', confidenceThreshold?: float|null
16+
* type: 'semantic', confidenceThreshold?: float|null
1717
* }
1818
*/
1919
final class MonitorsSemanticChangeDetection implements BaseModel
@@ -25,26 +25,9 @@ final class MonitorsSemanticChangeDetection implements BaseModel
2525
#[Required]
2626
public string $type = 'semantic';
2727

28-
#[Required]
29-
public string $query;
30-
3128
#[Optional('confidence_threshold')]
3229
public ?float $confidenceThreshold;
3330

34-
/**
35-
* `new MonitorsSemanticChangeDetection()` is missing required properties by the API.
36-
*
37-
* To enforce required parameters use
38-
* ```
39-
* MonitorsSemanticChangeDetection::with(query: ...)
40-
* ```
41-
*
42-
* Otherwise ensure the following setters are called
43-
*
44-
* ```
45-
* (new MonitorsSemanticChangeDetection)->withQuery(...)
46-
* ```
47-
*/
4831
public function __construct()
4932
{
5033
$this->initialize();
@@ -55,27 +38,15 @@ public function __construct()
5538
*
5639
* You must use named parameters to construct any parameters with a default value.
5740
*/
58-
public static function with(
59-
string $query,
60-
?float $confidenceThreshold = null
61-
): self {
41+
public static function with(?float $confidenceThreshold = null): self
42+
{
6243
$self = new self;
6344

64-
$self['query'] = $query;
65-
6645
null !== $confidenceThreshold && $self['confidenceThreshold'] = $confidenceThreshold;
6746

6847
return $self;
6948
}
7049

71-
public function withQuery(string $query): self
72-
{
73-
$self = clone $this;
74-
$self['query'] = $query;
75-
76-
return $self;
77-
}
78-
7950
/**
8051
* @param 'semantic' $type
8152
*/

src/Monitors/MonitorCreateParams/Target/MonitorsExtractTarget.php

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
* Watch a site's extracted structured data.
1414
*
1515
* @phpstan-type MonitorsExtractTargetShape = array{
16+
* instructions: string,
1617
* type: 'extract',
1718
* url: string,
1819
* followSubdomains?: bool|null,
19-
* instructions?: string|null,
2020
* maxDepth?: int|null,
2121
* maxPages?: int|null,
2222
* schema?: array<string,mixed>|null,
@@ -31,6 +31,12 @@ final class MonitorsExtractTarget implements BaseModel
3131
#[Required]
3232
public string $type = 'extract';
3333

34+
/**
35+
* Natural-language instructions describing what to extract and watch. This single prompt scopes both the extraction and what changes get reported: only data captured by the schema and these instructions is compared between runs.
36+
*/
37+
#[Required]
38+
public string $instructions;
39+
3440
/**
3541
* Root URL to extract structured data from.
3642
*/
@@ -40,12 +46,6 @@ final class MonitorsExtractTarget implements BaseModel
4046
#[Optional('follow_subdomains')]
4147
public ?bool $followSubdomains;
4248

43-
/**
44-
* Optional natural-language instructions guiding what to extract.
45-
*/
46-
#[Optional]
47-
public ?string $instructions;
48-
4949
/**
5050
* Optional maximum link depth from the starting URL (0 = only the starting page).
5151
*/
@@ -71,13 +71,13 @@ final class MonitorsExtractTarget implements BaseModel
7171
*
7272
* To enforce required parameters use
7373
* ```
74-
* MonitorsExtractTarget::with(url: ...)
74+
* MonitorsExtractTarget::with(instructions: ..., url: ...)
7575
* ```
7676
*
7777
* Otherwise ensure the following setters are called
7878
*
7979
* ```
80-
* (new MonitorsExtractTarget)->withURL(...)
80+
* (new MonitorsExtractTarget)->withInstructions(...)->withURL(...)
8181
* ```
8282
*/
8383
public function __construct()
@@ -93,26 +93,37 @@ public function __construct()
9393
* @param array<string,mixed>|null $schema
9494
*/
9595
public static function with(
96+
string $instructions,
9697
string $url,
9798
?bool $followSubdomains = null,
98-
?string $instructions = null,
9999
?int $maxDepth = null,
100100
?int $maxPages = null,
101101
?array $schema = null,
102102
): self {
103103
$self = new self;
104104

105+
$self['instructions'] = $instructions;
105106
$self['url'] = $url;
106107

107108
null !== $followSubdomains && $self['followSubdomains'] = $followSubdomains;
108-
null !== $instructions && $self['instructions'] = $instructions;
109109
null !== $maxDepth && $self['maxDepth'] = $maxDepth;
110110
null !== $maxPages && $self['maxPages'] = $maxPages;
111111
null !== $schema && $self['schema'] = $schema;
112112

113113
return $self;
114114
}
115115

116+
/**
117+
* Natural-language instructions describing what to extract and watch. This single prompt scopes both the extraction and what changes get reported: only data captured by the schema and these instructions is compared between runs.
118+
*/
119+
public function withInstructions(string $instructions): self
120+
{
121+
$self = clone $this;
122+
$self['instructions'] = $instructions;
123+
124+
return $self;
125+
}
126+
116127
/**
117128
* @param 'extract' $type
118129
*/
@@ -143,17 +154,6 @@ public function withFollowSubdomains(bool $followSubdomains): self
143154
return $self;
144155
}
145156

146-
/**
147-
* Optional natural-language instructions guiding what to extract.
148-
*/
149-
public function withInstructions(string $instructions): self
150-
{
151-
$self = clone $this;
152-
$self['instructions'] = $instructions;
153-
154-
return $self;
155-
}
156-
157157
/**
158158
* Optional maximum link depth from the starting URL (0 = only the starting page).
159159
*/

src/Monitors/MonitorGetChangeResponse.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
* importance?: null|Importance|value-of<Importance>,
4141
* matchedURLCount?: int|null,
4242
* matchedURLs?: list<string>|null,
43-
* query?: string|null,
4443
* removedURLCount?: int|null,
4544
* removedURLs?: list<string>|null,
4645
* tags?: list<string>|null,
@@ -136,9 +135,6 @@ final class MonitorGetChangeResponse implements BaseModel
136135
#[Optional('matched_urls', list: 'string')]
137136
public ?array $matchedURLs;
138137

139-
#[Optional]
140-
public ?string $query;
141-
142138
#[Optional('removed_url_count')]
143139
public ?int $removedURLCount;
144140

@@ -234,7 +230,6 @@ public static function with(
234230
Importance|string|null $importance = null,
235231
?int $matchedURLCount = null,
236232
?array $matchedURLs = null,
237-
?string $query = null,
238233
?int $removedURLCount = null,
239234
?array $removedURLs = null,
240235
?array $tags = null,
@@ -262,7 +257,6 @@ public static function with(
262257
null !== $importance && $self['importance'] = $importance;
263258
null !== $matchedURLCount && $self['matchedURLCount'] = $matchedURLCount;
264259
null !== $matchedURLs && $self['matchedURLs'] = $matchedURLs;
265-
null !== $query && $self['query'] = $query;
266260
null !== $removedURLCount && $self['removedURLCount'] = $removedURLCount;
267261
null !== $removedURLs && $self['removedURLs'] = $removedURLs;
268262
null !== $tags && $self['tags'] = $tags;
@@ -464,14 +458,6 @@ public function withMatchedURLs(array $matchedURLs): self
464458
return $self;
465459
}
466460

467-
public function withQuery(string $query): self
468-
{
469-
$self = clone $this;
470-
$self['query'] = $query;
471-
472-
return $self;
473-
}
474-
475461
public function withRemovedURLCount(int $removedURLCount): self
476462
{
477463
$self = clone $this;

src/Monitors/MonitorGetResponse/ChangeDetection/MonitorsSemanticChangeDetection.php

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
use ContextDev\Core\Contracts\BaseModel;
1111

1212
/**
13-
* Detect meaning-level changes that match a natural language query.
13+
* Detect meaning-level changes to the extracted data, ignoring cosmetic or paraphrase-only differences. What is watched is determined by the extract target's `schema` and `instructions`.
1414
*
1515
* @phpstan-type MonitorsSemanticChangeDetectionShape = array{
16-
* query: string, type: 'semantic', confidenceThreshold?: float|null
16+
* type: 'semantic', confidenceThreshold?: float|null
1717
* }
1818
*/
1919
final class MonitorsSemanticChangeDetection implements BaseModel
@@ -25,26 +25,9 @@ final class MonitorsSemanticChangeDetection implements BaseModel
2525
#[Required]
2626
public string $type = 'semantic';
2727

28-
#[Required]
29-
public string $query;
30-
3128
#[Optional('confidence_threshold')]
3229
public ?float $confidenceThreshold;
3330

34-
/**
35-
* `new MonitorsSemanticChangeDetection()` is missing required properties by the API.
36-
*
37-
* To enforce required parameters use
38-
* ```
39-
* MonitorsSemanticChangeDetection::with(query: ...)
40-
* ```
41-
*
42-
* Otherwise ensure the following setters are called
43-
*
44-
* ```
45-
* (new MonitorsSemanticChangeDetection)->withQuery(...)
46-
* ```
47-
*/
4831
public function __construct()
4932
{
5033
$this->initialize();
@@ -55,27 +38,15 @@ public function __construct()
5538
*
5639
* You must use named parameters to construct any parameters with a default value.
5740
*/
58-
public static function with(
59-
string $query,
60-
?float $confidenceThreshold = null
61-
): self {
41+
public static function with(?float $confidenceThreshold = null): self
42+
{
6243
$self = new self;
6344

64-
$self['query'] = $query;
65-
6645
null !== $confidenceThreshold && $self['confidenceThreshold'] = $confidenceThreshold;
6746

6847
return $self;
6948
}
7049

71-
public function withQuery(string $query): self
72-
{
73-
$self = clone $this;
74-
$self['query'] = $query;
75-
76-
return $self;
77-
}
78-
7950
/**
8051
* @param 'semantic' $type
8152
*/

0 commit comments

Comments
 (0)