google-genai 1.4.0__py3-none-any.whl → 1.6.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: google-genai
3
- Version: 1.4.0
3
+ Version: 1.6.0
4
4
  Summary: GenAI Python SDK
5
5
  Author-email: Google LLC <googleapis-packages@google.com>
6
6
  License: Apache-2.0
@@ -20,12 +20,13 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
20
  Requires-Python: >=3.9
21
21
  Description-Content-Type: text/markdown
22
22
  License-File: LICENSE
23
- Requires-Dist: google-auth<3.0.0dev,>=2.14.1
24
- Requires-Dist: httpx<1.0.0dev,>=0.28.1
25
- Requires-Dist: pydantic<3.0.0dev,>=2.0.0
26
- Requires-Dist: requests<3.0.0dev,>=2.28.1
27
- Requires-Dist: websockets<15.0dev,>=13.0
28
- Requires-Dist: typing-extensions<5.0.0dev,>=4.11.0
23
+ Requires-Dist: anyio<5.0.0,>=4.8.0
24
+ Requires-Dist: google-auth<3.0.0,>=2.14.1
25
+ Requires-Dist: httpx<1.0.0,>=0.28.1
26
+ Requires-Dist: pydantic<3.0.0,>=2.0.0
27
+ Requires-Dist: requests<3.0.0,>=2.28.1
28
+ Requires-Dist: websockets<15.0.0,>=13.0.0
29
+ Requires-Dist: typing-extensions<5.0.0,>=4.11.0
29
30
 
30
31
  # Google Gen AI SDK
31
32
 
@@ -159,37 +160,202 @@ response = client.models.generate_content(
159
160
  print(response.text)
160
161
  ```
161
162
 
162
- #### How to structure `contents`
163
- There are several ways to structure the `contents` in your request.
163
+ #### How to structure `contents` argument for `generate_content`
164
+ The SDK always converts the inputs to the `contents` argument into
165
+ `list[types.Content]`.
166
+ The following shows some common ways to provide your inputs.
164
167
 
165
- Provide a single string as shown in the text example above:
168
+ ##### Provide a `list[types.Content]`
169
+ This is the canonical way to provide contents, SDK will not do any conversion.
170
+
171
+ ##### Provide a `types.Content` instance
172
+
173
+ ```python
174
+ contents = types.Content(
175
+ role='user',
176
+ parts=[types.Part.from_text(text='Why is the sky blue?')]
177
+ )
178
+ ```
179
+
180
+ SDK converts this to
181
+
182
+ ```python
183
+ [
184
+ types.Content(
185
+ role='user',
186
+ parts=[types.Part.from_text(text='Why is the sky blue?')]
187
+ )
188
+ ]
189
+ ```
190
+
191
+ ##### Provide a string
192
+
193
+ ```python
194
+ contents='Why is the sky blue?'
195
+ ```
196
+
197
+ The SDK will assume this is a text part, and it converts this into the following:
198
+
199
+ ```python
200
+ [
201
+ types.UserContent(
202
+ parts=[
203
+ types.Part.from_text(text='Why is the sky blue?')
204
+ ]
205
+ )
206
+ ]
207
+ ```
208
+
209
+ Where a `types.UserContent` is a subclass of `types.Content`, it sets the
210
+ `role` field to be `user`.
211
+
212
+ ##### Provide a list of string
213
+
214
+ ```python
215
+ contents=['Why is the sky blue?', 'Why is the cloud white?']
216
+ ```
217
+
218
+ The SDK assumes these are 2 text parts, it converts this into a single content,
219
+ like the following:
220
+
221
+ ```python
222
+ [
223
+ types.UserContent(
224
+ parts=[
225
+ types.Part.from_text(text='Why is the sky blue?'),
226
+ types.Part.from_text(text='Why is the cloud white?'),
227
+ ]
228
+ )
229
+ ]
230
+ ```
231
+
232
+ Where a `types.UserContent` is a subclass of `types.Content`, the
233
+ `role` field in `types.UserContent` is fixed to be `user`.
234
+
235
+ ##### Provide a function call part
236
+
237
+ ```python
238
+ contents = types.Part.from_function_call(
239
+ name='get_weather_by_location',
240
+ args={'location': 'Boston'}
241
+ )
242
+ ```
243
+
244
+ The SDK converts a function call part to a content with a `model` role:
245
+
246
+ ```python
247
+ [
248
+ types.ModelContent(
249
+ parts=[
250
+ types.Part.from_function_call(
251
+ name='get_weather_by_location',
252
+ args={'location': 'Boston'}
253
+ )
254
+ ]
255
+ )
256
+ ]
257
+ ```
258
+
259
+ Where a `types.ModelContent` is a subclass of `types.Content`, the
260
+ `role` field in `types.ModelContent` is fixed to be `model`.
261
+
262
+ ##### Provide a list of function call parts
166
263
 
167
264
  ```python
168
- contents='Can you recommend some things to do in Boston and New York in the winter?'
265
+ contents = [
266
+ types.Part.from_function_call(
267
+ name='get_weather_by_location',
268
+ args={'location': 'Boston'}
269
+ ),
270
+ types.Part.from_function_call(
271
+ name='get_weather_by_location',
272
+ args={'location': 'New York'}
273
+ ),
274
+ ]
275
+ ```
276
+
277
+ The SDK converts a list of function call parts to the a content with a `model` role:
278
+
279
+ ```python
280
+ [
281
+ types.ModelContent(
282
+ parts=[
283
+ types.Part.from_function_call(
284
+ name='get_weather_by_location',
285
+ args={'location': 'Boston'}
286
+ ),
287
+ types.Part.from_function_call(
288
+ name='get_weather_by_location',
289
+ args={'location': 'New York'}
290
+ )
291
+ ]
292
+ )
293
+ ]
169
294
  ```
170
295
 
171
- Provide a single `Content` instance with multiple `Part` instances:
296
+ Where a `types.ModelContent` is a subclass of `types.Content`, the
297
+ `role` field in `types.ModelContent` is fixed to be `model`.
298
+
299
+ ##### Provide a non function call part
172
300
 
173
301
  ```python
174
- contents=types.Content(parts=[
175
- types.Part.from_text(text='Can you recommend some things to do in Boston in the winter?'),
176
- types.Part.from_text(text='Can you recommend some things to do in New York in the winter?')
177
- ], role='user')
302
+ contents = types.Part.from_uri(
303
+ file_uri: 'gs://generativeai-downloads/images/scones.jpg',
304
+ mime_type: 'image/jpeg',
305
+ )
178
306
  ```
179
307
 
180
- When sending more than one input type, provide a list with multiple `Content`
181
- instances:
308
+ The SDK converts all non function call parts into a content with a `user` role.
182
309
 
183
310
  ```python
184
- contents=[
185
- 'What is this a picture of?',
311
+ [
312
+ types.UserContent(parts=[
186
313
  types.Part.from_uri(
187
- file_uri='gs://generativeai-downloads/images/scones.jpg',
188
- mime_type='image/jpeg',
189
- ),
190
- ],
314
+ file_uri: 'gs://generativeai-downloads/images/scones.jpg',
315
+ mime_type: 'image/jpeg',
316
+ )
317
+ ])
318
+ ]
319
+ ```
320
+
321
+ ##### Provide a list of non function call parts
322
+
323
+ ```python
324
+ contents = [
325
+ types.Part.from_text('What is this image about?'),
326
+ types.Part.from_uri(
327
+ file_uri: 'gs://generativeai-downloads/images/scones.jpg',
328
+ mime_type: 'image/jpeg',
329
+ )
330
+ ]
191
331
  ```
192
332
 
333
+ The SDK will convert the list of parts into a content with a `user` role
334
+
335
+ ```python
336
+ [
337
+ types.UserContent(
338
+ parts=[
339
+ types.Part.from_text('What is this image about?'),
340
+ types.Part.from_uri(
341
+ file_uri: 'gs://generativeai-downloads/images/scones.jpg',
342
+ mime_type: 'image/jpeg',
343
+ )
344
+ ]
345
+ )
346
+ ]
347
+ ```
348
+
349
+ ##### Mix types in contents
350
+ You can also provide a list of `types.ContentUnion`. The SDK leaves items of
351
+ `types.Content` as is, it groups consecutive non function call parts into a
352
+ single `types.UserContent`, and it groups consecutive function call parts into
353
+ a single `types.ModelContent`.
354
+
355
+ If you put a list within a list, the inner list can only contain
356
+ `types.PartUnion` items. The SDK will convert the inner list into a single
357
+ `types.UserContent`.
358
+
193
359
  ### System Instructions and Other Configs
194
360
 
195
361
  The output of the model can be influenced by several optional settings
@@ -480,6 +646,10 @@ response = client.models.generate_content(
480
646
  ```
481
647
  ### JSON Response Schema
482
648
 
649
+ However you define your schema, don't duplicate it in your input prompt,
650
+ including by giving examples of expected JSON output. If you do, the generated
651
+ output might be lower in quality.
652
+
483
653
  #### Pydantic Model Schema support
484
654
 
485
655
  Schemas can be provided as Pydantic Models.
@@ -0,0 +1,27 @@
1
+ google/genai/__init__.py,sha256=IYw-PcsdgjSpS1mU_ZcYkTfPocsJ4aVmrDxP7vX7c6Y,709
2
+ google/genai/_api_client.py,sha256=xEme7KhIrp5lCDlde_HECGzH4TppepR8YraSDiGvhPc,30593
3
+ google/genai/_api_module.py,sha256=66FsFq9N8PdTegDyx3am3NHpI0Bw7HBmifUMCrZsx_Q,902
4
+ google/genai/_automatic_function_calling_util.py,sha256=xAH-96LIEmC-yefEIae8TrBPZZAI1UJrn0bAIZsISDE,10899
5
+ google/genai/_common.py,sha256=u0qX3Uli_7qaYmoTZm9JnVzoMihD4ASPksmqmsjGSBs,10071
6
+ google/genai/_extra_utils.py,sha256=l9U0uaq4TWdfY7fOpGR3LcsA6-TMEblfQlEXdC0IGPY,12462
7
+ google/genai/_replay_api_client.py,sha256=OxZIAyyyI4D9uj0avNO0QGf4DPWJ4Pqf_MCbUs5pvYc,18459
8
+ google/genai/_test_api_client.py,sha256=XNOWq8AkYbqInv1aljNGlFXsv8slQIWTYy_hdcCetD0,4797
9
+ google/genai/_transformers.py,sha256=9cVaRp1zLOG27D7iNJeW2rw2jbjlvuEUeVl5SUN6ljY,29863
10
+ google/genai/batches.py,sha256=K6RgkNWkYBjknADWe4hrv6BtXxWTl1N8b91Pg9MUnAc,41545
11
+ google/genai/caches.py,sha256=JymnKSaSZYGyTl201tR8PgbZF6fRKdXuCKe4BILKkTc,57551
12
+ google/genai/chats.py,sha256=ds5iF4hqvyHbHE4OlP1b5s93SwD0hlMNpWxT7db2E48,13493
13
+ google/genai/client.py,sha256=jN4oNT5qQtX0UILuGcZqxmIL66DOJ-T5P086ygnSnSg,9877
14
+ google/genai/errors.py,sha256=p_JbOU_eDKIIvWT6NBYGpZcxww622ChAi6eX1FuKKY0,3874
15
+ google/genai/files.py,sha256=N9TQYyuHRQm4Gb2agjyOlWFljwK-hdPUr-mP0vF0Bc8,45532
16
+ google/genai/live.py,sha256=Ftj_LxQ2zClK-2hbdRZNXkmnQQguduoNyVntIdPtTdM,32033
17
+ google/genai/models.py,sha256=1ZlRfRqEl2OvaMvU1nIosGhX7g35A-hupUkrAYqwRpg,210141
18
+ google/genai/operations.py,sha256=Tvlbk_AuQyXGL9b0wJbzgC8QGHGLSVjb1evbe-ZuZN0,20781
19
+ google/genai/pagers.py,sha256=1jxDjre7M_Udt0ntgOr_79iR0-axjdr_Q6tZZzVRli8,6784
20
+ google/genai/tunings.py,sha256=2tWvIkofDDnt6VPsfHAbcrfDIo7jAbIlpdwcx6-cUvM,48239
21
+ google/genai/types.py,sha256=sVOdjxmviV_oA5JQEKKOlg4nwrlTQjbWGqtgqQACP6Y,299883
22
+ google/genai/version.py,sha256=5_cjSe7IVSPjk4bpIyj-Lx9SCIXuPbulXr4yMMQgdT8,626
23
+ google_genai-1.6.0.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
24
+ google_genai-1.6.0.dist-info/METADATA,sha256=_zLVCqlXM9ZDEOPgINpGTkytCEN8pFJ_7Gg4DyPKpJQ,32842
25
+ google_genai-1.6.0.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
26
+ google_genai-1.6.0.dist-info/top_level.txt,sha256=_1QvSJIhFAGfxb79D6DhB7SUw2X6T4rwnz_LLrbcD3c,7
27
+ google_genai-1.6.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.2)
2
+ Generator: setuptools (76.0.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,27 +0,0 @@
1
- google/genai/__init__.py,sha256=IYw-PcsdgjSpS1mU_ZcYkTfPocsJ4aVmrDxP7vX7c6Y,709
2
- google/genai/_api_client.py,sha256=_dbVVtxTzO9ZiTgp3gLSc8C6_198Z8Maay9fUa-mi4M,27078
3
- google/genai/_api_module.py,sha256=66FsFq9N8PdTegDyx3am3NHpI0Bw7HBmifUMCrZsx_Q,902
4
- google/genai/_automatic_function_calling_util.py,sha256=OcmWb6RLYCMRxiEZu4Q1B9aVXg_Q1qqZvMlVaAwdKWI,11062
5
- google/genai/_common.py,sha256=uPDZ_HdZvWz7teUln36nCcRYbHbYTiT5HAmTuB_eCqA,9983
6
- google/genai/_extra_utils.py,sha256=UrmiGxOkXXBIThwu8A0QAkKZiv39whmlqGSXoP0oHDk,11807
7
- google/genai/_replay_api_client.py,sha256=rPu73PCijydo7cGdDS0B75Us3exopPBiXmRZmGSytzI,16199
8
- google/genai/_test_api_client.py,sha256=XNOWq8AkYbqInv1aljNGlFXsv8slQIWTYy_hdcCetD0,4797
9
- google/genai/_transformers.py,sha256=mEowhaTeH7l2pUevr7YB6DphN_D2-iPiyKnF6d41-bo,28340
10
- google/genai/batches.py,sha256=QgZlVDSNzOvtTUWnMR5f7fAALOLDyi5X022P0fkMvuc,41183
11
- google/genai/caches.py,sha256=7n0_7SeHa3nohJ0DFsOrIghE8AaVTLVLpYyiRemKf_I,57576
12
- google/genai/chats.py,sha256=ds5iF4hqvyHbHE4OlP1b5s93SwD0hlMNpWxT7db2E48,13493
13
- google/genai/client.py,sha256=uhX1MhEHepqe6biU-ix_d4wsv5xG8NevT7gFEva0XEM,9785
14
- google/genai/errors.py,sha256=BMEANEl_EK1ZIIZsO1FxgX1szvsdaEIaqhu4NpnBLow,4213
15
- google/genai/files.py,sha256=-IdlddbpwNK5ToA00vtOij_DMU2ugEZRQkBp3x7cCoM,44668
16
- google/genai/live.py,sha256=z_Y7LSZcPVkfInjLT9J8LWNIXD5E3e6TPDXZeadOcn0,24710
17
- google/genai/models.py,sha256=ra6j8-_PVy0LqTBHpK80pHwws9aPiY-5uTHQ_3t86RI,206985
18
- google/genai/operations.py,sha256=6zxvDBIJAH38Ga23Wf6msoEGzJWhfOscGnbHY_tdCrE,19451
19
- google/genai/pagers.py,sha256=xC0LEgR8E4z9XNZUnZnNwSsAUCJPlMFUpJ7eXr4nuDM,6645
20
- google/genai/tunings.py,sha256=Prt3bI5fKUoDWtz6A6pxSWQwP0_ecGXa1rPOvfzGKSM,47568
21
- google/genai/types.py,sha256=z8tX1THcR2dTMKZYwsOZWR_OGBHvdpkmCNFBSft55zE,297091
22
- google/genai/version.py,sha256=mOyGG-hAwdvxg1_wBKMm2uMprTFFYHVKz6j0htJ9Irs,626
23
- google_genai-1.4.0.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
24
- google_genai-1.4.0.dist-info/METADATA,sha256=y4Jij7zMfosWDeq44MoSPBuZQ4x3xctqOnqha4IMqcA,29152
25
- google_genai-1.4.0.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
26
- google_genai-1.4.0.dist-info/top_level.txt,sha256=_1QvSJIhFAGfxb79D6DhB7SUw2X6T4rwnz_LLrbcD3c,7
27
- google_genai-1.4.0.dist-info/RECORD,,