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/version.py
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# Copyright 2024 Google LLC
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
#
|
15
|
+
|
16
|
+
__version__ = '0.4.0' # x-release-please-version
|
@@ -1,6 +1,6 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.2
|
2
2
|
Name: google-genai
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.4.0
|
4
4
|
Summary: GenAI Python SDK
|
5
5
|
Author-email: Google LLC <googleapis-packages@google.com>
|
6
6
|
License: Apache-2.0
|
@@ -35,6 +35,12 @@ Requires-Dist: websockets<15.0dev,>=13.0
|
|
35
35
|
|
36
36
|
-----
|
37
37
|
|
38
|
+
## Installation
|
39
|
+
|
40
|
+
``` cmd
|
41
|
+
pip install google-genai
|
42
|
+
```
|
43
|
+
|
38
44
|
## Imports
|
39
45
|
|
40
46
|
``` python
|
@@ -430,10 +436,10 @@ response1 = client.models.generate_image(
|
|
430
436
|
model='imagen-3.0-generate-001',
|
431
437
|
prompt='An umbrella in the foreground, and a rainy night sky in the background',
|
432
438
|
config=types.GenerateImageConfig(
|
433
|
-
negative_prompt=
|
439
|
+
negative_prompt= 'human',
|
434
440
|
number_of_images= 1,
|
435
441
|
include_rai_reason= True,
|
436
|
-
output_mime_type=
|
442
|
+
output_mime_type= 'image/jpeg'
|
437
443
|
)
|
438
444
|
)
|
439
445
|
response1.generated_images[0].image.show()
|
@@ -448,13 +454,19 @@ Upscale image is not supported in Google AI.
|
|
448
454
|
response2 = client.models.upscale_image(
|
449
455
|
model='imagen-3.0-generate-001',
|
450
456
|
image=response1.generated_images[0].image,
|
451
|
-
|
457
|
+
upscale_factor='x2',
|
458
|
+
config=types.UpscaleImageConfig(
|
459
|
+
include_rai_reason= True,
|
460
|
+
output_mime_type= 'image/jpeg',
|
461
|
+
),
|
452
462
|
)
|
453
463
|
response2.generated_images[0].image.show()
|
454
464
|
```
|
455
465
|
|
456
466
|
#### Edit Image
|
457
467
|
|
468
|
+
Edit image uses a separate model from generate and upscale.
|
469
|
+
|
458
470
|
Edit image is not supported in Google AI.
|
459
471
|
|
460
472
|
``` python
|
@@ -475,7 +487,7 @@ mask_ref_image = MaskReferenceImage(
|
|
475
487
|
)
|
476
488
|
|
477
489
|
response3 = client.models.edit_image(
|
478
|
-
model='imagen-3.0-capability-
|
490
|
+
model='imagen-3.0-capability-001',
|
479
491
|
prompt='Sunlight and clear sky',
|
480
492
|
reference_images=[raw_ref_image, mask_ref_image],
|
481
493
|
config=types.EditImageConfig(
|
@@ -489,6 +501,42 @@ response3 = client.models.edit_image(
|
|
489
501
|
response3.generated_images[0].image.show()
|
490
502
|
```
|
491
503
|
|
504
|
+
## Chats
|
505
|
+
|
506
|
+
Create a chat session to start a multi-turn conversations with the model.
|
507
|
+
|
508
|
+
### Send Message
|
509
|
+
|
510
|
+
```python
|
511
|
+
chat = client.chats.create(model='gemini-2.0-flash-exp')
|
512
|
+
response = chat.send_message('tell me a story')
|
513
|
+
print(response.text)
|
514
|
+
```
|
515
|
+
|
516
|
+
### Streaming
|
517
|
+
|
518
|
+
```python
|
519
|
+
chat = client.chats.create(model='gemini-2.0-flash-exp')
|
520
|
+
for chunk in chat.send_message_stream('tell me a story'):
|
521
|
+
print(chunk.text)
|
522
|
+
```
|
523
|
+
|
524
|
+
### Async
|
525
|
+
|
526
|
+
```python
|
527
|
+
chat = client.aio.chats.create(model='gemini-2.0-flash-exp')
|
528
|
+
response = await chat.send_message('tell me a story')
|
529
|
+
print(response.text)
|
530
|
+
```
|
531
|
+
|
532
|
+
### Async Streaming
|
533
|
+
|
534
|
+
```python
|
535
|
+
chat = client.aio.chats.create(model='gemini-2.0-flash-exp')
|
536
|
+
async for chunk in chat.send_message_stream('tell me a story'):
|
537
|
+
print(chunk.text)
|
538
|
+
```
|
539
|
+
|
492
540
|
## Files (Only Google AI)
|
493
541
|
|
494
542
|
``` python
|
@@ -531,20 +579,20 @@ else:
|
|
531
579
|
|
532
580
|
cached_content = client.caches.create(
|
533
581
|
model='gemini-1.5-pro-002',
|
534
|
-
contents=[
|
535
|
-
types.Content(
|
536
|
-
role='user',
|
537
|
-
parts=[
|
538
|
-
types.Part.from_uri(
|
539
|
-
file_uri=file_uris[0],
|
540
|
-
mime_type='application/pdf'),
|
541
|
-
types.Part.from_uri(
|
542
|
-
file_uri=file_uris[1],
|
543
|
-
mime_type='application/pdf',)])
|
544
|
-
],
|
545
582
|
config=types.CreateCachedContentConfig(
|
546
|
-
|
583
|
+
contents=[
|
584
|
+
types.Content(
|
585
|
+
role='user',
|
586
|
+
parts=[
|
587
|
+
types.Part.from_uri(
|
588
|
+
file_uri=file_uris[0],
|
589
|
+
mime_type='application/pdf'),
|
590
|
+
types.Part.from_uri(
|
591
|
+
file_uri=file_uris[1],
|
592
|
+
mime_type='application/pdf',)])
|
593
|
+
],
|
547
594
|
system_instruction='What is the sum of the two pdfs?',
|
595
|
+
display_name='test cache',
|
548
596
|
ttl='3600s',
|
549
597
|
),
|
550
598
|
)
|
@@ -0,0 +1,25 @@
|
|
1
|
+
google/genai/__init__.py,sha256=IYw-PcsdgjSpS1mU_ZcYkTfPocsJ4aVmrDxP7vX7c6Y,709
|
2
|
+
google/genai/_api_client.py,sha256=xcfLLi8xwZnoprvZZQ8AU_ndDvgR1JPG3jMpSv7aF74,17909
|
3
|
+
google/genai/_automatic_function_calling_util.py,sha256=qbMCO8x6THe1O7Bn-L97rlbDSYJoX_gUfztvKHh-u6E,10078
|
4
|
+
google/genai/_common.py,sha256=Yj5cBkq5QRNFSBqvpB949Rjo7cbIhdtKp5dJxMW_I6I,7971
|
5
|
+
google/genai/_extra_utils.py,sha256=GQZnraFCrMffqrBEpurdcBmgrltRsnYgMizt-Ok6xX8,11098
|
6
|
+
google/genai/_replay_api_client.py,sha256=emeqe48BQt-_fLOXE_nsMZaCdJ488-Gv6hL9bY9frj0,16418
|
7
|
+
google/genai/_test_api_client.py,sha256=p771T27icmzENxKtyNDwPG1sTI7jaoJNFPwlwq9GK6o,4759
|
8
|
+
google/genai/_transformers.py,sha256=_2p1HbZYeDYfQiu24gLBRwMh5HqzSRgDHy9XvZTvogQ,13900
|
9
|
+
google/genai/batches.py,sha256=-Le43cdO_EZBoZGWhAX5bevqklEWj9Uu8f8NvMmZYKU,37316
|
10
|
+
google/genai/caches.py,sha256=KTjDw3H--VC1b2iI6enVByeEbPwVSJperh0qjwx758M,53684
|
11
|
+
google/genai/chats.py,sha256=cTr0B3n5mmKEgqpFdE5kt2dEXMGnk0c5oncZhDNn2fo,7645
|
12
|
+
google/genai/client.py,sha256=2W4AkvNNI6JnjOCtl-swBIaB1Z89zPqnvUc7RCGy3uE,9488
|
13
|
+
google/genai/errors.py,sha256=ZqJvfuJ7oS334WBrq3otzdZfmhEgcM1OBZhHccYzDok,3665
|
14
|
+
google/genai/files.py,sha256=P3hH6o47rAjtsKaMV6NwpFUWSTFEfeaKvzdKkNH-bdI,35837
|
15
|
+
google/genai/live.py,sha256=xK3VwBr5eSA4EcxElmWOfwu-cYCZapvd5v9cLziSz_k,22615
|
16
|
+
google/genai/models.py,sha256=oL8yhl-bSx-I8POyaqQAU0vy0OSxu0SaCOXnxQ_EZQU,156511
|
17
|
+
google/genai/pagers.py,sha256=hSHd-gLvEzYWwK85i8EcFNWUMKtszUs7Nw2r3L7d6_U,6686
|
18
|
+
google/genai/tunings.py,sha256=yH8FyI-srLfXq7gbedo_E_e1XclHz6NjXOTVU24ZNOs,49214
|
19
|
+
google/genai/types.py,sha256=vg8FaUs8HfYTQ_A4VCVS12Tjba75heOmavNqbAq4wY0,266417
|
20
|
+
google/genai/version.py,sha256=vaXyYIZ_ueDr5i0g0zejl7pfmDRB-zyWuynATlcxcbo,626
|
21
|
+
google_genai-0.4.0.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
22
|
+
google_genai-0.4.0.dist-info/METADATA,sha256=dq-dC8S6gk3n7MfXghjxfZ-JZDwSke51PWbQvTkPhcc,20164
|
23
|
+
google_genai-0.4.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
24
|
+
google_genai-0.4.0.dist-info/top_level.txt,sha256=_1QvSJIhFAGfxb79D6DhB7SUw2X6T4rwnz_LLrbcD3c,7
|
25
|
+
google_genai-0.4.0.dist-info/RECORD,,
|
@@ -1,24 +0,0 @@
|
|
1
|
-
google/genai/__init__.py,sha256=R7sy9MQmlItVERIQEWt25bApyNXxDIkYP4nl3-EtX50,674
|
2
|
-
google/genai/_api_client.py,sha256=naJy-6OjgjUNlciZNxDconmSOFhewD_0QsggNY1aCik,15950
|
3
|
-
google/genai/_automatic_function_calling_util.py,sha256=E25_66RH3DbDIucq7x-93XWPPBwB9FnzwD1NCGyPrjM,10242
|
4
|
-
google/genai/_common.py,sha256=Yj5cBkq5QRNFSBqvpB949Rjo7cbIhdtKp5dJxMW_I6I,7971
|
5
|
-
google/genai/_extra_utils.py,sha256=GQZnraFCrMffqrBEpurdcBmgrltRsnYgMizt-Ok6xX8,11098
|
6
|
-
google/genai/_replay_api_client.py,sha256=QPNg4SBpOLS58bx-kuJQngxy1tbjMpCpJzmImCwYePA,16226
|
7
|
-
google/genai/_test_api_client.py,sha256=p771T27icmzENxKtyNDwPG1sTI7jaoJNFPwlwq9GK6o,4759
|
8
|
-
google/genai/_transformers.py,sha256=_zWNr7zFTrUFniECYaZUn0n4TdioLpj783l3-z1XvIE,13443
|
9
|
-
google/genai/batches.py,sha256=Wi4Kptampp2WepAqv_AawwNCR6MKVhLKmzJdYXDQ_aE,37148
|
10
|
-
google/genai/caches.py,sha256=LJm2raykec7_iCHsVbEtX4v942mR-OSQvxTVKcBN2RA,53434
|
11
|
-
google/genai/chats.py,sha256=x-vCXrsxZ8kdEZ_0ZDfrBQnQ9urCr42x3urP0OXHyTo,5688
|
12
|
-
google/genai/client.py,sha256=HH_lYnjPOwW-4Vgynyw4K8cwurT2g578Dc51H_uk7GY,9244
|
13
|
-
google/genai/errors.py,sha256=ZqJvfuJ7oS334WBrq3otzdZfmhEgcM1OBZhHccYzDok,3665
|
14
|
-
google/genai/files.py,sha256=dn3q8P9aTN9OG3PtA4AYDs9hF6Uk-jkMjgAW7dSlt_4,35573
|
15
|
-
google/genai/live.py,sha256=T-pOtq7k43wE2VjQzqLrx-kqhotS66I2PY_NHBdv9G8,22056
|
16
|
-
google/genai/models.py,sha256=t5XgwlgkNrQKb6eww0oBGzjMiMQaj-BQedc8lVdJHz4,154834
|
17
|
-
google/genai/pagers.py,sha256=hSHd-gLvEzYWwK85i8EcFNWUMKtszUs7Nw2r3L7d6_U,6686
|
18
|
-
google/genai/tunings.py,sha256=tFTSEaECKZ6xeYcxUTIKUmXqPoDymYP3eyTcEKjnPa4,49010
|
19
|
-
google/genai/types.py,sha256=JC7CBQVRzVwImsT03t6Qv_vMYq8V58z3SF-rzvrUJHc,263839
|
20
|
-
google_genai-0.2.2.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
21
|
-
google_genai-0.2.2.dist-info/METADATA,sha256=Q1eNLWWM0fqko3S5gfudpPYrlmnebdnXXLOJGjAtmG0,19175
|
22
|
-
google_genai-0.2.2.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
23
|
-
google_genai-0.2.2.dist-info/top_level.txt,sha256=_1QvSJIhFAGfxb79D6DhB7SUw2X6T4rwnz_LLrbcD3c,7
|
24
|
-
google_genai-0.2.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|