google-genai 1.12.1__tar.gz → 1.13.0__tar.gz

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.
Files changed (36) hide show
  1. {google_genai-1.12.1/google_genai.egg-info → google_genai-1.13.0}/PKG-INFO +6 -6
  2. {google_genai-1.12.1 → google_genai-1.13.0}/README.md +5 -5
  3. google_genai-1.13.0/google/genai/_base_url.py +50 -0
  4. {google_genai-1.12.1 → google_genai-1.13.0}/google/genai/_live_converters.py +28 -226
  5. {google_genai-1.12.1 → google_genai-1.13.0}/google/genai/_transformers.py +2 -2
  6. {google_genai-1.12.1 → google_genai-1.13.0}/google/genai/batches.py +2 -2
  7. {google_genai-1.12.1 → google_genai-1.13.0}/google/genai/caches.py +14 -226
  8. {google_genai-1.12.1 → google_genai-1.13.0}/google/genai/chats.py +4 -4
  9. {google_genai-1.12.1 → google_genai-1.13.0}/google/genai/client.py +21 -9
  10. {google_genai-1.12.1 → google_genai-1.13.0}/google/genai/live.py +9 -6
  11. {google_genai-1.12.1 → google_genai-1.13.0}/google/genai/models.py +16 -236
  12. {google_genai-1.12.1 → google_genai-1.13.0}/google/genai/types.py +835 -840
  13. {google_genai-1.12.1 → google_genai-1.13.0}/google/genai/version.py +1 -1
  14. {google_genai-1.12.1 → google_genai-1.13.0/google_genai.egg-info}/PKG-INFO +6 -6
  15. {google_genai-1.12.1 → google_genai-1.13.0}/google_genai.egg-info/SOURCES.txt +1 -0
  16. {google_genai-1.12.1 → google_genai-1.13.0}/pyproject.toml +1 -1
  17. {google_genai-1.12.1 → google_genai-1.13.0}/LICENSE +0 -0
  18. {google_genai-1.12.1 → google_genai-1.13.0}/MANIFEST.in +0 -0
  19. {google_genai-1.12.1 → google_genai-1.13.0}/google/genai/__init__.py +0 -0
  20. {google_genai-1.12.1 → google_genai-1.13.0}/google/genai/_api_client.py +0 -0
  21. {google_genai-1.12.1 → google_genai-1.13.0}/google/genai/_api_module.py +0 -0
  22. {google_genai-1.12.1 → google_genai-1.13.0}/google/genai/_automatic_function_calling_util.py +0 -0
  23. {google_genai-1.12.1 → google_genai-1.13.0}/google/genai/_common.py +0 -0
  24. {google_genai-1.12.1 → google_genai-1.13.0}/google/genai/_extra_utils.py +0 -0
  25. {google_genai-1.12.1 → google_genai-1.13.0}/google/genai/_replay_api_client.py +0 -0
  26. {google_genai-1.12.1 → google_genai-1.13.0}/google/genai/_test_api_client.py +0 -0
  27. {google_genai-1.12.1 → google_genai-1.13.0}/google/genai/errors.py +0 -0
  28. {google_genai-1.12.1 → google_genai-1.13.0}/google/genai/files.py +0 -0
  29. {google_genai-1.12.1 → google_genai-1.13.0}/google/genai/operations.py +0 -0
  30. {google_genai-1.12.1 → google_genai-1.13.0}/google/genai/pagers.py +0 -0
  31. {google_genai-1.12.1 → google_genai-1.13.0}/google/genai/py.typed +0 -0
  32. {google_genai-1.12.1 → google_genai-1.13.0}/google/genai/tunings.py +0 -0
  33. {google_genai-1.12.1 → google_genai-1.13.0}/google_genai.egg-info/dependency_links.txt +0 -0
  34. {google_genai-1.12.1 → google_genai-1.13.0}/google_genai.egg-info/requires.txt +0 -0
  35. {google_genai-1.12.1 → google_genai-1.13.0}/google_genai.egg-info/top_level.txt +0 -0
  36. {google_genai-1.12.1 → google_genai-1.13.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: google-genai
3
- Version: 1.12.1
3
+ Version: 1.13.0
4
4
  Summary: GenAI Python SDK
5
5
  Author-email: Google LLC <googleapis-packages@google.com>
6
6
  License: Apache-2.0
@@ -1081,7 +1081,7 @@ else:
1081
1081
  file_uris = [file1.uri, file2.uri]
1082
1082
 
1083
1083
  cached_content = client.caches.create(
1084
- model='gemini-1.5-pro-002',
1084
+ model='gemini-2.0-flash-001',
1085
1085
  config=types.CreateCachedContentConfig(
1086
1086
  contents=[
1087
1087
  types.Content(
@@ -1114,7 +1114,7 @@ cached_content = client.caches.get(name=cached_content.name)
1114
1114
 
1115
1115
  ```python
1116
1116
  response = client.models.generate_content(
1117
- model='gemini-1.5-pro-002',
1117
+ model='gemini-2.0-flash-001',
1118
1118
  contents='Summarize the pdfs',
1119
1119
  config=types.GenerateContentConfig(
1120
1120
  cached_content=cached_content.name,
@@ -1135,12 +1135,12 @@ tuning through `tune`.
1135
1135
 
1136
1136
  ```python
1137
1137
  if client.vertexai:
1138
- model = 'gemini-1.5-pro-002'
1138
+ model = 'gemini-2.0-flash-001'
1139
1139
  training_dataset = types.TuningDataset(
1140
1140
  gcs_uri='gs://cloud-samples-data/ai-platform/generative_ai/gemini-1_5/text/sft_train_data.jsonl',
1141
1141
  )
1142
1142
  else:
1143
- model = 'models/gemini-1.0-pro-001'
1143
+ model = 'models/gemini-2.0-flash-001'
1144
1144
  training_dataset = types.TuningDataset(
1145
1145
  examples=[
1146
1146
  types.TuningExample(
@@ -1291,7 +1291,7 @@ Only supported in Vertex AI.
1291
1291
  ```python
1292
1292
  # Specify model and source file only, destination and job display name will be auto-populated
1293
1293
  job = client.batches.create(
1294
- model='gemini-1.5-flash-002',
1294
+ model='gemini-2.0-flash-001',
1295
1295
  src='bq://my-project.my-dataset.my-table',
1296
1296
  )
1297
1297
 
@@ -1050,7 +1050,7 @@ else:
1050
1050
  file_uris = [file1.uri, file2.uri]
1051
1051
 
1052
1052
  cached_content = client.caches.create(
1053
- model='gemini-1.5-pro-002',
1053
+ model='gemini-2.0-flash-001',
1054
1054
  config=types.CreateCachedContentConfig(
1055
1055
  contents=[
1056
1056
  types.Content(
@@ -1083,7 +1083,7 @@ cached_content = client.caches.get(name=cached_content.name)
1083
1083
 
1084
1084
  ```python
1085
1085
  response = client.models.generate_content(
1086
- model='gemini-1.5-pro-002',
1086
+ model='gemini-2.0-flash-001',
1087
1087
  contents='Summarize the pdfs',
1088
1088
  config=types.GenerateContentConfig(
1089
1089
  cached_content=cached_content.name,
@@ -1104,12 +1104,12 @@ tuning through `tune`.
1104
1104
 
1105
1105
  ```python
1106
1106
  if client.vertexai:
1107
- model = 'gemini-1.5-pro-002'
1107
+ model = 'gemini-2.0-flash-001'
1108
1108
  training_dataset = types.TuningDataset(
1109
1109
  gcs_uri='gs://cloud-samples-data/ai-platform/generative_ai/gemini-1_5/text/sft_train_data.jsonl',
1110
1110
  )
1111
1111
  else:
1112
- model = 'models/gemini-1.0-pro-001'
1112
+ model = 'models/gemini-2.0-flash-001'
1113
1113
  training_dataset = types.TuningDataset(
1114
1114
  examples=[
1115
1115
  types.TuningExample(
@@ -1260,7 +1260,7 @@ Only supported in Vertex AI.
1260
1260
  ```python
1261
1261
  # Specify model and source file only, destination and job display name will be auto-populated
1262
1262
  job = client.batches.create(
1263
- model='gemini-1.5-flash-002',
1263
+ model='gemini-2.0-flash-001',
1264
1264
  src='bq://my-project.my-dataset.my-table',
1265
1265
  )
1266
1266
 
@@ -0,0 +1,50 @@
1
+ # Copyright 2025 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
+ import os
17
+ from typing import Optional
18
+
19
+ from .types import HttpOptions
20
+
21
+ _default_base_gemini_url = None
22
+ _default_base_vertex_url = None
23
+
24
+
25
+ def set_default_base_urls(
26
+ gemini_url: Optional[str], vertex_url: Optional[str]
27
+ ) -> None:
28
+ """Overrides the base URLs for the Gemini API and Vertex AI API."""
29
+ global _default_base_gemini_url, _default_base_vertex_url
30
+ _default_base_gemini_url = gemini_url
31
+ _default_base_vertex_url = vertex_url
32
+
33
+
34
+ def get_base_url(
35
+ vertexai: bool,
36
+ http_options: Optional[HttpOptions] = None,
37
+ ) -> Optional[str]:
38
+ """Returns the default base URL based on the following priority.
39
+
40
+ 1. Base URLs set via HttpOptions.
41
+ 2. Base URLs set via the latest call to setDefaultBaseUrls.
42
+ 3. Base URLs set via environment variables.
43
+ """
44
+ if http_options and http_options.base_url:
45
+ return http_options.base_url
46
+
47
+ if vertexai:
48
+ return _default_base_vertex_url or os.getenv('GOOGLE_VERTEX_BASE_URL')
49
+ else:
50
+ return _default_base_gemini_url or os.getenv('GOOGLE_GEMINI_BASE_URL')
@@ -154,212 +154,6 @@ def _Content_to_vertex(
154
154
  return to_object
155
155
 
156
156
 
157
- def _Schema_to_mldev(
158
- api_client: BaseApiClient,
159
- from_object: Union[dict[str, Any], object],
160
- parent_object: Optional[dict[str, Any]] = None,
161
- ) -> dict[str, Any]:
162
- to_object: dict[str, Any] = {}
163
- if getv(from_object, ['example']) is not None:
164
- raise ValueError('example parameter is not supported in Gemini API.')
165
-
166
- if getv(from_object, ['pattern']) is not None:
167
- raise ValueError('pattern parameter is not supported in Gemini API.')
168
-
169
- if getv(from_object, ['default']) is not None:
170
- raise ValueError('default parameter is not supported in Gemini API.')
171
-
172
- if getv(from_object, ['max_length']) is not None:
173
- raise ValueError('max_length parameter is not supported in Gemini API.')
174
-
175
- if getv(from_object, ['min_length']) is not None:
176
- raise ValueError('min_length parameter is not supported in Gemini API.')
177
-
178
- if getv(from_object, ['min_properties']) is not None:
179
- raise ValueError('min_properties parameter is not supported in Gemini API.')
180
-
181
- if getv(from_object, ['max_properties']) is not None:
182
- raise ValueError('max_properties parameter is not supported in Gemini API.')
183
-
184
- if getv(from_object, ['any_of']) is not None:
185
- setv(to_object, ['anyOf'], getv(from_object, ['any_of']))
186
-
187
- if getv(from_object, ['description']) is not None:
188
- setv(to_object, ['description'], getv(from_object, ['description']))
189
-
190
- if getv(from_object, ['enum']) is not None:
191
- setv(to_object, ['enum'], getv(from_object, ['enum']))
192
-
193
- if getv(from_object, ['format']) is not None:
194
- setv(to_object, ['format'], getv(from_object, ['format']))
195
-
196
- if getv(from_object, ['items']) is not None:
197
- setv(to_object, ['items'], getv(from_object, ['items']))
198
-
199
- if getv(from_object, ['max_items']) is not None:
200
- setv(to_object, ['maxItems'], getv(from_object, ['max_items']))
201
-
202
- if getv(from_object, ['maximum']) is not None:
203
- setv(to_object, ['maximum'], getv(from_object, ['maximum']))
204
-
205
- if getv(from_object, ['min_items']) is not None:
206
- setv(to_object, ['minItems'], getv(from_object, ['min_items']))
207
-
208
- if getv(from_object, ['minimum']) is not None:
209
- setv(to_object, ['minimum'], getv(from_object, ['minimum']))
210
-
211
- if getv(from_object, ['nullable']) is not None:
212
- setv(to_object, ['nullable'], getv(from_object, ['nullable']))
213
-
214
- if getv(from_object, ['properties']) is not None:
215
- setv(to_object, ['properties'], getv(from_object, ['properties']))
216
-
217
- if getv(from_object, ['property_ordering']) is not None:
218
- setv(
219
- to_object,
220
- ['propertyOrdering'],
221
- getv(from_object, ['property_ordering']),
222
- )
223
-
224
- if getv(from_object, ['required']) is not None:
225
- setv(to_object, ['required'], getv(from_object, ['required']))
226
-
227
- if getv(from_object, ['title']) is not None:
228
- setv(to_object, ['title'], getv(from_object, ['title']))
229
-
230
- if getv(from_object, ['type']) is not None:
231
- setv(to_object, ['type'], getv(from_object, ['type']))
232
-
233
- return to_object
234
-
235
-
236
- def _Schema_to_vertex(
237
- api_client: BaseApiClient,
238
- from_object: Union[dict[str, Any], object],
239
- parent_object: Optional[dict[str, Any]] = None,
240
- ) -> dict[str, Any]:
241
- to_object: dict[str, Any] = {}
242
- if getv(from_object, ['example']) is not None:
243
- setv(to_object, ['example'], getv(from_object, ['example']))
244
-
245
- if getv(from_object, ['pattern']) is not None:
246
- setv(to_object, ['pattern'], getv(from_object, ['pattern']))
247
-
248
- if getv(from_object, ['default']) is not None:
249
- setv(to_object, ['default'], getv(from_object, ['default']))
250
-
251
- if getv(from_object, ['max_length']) is not None:
252
- setv(to_object, ['maxLength'], getv(from_object, ['max_length']))
253
-
254
- if getv(from_object, ['min_length']) is not None:
255
- setv(to_object, ['minLength'], getv(from_object, ['min_length']))
256
-
257
- if getv(from_object, ['min_properties']) is not None:
258
- setv(to_object, ['minProperties'], getv(from_object, ['min_properties']))
259
-
260
- if getv(from_object, ['max_properties']) is not None:
261
- setv(to_object, ['maxProperties'], getv(from_object, ['max_properties']))
262
-
263
- if getv(from_object, ['any_of']) is not None:
264
- setv(to_object, ['anyOf'], getv(from_object, ['any_of']))
265
-
266
- if getv(from_object, ['description']) is not None:
267
- setv(to_object, ['description'], getv(from_object, ['description']))
268
-
269
- if getv(from_object, ['enum']) is not None:
270
- setv(to_object, ['enum'], getv(from_object, ['enum']))
271
-
272
- if getv(from_object, ['format']) is not None:
273
- setv(to_object, ['format'], getv(from_object, ['format']))
274
-
275
- if getv(from_object, ['items']) is not None:
276
- setv(to_object, ['items'], getv(from_object, ['items']))
277
-
278
- if getv(from_object, ['max_items']) is not None:
279
- setv(to_object, ['maxItems'], getv(from_object, ['max_items']))
280
-
281
- if getv(from_object, ['maximum']) is not None:
282
- setv(to_object, ['maximum'], getv(from_object, ['maximum']))
283
-
284
- if getv(from_object, ['min_items']) is not None:
285
- setv(to_object, ['minItems'], getv(from_object, ['min_items']))
286
-
287
- if getv(from_object, ['minimum']) is not None:
288
- setv(to_object, ['minimum'], getv(from_object, ['minimum']))
289
-
290
- if getv(from_object, ['nullable']) is not None:
291
- setv(to_object, ['nullable'], getv(from_object, ['nullable']))
292
-
293
- if getv(from_object, ['properties']) is not None:
294
- setv(to_object, ['properties'], getv(from_object, ['properties']))
295
-
296
- if getv(from_object, ['property_ordering']) is not None:
297
- setv(
298
- to_object,
299
- ['propertyOrdering'],
300
- getv(from_object, ['property_ordering']),
301
- )
302
-
303
- if getv(from_object, ['required']) is not None:
304
- setv(to_object, ['required'], getv(from_object, ['required']))
305
-
306
- if getv(from_object, ['title']) is not None:
307
- setv(to_object, ['title'], getv(from_object, ['title']))
308
-
309
- if getv(from_object, ['type']) is not None:
310
- setv(to_object, ['type'], getv(from_object, ['type']))
311
-
312
- return to_object
313
-
314
-
315
- def _FunctionDeclaration_to_mldev(
316
- api_client: BaseApiClient,
317
- from_object: Union[dict[str, Any], object],
318
- parent_object: Optional[dict[str, Any]] = None,
319
- ) -> dict[str, Any]:
320
- to_object: dict[str, Any] = {}
321
- if getv(from_object, ['response']) is not None:
322
- raise ValueError('response parameter is not supported in Gemini API.')
323
-
324
- if getv(from_object, ['description']) is not None:
325
- setv(to_object, ['description'], getv(from_object, ['description']))
326
-
327
- if getv(from_object, ['name']) is not None:
328
- setv(to_object, ['name'], getv(from_object, ['name']))
329
-
330
- if getv(from_object, ['parameters']) is not None:
331
- setv(to_object, ['parameters'], getv(from_object, ['parameters']))
332
-
333
- return to_object
334
-
335
-
336
- def _FunctionDeclaration_to_vertex(
337
- api_client: BaseApiClient,
338
- from_object: Union[dict[str, Any], object],
339
- parent_object: Optional[dict[str, Any]] = None,
340
- ) -> dict[str, Any]:
341
- to_object: dict[str, Any] = {}
342
- if getv(from_object, ['response']) is not None:
343
- setv(
344
- to_object,
345
- ['response'],
346
- _Schema_to_vertex(
347
- api_client, getv(from_object, ['response']), to_object
348
- ),
349
- )
350
-
351
- if getv(from_object, ['description']) is not None:
352
- setv(to_object, ['description'], getv(from_object, ['description']))
353
-
354
- if getv(from_object, ['name']) is not None:
355
- setv(to_object, ['name'], getv(from_object, ['name']))
356
-
357
- if getv(from_object, ['parameters']) is not None:
358
- setv(to_object, ['parameters'], getv(from_object, ['parameters']))
359
-
360
- return to_object
361
-
362
-
363
157
  def _GoogleSearch_to_mldev(
364
158
  api_client: BaseApiClient,
365
159
  from_object: Union[dict[str, Any], object],
@@ -464,16 +258,6 @@ def _Tool_to_mldev(
464
258
  parent_object: Optional[dict[str, Any]] = None,
465
259
  ) -> dict[str, Any]:
466
260
  to_object: dict[str, Any] = {}
467
- if getv(from_object, ['function_declarations']) is not None:
468
- setv(
469
- to_object,
470
- ['functionDeclarations'],
471
- [
472
- _FunctionDeclaration_to_mldev(api_client, item, to_object)
473
- for item in getv(from_object, ['function_declarations'])
474
- ],
475
- )
476
-
477
261
  if getv(from_object, ['retrieval']) is not None:
478
262
  raise ValueError('retrieval parameter is not supported in Gemini API.')
479
263
 
@@ -500,6 +284,13 @@ def _Tool_to_mldev(
500
284
  if getv(from_object, ['code_execution']) is not None:
501
285
  setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
502
286
 
287
+ if getv(from_object, ['function_declarations']) is not None:
288
+ setv(
289
+ to_object,
290
+ ['functionDeclarations'],
291
+ getv(from_object, ['function_declarations']),
292
+ )
293
+
503
294
  return to_object
504
295
 
505
296
 
@@ -509,16 +300,6 @@ def _Tool_to_vertex(
509
300
  parent_object: Optional[dict[str, Any]] = None,
510
301
  ) -> dict[str, Any]:
511
302
  to_object: dict[str, Any] = {}
512
- if getv(from_object, ['function_declarations']) is not None:
513
- setv(
514
- to_object,
515
- ['functionDeclarations'],
516
- [
517
- _FunctionDeclaration_to_vertex(api_client, item, to_object)
518
- for item in getv(from_object, ['function_declarations'])
519
- ],
520
- )
521
-
522
303
  if getv(from_object, ['retrieval']) is not None:
523
304
  setv(to_object, ['retrieval'], getv(from_object, ['retrieval']))
524
305
 
@@ -545,6 +326,13 @@ def _Tool_to_vertex(
545
326
  if getv(from_object, ['code_execution']) is not None:
546
327
  setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
547
328
 
329
+ if getv(from_object, ['function_declarations']) is not None:
330
+ setv(
331
+ to_object,
332
+ ['functionDeclarations'],
333
+ getv(from_object, ['function_declarations']),
334
+ )
335
+
548
336
  return to_object
549
337
 
550
338
 
@@ -1887,6 +1675,13 @@ def _LiveServerContent_from_mldev(
1887
1675
  if getv(from_object, ['interrupted']) is not None:
1888
1676
  setv(to_object, ['interrupted'], getv(from_object, ['interrupted']))
1889
1677
 
1678
+ if getv(from_object, ['groundingMetadata']) is not None:
1679
+ setv(
1680
+ to_object,
1681
+ ['grounding_metadata'],
1682
+ getv(from_object, ['groundingMetadata']),
1683
+ )
1684
+
1890
1685
  if getv(from_object, ['generationComplete']) is not None:
1891
1686
  setv(
1892
1687
  to_object,
@@ -1936,6 +1731,13 @@ def _LiveServerContent_from_vertex(
1936
1731
  if getv(from_object, ['interrupted']) is not None:
1937
1732
  setv(to_object, ['interrupted'], getv(from_object, ['interrupted']))
1938
1733
 
1734
+ if getv(from_object, ['groundingMetadata']) is not None:
1735
+ setv(
1736
+ to_object,
1737
+ ['grounding_metadata'],
1738
+ getv(from_object, ['groundingMetadata']),
1739
+ )
1740
+
1939
1741
  if getv(from_object, ['generationComplete']) is not None:
1940
1742
  setv(
1941
1743
  to_object,
@@ -790,7 +790,7 @@ def t_schema(
790
790
  if not origin:
791
791
  return None
792
792
  if isinstance(origin, dict) and _is_type_dict_str_any(origin):
793
- process_schema(origin, client, order_properties=False)
793
+ process_schema(origin, client)
794
794
  return types.Schema.model_validate(origin)
795
795
  if isinstance(origin, EnumMeta):
796
796
  return _process_enum(origin, client)
@@ -799,7 +799,7 @@ def t_schema(
799
799
  # response_schema value was coerced to an empty Schema instance because it did not adhere to the Schema field annotation
800
800
  raise ValueError(f'Unsupported schema type.')
801
801
  schema = origin.model_dump(exclude_unset=True)
802
- process_schema(schema, client, order_properties=False)
802
+ process_schema(schema, client)
803
803
  return types.Schema.model_validate(schema)
804
804
 
805
805
  if (
@@ -743,7 +743,7 @@ class Batches(_api_module.BaseModule):
743
743
  .. code-block:: python
744
744
 
745
745
  batch_job = client.batches.create(
746
- model="gemini-1.5-flash",
746
+ model="gemini-2.0-flash-001",
747
747
  src="gs://path/to/input/data",
748
748
  )
749
749
  print(batch_job.state)
@@ -1113,7 +1113,7 @@ class AsyncBatches(_api_module.BaseModule):
1113
1113
  .. code-block:: python
1114
1114
 
1115
1115
  batch_job = await client.aio.batches.create(
1116
- model="gemini-1.5-flash",
1116
+ model="gemini-2.0-flash-001",
1117
1117
  src="gs://path/to/input/data",
1118
1118
  )
1119
1119
  """