Skip to content

Commit 9926fba

Browse files
author
stlc-bot
committed
fix(api): guarantee search descriptions and align response types (#1089)
Stainless-Generated-From: fc09ddd
1 parent 3677eab commit 9926fba

3 files changed

Lines changed: 54 additions & 51 deletions

File tree

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

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
__all__ = [
99
"BrandRetrieveResponse",
10-
"CacheMetadata",
1110
"Brand",
1211
"BrandAddress",
1312
"BrandBackdrop",
@@ -23,26 +22,11 @@
2322
"BrandLogoResolution",
2423
"BrandSocial",
2524
"BrandStock",
25+
"CacheMetadata",
2626
"KeyMetadata",
2727
]
2828

2929

30-
class CacheMetadata(BaseModel):
31-
"""Cache outcome for this response.
32-
33-
Composite responses are hits only when every cache-controlled fetch contributing to the output was a hit; age_ms is the oldest contributing hit.
34-
"""
35-
36-
age_ms: int
37-
"""Age of the cached data in milliseconds. Zero for miss and zdr responses."""
38-
39-
status: Literal["hit", "miss", "zdr"]
40-
"""
41-
Whether the response was served from cache, required fresh work, or honored
42-
zero-data-retention cache bypass.
43-
"""
44-
45-
4630
class BrandAddress(BaseModel):
4731
"""Physical address of the brand"""
4832

@@ -693,6 +677,22 @@ class Brand(BaseModel):
693677
"""The title or name of the brand"""
694678

695679

680+
class CacheMetadata(BaseModel):
681+
"""Cache outcome for this response.
682+
683+
Composite responses are hits only when every cache-controlled fetch contributing to the output was a hit; age_ms is the oldest contributing hit.
684+
"""
685+
686+
age_ms: int
687+
"""Age of the cached data in milliseconds. Zero for miss and zdr responses."""
688+
689+
status: Literal["hit", "miss", "zdr"]
690+
"""
691+
Whether the response was served from cache, required fresh work, or honored
692+
zero-data-retention cache bypass.
693+
"""
694+
695+
696696
class KeyMetadata(BaseModel):
697697
"""Credit usage, included whenever a valid API key is provided."""
698698

@@ -704,24 +704,27 @@ class KeyMetadata(BaseModel):
704704

705705

706706
class BrandRetrieveResponse(BaseModel):
707+
brand: Brand
708+
"""Detailed brand information"""
709+
707710
cache_metadata: CacheMetadata
708711
"""Cache outcome for this response.
709712
710713
Composite responses are hits only when every cache-controlled fetch contributing
711714
to the output was a hit; age_ms is the oldest contributing hit.
712715
"""
713716

717+
code: int
718+
"""HTTP status code"""
719+
714720
request_id: str
715721
"""Unique id of this API call, also sent in the X-Request-Id response header.
716722
717723
Quote it when contacting support about a failed request.
718724
"""
719725

720-
brand: Optional[Brand] = None
721-
"""Detailed brand information"""
722-
723-
code: Optional[int] = None
724-
"""HTTP status code"""
726+
status: str
727+
"""Status of the response, e.g., 'ok'"""
725728

726729
key_metadata: Optional[KeyMetadata] = None
727730
"""Credit usage, included whenever a valid API key is provided."""
@@ -731,6 +734,3 @@ class BrandRetrieveResponse(BaseModel):
731734
True when the timeout ended processing and this response contains the usable
732735
data completed so far. Unfinished fields are omitted.
733736
"""
734-
735-
status: Optional[str] = None
736-
"""Status of the response, e.g., 'ok'"""

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

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
__all__ = [
99
"BrandRetrieveSimplifiedResponse",
10-
"CacheMetadata",
1110
"Brand",
1211
"BrandBackdrop",
1312
"BrandBackdropColor",
@@ -16,26 +15,11 @@
1615
"BrandLogo",
1716
"BrandLogoColor",
1817
"BrandLogoResolution",
18+
"CacheMetadata",
1919
"KeyMetadata",
2020
]
2121

2222

23-
class CacheMetadata(BaseModel):
24-
"""Cache outcome for this response.
25-
26-
Composite responses are hits only when every cache-controlled fetch contributing to the output was a hit; age_ms is the oldest contributing hit.
27-
"""
28-
29-
age_ms: int
30-
"""Age of the cached data in milliseconds. Zero for miss and zdr responses."""
31-
32-
status: Literal["hit", "miss", "zdr"]
33-
"""
34-
Whether the response was served from cache, required fresh work, or honored
35-
zero-data-retention cache bypass.
36-
"""
37-
38-
3923
class BrandBackdropColor(BaseModel):
4024
hex: Optional[str] = None
4125
"""Color in hexadecimal format"""
@@ -144,6 +128,22 @@ class Brand(BaseModel):
144128
"""The title or name of the brand"""
145129

146130

131+
class CacheMetadata(BaseModel):
132+
"""Cache outcome for this response.
133+
134+
Composite responses are hits only when every cache-controlled fetch contributing to the output was a hit; age_ms is the oldest contributing hit.
135+
"""
136+
137+
age_ms: int
138+
"""Age of the cached data in milliseconds. Zero for miss and zdr responses."""
139+
140+
status: Literal["hit", "miss", "zdr"]
141+
"""
142+
Whether the response was served from cache, required fresh work, or honored
143+
zero-data-retention cache bypass.
144+
"""
145+
146+
147147
class KeyMetadata(BaseModel):
148148
"""Credit usage, included whenever a valid API key is provided."""
149149

@@ -155,24 +155,27 @@ class KeyMetadata(BaseModel):
155155

156156

157157
class BrandRetrieveSimplifiedResponse(BaseModel):
158+
brand: Brand
159+
"""Simplified brand information"""
160+
158161
cache_metadata: CacheMetadata
159162
"""Cache outcome for this response.
160163
161164
Composite responses are hits only when every cache-controlled fetch contributing
162165
to the output was a hit; age_ms is the oldest contributing hit.
163166
"""
164167

168+
code: int
169+
"""HTTP status code of the response"""
170+
165171
request_id: str
166172
"""Unique id of this API call, also sent in the X-Request-Id response header.
167173
168174
Quote it when contacting support about a failed request.
169175
"""
170176

171-
brand: Optional[Brand] = None
172-
"""Simplified brand information"""
173-
174-
code: Optional[int] = None
175-
"""HTTP status code of the response"""
177+
status: str
178+
"""Status of the response, e.g., 'ok'"""
176179

177180
key_metadata: Optional[KeyMetadata] = None
178181
"""Credit usage, included whenever a valid API key is provided."""
@@ -182,6 +185,3 @@ class BrandRetrieveSimplifiedResponse(BaseModel):
182185
True when the timeout ended processing and only completed brand data is
183186
returned.
184187
"""
185-
186-
status: Optional[str] = None
187-
"""Status of the response, e.g., 'ok'"""

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ class ResultMarkdown(BaseModel):
5151

5252
class Result(BaseModel):
5353
description: str
54-
"""Snippet excerpt from the page."""
54+
"""Snippet excerpt from the page.
55+
56+
Empty string when the search provider does not supply a snippet.
57+
"""
5558

5659
markdown: ResultMarkdown
5760
"""Markdown scrape status and content for this result."""

0 commit comments

Comments
 (0)