Skip to content

Commit f836718

Browse files
sararobcopybara-github
authored andcommitted
feat: Upgrade google-genai dependency required version to >=2.0.0
PiperOrigin-RevId: 908716648
1 parent 1f9c8e0 commit f836718

8 files changed

Lines changed: 28 additions & 13 deletions

File tree

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,7 @@
326326
"google-cloud-storage >= 3.10.0, < 4.0.0; python_version>='3.13'",
327327
"google-cloud-bigquery >= 1.15.0, < 4.0.0, !=3.20.0",
328328
"google-cloud-resource-manager >= 1.3.3, < 3.0.0",
329-
"google-genai >= 1.37.0, <2.0.0; python_version<'3.10'",
330-
"google-genai >= 1.66.0, <2.0.0; python_version>='3.10'",
329+
"google-genai >= 2.0.0, < 3.0.0",
331330
)
332331
+ genai_requires,
333332
extras_require={

testing/constraints-3.10.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# This constraints file is required for unit tests.
33
# List all library dependencies and extras in this file.
44
google-api-core==2.21.0 # Tests google-api-core with rest async support
5-
google-auth==2.47.0 # Tests google-auth with rest async support
5+
google-auth==2.49.0 # Updated to satisfy google-genai 2.0.0 requirement
66
proto-plus==1.22.3
77
protobuf
88
mock==4.0.2

testing/constraints-3.11.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# This constraints file is required for unit tests.
33
# List all library dependencies and extras in this file.
44
google-api-core==2.21.0 # Tests google-api-core with rest async support
5-
google-auth==2.47.0 # Tests google-auth with rest async support
5+
google-auth==2.49.0 # Updated to satisfy google-genai 2.0.0 requirement
66
proto-plus
77
protobuf
88
mock==4.0.2

testing/constraints-3.12.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# This constraints file is required for unit tests.
33
# List all library dependencies and extras in this file.
44
google-api-core==2.21.0 # Tests google-api-core with rest async support
5-
google-auth==2.47.0 # Tests google-auth with rest async support
5+
google-auth==2.49.0 # Updated to satisfy google-genai 2.0.0 requirement
66
proto-plus
77
mock==4.0.2
88
google-cloud-storage==3.0.0 # Updated to v3.x, backward compatible with v2.x via wrapper

testing/constraints-3.13.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# This constraints file is required for unit tests.
33
# List all library dependencies and extras in this file.
44
google-api-core==2.27.0 # Tests google-api-core with rest async support
5-
google-auth==2.47.0 # Tests google-auth with rest async support
5+
google-auth==2.49.0 # Updated to satisfy google-genai 2.0.0 requirement
66
proto-plus
77
mock==4.0.2
88
google-cloud-storage==3.10.0 # Updated to v3.x, backward compatible with v2.x via wrapper

testing/constraints-3.14.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# This constraints file is required for unit tests.
33
# List all library dependencies and extras in this file.
44
google-api-core==2.27.0
5-
google-auth==2.47.0 # Tests google-auth with rest async support
5+
google-auth==2.49.0 # Updated to satisfy google-genai 2.0.0 requirement
66
proto-plus
77
mock==4.0.2
88
google-cloud-storage==3.10.0 # Updated for Python 3.14 compatibility

tests/unit/vertexai/genai/replays/conftest.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"""Conftest for Vertex SDK GenAI tests."""
1818

1919
import os
20+
import sys
2021
from unittest import mock
2122

2223
from vertexai._genai import (
@@ -31,6 +32,7 @@
3132
from google.genai import _replay_api_client
3233
from google.genai import types as genai_types
3334
from google.genai import client as google_genai_client_module
35+
from google.genai import version as genai_version
3436
from vertexai._genai import _gcs_utils
3537
from vertexai._genai import prompt_optimizer
3638
import pytest
@@ -260,12 +262,20 @@ def client(use_vertex, replays_prefix, http_options, request):
260262
)
261263
os.environ["GOOGLE_GENAI_REPLAYS_DIRECTORY"] = replays_root_directory
262264

265+
genai_sdk_version = genai_version.__version__
266+
module_version = aip_version.__version__
267+
python_version = sys.version.split()[0]
268+
269+
tracking_label = (
270+
f"google-genai-sdk/{genai_sdk_version}+{_GENAI_MODULES_TELEMETRY_HEADER}/"
271+
f"{module_version} gl-python/{python_version}"
272+
)
273+
263274
if http_options is None:
264275
http_options = genai_types.HttpOptions()
265276
if http_options.headers is None:
266277
http_options.headers = {}
267278

268-
tracking_label = f"{_GENAI_MODULES_TELEMETRY_HEADER}/{aip_version.__version__}"
269279
http_options.headers["user-agent"] = tracking_label
270280
http_options.headers["x-goog-api-client"] = tracking_label
271281

vertexai/_genai/client.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import asyncio
1717
import importlib
18+
import sys
1819
from typing import Optional, Union, TYPE_CHECKING
1920
from types import TracebackType, ModuleType
2021

@@ -23,6 +24,7 @@
2324
from google.genai import _common
2425
from google.genai import client as genai_client
2526
from google.genai import types
27+
from google.genai import version as genai_version
2628
from . import live
2729

2830
if TYPE_CHECKING:
@@ -219,21 +221,25 @@ def __init__(
219221
if http_options.headers is None:
220222
http_options.headers = {}
221223

222-
tracking_label = f"{_GENAI_MODULES_TELEMETRY_HEADER}/{aip_version.__version__}"
224+
genai_sdk_version = genai_version.__version__
225+
module_version = aip_version.__version__
226+
python_version = sys.version.split()[0]
227+
228+
agent_platform_header = f"google-genai-sdk/{genai_sdk_version}+{_GENAI_MODULES_TELEMETRY_HEADER}/{module_version} gl-python/{python_version}"
223229

224230
if "user-agent" in http_options.headers:
225231
http_options.headers["user-agent"] = (
226-
f"{http_options.headers['user-agent']} {tracking_label}"
232+
f"{agent_platform_header} " + http_options.headers["user-agent"]
227233
)
228234
else:
229-
http_options.headers["user-agent"] = tracking_label
235+
http_options.headers["user-agent"] = agent_platform_header
230236

231237
if "x-goog-api-client" in http_options.headers:
232238
http_options.headers["x-goog-api-client"] = (
233-
f"{http_options.headers['x-goog-api-client']} {tracking_label}"
239+
f"{agent_platform_header} " + http_options.headers["x-goog-api-client"]
234240
)
235241
else:
236-
http_options.headers["x-goog-api-client"] = tracking_label
242+
http_options.headers["x-goog-api-client"] = agent_platform_header
237243

238244
self._api_client = genai_client.Client._get_api_client(
239245
vertexai=True,

0 commit comments

Comments
 (0)