google-genai 1.45.0__py3-none-any.whl → 1.47.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- google/genai/_api_client.py +47 -17
- google/genai/_extra_utils.py +4 -0
- google/genai/_live_converters.py +66 -61
- google/genai/_tokens_converters.py +47 -47
- google/genai/_transformers.py +10 -1
- google/genai/batches.py +57 -57
- google/genai/caches.py +58 -58
- google/genai/client.py +4 -1
- google/genai/live.py +28 -18
- google/genai/models.py +129 -74
- google/genai/tunings.py +269 -124
- google/genai/types.py +1425 -981
- google/genai/version.py +1 -1
- {google_genai-1.45.0.dist-info → google_genai-1.47.0.dist-info}/METADATA +168 -157
- {google_genai-1.45.0.dist-info → google_genai-1.47.0.dist-info}/RECORD +18 -18
- {google_genai-1.45.0.dist-info → google_genai-1.47.0.dist-info}/WHEEL +0 -0
- {google_genai-1.45.0.dist-info → google_genai-1.47.0.dist-info}/licenses/LICENSE +0 -0
- {google_genai-1.45.0.dist-info → google_genai-1.47.0.dist-info}/top_level.txt +0 -0
google/genai/version.py
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: google-genai
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.47.0
|
|
4
4
|
Summary: GenAI Python SDK
|
|
5
5
|
Author-email: Google LLC <googleapis-packages@google.com>
|
|
6
|
-
License: Apache-2.0
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
7
|
Project-URL: Homepage, https://github.com/googleapis/python-genai
|
|
8
8
|
Classifier: Intended Audience :: Developers
|
|
9
|
-
Classifier: License :: OSI Approved :: Apache Software License
|
|
10
9
|
Classifier: Operating System :: OS Independent
|
|
11
10
|
Classifier: Programming Language :: Python
|
|
12
11
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -24,7 +23,7 @@ License-File: LICENSE
|
|
|
24
23
|
Requires-Dist: anyio<5.0.0,>=4.8.0
|
|
25
24
|
Requires-Dist: google-auth<3.0.0,>=2.14.1
|
|
26
25
|
Requires-Dist: httpx<1.0.0,>=0.28.1
|
|
27
|
-
Requires-Dist: pydantic<3.0.0,>=2.
|
|
26
|
+
Requires-Dist: pydantic<3.0.0,>=2.9.0
|
|
28
27
|
Requires-Dist: requests<3.0.0,>=2.28.1
|
|
29
28
|
Requires-Dist: tenacity<9.2.0,>=8.2.3
|
|
30
29
|
Requires-Dist: websockets<15.1.0,>=13.0.0
|
|
@@ -129,7 +128,6 @@ Explicitly close the sync client to ensure that resources, such as the
|
|
|
129
128
|
underlying HTTP connections, are properly cleaned up and closed.
|
|
130
129
|
|
|
131
130
|
```python
|
|
132
|
-
|
|
133
131
|
from google.genai import Client
|
|
134
132
|
|
|
135
133
|
client = Client()
|
|
@@ -148,7 +146,6 @@ client.close()
|
|
|
148
146
|
To explicitly close the async client:
|
|
149
147
|
|
|
150
148
|
```python
|
|
151
|
-
|
|
152
149
|
from google.genai import Client
|
|
153
150
|
|
|
154
151
|
aclient = Client(
|
|
@@ -175,15 +172,14 @@ By using the sync client context manager, it will close the underlying
|
|
|
175
172
|
from google.genai import Client
|
|
176
173
|
|
|
177
174
|
with Client() as client:
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
175
|
+
response_1 = client.models.generate_content(
|
|
176
|
+
model=MODEL_ID,
|
|
177
|
+
contents='Hello',
|
|
178
|
+
)
|
|
179
|
+
response_2 = client.models.generate_content(
|
|
180
|
+
model=MODEL_ID,
|
|
181
|
+
contents='Ask a question',
|
|
182
|
+
)
|
|
187
183
|
```
|
|
188
184
|
|
|
189
185
|
By using the async client context manager, it will close the underlying
|
|
@@ -193,15 +189,14 @@ By using the async client context manager, it will close the underlying
|
|
|
193
189
|
from google.genai import Client
|
|
194
190
|
|
|
195
191
|
async with Client().aio as aclient:
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
192
|
+
response_1 = await aclient.models.generate_content(
|
|
193
|
+
model=MODEL_ID,
|
|
194
|
+
contents='Hello',
|
|
195
|
+
)
|
|
196
|
+
response_2 = await aclient.models.generate_content(
|
|
197
|
+
model=MODEL_ID,
|
|
198
|
+
contents='Ask a question',
|
|
199
|
+
)
|
|
205
200
|
```
|
|
206
201
|
|
|
207
202
|
### API Selection
|
|
@@ -246,7 +241,6 @@ Additional args of `aiohttp.ClientSession.request()` ([see _RequestOptions args]
|
|
|
246
241
|
through the following way:
|
|
247
242
|
|
|
248
243
|
```python
|
|
249
|
-
|
|
250
244
|
http_options = types.HttpOptions(
|
|
251
245
|
async_client_args={'cookies': ..., 'ssl': ...},
|
|
252
246
|
)
|
|
@@ -260,7 +254,6 @@ Both httpx and aiohttp libraries use `urllib.request.getproxies` from
|
|
|
260
254
|
environment variables. Before client initialization, you may set proxy (and
|
|
261
255
|
optional SSL_CERT_FILE) by setting the environment variables:
|
|
262
256
|
|
|
263
|
-
|
|
264
257
|
```bash
|
|
265
258
|
export HTTPS_PROXY='http://username:password@proxy_uri:port'
|
|
266
259
|
export SSL_CERT_FILE='client.pem'
|
|
@@ -271,7 +264,6 @@ args to `httpx.Client()`. You may install `httpx[socks]` to use it.
|
|
|
271
264
|
Then, you can pass it through the following way:
|
|
272
265
|
|
|
273
266
|
```python
|
|
274
|
-
|
|
275
267
|
http_options = types.HttpOptions(
|
|
276
268
|
client_args={'proxy': 'socks5://user:pass@host:port'},
|
|
277
269
|
async_client_args={'proxy': 'socks5://user:pass@host:port'},
|
|
@@ -287,16 +279,14 @@ In some cases you might need a custom base url (for example, API gateway proxy
|
|
|
287
279
|
You may pass the custom base url like this:
|
|
288
280
|
|
|
289
281
|
```python
|
|
290
|
-
|
|
291
282
|
base_url = 'https://test-api-gateway-proxy.com'
|
|
292
283
|
client = Client(
|
|
293
|
-
vertexai=True
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
284
|
+
vertexai=True, # Currently only vertexai=True is supported
|
|
285
|
+
http_options={
|
|
286
|
+
'base_url': base_url,
|
|
287
|
+
'headers': {'Authorization': 'Bearer test_token'},
|
|
288
|
+
},
|
|
298
289
|
)
|
|
299
|
-
|
|
300
290
|
```
|
|
301
291
|
|
|
302
292
|
## Types
|
|
@@ -312,7 +302,7 @@ See the 'Create a client' section above to initialize a client.
|
|
|
312
302
|
|
|
313
303
|
### Generate Content
|
|
314
304
|
|
|
315
|
-
#### with text content
|
|
305
|
+
#### with text content input (text output)
|
|
316
306
|
|
|
317
307
|
```python
|
|
318
308
|
response = client.models.generate_content(
|
|
@@ -321,6 +311,28 @@ response = client.models.generate_content(
|
|
|
321
311
|
print(response.text)
|
|
322
312
|
```
|
|
323
313
|
|
|
314
|
+
#### with text content input (image output)
|
|
315
|
+
|
|
316
|
+
```python
|
|
317
|
+
from google.genai import types
|
|
318
|
+
|
|
319
|
+
response = client.models.generate_content(
|
|
320
|
+
model='gemini-2.5-flash-image',
|
|
321
|
+
contents='A cartoon infographic for flying sneakers',
|
|
322
|
+
config=types.GenerateContentConfig(
|
|
323
|
+
response_modalities=["IMAGE"],
|
|
324
|
+
image_config=types.ImageConfig(
|
|
325
|
+
aspect_ratio="9:16",
|
|
326
|
+
),
|
|
327
|
+
),
|
|
328
|
+
)
|
|
329
|
+
|
|
330
|
+
for part in response.parts:
|
|
331
|
+
if part.inline_data:
|
|
332
|
+
generated_image = part.as_image()
|
|
333
|
+
generated_image.show()
|
|
334
|
+
```
|
|
335
|
+
|
|
324
336
|
#### with uploaded file (Gemini Developer API only)
|
|
325
337
|
download the file in console.
|
|
326
338
|
|
|
@@ -353,8 +365,8 @@ This is the canonical way to provide contents, SDK will not do any conversion.
|
|
|
353
365
|
from google.genai import types
|
|
354
366
|
|
|
355
367
|
contents = types.Content(
|
|
356
|
-
|
|
357
|
-
|
|
368
|
+
role='user',
|
|
369
|
+
parts=[types.Part.from_text(text='Why is the sky blue?')]
|
|
358
370
|
)
|
|
359
371
|
```
|
|
360
372
|
|
|
@@ -362,10 +374,10 @@ SDK converts this to
|
|
|
362
374
|
|
|
363
375
|
```python
|
|
364
376
|
[
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
377
|
+
types.Content(
|
|
378
|
+
role='user',
|
|
379
|
+
parts=[types.Part.from_text(text='Why is the sky blue?')]
|
|
380
|
+
)
|
|
369
381
|
]
|
|
370
382
|
```
|
|
371
383
|
|
|
@@ -379,11 +391,11 @@ The SDK will assume this is a text part, and it converts this into the following
|
|
|
379
391
|
|
|
380
392
|
```python
|
|
381
393
|
[
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
394
|
+
types.UserContent(
|
|
395
|
+
parts=[
|
|
396
|
+
types.Part.from_text(text='Why is the sky blue?')
|
|
397
|
+
]
|
|
398
|
+
)
|
|
387
399
|
]
|
|
388
400
|
```
|
|
389
401
|
|
|
@@ -401,12 +413,12 @@ like the following:
|
|
|
401
413
|
|
|
402
414
|
```python
|
|
403
415
|
[
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
416
|
+
types.UserContent(
|
|
417
|
+
parts=[
|
|
418
|
+
types.Part.from_text(text='Why is the sky blue?'),
|
|
419
|
+
types.Part.from_text(text='Why is the cloud white?'),
|
|
420
|
+
]
|
|
421
|
+
)
|
|
410
422
|
]
|
|
411
423
|
```
|
|
412
424
|
|
|
@@ -419,8 +431,8 @@ Where a `types.UserContent` is a subclass of `types.Content`, the
|
|
|
419
431
|
from google.genai import types
|
|
420
432
|
|
|
421
433
|
contents = types.Part.from_function_call(
|
|
422
|
-
|
|
423
|
-
|
|
434
|
+
name='get_weather_by_location',
|
|
435
|
+
args={'location': 'Boston'}
|
|
424
436
|
)
|
|
425
437
|
```
|
|
426
438
|
|
|
@@ -428,14 +440,14 @@ The SDK converts a function call part to a content with a `model` role:
|
|
|
428
440
|
|
|
429
441
|
```python
|
|
430
442
|
[
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
443
|
+
types.ModelContent(
|
|
444
|
+
parts=[
|
|
445
|
+
types.Part.from_function_call(
|
|
446
|
+
name='get_weather_by_location',
|
|
447
|
+
args={'location': 'Boston'}
|
|
448
|
+
)
|
|
449
|
+
]
|
|
450
|
+
)
|
|
439
451
|
]
|
|
440
452
|
```
|
|
441
453
|
|
|
@@ -448,14 +460,14 @@ Where a `types.ModelContent` is a subclass of `types.Content`, the
|
|
|
448
460
|
from google.genai import types
|
|
449
461
|
|
|
450
462
|
contents = [
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
463
|
+
types.Part.from_function_call(
|
|
464
|
+
name='get_weather_by_location',
|
|
465
|
+
args={'location': 'Boston'}
|
|
466
|
+
),
|
|
467
|
+
types.Part.from_function_call(
|
|
468
|
+
name='get_weather_by_location',
|
|
469
|
+
args={'location': 'New York'}
|
|
470
|
+
),
|
|
459
471
|
]
|
|
460
472
|
```
|
|
461
473
|
|
|
@@ -463,18 +475,18 @@ The SDK converts a list of function call parts to the a content with a `model` r
|
|
|
463
475
|
|
|
464
476
|
```python
|
|
465
477
|
[
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
+
types.ModelContent(
|
|
479
|
+
parts=[
|
|
480
|
+
types.Part.from_function_call(
|
|
481
|
+
name='get_weather_by_location',
|
|
482
|
+
args={'location': 'Boston'}
|
|
483
|
+
),
|
|
484
|
+
types.Part.from_function_call(
|
|
485
|
+
name='get_weather_by_location',
|
|
486
|
+
args={'location': 'New York'}
|
|
487
|
+
)
|
|
488
|
+
]
|
|
489
|
+
)
|
|
478
490
|
]
|
|
479
491
|
```
|
|
480
492
|
|
|
@@ -487,8 +499,8 @@ Where a `types.ModelContent` is a subclass of `types.Content`, the
|
|
|
487
499
|
from google.genai import types
|
|
488
500
|
|
|
489
501
|
contents = types.Part.from_uri(
|
|
490
|
-
|
|
491
|
-
|
|
502
|
+
file_uri: 'gs://generativeai-downloads/images/scones.jpg',
|
|
503
|
+
mime_type: 'image/jpeg',
|
|
492
504
|
)
|
|
493
505
|
```
|
|
494
506
|
|
|
@@ -496,12 +508,12 @@ The SDK converts all non function call parts into a content with a `user` role.
|
|
|
496
508
|
|
|
497
509
|
```python
|
|
498
510
|
[
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
511
|
+
types.UserContent(parts=[
|
|
512
|
+
types.Part.from_uri(
|
|
513
|
+
file_uri: 'gs://generativeai-downloads/images/scones.jpg',
|
|
514
|
+
mime_type: 'image/jpeg',
|
|
515
|
+
)
|
|
516
|
+
])
|
|
505
517
|
]
|
|
506
518
|
```
|
|
507
519
|
|
|
@@ -511,11 +523,11 @@ The SDK converts all non function call parts into a content with a `user` role.
|
|
|
511
523
|
from google.genai import types
|
|
512
524
|
|
|
513
525
|
contents = [
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
526
|
+
types.Part.from_text('What is this image about?'),
|
|
527
|
+
types.Part.from_uri(
|
|
528
|
+
file_uri: 'gs://generativeai-downloads/images/scones.jpg',
|
|
529
|
+
mime_type: 'image/jpeg',
|
|
530
|
+
)
|
|
519
531
|
]
|
|
520
532
|
```
|
|
521
533
|
|
|
@@ -523,15 +535,15 @@ The SDK will convert the list of parts into a content with a `user` role
|
|
|
523
535
|
|
|
524
536
|
```python
|
|
525
537
|
[
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
538
|
+
types.UserContent(
|
|
539
|
+
parts=[
|
|
540
|
+
types.Part.from_text('What is this image about?'),
|
|
541
|
+
types.Part.from_uri(
|
|
542
|
+
file_uri: 'gs://generativeai-downloads/images/scones.jpg',
|
|
543
|
+
mime_type: 'image/jpeg',
|
|
544
|
+
)
|
|
545
|
+
]
|
|
546
|
+
)
|
|
535
547
|
]
|
|
536
548
|
```
|
|
537
549
|
|
|
@@ -665,7 +677,7 @@ def get_current_weather(location: str) -> str:
|
|
|
665
677
|
"""Returns the current weather.
|
|
666
678
|
|
|
667
679
|
Args:
|
|
668
|
-
|
|
680
|
+
location: The city and state, e.g. San Francisco, CA
|
|
669
681
|
"""
|
|
670
682
|
return 'sunny'
|
|
671
683
|
|
|
@@ -687,14 +699,14 @@ as follows:
|
|
|
687
699
|
from google.genai import types
|
|
688
700
|
|
|
689
701
|
response = client.models.generate_content(
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
702
|
+
model='gemini-2.5-flash',
|
|
703
|
+
contents='What is the weather like in Boston?',
|
|
704
|
+
config=types.GenerateContentConfig(
|
|
705
|
+
tools=[get_current_weather],
|
|
706
|
+
automatic_function_calling=types.AutomaticFunctionCallingConfig(
|
|
707
|
+
disable=True
|
|
708
|
+
),
|
|
696
709
|
),
|
|
697
|
-
),
|
|
698
710
|
)
|
|
699
711
|
```
|
|
700
712
|
|
|
@@ -808,7 +820,7 @@ def get_current_weather(location: str) -> str:
|
|
|
808
820
|
"""Returns the current weather.
|
|
809
821
|
|
|
810
822
|
Args:
|
|
811
|
-
|
|
823
|
+
location: The city and state, e.g. San Francisco, CA
|
|
812
824
|
"""
|
|
813
825
|
return "sunny"
|
|
814
826
|
|
|
@@ -838,7 +850,7 @@ def get_current_weather(location: str) -> str:
|
|
|
838
850
|
"""Returns the current weather.
|
|
839
851
|
|
|
840
852
|
Args:
|
|
841
|
-
|
|
853
|
+
location: The city and state, e.g. San Francisco, CA
|
|
842
854
|
"""
|
|
843
855
|
return "sunny"
|
|
844
856
|
|
|
@@ -1018,20 +1030,20 @@ values as the response.
|
|
|
1018
1030
|
from enum import Enum
|
|
1019
1031
|
|
|
1020
1032
|
class InstrumentEnum(Enum):
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1033
|
+
PERCUSSION = 'Percussion'
|
|
1034
|
+
STRING = 'String'
|
|
1035
|
+
WOODWIND = 'Woodwind'
|
|
1036
|
+
BRASS = 'Brass'
|
|
1037
|
+
KEYBOARD = 'Keyboard'
|
|
1026
1038
|
|
|
1027
1039
|
response = client.models.generate_content(
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1040
|
+
model='gemini-2.5-flash',
|
|
1041
|
+
contents='What instrument plays multiple notes at once?',
|
|
1042
|
+
config={
|
|
1043
|
+
'response_mime_type': 'text/x.enum',
|
|
1044
|
+
'response_schema': InstrumentEnum,
|
|
1045
|
+
},
|
|
1046
|
+
)
|
|
1035
1047
|
print(response.text)
|
|
1036
1048
|
```
|
|
1037
1049
|
|
|
@@ -1044,20 +1056,20 @@ identical but in quotes.
|
|
|
1044
1056
|
from enum import Enum
|
|
1045
1057
|
|
|
1046
1058
|
class InstrumentEnum(Enum):
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1059
|
+
PERCUSSION = 'Percussion'
|
|
1060
|
+
STRING = 'String'
|
|
1061
|
+
WOODWIND = 'Woodwind'
|
|
1062
|
+
BRASS = 'Brass'
|
|
1063
|
+
KEYBOARD = 'Keyboard'
|
|
1052
1064
|
|
|
1053
1065
|
response = client.models.generate_content(
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1066
|
+
model='gemini-2.5-flash',
|
|
1067
|
+
contents='What instrument plays multiple notes at once?',
|
|
1068
|
+
config={
|
|
1069
|
+
'response_mime_type': 'application/json',
|
|
1070
|
+
'response_schema': InstrumentEnum,
|
|
1071
|
+
},
|
|
1072
|
+
)
|
|
1061
1073
|
print(response.text)
|
|
1062
1074
|
```
|
|
1063
1075
|
|
|
@@ -1135,7 +1147,6 @@ print(response.text)
|
|
|
1135
1147
|
|
|
1136
1148
|
### Generate Content (Asynchronous Streaming)
|
|
1137
1149
|
|
|
1138
|
-
|
|
1139
1150
|
```python
|
|
1140
1151
|
async for chunk in await client.aio.models.generate_content_stream(
|
|
1141
1152
|
model='gemini-2.5-flash', contents='Tell me a story in 300 words.'
|
|
@@ -1193,7 +1204,7 @@ result = tokenizer.compute_tokens("What is your name?")
|
|
|
1193
1204
|
|
|
1194
1205
|
```python
|
|
1195
1206
|
response = client.models.embed_content(
|
|
1196
|
-
model='
|
|
1207
|
+
model='gemini-embedding-001',
|
|
1197
1208
|
contents='why is the sky blue?',
|
|
1198
1209
|
)
|
|
1199
1210
|
print(response)
|
|
@@ -1204,7 +1215,7 @@ from google.genai import types
|
|
|
1204
1215
|
|
|
1205
1216
|
# multiple contents with config
|
|
1206
1217
|
response = client.models.embed_content(
|
|
1207
|
-
model='
|
|
1218
|
+
model='gemini-embedding-001',
|
|
1208
1219
|
contents=['why is the sky blue?', 'What is your age?'],
|
|
1209
1220
|
config=types.EmbedContentConfig(output_dimensionality=10),
|
|
1210
1221
|
)
|
|
@@ -1434,7 +1445,7 @@ async for chunk in await chat.send_message_stream('tell me a story'):
|
|
|
1434
1445
|
Files are only supported in Gemini Developer API. See the 'Create a client'
|
|
1435
1446
|
section above to initialize a client.
|
|
1436
1447
|
|
|
1437
|
-
```
|
|
1448
|
+
```sh
|
|
1438
1449
|
!gsutil cp gs://cloud-samples-data/generative-ai/pdf/2312.11805v3.pdf .
|
|
1439
1450
|
!gsutil cp gs://cloud-samples-data/generative-ai/pdf/2403.05530.pdf .
|
|
1440
1451
|
```
|
|
@@ -1535,14 +1546,14 @@ section above to initialize a client.
|
|
|
1535
1546
|
|
|
1536
1547
|
### Tune
|
|
1537
1548
|
|
|
1538
|
-
- Vertex AI supports tuning from GCS source or from a Vertex Multimodal Dataset
|
|
1549
|
+
- Vertex AI supports tuning from GCS source or from a [Vertex AI Multimodal Dataset](https://docs.cloud.google.com/vertex-ai/generative-ai/docs/multimodal/datasets)
|
|
1539
1550
|
|
|
1540
1551
|
```python
|
|
1541
1552
|
from google.genai import types
|
|
1542
1553
|
|
|
1543
1554
|
model = 'gemini-2.5-flash'
|
|
1544
1555
|
training_dataset = types.TuningDataset(
|
|
1545
|
-
|
|
1556
|
+
# or gcs_uri=my_vertex_multimodal_dataset
|
|
1546
1557
|
gcs_uri='gs://cloud-samples-data/ai-platform/generative_ai/gemini-1_5/text/sft_train_data.jsonl',
|
|
1547
1558
|
)
|
|
1548
1559
|
```
|
|
@@ -1698,7 +1709,7 @@ job = client.batches.create(
|
|
|
1698
1709
|
src='bq://my-project.my-dataset.my-table', # or "gs://path/to/input/data"
|
|
1699
1710
|
)
|
|
1700
1711
|
|
|
1701
|
-
job
|
|
1712
|
+
print(job)
|
|
1702
1713
|
```
|
|
1703
1714
|
|
|
1704
1715
|
Gemini Developer API:
|
|
@@ -1708,13 +1719,13 @@ Gemini Developer API:
|
|
|
1708
1719
|
batch_job = client.batches.create(
|
|
1709
1720
|
model="gemini-2.5-flash",
|
|
1710
1721
|
src=[{
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1722
|
+
"contents": [{
|
|
1723
|
+
"parts": [{
|
|
1724
|
+
"text": "Hello!",
|
|
1725
|
+
}],
|
|
1726
|
+
"role": "user",
|
|
1714
1727
|
}],
|
|
1715
|
-
|
|
1716
|
-
}],
|
|
1717
|
-
"config": {"response_modalities": ["text"]},
|
|
1728
|
+
"config": {"response_modalities": ["text"]},
|
|
1718
1729
|
}],
|
|
1719
1730
|
)
|
|
1720
1731
|
|
|
@@ -1822,13 +1833,13 @@ To handle errors raised by the model service, the SDK provides this [APIError](h
|
|
|
1822
1833
|
from google.genai import errors
|
|
1823
1834
|
|
|
1824
1835
|
try:
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1836
|
+
client.models.generate_content(
|
|
1837
|
+
model="invalid-model-name",
|
|
1838
|
+
contents="What is your name?",
|
|
1839
|
+
)
|
|
1829
1840
|
except errors.APIError as e:
|
|
1830
|
-
|
|
1831
|
-
|
|
1841
|
+
print(e.code) # 404
|
|
1842
|
+
print(e.message)
|
|
1832
1843
|
```
|
|
1833
1844
|
|
|
1834
1845
|
## Extra Request Body
|
|
@@ -1,39 +1,39 @@
|
|
|
1
1
|
google/genai/__init__.py,sha256=SKz_9WQKA3R4OpJIDJlgssVfizLNDG2tuWtOD9pxrPE,729
|
|
2
2
|
google/genai/_adapters.py,sha256=Kok38miNYJff2n--l0zEK_hbq0y2rWOH7k75J7SMYbQ,1744
|
|
3
|
-
google/genai/_api_client.py,sha256=
|
|
3
|
+
google/genai/_api_client.py,sha256=magDCIaa674RDE_oyqxjHxlbZ7Gl7qSq9GHKEOd4p0w,63909
|
|
4
4
|
google/genai/_api_module.py,sha256=lj8eUWx8_LBGBz-49qz6_ywWm3GYp3d8Bg5JoOHbtbI,902
|
|
5
5
|
google/genai/_automatic_function_calling_util.py,sha256=xXNkJR-pzSMkeSXMz3Jw-kMHFbTJEiRJ3wocuwtWW4I,11627
|
|
6
6
|
google/genai/_base_transformers.py,sha256=wljA6m4tLl4XLGlBC2DNOls5N9-X9tffBq0M7i8jgpw,1034
|
|
7
7
|
google/genai/_base_url.py,sha256=E5H4dew14Y16qfnB3XRnjSCi19cJVlkaMNoM_8ip-PM,1597
|
|
8
8
|
google/genai/_common.py,sha256=6_psdFl0iBRwgyIKOuGtugpTCHPGB2zZzsJCVcI_2oI,24114
|
|
9
|
-
google/genai/_extra_utils.py,sha256=
|
|
10
|
-
google/genai/_live_converters.py,sha256=
|
|
9
|
+
google/genai/_extra_utils.py,sha256=ld4W5t38QMdx-FOvQYycUM6ejSmEnyHvt2HBCB1pwAg,23202
|
|
10
|
+
google/genai/_live_converters.py,sha256=e7TZxmdc9eCMThXKzV5pHtYMTtESei7cJeU4ok9r1Bg,42296
|
|
11
11
|
google/genai/_local_tokenizer_loader.py,sha256=cGN1F0f7hNjRIGCGTLeox7IGAZf_YcvZjSp2rCyhUak,7465
|
|
12
12
|
google/genai/_mcp_utils.py,sha256=HuWJ8FUjquv40Mf_QjcL5r5yXWrS-JjINsjlOSbbyAc,3870
|
|
13
13
|
google/genai/_operations_converters.py,sha256=8w4WSeA_KSyc56JcL1MTknZHIds0gF3E8YdriluUJfY,8708
|
|
14
14
|
google/genai/_replay_api_client.py,sha256=oCPZULWpmjahOn5pvY7KkCB_cksNwm7pc4nuTnqqqV8,22956
|
|
15
15
|
google/genai/_test_api_client.py,sha256=4ruFIy5_1qcbKqqIBu3HSQbpSOBrxiecBtDZaTGFR1s,4797
|
|
16
|
-
google/genai/_tokens_converters.py,sha256=
|
|
17
|
-
google/genai/_transformers.py,sha256=
|
|
18
|
-
google/genai/batches.py,sha256=
|
|
19
|
-
google/genai/caches.py,sha256=
|
|
16
|
+
google/genai/_tokens_converters.py,sha256=vPsx-o5y6CgQx0HqEhHggPQ0YrvmRXg6l3hM0XprA8I,14137
|
|
17
|
+
google/genai/_transformers.py,sha256=h2VV2AnKdvHQtEwiiLV3vJFezYBYSfacvPmF5kcocEE,43165
|
|
18
|
+
google/genai/batches.py,sha256=WZSxcaQd64CsZ016Mg5U2mcaMigq9ffzqVO3pOfag6o,74986
|
|
19
|
+
google/genai/caches.py,sha256=bWgXf1_6v1-a4m7gx7Y8mALrMLFCyvS5yd3XGmP04DY,44788
|
|
20
20
|
google/genai/chats.py,sha256=pIBw8d13llupLn4a7vP6vnpbzDcvCCrZZ-Q2r8Cvo7g,16652
|
|
21
|
-
google/genai/client.py,sha256=
|
|
21
|
+
google/genai/client.py,sha256=_2B9w4cyah1kepMYwaaCpEDtbL3JWSt0Qx7k1IJXCFU,13110
|
|
22
22
|
google/genai/errors.py,sha256=dLH0Bo8-Y0K7zKASU5O0y_0FSKpSFJn8JPcnwIUvtIM,6089
|
|
23
23
|
google/genai/files.py,sha256=2TkcZo7iviHA48OEjc9YnyirZ-umBUN7Z4Gdr4nHyJI,31551
|
|
24
|
-
google/genai/live.py,sha256=
|
|
24
|
+
google/genai/live.py,sha256=IzBIHjjasfHivDxhi4HvMru0G8LlkFsM_e6QCgSL1cQ,41278
|
|
25
25
|
google/genai/live_music.py,sha256=Y7I7jh5SAKgyjBIMLboH0oTnZJ18uOT2SpRDKURvp94,6783
|
|
26
26
|
google/genai/local_tokenizer.py,sha256=EKZ72cV2Zfutlo_efMOPnLRNZN4WQe57rD3G80cF340,14109
|
|
27
|
-
google/genai/models.py,sha256=
|
|
27
|
+
google/genai/models.py,sha256=6XScrBzv9Wtruf9gQV4x8Uden1Wdw87OEDMJVlHH1F0,228216
|
|
28
28
|
google/genai/operations.py,sha256=KgM5vsagUnAMGk9wKxuQYBUh_6bwrPQ9BzZvydiumQA,16208
|
|
29
29
|
google/genai/pagers.py,sha256=m0SfWWn1EJs2k1On3DZx371qb8g2BRm_188ExsicIRc,7098
|
|
30
30
|
google/genai/py.typed,sha256=RsMFoLwBkAvY05t6izop4UHZtqOPLiKp3GkIEizzmQY,40
|
|
31
31
|
google/genai/tokens.py,sha256=4BPW0gGWFeFVk3INkuY2tfREnsrvzQDhouvRI6_F9Q8,12235
|
|
32
|
-
google/genai/tunings.py,sha256=
|
|
33
|
-
google/genai/types.py,sha256=
|
|
34
|
-
google/genai/version.py,sha256=
|
|
35
|
-
google_genai-1.
|
|
36
|
-
google_genai-1.
|
|
37
|
-
google_genai-1.
|
|
38
|
-
google_genai-1.
|
|
39
|
-
google_genai-1.
|
|
32
|
+
google/genai/tunings.py,sha256=qCkvzZsqlfJL-KPUtZtjTp4rQeLYTc5LCYJfJgKyJhM,63586
|
|
33
|
+
google/genai/types.py,sha256=pEJ8R9OmWxzFgEd9rZ-CDvw6vClpqnhoq_BdU87UJ3I,582585
|
|
34
|
+
google/genai/version.py,sha256=KI452uyiQJlyNkY4COWWobH2eHDIBQtP1914F70h9Pk,627
|
|
35
|
+
google_genai-1.47.0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
|
36
|
+
google_genai-1.47.0.dist-info/METADATA,sha256=haiWzFF16ZcBtMhrZObgZpLbdmBlTxZ407mfHChCxCU,46781
|
|
37
|
+
google_genai-1.47.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
38
|
+
google_genai-1.47.0.dist-info/top_level.txt,sha256=_1QvSJIhFAGfxb79D6DhB7SUw2X6T4rwnz_LLrbcD3c,7
|
|
39
|
+
google_genai-1.47.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|