chore: Allow httpoptions override in VertexAiSessionService

PiperOrigin-RevId: 785886180
This commit is contained in:
Shangjie Chen
2025-07-22 09:34:59 -07:00
committed by Copybara-Service
parent 13ff009d34
commit f46396fa98
@@ -13,7 +13,6 @@
# limitations under the License.
from __future__ import annotations
import asyncio
import json
import logging
import os
@@ -351,16 +350,24 @@ class VertexAiSessionService(BaseSessionService):
return match.groups()[-1]
def _api_client_http_options_override(
self,
) -> Optional[genai.types.HttpOptions]:
return None
def _get_api_client(self):
"""Instantiates an API client for the given project and location.
It needs to be instantiated inside each request so that the event loop
management can be properly propagated.
"""
client = genai.Client(
api_client = genai.Client(
vertexai=True, project=self._project, location=self._location
)
return client._api_client
)._api_client
if new_options := self._api_client_http_options_override():
api_client._http_options = new_options
return api_client
def _is_vertex_express_mode(