chore: Replace proxy methods with utils implementation

PiperOrigin-RevId: 864773118
This commit is contained in:
Google Team Member
2026-02-03 02:27:46 -08:00
committed by Copybara-Service
parent 33012e6dda
commit f82ceb0ce7
2 changed files with 6 additions and 12 deletions
+2 -1
View File
@@ -25,6 +25,7 @@ from google.adk import version as adk_version
from google.genai import types from google.genai import types
from typing_extensions import override from typing_extensions import override
from ..utils._google_client_headers import merge_tracking_headers
from ..utils.env_utils import is_env_enabled from ..utils.env_utils import is_env_enabled
from .google_llm import Gemini from .google_llm import Gemini
@@ -145,7 +146,7 @@ class ApigeeLlm(Gemini):
kwargs_for_http_options['api_version'] = self._api_version kwargs_for_http_options['api_version'] = self._api_version
http_options = types.HttpOptions( http_options = types.HttpOptions(
base_url=self._proxy_url, base_url=self._proxy_url,
headers=self._merge_tracking_headers(self._custom_headers), headers=merge_tracking_headers(self._custom_headers),
retry_options=self.retry_options, retry_options=self.retry_options,
**kwargs_for_http_options, **kwargs_for_http_options,
) )
+4 -11
View File
@@ -192,7 +192,7 @@ class Gemini(BaseLlm):
if llm_request.config: if llm_request.config:
if not llm_request.config.http_options: if not llm_request.config.http_options:
llm_request.config.http_options = types.HttpOptions() llm_request.config.http_options = types.HttpOptions()
llm_request.config.http_options.headers = self._merge_tracking_headers( llm_request.config.http_options.headers = merge_tracking_headers(
llm_request.config.http_options.headers llm_request.config.http_options.headers
) )
@@ -303,7 +303,7 @@ class Gemini(BaseLlm):
return Client( return Client(
http_options=types.HttpOptions( http_options=types.HttpOptions(
headers=self._tracking_headers(), headers=get_tracking_headers(),
retry_options=self.retry_options, retry_options=self.retry_options,
) )
) )
@@ -316,9 +316,6 @@ class Gemini(BaseLlm):
else GoogleLLMVariant.GEMINI_API else GoogleLLMVariant.GEMINI_API
) )
def _tracking_headers(self) -> dict[str, str]:
return get_tracking_headers()
@cached_property @cached_property
def _live_api_version(self) -> str: def _live_api_version(self) -> str:
if self._api_backend == GoogleLLMVariant.VERTEX_AI: if self._api_backend == GoogleLLMVariant.VERTEX_AI:
@@ -334,7 +331,7 @@ class Gemini(BaseLlm):
return Client( return Client(
http_options=types.HttpOptions( http_options=types.HttpOptions(
headers=self._tracking_headers(), api_version=self._live_api_version headers=get_tracking_headers(), api_version=self._live_api_version
) )
) )
@@ -358,7 +355,7 @@ class Gemini(BaseLlm):
if not llm_request.live_connect_config.http_options.headers: if not llm_request.live_connect_config.http_options.headers:
llm_request.live_connect_config.http_options.headers = {} llm_request.live_connect_config.http_options.headers = {}
llm_request.live_connect_config.http_options.headers = ( llm_request.live_connect_config.http_options.headers = (
self._merge_tracking_headers( merge_tracking_headers(
llm_request.live_connect_config.http_options.headers llm_request.live_connect_config.http_options.headers
) )
) )
@@ -451,10 +448,6 @@ class Gemini(BaseLlm):
llm_request.config.system_instruction = None llm_request.config.system_instruction = None
await self._adapt_computer_use_tool(llm_request) await self._adapt_computer_use_tool(llm_request)
def _merge_tracking_headers(self, headers: dict[str, str]) -> dict[str, str]:
"""Merge tracking headers to the given headers."""
return merge_tracking_headers(headers)
def _build_function_declaration_log( def _build_function_declaration_log(
func_decl: types.FunctionDeclaration, func_decl: types.FunctionDeclaration,