google-genai 1.13.0__py3-none-any.whl → 1.14.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 +59 -17
- google/genai/_live_converters.py +228 -2
- google/genai/caches.py +250 -0
- google/genai/models.py +250 -0
- google/genai/types.py +340 -0
- google/genai/version.py +1 -1
- {google_genai-1.13.0.dist-info → google_genai-1.14.0.dist-info}/METADATA +3 -1
- {google_genai-1.13.0.dist-info → google_genai-1.14.0.dist-info}/RECORD +11 -11
- {google_genai-1.13.0.dist-info → google_genai-1.14.0.dist-info}/WHEEL +1 -1
- {google_genai-1.13.0.dist-info → google_genai-1.14.0.dist-info}/licenses/LICENSE +0 -0
- {google_genai-1.13.0.dist-info → google_genai-1.14.0.dist-info}/top_level.txt +0 -0
google/genai/_api_client.py
CHANGED
@@ -58,7 +58,9 @@ from .types import HttpOptionsOrDict
|
|
58
58
|
|
59
59
|
logger = logging.getLogger('google_genai._api_client')
|
60
60
|
CHUNK_SIZE = 8 * 1024 * 1024 # 8 MB chunk size
|
61
|
-
|
61
|
+
MAX_RETRY_COUNT = 3
|
62
|
+
INITIAL_RETRY_DELAY = 1 # second
|
63
|
+
DELAY_MULTIPLIER = 2
|
62
64
|
|
63
65
|
def _append_library_version_headers(headers: dict[str, str]) -> None:
|
64
66
|
"""Appends the telemetry header to the headers dict."""
|
@@ -283,6 +285,18 @@ class SyncHttpxClient(httpx.Client):
|
|
283
285
|
kwargs.setdefault('follow_redirects', True)
|
284
286
|
super().__init__(**kwargs)
|
285
287
|
|
288
|
+
def __del__(self) -> None:
|
289
|
+
"""Closes the httpx client."""
|
290
|
+
try:
|
291
|
+
if self.is_closed:
|
292
|
+
return
|
293
|
+
except Exception:
|
294
|
+
pass
|
295
|
+
try:
|
296
|
+
self.close()
|
297
|
+
except Exception:
|
298
|
+
pass
|
299
|
+
|
286
300
|
|
287
301
|
class AsyncHttpxClient(httpx.AsyncClient):
|
288
302
|
"""Async httpx client."""
|
@@ -292,6 +306,17 @@ class AsyncHttpxClient(httpx.AsyncClient):
|
|
292
306
|
kwargs.setdefault('follow_redirects', True)
|
293
307
|
super().__init__(**kwargs)
|
294
308
|
|
309
|
+
def __del__(self) -> None:
|
310
|
+
try:
|
311
|
+
if self.is_closed:
|
312
|
+
return
|
313
|
+
except Exception:
|
314
|
+
pass
|
315
|
+
try:
|
316
|
+
asyncio.get_running_loop().create_task(self.aclose())
|
317
|
+
except Exception:
|
318
|
+
pass
|
319
|
+
|
295
320
|
|
296
321
|
class BaseApiClient:
|
297
322
|
"""Client for calling HTTP APIs sending and receiving JSON."""
|
@@ -865,15 +890,23 @@ class BaseApiClient:
|
|
865
890
|
'Content-Length': str(chunk_size),
|
866
891
|
}
|
867
892
|
_populate_server_timeout_header(upload_headers, timeout_in_seconds)
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
893
|
+
retry_count = 0
|
894
|
+
while retry_count < MAX_RETRY_COUNT:
|
895
|
+
response = self._httpx_client.request(
|
896
|
+
method='POST',
|
897
|
+
url=upload_url,
|
898
|
+
headers=upload_headers,
|
899
|
+
content=file_chunk,
|
900
|
+
timeout=timeout_in_seconds,
|
901
|
+
)
|
902
|
+
if response.headers.get('x-goog-upload-status'):
|
903
|
+
break
|
904
|
+
delay_seconds = INITIAL_RETRY_DELAY * (DELAY_MULTIPLIER**retry_count)
|
905
|
+
retry_count += 1
|
906
|
+
time.sleep(delay_seconds)
|
907
|
+
|
875
908
|
offset += chunk_size
|
876
|
-
if response.headers
|
909
|
+
if response.headers.get('x-goog-upload-status') != 'active':
|
877
910
|
break # upload is complete or it has been interrupted.
|
878
911
|
if upload_size <= offset: # Status is not finalized.
|
879
912
|
raise ValueError(
|
@@ -881,7 +914,7 @@ class BaseApiClient:
|
|
881
914
|
f' finalized.'
|
882
915
|
)
|
883
916
|
|
884
|
-
if response.headers
|
917
|
+
if response.headers.get('x-goog-upload-status') != 'final':
|
885
918
|
raise ValueError(
|
886
919
|
'Failed to upload file: Upload status is not finalized.'
|
887
920
|
)
|
@@ -1013,13 +1046,22 @@ class BaseApiClient:
|
|
1013
1046
|
'Content-Length': str(chunk_size),
|
1014
1047
|
}
|
1015
1048
|
_populate_server_timeout_header(upload_headers, timeout_in_seconds)
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1049
|
+
|
1050
|
+
retry_count = 0
|
1051
|
+
while retry_count < MAX_RETRY_COUNT:
|
1052
|
+
response = await self._async_httpx_client.request(
|
1053
|
+
method='POST',
|
1054
|
+
url=upload_url,
|
1055
|
+
content=file_chunk,
|
1056
|
+
headers=upload_headers,
|
1057
|
+
timeout=timeout_in_seconds,
|
1058
|
+
)
|
1059
|
+
if response.headers.get('x-goog-upload-status'):
|
1060
|
+
break
|
1061
|
+
delay_seconds = INITIAL_RETRY_DELAY * (DELAY_MULTIPLIER**retry_count)
|
1062
|
+
retry_count += 1
|
1063
|
+
time.sleep(delay_seconds)
|
1064
|
+
|
1023
1065
|
offset += chunk_size
|
1024
1066
|
if response.headers.get('x-goog-upload-status') != 'active':
|
1025
1067
|
break # upload is complete or it has been interrupted.
|
google/genai/_live_converters.py
CHANGED
@@ -252,6 +252,156 @@ def _GoogleSearchRetrieval_to_vertex(
|
|
252
252
|
return to_object
|
253
253
|
|
254
254
|
|
255
|
+
def _EnterpriseWebSearch_to_mldev(
|
256
|
+
api_client: BaseApiClient,
|
257
|
+
from_object: Union[dict[str, Any], object],
|
258
|
+
parent_object: Optional[dict[str, Any]] = None,
|
259
|
+
) -> dict[str, Any]:
|
260
|
+
to_object: dict[str, Any] = {}
|
261
|
+
|
262
|
+
return to_object
|
263
|
+
|
264
|
+
|
265
|
+
def _EnterpriseWebSearch_to_vertex(
|
266
|
+
api_client: BaseApiClient,
|
267
|
+
from_object: Union[dict[str, Any], object],
|
268
|
+
parent_object: Optional[dict[str, Any]] = None,
|
269
|
+
) -> dict[str, Any]:
|
270
|
+
to_object: dict[str, Any] = {}
|
271
|
+
|
272
|
+
return to_object
|
273
|
+
|
274
|
+
|
275
|
+
def _ApiKeyConfig_to_mldev(
|
276
|
+
api_client: BaseApiClient,
|
277
|
+
from_object: Union[dict[str, Any], object],
|
278
|
+
parent_object: Optional[dict[str, Any]] = None,
|
279
|
+
) -> dict[str, Any]:
|
280
|
+
to_object: dict[str, Any] = {}
|
281
|
+
if getv(from_object, ['api_key_string']) is not None:
|
282
|
+
raise ValueError('api_key_string parameter is not supported in Gemini API.')
|
283
|
+
|
284
|
+
return to_object
|
285
|
+
|
286
|
+
|
287
|
+
def _ApiKeyConfig_to_vertex(
|
288
|
+
api_client: BaseApiClient,
|
289
|
+
from_object: Union[dict[str, Any], object],
|
290
|
+
parent_object: Optional[dict[str, Any]] = None,
|
291
|
+
) -> dict[str, Any]:
|
292
|
+
to_object: dict[str, Any] = {}
|
293
|
+
if getv(from_object, ['api_key_string']) is not None:
|
294
|
+
setv(to_object, ['apiKeyString'], getv(from_object, ['api_key_string']))
|
295
|
+
|
296
|
+
return to_object
|
297
|
+
|
298
|
+
|
299
|
+
def _AuthConfig_to_mldev(
|
300
|
+
api_client: BaseApiClient,
|
301
|
+
from_object: Union[dict[str, Any], object],
|
302
|
+
parent_object: Optional[dict[str, Any]] = None,
|
303
|
+
) -> dict[str, Any]:
|
304
|
+
to_object: dict[str, Any] = {}
|
305
|
+
if getv(from_object, ['api_key_config']) is not None:
|
306
|
+
raise ValueError('api_key_config parameter is not supported in Gemini API.')
|
307
|
+
|
308
|
+
if getv(from_object, ['auth_type']) is not None:
|
309
|
+
setv(to_object, ['authType'], getv(from_object, ['auth_type']))
|
310
|
+
|
311
|
+
if getv(from_object, ['google_service_account_config']) is not None:
|
312
|
+
setv(
|
313
|
+
to_object,
|
314
|
+
['googleServiceAccountConfig'],
|
315
|
+
getv(from_object, ['google_service_account_config']),
|
316
|
+
)
|
317
|
+
|
318
|
+
if getv(from_object, ['http_basic_auth_config']) is not None:
|
319
|
+
setv(
|
320
|
+
to_object,
|
321
|
+
['httpBasicAuthConfig'],
|
322
|
+
getv(from_object, ['http_basic_auth_config']),
|
323
|
+
)
|
324
|
+
|
325
|
+
if getv(from_object, ['oauth_config']) is not None:
|
326
|
+
setv(to_object, ['oauthConfig'], getv(from_object, ['oauth_config']))
|
327
|
+
|
328
|
+
if getv(from_object, ['oidc_config']) is not None:
|
329
|
+
setv(to_object, ['oidcConfig'], getv(from_object, ['oidc_config']))
|
330
|
+
|
331
|
+
return to_object
|
332
|
+
|
333
|
+
|
334
|
+
def _AuthConfig_to_vertex(
|
335
|
+
api_client: BaseApiClient,
|
336
|
+
from_object: Union[dict[str, Any], object],
|
337
|
+
parent_object: Optional[dict[str, Any]] = None,
|
338
|
+
) -> dict[str, Any]:
|
339
|
+
to_object: dict[str, Any] = {}
|
340
|
+
if getv(from_object, ['api_key_config']) is not None:
|
341
|
+
setv(
|
342
|
+
to_object,
|
343
|
+
['apiKeyConfig'],
|
344
|
+
_ApiKeyConfig_to_vertex(
|
345
|
+
api_client, getv(from_object, ['api_key_config']), to_object
|
346
|
+
),
|
347
|
+
)
|
348
|
+
|
349
|
+
if getv(from_object, ['auth_type']) is not None:
|
350
|
+
setv(to_object, ['authType'], getv(from_object, ['auth_type']))
|
351
|
+
|
352
|
+
if getv(from_object, ['google_service_account_config']) is not None:
|
353
|
+
setv(
|
354
|
+
to_object,
|
355
|
+
['googleServiceAccountConfig'],
|
356
|
+
getv(from_object, ['google_service_account_config']),
|
357
|
+
)
|
358
|
+
|
359
|
+
if getv(from_object, ['http_basic_auth_config']) is not None:
|
360
|
+
setv(
|
361
|
+
to_object,
|
362
|
+
['httpBasicAuthConfig'],
|
363
|
+
getv(from_object, ['http_basic_auth_config']),
|
364
|
+
)
|
365
|
+
|
366
|
+
if getv(from_object, ['oauth_config']) is not None:
|
367
|
+
setv(to_object, ['oauthConfig'], getv(from_object, ['oauth_config']))
|
368
|
+
|
369
|
+
if getv(from_object, ['oidc_config']) is not None:
|
370
|
+
setv(to_object, ['oidcConfig'], getv(from_object, ['oidc_config']))
|
371
|
+
|
372
|
+
return to_object
|
373
|
+
|
374
|
+
|
375
|
+
def _GoogleMaps_to_mldev(
|
376
|
+
api_client: BaseApiClient,
|
377
|
+
from_object: Union[dict[str, Any], object],
|
378
|
+
parent_object: Optional[dict[str, Any]] = None,
|
379
|
+
) -> dict[str, Any]:
|
380
|
+
to_object: dict[str, Any] = {}
|
381
|
+
if getv(from_object, ['auth_config']) is not None:
|
382
|
+
raise ValueError('auth_config parameter is not supported in Gemini API.')
|
383
|
+
|
384
|
+
return to_object
|
385
|
+
|
386
|
+
|
387
|
+
def _GoogleMaps_to_vertex(
|
388
|
+
api_client: BaseApiClient,
|
389
|
+
from_object: Union[dict[str, Any], object],
|
390
|
+
parent_object: Optional[dict[str, Any]] = None,
|
391
|
+
) -> dict[str, Any]:
|
392
|
+
to_object: dict[str, Any] = {}
|
393
|
+
if getv(from_object, ['auth_config']) is not None:
|
394
|
+
setv(
|
395
|
+
to_object,
|
396
|
+
['authConfig'],
|
397
|
+
_AuthConfig_to_vertex(
|
398
|
+
api_client, getv(from_object, ['auth_config']), to_object
|
399
|
+
),
|
400
|
+
)
|
401
|
+
|
402
|
+
return to_object
|
403
|
+
|
404
|
+
|
255
405
|
def _Tool_to_mldev(
|
256
406
|
api_client: BaseApiClient,
|
257
407
|
from_object: Union[dict[str, Any], object],
|
@@ -281,6 +431,14 @@ def _Tool_to_mldev(
|
|
281
431
|
),
|
282
432
|
)
|
283
433
|
|
434
|
+
if getv(from_object, ['enterprise_web_search']) is not None:
|
435
|
+
raise ValueError(
|
436
|
+
'enterprise_web_search parameter is not supported in Gemini API.'
|
437
|
+
)
|
438
|
+
|
439
|
+
if getv(from_object, ['google_maps']) is not None:
|
440
|
+
raise ValueError('google_maps parameter is not supported in Gemini API.')
|
441
|
+
|
284
442
|
if getv(from_object, ['code_execution']) is not None:
|
285
443
|
setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
|
286
444
|
|
@@ -323,6 +481,24 @@ def _Tool_to_vertex(
|
|
323
481
|
),
|
324
482
|
)
|
325
483
|
|
484
|
+
if getv(from_object, ['enterprise_web_search']) is not None:
|
485
|
+
setv(
|
486
|
+
to_object,
|
487
|
+
['enterpriseWebSearch'],
|
488
|
+
_EnterpriseWebSearch_to_vertex(
|
489
|
+
api_client, getv(from_object, ['enterprise_web_search']), to_object
|
490
|
+
),
|
491
|
+
)
|
492
|
+
|
493
|
+
if getv(from_object, ['google_maps']) is not None:
|
494
|
+
setv(
|
495
|
+
to_object,
|
496
|
+
['googleMaps'],
|
497
|
+
_GoogleMaps_to_vertex(
|
498
|
+
api_client, getv(from_object, ['google_maps']), to_object
|
499
|
+
),
|
500
|
+
)
|
501
|
+
|
326
502
|
if getv(from_object, ['code_execution']) is not None:
|
327
503
|
setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
|
328
504
|
|
@@ -688,8 +864,14 @@ def _LiveConnectConfig_to_mldev(
|
|
688
864
|
)
|
689
865
|
|
690
866
|
if getv(from_object, ['input_audio_transcription']) is not None:
|
691
|
-
|
692
|
-
|
867
|
+
setv(
|
868
|
+
parent_object,
|
869
|
+
['setup', 'inputAudioTranscription'],
|
870
|
+
_AudioTranscriptionConfig_to_mldev(
|
871
|
+
api_client,
|
872
|
+
getv(from_object, ['input_audio_transcription']),
|
873
|
+
to_object,
|
874
|
+
),
|
693
875
|
)
|
694
876
|
|
695
877
|
if getv(from_object, ['output_audio_transcription']) is not None:
|
@@ -1117,6 +1299,28 @@ def _LiveClientSetup_to_mldev(
|
|
1117
1299
|
),
|
1118
1300
|
)
|
1119
1301
|
|
1302
|
+
if getv(from_object, ['input_audio_transcription']) is not None:
|
1303
|
+
setv(
|
1304
|
+
to_object,
|
1305
|
+
['inputAudioTranscription'],
|
1306
|
+
_AudioTranscriptionConfig_to_mldev(
|
1307
|
+
api_client,
|
1308
|
+
getv(from_object, ['input_audio_transcription']),
|
1309
|
+
to_object,
|
1310
|
+
),
|
1311
|
+
)
|
1312
|
+
|
1313
|
+
if getv(from_object, ['output_audio_transcription']) is not None:
|
1314
|
+
setv(
|
1315
|
+
to_object,
|
1316
|
+
['outputAudioTranscription'],
|
1317
|
+
_AudioTranscriptionConfig_to_mldev(
|
1318
|
+
api_client,
|
1319
|
+
getv(from_object, ['output_audio_transcription']),
|
1320
|
+
to_object,
|
1321
|
+
),
|
1322
|
+
)
|
1323
|
+
|
1120
1324
|
return to_object
|
1121
1325
|
|
1122
1326
|
|
@@ -1177,6 +1381,28 @@ def _LiveClientSetup_to_vertex(
|
|
1177
1381
|
),
|
1178
1382
|
)
|
1179
1383
|
|
1384
|
+
if getv(from_object, ['input_audio_transcription']) is not None:
|
1385
|
+
setv(
|
1386
|
+
to_object,
|
1387
|
+
['inputAudioTranscription'],
|
1388
|
+
_AudioTranscriptionConfig_to_vertex(
|
1389
|
+
api_client,
|
1390
|
+
getv(from_object, ['input_audio_transcription']),
|
1391
|
+
to_object,
|
1392
|
+
),
|
1393
|
+
)
|
1394
|
+
|
1395
|
+
if getv(from_object, ['output_audio_transcription']) is not None:
|
1396
|
+
setv(
|
1397
|
+
to_object,
|
1398
|
+
['outputAudioTranscription'],
|
1399
|
+
_AudioTranscriptionConfig_to_vertex(
|
1400
|
+
api_client,
|
1401
|
+
getv(from_object, ['output_audio_transcription']),
|
1402
|
+
to_object,
|
1403
|
+
),
|
1404
|
+
)
|
1405
|
+
|
1180
1406
|
return to_object
|
1181
1407
|
|
1182
1408
|
|
google/genai/caches.py
CHANGED
@@ -145,6 +145,75 @@ def _GoogleSearchRetrieval_to_mldev(
|
|
145
145
|
return to_object
|
146
146
|
|
147
147
|
|
148
|
+
def _EnterpriseWebSearch_to_mldev(
|
149
|
+
api_client: BaseApiClient,
|
150
|
+
from_object: Union[dict[str, Any], object],
|
151
|
+
parent_object: Optional[dict[str, Any]] = None,
|
152
|
+
) -> dict[str, Any]:
|
153
|
+
to_object: dict[str, Any] = {}
|
154
|
+
|
155
|
+
return to_object
|
156
|
+
|
157
|
+
|
158
|
+
def _ApiKeyConfig_to_mldev(
|
159
|
+
api_client: BaseApiClient,
|
160
|
+
from_object: Union[dict[str, Any], object],
|
161
|
+
parent_object: Optional[dict[str, Any]] = None,
|
162
|
+
) -> dict[str, Any]:
|
163
|
+
to_object: dict[str, Any] = {}
|
164
|
+
if getv(from_object, ['api_key_string']) is not None:
|
165
|
+
raise ValueError('api_key_string parameter is not supported in Gemini API.')
|
166
|
+
|
167
|
+
return to_object
|
168
|
+
|
169
|
+
|
170
|
+
def _AuthConfig_to_mldev(
|
171
|
+
api_client: BaseApiClient,
|
172
|
+
from_object: Union[dict[str, Any], object],
|
173
|
+
parent_object: Optional[dict[str, Any]] = None,
|
174
|
+
) -> dict[str, Any]:
|
175
|
+
to_object: dict[str, Any] = {}
|
176
|
+
if getv(from_object, ['api_key_config']) is not None:
|
177
|
+
raise ValueError('api_key_config parameter is not supported in Gemini API.')
|
178
|
+
|
179
|
+
if getv(from_object, ['auth_type']) is not None:
|
180
|
+
setv(to_object, ['authType'], getv(from_object, ['auth_type']))
|
181
|
+
|
182
|
+
if getv(from_object, ['google_service_account_config']) is not None:
|
183
|
+
setv(
|
184
|
+
to_object,
|
185
|
+
['googleServiceAccountConfig'],
|
186
|
+
getv(from_object, ['google_service_account_config']),
|
187
|
+
)
|
188
|
+
|
189
|
+
if getv(from_object, ['http_basic_auth_config']) is not None:
|
190
|
+
setv(
|
191
|
+
to_object,
|
192
|
+
['httpBasicAuthConfig'],
|
193
|
+
getv(from_object, ['http_basic_auth_config']),
|
194
|
+
)
|
195
|
+
|
196
|
+
if getv(from_object, ['oauth_config']) is not None:
|
197
|
+
setv(to_object, ['oauthConfig'], getv(from_object, ['oauth_config']))
|
198
|
+
|
199
|
+
if getv(from_object, ['oidc_config']) is not None:
|
200
|
+
setv(to_object, ['oidcConfig'], getv(from_object, ['oidc_config']))
|
201
|
+
|
202
|
+
return to_object
|
203
|
+
|
204
|
+
|
205
|
+
def _GoogleMaps_to_mldev(
|
206
|
+
api_client: BaseApiClient,
|
207
|
+
from_object: Union[dict[str, Any], object],
|
208
|
+
parent_object: Optional[dict[str, Any]] = None,
|
209
|
+
) -> dict[str, Any]:
|
210
|
+
to_object: dict[str, Any] = {}
|
211
|
+
if getv(from_object, ['auth_config']) is not None:
|
212
|
+
raise ValueError('auth_config parameter is not supported in Gemini API.')
|
213
|
+
|
214
|
+
return to_object
|
215
|
+
|
216
|
+
|
148
217
|
def _Tool_to_mldev(
|
149
218
|
api_client: BaseApiClient,
|
150
219
|
from_object: Union[dict[str, Any], object],
|
@@ -174,6 +243,14 @@ def _Tool_to_mldev(
|
|
174
243
|
),
|
175
244
|
)
|
176
245
|
|
246
|
+
if getv(from_object, ['enterprise_web_search']) is not None:
|
247
|
+
raise ValueError(
|
248
|
+
'enterprise_web_search parameter is not supported in Gemini API.'
|
249
|
+
)
|
250
|
+
|
251
|
+
if getv(from_object, ['google_maps']) is not None:
|
252
|
+
raise ValueError('google_maps parameter is not supported in Gemini API.')
|
253
|
+
|
177
254
|
if getv(from_object, ['code_execution']) is not None:
|
178
255
|
setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
|
179
256
|
|
@@ -206,6 +283,33 @@ def _FunctionCallingConfig_to_mldev(
|
|
206
283
|
return to_object
|
207
284
|
|
208
285
|
|
286
|
+
def _LatLng_to_mldev(
|
287
|
+
api_client: BaseApiClient,
|
288
|
+
from_object: Union[dict[str, Any], object],
|
289
|
+
parent_object: Optional[dict[str, Any]] = None,
|
290
|
+
) -> dict[str, Any]:
|
291
|
+
to_object: dict[str, Any] = {}
|
292
|
+
if getv(from_object, ['latitude']) is not None:
|
293
|
+
raise ValueError('latitude parameter is not supported in Gemini API.')
|
294
|
+
|
295
|
+
if getv(from_object, ['longitude']) is not None:
|
296
|
+
raise ValueError('longitude parameter is not supported in Gemini API.')
|
297
|
+
|
298
|
+
return to_object
|
299
|
+
|
300
|
+
|
301
|
+
def _RetrievalConfig_to_mldev(
|
302
|
+
api_client: BaseApiClient,
|
303
|
+
from_object: Union[dict[str, Any], object],
|
304
|
+
parent_object: Optional[dict[str, Any]] = None,
|
305
|
+
) -> dict[str, Any]:
|
306
|
+
to_object: dict[str, Any] = {}
|
307
|
+
if getv(from_object, ['lat_lng']) is not None:
|
308
|
+
raise ValueError('lat_lng parameter is not supported in Gemini API.')
|
309
|
+
|
310
|
+
return to_object
|
311
|
+
|
312
|
+
|
209
313
|
def _ToolConfig_to_mldev(
|
210
314
|
api_client: BaseApiClient,
|
211
315
|
from_object: Union[dict[str, Any], object],
|
@@ -223,6 +327,11 @@ def _ToolConfig_to_mldev(
|
|
223
327
|
),
|
224
328
|
)
|
225
329
|
|
330
|
+
if getv(from_object, ['retrieval_config']) is not None:
|
331
|
+
raise ValueError(
|
332
|
+
'retrieval_config parameter is not supported in Gemini API.'
|
333
|
+
)
|
334
|
+
|
226
335
|
return to_object
|
227
336
|
|
228
337
|
|
@@ -546,6 +655,87 @@ def _GoogleSearchRetrieval_to_vertex(
|
|
546
655
|
return to_object
|
547
656
|
|
548
657
|
|
658
|
+
def _EnterpriseWebSearch_to_vertex(
|
659
|
+
api_client: BaseApiClient,
|
660
|
+
from_object: Union[dict[str, Any], object],
|
661
|
+
parent_object: Optional[dict[str, Any]] = None,
|
662
|
+
) -> dict[str, Any]:
|
663
|
+
to_object: dict[str, Any] = {}
|
664
|
+
|
665
|
+
return to_object
|
666
|
+
|
667
|
+
|
668
|
+
def _ApiKeyConfig_to_vertex(
|
669
|
+
api_client: BaseApiClient,
|
670
|
+
from_object: Union[dict[str, Any], object],
|
671
|
+
parent_object: Optional[dict[str, Any]] = None,
|
672
|
+
) -> dict[str, Any]:
|
673
|
+
to_object: dict[str, Any] = {}
|
674
|
+
if getv(from_object, ['api_key_string']) is not None:
|
675
|
+
setv(to_object, ['apiKeyString'], getv(from_object, ['api_key_string']))
|
676
|
+
|
677
|
+
return to_object
|
678
|
+
|
679
|
+
|
680
|
+
def _AuthConfig_to_vertex(
|
681
|
+
api_client: BaseApiClient,
|
682
|
+
from_object: Union[dict[str, Any], object],
|
683
|
+
parent_object: Optional[dict[str, Any]] = None,
|
684
|
+
) -> dict[str, Any]:
|
685
|
+
to_object: dict[str, Any] = {}
|
686
|
+
if getv(from_object, ['api_key_config']) is not None:
|
687
|
+
setv(
|
688
|
+
to_object,
|
689
|
+
['apiKeyConfig'],
|
690
|
+
_ApiKeyConfig_to_vertex(
|
691
|
+
api_client, getv(from_object, ['api_key_config']), to_object
|
692
|
+
),
|
693
|
+
)
|
694
|
+
|
695
|
+
if getv(from_object, ['auth_type']) is not None:
|
696
|
+
setv(to_object, ['authType'], getv(from_object, ['auth_type']))
|
697
|
+
|
698
|
+
if getv(from_object, ['google_service_account_config']) is not None:
|
699
|
+
setv(
|
700
|
+
to_object,
|
701
|
+
['googleServiceAccountConfig'],
|
702
|
+
getv(from_object, ['google_service_account_config']),
|
703
|
+
)
|
704
|
+
|
705
|
+
if getv(from_object, ['http_basic_auth_config']) is not None:
|
706
|
+
setv(
|
707
|
+
to_object,
|
708
|
+
['httpBasicAuthConfig'],
|
709
|
+
getv(from_object, ['http_basic_auth_config']),
|
710
|
+
)
|
711
|
+
|
712
|
+
if getv(from_object, ['oauth_config']) is not None:
|
713
|
+
setv(to_object, ['oauthConfig'], getv(from_object, ['oauth_config']))
|
714
|
+
|
715
|
+
if getv(from_object, ['oidc_config']) is not None:
|
716
|
+
setv(to_object, ['oidcConfig'], getv(from_object, ['oidc_config']))
|
717
|
+
|
718
|
+
return to_object
|
719
|
+
|
720
|
+
|
721
|
+
def _GoogleMaps_to_vertex(
|
722
|
+
api_client: BaseApiClient,
|
723
|
+
from_object: Union[dict[str, Any], object],
|
724
|
+
parent_object: Optional[dict[str, Any]] = None,
|
725
|
+
) -> dict[str, Any]:
|
726
|
+
to_object: dict[str, Any] = {}
|
727
|
+
if getv(from_object, ['auth_config']) is not None:
|
728
|
+
setv(
|
729
|
+
to_object,
|
730
|
+
['authConfig'],
|
731
|
+
_AuthConfig_to_vertex(
|
732
|
+
api_client, getv(from_object, ['auth_config']), to_object
|
733
|
+
),
|
734
|
+
)
|
735
|
+
|
736
|
+
return to_object
|
737
|
+
|
738
|
+
|
549
739
|
def _Tool_to_vertex(
|
550
740
|
api_client: BaseApiClient,
|
551
741
|
from_object: Union[dict[str, Any], object],
|
@@ -575,6 +765,24 @@ def _Tool_to_vertex(
|
|
575
765
|
),
|
576
766
|
)
|
577
767
|
|
768
|
+
if getv(from_object, ['enterprise_web_search']) is not None:
|
769
|
+
setv(
|
770
|
+
to_object,
|
771
|
+
['enterpriseWebSearch'],
|
772
|
+
_EnterpriseWebSearch_to_vertex(
|
773
|
+
api_client, getv(from_object, ['enterprise_web_search']), to_object
|
774
|
+
),
|
775
|
+
)
|
776
|
+
|
777
|
+
if getv(from_object, ['google_maps']) is not None:
|
778
|
+
setv(
|
779
|
+
to_object,
|
780
|
+
['googleMaps'],
|
781
|
+
_GoogleMaps_to_vertex(
|
782
|
+
api_client, getv(from_object, ['google_maps']), to_object
|
783
|
+
),
|
784
|
+
)
|
785
|
+
|
578
786
|
if getv(from_object, ['code_execution']) is not None:
|
579
787
|
setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
|
580
788
|
|
@@ -607,6 +815,39 @@ def _FunctionCallingConfig_to_vertex(
|
|
607
815
|
return to_object
|
608
816
|
|
609
817
|
|
818
|
+
def _LatLng_to_vertex(
|
819
|
+
api_client: BaseApiClient,
|
820
|
+
from_object: Union[dict[str, Any], object],
|
821
|
+
parent_object: Optional[dict[str, Any]] = None,
|
822
|
+
) -> dict[str, Any]:
|
823
|
+
to_object: dict[str, Any] = {}
|
824
|
+
if getv(from_object, ['latitude']) is not None:
|
825
|
+
setv(to_object, ['latitude'], getv(from_object, ['latitude']))
|
826
|
+
|
827
|
+
if getv(from_object, ['longitude']) is not None:
|
828
|
+
setv(to_object, ['longitude'], getv(from_object, ['longitude']))
|
829
|
+
|
830
|
+
return to_object
|
831
|
+
|
832
|
+
|
833
|
+
def _RetrievalConfig_to_vertex(
|
834
|
+
api_client: BaseApiClient,
|
835
|
+
from_object: Union[dict[str, Any], object],
|
836
|
+
parent_object: Optional[dict[str, Any]] = None,
|
837
|
+
) -> dict[str, Any]:
|
838
|
+
to_object: dict[str, Any] = {}
|
839
|
+
if getv(from_object, ['lat_lng']) is not None:
|
840
|
+
setv(
|
841
|
+
to_object,
|
842
|
+
['latLng'],
|
843
|
+
_LatLng_to_vertex(
|
844
|
+
api_client, getv(from_object, ['lat_lng']), to_object
|
845
|
+
),
|
846
|
+
)
|
847
|
+
|
848
|
+
return to_object
|
849
|
+
|
850
|
+
|
610
851
|
def _ToolConfig_to_vertex(
|
611
852
|
api_client: BaseApiClient,
|
612
853
|
from_object: Union[dict[str, Any], object],
|
@@ -624,6 +865,15 @@ def _ToolConfig_to_vertex(
|
|
624
865
|
),
|
625
866
|
)
|
626
867
|
|
868
|
+
if getv(from_object, ['retrieval_config']) is not None:
|
869
|
+
setv(
|
870
|
+
to_object,
|
871
|
+
['retrievalConfig'],
|
872
|
+
_RetrievalConfig_to_vertex(
|
873
|
+
api_client, getv(from_object, ['retrieval_config']), to_object
|
874
|
+
),
|
875
|
+
)
|
876
|
+
|
627
877
|
return to_object
|
628
878
|
|
629
879
|
|