Skip to content

Commit 6052dc3

Browse files
hkt74copybara-github
authored andcommitted
chore: remove stainless headers
PiperOrigin-RevId: 877638624
1 parent 15666c0 commit 6052dc3

File tree

2 files changed

+5
-22
lines changed

2 files changed

+5
-22
lines changed

google/genai/_interactions/_base_client.py

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ def _make_status_error(
456456
) -> _exceptions.APIStatusError:
457457
raise NotImplementedError()
458458

459-
def _build_headers(self, options: FinalRequestOptions, *, retries_taken: int = 0) -> httpx.Headers:
459+
def _build_headers(self, options: FinalRequestOptions) -> httpx.Headers:
460460
custom_headers = options.headers or {}
461461
headers_dict = _merge_mappings(self.default_headers, custom_headers)
462462
self._validate_headers(headers_dict, custom_headers)
@@ -468,18 +468,6 @@ def _build_headers(self, options: FinalRequestOptions, *, retries_taken: int = 0
468468
if idempotency_header and options.idempotency_key and idempotency_header not in headers:
469469
headers[idempotency_header] = options.idempotency_key
470470

471-
# Don't set these headers if they were already set or removed by the caller. We check
472-
# `custom_headers`, which can contain `Omit()`, instead of `headers` to account for the removal case.
473-
lower_custom_headers = [header.lower() for header in custom_headers]
474-
if "x-stainless-retry-count" not in lower_custom_headers:
475-
headers["x-stainless-retry-count"] = str(retries_taken)
476-
if "x-stainless-read-timeout" not in lower_custom_headers:
477-
timeout = self.timeout if isinstance(options.timeout, NotGiven) else options.timeout
478-
if isinstance(timeout, Timeout):
479-
timeout = timeout.read
480-
if timeout is not None:
481-
headers["x-stainless-read-timeout"] = str(timeout)
482-
483471
return headers
484472

485473
def _prepare_url(self, url: str) -> URL:
@@ -501,8 +489,6 @@ def _make_sse_decoder(self) -> SSEDecoder | SSEBytesDecoder:
501489
def _build_request(
502490
self,
503491
options: FinalRequestOptions,
504-
*,
505-
retries_taken: int = 0,
506492
) -> httpx.Request:
507493
if log.isEnabledFor(logging.DEBUG):
508494
log.debug(
@@ -529,7 +515,7 @@ def _build_request(
529515
else:
530516
raise RuntimeError(f"Unexpected JSON data type, {type(json_data)}, cannot merge with `extra_body`")
531517

532-
headers = self._build_headers(options, retries_taken=retries_taken)
518+
headers = self._build_headers(options)
533519
params = _merge_mappings(self.default_query, options.params)
534520
content_type = headers.get("Content-Type")
535521
files = options.files
@@ -694,7 +680,6 @@ def default_headers(self) -> dict[str, str | Omit]:
694680
"Accept": "application/json",
695681
"Content-Type": "application/json",
696682
"User-Agent": self.user_agent,
697-
**self.platform_headers(),
698683
**self.auth_headers,
699684
**self._custom_headers,
700685
}
@@ -1010,7 +995,7 @@ def request(
1010995
options = self._prepare_options(options)
1011996

1012997
remaining_retries = max_retries - retries_taken
1013-
request = self._build_request(options, retries_taken=retries_taken)
998+
request = self._build_request(options)
1014999
self._prepare_request(request)
10151000

10161001
kwargs: HttpxSendArgs = {}
@@ -1594,7 +1579,7 @@ async def request(
15941579
options = await self._prepare_options(options)
15951580

15961581
remaining_retries = max_retries - retries_taken
1597-
request = self._build_request(options, retries_taken=retries_taken)
1582+
request = self._build_request(options)
15981583
await self._prepare_request(request)
15991584

16001585
kwargs: HttpxSendArgs = {}

google/genai/_interactions/_client.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
RequestOptions,
3636
not_given,
3737
)
38-
from ._utils import is_given, get_async_library
38+
from ._utils import is_given
3939
from ._compat import cached_property
4040
from ._models import FinalRequestOptions
4141
from ._version import __version__
@@ -159,7 +159,6 @@ def auth_headers(self) -> dict[str, str]:
159159
def default_headers(self) -> dict[str, str | Omit]:
160160
return {
161161
**super().default_headers,
162-
"X-Stainless-Async": "false",
163162
**self._custom_headers,
164163
}
165164

@@ -381,7 +380,6 @@ def auth_headers(self) -> dict[str, str]:
381380
def default_headers(self) -> dict[str, str | Omit]:
382381
return {
383382
**super().default_headers,
384-
"X-Stainless-Async": f"async:{get_async_library()}",
385383
**self._custom_headers,
386384
}
387385

0 commit comments

Comments
 (0)