|
15 | 15 |
|
16 | 16 | import asyncio |
17 | 17 | import importlib |
| 18 | +import sys |
18 | 19 | from typing import Optional, Union, TYPE_CHECKING |
19 | 20 | from types import TracebackType, ModuleType |
20 | 21 |
|
|
23 | 24 | from google.genai import _common |
24 | 25 | from google.genai import client as genai_client |
25 | 26 | from google.genai import types |
| 27 | +from google.genai import version as genai_version |
26 | 28 | from . import live |
27 | 29 |
|
28 | 30 | if TYPE_CHECKING: |
@@ -219,21 +221,25 @@ def __init__( |
219 | 221 | if http_options.headers is None: |
220 | 222 | http_options.headers = {} |
221 | 223 |
|
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}" |
223 | 229 |
|
224 | 230 | if "user-agent" in http_options.headers: |
225 | 231 | http_options.headers["user-agent"] = ( |
226 | | - f"{http_options.headers['user-agent']} {tracking_label}" |
| 232 | + f"{agent_platform_header} " + http_options.headers["user-agent"] |
227 | 233 | ) |
228 | 234 | else: |
229 | | - http_options.headers["user-agent"] = tracking_label |
| 235 | + http_options.headers["user-agent"] = agent_platform_header |
230 | 236 |
|
231 | 237 | if "x-goog-api-client" in http_options.headers: |
232 | 238 | 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"] |
234 | 240 | ) |
235 | 241 | else: |
236 | | - http_options.headers["x-goog-api-client"] = tracking_label |
| 242 | + http_options.headers["x-goog-api-client"] = agent_platform_header |
237 | 243 |
|
238 | 244 | self._api_client = genai_client.Client._get_api_client( |
239 | 245 | vertexai=True, |
|
0 commit comments