google-genai 1.55.0__py3-none-any.whl → 1.57.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.
Files changed (88) hide show
  1. google/genai/_api_client.py +37 -18
  2. google/genai/_interactions/_base_client.py +8 -2
  3. google/genai/_interactions/resources/interactions.py +6 -6
  4. google/genai/_interactions/types/__init__.py +4 -0
  5. google/genai/_interactions/types/audio_content.py +0 -1
  6. google/genai/_interactions/types/audio_content_param.py +0 -1
  7. google/genai/_interactions/types/code_execution_call_content.py +0 -1
  8. google/genai/_interactions/types/code_execution_call_content_param.py +0 -1
  9. google/genai/_interactions/types/code_execution_result_content.py +0 -1
  10. google/genai/_interactions/types/code_execution_result_content_param.py +0 -1
  11. google/genai/_interactions/types/content.py +63 -0
  12. google/genai/_interactions/types/content_delta.py +7 -23
  13. google/genai/_interactions/types/content_param.py +61 -0
  14. google/genai/_interactions/types/content_start.py +4 -44
  15. google/genai/_interactions/types/deep_research_agent_config.py +0 -1
  16. google/genai/_interactions/types/deep_research_agent_config_param.py +0 -1
  17. google/genai/_interactions/types/document_content.py +3 -2
  18. google/genai/_interactions/types/document_content_param.py +3 -2
  19. google/genai/_interactions/types/document_mime_type.py +23 -0
  20. google/genai/_interactions/types/document_mime_type_param.py +25 -0
  21. google/genai/_interactions/types/dynamic_agent_config.py +0 -1
  22. google/genai/_interactions/types/dynamic_agent_config_param.py +0 -1
  23. google/genai/_interactions/types/file_search_result_content.py +0 -1
  24. google/genai/_interactions/types/file_search_result_content_param.py +0 -1
  25. google/genai/_interactions/types/function_call_content.py +0 -1
  26. google/genai/_interactions/types/function_call_content_param.py +0 -1
  27. google/genai/_interactions/types/function_result_content.py +1 -2
  28. google/genai/_interactions/types/function_result_content_param.py +1 -2
  29. google/genai/_interactions/types/google_search_call_content.py +0 -1
  30. google/genai/_interactions/types/google_search_call_content_param.py +0 -1
  31. google/genai/_interactions/types/google_search_result_content.py +0 -1
  32. google/genai/_interactions/types/google_search_result_content_param.py +0 -1
  33. google/genai/_interactions/types/image_content.py +1 -2
  34. google/genai/_interactions/types/image_content_param.py +1 -2
  35. google/genai/_interactions/types/interaction.py +4 -52
  36. google/genai/_interactions/types/interaction_create_params.py +2 -22
  37. google/genai/_interactions/types/mcp_server_tool_call_content.py +0 -1
  38. google/genai/_interactions/types/mcp_server_tool_call_content_param.py +0 -1
  39. google/genai/_interactions/types/mcp_server_tool_result_content.py +1 -2
  40. google/genai/_interactions/types/mcp_server_tool_result_content_param.py +1 -2
  41. google/genai/_interactions/types/model.py +1 -0
  42. google/genai/_interactions/types/model_param.py +1 -0
  43. google/genai/_interactions/types/text_content.py +0 -1
  44. google/genai/_interactions/types/text_content_param.py +0 -1
  45. google/genai/_interactions/types/thinking_level.py +1 -1
  46. google/genai/_interactions/types/thought_content.py +0 -1
  47. google/genai/_interactions/types/thought_content_param.py +0 -1
  48. google/genai/_interactions/types/turn.py +3 -44
  49. google/genai/_interactions/types/turn_param.py +4 -40
  50. google/genai/_interactions/types/url_context_call_content.py +0 -1
  51. google/genai/_interactions/types/url_context_call_content_param.py +0 -1
  52. google/genai/_interactions/types/url_context_result_content.py +0 -1
  53. google/genai/_interactions/types/url_context_result_content_param.py +0 -1
  54. google/genai/_interactions/types/usage.py +1 -1
  55. google/genai/_interactions/types/usage_param.py +1 -1
  56. google/genai/_interactions/types/video_content.py +1 -2
  57. google/genai/_interactions/types/video_content_param.py +1 -2
  58. google/genai/_live_converters.py +36 -64
  59. google/genai/_local_tokenizer_loader.py +1 -0
  60. google/genai/_tokens_converters.py +14 -14
  61. google/genai/batches.py +27 -22
  62. google/genai/caches.py +42 -42
  63. google/genai/chats.py +0 -2
  64. google/genai/client.py +3 -1
  65. google/genai/files.py +224 -0
  66. google/genai/models.py +57 -72
  67. google/genai/tests/chats/test_get_history.py +9 -8
  68. google/genai/tests/chats/test_validate_response.py +1 -1
  69. google/genai/tests/client/test_client_requests.py +1 -135
  70. google/genai/tests/files/test_register.py +272 -0
  71. google/genai/tests/files/test_register_table.py +70 -0
  72. google/genai/tests/interactions/test_auth.py +479 -0
  73. google/genai/tests/interactions/test_integration.py +2 -0
  74. google/genai/tests/interactions/test_paths.py +105 -0
  75. google/genai/tests/live/test_live.py +2 -36
  76. google/genai/tests/local_tokenizer/test_local_tokenizer.py +1 -1
  77. google/genai/tests/models/test_function_call_streaming.py +90 -90
  78. google/genai/tests/models/test_generate_content.py +1 -2
  79. google/genai/tests/models/test_recontext_image.py +1 -1
  80. google/genai/tests/pytest_helper.py +17 -0
  81. google/genai/tunings.py +1 -27
  82. google/genai/types.py +603 -518
  83. google/genai/version.py +1 -1
  84. {google_genai-1.55.0.dist-info → google_genai-1.57.0.dist-info}/METADATA +224 -22
  85. {google_genai-1.55.0.dist-info → google_genai-1.57.0.dist-info}/RECORD +88 -80
  86. {google_genai-1.55.0.dist-info → google_genai-1.57.0.dist-info}/WHEEL +0 -0
  87. {google_genai-1.55.0.dist-info → google_genai-1.57.0.dist-info}/licenses/LICENSE +0 -0
  88. {google_genai-1.55.0.dist-info → google_genai-1.57.0.dist-info}/top_level.txt +0 -0
@@ -32,14 +32,13 @@ class VideoContentParam(TypedDict, total=False):
32
32
  """A video content block."""
33
33
 
34
34
  type: Required[Literal["video"]]
35
- """Used as the OpenAPI type discriminator for the content oneof."""
36
35
 
37
36
  data: Annotated[Union[str, Base64FileInput], PropertyInfo(format="base64")]
38
37
 
39
38
  mime_type: VideoMimeTypeParam
40
39
  """The mime type of the video."""
41
40
 
42
- resolution: Literal["low", "medium", "high"]
41
+ resolution: Literal["low", "medium", "high", "ultra_high"]
43
42
  """The resolution of the media."""
44
43
 
45
44
  uri: str
@@ -106,9 +106,6 @@ def _FunctionDeclaration_to_vertex(
106
106
  parent_object: Optional[dict[str, Any]] = None,
107
107
  ) -> dict[str, Any]:
108
108
  to_object: dict[str, Any] = {}
109
- if getv(from_object, ['behavior']) is not None:
110
- raise ValueError('behavior parameter is not supported in Vertex AI.')
111
-
112
109
  if getv(from_object, ['description']) is not None:
113
110
  setv(to_object, ['description'], getv(from_object, ['description']))
114
111
 
@@ -135,6 +132,9 @@ def _FunctionDeclaration_to_vertex(
135
132
  getv(from_object, ['response_json_schema']),
136
133
  )
137
134
 
135
+ if getv(from_object, ['behavior']) is not None:
136
+ raise ValueError('behavior parameter is not supported in Vertex AI.')
137
+
138
138
  return to_object
139
139
 
140
140
 
@@ -226,13 +226,7 @@ def _GenerationConfig_to_vertex(
226
226
  setv(to_object, ['seed'], getv(from_object, ['seed']))
227
227
 
228
228
  if getv(from_object, ['speech_config']) is not None:
229
- setv(
230
- to_object,
231
- ['speechConfig'],
232
- _SpeechConfig_to_vertex(
233
- getv(from_object, ['speech_config']), to_object
234
- ),
235
- )
229
+ setv(to_object, ['speechConfig'], getv(from_object, ['speech_config']))
236
230
 
237
231
  if getv(from_object, ['stop_sequences']) is not None:
238
232
  setv(to_object, ['stopSequences'], getv(from_object, ['stop_sequences']))
@@ -842,10 +836,7 @@ def _LiveConnectConfig_to_vertex(
842
836
  setv(
843
837
  parent_object,
844
838
  ['setup', 'generationConfig', 'speechConfig'],
845
- _SpeechConfig_to_vertex(
846
- t.t_live_speech_config(getv(from_object, ['speech_config'])),
847
- to_object,
848
- ),
839
+ t.t_live_speech_config(getv(from_object, ['speech_config'])),
849
840
  )
850
841
 
851
842
  if getv(from_object, ['thinking_config']) is not None:
@@ -1291,47 +1282,14 @@ def _SessionResumptionConfig_to_mldev(
1291
1282
  return to_object
1292
1283
 
1293
1284
 
1294
- def _SpeechConfig_to_vertex(
1295
- from_object: Union[dict[str, Any], object],
1296
- parent_object: Optional[dict[str, Any]] = None,
1297
- ) -> dict[str, Any]:
1298
- to_object: dict[str, Any] = {}
1299
- if getv(from_object, ['voice_config']) is not None:
1300
- setv(to_object, ['voiceConfig'], getv(from_object, ['voice_config']))
1301
-
1302
- if getv(from_object, ['language_code']) is not None:
1303
- setv(to_object, ['languageCode'], getv(from_object, ['language_code']))
1304
-
1305
- if getv(from_object, ['multi_speaker_voice_config']) is not None:
1306
- raise ValueError(
1307
- 'multi_speaker_voice_config parameter is not supported in Vertex AI.'
1308
- )
1309
-
1310
- return to_object
1311
-
1312
-
1313
1285
  def _Tool_to_mldev(
1314
1286
  from_object: Union[dict[str, Any], object],
1315
1287
  parent_object: Optional[dict[str, Any]] = None,
1316
1288
  ) -> dict[str, Any]:
1317
1289
  to_object: dict[str, Any] = {}
1318
- if getv(from_object, ['function_declarations']) is not None:
1319
- setv(
1320
- to_object,
1321
- ['functionDeclarations'],
1322
- [item for item in getv(from_object, ['function_declarations'])],
1323
- )
1324
-
1325
1290
  if getv(from_object, ['retrieval']) is not None:
1326
1291
  raise ValueError('retrieval parameter is not supported in Gemini API.')
1327
1292
 
1328
- if getv(from_object, ['google_search_retrieval']) is not None:
1329
- setv(
1330
- to_object,
1331
- ['googleSearchRetrieval'],
1332
- getv(from_object, ['google_search_retrieval']),
1333
- )
1334
-
1335
1293
  if getv(from_object, ['computer_use']) is not None:
1336
1294
  setv(to_object, ['computerUse'], getv(from_object, ['computer_use']))
1337
1295
 
@@ -1346,6 +1304,13 @@ def _Tool_to_mldev(
1346
1304
  'enterprise_web_search parameter is not supported in Gemini API.'
1347
1305
  )
1348
1306
 
1307
+ if getv(from_object, ['function_declarations']) is not None:
1308
+ setv(
1309
+ to_object,
1310
+ ['functionDeclarations'],
1311
+ [item for item in getv(from_object, ['function_declarations'])],
1312
+ )
1313
+
1349
1314
  if getv(from_object, ['google_maps']) is not None:
1350
1315
  setv(
1351
1316
  to_object,
@@ -1360,6 +1325,13 @@ def _Tool_to_mldev(
1360
1325
  _GoogleSearch_to_mldev(getv(from_object, ['google_search']), to_object),
1361
1326
  )
1362
1327
 
1328
+ if getv(from_object, ['google_search_retrieval']) is not None:
1329
+ setv(
1330
+ to_object,
1331
+ ['googleSearchRetrieval'],
1332
+ getv(from_object, ['google_search_retrieval']),
1333
+ )
1334
+
1363
1335
  if getv(from_object, ['url_context']) is not None:
1364
1336
  setv(to_object, ['urlContext'], getv(from_object, ['url_context']))
1365
1337
 
@@ -1371,26 +1343,9 @@ def _Tool_to_vertex(
1371
1343
  parent_object: Optional[dict[str, Any]] = None,
1372
1344
  ) -> dict[str, Any]:
1373
1345
  to_object: dict[str, Any] = {}
1374
- if getv(from_object, ['function_declarations']) is not None:
1375
- setv(
1376
- to_object,
1377
- ['functionDeclarations'],
1378
- [
1379
- _FunctionDeclaration_to_vertex(item, to_object)
1380
- for item in getv(from_object, ['function_declarations'])
1381
- ],
1382
- )
1383
-
1384
1346
  if getv(from_object, ['retrieval']) is not None:
1385
1347
  setv(to_object, ['retrieval'], getv(from_object, ['retrieval']))
1386
1348
 
1387
- if getv(from_object, ['google_search_retrieval']) is not None:
1388
- setv(
1389
- to_object,
1390
- ['googleSearchRetrieval'],
1391
- getv(from_object, ['google_search_retrieval']),
1392
- )
1393
-
1394
1349
  if getv(from_object, ['computer_use']) is not None:
1395
1350
  setv(to_object, ['computerUse'], getv(from_object, ['computer_use']))
1396
1351
 
@@ -1407,12 +1362,29 @@ def _Tool_to_vertex(
1407
1362
  getv(from_object, ['enterprise_web_search']),
1408
1363
  )
1409
1364
 
1365
+ if getv(from_object, ['function_declarations']) is not None:
1366
+ setv(
1367
+ to_object,
1368
+ ['functionDeclarations'],
1369
+ [
1370
+ _FunctionDeclaration_to_vertex(item, to_object)
1371
+ for item in getv(from_object, ['function_declarations'])
1372
+ ],
1373
+ )
1374
+
1410
1375
  if getv(from_object, ['google_maps']) is not None:
1411
1376
  setv(to_object, ['googleMaps'], getv(from_object, ['google_maps']))
1412
1377
 
1413
1378
  if getv(from_object, ['google_search']) is not None:
1414
1379
  setv(to_object, ['googleSearch'], getv(from_object, ['google_search']))
1415
1380
 
1381
+ if getv(from_object, ['google_search_retrieval']) is not None:
1382
+ setv(
1383
+ to_object,
1384
+ ['googleSearchRetrieval'],
1385
+ getv(from_object, ['google_search_retrieval']),
1386
+ )
1387
+
1416
1388
  if getv(from_object, ['url_context']) is not None:
1417
1389
  setv(to_object, ['urlContext'], getv(from_object, ['url_context']))
1418
1390
 
@@ -44,6 +44,7 @@ _GEMINI_STABLE_MODELS_TO_TOKENIZER_NAMES = {
44
44
  "gemini-2.5-flash-lite-preview-06-17": "gemma3",
45
45
  "gemini-2.0-flash-001": "gemma3",
46
46
  "gemini-2.0-flash-lite-001": "gemma3",
47
+ "gemini-3-pro-preview": "gemma3",
47
48
  }
48
49
 
49
50
 
@@ -474,23 +474,9 @@ def _Tool_to_mldev(
474
474
  parent_object: Optional[dict[str, Any]] = None,
475
475
  ) -> dict[str, Any]:
476
476
  to_object: dict[str, Any] = {}
477
- if getv(from_object, ['function_declarations']) is not None:
478
- setv(
479
- to_object,
480
- ['functionDeclarations'],
481
- [item for item in getv(from_object, ['function_declarations'])],
482
- )
483
-
484
477
  if getv(from_object, ['retrieval']) is not None:
485
478
  raise ValueError('retrieval parameter is not supported in Gemini API.')
486
479
 
487
- if getv(from_object, ['google_search_retrieval']) is not None:
488
- setv(
489
- to_object,
490
- ['googleSearchRetrieval'],
491
- getv(from_object, ['google_search_retrieval']),
492
- )
493
-
494
480
  if getv(from_object, ['computer_use']) is not None:
495
481
  setv(to_object, ['computerUse'], getv(from_object, ['computer_use']))
496
482
 
@@ -505,6 +491,13 @@ def _Tool_to_mldev(
505
491
  'enterprise_web_search parameter is not supported in Gemini API.'
506
492
  )
507
493
 
494
+ if getv(from_object, ['function_declarations']) is not None:
495
+ setv(
496
+ to_object,
497
+ ['functionDeclarations'],
498
+ [item for item in getv(from_object, ['function_declarations'])],
499
+ )
500
+
508
501
  if getv(from_object, ['google_maps']) is not None:
509
502
  setv(
510
503
  to_object,
@@ -519,6 +512,13 @@ def _Tool_to_mldev(
519
512
  _GoogleSearch_to_mldev(getv(from_object, ['google_search']), to_object),
520
513
  )
521
514
 
515
+ if getv(from_object, ['google_search_retrieval']) is not None:
516
+ setv(
517
+ to_object,
518
+ ['googleSearchRetrieval'],
519
+ getv(from_object, ['google_search_retrieval']),
520
+ )
521
+
522
522
  if getv(from_object, ['url_context']) is not None:
523
523
  setv(to_object, ['urlContext'], getv(from_object, ['url_context']))
524
524
 
google/genai/batches.py CHANGED
@@ -824,9 +824,6 @@ def _FunctionCallingConfig_to_mldev(
824
824
  parent_object: Optional[dict[str, Any]] = None,
825
825
  ) -> dict[str, Any]:
826
826
  to_object: dict[str, Any] = {}
827
- if getv(from_object, ['mode']) is not None:
828
- setv(to_object, ['mode'], getv(from_object, ['mode']))
829
-
830
827
  if getv(from_object, ['allowed_function_names']) is not None:
831
828
  setv(
832
829
  to_object,
@@ -834,6 +831,9 @@ def _FunctionCallingConfig_to_mldev(
834
831
  getv(from_object, ['allowed_function_names']),
835
832
  )
836
833
 
834
+ if getv(from_object, ['mode']) is not None:
835
+ setv(to_object, ['mode'], getv(from_object, ['mode']))
836
+
837
837
  if getv(from_object, ['stream_function_call_arguments']) is not None:
838
838
  raise ValueError(
839
839
  'stream_function_call_arguments parameter is not supported in Gemini'
@@ -1131,6 +1131,11 @@ def _ImageConfig_to_mldev(
1131
1131
  if getv(from_object, ['image_size']) is not None:
1132
1132
  setv(to_object, ['imageSize'], getv(from_object, ['image_size']))
1133
1133
 
1134
+ if getv(from_object, ['person_generation']) is not None:
1135
+ raise ValueError(
1136
+ 'person_generation parameter is not supported in Gemini API.'
1137
+ )
1138
+
1134
1139
  if getv(from_object, ['output_mime_type']) is not None:
1135
1140
  raise ValueError(
1136
1141
  'output_mime_type parameter is not supported in Gemini API.'
@@ -1415,6 +1420,11 @@ def _ToolConfig_to_mldev(
1415
1420
  parent_object: Optional[dict[str, Any]] = None,
1416
1421
  ) -> dict[str, Any]:
1417
1422
  to_object: dict[str, Any] = {}
1423
+ if getv(from_object, ['retrieval_config']) is not None:
1424
+ setv(
1425
+ to_object, ['retrievalConfig'], getv(from_object, ['retrieval_config'])
1426
+ )
1427
+
1418
1428
  if getv(from_object, ['function_calling_config']) is not None:
1419
1429
  setv(
1420
1430
  to_object,
@@ -1424,11 +1434,6 @@ def _ToolConfig_to_mldev(
1424
1434
  ),
1425
1435
  )
1426
1436
 
1427
- if getv(from_object, ['retrieval_config']) is not None:
1428
- setv(
1429
- to_object, ['retrievalConfig'], getv(from_object, ['retrieval_config'])
1430
- )
1431
-
1432
1437
  return to_object
1433
1438
 
1434
1439
 
@@ -1437,23 +1442,9 @@ def _Tool_to_mldev(
1437
1442
  parent_object: Optional[dict[str, Any]] = None,
1438
1443
  ) -> dict[str, Any]:
1439
1444
  to_object: dict[str, Any] = {}
1440
- if getv(from_object, ['function_declarations']) is not None:
1441
- setv(
1442
- to_object,
1443
- ['functionDeclarations'],
1444
- [item for item in getv(from_object, ['function_declarations'])],
1445
- )
1446
-
1447
1445
  if getv(from_object, ['retrieval']) is not None:
1448
1446
  raise ValueError('retrieval parameter is not supported in Gemini API.')
1449
1447
 
1450
- if getv(from_object, ['google_search_retrieval']) is not None:
1451
- setv(
1452
- to_object,
1453
- ['googleSearchRetrieval'],
1454
- getv(from_object, ['google_search_retrieval']),
1455
- )
1456
-
1457
1448
  if getv(from_object, ['computer_use']) is not None:
1458
1449
  setv(to_object, ['computerUse'], getv(from_object, ['computer_use']))
1459
1450
 
@@ -1468,6 +1459,13 @@ def _Tool_to_mldev(
1468
1459
  'enterprise_web_search parameter is not supported in Gemini API.'
1469
1460
  )
1470
1461
 
1462
+ if getv(from_object, ['function_declarations']) is not None:
1463
+ setv(
1464
+ to_object,
1465
+ ['functionDeclarations'],
1466
+ [item for item in getv(from_object, ['function_declarations'])],
1467
+ )
1468
+
1471
1469
  if getv(from_object, ['google_maps']) is not None:
1472
1470
  setv(
1473
1471
  to_object,
@@ -1482,6 +1480,13 @@ def _Tool_to_mldev(
1482
1480
  _GoogleSearch_to_mldev(getv(from_object, ['google_search']), to_object),
1483
1481
  )
1484
1482
 
1483
+ if getv(from_object, ['google_search_retrieval']) is not None:
1484
+ setv(
1485
+ to_object,
1486
+ ['googleSearchRetrieval'],
1487
+ getv(from_object, ['google_search_retrieval']),
1488
+ )
1489
+
1485
1490
  if getv(from_object, ['url_context']) is not None:
1486
1491
  setv(to_object, ['urlContext'], getv(from_object, ['url_context']))
1487
1492
 
google/genai/caches.py CHANGED
@@ -325,9 +325,6 @@ def _FunctionCallingConfig_to_mldev(
325
325
  parent_object: Optional[dict[str, Any]] = None,
326
326
  ) -> dict[str, Any]:
327
327
  to_object: dict[str, Any] = {}
328
- if getv(from_object, ['mode']) is not None:
329
- setv(to_object, ['mode'], getv(from_object, ['mode']))
330
-
331
328
  if getv(from_object, ['allowed_function_names']) is not None:
332
329
  setv(
333
330
  to_object,
@@ -335,6 +332,9 @@ def _FunctionCallingConfig_to_mldev(
335
332
  getv(from_object, ['allowed_function_names']),
336
333
  )
337
334
 
335
+ if getv(from_object, ['mode']) is not None:
336
+ setv(to_object, ['mode'], getv(from_object, ['mode']))
337
+
338
338
  if getv(from_object, ['stream_function_call_arguments']) is not None:
339
339
  raise ValueError(
340
340
  'stream_function_call_arguments parameter is not supported in Gemini'
@@ -349,9 +349,6 @@ def _FunctionDeclaration_to_vertex(
349
349
  parent_object: Optional[dict[str, Any]] = None,
350
350
  ) -> dict[str, Any]:
351
351
  to_object: dict[str, Any] = {}
352
- if getv(from_object, ['behavior']) is not None:
353
- raise ValueError('behavior parameter is not supported in Vertex AI.')
354
-
355
352
  if getv(from_object, ['description']) is not None:
356
353
  setv(to_object, ['description'], getv(from_object, ['description']))
357
354
 
@@ -378,6 +375,9 @@ def _FunctionDeclaration_to_vertex(
378
375
  getv(from_object, ['response_json_schema']),
379
376
  )
380
377
 
378
+ if getv(from_object, ['behavior']) is not None:
379
+ raise ValueError('behavior parameter is not supported in Vertex AI.')
380
+
381
381
  return to_object
382
382
 
383
383
 
@@ -634,6 +634,11 @@ def _ToolConfig_to_mldev(
634
634
  parent_object: Optional[dict[str, Any]] = None,
635
635
  ) -> dict[str, Any]:
636
636
  to_object: dict[str, Any] = {}
637
+ if getv(from_object, ['retrieval_config']) is not None:
638
+ setv(
639
+ to_object, ['retrievalConfig'], getv(from_object, ['retrieval_config'])
640
+ )
641
+
637
642
  if getv(from_object, ['function_calling_config']) is not None:
638
643
  setv(
639
644
  to_object,
@@ -643,11 +648,6 @@ def _ToolConfig_to_mldev(
643
648
  ),
644
649
  )
645
650
 
646
- if getv(from_object, ['retrieval_config']) is not None:
647
- setv(
648
- to_object, ['retrievalConfig'], getv(from_object, ['retrieval_config'])
649
- )
650
-
651
651
  return to_object
652
652
 
653
653
 
@@ -656,23 +656,9 @@ def _Tool_to_mldev(
656
656
  parent_object: Optional[dict[str, Any]] = None,
657
657
  ) -> dict[str, Any]:
658
658
  to_object: dict[str, Any] = {}
659
- if getv(from_object, ['function_declarations']) is not None:
660
- setv(
661
- to_object,
662
- ['functionDeclarations'],
663
- [item for item in getv(from_object, ['function_declarations'])],
664
- )
665
-
666
659
  if getv(from_object, ['retrieval']) is not None:
667
660
  raise ValueError('retrieval parameter is not supported in Gemini API.')
668
661
 
669
- if getv(from_object, ['google_search_retrieval']) is not None:
670
- setv(
671
- to_object,
672
- ['googleSearchRetrieval'],
673
- getv(from_object, ['google_search_retrieval']),
674
- )
675
-
676
662
  if getv(from_object, ['computer_use']) is not None:
677
663
  setv(to_object, ['computerUse'], getv(from_object, ['computer_use']))
678
664
 
@@ -687,6 +673,13 @@ def _Tool_to_mldev(
687
673
  'enterprise_web_search parameter is not supported in Gemini API.'
688
674
  )
689
675
 
676
+ if getv(from_object, ['function_declarations']) is not None:
677
+ setv(
678
+ to_object,
679
+ ['functionDeclarations'],
680
+ [item for item in getv(from_object, ['function_declarations'])],
681
+ )
682
+
690
683
  if getv(from_object, ['google_maps']) is not None:
691
684
  setv(
692
685
  to_object,
@@ -701,6 +694,13 @@ def _Tool_to_mldev(
701
694
  _GoogleSearch_to_mldev(getv(from_object, ['google_search']), to_object),
702
695
  )
703
696
 
697
+ if getv(from_object, ['google_search_retrieval']) is not None:
698
+ setv(
699
+ to_object,
700
+ ['googleSearchRetrieval'],
701
+ getv(from_object, ['google_search_retrieval']),
702
+ )
703
+
704
704
  if getv(from_object, ['url_context']) is not None:
705
705
  setv(to_object, ['urlContext'], getv(from_object, ['url_context']))
706
706
 
@@ -712,26 +712,9 @@ def _Tool_to_vertex(
712
712
  parent_object: Optional[dict[str, Any]] = None,
713
713
  ) -> dict[str, Any]:
714
714
  to_object: dict[str, Any] = {}
715
- if getv(from_object, ['function_declarations']) is not None:
716
- setv(
717
- to_object,
718
- ['functionDeclarations'],
719
- [
720
- _FunctionDeclaration_to_vertex(item, to_object)
721
- for item in getv(from_object, ['function_declarations'])
722
- ],
723
- )
724
-
725
715
  if getv(from_object, ['retrieval']) is not None:
726
716
  setv(to_object, ['retrieval'], getv(from_object, ['retrieval']))
727
717
 
728
- if getv(from_object, ['google_search_retrieval']) is not None:
729
- setv(
730
- to_object,
731
- ['googleSearchRetrieval'],
732
- getv(from_object, ['google_search_retrieval']),
733
- )
734
-
735
718
  if getv(from_object, ['computer_use']) is not None:
736
719
  setv(to_object, ['computerUse'], getv(from_object, ['computer_use']))
737
720
 
@@ -748,12 +731,29 @@ def _Tool_to_vertex(
748
731
  getv(from_object, ['enterprise_web_search']),
749
732
  )
750
733
 
734
+ if getv(from_object, ['function_declarations']) is not None:
735
+ setv(
736
+ to_object,
737
+ ['functionDeclarations'],
738
+ [
739
+ _FunctionDeclaration_to_vertex(item, to_object)
740
+ for item in getv(from_object, ['function_declarations'])
741
+ ],
742
+ )
743
+
751
744
  if getv(from_object, ['google_maps']) is not None:
752
745
  setv(to_object, ['googleMaps'], getv(from_object, ['google_maps']))
753
746
 
754
747
  if getv(from_object, ['google_search']) is not None:
755
748
  setv(to_object, ['googleSearch'], getv(from_object, ['google_search']))
756
749
 
750
+ if getv(from_object, ['google_search_retrieval']) is not None:
751
+ setv(
752
+ to_object,
753
+ ['googleSearchRetrieval'],
754
+ getv(from_object, ['google_search_retrieval']),
755
+ )
756
+
757
757
  if getv(from_object, ['url_context']) is not None:
758
758
  setv(to_object, ['urlContext'], getv(from_object, ['url_context']))
759
759
 
google/genai/chats.py CHANGED
@@ -35,8 +35,6 @@ def _validate_content(content: Content) -> bool:
35
35
  for part in content.parts:
36
36
  if part == Part():
37
37
  return False
38
- if part.text is not None and part.text == "":
39
- return False
40
38
  return True
41
39
 
42
40
 
google/genai/client.py CHANGED
@@ -16,7 +16,7 @@
16
16
  import asyncio
17
17
  import os
18
18
  from types import TracebackType
19
- from typing import Optional, Union
19
+ from typing import Optional, Union, cast
20
20
 
21
21
  import google.auth
22
22
  import pydantic
@@ -116,6 +116,7 @@ class AsyncClient:
116
116
  self._nextgen_client_instance = AsyncGeminiNextGenAPIClient(
117
117
  base_url=http_opts.base_url,
118
118
  api_key=self._api_client.api_key,
119
+ api_version=http_opts.api_version,
119
120
  default_headers=http_opts.headers,
120
121
  http_client=http_client,
121
122
  # uSDk expects ms, nextgen uses a httpx Timeout -> expects seconds.
@@ -485,6 +486,7 @@ class Client:
485
486
  self._nextgen_client_instance = GeminiNextGenAPIClient(
486
487
  base_url=http_opts.base_url,
487
488
  api_key=self._api_client.api_key,
489
+ api_version=http_opts.api_version,
488
490
  default_headers=http_opts.headers,
489
491
  http_client=self._api_client._httpx_client,
490
492
  # uSDk expects ms, nextgen uses a httpx Timeout -> expects seconds.