|
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 _api_client as genai_api_client |
| 28 | +from google.genai import version as genai_version |
26 | 29 | from . import live |
27 | 30 |
|
28 | 31 | if TYPE_CHECKING: |
@@ -208,21 +211,25 @@ def __init__( |
208 | 211 | if http_options.headers is None: |
209 | 212 | http_options.headers = {} |
210 | 213 |
|
211 | | - tracking_label = f"{_GENAI_MODULES_TELEMETRY_HEADER}/{aip_version.__version__}" |
| 214 | + genai_sdk_version = genai_version.__version__ |
| 215 | + module_version = aip_version.__version__ |
| 216 | + python_version = sys.version.split()[0] |
| 217 | + |
| 218 | + agent_platform_header = f"google-genai-sdk/{genai_sdk_version}+{_GENAI_MODULES_TELEMETRY_HEADER}/{module_version} gl-python/{python_version}" |
212 | 219 |
|
213 | 220 | if "user-agent" in http_options.headers: |
214 | 221 | http_options.headers["user-agent"] = ( |
215 | | - f"{http_options.headers['user-agent']} {tracking_label}" |
| 222 | + f"{agent_platform_header} " + http_options.headers["user-agent"] |
216 | 223 | ) |
217 | 224 | else: |
218 | | - http_options.headers["user-agent"] = tracking_label |
| 225 | + http_options.headers["user-agent"] = agent_platform_header |
219 | 226 |
|
220 | 227 | if "x-goog-api-client" in http_options.headers: |
221 | 228 | http_options.headers["x-goog-api-client"] = ( |
222 | | - f"{http_options.headers['x-goog-api-client']} {tracking_label}" |
| 229 | + f"{agent_platform_header} " + http_options.headers["x-goog-api-client"] |
223 | 230 | ) |
224 | 231 | else: |
225 | | - http_options.headers["x-goog-api-client"] = tracking_label |
| 232 | + http_options.headers["x-goog-api-client"] = agent_platform_header |
226 | 233 |
|
227 | 234 | self._api_client = genai_client.Client._get_api_client( |
228 | 235 | vertexai=True, |
|
0 commit comments