Skip to content

Commit c24a182

Browse files
feat(api): api update
1 parent 307b423 commit c24a182

5 files changed

Lines changed: 65 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: 22
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev%2Fcontext.dev-91dbd4c6ac7e59beea9c160c063dbcc54ab6375444833f1da0d38a3e6c182384.yml
3-
openapi_spec_hash: 5a827539bca2813c6d0d2bba2c3301a2
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev%2Fcontext.dev-d5ca4cac056c38a1cb69c6d9033abe0d2b4d5858ee9a76e1172b23649ab1cca6.yml
3+
openapi_spec_hash: 8e1dd204746bcfaaf637d93b1d339eb2
44
config_hash: 70354330f92ce169beabc98696ebb9a3

‎src/context/dev/resources/ai.py‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ def extract_product(
106106
self,
107107
*,
108108
url: str,
109+
max_age_ms: int | Omit = omit,
109110
timeout_ms: int | Omit = omit,
110111
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
111112
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -121,6 +122,10 @@ def extract_product(
121122
Args:
122123
url: The product page URL to extract product data from.
123124
125+
max_age_ms: Return a cached result if a prior scrape for the same parameters exists and is
126+
younger than this many milliseconds. Defaults to 7 days (604800000 ms) when
127+
omitted. Max is 30 days (2592000000 ms). Set to 0 to always scrape fresh.
128+
124129
timeout_ms: Optional timeout in milliseconds for the request. Maximum allowed value is
125130
300000ms (5 minutes).
126131
@@ -137,6 +142,7 @@ def extract_product(
137142
body=maybe_transform(
138143
{
139144
"url": url,
145+
"max_age_ms": max_age_ms,
140146
"timeout_ms": timeout_ms,
141147
},
142148
ai_extract_product_params.AIExtractProductParams,
@@ -152,6 +158,7 @@ def extract_products(
152158
self,
153159
*,
154160
domain: str,
161+
max_age_ms: int | Omit = omit,
155162
max_products: int | Omit = omit,
156163
timeout_ms: int | Omit = omit,
157164
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -170,6 +177,10 @@ def extract_products(
170177
Args:
171178
domain: The domain name to analyze.
172179
180+
max_age_ms: Return a cached result if a prior scrape for the same parameters exists and is
181+
younger than this many milliseconds. Defaults to 7 days (604800000 ms) when
182+
omitted. Max is 30 days (2592000000 ms). Set to 0 to always scrape fresh.
183+
173184
max_products: Maximum number of products to extract.
174185
175186
timeout_ms: Optional timeout in milliseconds for the request. Maximum allowed value is
@@ -190,6 +201,7 @@ def extract_products(
190201
self,
191202
*,
192203
direct_url: str,
204+
max_age_ms: int | Omit = omit,
193205
max_products: int | Omit = omit,
194206
timeout_ms: int | Omit = omit,
195207
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -209,6 +221,10 @@ def extract_products(
209221
direct_url: A specific URL to use directly as the starting point for extraction without
210222
domain resolution.
211223
224+
max_age_ms: Return a cached result if a prior scrape for the same parameters exists and is
225+
younger than this many milliseconds. Defaults to 7 days (604800000 ms) when
226+
omitted. Max is 30 days (2592000000 ms). Set to 0 to always scrape fresh.
227+
212228
max_products: Maximum number of products to extract.
213229
214230
timeout_ms: Optional timeout in milliseconds for the request. Maximum allowed value is
@@ -229,6 +245,7 @@ def extract_products(
229245
self,
230246
*,
231247
domain: str | Omit = omit,
248+
max_age_ms: int | Omit = omit,
232249
max_products: int | Omit = omit,
233250
timeout_ms: int | Omit = omit,
234251
direct_url: str | Omit = omit,
@@ -244,6 +261,7 @@ def extract_products(
244261
body=maybe_transform(
245262
{
246263
"domain": domain,
264+
"max_age_ms": max_age_ms,
247265
"max_products": max_products,
248266
"timeout_ms": timeout_ms,
249267
"direct_url": direct_url,
@@ -337,6 +355,7 @@ async def extract_product(
337355
self,
338356
*,
339357
url: str,
358+
max_age_ms: int | Omit = omit,
340359
timeout_ms: int | Omit = omit,
341360
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
342361
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -352,6 +371,10 @@ async def extract_product(
352371
Args:
353372
url: The product page URL to extract product data from.
354373
374+
max_age_ms: Return a cached result if a prior scrape for the same parameters exists and is
375+
younger than this many milliseconds. Defaults to 7 days (604800000 ms) when
376+
omitted. Max is 30 days (2592000000 ms). Set to 0 to always scrape fresh.
377+
355378
timeout_ms: Optional timeout in milliseconds for the request. Maximum allowed value is
356379
300000ms (5 minutes).
357380
@@ -368,6 +391,7 @@ async def extract_product(
368391
body=await async_maybe_transform(
369392
{
370393
"url": url,
394+
"max_age_ms": max_age_ms,
371395
"timeout_ms": timeout_ms,
372396
},
373397
ai_extract_product_params.AIExtractProductParams,
@@ -383,6 +407,7 @@ async def extract_products(
383407
self,
384408
*,
385409
domain: str,
410+
max_age_ms: int | Omit = omit,
386411
max_products: int | Omit = omit,
387412
timeout_ms: int | Omit = omit,
388413
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -401,6 +426,10 @@ async def extract_products(
401426
Args:
402427
domain: The domain name to analyze.
403428
429+
max_age_ms: Return a cached result if a prior scrape for the same parameters exists and is
430+
younger than this many milliseconds. Defaults to 7 days (604800000 ms) when
431+
omitted. Max is 30 days (2592000000 ms). Set to 0 to always scrape fresh.
432+
404433
max_products: Maximum number of products to extract.
405434
406435
timeout_ms: Optional timeout in milliseconds for the request. Maximum allowed value is
@@ -421,6 +450,7 @@ async def extract_products(
421450
self,
422451
*,
423452
direct_url: str,
453+
max_age_ms: int | Omit = omit,
424454
max_products: int | Omit = omit,
425455
timeout_ms: int | Omit = omit,
426456
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -440,6 +470,10 @@ async def extract_products(
440470
direct_url: A specific URL to use directly as the starting point for extraction without
441471
domain resolution.
442472
473+
max_age_ms: Return a cached result if a prior scrape for the same parameters exists and is
474+
younger than this many milliseconds. Defaults to 7 days (604800000 ms) when
475+
omitted. Max is 30 days (2592000000 ms). Set to 0 to always scrape fresh.
476+
443477
max_products: Maximum number of products to extract.
444478
445479
timeout_ms: Optional timeout in milliseconds for the request. Maximum allowed value is
@@ -460,6 +494,7 @@ async def extract_products(
460494
self,
461495
*,
462496
domain: str | Omit = omit,
497+
max_age_ms: int | Omit = omit,
463498
max_products: int | Omit = omit,
464499
timeout_ms: int | Omit = omit,
465500
direct_url: str | Omit = omit,
@@ -475,6 +510,7 @@ async def extract_products(
475510
body=await async_maybe_transform(
476511
{
477512
"domain": domain,
513+
"max_age_ms": max_age_ms,
478514
"max_products": max_products,
479515
"timeout_ms": timeout_ms,
480516
"direct_url": direct_url,

‎src/context/dev/types/ai_extract_product_params.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ class AIExtractProductParams(TypedDict, total=False):
1313
url: Required[str]
1414
"""The product page URL to extract product data from."""
1515

16+
max_age_ms: Annotated[int, PropertyInfo(alias="maxAgeMs")]
17+
"""
18+
Return a cached result if a prior scrape for the same parameters exists and is
19+
younger than this many milliseconds. Defaults to 7 days (604800000 ms) when
20+
omitted. Max is 30 days (2592000000 ms). Set to 0 to always scrape fresh.
21+
"""
22+
1623
timeout_ms: Annotated[int, PropertyInfo(alias="timeoutMS")]
1724
"""Optional timeout in milliseconds for the request.
1825

‎src/context/dev/types/ai_extract_products_params.py‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ class ByDomain(TypedDict, total=False):
1414
domain: Required[str]
1515
"""The domain name to analyze."""
1616

17+
max_age_ms: Annotated[int, PropertyInfo(alias="maxAgeMs")]
18+
"""
19+
Return a cached result if a prior scrape for the same parameters exists and is
20+
younger than this many milliseconds. Defaults to 7 days (604800000 ms) when
21+
omitted. Max is 30 days (2592000000 ms). Set to 0 to always scrape fresh.
22+
"""
23+
1724
max_products: Annotated[int, PropertyInfo(alias="maxProducts")]
1825
"""Maximum number of products to extract."""
1926

@@ -31,6 +38,13 @@ class ByDirectURL(TypedDict, total=False):
3138
domain resolution.
3239
"""
3340

41+
max_age_ms: Annotated[int, PropertyInfo(alias="maxAgeMs")]
42+
"""
43+
Return a cached result if a prior scrape for the same parameters exists and is
44+
younger than this many milliseconds. Defaults to 7 days (604800000 ms) when
45+
omitted. Max is 30 days (2592000000 ms). Set to 0 to always scrape fresh.
46+
"""
47+
3448
max_products: Annotated[int, PropertyInfo(alias="maxProducts")]
3549
"""Maximum number of products to extract."""
3650

‎tests/api_resources/test_ai.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ def test_method_extract_product(self, client: ContextDev) -> None:
125125
def test_method_extract_product_with_all_params(self, client: ContextDev) -> None:
126126
ai = client.ai.extract_product(
127127
url="https://example.com",
128+
max_age_ms=0,
128129
timeout_ms=1000,
129130
)
130131
assert_matches_type(AIExtractProductResponse, ai, path=["response"])
@@ -168,6 +169,7 @@ def test_method_extract_products_overload_1(self, client: ContextDev) -> None:
168169
def test_method_extract_products_with_all_params_overload_1(self, client: ContextDev) -> None:
169170
ai = client.ai.extract_products(
170171
domain="domain",
172+
max_age_ms=0,
171173
max_products=1,
172174
timeout_ms=1000,
173175
)
@@ -212,6 +214,7 @@ def test_method_extract_products_overload_2(self, client: ContextDev) -> None:
212214
def test_method_extract_products_with_all_params_overload_2(self, client: ContextDev) -> None:
213215
ai = client.ai.extract_products(
214216
direct_url="https://example.com",
217+
max_age_ms=0,
215218
max_products=1,
216219
timeout_ms=1000,
217220
)
@@ -353,6 +356,7 @@ async def test_method_extract_product(self, async_client: AsyncContextDev) -> No
353356
async def test_method_extract_product_with_all_params(self, async_client: AsyncContextDev) -> None:
354357
ai = await async_client.ai.extract_product(
355358
url="https://example.com",
359+
max_age_ms=0,
356360
timeout_ms=1000,
357361
)
358362
assert_matches_type(AIExtractProductResponse, ai, path=["response"])
@@ -396,6 +400,7 @@ async def test_method_extract_products_overload_1(self, async_client: AsyncConte
396400
async def test_method_extract_products_with_all_params_overload_1(self, async_client: AsyncContextDev) -> None:
397401
ai = await async_client.ai.extract_products(
398402
domain="domain",
403+
max_age_ms=0,
399404
max_products=1,
400405
timeout_ms=1000,
401406
)
@@ -440,6 +445,7 @@ async def test_method_extract_products_overload_2(self, async_client: AsyncConte
440445
async def test_method_extract_products_with_all_params_overload_2(self, async_client: AsyncContextDev) -> None:
441446
ai = await async_client.ai.extract_products(
442447
direct_url="https://example.com",
448+
max_age_ms=0,
443449
max_products=1,
444450
timeout_ms=1000,
445451
)

0 commit comments

Comments
 (0)