Skip to content

Commit bc9e1c2

Browse files
fix(api): Make beta headers optional in /v1beta/extract
1 parent d656151 commit bc9e1c2

File tree

4 files changed

+29
-23
lines changed

4 files changed

+29
-23
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 13
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/parallel-web%2Fparallel-sdk-de8ef7fc6a3509bf74c63258ebd4c110fc0c7669ebdbeaf7c8adcbf359f43a56.yml
3-
openapi_spec_hash: a7fd6467be3ff6c3037d29e87c172260
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/parallel-web%2Fparallel-sdk-77649b8f6d46525bfb9fe6d0ec115b1c639d41fffae2a513fa8e9fe5d700f069.yml
3+
openapi_spec_hash: 9e34db58728d2541dc23144262a66a71
44
config_hash: 677d555754b79eb922f6bf64bccd9559

src/parallel/resources/beta/beta.py

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@ def extract(
7878
self,
7979
*,
8080
urls: SequenceNotStr[str],
81-
betas: List[ParallelBetaParam],
8281
excerpts: beta_extract_params.Excerpts | Omit = omit,
8382
fetch_policy: Optional[FetchPolicyParam] | Omit = omit,
8483
full_content: beta_extract_params.FullContent | Omit = omit,
8584
objective: Optional[str] | Omit = omit,
8685
search_queries: Optional[SequenceNotStr[str]] | Omit = omit,
86+
betas: List[ParallelBetaParam] | Omit = omit,
8787
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
8888
# The extra values given here take precedence over values defined on the client or passed to this method.
8989
extra_headers: Headers | None = None,
@@ -98,8 +98,6 @@ def extract(
9898
`search-extract-2025-10-10`.
9999
100100
Args:
101-
betas: Optional header to specify the beta version(s) to enable.
102-
103101
excerpts: Include excerpts from each URL relevant to the search objective and queries.
104102
Note that if neither objective nor search_queries is provided, excerpts are
105103
redundant with full content.
@@ -117,6 +115,8 @@ def extract(
117115
118116
search_queries: If provided, focuses extracted content on the specified keyword search queries.
119117
118+
betas: Optional header to specify the beta version(s) to enable.
119+
120120
extra_headers: Send extra headers
121121
122122
extra_query: Add additional query parameters to the request
@@ -126,10 +126,16 @@ def extract(
126126
timeout: Override the client-level default timeout for this request, in seconds
127127
"""
128128
extra_headers = {
129-
"parallel-beta": ",".join(chain((str(e) for e in betas), ["search-extract-2025-10-10"])),
129+
**strip_not_given(
130+
{
131+
"parallel-beta": ",".join(chain((str(e) for e in betas), ["search-extract-2025-10-10"]))
132+
if is_given(betas)
133+
else not_given
134+
}
135+
),
130136
**(extra_headers or {}),
131137
}
132-
extra_headers.update({"parallel-beta": "search-extract-2025-10-10"})
138+
extra_headers = {"parallel-beta": "search-extract-2025-10-10", **(extra_headers or {})}
133139
return self._post(
134140
"/v1beta/extract",
135141
body=maybe_transform(
@@ -284,12 +290,12 @@ async def extract(
284290
self,
285291
*,
286292
urls: SequenceNotStr[str],
287-
betas: List[ParallelBetaParam],
288293
excerpts: beta_extract_params.Excerpts | Omit = omit,
289294
fetch_policy: Optional[FetchPolicyParam] | Omit = omit,
290295
full_content: beta_extract_params.FullContent | Omit = omit,
291296
objective: Optional[str] | Omit = omit,
292297
search_queries: Optional[SequenceNotStr[str]] | Omit = omit,
298+
betas: List[ParallelBetaParam] | Omit = omit,
293299
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
294300
# The extra values given here take precedence over values defined on the client or passed to this method.
295301
extra_headers: Headers | None = None,
@@ -304,8 +310,6 @@ async def extract(
304310
`search-extract-2025-10-10`.
305311
306312
Args:
307-
betas: Optional header to specify the beta version(s) to enable.
308-
309313
excerpts: Include excerpts from each URL relevant to the search objective and queries.
310314
Note that if neither objective nor search_queries is provided, excerpts are
311315
redundant with full content.
@@ -323,6 +327,8 @@ async def extract(
323327
324328
search_queries: If provided, focuses extracted content on the specified keyword search queries.
325329
330+
betas: Optional header to specify the beta version(s) to enable.
331+
326332
extra_headers: Send extra headers
327333
328334
extra_query: Add additional query parameters to the request
@@ -332,10 +338,16 @@ async def extract(
332338
timeout: Override the client-level default timeout for this request, in seconds
333339
"""
334340
extra_headers = {
335-
"parallel-beta": ",".join(chain((str(e) for e in betas), ["search-extract-2025-10-10"])),
341+
**strip_not_given(
342+
{
343+
"parallel-beta": ",".join(chain((str(e) for e in betas), ["search-extract-2025-10-10"]))
344+
if is_given(betas)
345+
else not_given
346+
}
347+
),
336348
**(extra_headers or {}),
337349
}
338-
extra_headers.update({"parallel-beta": "search-extract-2025-10-10"})
350+
extra_headers = {"parallel-beta": "search-extract-2025-10-10", **(extra_headers or {})}
339351
return await self._post(
340352
"/v1beta/extract",
341353
body=await async_maybe_transform(

src/parallel/types/beta/beta_extract_params.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717
class BetaExtractParams(TypedDict, total=False):
1818
urls: Required[SequenceNotStr[str]]
1919

20-
betas: Required[Annotated[List[ParallelBetaParam], PropertyInfo(alias="parallel-beta")]]
21-
"""Optional header to specify the beta version(s) to enable."""
22-
2320
excerpts: Excerpts
2421
"""Include excerpts from each URL relevant to the search objective and queries.
2522
@@ -48,6 +45,9 @@ class BetaExtractParams(TypedDict, total=False):
4845
search_queries: Optional[SequenceNotStr[str]]
4946
"""If provided, focuses extracted content on the specified keyword search queries."""
5047

48+
betas: Annotated[List[ParallelBetaParam], PropertyInfo(alias="parallel-beta")]
49+
"""Optional header to specify the beta version(s) to enable."""
50+
5151

5252
Excerpts: TypeAlias = Union[bool, ExcerptSettingsParam]
5353

tests/api_resources/test_beta.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,13 @@ class TestBeta:
2424
def test_method_extract(self, client: Parallel) -> None:
2525
beta = client.beta.extract(
2626
urls=["string"],
27-
betas=["mcp-server-2025-07-17"],
2827
)
2928
assert_matches_type(ExtractResponse, beta, path=["response"])
3029

3130
@parametrize
3231
def test_method_extract_with_all_params(self, client: Parallel) -> None:
3332
beta = client.beta.extract(
3433
urls=["string"],
35-
betas=["mcp-server-2025-07-17"],
3634
excerpts=True,
3735
fetch_policy={
3836
"disable_cache_fallback": True,
@@ -42,14 +40,14 @@ def test_method_extract_with_all_params(self, client: Parallel) -> None:
4240
full_content=True,
4341
objective="objective",
4442
search_queries=["string"],
43+
betas=["mcp-server-2025-07-17"],
4544
)
4645
assert_matches_type(ExtractResponse, beta, path=["response"])
4746

4847
@parametrize
4948
def test_raw_response_extract(self, client: Parallel) -> None:
5049
response = client.beta.with_raw_response.extract(
5150
urls=["string"],
52-
betas=["mcp-server-2025-07-17"],
5351
)
5452

5553
assert response.is_closed is True
@@ -61,7 +59,6 @@ def test_raw_response_extract(self, client: Parallel) -> None:
6159
def test_streaming_response_extract(self, client: Parallel) -> None:
6260
with client.beta.with_streaming_response.extract(
6361
urls=["string"],
64-
betas=["mcp-server-2025-07-17"],
6562
) as response:
6663
assert not response.is_closed
6764
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -129,15 +126,13 @@ class TestAsyncBeta:
129126
async def test_method_extract(self, async_client: AsyncParallel) -> None:
130127
beta = await async_client.beta.extract(
131128
urls=["string"],
132-
betas=["mcp-server-2025-07-17"],
133129
)
134130
assert_matches_type(ExtractResponse, beta, path=["response"])
135131

136132
@parametrize
137133
async def test_method_extract_with_all_params(self, async_client: AsyncParallel) -> None:
138134
beta = await async_client.beta.extract(
139135
urls=["string"],
140-
betas=["mcp-server-2025-07-17"],
141136
excerpts=True,
142137
fetch_policy={
143138
"disable_cache_fallback": True,
@@ -147,14 +142,14 @@ async def test_method_extract_with_all_params(self, async_client: AsyncParallel)
147142
full_content=True,
148143
objective="objective",
149144
search_queries=["string"],
145+
betas=["mcp-server-2025-07-17"],
150146
)
151147
assert_matches_type(ExtractResponse, beta, path=["response"])
152148

153149
@parametrize
154150
async def test_raw_response_extract(self, async_client: AsyncParallel) -> None:
155151
response = await async_client.beta.with_raw_response.extract(
156152
urls=["string"],
157-
betas=["mcp-server-2025-07-17"],
158153
)
159154

160155
assert response.is_closed is True
@@ -166,7 +161,6 @@ async def test_raw_response_extract(self, async_client: AsyncParallel) -> None:
166161
async def test_streaming_response_extract(self, async_client: AsyncParallel) -> None:
167162
async with async_client.beta.with_streaming_response.extract(
168163
urls=["string"],
169-
betas=["mcp-server-2025-07-17"],
170164
) as response:
171165
assert not response.is_closed
172166
assert response.http_request.headers.get("X-Stainless-Lang") == "python"

0 commit comments

Comments
 (0)