google-genai 1.16.1__py3-none-any.whl → 1.18.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
@@ -69,6 +69,24 @@ def _Blob_to_mldev(
69
69
  return to_object
70
70
 
71
71
 
72
+ def _FileData_to_mldev(
73
+ api_client: BaseApiClient,
74
+ from_object: Union[dict[str, Any], object],
75
+ parent_object: Optional[dict[str, Any]] = None,
76
+ ) -> dict[str, Any]:
77
+ to_object: dict[str, Any] = {}
78
+ if getv(from_object, ['display_name']) is not None:
79
+ raise ValueError('display_name parameter is not supported in Gemini API.')
80
+
81
+ if getv(from_object, ['file_uri']) is not None:
82
+ setv(to_object, ['fileUri'], getv(from_object, ['file_uri']))
83
+
84
+ if getv(from_object, ['mime_type']) is not None:
85
+ setv(to_object, ['mimeType'], getv(from_object, ['mime_type']))
86
+
87
+ return to_object
88
+
89
+
72
90
  def _Part_to_mldev(
73
91
  api_client: BaseApiClient,
74
92
  from_object: Union[dict[str, Any], object],
@@ -96,6 +114,22 @@ def _Part_to_mldev(
96
114
  ),
97
115
  )
98
116
 
117
+ if getv(from_object, ['file_data']) is not None:
118
+ setv(
119
+ to_object,
120
+ ['fileData'],
121
+ _FileData_to_mldev(
122
+ api_client, getv(from_object, ['file_data']), to_object
123
+ ),
124
+ )
125
+
126
+ if getv(from_object, ['thought_signature']) is not None:
127
+ setv(
128
+ to_object,
129
+ ['thoughtSignature'],
130
+ getv(from_object, ['thought_signature']),
131
+ )
132
+
99
133
  if getv(from_object, ['code_execution_result']) is not None:
100
134
  setv(
101
135
  to_object,
@@ -106,9 +140,6 @@ def _Part_to_mldev(
106
140
  if getv(from_object, ['executable_code']) is not None:
107
141
  setv(to_object, ['executableCode'], getv(from_object, ['executable_code']))
108
142
 
109
- if getv(from_object, ['file_data']) is not None:
110
- setv(to_object, ['fileData'], getv(from_object, ['file_data']))
111
-
112
143
  if getv(from_object, ['function_call']) is not None:
113
144
  setv(to_object, ['functionCall'], getv(from_object, ['function_call']))
114
145
 
@@ -147,6 +178,96 @@ def _Content_to_mldev(
147
178
  return to_object
148
179
 
149
180
 
181
+ def _Schema_to_mldev(
182
+ api_client: BaseApiClient,
183
+ from_object: Union[dict[str, Any], object],
184
+ parent_object: Optional[dict[str, Any]] = None,
185
+ ) -> dict[str, Any]:
186
+ to_object: dict[str, Any] = {}
187
+ if getv(from_object, ['additional_properties']) is not None:
188
+ raise ValueError(
189
+ 'additional_properties parameter is not supported in Gemini API.'
190
+ )
191
+
192
+ if getv(from_object, ['defs']) is not None:
193
+ raise ValueError('defs parameter is not supported in Gemini API.')
194
+
195
+ if getv(from_object, ['ref']) is not None:
196
+ raise ValueError('ref parameter is not supported in Gemini API.')
197
+
198
+ if getv(from_object, ['any_of']) is not None:
199
+ setv(to_object, ['anyOf'], getv(from_object, ['any_of']))
200
+
201
+ if getv(from_object, ['default']) is not None:
202
+ setv(to_object, ['default'], getv(from_object, ['default']))
203
+
204
+ if getv(from_object, ['description']) is not None:
205
+ setv(to_object, ['description'], getv(from_object, ['description']))
206
+
207
+ if getv(from_object, ['enum']) is not None:
208
+ setv(to_object, ['enum'], getv(from_object, ['enum']))
209
+
210
+ if getv(from_object, ['example']) is not None:
211
+ setv(to_object, ['example'], getv(from_object, ['example']))
212
+
213
+ if getv(from_object, ['format']) is not None:
214
+ setv(to_object, ['format'], getv(from_object, ['format']))
215
+
216
+ if getv(from_object, ['items']) is not None:
217
+ setv(to_object, ['items'], getv(from_object, ['items']))
218
+
219
+ if getv(from_object, ['max_items']) is not None:
220
+ setv(to_object, ['maxItems'], getv(from_object, ['max_items']))
221
+
222
+ if getv(from_object, ['max_length']) is not None:
223
+ setv(to_object, ['maxLength'], getv(from_object, ['max_length']))
224
+
225
+ if getv(from_object, ['max_properties']) is not None:
226
+ setv(to_object, ['maxProperties'], getv(from_object, ['max_properties']))
227
+
228
+ if getv(from_object, ['maximum']) is not None:
229
+ setv(to_object, ['maximum'], getv(from_object, ['maximum']))
230
+
231
+ if getv(from_object, ['min_items']) is not None:
232
+ setv(to_object, ['minItems'], getv(from_object, ['min_items']))
233
+
234
+ if getv(from_object, ['min_length']) is not None:
235
+ setv(to_object, ['minLength'], getv(from_object, ['min_length']))
236
+
237
+ if getv(from_object, ['min_properties']) is not None:
238
+ setv(to_object, ['minProperties'], getv(from_object, ['min_properties']))
239
+
240
+ if getv(from_object, ['minimum']) is not None:
241
+ setv(to_object, ['minimum'], getv(from_object, ['minimum']))
242
+
243
+ if getv(from_object, ['nullable']) is not None:
244
+ setv(to_object, ['nullable'], getv(from_object, ['nullable']))
245
+
246
+ if getv(from_object, ['pattern']) is not None:
247
+ setv(to_object, ['pattern'], getv(from_object, ['pattern']))
248
+
249
+ if getv(from_object, ['properties']) is not None:
250
+ setv(to_object, ['properties'], getv(from_object, ['properties']))
251
+
252
+ if getv(from_object, ['property_ordering']) is not None:
253
+ setv(
254
+ to_object,
255
+ ['propertyOrdering'],
256
+ getv(from_object, ['property_ordering']),
257
+ )
258
+
259
+ if getv(from_object, ['required']) is not None:
260
+ setv(to_object, ['required'], getv(from_object, ['required']))
261
+
262
+ if getv(from_object, ['title']) is not None:
263
+ setv(to_object, ['title'], getv(from_object, ['title']))
264
+
265
+ if getv(from_object, ['type']) is not None:
266
+ setv(to_object, ['type'], getv(from_object, ['type']))
267
+
268
+ return to_object
269
+
270
+
150
271
  def _ModelSelectionConfig_to_mldev(
151
272
  api_client: BaseApiClient,
152
273
  from_object: Union[dict[str, Any], object],
@@ -463,6 +584,9 @@ def _RetrievalConfig_to_mldev(
463
584
  _LatLng_to_mldev(api_client, getv(from_object, ['lat_lng']), to_object),
464
585
  )
465
586
 
587
+ if getv(from_object, ['language_code']) is not None:
588
+ setv(to_object, ['languageCode'], getv(from_object, ['language_code']))
589
+
466
590
  return to_object
467
591
 
468
592
 
@@ -688,7 +812,11 @@ def _GenerateContentConfig_to_mldev(
688
812
  setv(
689
813
  to_object,
690
814
  ['responseSchema'],
691
- t.t_schema(api_client, getv(from_object, ['response_schema'])),
815
+ _Schema_to_mldev(
816
+ api_client,
817
+ t.t_schema(api_client, getv(from_object, ['response_schema'])),
818
+ to_object,
819
+ ),
692
820
  )
693
821
 
694
822
  if getv(from_object, ['routing_config']) is not None:
@@ -1296,6 +1424,9 @@ def _GenerateVideosConfig_to_mldev(
1296
1424
  if getv(from_object, ['enhance_prompt']) is not None:
1297
1425
  raise ValueError('enhance_prompt parameter is not supported in Gemini API.')
1298
1426
 
1427
+ if getv(from_object, ['generate_audio']) is not None:
1428
+ raise ValueError('generate_audio parameter is not supported in Gemini API.')
1429
+
1299
1430
  return to_object
1300
1431
 
1301
1432
 
@@ -1370,6 +1501,24 @@ def _Blob_to_vertex(
1370
1501
  return to_object
1371
1502
 
1372
1503
 
1504
+ def _FileData_to_vertex(
1505
+ api_client: BaseApiClient,
1506
+ from_object: Union[dict[str, Any], object],
1507
+ parent_object: Optional[dict[str, Any]] = None,
1508
+ ) -> dict[str, Any]:
1509
+ to_object: dict[str, Any] = {}
1510
+ if getv(from_object, ['display_name']) is not None:
1511
+ setv(to_object, ['displayName'], getv(from_object, ['display_name']))
1512
+
1513
+ if getv(from_object, ['file_uri']) is not None:
1514
+ setv(to_object, ['fileUri'], getv(from_object, ['file_uri']))
1515
+
1516
+ if getv(from_object, ['mime_type']) is not None:
1517
+ setv(to_object, ['mimeType'], getv(from_object, ['mime_type']))
1518
+
1519
+ return to_object
1520
+
1521
+
1373
1522
  def _Part_to_vertex(
1374
1523
  api_client: BaseApiClient,
1375
1524
  from_object: Union[dict[str, Any], object],
@@ -1397,6 +1546,22 @@ def _Part_to_vertex(
1397
1546
  ),
1398
1547
  )
1399
1548
 
1549
+ if getv(from_object, ['file_data']) is not None:
1550
+ setv(
1551
+ to_object,
1552
+ ['fileData'],
1553
+ _FileData_to_vertex(
1554
+ api_client, getv(from_object, ['file_data']), to_object
1555
+ ),
1556
+ )
1557
+
1558
+ if getv(from_object, ['thought_signature']) is not None:
1559
+ setv(
1560
+ to_object,
1561
+ ['thoughtSignature'],
1562
+ getv(from_object, ['thought_signature']),
1563
+ )
1564
+
1400
1565
  if getv(from_object, ['code_execution_result']) is not None:
1401
1566
  setv(
1402
1567
  to_object,
@@ -1407,9 +1572,6 @@ def _Part_to_vertex(
1407
1572
  if getv(from_object, ['executable_code']) is not None:
1408
1573
  setv(to_object, ['executableCode'], getv(from_object, ['executable_code']))
1409
1574
 
1410
- if getv(from_object, ['file_data']) is not None:
1411
- setv(to_object, ['fileData'], getv(from_object, ['file_data']))
1412
-
1413
1575
  if getv(from_object, ['function_call']) is not None:
1414
1576
  setv(to_object, ['functionCall'], getv(from_object, ['function_call']))
1415
1577
 
@@ -1448,6 +1610,98 @@ def _Content_to_vertex(
1448
1610
  return to_object
1449
1611
 
1450
1612
 
1613
+ def _Schema_to_vertex(
1614
+ api_client: BaseApiClient,
1615
+ from_object: Union[dict[str, Any], object],
1616
+ parent_object: Optional[dict[str, Any]] = None,
1617
+ ) -> dict[str, Any]:
1618
+ to_object: dict[str, Any] = {}
1619
+ if getv(from_object, ['additional_properties']) is not None:
1620
+ setv(
1621
+ to_object,
1622
+ ['additionalProperties'],
1623
+ getv(from_object, ['additional_properties']),
1624
+ )
1625
+
1626
+ if getv(from_object, ['defs']) is not None:
1627
+ setv(to_object, ['defs'], getv(from_object, ['defs']))
1628
+
1629
+ if getv(from_object, ['ref']) is not None:
1630
+ setv(to_object, ['ref'], getv(from_object, ['ref']))
1631
+
1632
+ if getv(from_object, ['any_of']) is not None:
1633
+ setv(to_object, ['anyOf'], getv(from_object, ['any_of']))
1634
+
1635
+ if getv(from_object, ['default']) is not None:
1636
+ setv(to_object, ['default'], getv(from_object, ['default']))
1637
+
1638
+ if getv(from_object, ['description']) is not None:
1639
+ setv(to_object, ['description'], getv(from_object, ['description']))
1640
+
1641
+ if getv(from_object, ['enum']) is not None:
1642
+ setv(to_object, ['enum'], getv(from_object, ['enum']))
1643
+
1644
+ if getv(from_object, ['example']) is not None:
1645
+ setv(to_object, ['example'], getv(from_object, ['example']))
1646
+
1647
+ if getv(from_object, ['format']) is not None:
1648
+ setv(to_object, ['format'], getv(from_object, ['format']))
1649
+
1650
+ if getv(from_object, ['items']) is not None:
1651
+ setv(to_object, ['items'], getv(from_object, ['items']))
1652
+
1653
+ if getv(from_object, ['max_items']) is not None:
1654
+ setv(to_object, ['maxItems'], getv(from_object, ['max_items']))
1655
+
1656
+ if getv(from_object, ['max_length']) is not None:
1657
+ setv(to_object, ['maxLength'], getv(from_object, ['max_length']))
1658
+
1659
+ if getv(from_object, ['max_properties']) is not None:
1660
+ setv(to_object, ['maxProperties'], getv(from_object, ['max_properties']))
1661
+
1662
+ if getv(from_object, ['maximum']) is not None:
1663
+ setv(to_object, ['maximum'], getv(from_object, ['maximum']))
1664
+
1665
+ if getv(from_object, ['min_items']) is not None:
1666
+ setv(to_object, ['minItems'], getv(from_object, ['min_items']))
1667
+
1668
+ if getv(from_object, ['min_length']) is not None:
1669
+ setv(to_object, ['minLength'], getv(from_object, ['min_length']))
1670
+
1671
+ if getv(from_object, ['min_properties']) is not None:
1672
+ setv(to_object, ['minProperties'], getv(from_object, ['min_properties']))
1673
+
1674
+ if getv(from_object, ['minimum']) is not None:
1675
+ setv(to_object, ['minimum'], getv(from_object, ['minimum']))
1676
+
1677
+ if getv(from_object, ['nullable']) is not None:
1678
+ setv(to_object, ['nullable'], getv(from_object, ['nullable']))
1679
+
1680
+ if getv(from_object, ['pattern']) is not None:
1681
+ setv(to_object, ['pattern'], getv(from_object, ['pattern']))
1682
+
1683
+ if getv(from_object, ['properties']) is not None:
1684
+ setv(to_object, ['properties'], getv(from_object, ['properties']))
1685
+
1686
+ if getv(from_object, ['property_ordering']) is not None:
1687
+ setv(
1688
+ to_object,
1689
+ ['propertyOrdering'],
1690
+ getv(from_object, ['property_ordering']),
1691
+ )
1692
+
1693
+ if getv(from_object, ['required']) is not None:
1694
+ setv(to_object, ['required'], getv(from_object, ['required']))
1695
+
1696
+ if getv(from_object, ['title']) is not None:
1697
+ setv(to_object, ['title'], getv(from_object, ['title']))
1698
+
1699
+ if getv(from_object, ['type']) is not None:
1700
+ setv(to_object, ['type'], getv(from_object, ['type']))
1701
+
1702
+ return to_object
1703
+
1704
+
1451
1705
  def _ModelSelectionConfig_to_vertex(
1452
1706
  api_client: BaseApiClient,
1453
1707
  from_object: Union[dict[str, Any], object],
@@ -1784,6 +2038,9 @@ def _RetrievalConfig_to_vertex(
1784
2038
  ),
1785
2039
  )
1786
2040
 
2041
+ if getv(from_object, ['language_code']) is not None:
2042
+ setv(to_object, ['languageCode'], getv(from_object, ['language_code']))
2043
+
1787
2044
  return to_object
1788
2045
 
1789
2046
 
@@ -1992,7 +2249,11 @@ def _GenerateContentConfig_to_vertex(
1992
2249
  setv(
1993
2250
  to_object,
1994
2251
  ['responseSchema'],
1995
- t.t_schema(api_client, getv(from_object, ['response_schema'])),
2252
+ _Schema_to_vertex(
2253
+ api_client,
2254
+ t.t_schema(api_client, getv(from_object, ['response_schema'])),
2255
+ to_object,
2256
+ ),
1996
2257
  )
1997
2258
 
1998
2259
  if getv(from_object, ['routing_config']) is not None:
@@ -3038,6 +3299,13 @@ def _GenerateVideosConfig_to_vertex(
3038
3299
  getv(from_object, ['enhance_prompt']),
3039
3300
  )
3040
3301
 
3302
+ if getv(from_object, ['generate_audio']) is not None:
3303
+ setv(
3304
+ parent_object,
3305
+ ['parameters', 'generateAudio'],
3306
+ getv(from_object, ['generate_audio']),
3307
+ )
3308
+
3041
3309
  return to_object
3042
3310
 
3043
3311
 
@@ -3135,6 +3403,22 @@ def _Blob_from_mldev(
3135
3403
  return to_object
3136
3404
 
3137
3405
 
3406
+ def _FileData_from_mldev(
3407
+ api_client: BaseApiClient,
3408
+ from_object: Union[dict[str, Any], object],
3409
+ parent_object: Optional[dict[str, Any]] = None,
3410
+ ) -> dict[str, Any]:
3411
+ to_object: dict[str, Any] = {}
3412
+
3413
+ if getv(from_object, ['fileUri']) is not None:
3414
+ setv(to_object, ['file_uri'], getv(from_object, ['fileUri']))
3415
+
3416
+ if getv(from_object, ['mimeType']) is not None:
3417
+ setv(to_object, ['mime_type'], getv(from_object, ['mimeType']))
3418
+
3419
+ return to_object
3420
+
3421
+
3138
3422
  def _Part_from_mldev(
3139
3423
  api_client: BaseApiClient,
3140
3424
  from_object: Union[dict[str, Any], object],
@@ -3162,6 +3446,22 @@ def _Part_from_mldev(
3162
3446
  ),
3163
3447
  )
3164
3448
 
3449
+ if getv(from_object, ['fileData']) is not None:
3450
+ setv(
3451
+ to_object,
3452
+ ['file_data'],
3453
+ _FileData_from_mldev(
3454
+ api_client, getv(from_object, ['fileData']), to_object
3455
+ ),
3456
+ )
3457
+
3458
+ if getv(from_object, ['thoughtSignature']) is not None:
3459
+ setv(
3460
+ to_object,
3461
+ ['thought_signature'],
3462
+ getv(from_object, ['thoughtSignature']),
3463
+ )
3464
+
3165
3465
  if getv(from_object, ['codeExecutionResult']) is not None:
3166
3466
  setv(
3167
3467
  to_object,
@@ -3172,9 +3472,6 @@ def _Part_from_mldev(
3172
3472
  if getv(from_object, ['executableCode']) is not None:
3173
3473
  setv(to_object, ['executable_code'], getv(from_object, ['executableCode']))
3174
3474
 
3175
- if getv(from_object, ['fileData']) is not None:
3176
- setv(to_object, ['file_data'], getv(from_object, ['fileData']))
3177
-
3178
3475
  if getv(from_object, ['functionCall']) is not None:
3179
3476
  setv(to_object, ['function_call'], getv(from_object, ['functionCall']))
3180
3477
 
@@ -3808,6 +4105,24 @@ def _Blob_from_vertex(
3808
4105
  return to_object
3809
4106
 
3810
4107
 
4108
+ def _FileData_from_vertex(
4109
+ api_client: BaseApiClient,
4110
+ from_object: Union[dict[str, Any], object],
4111
+ parent_object: Optional[dict[str, Any]] = None,
4112
+ ) -> dict[str, Any]:
4113
+ to_object: dict[str, Any] = {}
4114
+ if getv(from_object, ['displayName']) is not None:
4115
+ setv(to_object, ['display_name'], getv(from_object, ['displayName']))
4116
+
4117
+ if getv(from_object, ['fileUri']) is not None:
4118
+ setv(to_object, ['file_uri'], getv(from_object, ['fileUri']))
4119
+
4120
+ if getv(from_object, ['mimeType']) is not None:
4121
+ setv(to_object, ['mime_type'], getv(from_object, ['mimeType']))
4122
+
4123
+ return to_object
4124
+
4125
+
3811
4126
  def _Part_from_vertex(
3812
4127
  api_client: BaseApiClient,
3813
4128
  from_object: Union[dict[str, Any], object],
@@ -3835,6 +4150,22 @@ def _Part_from_vertex(
3835
4150
  ),
3836
4151
  )
3837
4152
 
4153
+ if getv(from_object, ['fileData']) is not None:
4154
+ setv(
4155
+ to_object,
4156
+ ['file_data'],
4157
+ _FileData_from_vertex(
4158
+ api_client, getv(from_object, ['fileData']), to_object
4159
+ ),
4160
+ )
4161
+
4162
+ if getv(from_object, ['thoughtSignature']) is not None:
4163
+ setv(
4164
+ to_object,
4165
+ ['thought_signature'],
4166
+ getv(from_object, ['thoughtSignature']),
4167
+ )
4168
+
3838
4169
  if getv(from_object, ['codeExecutionResult']) is not None:
3839
4170
  setv(
3840
4171
  to_object,
@@ -3845,9 +4176,6 @@ def _Part_from_vertex(
3845
4176
  if getv(from_object, ['executableCode']) is not None:
3846
4177
  setv(to_object, ['executable_code'], getv(from_object, ['executableCode']))
3847
4178
 
3848
- if getv(from_object, ['fileData']) is not None:
3849
- setv(to_object, ['file_data'], getv(from_object, ['fileData']))
3850
-
3851
4179
  if getv(from_object, ['functionCall']) is not None:
3852
4180
  setv(to_object, ['function_call'], getv(from_object, ['functionCall']))
3853
4181
 
@@ -5805,7 +6133,8 @@ class Models(_api_module.BaseModule):
5805
6133
  )
5806
6134
  yield chunk
5807
6135
  if (
5808
- not chunk.candidates
6136
+ chunk is None
6137
+ or not chunk.candidates
5809
6138
  or not chunk.candidates[0].content
5810
6139
  or not chunk.candidates[0].content.parts
5811
6140
  ):
@@ -5820,7 +6149,7 @@ class Models(_api_module.BaseModule):
5820
6149
  break
5821
6150
 
5822
6151
  # Append function response parts to contents for the next request.
5823
- if chunk.candidates is not None:
6152
+ if chunk is not None and chunk.candidates is not None:
5824
6153
  func_call_content = chunk.candidates[0].content
5825
6154
  func_response_content = types.Content(
5826
6155
  role='user',
@@ -7309,7 +7638,8 @@ class AsyncModels(_api_module.BaseModule):
7309
7638
  )
7310
7639
  yield chunk
7311
7640
  if (
7312
- not chunk.candidates
7641
+ chunk is None
7642
+ or not chunk.candidates
7313
7643
  or not chunk.candidates[0].content
7314
7644
  or not chunk.candidates[0].content.parts
7315
7645
  ):
@@ -7323,6 +7653,8 @@ class AsyncModels(_api_module.BaseModule):
7323
7653
  if not func_response_parts:
7324
7654
  break
7325
7655
 
7656
+ if chunk is None:
7657
+ continue
7326
7658
  # Append function response parts to contents for the next request.
7327
7659
  func_call_content = chunk.candidates[0].content
7328
7660
  func_response_content = types.Content(
google/genai/tunings.py CHANGED
@@ -517,6 +517,9 @@ def _TuningJob_from_mldev(
517
517
  if getv(from_object, ['pipelineJob']) is not None:
518
518
  setv(to_object, ['pipeline_job'], getv(from_object, ['pipelineJob']))
519
519
 
520
+ if getv(from_object, ['serviceAccount']) is not None:
521
+ setv(to_object, ['service_account'], getv(from_object, ['serviceAccount']))
522
+
520
523
  if getv(from_object, ['tunedModelDisplayName']) is not None:
521
524
  setv(
522
525
  to_object,
@@ -700,6 +703,9 @@ def _TuningJob_from_vertex(
700
703
  if getv(from_object, ['pipelineJob']) is not None:
701
704
  setv(to_object, ['pipeline_job'], getv(from_object, ['pipelineJob']))
702
705
 
706
+ if getv(from_object, ['serviceAccount']) is not None:
707
+ setv(to_object, ['service_account'], getv(from_object, ['serviceAccount']))
708
+
703
709
  if getv(from_object, ['tunedModelDisplayName']) is not None:
704
710
  setv(
705
711
  to_object,