Skip to content

Commit e72452f

Browse files
authored
Bump google-genai to v1.50.1 and remove patches (#3340)
1 parent dec2611 commit e72452f

File tree

3 files changed

+8
-48
lines changed

3 files changed

+8
-48
lines changed

pydantic_ai_slim/pydantic_ai/providers/google.py

Lines changed: 3 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313

1414
try:
1515
from google.auth.credentials import Credentials
16-
from google.genai._api_client import BaseApiClient
17-
from google.genai.client import Client, DebugConfig
16+
from google.genai.client import Client
1817
from google.genai.types import HttpOptions
1918
except ImportError as _import_error:
2019
raise ImportError(
@@ -115,16 +114,14 @@ def __init__(
115114
base_url=base_url,
116115
headers={'User-Agent': get_user_agent()},
117116
httpx_async_client=http_client,
118-
# TODO: Remove once https://github.com/googleapis/python-genai/issues/1565 is solved.
119-
async_client_args={'transport': httpx.AsyncHTTPTransport()},
120117
)
121118
if not vertexai:
122119
if api_key is None:
123120
raise UserError(
124121
'Set the `GOOGLE_API_KEY` environment variable or pass it via `GoogleProvider(api_key=...)`'
125122
'to use the Google Generative Language API.'
126123
)
127-
self._client = _SafelyClosingClient(vertexai=False, api_key=api_key, http_options=http_options)
124+
self._client = Client(vertexai=False, api_key=api_key, http_options=http_options)
128125
else:
129126
if vertex_ai_args_used:
130127
api_key = None
@@ -138,7 +135,7 @@ def __init__(
138135
# For more details, check: https://cloud.google.com/vertex-ai/generative-ai/docs/learn/locations#available-regions
139136
location = location or os.getenv('GOOGLE_CLOUD_LOCATION') or 'us-central1'
140137

141-
self._client = _SafelyClosingClient(
138+
self._client = Client(
142139
vertexai=True,
143140
api_key=api_key,
144141
project=project,
@@ -184,40 +181,3 @@ def __init__(
184181
"""Regions available for Vertex AI.
185182
More details [here](https://cloud.google.com/vertex-ai/generative-ai/docs/learn/locations#genai-locations).
186183
"""
187-
188-
189-
class _SafelyClosingClient(Client):
190-
@staticmethod
191-
def _get_api_client(
192-
vertexai: bool | None = None,
193-
api_key: str | None = None,
194-
credentials: Credentials | None = None,
195-
project: str | None = None,
196-
location: str | None = None,
197-
debug_config: DebugConfig | None = None,
198-
http_options: HttpOptions | None = None,
199-
) -> BaseApiClient:
200-
return _NonClosingApiClient(
201-
vertexai=vertexai,
202-
api_key=api_key,
203-
credentials=credentials,
204-
project=project,
205-
location=location,
206-
http_options=http_options,
207-
)
208-
209-
def close(self) -> None:
210-
# This is called from `Client.__del__`, even if `Client.__init__` raised an error before `self._api_client` is set, which would raise an `AttributeError` here.
211-
# TODO: Remove once https://github.com/googleapis/python-genai/issues/1567 is solved.
212-
try:
213-
super().close()
214-
except AttributeError:
215-
pass
216-
217-
218-
class _NonClosingApiClient(BaseApiClient):
219-
async def aclose(self) -> None:
220-
# The original implementation also calls `await self._async_httpx_client.aclose()`, but we don't want to close our `cached_async_http_client` or the one the user passed in.
221-
# TODO: Remove once https://github.com/googleapis/python-genai/issues/1566 is solved.
222-
if self._aiohttp_session:
223-
await self._aiohttp_session.close() # pragma: no cover

pydantic_ai_slim/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ logfire = ["logfire[httpx]>=3.14.1"]
7070
openai = ["openai>=1.107.2"]
7171
cohere = ["cohere>=5.18.0; platform_system != 'Emscripten'"]
7272
vertexai = ["google-auth>=2.36.0", "requests>=2.32.2"]
73-
google = ["google-genai>=1.46.0"]
73+
google = ["google-genai>=1.50.1"]
7474
anthropic = ["anthropic>=0.70.0"]
7575
groq = ["groq>=0.25.0"]
7676
mistral = ["mistralai>=1.9.10"]

uv.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)