google-genai 1.46.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 +38 -15
- google/genai/_extra_utils.py +4 -0
- google/genai/_live_converters.py +61 -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 +89 -71
- google/genai/tunings.py +269 -94
- google/genai/types.py +1386 -1003
- google/genai/version.py +1 -1
- {google_genai-1.46.0.dist-info → google_genai-1.47.0.dist-info}/METADATA +151 -161
- {google_genai-1.46.0.dist-info → google_genai-1.47.0.dist-info}/RECORD +18 -18
- {google_genai-1.46.0.dist-info → google_genai-1.47.0.dist-info}/WHEEL +0 -0
- {google_genai-1.46.0.dist-info → google_genai-1.47.0.dist-info}/licenses/LICENSE +0 -0
- {google_genai-1.46.0.dist-info → google_genai-1.47.0.dist-info}/top_level.txt +0 -0
google/genai/version.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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
6
|
License-Expression: Apache-2.0
|
|
@@ -23,7 +23,7 @@ License-File: LICENSE
|
|
|
23
23
|
Requires-Dist: anyio<5.0.0,>=4.8.0
|
|
24
24
|
Requires-Dist: google-auth<3.0.0,>=2.14.1
|
|
25
25
|
Requires-Dist: httpx<1.0.0,>=0.28.1
|
|
26
|
-
Requires-Dist: pydantic<3.0.0,>=2.
|
|
26
|
+
Requires-Dist: pydantic<3.0.0,>=2.9.0
|
|
27
27
|
Requires-Dist: requests<3.0.0,>=2.28.1
|
|
28
28
|
Requires-Dist: tenacity<9.2.0,>=8.2.3
|
|
29
29
|
Requires-Dist: websockets<15.1.0,>=13.0.0
|
|
@@ -128,7 +128,6 @@ Explicitly close the sync client to ensure that resources, such as the
|
|
|
128
128
|
underlying HTTP connections, are properly cleaned up and closed.
|
|
129
129
|
|
|
130
130
|
```python
|
|
131
|
-
|
|
132
131
|
from google.genai import Client
|
|
133
132
|
|
|
134
133
|
client = Client()
|
|
@@ -147,7 +146,6 @@ client.close()
|
|
|
147
146
|
To explicitly close the async client:
|
|
148
147
|
|
|
149
148
|
```python
|
|
150
|
-
|
|
151
149
|
from google.genai import Client
|
|
152
150
|
|
|
153
151
|
aclient = Client(
|
|
@@ -174,15 +172,14 @@ By using the sync client context manager, it will close the underlying
|
|
|
174
172
|
from google.genai import Client
|
|
175
173
|
|
|
176
174
|
with Client() as client:
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
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
|
+
)
|
|
186
183
|
```
|
|
187
184
|
|
|
188
185
|
By using the async client context manager, it will close the underlying
|
|
@@ -192,15 +189,14 @@ By using the async client context manager, it will close the underlying
|
|
|
192
189
|
from google.genai import Client
|
|
193
190
|
|
|
194
191
|
async with Client().aio as aclient:
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
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
|
+
)
|
|
204
200
|
```
|
|
205
201
|
|
|
206
202
|
### API Selection
|
|
@@ -245,7 +241,6 @@ Additional args of `aiohttp.ClientSession.request()` ([see _RequestOptions args]
|
|
|
245
241
|
through the following way:
|
|
246
242
|
|
|
247
243
|
```python
|
|
248
|
-
|
|
249
244
|
http_options = types.HttpOptions(
|
|
250
245
|
async_client_args={'cookies': ..., 'ssl': ...},
|
|
251
246
|
)
|
|
@@ -259,7 +254,6 @@ Both httpx and aiohttp libraries use `urllib.request.getproxies` from
|
|
|
259
254
|
environment variables. Before client initialization, you may set proxy (and
|
|
260
255
|
optional SSL_CERT_FILE) by setting the environment variables:
|
|
261
256
|
|
|
262
|
-
|
|
263
257
|
```bash
|
|
264
258
|
export HTTPS_PROXY='http://username:password@proxy_uri:port'
|
|
265
259
|
export SSL_CERT_FILE='client.pem'
|
|
@@ -270,7 +264,6 @@ args to `httpx.Client()`. You may install `httpx[socks]` to use it.
|
|
|
270
264
|
Then, you can pass it through the following way:
|
|
271
265
|
|
|
272
266
|
```python
|
|
273
|
-
|
|
274
267
|
http_options = types.HttpOptions(
|
|
275
268
|
client_args={'proxy': 'socks5://user:pass@host:port'},
|
|
276
269
|
async_client_args={'proxy': 'socks5://user:pass@host:port'},
|
|
@@ -286,16 +279,14 @@ In some cases you might need a custom base url (for example, API gateway proxy
|
|
|
286
279
|
You may pass the custom base url like this:
|
|
287
280
|
|
|
288
281
|
```python
|
|
289
|
-
|
|
290
282
|
base_url = 'https://test-api-gateway-proxy.com'
|
|
291
283
|
client = Client(
|
|
292
|
-
vertexai=True
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
284
|
+
vertexai=True, # Currently only vertexai=True is supported
|
|
285
|
+
http_options={
|
|
286
|
+
'base_url': base_url,
|
|
287
|
+
'headers': {'Authorization': 'Bearer test_token'},
|
|
288
|
+
},
|
|
297
289
|
)
|
|
298
|
-
|
|
299
290
|
```
|
|
300
291
|
|
|
301
292
|
## Types
|
|
@@ -329,17 +320,17 @@ response = client.models.generate_content(
|
|
|
329
320
|
model='gemini-2.5-flash-image',
|
|
330
321
|
contents='A cartoon infographic for flying sneakers',
|
|
331
322
|
config=types.GenerateContentConfig(
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
323
|
+
response_modalities=["IMAGE"],
|
|
324
|
+
image_config=types.ImageConfig(
|
|
325
|
+
aspect_ratio="9:16",
|
|
326
|
+
),
|
|
336
327
|
),
|
|
337
328
|
)
|
|
338
329
|
|
|
339
330
|
for part in response.parts:
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
331
|
+
if part.inline_data:
|
|
332
|
+
generated_image = part.as_image()
|
|
333
|
+
generated_image.show()
|
|
343
334
|
```
|
|
344
335
|
|
|
345
336
|
#### with uploaded file (Gemini Developer API only)
|
|
@@ -374,8 +365,8 @@ This is the canonical way to provide contents, SDK will not do any conversion.
|
|
|
374
365
|
from google.genai import types
|
|
375
366
|
|
|
376
367
|
contents = types.Content(
|
|
377
|
-
|
|
378
|
-
|
|
368
|
+
role='user',
|
|
369
|
+
parts=[types.Part.from_text(text='Why is the sky blue?')]
|
|
379
370
|
)
|
|
380
371
|
```
|
|
381
372
|
|
|
@@ -383,10 +374,10 @@ SDK converts this to
|
|
|
383
374
|
|
|
384
375
|
```python
|
|
385
376
|
[
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
377
|
+
types.Content(
|
|
378
|
+
role='user',
|
|
379
|
+
parts=[types.Part.from_text(text='Why is the sky blue?')]
|
|
380
|
+
)
|
|
390
381
|
]
|
|
391
382
|
```
|
|
392
383
|
|
|
@@ -400,11 +391,11 @@ The SDK will assume this is a text part, and it converts this into the following
|
|
|
400
391
|
|
|
401
392
|
```python
|
|
402
393
|
[
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
394
|
+
types.UserContent(
|
|
395
|
+
parts=[
|
|
396
|
+
types.Part.from_text(text='Why is the sky blue?')
|
|
397
|
+
]
|
|
398
|
+
)
|
|
408
399
|
]
|
|
409
400
|
```
|
|
410
401
|
|
|
@@ -422,12 +413,12 @@ like the following:
|
|
|
422
413
|
|
|
423
414
|
```python
|
|
424
415
|
[
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
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
|
+
)
|
|
431
422
|
]
|
|
432
423
|
```
|
|
433
424
|
|
|
@@ -440,8 +431,8 @@ Where a `types.UserContent` is a subclass of `types.Content`, the
|
|
|
440
431
|
from google.genai import types
|
|
441
432
|
|
|
442
433
|
contents = types.Part.from_function_call(
|
|
443
|
-
|
|
444
|
-
|
|
434
|
+
name='get_weather_by_location',
|
|
435
|
+
args={'location': 'Boston'}
|
|
445
436
|
)
|
|
446
437
|
```
|
|
447
438
|
|
|
@@ -449,14 +440,14 @@ The SDK converts a function call part to a content with a `model` role:
|
|
|
449
440
|
|
|
450
441
|
```python
|
|
451
442
|
[
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
443
|
+
types.ModelContent(
|
|
444
|
+
parts=[
|
|
445
|
+
types.Part.from_function_call(
|
|
446
|
+
name='get_weather_by_location',
|
|
447
|
+
args={'location': 'Boston'}
|
|
448
|
+
)
|
|
449
|
+
]
|
|
450
|
+
)
|
|
460
451
|
]
|
|
461
452
|
```
|
|
462
453
|
|
|
@@ -469,14 +460,14 @@ Where a `types.ModelContent` is a subclass of `types.Content`, the
|
|
|
469
460
|
from google.genai import types
|
|
470
461
|
|
|
471
462
|
contents = [
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
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
|
+
),
|
|
480
471
|
]
|
|
481
472
|
```
|
|
482
473
|
|
|
@@ -484,18 +475,18 @@ The SDK converts a list of function call parts to the a content with a `model` r
|
|
|
484
475
|
|
|
485
476
|
```python
|
|
486
477
|
[
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
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
|
+
)
|
|
499
490
|
]
|
|
500
491
|
```
|
|
501
492
|
|
|
@@ -508,8 +499,8 @@ Where a `types.ModelContent` is a subclass of `types.Content`, the
|
|
|
508
499
|
from google.genai import types
|
|
509
500
|
|
|
510
501
|
contents = types.Part.from_uri(
|
|
511
|
-
|
|
512
|
-
|
|
502
|
+
file_uri: 'gs://generativeai-downloads/images/scones.jpg',
|
|
503
|
+
mime_type: 'image/jpeg',
|
|
513
504
|
)
|
|
514
505
|
```
|
|
515
506
|
|
|
@@ -517,12 +508,12 @@ The SDK converts all non function call parts into a content with a `user` role.
|
|
|
517
508
|
|
|
518
509
|
```python
|
|
519
510
|
[
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
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
|
+
])
|
|
526
517
|
]
|
|
527
518
|
```
|
|
528
519
|
|
|
@@ -532,11 +523,11 @@ The SDK converts all non function call parts into a content with a `user` role.
|
|
|
532
523
|
from google.genai import types
|
|
533
524
|
|
|
534
525
|
contents = [
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
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
|
+
)
|
|
540
531
|
]
|
|
541
532
|
```
|
|
542
533
|
|
|
@@ -544,15 +535,15 @@ The SDK will convert the list of parts into a content with a `user` role
|
|
|
544
535
|
|
|
545
536
|
```python
|
|
546
537
|
[
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
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
|
+
)
|
|
556
547
|
]
|
|
557
548
|
```
|
|
558
549
|
|
|
@@ -686,7 +677,7 @@ def get_current_weather(location: str) -> str:
|
|
|
686
677
|
"""Returns the current weather.
|
|
687
678
|
|
|
688
679
|
Args:
|
|
689
|
-
|
|
680
|
+
location: The city and state, e.g. San Francisco, CA
|
|
690
681
|
"""
|
|
691
682
|
return 'sunny'
|
|
692
683
|
|
|
@@ -708,14 +699,14 @@ as follows:
|
|
|
708
699
|
from google.genai import types
|
|
709
700
|
|
|
710
701
|
response = client.models.generate_content(
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
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
|
+
),
|
|
717
709
|
),
|
|
718
|
-
),
|
|
719
710
|
)
|
|
720
711
|
```
|
|
721
712
|
|
|
@@ -829,7 +820,7 @@ def get_current_weather(location: str) -> str:
|
|
|
829
820
|
"""Returns the current weather.
|
|
830
821
|
|
|
831
822
|
Args:
|
|
832
|
-
|
|
823
|
+
location: The city and state, e.g. San Francisco, CA
|
|
833
824
|
"""
|
|
834
825
|
return "sunny"
|
|
835
826
|
|
|
@@ -859,7 +850,7 @@ def get_current_weather(location: str) -> str:
|
|
|
859
850
|
"""Returns the current weather.
|
|
860
851
|
|
|
861
852
|
Args:
|
|
862
|
-
|
|
853
|
+
location: The city and state, e.g. San Francisco, CA
|
|
863
854
|
"""
|
|
864
855
|
return "sunny"
|
|
865
856
|
|
|
@@ -1039,20 +1030,20 @@ values as the response.
|
|
|
1039
1030
|
from enum import Enum
|
|
1040
1031
|
|
|
1041
1032
|
class InstrumentEnum(Enum):
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1033
|
+
PERCUSSION = 'Percussion'
|
|
1034
|
+
STRING = 'String'
|
|
1035
|
+
WOODWIND = 'Woodwind'
|
|
1036
|
+
BRASS = 'Brass'
|
|
1037
|
+
KEYBOARD = 'Keyboard'
|
|
1047
1038
|
|
|
1048
1039
|
response = client.models.generate_content(
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
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
|
+
)
|
|
1056
1047
|
print(response.text)
|
|
1057
1048
|
```
|
|
1058
1049
|
|
|
@@ -1065,20 +1056,20 @@ identical but in quotes.
|
|
|
1065
1056
|
from enum import Enum
|
|
1066
1057
|
|
|
1067
1058
|
class InstrumentEnum(Enum):
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1059
|
+
PERCUSSION = 'Percussion'
|
|
1060
|
+
STRING = 'String'
|
|
1061
|
+
WOODWIND = 'Woodwind'
|
|
1062
|
+
BRASS = 'Brass'
|
|
1063
|
+
KEYBOARD = 'Keyboard'
|
|
1073
1064
|
|
|
1074
1065
|
response = client.models.generate_content(
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
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
|
+
)
|
|
1082
1073
|
print(response.text)
|
|
1083
1074
|
```
|
|
1084
1075
|
|
|
@@ -1156,7 +1147,6 @@ print(response.text)
|
|
|
1156
1147
|
|
|
1157
1148
|
### Generate Content (Asynchronous Streaming)
|
|
1158
1149
|
|
|
1159
|
-
|
|
1160
1150
|
```python
|
|
1161
1151
|
async for chunk in await client.aio.models.generate_content_stream(
|
|
1162
1152
|
model='gemini-2.5-flash', contents='Tell me a story in 300 words.'
|
|
@@ -1214,7 +1204,7 @@ result = tokenizer.compute_tokens("What is your name?")
|
|
|
1214
1204
|
|
|
1215
1205
|
```python
|
|
1216
1206
|
response = client.models.embed_content(
|
|
1217
|
-
model='
|
|
1207
|
+
model='gemini-embedding-001',
|
|
1218
1208
|
contents='why is the sky blue?',
|
|
1219
1209
|
)
|
|
1220
1210
|
print(response)
|
|
@@ -1225,7 +1215,7 @@ from google.genai import types
|
|
|
1225
1215
|
|
|
1226
1216
|
# multiple contents with config
|
|
1227
1217
|
response = client.models.embed_content(
|
|
1228
|
-
model='
|
|
1218
|
+
model='gemini-embedding-001',
|
|
1229
1219
|
contents=['why is the sky blue?', 'What is your age?'],
|
|
1230
1220
|
config=types.EmbedContentConfig(output_dimensionality=10),
|
|
1231
1221
|
)
|
|
@@ -1455,7 +1445,7 @@ async for chunk in await chat.send_message_stream('tell me a story'):
|
|
|
1455
1445
|
Files are only supported in Gemini Developer API. See the 'Create a client'
|
|
1456
1446
|
section above to initialize a client.
|
|
1457
1447
|
|
|
1458
|
-
```
|
|
1448
|
+
```sh
|
|
1459
1449
|
!gsutil cp gs://cloud-samples-data/generative-ai/pdf/2312.11805v3.pdf .
|
|
1460
1450
|
!gsutil cp gs://cloud-samples-data/generative-ai/pdf/2403.05530.pdf .
|
|
1461
1451
|
```
|
|
@@ -1556,14 +1546,14 @@ section above to initialize a client.
|
|
|
1556
1546
|
|
|
1557
1547
|
### Tune
|
|
1558
1548
|
|
|
1559
|
-
- 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)
|
|
1560
1550
|
|
|
1561
1551
|
```python
|
|
1562
1552
|
from google.genai import types
|
|
1563
1553
|
|
|
1564
1554
|
model = 'gemini-2.5-flash'
|
|
1565
1555
|
training_dataset = types.TuningDataset(
|
|
1566
|
-
|
|
1556
|
+
# or gcs_uri=my_vertex_multimodal_dataset
|
|
1567
1557
|
gcs_uri='gs://cloud-samples-data/ai-platform/generative_ai/gemini-1_5/text/sft_train_data.jsonl',
|
|
1568
1558
|
)
|
|
1569
1559
|
```
|
|
@@ -1719,7 +1709,7 @@ job = client.batches.create(
|
|
|
1719
1709
|
src='bq://my-project.my-dataset.my-table', # or "gs://path/to/input/data"
|
|
1720
1710
|
)
|
|
1721
1711
|
|
|
1722
|
-
job
|
|
1712
|
+
print(job)
|
|
1723
1713
|
```
|
|
1724
1714
|
|
|
1725
1715
|
Gemini Developer API:
|
|
@@ -1729,13 +1719,13 @@ Gemini Developer API:
|
|
|
1729
1719
|
batch_job = client.batches.create(
|
|
1730
1720
|
model="gemini-2.5-flash",
|
|
1731
1721
|
src=[{
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1722
|
+
"contents": [{
|
|
1723
|
+
"parts": [{
|
|
1724
|
+
"text": "Hello!",
|
|
1725
|
+
}],
|
|
1726
|
+
"role": "user",
|
|
1735
1727
|
}],
|
|
1736
|
-
|
|
1737
|
-
}],
|
|
1738
|
-
"config": {"response_modalities": ["text"]},
|
|
1728
|
+
"config": {"response_modalities": ["text"]},
|
|
1739
1729
|
}],
|
|
1740
1730
|
)
|
|
1741
1731
|
|
|
@@ -1843,13 +1833,13 @@ To handle errors raised by the model service, the SDK provides this [APIError](h
|
|
|
1843
1833
|
from google.genai import errors
|
|
1844
1834
|
|
|
1845
1835
|
try:
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1836
|
+
client.models.generate_content(
|
|
1837
|
+
model="invalid-model-name",
|
|
1838
|
+
contents="What is your name?",
|
|
1839
|
+
)
|
|
1850
1840
|
except errors.APIError as e:
|
|
1851
|
-
|
|
1852
|
-
|
|
1841
|
+
print(e.code) # 404
|
|
1842
|
+
print(e.message)
|
|
1853
1843
|
```
|
|
1854
1844
|
|
|
1855
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
|