google-genai 1.13.0__py3-none-any.whl → 1.15.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- google/genai/_api_client.py +80 -34
- google/genai/_automatic_function_calling_util.py +1 -1
- google/genai/_live_converters.py +334 -14
- google/genai/caches.py +304 -6
- google/genai/models.py +415 -12
- google/genai/tunings.py +53 -0
- google/genai/types.py +622 -118
- google/genai/version.py +1 -1
- {google_genai-1.13.0.dist-info → google_genai-1.15.0.dist-info}/METADATA +106 -19
- {google_genai-1.13.0.dist-info → google_genai-1.15.0.dist-info}/RECORD +13 -13
- {google_genai-1.13.0.dist-info → google_genai-1.15.0.dist-info}/WHEEL +1 -1
- {google_genai-1.13.0.dist-info → google_genai-1.15.0.dist-info}/licenses/LICENSE +0 -0
- {google_genai-1.13.0.dist-info → google_genai-1.15.0.dist-info}/top_level.txt +0 -0
google/genai/_api_client.py
CHANGED
@@ -32,6 +32,7 @@ import math
|
|
32
32
|
import os
|
33
33
|
import ssl
|
34
34
|
import sys
|
35
|
+
import threading
|
35
36
|
import time
|
36
37
|
from typing import Any, AsyncIterator, Optional, Tuple, Union
|
37
38
|
from urllib.parse import urlparse
|
@@ -58,7 +59,9 @@ from .types import HttpOptionsOrDict
|
|
58
59
|
|
59
60
|
logger = logging.getLogger('google_genai._api_client')
|
60
61
|
CHUNK_SIZE = 8 * 1024 * 1024 # 8 MB chunk size
|
61
|
-
|
62
|
+
MAX_RETRY_COUNT = 3
|
63
|
+
INITIAL_RETRY_DELAY = 1 # second
|
64
|
+
DELAY_MULTIPLIER = 2
|
62
65
|
|
63
66
|
def _append_library_version_headers(headers: dict[str, str]) -> None:
|
64
67
|
"""Appends the telemetry header to the headers dict."""
|
@@ -283,6 +286,18 @@ class SyncHttpxClient(httpx.Client):
|
|
283
286
|
kwargs.setdefault('follow_redirects', True)
|
284
287
|
super().__init__(**kwargs)
|
285
288
|
|
289
|
+
def __del__(self) -> None:
|
290
|
+
"""Closes the httpx client."""
|
291
|
+
try:
|
292
|
+
if self.is_closed:
|
293
|
+
return
|
294
|
+
except Exception:
|
295
|
+
pass
|
296
|
+
try:
|
297
|
+
self.close()
|
298
|
+
except Exception:
|
299
|
+
pass
|
300
|
+
|
286
301
|
|
287
302
|
class AsyncHttpxClient(httpx.AsyncClient):
|
288
303
|
"""Async httpx client."""
|
@@ -292,6 +307,17 @@ class AsyncHttpxClient(httpx.AsyncClient):
|
|
292
307
|
kwargs.setdefault('follow_redirects', True)
|
293
308
|
super().__init__(**kwargs)
|
294
309
|
|
310
|
+
def __del__(self) -> None:
|
311
|
+
try:
|
312
|
+
if self.is_closed:
|
313
|
+
return
|
314
|
+
except Exception:
|
315
|
+
pass
|
316
|
+
try:
|
317
|
+
asyncio.get_running_loop().create_task(self.aclose())
|
318
|
+
except Exception:
|
319
|
+
pass
|
320
|
+
|
295
321
|
|
296
322
|
class BaseApiClient:
|
297
323
|
"""Client for calling HTTP APIs sending and receiving JSON."""
|
@@ -351,10 +377,12 @@ class BaseApiClient:
|
|
351
377
|
# credentials. This is crucial for thread safety when multiple coroutines
|
352
378
|
# might be accessing the credentials at the same time.
|
353
379
|
try:
|
354
|
-
self.
|
380
|
+
self._sync_auth_lock = threading.Lock()
|
381
|
+
self._async_auth_lock = asyncio.Lock()
|
355
382
|
except RuntimeError:
|
356
383
|
asyncio.set_event_loop(asyncio.new_event_loop())
|
357
|
-
self.
|
384
|
+
self._sync_auth_lock = threading.Lock()
|
385
|
+
self._async_auth_lock = asyncio.Lock()
|
358
386
|
|
359
387
|
# Handle when to use Vertex AI in express mode (api key).
|
360
388
|
# Explicit initializer arguments are already validated above.
|
@@ -494,25 +522,26 @@ class BaseApiClient:
|
|
494
522
|
|
495
523
|
def _access_token(self) -> str:
|
496
524
|
"""Retrieves the access token for the credentials."""
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
self.project
|
501
|
-
|
502
|
-
|
503
|
-
if self._credentials
|
504
|
-
|
505
|
-
|
506
|
-
|
525
|
+
with self._sync_auth_lock:
|
526
|
+
if not self._credentials:
|
527
|
+
self._credentials, project = _load_auth(project=self.project)
|
528
|
+
if not self.project:
|
529
|
+
self.project = project
|
530
|
+
|
531
|
+
if self._credentials:
|
532
|
+
if self._credentials.expired or not self._credentials.token:
|
533
|
+
# Only refresh when it needs to. Default expiration is 3600 seconds.
|
534
|
+
_refresh_auth(self._credentials)
|
535
|
+
if not self._credentials.token:
|
536
|
+
raise RuntimeError('Could not resolve API token from the environment')
|
537
|
+
return self._credentials.token # type: ignore[no-any-return]
|
538
|
+
else:
|
507
539
|
raise RuntimeError('Could not resolve API token from the environment')
|
508
|
-
return self._credentials.token # type: ignore[no-any-return]
|
509
|
-
else:
|
510
|
-
raise RuntimeError('Could not resolve API token from the environment')
|
511
540
|
|
512
541
|
async def _async_access_token(self) -> Union[str, Any]:
|
513
542
|
"""Retrieves the access token for the credentials asynchronously."""
|
514
543
|
if not self._credentials:
|
515
|
-
async with self.
|
544
|
+
async with self._async_auth_lock:
|
516
545
|
# This ensures that only one coroutine can execute the auth logic at a
|
517
546
|
# time for thread safety.
|
518
547
|
if not self._credentials:
|
@@ -526,7 +555,7 @@ class BaseApiClient:
|
|
526
555
|
if self._credentials:
|
527
556
|
if self._credentials.expired or not self._credentials.token:
|
528
557
|
# Only refresh when it needs to. Default expiration is 3600 seconds.
|
529
|
-
async with self.
|
558
|
+
async with self._async_auth_lock:
|
530
559
|
if self._credentials.expired or not self._credentials.token:
|
531
560
|
# Double check that the credentials expired before refreshing.
|
532
561
|
await asyncio.to_thread(_refresh_auth, self._credentials)
|
@@ -865,15 +894,23 @@ class BaseApiClient:
|
|
865
894
|
'Content-Length': str(chunk_size),
|
866
895
|
}
|
867
896
|
_populate_server_timeout_header(upload_headers, timeout_in_seconds)
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
897
|
+
retry_count = 0
|
898
|
+
while retry_count < MAX_RETRY_COUNT:
|
899
|
+
response = self._httpx_client.request(
|
900
|
+
method='POST',
|
901
|
+
url=upload_url,
|
902
|
+
headers=upload_headers,
|
903
|
+
content=file_chunk,
|
904
|
+
timeout=timeout_in_seconds,
|
905
|
+
)
|
906
|
+
if response.headers.get('x-goog-upload-status'):
|
907
|
+
break
|
908
|
+
delay_seconds = INITIAL_RETRY_DELAY * (DELAY_MULTIPLIER**retry_count)
|
909
|
+
retry_count += 1
|
910
|
+
time.sleep(delay_seconds)
|
911
|
+
|
875
912
|
offset += chunk_size
|
876
|
-
if response.headers
|
913
|
+
if response.headers.get('x-goog-upload-status') != 'active':
|
877
914
|
break # upload is complete or it has been interrupted.
|
878
915
|
if upload_size <= offset: # Status is not finalized.
|
879
916
|
raise ValueError(
|
@@ -881,7 +918,7 @@ class BaseApiClient:
|
|
881
918
|
f' finalized.'
|
882
919
|
)
|
883
920
|
|
884
|
-
if response.headers
|
921
|
+
if response.headers.get('x-goog-upload-status') != 'final':
|
885
922
|
raise ValueError(
|
886
923
|
'Failed to upload file: Upload status is not finalized.'
|
887
924
|
)
|
@@ -1013,13 +1050,22 @@ class BaseApiClient:
|
|
1013
1050
|
'Content-Length': str(chunk_size),
|
1014
1051
|
}
|
1015
1052
|
_populate_server_timeout_header(upload_headers, timeout_in_seconds)
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1053
|
+
|
1054
|
+
retry_count = 0
|
1055
|
+
while retry_count < MAX_RETRY_COUNT:
|
1056
|
+
response = await self._async_httpx_client.request(
|
1057
|
+
method='POST',
|
1058
|
+
url=upload_url,
|
1059
|
+
content=file_chunk,
|
1060
|
+
headers=upload_headers,
|
1061
|
+
timeout=timeout_in_seconds,
|
1062
|
+
)
|
1063
|
+
if response.headers.get('x-goog-upload-status'):
|
1064
|
+
break
|
1065
|
+
delay_seconds = INITIAL_RETRY_DELAY * (DELAY_MULTIPLIER**retry_count)
|
1066
|
+
retry_count += 1
|
1067
|
+
time.sleep(delay_seconds)
|
1068
|
+
|
1023
1069
|
offset += chunk_size
|
1024
1070
|
if response.headers.get('x-goog-upload-status') != 'active':
|
1025
1071
|
break # upload is complete or it has been interrupted.
|
@@ -269,7 +269,7 @@ def _parse_schema_from_parameter(
|
|
269
269
|
raise ValueError(
|
270
270
|
f'Failed to parse the parameter {param} of function {func_name} for'
|
271
271
|
' automatic function calling.Automatic function calling works best with'
|
272
|
-
' simpler function signature schema,consider manually
|
272
|
+
' simpler function signature schema, consider manually parsing your'
|
273
273
|
f' function declaration for function {func_name}.'
|
274
274
|
)
|
275
275
|
|
google/genai/_live_converters.py
CHANGED
@@ -22,6 +22,42 @@ from ._common import get_value_by_path as getv
|
|
22
22
|
from ._common import set_value_by_path as setv
|
23
23
|
|
24
24
|
|
25
|
+
def _Blob_to_mldev(
|
26
|
+
api_client: BaseApiClient,
|
27
|
+
from_object: Union[dict[str, Any], object],
|
28
|
+
parent_object: Optional[dict[str, Any]] = None,
|
29
|
+
) -> dict[str, Any]:
|
30
|
+
to_object: dict[str, Any] = {}
|
31
|
+
if getv(from_object, ['display_name']) is not None:
|
32
|
+
raise ValueError('display_name parameter is not supported in Gemini API.')
|
33
|
+
|
34
|
+
if getv(from_object, ['data']) is not None:
|
35
|
+
setv(to_object, ['data'], getv(from_object, ['data']))
|
36
|
+
|
37
|
+
if getv(from_object, ['mime_type']) is not None:
|
38
|
+
setv(to_object, ['mimeType'], getv(from_object, ['mime_type']))
|
39
|
+
|
40
|
+
return to_object
|
41
|
+
|
42
|
+
|
43
|
+
def _Blob_to_vertex(
|
44
|
+
api_client: BaseApiClient,
|
45
|
+
from_object: Union[dict[str, Any], object],
|
46
|
+
parent_object: Optional[dict[str, Any]] = None,
|
47
|
+
) -> dict[str, Any]:
|
48
|
+
to_object: dict[str, Any] = {}
|
49
|
+
if getv(from_object, ['display_name']) is not None:
|
50
|
+
setv(to_object, ['displayName'], getv(from_object, ['display_name']))
|
51
|
+
|
52
|
+
if getv(from_object, ['data']) is not None:
|
53
|
+
setv(to_object, ['data'], getv(from_object, ['data']))
|
54
|
+
|
55
|
+
if getv(from_object, ['mime_type']) is not None:
|
56
|
+
setv(to_object, ['mimeType'], getv(from_object, ['mime_type']))
|
57
|
+
|
58
|
+
return to_object
|
59
|
+
|
60
|
+
|
25
61
|
def _Part_to_mldev(
|
26
62
|
api_client: BaseApiClient,
|
27
63
|
from_object: Union[dict[str, Any], object],
|
@@ -34,6 +70,15 @@ def _Part_to_mldev(
|
|
34
70
|
if getv(from_object, ['thought']) is not None:
|
35
71
|
setv(to_object, ['thought'], getv(from_object, ['thought']))
|
36
72
|
|
73
|
+
if getv(from_object, ['inline_data']) is not None:
|
74
|
+
setv(
|
75
|
+
to_object,
|
76
|
+
['inlineData'],
|
77
|
+
_Blob_to_mldev(
|
78
|
+
api_client, getv(from_object, ['inline_data']), to_object
|
79
|
+
),
|
80
|
+
)
|
81
|
+
|
37
82
|
if getv(from_object, ['code_execution_result']) is not None:
|
38
83
|
setv(
|
39
84
|
to_object,
|
@@ -57,9 +102,6 @@ def _Part_to_mldev(
|
|
57
102
|
getv(from_object, ['function_response']),
|
58
103
|
)
|
59
104
|
|
60
|
-
if getv(from_object, ['inline_data']) is not None:
|
61
|
-
setv(to_object, ['inlineData'], getv(from_object, ['inline_data']))
|
62
|
-
|
63
105
|
if getv(from_object, ['text']) is not None:
|
64
106
|
setv(to_object, ['text'], getv(from_object, ['text']))
|
65
107
|
|
@@ -78,6 +120,15 @@ def _Part_to_vertex(
|
|
78
120
|
if getv(from_object, ['thought']) is not None:
|
79
121
|
setv(to_object, ['thought'], getv(from_object, ['thought']))
|
80
122
|
|
123
|
+
if getv(from_object, ['inline_data']) is not None:
|
124
|
+
setv(
|
125
|
+
to_object,
|
126
|
+
['inlineData'],
|
127
|
+
_Blob_to_vertex(
|
128
|
+
api_client, getv(from_object, ['inline_data']), to_object
|
129
|
+
),
|
130
|
+
)
|
131
|
+
|
81
132
|
if getv(from_object, ['code_execution_result']) is not None:
|
82
133
|
setv(
|
83
134
|
to_object,
|
@@ -101,9 +152,6 @@ def _Part_to_vertex(
|
|
101
152
|
getv(from_object, ['function_response']),
|
102
153
|
)
|
103
154
|
|
104
|
-
if getv(from_object, ['inline_data']) is not None:
|
105
|
-
setv(to_object, ['inlineData'], getv(from_object, ['inline_data']))
|
106
|
-
|
107
155
|
if getv(from_object, ['text']) is not None:
|
108
156
|
setv(to_object, ['text'], getv(from_object, ['text']))
|
109
157
|
|
@@ -252,6 +300,156 @@ def _GoogleSearchRetrieval_to_vertex(
|
|
252
300
|
return to_object
|
253
301
|
|
254
302
|
|
303
|
+
def _EnterpriseWebSearch_to_mldev(
|
304
|
+
api_client: BaseApiClient,
|
305
|
+
from_object: Union[dict[str, Any], object],
|
306
|
+
parent_object: Optional[dict[str, Any]] = None,
|
307
|
+
) -> dict[str, Any]:
|
308
|
+
to_object: dict[str, Any] = {}
|
309
|
+
|
310
|
+
return to_object
|
311
|
+
|
312
|
+
|
313
|
+
def _EnterpriseWebSearch_to_vertex(
|
314
|
+
api_client: BaseApiClient,
|
315
|
+
from_object: Union[dict[str, Any], object],
|
316
|
+
parent_object: Optional[dict[str, Any]] = None,
|
317
|
+
) -> dict[str, Any]:
|
318
|
+
to_object: dict[str, Any] = {}
|
319
|
+
|
320
|
+
return to_object
|
321
|
+
|
322
|
+
|
323
|
+
def _ApiKeyConfig_to_mldev(
|
324
|
+
api_client: BaseApiClient,
|
325
|
+
from_object: Union[dict[str, Any], object],
|
326
|
+
parent_object: Optional[dict[str, Any]] = None,
|
327
|
+
) -> dict[str, Any]:
|
328
|
+
to_object: dict[str, Any] = {}
|
329
|
+
if getv(from_object, ['api_key_string']) is not None:
|
330
|
+
raise ValueError('api_key_string parameter is not supported in Gemini API.')
|
331
|
+
|
332
|
+
return to_object
|
333
|
+
|
334
|
+
|
335
|
+
def _ApiKeyConfig_to_vertex(
|
336
|
+
api_client: BaseApiClient,
|
337
|
+
from_object: Union[dict[str, Any], object],
|
338
|
+
parent_object: Optional[dict[str, Any]] = None,
|
339
|
+
) -> dict[str, Any]:
|
340
|
+
to_object: dict[str, Any] = {}
|
341
|
+
if getv(from_object, ['api_key_string']) is not None:
|
342
|
+
setv(to_object, ['apiKeyString'], getv(from_object, ['api_key_string']))
|
343
|
+
|
344
|
+
return to_object
|
345
|
+
|
346
|
+
|
347
|
+
def _AuthConfig_to_mldev(
|
348
|
+
api_client: BaseApiClient,
|
349
|
+
from_object: Union[dict[str, Any], object],
|
350
|
+
parent_object: Optional[dict[str, Any]] = None,
|
351
|
+
) -> dict[str, Any]:
|
352
|
+
to_object: dict[str, Any] = {}
|
353
|
+
if getv(from_object, ['api_key_config']) is not None:
|
354
|
+
raise ValueError('api_key_config parameter is not supported in Gemini API.')
|
355
|
+
|
356
|
+
if getv(from_object, ['auth_type']) is not None:
|
357
|
+
setv(to_object, ['authType'], getv(from_object, ['auth_type']))
|
358
|
+
|
359
|
+
if getv(from_object, ['google_service_account_config']) is not None:
|
360
|
+
setv(
|
361
|
+
to_object,
|
362
|
+
['googleServiceAccountConfig'],
|
363
|
+
getv(from_object, ['google_service_account_config']),
|
364
|
+
)
|
365
|
+
|
366
|
+
if getv(from_object, ['http_basic_auth_config']) is not None:
|
367
|
+
setv(
|
368
|
+
to_object,
|
369
|
+
['httpBasicAuthConfig'],
|
370
|
+
getv(from_object, ['http_basic_auth_config']),
|
371
|
+
)
|
372
|
+
|
373
|
+
if getv(from_object, ['oauth_config']) is not None:
|
374
|
+
setv(to_object, ['oauthConfig'], getv(from_object, ['oauth_config']))
|
375
|
+
|
376
|
+
if getv(from_object, ['oidc_config']) is not None:
|
377
|
+
setv(to_object, ['oidcConfig'], getv(from_object, ['oidc_config']))
|
378
|
+
|
379
|
+
return to_object
|
380
|
+
|
381
|
+
|
382
|
+
def _AuthConfig_to_vertex(
|
383
|
+
api_client: BaseApiClient,
|
384
|
+
from_object: Union[dict[str, Any], object],
|
385
|
+
parent_object: Optional[dict[str, Any]] = None,
|
386
|
+
) -> dict[str, Any]:
|
387
|
+
to_object: dict[str, Any] = {}
|
388
|
+
if getv(from_object, ['api_key_config']) is not None:
|
389
|
+
setv(
|
390
|
+
to_object,
|
391
|
+
['apiKeyConfig'],
|
392
|
+
_ApiKeyConfig_to_vertex(
|
393
|
+
api_client, getv(from_object, ['api_key_config']), to_object
|
394
|
+
),
|
395
|
+
)
|
396
|
+
|
397
|
+
if getv(from_object, ['auth_type']) is not None:
|
398
|
+
setv(to_object, ['authType'], getv(from_object, ['auth_type']))
|
399
|
+
|
400
|
+
if getv(from_object, ['google_service_account_config']) is not None:
|
401
|
+
setv(
|
402
|
+
to_object,
|
403
|
+
['googleServiceAccountConfig'],
|
404
|
+
getv(from_object, ['google_service_account_config']),
|
405
|
+
)
|
406
|
+
|
407
|
+
if getv(from_object, ['http_basic_auth_config']) is not None:
|
408
|
+
setv(
|
409
|
+
to_object,
|
410
|
+
['httpBasicAuthConfig'],
|
411
|
+
getv(from_object, ['http_basic_auth_config']),
|
412
|
+
)
|
413
|
+
|
414
|
+
if getv(from_object, ['oauth_config']) is not None:
|
415
|
+
setv(to_object, ['oauthConfig'], getv(from_object, ['oauth_config']))
|
416
|
+
|
417
|
+
if getv(from_object, ['oidc_config']) is not None:
|
418
|
+
setv(to_object, ['oidcConfig'], getv(from_object, ['oidc_config']))
|
419
|
+
|
420
|
+
return to_object
|
421
|
+
|
422
|
+
|
423
|
+
def _GoogleMaps_to_mldev(
|
424
|
+
api_client: BaseApiClient,
|
425
|
+
from_object: Union[dict[str, Any], object],
|
426
|
+
parent_object: Optional[dict[str, Any]] = None,
|
427
|
+
) -> dict[str, Any]:
|
428
|
+
to_object: dict[str, Any] = {}
|
429
|
+
if getv(from_object, ['auth_config']) is not None:
|
430
|
+
raise ValueError('auth_config parameter is not supported in Gemini API.')
|
431
|
+
|
432
|
+
return to_object
|
433
|
+
|
434
|
+
|
435
|
+
def _GoogleMaps_to_vertex(
|
436
|
+
api_client: BaseApiClient,
|
437
|
+
from_object: Union[dict[str, Any], object],
|
438
|
+
parent_object: Optional[dict[str, Any]] = None,
|
439
|
+
) -> dict[str, Any]:
|
440
|
+
to_object: dict[str, Any] = {}
|
441
|
+
if getv(from_object, ['auth_config']) is not None:
|
442
|
+
setv(
|
443
|
+
to_object,
|
444
|
+
['authConfig'],
|
445
|
+
_AuthConfig_to_vertex(
|
446
|
+
api_client, getv(from_object, ['auth_config']), to_object
|
447
|
+
),
|
448
|
+
)
|
449
|
+
|
450
|
+
return to_object
|
451
|
+
|
452
|
+
|
255
453
|
def _Tool_to_mldev(
|
256
454
|
api_client: BaseApiClient,
|
257
455
|
from_object: Union[dict[str, Any], object],
|
@@ -281,6 +479,14 @@ def _Tool_to_mldev(
|
|
281
479
|
),
|
282
480
|
)
|
283
481
|
|
482
|
+
if getv(from_object, ['enterprise_web_search']) is not None:
|
483
|
+
raise ValueError(
|
484
|
+
'enterprise_web_search parameter is not supported in Gemini API.'
|
485
|
+
)
|
486
|
+
|
487
|
+
if getv(from_object, ['google_maps']) is not None:
|
488
|
+
raise ValueError('google_maps parameter is not supported in Gemini API.')
|
489
|
+
|
284
490
|
if getv(from_object, ['code_execution']) is not None:
|
285
491
|
setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
|
286
492
|
|
@@ -323,6 +529,24 @@ def _Tool_to_vertex(
|
|
323
529
|
),
|
324
530
|
)
|
325
531
|
|
532
|
+
if getv(from_object, ['enterprise_web_search']) is not None:
|
533
|
+
setv(
|
534
|
+
to_object,
|
535
|
+
['enterpriseWebSearch'],
|
536
|
+
_EnterpriseWebSearch_to_vertex(
|
537
|
+
api_client, getv(from_object, ['enterprise_web_search']), to_object
|
538
|
+
),
|
539
|
+
)
|
540
|
+
|
541
|
+
if getv(from_object, ['google_maps']) is not None:
|
542
|
+
setv(
|
543
|
+
to_object,
|
544
|
+
['googleMaps'],
|
545
|
+
_GoogleMaps_to_vertex(
|
546
|
+
api_client, getv(from_object, ['google_maps']), to_object
|
547
|
+
),
|
548
|
+
)
|
549
|
+
|
326
550
|
if getv(from_object, ['code_execution']) is not None:
|
327
551
|
setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
|
328
552
|
|
@@ -688,8 +912,14 @@ def _LiveConnectConfig_to_mldev(
|
|
688
912
|
)
|
689
913
|
|
690
914
|
if getv(from_object, ['input_audio_transcription']) is not None:
|
691
|
-
|
692
|
-
|
915
|
+
setv(
|
916
|
+
parent_object,
|
917
|
+
['setup', 'inputAudioTranscription'],
|
918
|
+
_AudioTranscriptionConfig_to_mldev(
|
919
|
+
api_client,
|
920
|
+
getv(from_object, ['input_audio_transcription']),
|
921
|
+
to_object,
|
922
|
+
),
|
693
923
|
)
|
694
924
|
|
695
925
|
if getv(from_object, ['output_audio_transcription']) is not None:
|
@@ -1117,6 +1347,28 @@ def _LiveClientSetup_to_mldev(
|
|
1117
1347
|
),
|
1118
1348
|
)
|
1119
1349
|
|
1350
|
+
if getv(from_object, ['input_audio_transcription']) is not None:
|
1351
|
+
setv(
|
1352
|
+
to_object,
|
1353
|
+
['inputAudioTranscription'],
|
1354
|
+
_AudioTranscriptionConfig_to_mldev(
|
1355
|
+
api_client,
|
1356
|
+
getv(from_object, ['input_audio_transcription']),
|
1357
|
+
to_object,
|
1358
|
+
),
|
1359
|
+
)
|
1360
|
+
|
1361
|
+
if getv(from_object, ['output_audio_transcription']) is not None:
|
1362
|
+
setv(
|
1363
|
+
to_object,
|
1364
|
+
['outputAudioTranscription'],
|
1365
|
+
_AudioTranscriptionConfig_to_mldev(
|
1366
|
+
api_client,
|
1367
|
+
getv(from_object, ['output_audio_transcription']),
|
1368
|
+
to_object,
|
1369
|
+
),
|
1370
|
+
)
|
1371
|
+
|
1120
1372
|
return to_object
|
1121
1373
|
|
1122
1374
|
|
@@ -1177,6 +1429,28 @@ def _LiveClientSetup_to_vertex(
|
|
1177
1429
|
),
|
1178
1430
|
)
|
1179
1431
|
|
1432
|
+
if getv(from_object, ['input_audio_transcription']) is not None:
|
1433
|
+
setv(
|
1434
|
+
to_object,
|
1435
|
+
['inputAudioTranscription'],
|
1436
|
+
_AudioTranscriptionConfig_to_vertex(
|
1437
|
+
api_client,
|
1438
|
+
getv(from_object, ['input_audio_transcription']),
|
1439
|
+
to_object,
|
1440
|
+
),
|
1441
|
+
)
|
1442
|
+
|
1443
|
+
if getv(from_object, ['output_audio_transcription']) is not None:
|
1444
|
+
setv(
|
1445
|
+
to_object,
|
1446
|
+
['outputAudioTranscription'],
|
1447
|
+
_AudioTranscriptionConfig_to_vertex(
|
1448
|
+
api_client,
|
1449
|
+
getv(from_object, ['output_audio_transcription']),
|
1450
|
+
to_object,
|
1451
|
+
),
|
1452
|
+
)
|
1453
|
+
|
1180
1454
|
return to_object
|
1181
1455
|
|
1182
1456
|
|
@@ -1494,6 +1768,40 @@ def _LiveServerSetupComplete_from_vertex(
|
|
1494
1768
|
return to_object
|
1495
1769
|
|
1496
1770
|
|
1771
|
+
def _Blob_from_mldev(
|
1772
|
+
api_client: BaseApiClient,
|
1773
|
+
from_object: Union[dict[str, Any], object],
|
1774
|
+
parent_object: Optional[dict[str, Any]] = None,
|
1775
|
+
) -> dict[str, Any]:
|
1776
|
+
to_object: dict[str, Any] = {}
|
1777
|
+
|
1778
|
+
if getv(from_object, ['data']) is not None:
|
1779
|
+
setv(to_object, ['data'], getv(from_object, ['data']))
|
1780
|
+
|
1781
|
+
if getv(from_object, ['mimeType']) is not None:
|
1782
|
+
setv(to_object, ['mime_type'], getv(from_object, ['mimeType']))
|
1783
|
+
|
1784
|
+
return to_object
|
1785
|
+
|
1786
|
+
|
1787
|
+
def _Blob_from_vertex(
|
1788
|
+
api_client: BaseApiClient,
|
1789
|
+
from_object: Union[dict[str, Any], object],
|
1790
|
+
parent_object: Optional[dict[str, Any]] = None,
|
1791
|
+
) -> dict[str, Any]:
|
1792
|
+
to_object: dict[str, Any] = {}
|
1793
|
+
if getv(from_object, ['displayName']) is not None:
|
1794
|
+
setv(to_object, ['display_name'], getv(from_object, ['displayName']))
|
1795
|
+
|
1796
|
+
if getv(from_object, ['data']) is not None:
|
1797
|
+
setv(to_object, ['data'], getv(from_object, ['data']))
|
1798
|
+
|
1799
|
+
if getv(from_object, ['mimeType']) is not None:
|
1800
|
+
setv(to_object, ['mime_type'], getv(from_object, ['mimeType']))
|
1801
|
+
|
1802
|
+
return to_object
|
1803
|
+
|
1804
|
+
|
1497
1805
|
def _Part_from_mldev(
|
1498
1806
|
api_client: BaseApiClient,
|
1499
1807
|
from_object: Union[dict[str, Any], object],
|
@@ -1504,6 +1812,15 @@ def _Part_from_mldev(
|
|
1504
1812
|
if getv(from_object, ['thought']) is not None:
|
1505
1813
|
setv(to_object, ['thought'], getv(from_object, ['thought']))
|
1506
1814
|
|
1815
|
+
if getv(from_object, ['inlineData']) is not None:
|
1816
|
+
setv(
|
1817
|
+
to_object,
|
1818
|
+
['inline_data'],
|
1819
|
+
_Blob_from_mldev(
|
1820
|
+
api_client, getv(from_object, ['inlineData']), to_object
|
1821
|
+
),
|
1822
|
+
)
|
1823
|
+
|
1507
1824
|
if getv(from_object, ['codeExecutionResult']) is not None:
|
1508
1825
|
setv(
|
1509
1826
|
to_object,
|
@@ -1527,9 +1844,6 @@ def _Part_from_mldev(
|
|
1527
1844
|
getv(from_object, ['functionResponse']),
|
1528
1845
|
)
|
1529
1846
|
|
1530
|
-
if getv(from_object, ['inlineData']) is not None:
|
1531
|
-
setv(to_object, ['inline_data'], getv(from_object, ['inlineData']))
|
1532
|
-
|
1533
1847
|
if getv(from_object, ['text']) is not None:
|
1534
1848
|
setv(to_object, ['text'], getv(from_object, ['text']))
|
1535
1849
|
|
@@ -1548,6 +1862,15 @@ def _Part_from_vertex(
|
|
1548
1862
|
if getv(from_object, ['thought']) is not None:
|
1549
1863
|
setv(to_object, ['thought'], getv(from_object, ['thought']))
|
1550
1864
|
|
1865
|
+
if getv(from_object, ['inlineData']) is not None:
|
1866
|
+
setv(
|
1867
|
+
to_object,
|
1868
|
+
['inline_data'],
|
1869
|
+
_Blob_from_vertex(
|
1870
|
+
api_client, getv(from_object, ['inlineData']), to_object
|
1871
|
+
),
|
1872
|
+
)
|
1873
|
+
|
1551
1874
|
if getv(from_object, ['codeExecutionResult']) is not None:
|
1552
1875
|
setv(
|
1553
1876
|
to_object,
|
@@ -1571,9 +1894,6 @@ def _Part_from_vertex(
|
|
1571
1894
|
getv(from_object, ['functionResponse']),
|
1572
1895
|
)
|
1573
1896
|
|
1574
|
-
if getv(from_object, ['inlineData']) is not None:
|
1575
|
-
setv(to_object, ['inline_data'], getv(from_object, ['inlineData']))
|
1576
|
-
|
1577
1897
|
if getv(from_object, ['text']) is not None:
|
1578
1898
|
setv(to_object, ['text'], getv(from_object, ['text']))
|
1579
1899
|
|