google-genai 1.14.0__py3-none-any.whl → 1.16.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/models.py CHANGED
@@ -21,7 +21,9 @@ from urllib.parse import urlencode
21
21
  from . import _api_module
22
22
  from . import _common
23
23
  from . import _extra_utils
24
+ from . import _mcp_utils
24
25
  from . import _transformers as t
26
+ from . import errors
25
27
  from . import types
26
28
  from ._api_client import BaseApiClient
27
29
  from ._common import get_value_by_path as getv
@@ -31,6 +33,42 @@ from .pagers import AsyncPager, Pager
31
33
  logger = logging.getLogger('google_genai.models')
32
34
 
33
35
 
36
+ def _VideoMetadata_to_mldev(
37
+ api_client: BaseApiClient,
38
+ from_object: Union[dict[str, Any], object],
39
+ parent_object: Optional[dict[str, Any]] = None,
40
+ ) -> dict[str, Any]:
41
+ to_object: dict[str, Any] = {}
42
+ if getv(from_object, ['fps']) is not None:
43
+ setv(to_object, ['fps'], getv(from_object, ['fps']))
44
+
45
+ if getv(from_object, ['end_offset']) is not None:
46
+ setv(to_object, ['endOffset'], getv(from_object, ['end_offset']))
47
+
48
+ if getv(from_object, ['start_offset']) is not None:
49
+ setv(to_object, ['startOffset'], getv(from_object, ['start_offset']))
50
+
51
+ return to_object
52
+
53
+
54
+ def _Blob_to_mldev(
55
+ api_client: BaseApiClient,
56
+ from_object: Union[dict[str, Any], object],
57
+ parent_object: Optional[dict[str, Any]] = None,
58
+ ) -> dict[str, Any]:
59
+ to_object: dict[str, Any] = {}
60
+ if getv(from_object, ['display_name']) is not None:
61
+ raise ValueError('display_name parameter is not supported in Gemini API.')
62
+
63
+ if getv(from_object, ['data']) is not None:
64
+ setv(to_object, ['data'], getv(from_object, ['data']))
65
+
66
+ if getv(from_object, ['mime_type']) is not None:
67
+ setv(to_object, ['mimeType'], getv(from_object, ['mime_type']))
68
+
69
+ return to_object
70
+
71
+
34
72
  def _Part_to_mldev(
35
73
  api_client: BaseApiClient,
36
74
  from_object: Union[dict[str, Any], object],
@@ -38,11 +76,26 @@ def _Part_to_mldev(
38
76
  ) -> dict[str, Any]:
39
77
  to_object: dict[str, Any] = {}
40
78
  if getv(from_object, ['video_metadata']) is not None:
41
- raise ValueError('video_metadata parameter is not supported in Gemini API.')
79
+ setv(
80
+ to_object,
81
+ ['videoMetadata'],
82
+ _VideoMetadata_to_mldev(
83
+ api_client, getv(from_object, ['video_metadata']), to_object
84
+ ),
85
+ )
42
86
 
43
87
  if getv(from_object, ['thought']) is not None:
44
88
  setv(to_object, ['thought'], getv(from_object, ['thought']))
45
89
 
90
+ if getv(from_object, ['inline_data']) is not None:
91
+ setv(
92
+ to_object,
93
+ ['inlineData'],
94
+ _Blob_to_mldev(
95
+ api_client, getv(from_object, ['inline_data']), to_object
96
+ ),
97
+ )
98
+
46
99
  if getv(from_object, ['code_execution_result']) is not None:
47
100
  setv(
48
101
  to_object,
@@ -66,9 +119,6 @@ def _Part_to_mldev(
66
119
  getv(from_object, ['function_response']),
67
120
  )
68
121
 
69
- if getv(from_object, ['inline_data']) is not None:
70
- setv(to_object, ['inlineData'], getv(from_object, ['inline_data']))
71
-
72
122
  if getv(from_object, ['text']) is not None:
73
123
  setv(to_object, ['text'], getv(from_object, ['text']))
74
124
 
@@ -129,12 +179,59 @@ def _SafetySetting_to_mldev(
129
179
  return to_object
130
180
 
131
181
 
182
+ def _FunctionDeclaration_to_mldev(
183
+ api_client: BaseApiClient,
184
+ from_object: Union[dict[str, Any], object],
185
+ parent_object: Optional[dict[str, Any]] = None,
186
+ ) -> dict[str, Any]:
187
+ to_object: dict[str, Any] = {}
188
+ if getv(from_object, ['behavior']) is not None:
189
+ setv(to_object, ['behavior'], getv(from_object, ['behavior']))
190
+
191
+ if getv(from_object, ['description']) is not None:
192
+ setv(to_object, ['description'], getv(from_object, ['description']))
193
+
194
+ if getv(from_object, ['name']) is not None:
195
+ setv(to_object, ['name'], getv(from_object, ['name']))
196
+
197
+ if getv(from_object, ['parameters']) is not None:
198
+ setv(to_object, ['parameters'], getv(from_object, ['parameters']))
199
+
200
+ if getv(from_object, ['response']) is not None:
201
+ setv(to_object, ['response'], getv(from_object, ['response']))
202
+
203
+ return to_object
204
+
205
+
206
+ def _Interval_to_mldev(
207
+ api_client: BaseApiClient,
208
+ from_object: Union[dict[str, Any], object],
209
+ parent_object: Optional[dict[str, Any]] = None,
210
+ ) -> dict[str, Any]:
211
+ to_object: dict[str, Any] = {}
212
+ if getv(from_object, ['start_time']) is not None:
213
+ setv(to_object, ['startTime'], getv(from_object, ['start_time']))
214
+
215
+ if getv(from_object, ['end_time']) is not None:
216
+ setv(to_object, ['endTime'], getv(from_object, ['end_time']))
217
+
218
+ return to_object
219
+
220
+
132
221
  def _GoogleSearch_to_mldev(
133
222
  api_client: BaseApiClient,
134
223
  from_object: Union[dict[str, Any], object],
135
224
  parent_object: Optional[dict[str, Any]] = None,
136
225
  ) -> dict[str, Any]:
137
226
  to_object: dict[str, Any] = {}
227
+ if getv(from_object, ['time_range_filter']) is not None:
228
+ setv(
229
+ to_object,
230
+ ['timeRangeFilter'],
231
+ _Interval_to_mldev(
232
+ api_client, getv(from_object, ['time_range_filter']), to_object
233
+ ),
234
+ )
138
235
 
139
236
  return to_object
140
237
 
@@ -247,12 +344,32 @@ def _GoogleMaps_to_mldev(
247
344
  return to_object
248
345
 
249
346
 
347
+ def _UrlContext_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
+
354
+ return to_object
355
+
356
+
250
357
  def _Tool_to_mldev(
251
358
  api_client: BaseApiClient,
252
359
  from_object: Union[dict[str, Any], object],
253
360
  parent_object: Optional[dict[str, Any]] = None,
254
361
  ) -> dict[str, Any]:
255
362
  to_object: dict[str, Any] = {}
363
+ if getv(from_object, ['function_declarations']) is not None:
364
+ setv(
365
+ to_object,
366
+ ['functionDeclarations'],
367
+ [
368
+ _FunctionDeclaration_to_mldev(api_client, item, to_object)
369
+ for item in getv(from_object, ['function_declarations'])
370
+ ],
371
+ )
372
+
256
373
  if getv(from_object, ['retrieval']) is not None:
257
374
  raise ValueError('retrieval parameter is not supported in Gemini API.')
258
375
 
@@ -284,16 +401,18 @@ def _Tool_to_mldev(
284
401
  if getv(from_object, ['google_maps']) is not None:
285
402
  raise ValueError('google_maps parameter is not supported in Gemini API.')
286
403
 
287
- if getv(from_object, ['code_execution']) is not None:
288
- setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
289
-
290
- if getv(from_object, ['function_declarations']) is not None:
404
+ if getv(from_object, ['url_context']) is not None:
291
405
  setv(
292
406
  to_object,
293
- ['functionDeclarations'],
294
- getv(from_object, ['function_declarations']),
407
+ ['urlContext'],
408
+ _UrlContext_to_mldev(
409
+ api_client, getv(from_object, ['url_context']), to_object
410
+ ),
295
411
  )
296
412
 
413
+ if getv(from_object, ['code_execution']) is not None:
414
+ setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
415
+
297
416
  return to_object
298
417
 
299
418
 
@@ -323,10 +442,10 @@ def _LatLng_to_mldev(
323
442
  ) -> dict[str, Any]:
324
443
  to_object: dict[str, Any] = {}
325
444
  if getv(from_object, ['latitude']) is not None:
326
- raise ValueError('latitude parameter is not supported in Gemini API.')
445
+ setv(to_object, ['latitude'], getv(from_object, ['latitude']))
327
446
 
328
447
  if getv(from_object, ['longitude']) is not None:
329
- raise ValueError('longitude parameter is not supported in Gemini API.')
448
+ setv(to_object, ['longitude'], getv(from_object, ['longitude']))
330
449
 
331
450
  return to_object
332
451
 
@@ -338,7 +457,11 @@ def _RetrievalConfig_to_mldev(
338
457
  ) -> dict[str, Any]:
339
458
  to_object: dict[str, Any] = {}
340
459
  if getv(from_object, ['lat_lng']) is not None:
341
- raise ValueError('lat_lng parameter is not supported in Gemini API.')
460
+ setv(
461
+ to_object,
462
+ ['latLng'],
463
+ _LatLng_to_mldev(api_client, getv(from_object, ['lat_lng']), to_object),
464
+ )
342
465
 
343
466
  return to_object
344
467
 
@@ -361,8 +484,12 @@ def _ToolConfig_to_mldev(
361
484
  )
362
485
 
363
486
  if getv(from_object, ['retrieval_config']) is not None:
364
- raise ValueError(
365
- 'retrieval_config parameter is not supported in Gemini API.'
487
+ setv(
488
+ to_object,
489
+ ['retrievalConfig'],
490
+ _RetrievalConfig_to_mldev(
491
+ api_client, getv(from_object, ['retrieval_config']), to_object
492
+ ),
366
493
  )
367
494
 
368
495
  return to_object
@@ -398,6 +525,46 @@ def _VoiceConfig_to_mldev(
398
525
  return to_object
399
526
 
400
527
 
528
+ def _SpeakerVoiceConfig_to_mldev(
529
+ api_client: BaseApiClient,
530
+ from_object: Union[dict[str, Any], object],
531
+ parent_object: Optional[dict[str, Any]] = None,
532
+ ) -> dict[str, Any]:
533
+ to_object: dict[str, Any] = {}
534
+ if getv(from_object, ['speaker']) is not None:
535
+ setv(to_object, ['speaker'], getv(from_object, ['speaker']))
536
+
537
+ if getv(from_object, ['voice_config']) is not None:
538
+ setv(
539
+ to_object,
540
+ ['voiceConfig'],
541
+ _VoiceConfig_to_mldev(
542
+ api_client, getv(from_object, ['voice_config']), to_object
543
+ ),
544
+ )
545
+
546
+ return to_object
547
+
548
+
549
+ def _MultiSpeakerVoiceConfig_to_mldev(
550
+ api_client: BaseApiClient,
551
+ from_object: Union[dict[str, Any], object],
552
+ parent_object: Optional[dict[str, Any]] = None,
553
+ ) -> dict[str, Any]:
554
+ to_object: dict[str, Any] = {}
555
+ if getv(from_object, ['speaker_voice_configs']) is not None:
556
+ setv(
557
+ to_object,
558
+ ['speakerVoiceConfigs'],
559
+ [
560
+ _SpeakerVoiceConfig_to_mldev(api_client, item, to_object)
561
+ for item in getv(from_object, ['speaker_voice_configs'])
562
+ ],
563
+ )
564
+
565
+ return to_object
566
+
567
+
401
568
  def _SpeechConfig_to_mldev(
402
569
  api_client: BaseApiClient,
403
570
  from_object: Union[dict[str, Any], object],
@@ -413,6 +580,17 @@ def _SpeechConfig_to_mldev(
413
580
  ),
414
581
  )
415
582
 
583
+ if getv(from_object, ['multi_speaker_voice_config']) is not None:
584
+ setv(
585
+ to_object,
586
+ ['multiSpeakerVoiceConfig'],
587
+ _MultiSpeakerVoiceConfig_to_mldev(
588
+ api_client,
589
+ getv(from_object, ['multi_speaker_voice_config']),
590
+ to_object,
591
+ ),
592
+ )
593
+
416
594
  if getv(from_object, ['language_code']) is not None:
417
595
  setv(to_object, ['languageCode'], getv(from_object, ['language_code']))
418
596
 
@@ -922,6 +1100,13 @@ def _UpdateModelConfig_to_mldev(
922
1100
  if getv(from_object, ['description']) is not None:
923
1101
  setv(parent_object, ['description'], getv(from_object, ['description']))
924
1102
 
1103
+ if getv(from_object, ['default_checkpoint_id']) is not None:
1104
+ setv(
1105
+ parent_object,
1106
+ ['defaultCheckpointId'],
1107
+ getv(from_object, ['default_checkpoint_id']),
1108
+ )
1109
+
925
1110
  return to_object
926
1111
 
927
1112
 
@@ -1149,6 +1334,42 @@ def _GenerateVideosParameters_to_mldev(
1149
1334
  return to_object
1150
1335
 
1151
1336
 
1337
+ def _VideoMetadata_to_vertex(
1338
+ api_client: BaseApiClient,
1339
+ from_object: Union[dict[str, Any], object],
1340
+ parent_object: Optional[dict[str, Any]] = None,
1341
+ ) -> dict[str, Any]:
1342
+ to_object: dict[str, Any] = {}
1343
+ if getv(from_object, ['fps']) is not None:
1344
+ setv(to_object, ['fps'], getv(from_object, ['fps']))
1345
+
1346
+ if getv(from_object, ['end_offset']) is not None:
1347
+ setv(to_object, ['endOffset'], getv(from_object, ['end_offset']))
1348
+
1349
+ if getv(from_object, ['start_offset']) is not None:
1350
+ setv(to_object, ['startOffset'], getv(from_object, ['start_offset']))
1351
+
1352
+ return to_object
1353
+
1354
+
1355
+ def _Blob_to_vertex(
1356
+ api_client: BaseApiClient,
1357
+ from_object: Union[dict[str, Any], object],
1358
+ parent_object: Optional[dict[str, Any]] = None,
1359
+ ) -> dict[str, Any]:
1360
+ to_object: dict[str, Any] = {}
1361
+ if getv(from_object, ['display_name']) is not None:
1362
+ setv(to_object, ['displayName'], getv(from_object, ['display_name']))
1363
+
1364
+ if getv(from_object, ['data']) is not None:
1365
+ setv(to_object, ['data'], getv(from_object, ['data']))
1366
+
1367
+ if getv(from_object, ['mime_type']) is not None:
1368
+ setv(to_object, ['mimeType'], getv(from_object, ['mime_type']))
1369
+
1370
+ return to_object
1371
+
1372
+
1152
1373
  def _Part_to_vertex(
1153
1374
  api_client: BaseApiClient,
1154
1375
  from_object: Union[dict[str, Any], object],
@@ -1156,11 +1377,26 @@ def _Part_to_vertex(
1156
1377
  ) -> dict[str, Any]:
1157
1378
  to_object: dict[str, Any] = {}
1158
1379
  if getv(from_object, ['video_metadata']) is not None:
1159
- setv(to_object, ['videoMetadata'], getv(from_object, ['video_metadata']))
1380
+ setv(
1381
+ to_object,
1382
+ ['videoMetadata'],
1383
+ _VideoMetadata_to_vertex(
1384
+ api_client, getv(from_object, ['video_metadata']), to_object
1385
+ ),
1386
+ )
1160
1387
 
1161
1388
  if getv(from_object, ['thought']) is not None:
1162
1389
  setv(to_object, ['thought'], getv(from_object, ['thought']))
1163
1390
 
1391
+ if getv(from_object, ['inline_data']) is not None:
1392
+ setv(
1393
+ to_object,
1394
+ ['inlineData'],
1395
+ _Blob_to_vertex(
1396
+ api_client, getv(from_object, ['inline_data']), to_object
1397
+ ),
1398
+ )
1399
+
1164
1400
  if getv(from_object, ['code_execution_result']) is not None:
1165
1401
  setv(
1166
1402
  to_object,
@@ -1184,9 +1420,6 @@ def _Part_to_vertex(
1184
1420
  getv(from_object, ['function_response']),
1185
1421
  )
1186
1422
 
1187
- if getv(from_object, ['inline_data']) is not None:
1188
- setv(to_object, ['inlineData'], getv(from_object, ['inline_data']))
1189
-
1190
1423
  if getv(from_object, ['text']) is not None:
1191
1424
  setv(to_object, ['text'], getv(from_object, ['text']))
1192
1425
 
@@ -1249,12 +1482,59 @@ def _SafetySetting_to_vertex(
1249
1482
  return to_object
1250
1483
 
1251
1484
 
1485
+ def _FunctionDeclaration_to_vertex(
1486
+ api_client: BaseApiClient,
1487
+ from_object: Union[dict[str, Any], object],
1488
+ parent_object: Optional[dict[str, Any]] = None,
1489
+ ) -> dict[str, Any]:
1490
+ to_object: dict[str, Any] = {}
1491
+ if getv(from_object, ['behavior']) is not None:
1492
+ raise ValueError('behavior parameter is not supported in Vertex AI.')
1493
+
1494
+ if getv(from_object, ['description']) is not None:
1495
+ setv(to_object, ['description'], getv(from_object, ['description']))
1496
+
1497
+ if getv(from_object, ['name']) is not None:
1498
+ setv(to_object, ['name'], getv(from_object, ['name']))
1499
+
1500
+ if getv(from_object, ['parameters']) is not None:
1501
+ setv(to_object, ['parameters'], getv(from_object, ['parameters']))
1502
+
1503
+ if getv(from_object, ['response']) is not None:
1504
+ setv(to_object, ['response'], getv(from_object, ['response']))
1505
+
1506
+ return to_object
1507
+
1508
+
1509
+ def _Interval_to_vertex(
1510
+ api_client: BaseApiClient,
1511
+ from_object: Union[dict[str, Any], object],
1512
+ parent_object: Optional[dict[str, Any]] = None,
1513
+ ) -> dict[str, Any]:
1514
+ to_object: dict[str, Any] = {}
1515
+ if getv(from_object, ['start_time']) is not None:
1516
+ setv(to_object, ['startTime'], getv(from_object, ['start_time']))
1517
+
1518
+ if getv(from_object, ['end_time']) is not None:
1519
+ setv(to_object, ['endTime'], getv(from_object, ['end_time']))
1520
+
1521
+ return to_object
1522
+
1523
+
1252
1524
  def _GoogleSearch_to_vertex(
1253
1525
  api_client: BaseApiClient,
1254
1526
  from_object: Union[dict[str, Any], object],
1255
1527
  parent_object: Optional[dict[str, Any]] = None,
1256
1528
  ) -> dict[str, Any]:
1257
1529
  to_object: dict[str, Any] = {}
1530
+ if getv(from_object, ['time_range_filter']) is not None:
1531
+ setv(
1532
+ to_object,
1533
+ ['timeRangeFilter'],
1534
+ _Interval_to_vertex(
1535
+ api_client, getv(from_object, ['time_range_filter']), to_object
1536
+ ),
1537
+ )
1258
1538
 
1259
1539
  return to_object
1260
1540
 
@@ -1379,12 +1659,32 @@ def _GoogleMaps_to_vertex(
1379
1659
  return to_object
1380
1660
 
1381
1661
 
1662
+ def _UrlContext_to_vertex(
1663
+ api_client: BaseApiClient,
1664
+ from_object: Union[dict[str, Any], object],
1665
+ parent_object: Optional[dict[str, Any]] = None,
1666
+ ) -> dict[str, Any]:
1667
+ to_object: dict[str, Any] = {}
1668
+
1669
+ return to_object
1670
+
1671
+
1382
1672
  def _Tool_to_vertex(
1383
1673
  api_client: BaseApiClient,
1384
1674
  from_object: Union[dict[str, Any], object],
1385
1675
  parent_object: Optional[dict[str, Any]] = None,
1386
1676
  ) -> dict[str, Any]:
1387
1677
  to_object: dict[str, Any] = {}
1678
+ if getv(from_object, ['function_declarations']) is not None:
1679
+ setv(
1680
+ to_object,
1681
+ ['functionDeclarations'],
1682
+ [
1683
+ _FunctionDeclaration_to_vertex(api_client, item, to_object)
1684
+ for item in getv(from_object, ['function_declarations'])
1685
+ ],
1686
+ )
1687
+
1388
1688
  if getv(from_object, ['retrieval']) is not None:
1389
1689
  setv(to_object, ['retrieval'], getv(from_object, ['retrieval']))
1390
1690
 
@@ -1426,16 +1726,12 @@ def _Tool_to_vertex(
1426
1726
  ),
1427
1727
  )
1428
1728
 
1729
+ if getv(from_object, ['url_context']) is not None:
1730
+ raise ValueError('url_context parameter is not supported in Vertex AI.')
1731
+
1429
1732
  if getv(from_object, ['code_execution']) is not None:
1430
1733
  setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
1431
1734
 
1432
- if getv(from_object, ['function_declarations']) is not None:
1433
- setv(
1434
- to_object,
1435
- ['functionDeclarations'],
1436
- getv(from_object, ['function_declarations']),
1437
- )
1438
-
1439
1735
  return to_object
1440
1736
 
1441
1737
 
@@ -1550,6 +1846,35 @@ def _VoiceConfig_to_vertex(
1550
1846
  return to_object
1551
1847
 
1552
1848
 
1849
+ def _SpeakerVoiceConfig_to_vertex(
1850
+ api_client: BaseApiClient,
1851
+ from_object: Union[dict[str, Any], object],
1852
+ parent_object: Optional[dict[str, Any]] = None,
1853
+ ) -> dict[str, Any]:
1854
+ to_object: dict[str, Any] = {}
1855
+ if getv(from_object, ['speaker']) is not None:
1856
+ raise ValueError('speaker parameter is not supported in Vertex AI.')
1857
+
1858
+ if getv(from_object, ['voice_config']) is not None:
1859
+ raise ValueError('voice_config parameter is not supported in Vertex AI.')
1860
+
1861
+ return to_object
1862
+
1863
+
1864
+ def _MultiSpeakerVoiceConfig_to_vertex(
1865
+ api_client: BaseApiClient,
1866
+ from_object: Union[dict[str, Any], object],
1867
+ parent_object: Optional[dict[str, Any]] = None,
1868
+ ) -> dict[str, Any]:
1869
+ to_object: dict[str, Any] = {}
1870
+ if getv(from_object, ['speaker_voice_configs']) is not None:
1871
+ raise ValueError(
1872
+ 'speaker_voice_configs parameter is not supported in Vertex AI.'
1873
+ )
1874
+
1875
+ return to_object
1876
+
1877
+
1553
1878
  def _SpeechConfig_to_vertex(
1554
1879
  api_client: BaseApiClient,
1555
1880
  from_object: Union[dict[str, Any], object],
@@ -1565,6 +1890,11 @@ def _SpeechConfig_to_vertex(
1565
1890
  ),
1566
1891
  )
1567
1892
 
1893
+ if getv(from_object, ['multi_speaker_voice_config']) is not None:
1894
+ raise ValueError(
1895
+ 'multi_speaker_voice_config parameter is not supported in Vertex AI.'
1896
+ )
1897
+
1568
1898
  if getv(from_object, ['language_code']) is not None:
1569
1899
  setv(to_object, ['languageCode'], getv(from_object, ['language_code']))
1570
1900
 
@@ -2472,6 +2802,13 @@ def _UpdateModelConfig_to_vertex(
2472
2802
  if getv(from_object, ['description']) is not None:
2473
2803
  setv(parent_object, ['description'], getv(from_object, ['description']))
2474
2804
 
2805
+ if getv(from_object, ['default_checkpoint_id']) is not None:
2806
+ setv(
2807
+ parent_object,
2808
+ ['defaultCheckpointId'],
2809
+ getv(from_object, ['default_checkpoint_id']),
2810
+ )
2811
+
2475
2812
  return to_object
2476
2813
 
2477
2814
 
@@ -2759,16 +3096,72 @@ def _PersonGeneration_to_mldev_enum_validate(enum_value: Any) -> None:
2759
3096
  raise ValueError(f'{enum_value} enum value is not supported in Gemini API.')
2760
3097
 
2761
3098
 
3099
+ def _Behavior_to_vertex_enum_validate(enum_value: Any) -> None:
3100
+ if enum_value in set(['UNSPECIFIED', 'BLOCKING', 'NON_BLOCKING']):
3101
+ raise ValueError(f'{enum_value} enum value is not supported in Vertex AI.')
3102
+
3103
+
3104
+ def _VideoMetadata_from_mldev(
3105
+ api_client: BaseApiClient,
3106
+ from_object: Union[dict[str, Any], object],
3107
+ parent_object: Optional[dict[str, Any]] = None,
3108
+ ) -> dict[str, Any]:
3109
+ to_object: dict[str, Any] = {}
3110
+ if getv(from_object, ['fps']) is not None:
3111
+ setv(to_object, ['fps'], getv(from_object, ['fps']))
3112
+
3113
+ if getv(from_object, ['endOffset']) is not None:
3114
+ setv(to_object, ['end_offset'], getv(from_object, ['endOffset']))
3115
+
3116
+ if getv(from_object, ['startOffset']) is not None:
3117
+ setv(to_object, ['start_offset'], getv(from_object, ['startOffset']))
3118
+
3119
+ return to_object
3120
+
3121
+
3122
+ def _Blob_from_mldev(
3123
+ api_client: BaseApiClient,
3124
+ from_object: Union[dict[str, Any], object],
3125
+ parent_object: Optional[dict[str, Any]] = None,
3126
+ ) -> dict[str, Any]:
3127
+ to_object: dict[str, Any] = {}
3128
+
3129
+ if getv(from_object, ['data']) is not None:
3130
+ setv(to_object, ['data'], getv(from_object, ['data']))
3131
+
3132
+ if getv(from_object, ['mimeType']) is not None:
3133
+ setv(to_object, ['mime_type'], getv(from_object, ['mimeType']))
3134
+
3135
+ return to_object
3136
+
3137
+
2762
3138
  def _Part_from_mldev(
2763
3139
  api_client: BaseApiClient,
2764
3140
  from_object: Union[dict[str, Any], object],
2765
3141
  parent_object: Optional[dict[str, Any]] = None,
2766
3142
  ) -> dict[str, Any]:
2767
3143
  to_object: dict[str, Any] = {}
3144
+ if getv(from_object, ['videoMetadata']) is not None:
3145
+ setv(
3146
+ to_object,
3147
+ ['video_metadata'],
3148
+ _VideoMetadata_from_mldev(
3149
+ api_client, getv(from_object, ['videoMetadata']), to_object
3150
+ ),
3151
+ )
2768
3152
 
2769
3153
  if getv(from_object, ['thought']) is not None:
2770
3154
  setv(to_object, ['thought'], getv(from_object, ['thought']))
2771
3155
 
3156
+ if getv(from_object, ['inlineData']) is not None:
3157
+ setv(
3158
+ to_object,
3159
+ ['inline_data'],
3160
+ _Blob_from_mldev(
3161
+ api_client, getv(from_object, ['inlineData']), to_object
3162
+ ),
3163
+ )
3164
+
2772
3165
  if getv(from_object, ['codeExecutionResult']) is not None:
2773
3166
  setv(
2774
3167
  to_object,
@@ -2792,9 +3185,6 @@ def _Part_from_mldev(
2792
3185
  getv(from_object, ['functionResponse']),
2793
3186
  )
2794
3187
 
2795
- if getv(from_object, ['inlineData']) is not None:
2796
- setv(to_object, ['inline_data'], getv(from_object, ['inlineData']))
2797
-
2798
3188
  if getv(from_object, ['text']) is not None:
2799
3189
  setv(to_object, ['text'], getv(from_object, ['text']))
2800
3190
 
@@ -2835,6 +3225,44 @@ def _CitationMetadata_from_mldev(
2835
3225
  return to_object
2836
3226
 
2837
3227
 
3228
+ def _UrlMetadata_from_mldev(
3229
+ api_client: BaseApiClient,
3230
+ from_object: Union[dict[str, Any], object],
3231
+ parent_object: Optional[dict[str, Any]] = None,
3232
+ ) -> dict[str, Any]:
3233
+ to_object: dict[str, Any] = {}
3234
+ if getv(from_object, ['retrievedUrl']) is not None:
3235
+ setv(to_object, ['retrieved_url'], getv(from_object, ['retrievedUrl']))
3236
+
3237
+ if getv(from_object, ['urlRetrievalStatus']) is not None:
3238
+ setv(
3239
+ to_object,
3240
+ ['url_retrieval_status'],
3241
+ getv(from_object, ['urlRetrievalStatus']),
3242
+ )
3243
+
3244
+ return to_object
3245
+
3246
+
3247
+ def _UrlContextMetadata_from_mldev(
3248
+ api_client: BaseApiClient,
3249
+ from_object: Union[dict[str, Any], object],
3250
+ parent_object: Optional[dict[str, Any]] = None,
3251
+ ) -> dict[str, Any]:
3252
+ to_object: dict[str, Any] = {}
3253
+ if getv(from_object, ['urlMetadata']) is not None:
3254
+ setv(
3255
+ to_object,
3256
+ ['url_metadata'],
3257
+ [
3258
+ _UrlMetadata_from_mldev(api_client, item, to_object)
3259
+ for item in getv(from_object, ['urlMetadata'])
3260
+ ],
3261
+ )
3262
+
3263
+ return to_object
3264
+
3265
+
2838
3266
  def _Candidate_from_mldev(
2839
3267
  api_client: BaseApiClient,
2840
3268
  from_object: Union[dict[str, Any], object],
@@ -2865,6 +3293,15 @@ def _Candidate_from_mldev(
2865
3293
  if getv(from_object, ['finishReason']) is not None:
2866
3294
  setv(to_object, ['finish_reason'], getv(from_object, ['finishReason']))
2867
3295
 
3296
+ if getv(from_object, ['urlContextMetadata']) is not None:
3297
+ setv(
3298
+ to_object,
3299
+ ['url_context_metadata'],
3300
+ _UrlContextMetadata_from_mldev(
3301
+ api_client, getv(from_object, ['urlContextMetadata']), to_object
3302
+ ),
3303
+ )
3304
+
2868
3305
  if getv(from_object, ['avgLogprobs']) is not None:
2869
3306
  setv(to_object, ['avg_logprobs'], getv(from_object, ['avgLogprobs']))
2870
3307
 
@@ -3109,6 +3546,16 @@ def _TunedModelInfo_from_mldev(
3109
3546
  return to_object
3110
3547
 
3111
3548
 
3549
+ def _Checkpoint_from_mldev(
3550
+ api_client: BaseApiClient,
3551
+ from_object: Union[dict[str, Any], object],
3552
+ parent_object: Optional[dict[str, Any]] = None,
3553
+ ) -> dict[str, Any]:
3554
+ to_object: dict[str, Any] = {}
3555
+
3556
+ return to_object
3557
+
3558
+
3112
3559
  def _Model_from_mldev(
3113
3560
  api_client: BaseApiClient,
3114
3561
  from_object: Union[dict[str, Any], object],
@@ -3325,6 +3772,42 @@ def _GenerateVideosOperation_from_mldev(
3325
3772
  return to_object
3326
3773
 
3327
3774
 
3775
+ def _VideoMetadata_from_vertex(
3776
+ api_client: BaseApiClient,
3777
+ from_object: Union[dict[str, Any], object],
3778
+ parent_object: Optional[dict[str, Any]] = None,
3779
+ ) -> dict[str, Any]:
3780
+ to_object: dict[str, Any] = {}
3781
+ if getv(from_object, ['fps']) is not None:
3782
+ setv(to_object, ['fps'], getv(from_object, ['fps']))
3783
+
3784
+ if getv(from_object, ['endOffset']) is not None:
3785
+ setv(to_object, ['end_offset'], getv(from_object, ['endOffset']))
3786
+
3787
+ if getv(from_object, ['startOffset']) is not None:
3788
+ setv(to_object, ['start_offset'], getv(from_object, ['startOffset']))
3789
+
3790
+ return to_object
3791
+
3792
+
3793
+ def _Blob_from_vertex(
3794
+ api_client: BaseApiClient,
3795
+ from_object: Union[dict[str, Any], object],
3796
+ parent_object: Optional[dict[str, Any]] = None,
3797
+ ) -> dict[str, Any]:
3798
+ to_object: dict[str, Any] = {}
3799
+ if getv(from_object, ['displayName']) is not None:
3800
+ setv(to_object, ['display_name'], getv(from_object, ['displayName']))
3801
+
3802
+ if getv(from_object, ['data']) is not None:
3803
+ setv(to_object, ['data'], getv(from_object, ['data']))
3804
+
3805
+ if getv(from_object, ['mimeType']) is not None:
3806
+ setv(to_object, ['mime_type'], getv(from_object, ['mimeType']))
3807
+
3808
+ return to_object
3809
+
3810
+
3328
3811
  def _Part_from_vertex(
3329
3812
  api_client: BaseApiClient,
3330
3813
  from_object: Union[dict[str, Any], object],
@@ -3332,11 +3815,26 @@ def _Part_from_vertex(
3332
3815
  ) -> dict[str, Any]:
3333
3816
  to_object: dict[str, Any] = {}
3334
3817
  if getv(from_object, ['videoMetadata']) is not None:
3335
- setv(to_object, ['video_metadata'], getv(from_object, ['videoMetadata']))
3818
+ setv(
3819
+ to_object,
3820
+ ['video_metadata'],
3821
+ _VideoMetadata_from_vertex(
3822
+ api_client, getv(from_object, ['videoMetadata']), to_object
3823
+ ),
3824
+ )
3336
3825
 
3337
3826
  if getv(from_object, ['thought']) is not None:
3338
3827
  setv(to_object, ['thought'], getv(from_object, ['thought']))
3339
3828
 
3829
+ if getv(from_object, ['inlineData']) is not None:
3830
+ setv(
3831
+ to_object,
3832
+ ['inline_data'],
3833
+ _Blob_from_vertex(
3834
+ api_client, getv(from_object, ['inlineData']), to_object
3835
+ ),
3836
+ )
3837
+
3340
3838
  if getv(from_object, ['codeExecutionResult']) is not None:
3341
3839
  setv(
3342
3840
  to_object,
@@ -3360,9 +3858,6 @@ def _Part_from_vertex(
3360
3858
  getv(from_object, ['functionResponse']),
3361
3859
  )
3362
3860
 
3363
- if getv(from_object, ['inlineData']) is not None:
3364
- setv(to_object, ['inline_data'], getv(from_object, ['inlineData']))
3365
-
3366
3861
  if getv(from_object, ['text']) is not None:
3367
3862
  setv(to_object, ['text'], getv(from_object, ['text']))
3368
3863
 
@@ -3403,6 +3898,44 @@ def _CitationMetadata_from_vertex(
3403
3898
  return to_object
3404
3899
 
3405
3900
 
3901
+ def _UrlMetadata_from_vertex(
3902
+ api_client: BaseApiClient,
3903
+ from_object: Union[dict[str, Any], object],
3904
+ parent_object: Optional[dict[str, Any]] = None,
3905
+ ) -> dict[str, Any]:
3906
+ to_object: dict[str, Any] = {}
3907
+ if getv(from_object, ['retrievedUrl']) is not None:
3908
+ setv(to_object, ['retrieved_url'], getv(from_object, ['retrievedUrl']))
3909
+
3910
+ if getv(from_object, ['urlRetrievalStatus']) is not None:
3911
+ setv(
3912
+ to_object,
3913
+ ['url_retrieval_status'],
3914
+ getv(from_object, ['urlRetrievalStatus']),
3915
+ )
3916
+
3917
+ return to_object
3918
+
3919
+
3920
+ def _UrlContextMetadata_from_vertex(
3921
+ api_client: BaseApiClient,
3922
+ from_object: Union[dict[str, Any], object],
3923
+ parent_object: Optional[dict[str, Any]] = None,
3924
+ ) -> dict[str, Any]:
3925
+ to_object: dict[str, Any] = {}
3926
+ if getv(from_object, ['urlMetadata']) is not None:
3927
+ setv(
3928
+ to_object,
3929
+ ['url_metadata'],
3930
+ [
3931
+ _UrlMetadata_from_vertex(api_client, item, to_object)
3932
+ for item in getv(from_object, ['urlMetadata'])
3933
+ ],
3934
+ )
3935
+
3936
+ return to_object
3937
+
3938
+
3406
3939
  def _Candidate_from_vertex(
3407
3940
  api_client: BaseApiClient,
3408
3941
  from_object: Union[dict[str, Any], object],
@@ -3760,6 +4293,24 @@ def _TunedModelInfo_from_vertex(
3760
4293
  return to_object
3761
4294
 
3762
4295
 
4296
+ def _Checkpoint_from_vertex(
4297
+ api_client: BaseApiClient,
4298
+ from_object: Union[dict[str, Any], object],
4299
+ parent_object: Optional[dict[str, Any]] = None,
4300
+ ) -> dict[str, Any]:
4301
+ to_object: dict[str, Any] = {}
4302
+ if getv(from_object, ['checkpointId']) is not None:
4303
+ setv(to_object, ['checkpoint_id'], getv(from_object, ['checkpointId']))
4304
+
4305
+ if getv(from_object, ['epoch']) is not None:
4306
+ setv(to_object, ['epoch'], getv(from_object, ['epoch']))
4307
+
4308
+ if getv(from_object, ['step']) is not None:
4309
+ setv(to_object, ['step'], getv(from_object, ['step']))
4310
+
4311
+ return to_object
4312
+
4313
+
3763
4314
  def _Model_from_vertex(
3764
4315
  api_client: BaseApiClient,
3765
4316
  from_object: Union[dict[str, Any], object],
@@ -3800,6 +4351,23 @@ def _Model_from_vertex(
3800
4351
  ),
3801
4352
  )
3802
4353
 
4354
+ if getv(from_object, ['defaultCheckpointId']) is not None:
4355
+ setv(
4356
+ to_object,
4357
+ ['default_checkpoint_id'],
4358
+ getv(from_object, ['defaultCheckpointId']),
4359
+ )
4360
+
4361
+ if getv(from_object, ['checkpoints']) is not None:
4362
+ setv(
4363
+ to_object,
4364
+ ['checkpoints'],
4365
+ [
4366
+ _Checkpoint_from_vertex(api_client, item, to_object)
4367
+ for item in getv(from_object, ['checkpoints'])
4368
+ ],
4369
+ )
4370
+
3803
4371
  return to_object
3804
4372
 
3805
4373
 
@@ -4998,6 +5566,8 @@ class Models(_api_module.BaseModule):
4998
5566
 
4999
5567
  Some models support multimodal input and output.
5000
5568
 
5569
+ Built-in MCP support is an experimental feature.
5570
+
5001
5571
  Usage:
5002
5572
 
5003
5573
  .. code-block:: python
@@ -5033,11 +5603,22 @@ class Models(_api_module.BaseModule):
5033
5603
  # scones.
5034
5604
  """
5035
5605
 
5036
- if _extra_utils.should_disable_afc(config):
5606
+ parsed_config = _extra_utils.parse_config_for_mcp_usage(config)
5607
+ if (
5608
+ parsed_config
5609
+ and parsed_config.tools
5610
+ and _mcp_utils.has_mcp_session_usage(parsed_config.tools)
5611
+ ):
5612
+ raise errors.UnsupportedFunctionError(
5613
+ 'MCP sessions are not supported in synchronous methods.'
5614
+ )
5615
+ if _extra_utils.should_disable_afc(parsed_config):
5037
5616
  return self._generate_content(
5038
- model=model, contents=contents, config=config
5617
+ model=model, contents=contents, config=parsed_config
5039
5618
  )
5040
- remaining_remote_calls_afc = _extra_utils.get_max_remote_calls_afc(config)
5619
+ remaining_remote_calls_afc = _extra_utils.get_max_remote_calls_afc(
5620
+ parsed_config
5621
+ )
5041
5622
  logger.info(
5042
5623
  f'AFC is enabled with max remote calls: {remaining_remote_calls_afc}.'
5043
5624
  )
@@ -5047,14 +5628,14 @@ class Models(_api_module.BaseModule):
5047
5628
  while remaining_remote_calls_afc > 0:
5048
5629
  i += 1
5049
5630
  response = self._generate_content(
5050
- model=model, contents=contents, config=config
5631
+ model=model, contents=contents, config=parsed_config
5051
5632
  )
5052
5633
  logger.info(f'AFC remote call {i} is done.')
5053
5634
  remaining_remote_calls_afc -= 1
5054
5635
  if remaining_remote_calls_afc == 0:
5055
5636
  logger.info('Reached max remote calls for automatic function calling.')
5056
5637
 
5057
- function_map = _extra_utils.get_function_map(config)
5638
+ function_map = _extra_utils.get_function_map(parsed_config)
5058
5639
  if not function_map:
5059
5640
  break
5060
5641
  if not response:
@@ -5083,7 +5664,10 @@ class Models(_api_module.BaseModule):
5083
5664
  contents.append(func_response_content) # type: ignore[arg-type]
5084
5665
  automatic_function_calling_history.append(func_call_content)
5085
5666
  automatic_function_calling_history.append(func_response_content)
5086
- if _extra_utils.should_append_afc_history(config) and response is not None:
5667
+ if (
5668
+ _extra_utils.should_append_afc_history(parsed_config)
5669
+ and response is not None
5670
+ ):
5087
5671
  response.automatic_function_calling_history = (
5088
5672
  automatic_function_calling_history
5089
5673
  )
@@ -5118,6 +5702,8 @@ class Models(_api_module.BaseModule):
5118
5702
 
5119
5703
  Some models support multimodal input and output.
5120
5704
 
5705
+ Built-in MCP support is an experimental feature.
5706
+
5121
5707
  Usage:
5122
5708
 
5123
5709
  .. code-block:: python
@@ -5153,13 +5739,24 @@ class Models(_api_module.BaseModule):
5153
5739
  # scones.
5154
5740
  """
5155
5741
 
5156
- if _extra_utils.should_disable_afc(config):
5742
+ parsed_config = _extra_utils.parse_config_for_mcp_usage(config)
5743
+ if (
5744
+ parsed_config
5745
+ and parsed_config.tools
5746
+ and _mcp_utils.has_mcp_session_usage(parsed_config.tools)
5747
+ ):
5748
+ raise errors.UnsupportedFunctionError(
5749
+ 'MCP sessions are not supported in synchronous methods.'
5750
+ )
5751
+ if _extra_utils.should_disable_afc(parsed_config):
5157
5752
  yield from self._generate_content_stream(
5158
- model=model, contents=contents, config=config
5753
+ model=model, contents=contents, config=parsed_config
5159
5754
  )
5160
5755
  return
5161
5756
 
5162
- remaining_remote_calls_afc = _extra_utils.get_max_remote_calls_afc(config)
5757
+ remaining_remote_calls_afc = _extra_utils.get_max_remote_calls_afc(
5758
+ parsed_config
5759
+ )
5163
5760
  logger.info(
5164
5761
  f'AFC is enabled with max remote calls: {remaining_remote_calls_afc}.'
5165
5762
  )
@@ -5170,14 +5767,14 @@ class Models(_api_module.BaseModule):
5170
5767
  while remaining_remote_calls_afc > 0:
5171
5768
  i += 1
5172
5769
  response = self._generate_content_stream(
5173
- model=model, contents=contents, config=config
5770
+ model=model, contents=contents, config=parsed_config
5174
5771
  )
5175
5772
  logger.info(f'AFC remote call {i} is done.')
5176
5773
  remaining_remote_calls_afc -= 1
5177
5774
  if remaining_remote_calls_afc == 0:
5178
5775
  logger.info('Reached max remote calls for automatic function calling.')
5179
5776
 
5180
- function_map = _extra_utils.get_function_map(config)
5777
+ function_map = _extra_utils.get_function_map(parsed_config)
5181
5778
 
5182
5779
  if i == 1:
5183
5780
  # First request gets a function call.
@@ -5202,7 +5799,7 @@ class Models(_api_module.BaseModule):
5202
5799
  else:
5203
5800
  # Second request and beyond, yield chunks.
5204
5801
  for chunk in response:
5205
- if _extra_utils.should_append_afc_history(config):
5802
+ if _extra_utils.should_append_afc_history(parsed_config):
5206
5803
  chunk.automatic_function_calling_history = (
5207
5804
  automatic_function_calling_history
5208
5805
  )
@@ -6480,6 +7077,8 @@ class AsyncModels(_api_module.BaseModule):
6480
7077
 
6481
7078
  Some models support multimodal input and output.
6482
7079
 
7080
+ Built-in MCP support is an experimental feature.
7081
+
6483
7082
  Usage:
6484
7083
 
6485
7084
  .. code-block:: python
@@ -6505,11 +7104,17 @@ class AsyncModels(_api_module.BaseModule):
6505
7104
  print(response.text)
6506
7105
  # J'aime les bagels.
6507
7106
  """
6508
- if _extra_utils.should_disable_afc(config):
7107
+ # Retrieve and cache any MCP sessions if provided.
7108
+ parsed_config, mcp_to_genai_tool_adapters = (
7109
+ await _extra_utils.parse_config_for_mcp_sessions(config)
7110
+ )
7111
+ if _extra_utils.should_disable_afc(parsed_config):
6509
7112
  return await self._generate_content(
6510
- model=model, contents=contents, config=config
7113
+ model=model, contents=contents, config=parsed_config
6511
7114
  )
6512
- remaining_remote_calls_afc = _extra_utils.get_max_remote_calls_afc(config)
7115
+ remaining_remote_calls_afc = _extra_utils.get_max_remote_calls_afc(
7116
+ parsed_config
7117
+ )
6513
7118
  logger.info(
6514
7119
  f'AFC is enabled with max remote calls: {remaining_remote_calls_afc}.'
6515
7120
  )
@@ -6517,14 +7122,14 @@ class AsyncModels(_api_module.BaseModule):
6517
7122
  response = types.GenerateContentResponse()
6518
7123
  while remaining_remote_calls_afc > 0:
6519
7124
  response = await self._generate_content(
6520
- model=model, contents=contents, config=config
7125
+ model=model, contents=contents, config=parsed_config
6521
7126
  )
6522
7127
  remaining_remote_calls_afc -= 1
6523
7128
  if remaining_remote_calls_afc == 0:
6524
7129
  logger.info('Reached max remote calls for automatic function calling.')
6525
7130
 
6526
7131
  function_map = _extra_utils.get_function_map(
6527
- config, is_caller_method_async=True
7132
+ parsed_config, mcp_to_genai_tool_adapters, is_caller_method_async=True
6528
7133
  )
6529
7134
  if not function_map:
6530
7135
  break
@@ -6557,7 +7162,10 @@ class AsyncModels(_api_module.BaseModule):
6557
7162
  automatic_function_calling_history.append(func_call_content)
6558
7163
  automatic_function_calling_history.append(func_response_content)
6559
7164
 
6560
- if _extra_utils.should_append_afc_history(config) and response is not None:
7165
+ if (
7166
+ _extra_utils.should_append_afc_history(parsed_config)
7167
+ and response is not None
7168
+ ):
6561
7169
  response.automatic_function_calling_history = (
6562
7170
  automatic_function_calling_history
6563
7171
  )
@@ -6592,6 +7200,8 @@ class AsyncModels(_api_module.BaseModule):
6592
7200
 
6593
7201
  Some models support multimodal input and output.
6594
7202
 
7203
+ Built-in MCP support is an experimental feature.
7204
+
6595
7205
  Usage:
6596
7206
 
6597
7207
  .. code-block:: python
@@ -6627,16 +7237,20 @@ class AsyncModels(_api_module.BaseModule):
6627
7237
  # scones.
6628
7238
  """
6629
7239
 
6630
- if _extra_utils.should_disable_afc(config):
7240
+ # Retrieve and cache any MCP sessions if provided.
7241
+ parsed_config, mcp_to_genai_tool_adapters = (
7242
+ await _extra_utils.parse_config_for_mcp_sessions(config)
7243
+ )
7244
+ if _extra_utils.should_disable_afc(parsed_config):
6631
7245
  response = await self._generate_content_stream(
6632
- model=model, contents=contents, config=config
7246
+ model=model, contents=contents, config=parsed_config
6633
7247
  )
6634
7248
 
6635
7249
  async def base_async_generator(model, contents, config): # type: ignore[no-untyped-def]
6636
7250
  async for chunk in response: # type: ignore[attr-defined]
6637
7251
  yield chunk
6638
7252
 
6639
- return base_async_generator(model, contents, config) # type: ignore[no-untyped-call, no-any-return]
7253
+ return base_async_generator(model, contents, parsed_config) # type: ignore[no-untyped-call, no-any-return]
6640
7254
 
6641
7255
  async def async_generator(model, contents, config): # type: ignore[no-untyped-def]
6642
7256
  remaining_remote_calls_afc = _extra_utils.get_max_remote_calls_afc(config)
@@ -6660,7 +7274,7 @@ class AsyncModels(_api_module.BaseModule):
6660
7274
  )
6661
7275
 
6662
7276
  function_map = _extra_utils.get_function_map(
6663
- config, is_caller_method_async=True
7277
+ config, mcp_to_genai_tool_adapters, is_caller_method_async=True
6664
7278
  )
6665
7279
 
6666
7280
  if i == 1:
@@ -6725,7 +7339,7 @@ class AsyncModels(_api_module.BaseModule):
6725
7339
  automatic_function_calling_history.append(func_call_content)
6726
7340
  automatic_function_calling_history.append(func_response_content)
6727
7341
 
6728
- return async_generator(model, contents, config) # type: ignore[no-untyped-call, no-any-return]
7342
+ return async_generator(model, contents, parsed_config) # type: ignore[no-untyped-call, no-any-return]
6729
7343
 
6730
7344
  async def edit_image(
6731
7345
  self,