Skip to content

Commit f46396f

Browse files
DeanChensjcopybara-github
authored andcommitted
chore: Allow httpoptions override in VertexAiSessionService
PiperOrigin-RevId: 785886180
1 parent 13ff009 commit f46396f

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/google/adk/sessions/vertex_ai_session_service.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
# limitations under the License.
1414
from __future__ import annotations
1515

16-
import asyncio
1716
import json
1817
import logging
1918
import os
@@ -351,16 +350,24 @@ def _get_reasoning_engine_id(self, app_name: str):
351350

352351
return match.groups()[-1]
353352

353+
def _api_client_http_options_override(
354+
self,
355+
) -> Optional[genai.types.HttpOptions]:
356+
return None
357+
354358
def _get_api_client(self):
355359
"""Instantiates an API client for the given project and location.
356360
357361
It needs to be instantiated inside each request so that the event loop
358362
management can be properly propagated.
359363
"""
360-
client = genai.Client(
364+
api_client = genai.Client(
361365
vertexai=True, project=self._project, location=self._location
362-
)
363-
return client._api_client
366+
)._api_client
367+
368+
if new_options := self._api_client_http_options_override():
369+
api_client._http_options = new_options
370+
return api_client
364371

365372

366373
def _is_vertex_express_mode(

0 commit comments

Comments
 (0)