google-genai 0.2.2__py3-none-any.whl → 0.4.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/__init__.py +2 -1
- google/genai/_api_client.py +91 -38
- google/genai/_automatic_function_calling_util.py +19 -22
- google/genai/_replay_api_client.py +22 -28
- google/genai/_transformers.py +15 -0
- google/genai/batches.py +16 -16
- google/genai/caches.py +48 -46
- google/genai/chats.py +88 -15
- google/genai/client.py +6 -3
- google/genai/files.py +22 -22
- google/genai/live.py +28 -5
- google/genai/models.py +109 -77
- google/genai/tunings.py +17 -17
- google/genai/types.py +173 -90
- google/genai/version.py +16 -0
- {google_genai-0.2.2.dist-info → google_genai-0.4.0.dist-info}/METADATA +66 -18
- google_genai-0.4.0.dist-info/RECORD +25 -0
- {google_genai-0.2.2.dist-info → google_genai-0.4.0.dist-info}/WHEEL +1 -1
- google_genai-0.2.2.dist-info/RECORD +0 -24
- {google_genai-0.2.2.dist-info → google_genai-0.4.0.dist-info}/LICENSE +0 -0
- {google_genai-0.2.2.dist-info → google_genai-0.4.0.dist-info}/top_level.txt +0 -0
google/genai/models.py
CHANGED
@@ -32,9 +32,12 @@ def _Part_to_mldev(
|
|
32
32
|
parent_object: dict = None,
|
33
33
|
) -> dict:
|
34
34
|
to_object = {}
|
35
|
-
if getv(from_object, ['video_metadata']):
|
35
|
+
if getv(from_object, ['video_metadata']) is not None:
|
36
36
|
raise ValueError('video_metadata parameter is not supported in Google AI.')
|
37
37
|
|
38
|
+
if getv(from_object, ['thought']) is not None:
|
39
|
+
setv(to_object, ['thought'], getv(from_object, ['thought']))
|
40
|
+
|
38
41
|
if getv(from_object, ['code_execution_result']) is not None:
|
39
42
|
setv(
|
40
43
|
to_object,
|
@@ -76,6 +79,9 @@ def _Part_to_vertex(
|
|
76
79
|
if getv(from_object, ['video_metadata']) is not None:
|
77
80
|
setv(to_object, ['videoMetadata'], getv(from_object, ['video_metadata']))
|
78
81
|
|
82
|
+
if getv(from_object, ['thought']) is not None:
|
83
|
+
setv(to_object, ['thought'], getv(from_object, ['thought']))
|
84
|
+
|
79
85
|
if getv(from_object, ['code_execution_result']) is not None:
|
80
86
|
setv(
|
81
87
|
to_object,
|
@@ -158,51 +164,51 @@ def _Schema_to_mldev(
|
|
158
164
|
parent_object: dict = None,
|
159
165
|
) -> dict:
|
160
166
|
to_object = {}
|
161
|
-
if getv(from_object, ['min_items']):
|
167
|
+
if getv(from_object, ['min_items']) is not None:
|
162
168
|
raise ValueError('min_items parameter is not supported in Google AI.')
|
163
169
|
|
164
|
-
if getv(from_object, ['example']):
|
170
|
+
if getv(from_object, ['example']) is not None:
|
165
171
|
raise ValueError('example parameter is not supported in Google AI.')
|
166
172
|
|
167
|
-
if getv(from_object, ['property_ordering']):
|
173
|
+
if getv(from_object, ['property_ordering']) is not None:
|
168
174
|
raise ValueError(
|
169
175
|
'property_ordering parameter is not supported in Google AI.'
|
170
176
|
)
|
171
177
|
|
172
|
-
if getv(from_object, ['pattern']):
|
178
|
+
if getv(from_object, ['pattern']) is not None:
|
173
179
|
raise ValueError('pattern parameter is not supported in Google AI.')
|
174
180
|
|
175
|
-
if getv(from_object, ['minimum']):
|
181
|
+
if getv(from_object, ['minimum']) is not None:
|
176
182
|
raise ValueError('minimum parameter is not supported in Google AI.')
|
177
183
|
|
178
|
-
if getv(from_object, ['default']):
|
184
|
+
if getv(from_object, ['default']) is not None:
|
179
185
|
raise ValueError('default parameter is not supported in Google AI.')
|
180
186
|
|
181
|
-
if getv(from_object, ['any_of']):
|
187
|
+
if getv(from_object, ['any_of']) is not None:
|
182
188
|
raise ValueError('any_of parameter is not supported in Google AI.')
|
183
189
|
|
184
|
-
if getv(from_object, ['max_length']):
|
190
|
+
if getv(from_object, ['max_length']) is not None:
|
185
191
|
raise ValueError('max_length parameter is not supported in Google AI.')
|
186
192
|
|
187
|
-
if getv(from_object, ['title']):
|
193
|
+
if getv(from_object, ['title']) is not None:
|
188
194
|
raise ValueError('title parameter is not supported in Google AI.')
|
189
195
|
|
190
|
-
if getv(from_object, ['min_length']):
|
196
|
+
if getv(from_object, ['min_length']) is not None:
|
191
197
|
raise ValueError('min_length parameter is not supported in Google AI.')
|
192
198
|
|
193
|
-
if getv(from_object, ['min_properties']):
|
199
|
+
if getv(from_object, ['min_properties']) is not None:
|
194
200
|
raise ValueError('min_properties parameter is not supported in Google AI.')
|
195
201
|
|
196
|
-
if getv(from_object, ['max_items']):
|
202
|
+
if getv(from_object, ['max_items']) is not None:
|
197
203
|
raise ValueError('max_items parameter is not supported in Google AI.')
|
198
204
|
|
199
|
-
if getv(from_object, ['maximum']):
|
205
|
+
if getv(from_object, ['maximum']) is not None:
|
200
206
|
raise ValueError('maximum parameter is not supported in Google AI.')
|
201
207
|
|
202
|
-
if getv(from_object, ['nullable']):
|
208
|
+
if getv(from_object, ['nullable']) is not None:
|
203
209
|
raise ValueError('nullable parameter is not supported in Google AI.')
|
204
210
|
|
205
|
-
if getv(from_object, ['max_properties']):
|
211
|
+
if getv(from_object, ['max_properties']) is not None:
|
206
212
|
raise ValueError('max_properties parameter is not supported in Google AI.')
|
207
213
|
|
208
214
|
if getv(from_object, ['type']) is not None:
|
@@ -314,7 +320,7 @@ def _SafetySetting_to_mldev(
|
|
314
320
|
parent_object: dict = None,
|
315
321
|
) -> dict:
|
316
322
|
to_object = {}
|
317
|
-
if getv(from_object, ['method']):
|
323
|
+
if getv(from_object, ['method']) is not None:
|
318
324
|
raise ValueError('method parameter is not supported in Google AI.')
|
319
325
|
|
320
326
|
if getv(from_object, ['category']) is not None:
|
@@ -350,7 +356,7 @@ def _FunctionDeclaration_to_mldev(
|
|
350
356
|
parent_object: dict = None,
|
351
357
|
) -> dict:
|
352
358
|
to_object = {}
|
353
|
-
if getv(from_object, ['response']):
|
359
|
+
if getv(from_object, ['response']) is not None:
|
354
360
|
raise ValueError('response parameter is not supported in Google AI.')
|
355
361
|
|
356
362
|
if getv(from_object, ['description']) is not None:
|
@@ -506,7 +512,7 @@ def _Tool_to_mldev(
|
|
506
512
|
],
|
507
513
|
)
|
508
514
|
|
509
|
-
if getv(from_object, ['retrieval']):
|
515
|
+
if getv(from_object, ['retrieval']) is not None:
|
510
516
|
raise ValueError('retrieval parameter is not supported in Google AI.')
|
511
517
|
|
512
518
|
if getv(from_object, ['google_search']) is not None:
|
@@ -791,13 +797,15 @@ def _GenerateContentConfig_to_mldev(
|
|
791
797
|
if getv(from_object, ['stop_sequences']) is not None:
|
792
798
|
setv(to_object, ['stopSequences'], getv(from_object, ['stop_sequences']))
|
793
799
|
|
794
|
-
if getv(from_object, ['response_logprobs']):
|
795
|
-
|
796
|
-
|
800
|
+
if getv(from_object, ['response_logprobs']) is not None:
|
801
|
+
setv(
|
802
|
+
to_object,
|
803
|
+
['responseLogprobs'],
|
804
|
+
getv(from_object, ['response_logprobs']),
|
797
805
|
)
|
798
806
|
|
799
|
-
if getv(from_object, ['logprobs']):
|
800
|
-
|
807
|
+
if getv(from_object, ['logprobs']) is not None:
|
808
|
+
setv(to_object, ['logprobs'], getv(from_object, ['logprobs']))
|
801
809
|
|
802
810
|
if getv(from_object, ['presence_penalty']) is not None:
|
803
811
|
setv(
|
@@ -832,7 +840,7 @@ def _GenerateContentConfig_to_mldev(
|
|
832
840
|
),
|
833
841
|
)
|
834
842
|
|
835
|
-
if getv(from_object, ['routing_config']):
|
843
|
+
if getv(from_object, ['routing_config']) is not None:
|
836
844
|
raise ValueError('routing_config parameter is not supported in Google AI.')
|
837
845
|
|
838
846
|
if getv(from_object, ['safety_settings']) is not None:
|
@@ -880,7 +888,7 @@ def _GenerateContentConfig_to_mldev(
|
|
880
888
|
getv(from_object, ['response_modalities']),
|
881
889
|
)
|
882
890
|
|
883
|
-
if getv(from_object, ['media_resolution']):
|
891
|
+
if getv(from_object, ['media_resolution']) is not None:
|
884
892
|
raise ValueError(
|
885
893
|
'media_resolution parameter is not supported in Google AI.'
|
886
894
|
)
|
@@ -1146,10 +1154,10 @@ def _EmbedContentConfig_to_mldev(
|
|
1146
1154
|
getv(from_object, ['output_dimensionality']),
|
1147
1155
|
)
|
1148
1156
|
|
1149
|
-
if getv(from_object, ['mime_type']):
|
1157
|
+
if getv(from_object, ['mime_type']) is not None:
|
1150
1158
|
raise ValueError('mime_type parameter is not supported in Google AI.')
|
1151
1159
|
|
1152
|
-
if getv(from_object, ['auto_truncate']):
|
1160
|
+
if getv(from_object, ['auto_truncate']) is not None:
|
1153
1161
|
raise ValueError('auto_truncate parameter is not supported in Google AI.')
|
1154
1162
|
|
1155
1163
|
return to_object
|
@@ -1276,7 +1284,7 @@ def _GenerateImageConfig_to_mldev(
|
|
1276
1284
|
if getv(from_object, ['http_options']) is not None:
|
1277
1285
|
setv(to_object, ['httpOptions'], getv(from_object, ['http_options']))
|
1278
1286
|
|
1279
|
-
if getv(from_object, ['output_gcs_uri']):
|
1287
|
+
if getv(from_object, ['output_gcs_uri']) is not None:
|
1280
1288
|
raise ValueError('output_gcs_uri parameter is not supported in Google AI.')
|
1281
1289
|
|
1282
1290
|
if getv(from_object, ['negative_prompt']) is not None:
|
@@ -1300,7 +1308,7 @@ def _GenerateImageConfig_to_mldev(
|
|
1300
1308
|
getv(from_object, ['guidance_scale']),
|
1301
1309
|
)
|
1302
1310
|
|
1303
|
-
if getv(from_object, ['seed']):
|
1311
|
+
if getv(from_object, ['seed']) is not None:
|
1304
1312
|
raise ValueError('seed parameter is not supported in Google AI.')
|
1305
1313
|
|
1306
1314
|
if getv(from_object, ['safety_filter_level']) is not None:
|
@@ -1352,7 +1360,7 @@ def _GenerateImageConfig_to_mldev(
|
|
1352
1360
|
getv(from_object, ['output_compression_quality']),
|
1353
1361
|
)
|
1354
1362
|
|
1355
|
-
if getv(from_object, ['add_watermark']):
|
1363
|
+
if getv(from_object, ['add_watermark']) is not None:
|
1356
1364
|
raise ValueError('add_watermark parameter is not supported in Google AI.')
|
1357
1365
|
|
1358
1366
|
if getv(from_object, ['aspect_ratio']) is not None:
|
@@ -1533,7 +1541,7 @@ def _Image_to_mldev(
|
|
1533
1541
|
parent_object: dict = None,
|
1534
1542
|
) -> dict:
|
1535
1543
|
to_object = {}
|
1536
|
-
if getv(from_object, ['gcs_uri']):
|
1544
|
+
if getv(from_object, ['gcs_uri']) is not None:
|
1537
1545
|
raise ValueError('gcs_uri parameter is not supported in Google AI.')
|
1538
1546
|
|
1539
1547
|
if getv(from_object, ['image_bytes']) is not None:
|
@@ -1563,15 +1571,15 @@ def _MaskReferenceConfig_to_mldev(
|
|
1563
1571
|
parent_object: dict = None,
|
1564
1572
|
) -> dict:
|
1565
1573
|
to_object = {}
|
1566
|
-
if getv(from_object, ['mask_mode']):
|
1574
|
+
if getv(from_object, ['mask_mode']) is not None:
|
1567
1575
|
raise ValueError('mask_mode parameter is not supported in Google AI.')
|
1568
1576
|
|
1569
|
-
if getv(from_object, ['segmentation_classes']):
|
1577
|
+
if getv(from_object, ['segmentation_classes']) is not None:
|
1570
1578
|
raise ValueError(
|
1571
1579
|
'segmentation_classes parameter is not supported in Google AI.'
|
1572
1580
|
)
|
1573
1581
|
|
1574
|
-
if getv(from_object, ['mask_dilation']):
|
1582
|
+
if getv(from_object, ['mask_dilation']) is not None:
|
1575
1583
|
raise ValueError('mask_dilation parameter is not supported in Google AI.')
|
1576
1584
|
|
1577
1585
|
return to_object
|
@@ -1603,10 +1611,10 @@ def _ControlReferenceConfig_to_mldev(
|
|
1603
1611
|
parent_object: dict = None,
|
1604
1612
|
) -> dict:
|
1605
1613
|
to_object = {}
|
1606
|
-
if getv(from_object, ['control_type']):
|
1614
|
+
if getv(from_object, ['control_type']) is not None:
|
1607
1615
|
raise ValueError('control_type parameter is not supported in Google AI.')
|
1608
1616
|
|
1609
|
-
if getv(from_object, ['enable_control_image_computation']):
|
1617
|
+
if getv(from_object, ['enable_control_image_computation']) is not None:
|
1610
1618
|
raise ValueError(
|
1611
1619
|
'enable_control_image_computation parameter is not supported in'
|
1612
1620
|
' Google AI.'
|
@@ -1640,7 +1648,7 @@ def _StyleReferenceConfig_to_mldev(
|
|
1640
1648
|
parent_object: dict = None,
|
1641
1649
|
) -> dict:
|
1642
1650
|
to_object = {}
|
1643
|
-
if getv(from_object, ['style_description']):
|
1651
|
+
if getv(from_object, ['style_description']) is not None:
|
1644
1652
|
raise ValueError(
|
1645
1653
|
'style_description parameter is not supported in Google AI.'
|
1646
1654
|
)
|
@@ -1670,10 +1678,10 @@ def _SubjectReferenceConfig_to_mldev(
|
|
1670
1678
|
parent_object: dict = None,
|
1671
1679
|
) -> dict:
|
1672
1680
|
to_object = {}
|
1673
|
-
if getv(from_object, ['subject_type']):
|
1681
|
+
if getv(from_object, ['subject_type']) is not None:
|
1674
1682
|
raise ValueError('subject_type parameter is not supported in Google AI.')
|
1675
1683
|
|
1676
|
-
if getv(from_object, ['subject_description']):
|
1684
|
+
if getv(from_object, ['subject_description']) is not None:
|
1677
1685
|
raise ValueError(
|
1678
1686
|
'subject_description parameter is not supported in Google AI.'
|
1679
1687
|
)
|
@@ -1706,31 +1714,31 @@ def _ReferenceImageAPI_to_mldev(
|
|
1706
1714
|
parent_object: dict = None,
|
1707
1715
|
) -> dict:
|
1708
1716
|
to_object = {}
|
1709
|
-
if getv(from_object, ['reference_image']):
|
1717
|
+
if getv(from_object, ['reference_image']) is not None:
|
1710
1718
|
raise ValueError('reference_image parameter is not supported in Google AI.')
|
1711
1719
|
|
1712
|
-
if getv(from_object, ['reference_id']):
|
1720
|
+
if getv(from_object, ['reference_id']) is not None:
|
1713
1721
|
raise ValueError('reference_id parameter is not supported in Google AI.')
|
1714
1722
|
|
1715
|
-
if getv(from_object, ['reference_type']):
|
1723
|
+
if getv(from_object, ['reference_type']) is not None:
|
1716
1724
|
raise ValueError('reference_type parameter is not supported in Google AI.')
|
1717
1725
|
|
1718
|
-
if getv(from_object, ['mask_image_config']):
|
1726
|
+
if getv(from_object, ['mask_image_config']) is not None:
|
1719
1727
|
raise ValueError(
|
1720
1728
|
'mask_image_config parameter is not supported in Google AI.'
|
1721
1729
|
)
|
1722
1730
|
|
1723
|
-
if getv(from_object, ['control_image_config']):
|
1731
|
+
if getv(from_object, ['control_image_config']) is not None:
|
1724
1732
|
raise ValueError(
|
1725
1733
|
'control_image_config parameter is not supported in Google AI.'
|
1726
1734
|
)
|
1727
1735
|
|
1728
|
-
if getv(from_object, ['style_image_config']):
|
1736
|
+
if getv(from_object, ['style_image_config']) is not None:
|
1729
1737
|
raise ValueError(
|
1730
1738
|
'style_image_config parameter is not supported in Google AI.'
|
1731
1739
|
)
|
1732
1740
|
|
1733
|
-
if getv(from_object, ['subject_image_config']):
|
1741
|
+
if getv(from_object, ['subject_image_config']) is not None:
|
1734
1742
|
raise ValueError(
|
1735
1743
|
'subject_image_config parameter is not supported in Google AI.'
|
1736
1744
|
)
|
@@ -1807,7 +1815,7 @@ def _EditImageConfig_to_mldev(
|
|
1807
1815
|
if getv(from_object, ['http_options']) is not None:
|
1808
1816
|
setv(to_object, ['httpOptions'], getv(from_object, ['http_options']))
|
1809
1817
|
|
1810
|
-
if getv(from_object, ['output_gcs_uri']):
|
1818
|
+
if getv(from_object, ['output_gcs_uri']) is not None:
|
1811
1819
|
raise ValueError('output_gcs_uri parameter is not supported in Google AI.')
|
1812
1820
|
|
1813
1821
|
if getv(from_object, ['negative_prompt']) is not None:
|
@@ -1831,7 +1839,7 @@ def _EditImageConfig_to_mldev(
|
|
1831
1839
|
getv(from_object, ['guidance_scale']),
|
1832
1840
|
)
|
1833
1841
|
|
1834
|
-
if getv(from_object, ['seed']):
|
1842
|
+
if getv(from_object, ['seed']) is not None:
|
1835
1843
|
raise ValueError('seed parameter is not supported in Google AI.')
|
1836
1844
|
|
1837
1845
|
if getv(from_object, ['safety_filter_level']) is not None:
|
@@ -2077,13 +2085,6 @@ def _UpscaleImageAPIConfig_to_mldev(
|
|
2077
2085
|
if getv(from_object, ['http_options']) is not None:
|
2078
2086
|
setv(to_object, ['httpOptions'], getv(from_object, ['http_options']))
|
2079
2087
|
|
2080
|
-
if getv(from_object, ['upscale_factor']) is not None:
|
2081
|
-
setv(
|
2082
|
-
parent_object,
|
2083
|
-
['parameters', 'upscaleConfig', 'upscaleFactor'],
|
2084
|
-
getv(from_object, ['upscale_factor']),
|
2085
|
-
)
|
2086
|
-
|
2087
2088
|
if getv(from_object, ['include_rai_reason']) is not None:
|
2088
2089
|
setv(
|
2089
2090
|
parent_object,
|
@@ -2127,13 +2128,6 @@ def _UpscaleImageAPIConfig_to_vertex(
|
|
2127
2128
|
if getv(from_object, ['http_options']) is not None:
|
2128
2129
|
setv(to_object, ['httpOptions'], getv(from_object, ['http_options']))
|
2129
2130
|
|
2130
|
-
if getv(from_object, ['upscale_factor']) is not None:
|
2131
|
-
setv(
|
2132
|
-
parent_object,
|
2133
|
-
['parameters', 'upscaleConfig', 'upscaleFactor'],
|
2134
|
-
getv(from_object, ['upscale_factor']),
|
2135
|
-
)
|
2136
|
-
|
2137
2131
|
if getv(from_object, ['include_rai_reason']) is not None:
|
2138
2132
|
setv(
|
2139
2133
|
parent_object,
|
@@ -2188,6 +2182,13 @@ def _UpscaleImageAPIParameters_to_mldev(
|
|
2188
2182
|
_Image_to_mldev(api_client, getv(from_object, ['image']), to_object),
|
2189
2183
|
)
|
2190
2184
|
|
2185
|
+
if getv(from_object, ['upscale_factor']) is not None:
|
2186
|
+
setv(
|
2187
|
+
to_object,
|
2188
|
+
['parameters', 'upscaleConfig', 'upscaleFactor'],
|
2189
|
+
getv(from_object, ['upscale_factor']),
|
2190
|
+
)
|
2191
|
+
|
2191
2192
|
if getv(from_object, ['config']) is not None:
|
2192
2193
|
setv(
|
2193
2194
|
to_object,
|
@@ -2220,6 +2221,13 @@ def _UpscaleImageAPIParameters_to_vertex(
|
|
2220
2221
|
_Image_to_vertex(api_client, getv(from_object, ['image']), to_object),
|
2221
2222
|
)
|
2222
2223
|
|
2224
|
+
if getv(from_object, ['upscale_factor']) is not None:
|
2225
|
+
setv(
|
2226
|
+
to_object,
|
2227
|
+
['parameters', 'upscaleConfig', 'upscaleFactor'],
|
2228
|
+
getv(from_object, ['upscale_factor']),
|
2229
|
+
)
|
2230
|
+
|
2223
2231
|
if getv(from_object, ['config']) is not None:
|
2224
2232
|
setv(
|
2225
2233
|
to_object,
|
@@ -2490,7 +2498,7 @@ def _CountTokensConfig_to_mldev(
|
|
2490
2498
|
],
|
2491
2499
|
)
|
2492
2500
|
|
2493
|
-
if getv(from_object, ['generation_config']):
|
2501
|
+
if getv(from_object, ['generation_config']) is not None:
|
2494
2502
|
raise ValueError(
|
2495
2503
|
'generation_config parameter is not supported in Google AI.'
|
2496
2504
|
)
|
@@ -2649,7 +2657,7 @@ def _ComputeTokensParameters_to_mldev(
|
|
2649
2657
|
t.t_model(api_client, getv(from_object, ['model'])),
|
2650
2658
|
)
|
2651
2659
|
|
2652
|
-
if getv(from_object, ['contents']):
|
2660
|
+
if getv(from_object, ['contents']) is not None:
|
2653
2661
|
raise ValueError('contents parameter is not supported in Google AI.')
|
2654
2662
|
|
2655
2663
|
if getv(from_object, ['config']) is not None:
|
@@ -2708,6 +2716,9 @@ def _Part_from_mldev(
|
|
2708
2716
|
) -> dict:
|
2709
2717
|
to_object = {}
|
2710
2718
|
|
2719
|
+
if getv(from_object, ['thought']) is not None:
|
2720
|
+
setv(to_object, ['thought'], getv(from_object, ['thought']))
|
2721
|
+
|
2711
2722
|
if getv(from_object, ['codeExecutionResult']) is not None:
|
2712
2723
|
setv(
|
2713
2724
|
to_object,
|
@@ -2749,6 +2760,9 @@ def _Part_from_vertex(
|
|
2749
2760
|
if getv(from_object, ['videoMetadata']) is not None:
|
2750
2761
|
setv(to_object, ['video_metadata'], getv(from_object, ['videoMetadata']))
|
2751
2762
|
|
2763
|
+
if getv(from_object, ['thought']) is not None:
|
2764
|
+
setv(to_object, ['thought'], getv(from_object, ['thought']))
|
2765
|
+
|
2752
2766
|
if getv(from_object, ['codeExecutionResult']) is not None:
|
2753
2767
|
setv(
|
2754
2768
|
to_object,
|
@@ -3972,6 +3986,7 @@ class Models(_common.BaseModule):
|
|
3972
3986
|
*,
|
3973
3987
|
model: str,
|
3974
3988
|
image: types.ImageOrDict,
|
3989
|
+
upscale_factor: str,
|
3975
3990
|
config: Optional[types._UpscaleImageAPIConfigOrDict] = None,
|
3976
3991
|
) -> types.UpscaleImageResponse:
|
3977
3992
|
"""Upscales an image.
|
@@ -3979,12 +3994,14 @@ class Models(_common.BaseModule):
|
|
3979
3994
|
Args:
|
3980
3995
|
model (str): The model to use.
|
3981
3996
|
image (Image): The input image for upscaling.
|
3997
|
+
upscale_factor (str): The factor to upscale the image (x2 or x4).
|
3982
3998
|
config (_UpscaleImageAPIConfig): Configuration for upscaling.
|
3983
3999
|
"""
|
3984
4000
|
|
3985
4001
|
parameter_model = types._UpscaleImageAPIParameters(
|
3986
4002
|
model=model,
|
3987
4003
|
image=image,
|
4004
|
+
upscale_factor=upscale_factor,
|
3988
4005
|
config=config,
|
3989
4006
|
)
|
3990
4007
|
|
@@ -4431,13 +4448,15 @@ class Models(_common.BaseModule):
|
|
4431
4448
|
*,
|
4432
4449
|
model: str,
|
4433
4450
|
image: types.ImageOrDict,
|
4434
|
-
|
4451
|
+
upscale_factor: str,
|
4452
|
+
config: Optional[types.UpscaleImageConfigOrDict] = None,
|
4435
4453
|
) -> types.UpscaleImageResponse:
|
4436
4454
|
"""Makes an API request to upscale a provided image.
|
4437
4455
|
|
4438
4456
|
Args:
|
4439
4457
|
model (str): The model to use.
|
4440
4458
|
image (Image): The input image for upscaling.
|
4459
|
+
upscale_factor (str): The factor to upscale the image (x2 or x4).
|
4441
4460
|
config (UpscaleImageConfig): Configuration for upscaling.
|
4442
4461
|
|
4443
4462
|
Usage:
|
@@ -4450,9 +4469,7 @@ class Models(_common.BaseModule):
|
|
4450
4469
|
response=client.models.upscale_image(
|
4451
4470
|
model='imagen-3.0-generate-001',
|
4452
4471
|
image=types.Image.from_file(IMAGE_FILE_PATH),
|
4453
|
-
|
4454
|
-
'upscale_factor': 'x2',
|
4455
|
-
}
|
4472
|
+
upscale_factor='x2',
|
4456
4473
|
)
|
4457
4474
|
response.generated_images[0].image.show()
|
4458
4475
|
# Opens my-image.png which is upscaled by a factor of 2.
|
@@ -4462,10 +4479,12 @@ class Models(_common.BaseModule):
|
|
4462
4479
|
types.UpscaleImageParameters(
|
4463
4480
|
model=model,
|
4464
4481
|
image=image,
|
4482
|
+
upscale_factor=upscale_factor,
|
4465
4483
|
config=config,
|
4466
4484
|
)
|
4467
4485
|
|
4468
4486
|
# Convert to API config.
|
4487
|
+
config = config or {}
|
4469
4488
|
config_dct = config if isinstance(config, dict) else config.dict()
|
4470
4489
|
api_config = types._UpscaleImageAPIConfigDict(**config_dct) # pylint: disable=protected-access
|
4471
4490
|
|
@@ -4473,7 +4492,12 @@ class Models(_common.BaseModule):
|
|
4473
4492
|
api_config['mode'] = 'upscale'
|
4474
4493
|
api_config['number_of_images'] = 1
|
4475
4494
|
|
4476
|
-
return self._upscale_image(
|
4495
|
+
return self._upscale_image(
|
4496
|
+
model=model,
|
4497
|
+
image=image,
|
4498
|
+
upscale_factor=upscale_factor,
|
4499
|
+
config=api_config,
|
4500
|
+
)
|
4477
4501
|
|
4478
4502
|
def list(
|
4479
4503
|
self,
|
@@ -4870,6 +4894,7 @@ class AsyncModels(_common.BaseModule):
|
|
4870
4894
|
*,
|
4871
4895
|
model: str,
|
4872
4896
|
image: types.ImageOrDict,
|
4897
|
+
upscale_factor: str,
|
4873
4898
|
config: Optional[types._UpscaleImageAPIConfigOrDict] = None,
|
4874
4899
|
) -> types.UpscaleImageResponse:
|
4875
4900
|
"""Upscales an image.
|
@@ -4877,12 +4902,14 @@ class AsyncModels(_common.BaseModule):
|
|
4877
4902
|
Args:
|
4878
4903
|
model (str): The model to use.
|
4879
4904
|
image (Image): The input image for upscaling.
|
4905
|
+
upscale_factor (str): The factor to upscale the image (x2 or x4).
|
4880
4906
|
config (_UpscaleImageAPIConfig): Configuration for upscaling.
|
4881
4907
|
"""
|
4882
4908
|
|
4883
4909
|
parameter_model = types._UpscaleImageAPIParameters(
|
4884
4910
|
model=model,
|
4885
4911
|
image=image,
|
4912
|
+
upscale_factor=upscale_factor,
|
4886
4913
|
config=config,
|
4887
4914
|
)
|
4888
4915
|
|
@@ -5359,13 +5386,15 @@ class AsyncModels(_common.BaseModule):
|
|
5359
5386
|
*,
|
5360
5387
|
model: str,
|
5361
5388
|
image: types.ImageOrDict,
|
5362
|
-
|
5389
|
+
upscale_factor: str,
|
5390
|
+
config: Optional[types.UpscaleImageConfigOrDict] = None,
|
5363
5391
|
) -> types.UpscaleImageResponse:
|
5364
5392
|
"""Makes an API request to upscale a provided image.
|
5365
5393
|
|
5366
5394
|
Args:
|
5367
5395
|
model (str): The model to use.
|
5368
5396
|
image (Image): The input image for upscaling.
|
5397
|
+
upscale_factor (str): The factor to upscale the image (x2 or x4).
|
5369
5398
|
config (UpscaleImageConfig): Configuration for upscaling.
|
5370
5399
|
|
5371
5400
|
Usage:
|
@@ -5376,11 +5405,9 @@ class AsyncModels(_common.BaseModule):
|
|
5376
5405
|
|
5377
5406
|
IMAGE_FILE_PATH="my-image.png"
|
5378
5407
|
response = await client.aio.models.upscale_image(
|
5379
|
-
model
|
5380
|
-
image
|
5381
|
-
|
5382
|
-
'upscale_factor': 'x2',
|
5383
|
-
}
|
5408
|
+
model='imagen-3.0-generate-001',
|
5409
|
+
image=types.Image.from_file(IMAGE_FILE_PATH),
|
5410
|
+
upscale_factor='x2',
|
5384
5411
|
)
|
5385
5412
|
response.generated_images[0].image.show()
|
5386
5413
|
# Opens my-image.png which is upscaled by a factor of 2.
|
@@ -5390,10 +5417,12 @@ class AsyncModels(_common.BaseModule):
|
|
5390
5417
|
types.UpscaleImageParameters(
|
5391
5418
|
model=model,
|
5392
5419
|
image=image,
|
5420
|
+
upscale_factor=upscale_factor,
|
5393
5421
|
config=config,
|
5394
5422
|
)
|
5395
5423
|
|
5396
5424
|
# Convert to API config.
|
5425
|
+
config = config or {}
|
5397
5426
|
config_dct = config if isinstance(config, dict) else config.dict()
|
5398
5427
|
api_config = types._UpscaleImageAPIConfigDict(**config_dct) # pylint: disable=protected-access
|
5399
5428
|
|
@@ -5402,5 +5431,8 @@ class AsyncModels(_common.BaseModule):
|
|
5402
5431
|
api_config['number_of_images'] = 1
|
5403
5432
|
|
5404
5433
|
return await self._upscale_image(
|
5405
|
-
model=model,
|
5434
|
+
model=model,
|
5435
|
+
image=image,
|
5436
|
+
upscale_factor=upscale_factor,
|
5437
|
+
config=api_config,
|
5406
5438
|
)
|
google/genai/tunings.py
CHANGED
@@ -195,10 +195,10 @@ def _TuningExample_to_vertex(
|
|
195
195
|
parent_object: dict = None,
|
196
196
|
) -> dict:
|
197
197
|
to_object = {}
|
198
|
-
if getv(from_object, ['text_input']):
|
198
|
+
if getv(from_object, ['text_input']) is not None:
|
199
199
|
raise ValueError('text_input parameter is not supported in Vertex AI.')
|
200
200
|
|
201
|
-
if getv(from_object, ['output']):
|
201
|
+
if getv(from_object, ['output']) is not None:
|
202
202
|
raise ValueError('output parameter is not supported in Vertex AI.')
|
203
203
|
|
204
204
|
return to_object
|
@@ -210,7 +210,7 @@ def _TuningDataset_to_mldev(
|
|
210
210
|
parent_object: dict = None,
|
211
211
|
) -> dict:
|
212
212
|
to_object = {}
|
213
|
-
if getv(from_object, ['gcs_uri']):
|
213
|
+
if getv(from_object, ['gcs_uri']) is not None:
|
214
214
|
raise ValueError('gcs_uri parameter is not supported in Google AI.')
|
215
215
|
|
216
216
|
if getv(from_object, ['examples']) is not None:
|
@@ -239,7 +239,7 @@ def _TuningDataset_to_vertex(
|
|
239
239
|
getv(from_object, ['gcs_uri']),
|
240
240
|
)
|
241
241
|
|
242
|
-
if getv(from_object, ['examples']):
|
242
|
+
if getv(from_object, ['examples']) is not None:
|
243
243
|
raise ValueError('examples parameter is not supported in Vertex AI.')
|
244
244
|
|
245
245
|
return to_object
|
@@ -251,7 +251,7 @@ def _TuningValidationDataset_to_mldev(
|
|
251
251
|
parent_object: dict = None,
|
252
252
|
) -> dict:
|
253
253
|
to_object = {}
|
254
|
-
if getv(from_object, ['gcs_uri']):
|
254
|
+
if getv(from_object, ['gcs_uri']) is not None:
|
255
255
|
raise ValueError('gcs_uri parameter is not supported in Google AI.')
|
256
256
|
|
257
257
|
return to_object
|
@@ -278,7 +278,7 @@ def _CreateTuningJobConfig_to_mldev(
|
|
278
278
|
if getv(from_object, ['http_options']) is not None:
|
279
279
|
setv(to_object, ['httpOptions'], getv(from_object, ['http_options']))
|
280
280
|
|
281
|
-
if getv(from_object, ['validation_dataset']):
|
281
|
+
if getv(from_object, ['validation_dataset']) is not None:
|
282
282
|
raise ValueError(
|
283
283
|
'validation_dataset parameter is not supported in Google AI.'
|
284
284
|
)
|
@@ -290,7 +290,7 @@ def _CreateTuningJobConfig_to_mldev(
|
|
290
290
|
getv(from_object, ['tuned_model_display_name']),
|
291
291
|
)
|
292
292
|
|
293
|
-
if getv(from_object, ['description']):
|
293
|
+
if getv(from_object, ['description']) is not None:
|
294
294
|
raise ValueError('description parameter is not supported in Google AI.')
|
295
295
|
|
296
296
|
if getv(from_object, ['epoch_count']) is not None:
|
@@ -307,7 +307,7 @@ def _CreateTuningJobConfig_to_mldev(
|
|
307
307
|
getv(from_object, ['learning_rate_multiplier']),
|
308
308
|
)
|
309
309
|
|
310
|
-
if getv(from_object, ['adapter_size']):
|
310
|
+
if getv(from_object, ['adapter_size']) is not None:
|
311
311
|
raise ValueError('adapter_size parameter is not supported in Google AI.')
|
312
312
|
|
313
313
|
if getv(from_object, ['batch_size']) is not None:
|
@@ -376,10 +376,10 @@ def _CreateTuningJobConfig_to_vertex(
|
|
376
376
|
getv(from_object, ['adapter_size']),
|
377
377
|
)
|
378
378
|
|
379
|
-
if getv(from_object, ['batch_size']):
|
379
|
+
if getv(from_object, ['batch_size']) is not None:
|
380
380
|
raise ValueError('batch_size parameter is not supported in Vertex AI.')
|
381
381
|
|
382
|
-
if getv(from_object, ['learning_rate']):
|
382
|
+
if getv(from_object, ['learning_rate']) is not None:
|
383
383
|
raise ValueError('learning_rate parameter is not supported in Vertex AI.')
|
384
384
|
|
385
385
|
return to_object
|
@@ -451,7 +451,7 @@ def _DistillationDataset_to_mldev(
|
|
451
451
|
parent_object: dict = None,
|
452
452
|
) -> dict:
|
453
453
|
to_object = {}
|
454
|
-
if getv(from_object, ['gcs_uri']):
|
454
|
+
if getv(from_object, ['gcs_uri']) is not None:
|
455
455
|
raise ValueError('gcs_uri parameter is not supported in Google AI.')
|
456
456
|
|
457
457
|
return to_object
|
@@ -479,7 +479,7 @@ def _DistillationValidationDataset_to_mldev(
|
|
479
479
|
parent_object: dict = None,
|
480
480
|
) -> dict:
|
481
481
|
to_object = {}
|
482
|
-
if getv(from_object, ['gcs_uri']):
|
482
|
+
if getv(from_object, ['gcs_uri']) is not None:
|
483
483
|
raise ValueError('gcs_uri parameter is not supported in Google AI.')
|
484
484
|
|
485
485
|
return to_object
|
@@ -506,7 +506,7 @@ def _CreateDistillationJobConfig_to_mldev(
|
|
506
506
|
if getv(from_object, ['http_options']) is not None:
|
507
507
|
setv(to_object, ['httpOptions'], getv(from_object, ['http_options']))
|
508
508
|
|
509
|
-
if getv(from_object, ['validation_dataset']):
|
509
|
+
if getv(from_object, ['validation_dataset']) is not None:
|
510
510
|
raise ValueError(
|
511
511
|
'validation_dataset parameter is not supported in Google AI.'
|
512
512
|
)
|
@@ -532,10 +532,10 @@ def _CreateDistillationJobConfig_to_mldev(
|
|
532
532
|
getv(from_object, ['learning_rate_multiplier']),
|
533
533
|
)
|
534
534
|
|
535
|
-
if getv(from_object, ['adapter_size']):
|
535
|
+
if getv(from_object, ['adapter_size']) is not None:
|
536
536
|
raise ValueError('adapter_size parameter is not supported in Google AI.')
|
537
537
|
|
538
|
-
if getv(from_object, ['pipeline_root_directory']):
|
538
|
+
if getv(from_object, ['pipeline_root_directory']) is not None:
|
539
539
|
raise ValueError(
|
540
540
|
'pipeline_root_directory parameter is not supported in Google AI.'
|
541
541
|
)
|
@@ -605,10 +605,10 @@ def _CreateDistillationJobParameters_to_mldev(
|
|
605
605
|
parent_object: dict = None,
|
606
606
|
) -> dict:
|
607
607
|
to_object = {}
|
608
|
-
if getv(from_object, ['student_model']):
|
608
|
+
if getv(from_object, ['student_model']) is not None:
|
609
609
|
raise ValueError('student_model parameter is not supported in Google AI.')
|
610
610
|
|
611
|
-
if getv(from_object, ['teacher_model']):
|
611
|
+
if getv(from_object, ['teacher_model']) is not None:
|
612
612
|
raise ValueError('teacher_model parameter is not supported in Google AI.')
|
613
613
|
|
614
614
|
if getv(from_object, ['training_dataset']) is not None:
|