google-genai 1.23.0__py3-none-any.whl → 1.24.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.
@@ -74,8 +74,6 @@ try:
74
74
  except ImportError:
75
75
  pass
76
76
 
77
- # internal comment
78
-
79
77
 
80
78
  if TYPE_CHECKING:
81
79
  from multidict import CIMultiDictProxy
@@ -338,9 +336,11 @@ class HttpResponse:
338
336
 
339
337
  # Default retry options.
340
338
  # The config is based on https://cloud.google.com/storage/docs/retry-strategy.
341
- _RETRY_ATTEMPTS = 3
339
+ # By default, the client will retry 4 times with approximately 1.0, 2.0, 4.0,
340
+ # 8.0 seconds between each attempt.
341
+ _RETRY_ATTEMPTS = 5 # including the initial call.
342
342
  _RETRY_INITIAL_DELAY = 1.0 # seconds
343
- _RETRY_MAX_DELAY = 120.0 # seconds
343
+ _RETRY_MAX_DELAY = 60.0 # seconds
344
344
  _RETRY_EXP_BASE = 2
345
345
  _RETRY_JITTER = 1
346
346
  _RETRY_HTTP_STATUS_CODES = (
@@ -364,14 +364,13 @@ def _retry_args(options: Optional[HttpRetryOptions]) -> dict[str, Any]:
364
364
  The arguments passed to the tenacity.(Async)Retrying constructor.
365
365
  """
366
366
  if options is None:
367
- return {'stop': tenacity.stop_after_attempt(1)}
367
+ return {'stop': tenacity.stop_after_attempt(1), 'reraise': True}
368
368
 
369
369
  stop = tenacity.stop_after_attempt(options.attempts or _RETRY_ATTEMPTS)
370
370
  retriable_codes = options.http_status_codes or _RETRY_HTTP_STATUS_CODES
371
- retry = tenacity.retry_if_result(
372
- lambda response: response.status_code in retriable_codes,
371
+ retry = tenacity.retry_if_exception(
372
+ lambda e: isinstance(e, errors.APIError) and e.code in retriable_codes,
373
373
  )
374
- retry_error_callback = lambda retry_state: retry_state.outcome.result()
375
374
  wait = tenacity.wait_exponential_jitter(
376
375
  initial=options.initial_delay or _RETRY_INITIAL_DELAY,
377
376
  max=options.max_delay or _RETRY_MAX_DELAY,
@@ -381,7 +380,7 @@ def _retry_args(options: Optional[HttpRetryOptions]) -> dict[str, Any]:
381
380
  return {
382
381
  'stop': stop,
383
382
  'retry': retry,
384
- 'retry_error_callback': retry_error_callback,
383
+ 'reraise': True,
385
384
  'wait': wait,
386
385
  }
387
386
 
@@ -569,18 +568,16 @@ class BaseApiClient:
569
568
  )
570
569
  self._httpx_client = SyncHttpxClient(**client_args)
571
570
  self._async_httpx_client = AsyncHttpxClient(**async_client_args)
572
- if has_aiohttp:
571
+ if self._use_aiohttp():
573
572
  # Do it once at the genai.Client level. Share among all requests.
574
573
  self._async_client_session_request_args = self._ensure_aiohttp_ssl_ctx(
575
574
  self._http_options
576
- )
577
- self._websocket_ssl_ctx = self._ensure_websocket_ssl_ctx(
578
- self._http_options
579
- )
575
+ )
576
+ self._websocket_ssl_ctx = self._ensure_websocket_ssl_ctx(self._http_options)
580
577
 
581
578
  retry_kwargs = _retry_args(self._http_options.retry_options)
582
- self._retry = tenacity.Retrying(**retry_kwargs, reraise=True)
583
- self._async_retry = tenacity.AsyncRetrying(**retry_kwargs, reraise=True)
579
+ self._retry = tenacity.Retrying(**retry_kwargs)
580
+ self._async_retry = tenacity.AsyncRetrying(**retry_kwargs)
584
581
 
585
582
  @staticmethod
586
583
  def _ensure_httpx_ssl_ctx(
@@ -706,7 +703,6 @@ class BaseApiClient:
706
703
 
707
704
  return _maybe_set(async_args, ctx)
708
705
 
709
-
710
706
  @staticmethod
711
707
  def _ensure_websocket_ssl_ctx(options: HttpOptions) -> dict[str, Any]:
712
708
  """Ensures the SSL context is present in the async client args.
@@ -762,6 +758,14 @@ class BaseApiClient:
762
758
 
763
759
  return _maybe_set(async_args, ctx)
764
760
 
761
+ def _use_aiohttp(self) -> bool:
762
+ # If the instantiator has passed a custom transport, they want httpx not
763
+ # aiohttp.
764
+ return (
765
+ has_aiohttp
766
+ and (self._http_options.async_client_args or {}).get('transport')
767
+ is None
768
+ )
765
769
 
766
770
  def _websocket_base_url(self) -> str:
767
771
  url_parts = urlparse(self._http_options.base_url)
@@ -975,7 +979,7 @@ class BaseApiClient:
975
979
  data = http_request.data
976
980
 
977
981
  if stream:
978
- if has_aiohttp:
982
+ if self._use_aiohttp():
979
983
  session = aiohttp.ClientSession(
980
984
  headers=http_request.headers,
981
985
  trust_env=True,
@@ -1007,7 +1011,7 @@ class BaseApiClient:
1007
1011
  await errors.APIError.raise_for_async_response(client_response)
1008
1012
  return HttpResponse(client_response.headers, client_response)
1009
1013
  else:
1010
- if has_aiohttp:
1014
+ if self._use_aiohttp():
1011
1015
  async with aiohttp.ClientSession(
1012
1016
  headers=http_request.headers,
1013
1017
  trust_env=True,
@@ -1061,11 +1065,10 @@ class BaseApiClient:
1061
1065
  http_method, path, request_dict, http_options
1062
1066
  )
1063
1067
  response = self._request(http_request, stream=False)
1064
- response_body = response.response_stream[0] if response.response_stream else ''
1065
- return SdkHttpResponse(
1066
- headers=response.headers, body=response_body
1068
+ response_body = (
1069
+ response.response_stream[0] if response.response_stream else ''
1067
1070
  )
1068
-
1071
+ return SdkHttpResponse(headers=response.headers, body=response_body)
1069
1072
 
1070
1073
  def request_streamed(
1071
1074
  self,
@@ -1080,7 +1083,9 @@ class BaseApiClient:
1080
1083
 
1081
1084
  session_response = self._request(http_request, stream=True)
1082
1085
  for chunk in session_response.segments():
1083
- yield SdkHttpResponse(headers=session_response.headers, body=json.dumps(chunk))
1086
+ yield SdkHttpResponse(
1087
+ headers=session_response.headers, body=json.dumps(chunk)
1088
+ )
1084
1089
 
1085
1090
  async def async_request(
1086
1091
  self,
@@ -1095,10 +1100,7 @@ class BaseApiClient:
1095
1100
 
1096
1101
  result = await self._async_request(http_request=http_request, stream=False)
1097
1102
  response_body = result.response_stream[0] if result.response_stream else ''
1098
- return SdkHttpResponse(
1099
- headers=result.headers, body=response_body
1100
- )
1101
-
1103
+ return SdkHttpResponse(headers=result.headers, body=response_body)
1102
1104
 
1103
1105
  async def async_request_streamed(
1104
1106
  self,
@@ -1324,7 +1326,7 @@ class BaseApiClient:
1324
1326
  """
1325
1327
  offset = 0
1326
1328
  # Upload the file in chunks
1327
- if has_aiohttp: # pylint: disable=g-import-not-at-top
1329
+ if self._use_aiohttp(): # pylint: disable=g-import-not-at-top
1328
1330
  async with aiohttp.ClientSession(
1329
1331
  headers=self._http_options.headers,
1330
1332
  trust_env=True,
@@ -1507,7 +1509,7 @@ class BaseApiClient:
1507
1509
  else:
1508
1510
  data = http_request.data
1509
1511
 
1510
- if has_aiohttp:
1512
+ if self._use_aiohttp():
1511
1513
  async with aiohttp.ClientSession(
1512
1514
  headers=http_request.headers,
1513
1515
  trust_env=True,
@@ -877,6 +877,9 @@ def _Tool_to_mldev(
877
877
  if getv(from_object, ['code_execution']) is not None:
878
878
  setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
879
879
 
880
+ if getv(from_object, ['computer_use']) is not None:
881
+ setv(to_object, ['computerUse'], getv(from_object, ['computer_use']))
882
+
880
883
  return to_object
881
884
 
882
885
 
@@ -942,6 +945,9 @@ def _Tool_to_vertex(
942
945
  if getv(from_object, ['code_execution']) is not None:
943
946
  setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
944
947
 
948
+ if getv(from_object, ['computer_use']) is not None:
949
+ setv(to_object, ['computerUse'], getv(from_object, ['computer_use']))
950
+
945
951
  return to_object
946
952
 
947
953
 
@@ -1649,16 +1655,16 @@ def _LiveSendRealtimeInputParameters_to_vertex(
1649
1655
  setv(to_object, ['mediaChunks'], t.t_blobs(getv(from_object, ['media'])))
1650
1656
 
1651
1657
  if getv(from_object, ['audio']) is not None:
1652
- raise ValueError('audio parameter is not supported in Vertex AI.')
1658
+ setv(to_object, ['audio'], t.t_audio_blob(getv(from_object, ['audio'])))
1653
1659
 
1654
1660
  if getv(from_object, ['audio_stream_end']) is not None:
1655
1661
  setv(to_object, ['audioStreamEnd'], getv(from_object, ['audio_stream_end']))
1656
1662
 
1657
1663
  if getv(from_object, ['video']) is not None:
1658
- raise ValueError('video parameter is not supported in Vertex AI.')
1664
+ setv(to_object, ['video'], t.t_image_blob(getv(from_object, ['video'])))
1659
1665
 
1660
1666
  if getv(from_object, ['text']) is not None:
1661
- raise ValueError('text parameter is not supported in Vertex AI.')
1667
+ setv(to_object, ['text'], getv(from_object, ['text']))
1662
1668
 
1663
1669
  if getv(from_object, ['activity_start']) is not None:
1664
1670
  setv(
@@ -1935,7 +1941,7 @@ def _LiveClientRealtimeInput_to_vertex(
1935
1941
  setv(to_object, ['mediaChunks'], getv(from_object, ['media_chunks']))
1936
1942
 
1937
1943
  if getv(from_object, ['audio']) is not None:
1938
- raise ValueError('audio parameter is not supported in Vertex AI.')
1944
+ setv(to_object, ['audio'], getv(from_object, ['audio']))
1939
1945
 
1940
1946
  if getv(from_object, ['audio_stream_end']) is not None:
1941
1947
  raise ValueError(
@@ -1943,10 +1949,10 @@ def _LiveClientRealtimeInput_to_vertex(
1943
1949
  )
1944
1950
 
1945
1951
  if getv(from_object, ['video']) is not None:
1946
- raise ValueError('video parameter is not supported in Vertex AI.')
1952
+ setv(to_object, ['video'], getv(from_object, ['video']))
1947
1953
 
1948
1954
  if getv(from_object, ['text']) is not None:
1949
- raise ValueError('text parameter is not supported in Vertex AI.')
1955
+ setv(to_object, ['text'], getv(from_object, ['text']))
1950
1956
 
1951
1957
  if getv(from_object, ['activity_start']) is not None:
1952
1958
  setv(
@@ -2467,6 +2473,8 @@ def _LiveServerSetupComplete_from_vertex(
2467
2473
  parent_object: Optional[dict[str, Any]] = None,
2468
2474
  ) -> dict[str, Any]:
2469
2475
  to_object: dict[str, Any] = {}
2476
+ if getv(from_object, ['sessionId']) is not None:
2477
+ setv(to_object, ['session_id'], getv(from_object, ['sessionId']))
2470
2478
 
2471
2479
  return to_object
2472
2480
 
@@ -877,6 +877,9 @@ def _Tool_to_mldev(
877
877
  if getv(from_object, ['code_execution']) is not None:
878
878
  setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
879
879
 
880
+ if getv(from_object, ['computer_use']) is not None:
881
+ setv(to_object, ['computerUse'], getv(from_object, ['computer_use']))
882
+
880
883
  return to_object
881
884
 
882
885
 
@@ -942,6 +945,9 @@ def _Tool_to_vertex(
942
945
  if getv(from_object, ['code_execution']) is not None:
943
946
  setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
944
947
 
948
+ if getv(from_object, ['computer_use']) is not None:
949
+ setv(to_object, ['computerUse'], getv(from_object, ['computer_use']))
950
+
945
951
  return to_object
946
952
 
947
953
 
google/genai/batches.py CHANGED
@@ -515,6 +515,9 @@ def _Tool_to_mldev(
515
515
  if getv(from_object, ['code_execution']) is not None:
516
516
  setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
517
517
 
518
+ if getv(from_object, ['computer_use']) is not None:
519
+ setv(to_object, ['computerUse'], getv(from_object, ['computer_use']))
520
+
518
521
  return to_object
519
522
 
520
523
 
@@ -1288,6 +1291,25 @@ def _ListBatchJobsParameters_to_mldev(
1288
1291
  return to_object
1289
1292
 
1290
1293
 
1294
+ def _DeleteBatchJobParameters_to_mldev(
1295
+ api_client: BaseApiClient,
1296
+ from_object: Union[dict[str, Any], object],
1297
+ parent_object: Optional[dict[str, Any]] = None,
1298
+ ) -> dict[str, Any]:
1299
+ to_object: dict[str, Any] = {}
1300
+ if getv(from_object, ['name']) is not None:
1301
+ setv(
1302
+ to_object,
1303
+ ['_url', 'name'],
1304
+ t.t_batch_job_name(api_client, getv(from_object, ['name'])),
1305
+ )
1306
+
1307
+ if getv(from_object, ['config']) is not None:
1308
+ setv(to_object, ['config'], getv(from_object, ['config']))
1309
+
1310
+ return to_object
1311
+
1312
+
1291
1313
  def _VideoMetadata_to_vertex(
1292
1314
  from_object: Union[dict[str, Any], object],
1293
1315
  parent_object: Optional[dict[str, Any]] = None,
@@ -1796,6 +1818,9 @@ def _Tool_to_vertex(
1796
1818
  if getv(from_object, ['code_execution']) is not None:
1797
1819
  setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
1798
1820
 
1821
+ if getv(from_object, ['computer_use']) is not None:
1822
+ setv(to_object, ['computerUse'], getv(from_object, ['computer_use']))
1823
+
1799
1824
  return to_object
1800
1825
 
1801
1826
 
@@ -3036,6 +3061,9 @@ def _Tool_from_mldev(
3036
3061
  if getv(from_object, ['codeExecution']) is not None:
3037
3062
  setv(to_object, ['code_execution'], getv(from_object, ['codeExecution']))
3038
3063
 
3064
+ if getv(from_object, ['computerUse']) is not None:
3065
+ setv(to_object, ['computer_use'], getv(from_object, ['computerUse']))
3066
+
3039
3067
  return to_object
3040
3068
 
3041
3069
 
@@ -3697,6 +3725,27 @@ def _ListBatchJobsResponse_from_mldev(
3697
3725
  return to_object
3698
3726
 
3699
3727
 
3728
+ def _DeleteResourceJob_from_mldev(
3729
+ from_object: Union[dict[str, Any], object],
3730
+ parent_object: Optional[dict[str, Any]] = None,
3731
+ ) -> dict[str, Any]:
3732
+ to_object: dict[str, Any] = {}
3733
+ if getv(from_object, ['name']) is not None:
3734
+ setv(to_object, ['name'], getv(from_object, ['name']))
3735
+
3736
+ if getv(from_object, ['done']) is not None:
3737
+ setv(to_object, ['done'], getv(from_object, ['done']))
3738
+
3739
+ if getv(from_object, ['error']) is not None:
3740
+ setv(
3741
+ to_object,
3742
+ ['error'],
3743
+ _JobError_from_mldev(getv(from_object, ['error']), to_object),
3744
+ )
3745
+
3746
+ return to_object
3747
+
3748
+
3700
3749
  def _JobError_from_vertex(
3701
3750
  from_object: Union[dict[str, Any], object],
3702
3751
  parent_object: Optional[dict[str, Any]] = None,
@@ -4220,6 +4269,9 @@ def _Tool_from_vertex(
4220
4269
  if getv(from_object, ['codeExecution']) is not None:
4221
4270
  setv(to_object, ['code_execution'], getv(from_object, ['codeExecution']))
4222
4271
 
4272
+ if getv(from_object, ['computerUse']) is not None:
4273
+ setv(to_object, ['computer_use'], getv(from_object, ['computerUse']))
4274
+
4223
4275
  return to_object
4224
4276
 
4225
4277
 
@@ -4937,7 +4989,7 @@ class Batches(_api_module.BaseModule):
4937
4989
  name (str): A fully-qualified BatchJob resource name or ID.
4938
4990
  Example: "projects/.../locations/.../batchPredictionJobs/456" or "456"
4939
4991
  when project and location are initialized in the Vertex AI client. Or
4940
- "files/abc" using the Gemini Developer AI client.
4992
+ "batches/abc" using the Gemini Developer AI client.
4941
4993
 
4942
4994
  Returns:
4943
4995
  A BatchJob object that contains details about the batch job.
@@ -5022,7 +5074,7 @@ class Batches(_api_module.BaseModule):
5022
5074
  name (str): A fully-qualified BatchJob resource name or ID.
5023
5075
  Example: "projects/.../locations/.../batchPredictionJobs/456" or "456"
5024
5076
  when project and location are initialized in the Vertex AI client. Or
5025
- "files/abc" using the Gemini Developer AI client.
5077
+ "batches/abc" using the Gemini Developer AI client.
5026
5078
 
5027
5079
  Usage:
5028
5080
 
@@ -5161,9 +5213,8 @@ class Batches(_api_module.BaseModule):
5161
5213
  )
5162
5214
 
5163
5215
  request_url_dict: Optional[dict[str, str]]
5164
- if not self._api_client.vertexai:
5165
- raise ValueError('This method is only supported in the Vertex AI client.')
5166
- else:
5216
+
5217
+ if self._api_client.vertexai:
5167
5218
  request_dict = _DeleteBatchJobParameters_to_vertex(
5168
5219
  self._api_client, parameter_model
5169
5220
  )
@@ -5172,7 +5223,15 @@ class Batches(_api_module.BaseModule):
5172
5223
  path = 'batchPredictionJobs/{name}'.format_map(request_url_dict)
5173
5224
  else:
5174
5225
  path = 'batchPredictionJobs/{name}'
5175
-
5226
+ else:
5227
+ request_dict = _DeleteBatchJobParameters_to_mldev(
5228
+ self._api_client, parameter_model
5229
+ )
5230
+ request_url_dict = request_dict.get('_url')
5231
+ if request_url_dict:
5232
+ path = 'batches/{name}'.format_map(request_url_dict)
5233
+ else:
5234
+ path = 'batches/{name}'
5176
5235
  query_params = request_dict.get('_query')
5177
5236
  if query_params:
5178
5237
  path = f'{path}?{urlencode(query_params)}'
@@ -5198,6 +5257,9 @@ class Batches(_api_module.BaseModule):
5198
5257
  if self._api_client.vertexai:
5199
5258
  response_dict = _DeleteResourceJob_from_vertex(response_dict)
5200
5259
 
5260
+ else:
5261
+ response_dict = _DeleteResourceJob_from_mldev(response_dict)
5262
+
5201
5263
  return_value = types.DeleteResourceJob._from_response(
5202
5264
  response=response_dict, kwargs=parameter_model.model_dump()
5203
5265
  )
@@ -5354,7 +5416,7 @@ class AsyncBatches(_api_module.BaseModule):
5354
5416
  name (str): A fully-qualified BatchJob resource name or ID.
5355
5417
  Example: "projects/.../locations/.../batchPredictionJobs/456" or "456"
5356
5418
  when project and location are initialized in the Vertex AI client. Or
5357
- "files/abc" using the Gemini Developer AI client.
5419
+ "batches/abc" using the Gemini Developer AI client.
5358
5420
 
5359
5421
  Returns:
5360
5422
  A BatchJob object that contains details about the batch job.
@@ -5441,7 +5503,7 @@ class AsyncBatches(_api_module.BaseModule):
5441
5503
  name (str): A fully-qualified BatchJob resource name or ID.
5442
5504
  Example: "projects/.../locations/.../batchPredictionJobs/456" or "456"
5443
5505
  when project and location are initialized in the Vertex AI client. Or
5444
- "files/abc" using the Gemini Developer AI client.
5506
+ "batches/abc" using the Gemini Developer AI client.
5445
5507
 
5446
5508
  Usage:
5447
5509
 
@@ -5582,9 +5644,8 @@ class AsyncBatches(_api_module.BaseModule):
5582
5644
  )
5583
5645
 
5584
5646
  request_url_dict: Optional[dict[str, str]]
5585
- if not self._api_client.vertexai:
5586
- raise ValueError('This method is only supported in the Vertex AI client.')
5587
- else:
5647
+
5648
+ if self._api_client.vertexai:
5588
5649
  request_dict = _DeleteBatchJobParameters_to_vertex(
5589
5650
  self._api_client, parameter_model
5590
5651
  )
@@ -5593,7 +5654,15 @@ class AsyncBatches(_api_module.BaseModule):
5593
5654
  path = 'batchPredictionJobs/{name}'.format_map(request_url_dict)
5594
5655
  else:
5595
5656
  path = 'batchPredictionJobs/{name}'
5596
-
5657
+ else:
5658
+ request_dict = _DeleteBatchJobParameters_to_mldev(
5659
+ self._api_client, parameter_model
5660
+ )
5661
+ request_url_dict = request_dict.get('_url')
5662
+ if request_url_dict:
5663
+ path = 'batches/{name}'.format_map(request_url_dict)
5664
+ else:
5665
+ path = 'batches/{name}'
5597
5666
  query_params = request_dict.get('_query')
5598
5667
  if query_params:
5599
5668
  path = f'{path}?{urlencode(query_params)}'
@@ -5619,6 +5688,9 @@ class AsyncBatches(_api_module.BaseModule):
5619
5688
  if self._api_client.vertexai:
5620
5689
  response_dict = _DeleteResourceJob_from_vertex(response_dict)
5621
5690
 
5691
+ else:
5692
+ response_dict = _DeleteResourceJob_from_mldev(response_dict)
5693
+
5622
5694
  return_value = types.DeleteResourceJob._from_response(
5623
5695
  response=response_dict, kwargs=parameter_model.model_dump()
5624
5696
  )
google/genai/caches.py CHANGED
@@ -395,6 +395,9 @@ def _Tool_to_mldev(
395
395
  if getv(from_object, ['code_execution']) is not None:
396
396
  setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
397
397
 
398
+ if getv(from_object, ['computer_use']) is not None:
399
+ setv(to_object, ['computerUse'], getv(from_object, ['computer_use']))
400
+
398
401
  return to_object
399
402
 
400
403
 
@@ -1057,6 +1060,9 @@ def _Tool_to_vertex(
1057
1060
  if getv(from_object, ['code_execution']) is not None:
1058
1061
  setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
1059
1062
 
1063
+ if getv(from_object, ['computer_use']) is not None:
1064
+ setv(to_object, ['computerUse'], getv(from_object, ['computer_use']))
1065
+
1060
1066
  return to_object
1061
1067
 
1062
1068
 
google/genai/models.py CHANGED
@@ -517,6 +517,9 @@ def _Tool_to_mldev(
517
517
  if getv(from_object, ['code_execution']) is not None:
518
518
  setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
519
519
 
520
+ if getv(from_object, ['computer_use']) is not None:
521
+ setv(to_object, ['computerUse'], getv(from_object, ['computer_use']))
522
+
520
523
  return to_object
521
524
 
522
525
 
@@ -1958,6 +1961,9 @@ def _Tool_to_vertex(
1958
1961
  if getv(from_object, ['code_execution']) is not None:
1959
1962
  setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
1960
1963
 
1964
+ if getv(from_object, ['computer_use']) is not None:
1965
+ setv(to_object, ['computerUse'], getv(from_object, ['computer_use']))
1966
+
1961
1967
  return to_object
1962
1968
 
1963
1969
 
google/genai/tunings.py CHANGED
@@ -521,6 +521,12 @@ def _TuningJob_from_mldev(
521
521
  if getv(from_object, ['pipelineJob']) is not None:
522
522
  setv(to_object, ['pipeline_job'], getv(from_object, ['pipelineJob']))
523
523
 
524
+ if getv(from_object, ['satisfiesPzi']) is not None:
525
+ setv(to_object, ['satisfies_pzi'], getv(from_object, ['satisfiesPzi']))
526
+
527
+ if getv(from_object, ['satisfiesPzs']) is not None:
528
+ setv(to_object, ['satisfies_pzs'], getv(from_object, ['satisfiesPzs']))
529
+
524
530
  if getv(from_object, ['serviceAccount']) is not None:
525
531
  setv(to_object, ['service_account'], getv(from_object, ['serviceAccount']))
526
532
 
@@ -700,6 +706,12 @@ def _TuningJob_from_vertex(
700
706
  if getv(from_object, ['pipelineJob']) is not None:
701
707
  setv(to_object, ['pipeline_job'], getv(from_object, ['pipelineJob']))
702
708
 
709
+ if getv(from_object, ['satisfiesPzi']) is not None:
710
+ setv(to_object, ['satisfies_pzi'], getv(from_object, ['satisfiesPzi']))
711
+
712
+ if getv(from_object, ['satisfiesPzs']) is not None:
713
+ setv(to_object, ['satisfies_pzs'], getv(from_object, ['satisfiesPzs']))
714
+
703
715
  if getv(from_object, ['serviceAccount']) is not None:
704
716
  setv(to_object, ['service_account'], getv(from_object, ['serviceAccount']))
705
717
 
google/genai/types.py CHANGED
@@ -138,6 +138,18 @@ class HarmCategory(_common.CaseInSensitiveEnum):
138
138
  """The harm category is sexually explicit content."""
139
139
  HARM_CATEGORY_CIVIC_INTEGRITY = 'HARM_CATEGORY_CIVIC_INTEGRITY'
140
140
  """Deprecated: Election filter is not longer supported. The harm category is civic integrity."""
141
+ HARM_CATEGORY_IMAGE_HATE = 'HARM_CATEGORY_IMAGE_HATE'
142
+ """The harm category is image hate."""
143
+ HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT = (
144
+ 'HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT'
145
+ )
146
+ """The harm category is image dangerous content."""
147
+ HARM_CATEGORY_IMAGE_HARASSMENT = 'HARM_CATEGORY_IMAGE_HARASSMENT'
148
+ """The harm category is image harassment."""
149
+ HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT = (
150
+ 'HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT'
151
+ )
152
+ """The harm category is image sexually explicit content."""
141
153
 
142
154
 
143
155
  class HarmBlockMethod(_common.CaseInSensitiveEnum):
@@ -199,6 +211,37 @@ class AuthType(_common.CaseInSensitiveEnum):
199
211
  """OpenID Connect (OIDC) Auth."""
200
212
 
201
213
 
214
+ class ApiSpec(_common.CaseInSensitiveEnum):
215
+ """The API spec that the external API implements."""
216
+
217
+ API_SPEC_UNSPECIFIED = 'API_SPEC_UNSPECIFIED'
218
+ """Unspecified API spec. This value should not be used."""
219
+ SIMPLE_SEARCH = 'SIMPLE_SEARCH'
220
+ """Simple search API spec."""
221
+ ELASTIC_SEARCH = 'ELASTIC_SEARCH'
222
+ """Elastic search API spec."""
223
+
224
+
225
+ class Environment(_common.CaseInSensitiveEnum):
226
+ """Required. The environment being operated."""
227
+
228
+ ENVIRONMENT_UNSPECIFIED = 'ENVIRONMENT_UNSPECIFIED'
229
+ """Defaults to browser."""
230
+ ENVIRONMENT_BROWSER = 'ENVIRONMENT_BROWSER'
231
+ """Operates in a web browser."""
232
+
233
+
234
+ class UrlRetrievalStatus(_common.CaseInSensitiveEnum):
235
+ """Status of the url retrieval."""
236
+
237
+ URL_RETRIEVAL_STATUS_UNSPECIFIED = 'URL_RETRIEVAL_STATUS_UNSPECIFIED'
238
+ """Default value. This value is unused"""
239
+ URL_RETRIEVAL_STATUS_SUCCESS = 'URL_RETRIEVAL_STATUS_SUCCESS'
240
+ """Url retrieval is successful."""
241
+ URL_RETRIEVAL_STATUS_ERROR = 'URL_RETRIEVAL_STATUS_ERROR'
242
+ """Url retrieval is failed due to error."""
243
+
244
+
202
245
  class FinishReason(_common.CaseInSensitiveEnum):
203
246
  """Output only. The reason why the model stopped generating tokens.
204
247
 
@@ -276,6 +319,8 @@ class BlockedReason(_common.CaseInSensitiveEnum):
276
319
  """Candidates blocked due to the terms which are included from the terminology blocklist."""
277
320
  PROHIBITED_CONTENT = 'PROHIBITED_CONTENT'
278
321
  """Candidates blocked due to prohibited content."""
322
+ IMAGE_SAFETY = 'IMAGE_SAFETY'
323
+ """Candidates blocked due to unsafe image generation content."""
279
324
 
280
325
 
281
326
  class TrafficType(_common.CaseInSensitiveEnum):
@@ -411,17 +456,6 @@ class FunctionCallingConfigMode(_common.CaseInSensitiveEnum):
411
456
  """Model will not predict any function calls. Model behavior is same as when not passing any function declarations."""
412
457
 
413
458
 
414
- class UrlRetrievalStatus(_common.CaseInSensitiveEnum):
415
- """Status of the url retrieval."""
416
-
417
- URL_RETRIEVAL_STATUS_UNSPECIFIED = 'URL_RETRIEVAL_STATUS_UNSPECIFIED'
418
- """Default value. This value is unused"""
419
- URL_RETRIEVAL_STATUS_SUCCESS = 'URL_RETRIEVAL_STATUS_SUCCESS'
420
- """Url retrieval is successful."""
421
- URL_RETRIEVAL_STATUS_ERROR = 'URL_RETRIEVAL_STATUS_ERROR'
422
- """Url retrieval is failed due to error."""
423
-
424
-
425
459
  class SafetyFilterLevel(_common.CaseInSensitiveEnum):
426
460
  """Enum that controls the safety filter level for objectionable content."""
427
461
 
@@ -743,7 +777,8 @@ FileDataOrDict = Union[FileData, FileDataDict]
743
777
  class CodeExecutionResult(_common.BaseModel):
744
778
  """Result of executing the [ExecutableCode].
745
779
 
746
- Always follows a `part` containing the [ExecutableCode].
780
+ Only generated when using the [CodeExecution] tool, and always follows a
781
+ `part` containing the [ExecutableCode].
747
782
  """
748
783
 
749
784
  outcome: Optional[Outcome] = Field(
@@ -758,7 +793,8 @@ class CodeExecutionResult(_common.BaseModel):
758
793
  class CodeExecutionResultDict(TypedDict, total=False):
759
794
  """Result of executing the [ExecutableCode].
760
795
 
761
- Always follows a `part` containing the [ExecutableCode].
796
+ Only generated when using the [CodeExecution] tool, and always follows a
797
+ `part` containing the [ExecutableCode].
762
798
  """
763
799
 
764
800
  outcome: Optional[Outcome]
@@ -774,8 +810,9 @@ CodeExecutionResultOrDict = Union[CodeExecutionResult, CodeExecutionResultDict]
774
810
  class ExecutableCode(_common.BaseModel):
775
811
  """Code generated by the model that is meant to be executed, and the result returned to the model.
776
812
 
777
- Generated when using the [FunctionDeclaration] tool and
778
- [FunctionCallingConfig] mode is set to [Mode.CODE].
813
+ Generated when using the [CodeExecution] tool, in which the code will be
814
+ automatically executed, and a corresponding [CodeExecutionResult] will also be
815
+ generated.
779
816
  """
780
817
 
781
818
  code: Optional[str] = Field(
@@ -790,8 +827,9 @@ class ExecutableCode(_common.BaseModel):
790
827
  class ExecutableCodeDict(TypedDict, total=False):
791
828
  """Code generated by the model that is meant to be executed, and the result returned to the model.
792
829
 
793
- Generated when using the [FunctionDeclaration] tool and
794
- [FunctionCallingConfig] mode is set to [Mode.CODE].
830
+ Generated when using the [CodeExecution] tool, in which the code will be
831
+ automatically executed, and a corresponding [CodeExecutionResult] will also be
832
+ generated.
795
833
  """
796
834
 
797
835
  code: Optional[str]
@@ -2473,6 +2511,168 @@ class UrlContextDict(TypedDict, total=False):
2473
2511
  UrlContextOrDict = Union[UrlContext, UrlContextDict]
2474
2512
 
2475
2513
 
2514
+ class ApiAuthApiKeyConfig(_common.BaseModel):
2515
+ """The API secret."""
2516
+
2517
+ api_key_secret_version: Optional[str] = Field(
2518
+ default=None,
2519
+ description="""Required. The SecretManager secret version resource name storing API key. e.g. projects/{project}/secrets/{secret}/versions/{version}""",
2520
+ )
2521
+ api_key_string: Optional[str] = Field(
2522
+ default=None,
2523
+ description="""The API key string. Either this or `api_key_secret_version` must be set.""",
2524
+ )
2525
+
2526
+
2527
+ class ApiAuthApiKeyConfigDict(TypedDict, total=False):
2528
+ """The API secret."""
2529
+
2530
+ api_key_secret_version: Optional[str]
2531
+ """Required. The SecretManager secret version resource name storing API key. e.g. projects/{project}/secrets/{secret}/versions/{version}"""
2532
+
2533
+ api_key_string: Optional[str]
2534
+ """The API key string. Either this or `api_key_secret_version` must be set."""
2535
+
2536
+
2537
+ ApiAuthApiKeyConfigOrDict = Union[ApiAuthApiKeyConfig, ApiAuthApiKeyConfigDict]
2538
+
2539
+
2540
+ class ApiAuth(_common.BaseModel):
2541
+ """The generic reusable api auth config.
2542
+
2543
+ Deprecated. Please use AuthConfig (google/cloud/aiplatform/master/auth.proto)
2544
+ instead.
2545
+ """
2546
+
2547
+ api_key_config: Optional[ApiAuthApiKeyConfig] = Field(
2548
+ default=None, description="""The API secret."""
2549
+ )
2550
+
2551
+
2552
+ class ApiAuthDict(TypedDict, total=False):
2553
+ """The generic reusable api auth config.
2554
+
2555
+ Deprecated. Please use AuthConfig (google/cloud/aiplatform/master/auth.proto)
2556
+ instead.
2557
+ """
2558
+
2559
+ api_key_config: Optional[ApiAuthApiKeyConfigDict]
2560
+ """The API secret."""
2561
+
2562
+
2563
+ ApiAuthOrDict = Union[ApiAuth, ApiAuthDict]
2564
+
2565
+
2566
+ class ExternalApiElasticSearchParams(_common.BaseModel):
2567
+ """The search parameters to use for the ELASTIC_SEARCH spec."""
2568
+
2569
+ index: Optional[str] = Field(
2570
+ default=None, description="""The ElasticSearch index to use."""
2571
+ )
2572
+ num_hits: Optional[int] = Field(
2573
+ default=None,
2574
+ description="""Optional. Number of hits (chunks) to request. When specified, it is passed to Elasticsearch as the `num_hits` param.""",
2575
+ )
2576
+ search_template: Optional[str] = Field(
2577
+ default=None, description="""The ElasticSearch search template to use."""
2578
+ )
2579
+
2580
+
2581
+ class ExternalApiElasticSearchParamsDict(TypedDict, total=False):
2582
+ """The search parameters to use for the ELASTIC_SEARCH spec."""
2583
+
2584
+ index: Optional[str]
2585
+ """The ElasticSearch index to use."""
2586
+
2587
+ num_hits: Optional[int]
2588
+ """Optional. Number of hits (chunks) to request. When specified, it is passed to Elasticsearch as the `num_hits` param."""
2589
+
2590
+ search_template: Optional[str]
2591
+ """The ElasticSearch search template to use."""
2592
+
2593
+
2594
+ ExternalApiElasticSearchParamsOrDict = Union[
2595
+ ExternalApiElasticSearchParams, ExternalApiElasticSearchParamsDict
2596
+ ]
2597
+
2598
+
2599
+ class ExternalApiSimpleSearchParams(_common.BaseModel):
2600
+ """The search parameters to use for SIMPLE_SEARCH spec."""
2601
+
2602
+ pass
2603
+
2604
+
2605
+ class ExternalApiSimpleSearchParamsDict(TypedDict, total=False):
2606
+ """The search parameters to use for SIMPLE_SEARCH spec."""
2607
+
2608
+ pass
2609
+
2610
+
2611
+ ExternalApiSimpleSearchParamsOrDict = Union[
2612
+ ExternalApiSimpleSearchParams, ExternalApiSimpleSearchParamsDict
2613
+ ]
2614
+
2615
+
2616
+ class ExternalApi(_common.BaseModel):
2617
+ """Retrieve from data source powered by external API for grounding.
2618
+
2619
+ The external API is not owned by Google, but need to follow the pre-defined
2620
+ API spec.
2621
+ """
2622
+
2623
+ api_auth: Optional[ApiAuth] = Field(
2624
+ default=None,
2625
+ description="""The authentication config to access the API. Deprecated. Please use auth_config instead.""",
2626
+ )
2627
+ api_spec: Optional[ApiSpec] = Field(
2628
+ default=None,
2629
+ description="""The API spec that the external API implements.""",
2630
+ )
2631
+ auth_config: Optional[AuthConfig] = Field(
2632
+ default=None,
2633
+ description="""The authentication config to access the API.""",
2634
+ )
2635
+ elastic_search_params: Optional[ExternalApiElasticSearchParams] = Field(
2636
+ default=None, description="""Parameters for the elastic search API."""
2637
+ )
2638
+ endpoint: Optional[str] = Field(
2639
+ default=None,
2640
+ description="""The endpoint of the external API. The system will call the API at this endpoint to retrieve the data for grounding. Example: https://acme.com:443/search""",
2641
+ )
2642
+ simple_search_params: Optional[ExternalApiSimpleSearchParams] = Field(
2643
+ default=None, description="""Parameters for the simple search API."""
2644
+ )
2645
+
2646
+
2647
+ class ExternalApiDict(TypedDict, total=False):
2648
+ """Retrieve from data source powered by external API for grounding.
2649
+
2650
+ The external API is not owned by Google, but need to follow the pre-defined
2651
+ API spec.
2652
+ """
2653
+
2654
+ api_auth: Optional[ApiAuthDict]
2655
+ """The authentication config to access the API. Deprecated. Please use auth_config instead."""
2656
+
2657
+ api_spec: Optional[ApiSpec]
2658
+ """The API spec that the external API implements."""
2659
+
2660
+ auth_config: Optional[AuthConfigDict]
2661
+ """The authentication config to access the API."""
2662
+
2663
+ elastic_search_params: Optional[ExternalApiElasticSearchParamsDict]
2664
+ """Parameters for the elastic search API."""
2665
+
2666
+ endpoint: Optional[str]
2667
+ """The endpoint of the external API. The system will call the API at this endpoint to retrieve the data for grounding. Example: https://acme.com:443/search"""
2668
+
2669
+ simple_search_params: Optional[ExternalApiSimpleSearchParamsDict]
2670
+ """Parameters for the simple search API."""
2671
+
2672
+
2673
+ ExternalApiOrDict = Union[ExternalApi, ExternalApiDict]
2674
+
2675
+
2476
2676
  class VertexAISearchDataStoreSpec(_common.BaseModel):
2477
2677
  """Define data stores within engine to filter on in a search call and configurations for those data stores.
2478
2678
 
@@ -2815,6 +3015,10 @@ class Retrieval(_common.BaseModel):
2815
3015
  default=None,
2816
3016
  description="""Optional. Deprecated. This option is no longer supported.""",
2817
3017
  )
3018
+ external_api: Optional[ExternalApi] = Field(
3019
+ default=None,
3020
+ description="""Use data source powered by external API for grounding.""",
3021
+ )
2818
3022
  vertex_ai_search: Optional[VertexAISearch] = Field(
2819
3023
  default=None,
2820
3024
  description="""Set to use data source powered by Vertex AI Search.""",
@@ -2831,6 +3035,9 @@ class RetrievalDict(TypedDict, total=False):
2831
3035
  disable_attribution: Optional[bool]
2832
3036
  """Optional. Deprecated. This option is no longer supported."""
2833
3037
 
3038
+ external_api: Optional[ExternalApiDict]
3039
+ """Use data source powered by external API for grounding."""
3040
+
2834
3041
  vertex_ai_search: Optional[VertexAISearchDict]
2835
3042
  """Set to use data source powered by Vertex AI Search."""
2836
3043
 
@@ -2864,6 +3071,24 @@ class ToolCodeExecutionDict(TypedDict, total=False):
2864
3071
  ToolCodeExecutionOrDict = Union[ToolCodeExecution, ToolCodeExecutionDict]
2865
3072
 
2866
3073
 
3074
+ class ToolComputerUse(_common.BaseModel):
3075
+ """Tool to support computer use."""
3076
+
3077
+ environment: Optional[Environment] = Field(
3078
+ default=None, description="""Required. The environment being operated."""
3079
+ )
3080
+
3081
+
3082
+ class ToolComputerUseDict(TypedDict, total=False):
3083
+ """Tool to support computer use."""
3084
+
3085
+ environment: Optional[Environment]
3086
+ """Required. The environment being operated."""
3087
+
3088
+
3089
+ ToolComputerUseOrDict = Union[ToolComputerUse, ToolComputerUseDict]
3090
+
3091
+
2867
3092
  class Tool(_common.BaseModel):
2868
3093
  """Tool details of a tool that the model may use to generate a response."""
2869
3094
 
@@ -2902,6 +3127,10 @@ class Tool(_common.BaseModel):
2902
3127
  default=None,
2903
3128
  description="""Optional. CodeExecution tool type. Enables the model to execute code as part of generation.""",
2904
3129
  )
3130
+ computer_use: Optional[ToolComputerUse] = Field(
3131
+ default=None,
3132
+ description="""Optional. Tool to support the model interacting directly with the computer. If enabled, it automatically populates computer-use specific Function Declarations.""",
3133
+ )
2905
3134
 
2906
3135
 
2907
3136
  class ToolDict(TypedDict, total=False):
@@ -2934,6 +3163,9 @@ class ToolDict(TypedDict, total=False):
2934
3163
  code_execution: Optional[ToolCodeExecutionDict]
2935
3164
  """Optional. CodeExecution tool type. Enables the model to execute code as part of generation."""
2936
3165
 
3166
+ computer_use: Optional[ToolComputerUseDict]
3167
+ """Optional. Tool to support the model interacting directly with the computer. If enabled, it automatically populates computer-use specific Function Declarations."""
3168
+
2937
3169
 
2938
3170
  ToolOrDict = Union[Tool, ToolDict]
2939
3171
  if _is_mcp_imported:
@@ -4341,7 +4573,7 @@ class GroundingSupport(_common.BaseModel):
4341
4573
 
4342
4574
  confidence_scores: Optional[list[float]] = Field(
4343
4575
  default=None,
4344
- description="""Confidence score of the support references. Ranges from 0 to 1. 1 is the most confident. This list must have the same size as the grounding_chunk_indices.""",
4576
+ description="""Confidence score of the support references. Ranges from 0 to 1. 1 is the most confident. For Gemini 2.0 and before, this list must have the same size as the grounding_chunk_indices. For Gemini 2.5 and after, this list will be empty and should be ignored.""",
4345
4577
  )
4346
4578
  grounding_chunk_indices: Optional[list[int]] = Field(
4347
4579
  default=None,
@@ -4357,7 +4589,7 @@ class GroundingSupportDict(TypedDict, total=False):
4357
4589
  """Grounding support."""
4358
4590
 
4359
4591
  confidence_scores: Optional[list[float]]
4360
- """Confidence score of the support references. Ranges from 0 to 1. 1 is the most confident. This list must have the same size as the grounding_chunk_indices."""
4592
+ """Confidence score of the support references. Ranges from 0 to 1. 1 is the most confident. For Gemini 2.0 and before, this list must have the same size as the grounding_chunk_indices. For Gemini 2.5 and after, this list will be empty and should be ignored."""
4361
4593
 
4362
4594
  grounding_chunk_indices: Optional[list[int]]
4363
4595
  """A list of indices (into 'grounding_chunk') specifying the citations associated with the claim. For instance [1,3,4] means that grounding_chunk[1], grounding_chunk[3], grounding_chunk[4] are the retrieved content attributed to the claim."""
@@ -4554,6 +4786,10 @@ class SafetyRating(_common.BaseModel):
4554
4786
  category: Optional[HarmCategory] = Field(
4555
4787
  default=None, description="""Output only. Harm category."""
4556
4788
  )
4789
+ overwritten_threshold: Optional[HarmBlockThreshold] = Field(
4790
+ default=None,
4791
+ description="""Output only. The overwritten threshold for the safety category of Gemini 2.0 image out. If minors are detected in the output image, the threshold of each safety category will be overwritten if user sets a lower threshold.""",
4792
+ )
4557
4793
  probability: Optional[HarmProbability] = Field(
4558
4794
  default=None,
4559
4795
  description="""Output only. Harm probability levels in the content.""",
@@ -4579,6 +4815,9 @@ class SafetyRatingDict(TypedDict, total=False):
4579
4815
  category: Optional[HarmCategory]
4580
4816
  """Output only. Harm category."""
4581
4817
 
4818
+ overwritten_threshold: Optional[HarmBlockThreshold]
4819
+ """Output only. The overwritten threshold for the safety category of Gemini 2.0 image out. If minors are detected in the output image, the threshold of each safety category will be overwritten if user sets a lower threshold."""
4820
+
4582
4821
  probability: Optional[HarmProbability]
4583
4822
  """Output only. Harm probability levels in the content."""
4584
4823
 
@@ -6866,6 +7105,10 @@ class GenerationConfig(_common.BaseModel):
6866
7105
  default=None,
6867
7106
  description="""Optional. Number of candidates to generate.""",
6868
7107
  )
7108
+ enable_affective_dialog: Optional[bool] = Field(
7109
+ default=None,
7110
+ description="""Optional. If enabled, the model will detect emotions and adapt its responses accordingly.""",
7111
+ )
6869
7112
  frequency_penalty: Optional[float] = Field(
6870
7113
  default=None, description="""Optional. Frequency penalties."""
6871
7114
  )
@@ -6883,6 +7126,10 @@ class GenerationConfig(_common.BaseModel):
6883
7126
  presence_penalty: Optional[float] = Field(
6884
7127
  default=None, description="""Optional. Positive penalties."""
6885
7128
  )
7129
+ response_json_schema: Optional[Any] = Field(
7130
+ default=None,
7131
+ description="""Optional. Output schema of the generated response. This is an alternative to `response_schema` that accepts [JSON Schema](https://json-schema.org/). If set, `response_schema` must be omitted, but `response_mime_type` is required. While the full JSON Schema may be sent, not all features are supported. Specifically, only the following properties are supported: - `$id` - `$defs` - `$ref` - `$anchor` - `type` - `format` - `title` - `description` - `enum` (for strings and numbers) - `items` - `prefixItems` - `minItems` - `maxItems` - `minimum` - `maximum` - `anyOf` - `oneOf` (interpreted the same as `anyOf`) - `properties` - `additionalProperties` - `required` The non-standard `propertyOrdering` property may also be set. Cyclic references are unrolled to a limited degree and, as such, may only be used within non-required properties. (Nullable properties are not sufficient.) If `$ref` is set on a sub-schema, no other properties, except for than those starting as a `$`, may be set.""",
7132
+ )
6886
7133
  response_logprobs: Optional[bool] = Field(
6887
7134
  default=None,
6888
7135
  description="""Optional. If true, export the logprobs results in response.""",
@@ -6898,10 +7145,6 @@ class GenerationConfig(_common.BaseModel):
6898
7145
  default=None,
6899
7146
  description="""Optional. The `Schema` object allows the definition of input and output data types. These types can be objects, but also primitives and arrays. Represents a select subset of an [OpenAPI 3.0 schema object](https://spec.openapis.org/oas/v3.0.3#schema). If set, a compatible response_mime_type must also be set. Compatible mimetypes: `application/json`: Schema for JSON response.""",
6900
7147
  )
6901
- response_json_schema: Optional[Any] = Field(
6902
- default=None,
6903
- description="""Optional. Output schema of the generated response. This is an alternative to `response_schema` that accepts [JSON Schema](https://json-schema.org/). If set, `response_schema` must be omitted, but `response_mime_type` is required. While the full JSON Schema may be sent, not all features are supported. Specifically, only the following properties are supported: - `$id` - `$defs` - `$ref` - `$anchor` - `type` - `format` - `title` - `description` - `enum` (for strings and numbers) - `items` - `prefixItems` - `minItems` - `maxItems` - `minimum` - `maximum` - `anyOf` - `oneOf` (interpreted the same as `anyOf`) - `properties` - `additionalProperties` - `required` The non-standard `propertyOrdering` property may also be set. Cyclic references are unrolled to a limited degree and, as such, may only be used within non-required properties. (Nullable properties are not sufficient.) If `$ref` is set on a sub-schema, no other properties, except for than those starting as a `$`, may be set.""",
6904
- )
6905
7148
  routing_config: Optional[GenerationConfigRoutingConfig] = Field(
6906
7149
  default=None, description="""Optional. Routing configuration."""
6907
7150
  )
@@ -6942,6 +7185,9 @@ class GenerationConfigDict(TypedDict, total=False):
6942
7185
  candidate_count: Optional[int]
6943
7186
  """Optional. Number of candidates to generate."""
6944
7187
 
7188
+ enable_affective_dialog: Optional[bool]
7189
+ """Optional. If enabled, the model will detect emotions and adapt its responses accordingly."""
7190
+
6945
7191
  frequency_penalty: Optional[float]
6946
7192
  """Optional. Frequency penalties."""
6947
7193
 
@@ -6957,6 +7203,9 @@ class GenerationConfigDict(TypedDict, total=False):
6957
7203
  presence_penalty: Optional[float]
6958
7204
  """Optional. Positive penalties."""
6959
7205
 
7206
+ response_json_schema: Optional[Any]
7207
+ """Optional. Output schema of the generated response. This is an alternative to `response_schema` that accepts [JSON Schema](https://json-schema.org/). If set, `response_schema` must be omitted, but `response_mime_type` is required. While the full JSON Schema may be sent, not all features are supported. Specifically, only the following properties are supported: - `$id` - `$defs` - `$ref` - `$anchor` - `type` - `format` - `title` - `description` - `enum` (for strings and numbers) - `items` - `prefixItems` - `minItems` - `maxItems` - `minimum` - `maximum` - `anyOf` - `oneOf` (interpreted the same as `anyOf`) - `properties` - `additionalProperties` - `required` The non-standard `propertyOrdering` property may also be set. Cyclic references are unrolled to a limited degree and, as such, may only be used within non-required properties. (Nullable properties are not sufficient.) If `$ref` is set on a sub-schema, no other properties, except for than those starting as a `$`, may be set."""
7208
+
6960
7209
  response_logprobs: Optional[bool]
6961
7210
  """Optional. If true, export the logprobs results in response."""
6962
7211
 
@@ -6969,9 +7218,6 @@ class GenerationConfigDict(TypedDict, total=False):
6969
7218
  response_schema: Optional[SchemaDict]
6970
7219
  """Optional. The `Schema` object allows the definition of input and output data types. These types can be objects, but also primitives and arrays. Represents a select subset of an [OpenAPI 3.0 schema object](https://spec.openapis.org/oas/v3.0.3#schema). If set, a compatible response_mime_type must also be set. Compatible mimetypes: `application/json`: Schema for JSON response."""
6971
7220
 
6972
- response_json_schema: Optional[Any]
6973
- """Optional. Output schema of the generated response. This is an alternative to `response_schema` that accepts [JSON Schema](https://json-schema.org/). If set, `response_schema` must be omitted, but `response_mime_type` is required. While the full JSON Schema may be sent, not all features are supported. Specifically, only the following properties are supported: - `$id` - `$defs` - `$ref` - `$anchor` - `type` - `format` - `title` - `description` - `enum` (for strings and numbers) - `items` - `prefixItems` - `minItems` - `maxItems` - `minimum` - `maximum` - `anyOf` - `oneOf` (interpreted the same as `anyOf`) - `properties` - `additionalProperties` - `required` The non-standard `propertyOrdering` property may also be set. Cyclic references are unrolled to a limited degree and, as such, may only be used within non-required properties. (Nullable properties are not sufficient.) If `$ref` is set on a sub-schema, no other properties, except for than those starting as a `$`, may be set."""
6974
-
6975
7221
  routing_config: Optional[GenerationConfigRoutingConfigDict]
6976
7222
  """Optional. Routing configuration."""
6977
7223
 
@@ -7780,7 +8026,7 @@ class SupervisedHyperParameters(_common.BaseModel):
7780
8026
  )
7781
8027
  learning_rate_multiplier: Optional[float] = Field(
7782
8028
  default=None,
7783
- description="""Optional. Multiplier for adjusting the default learning rate.""",
8029
+ description="""Optional. Multiplier for adjusting the default learning rate. Mutually exclusive with `learning_rate`.""",
7784
8030
  )
7785
8031
 
7786
8032
 
@@ -7794,7 +8040,7 @@ class SupervisedHyperParametersDict(TypedDict, total=False):
7794
8040
  """Optional. Number of complete passes the model makes over the entire training dataset during training."""
7795
8041
 
7796
8042
  learning_rate_multiplier: Optional[float]
7797
- """Optional. Multiplier for adjusting the default learning rate."""
8043
+ """Optional. Multiplier for adjusting the default learning rate. Mutually exclusive with `learning_rate`."""
7798
8044
 
7799
8045
 
7800
8046
  SupervisedHyperParametersOrDict = Union[
@@ -7814,11 +8060,11 @@ class SupervisedTuningSpec(_common.BaseModel):
7814
8060
  )
7815
8061
  training_dataset_uri: Optional[str] = Field(
7816
8062
  default=None,
7817
- description="""Required. Cloud Storage path to file containing training dataset for tuning. The dataset must be formatted as a JSONL file.""",
8063
+ description="""Required. Training dataset used for tuning. The dataset can be specified as either a Cloud Storage path to a JSONL file or as the resource name of a Vertex Multimodal Dataset.""",
7818
8064
  )
7819
8065
  validation_dataset_uri: Optional[str] = Field(
7820
8066
  default=None,
7821
- description="""Optional. Cloud Storage path to file containing validation dataset for tuning. The dataset must be formatted as a JSONL file.""",
8067
+ description="""Optional. Validation dataset used for tuning. The dataset can be specified as either a Cloud Storage path to a JSONL file or as the resource name of a Vertex Multimodal Dataset.""",
7822
8068
  )
7823
8069
 
7824
8070
 
@@ -7832,10 +8078,10 @@ class SupervisedTuningSpecDict(TypedDict, total=False):
7832
8078
  """Optional. Hyperparameters for SFT."""
7833
8079
 
7834
8080
  training_dataset_uri: Optional[str]
7835
- """Required. Cloud Storage path to file containing training dataset for tuning. The dataset must be formatted as a JSONL file."""
8081
+ """Required. Training dataset used for tuning. The dataset can be specified as either a Cloud Storage path to a JSONL file or as the resource name of a Vertex Multimodal Dataset."""
7836
8082
 
7837
8083
  validation_dataset_uri: Optional[str]
7838
- """Optional. Cloud Storage path to file containing validation dataset for tuning. The dataset must be formatted as a JSONL file."""
8084
+ """Optional. Validation dataset used for tuning. The dataset can be specified as either a Cloud Storage path to a JSONL file or as the resource name of a Vertex Multimodal Dataset."""
7839
8085
 
7840
8086
 
7841
8087
  SupervisedTuningSpecOrDict = Union[
@@ -8504,6 +8750,12 @@ class TuningJob(_common.BaseModel):
8504
8750
  default=None,
8505
8751
  description="""Output only. The resource name of the PipelineJob associated with the TuningJob. Format: `projects/{project}/locations/{location}/pipelineJobs/{pipeline_job}`.""",
8506
8752
  )
8753
+ satisfies_pzi: Optional[bool] = Field(
8754
+ default=None, description="""Output only. Reserved for future use."""
8755
+ )
8756
+ satisfies_pzs: Optional[bool] = Field(
8757
+ default=None, description="""Output only. Reserved for future use."""
8758
+ )
8507
8759
  service_account: Optional[str] = Field(
8508
8760
  default=None,
8509
8761
  description="""The service account that the tuningJob workload runs as. If not specified, the Vertex AI Secure Fine-Tuned Service Agent in the project will be used. See https://cloud.google.com/iam/docs/service-agents#vertex-ai-secure-fine-tuning-service-agent Users starting the pipeline must have the `iam.serviceAccounts.actAs` permission on this service account.""",
@@ -8581,6 +8833,12 @@ class TuningJobDict(TypedDict, total=False):
8581
8833
  pipeline_job: Optional[str]
8582
8834
  """Output only. The resource name of the PipelineJob associated with the TuningJob. Format: `projects/{project}/locations/{location}/pipelineJobs/{pipeline_job}`."""
8583
8835
 
8836
+ satisfies_pzi: Optional[bool]
8837
+ """Output only. Reserved for future use."""
8838
+
8839
+ satisfies_pzs: Optional[bool]
8840
+ """Output only. Reserved for future use."""
8841
+
8584
8842
  service_account: Optional[str]
8585
8843
  """The service account that the tuningJob workload runs as. If not specified, the Vertex AI Secure Fine-Tuned Service Agent in the project will be used. See https://cloud.google.com/iam/docs/service-agents#vertex-ai-secure-fine-tuning-service-agent Users starting the pipeline must have the `iam.serviceAccounts.actAs` permission on this service account."""
8586
8844
 
@@ -11139,13 +11397,16 @@ SubjectReferenceImageOrDict = Union[
11139
11397
  class LiveServerSetupComplete(_common.BaseModel):
11140
11398
  """Sent in response to a `LiveGenerateContentSetup` message from the client."""
11141
11399
 
11142
- pass
11400
+ session_id: Optional[str] = Field(
11401
+ default=None, description="""The session id of the live session."""
11402
+ )
11143
11403
 
11144
11404
 
11145
11405
  class LiveServerSetupCompleteDict(TypedDict, total=False):
11146
11406
  """Sent in response to a `LiveGenerateContentSetup` message from the client."""
11147
11407
 
11148
- pass
11408
+ session_id: Optional[str]
11409
+ """The session id of the live session."""
11149
11410
 
11150
11411
 
11151
11412
  LiveServerSetupCompleteOrDict = Union[
google/genai/version.py CHANGED
@@ -13,4 +13,4 @@
13
13
  # limitations under the License.
14
14
  #
15
15
 
16
- __version__ = '1.23.0' # x-release-please-version
16
+ __version__ = '1.24.0' # x-release-please-version
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: google-genai
3
- Version: 1.23.0
3
+ Version: 1.24.0
4
4
  Summary: GenAI Python SDK
5
5
  Author-email: Google LLC <googleapis-packages@google.com>
6
6
  License: Apache-2.0
@@ -1132,9 +1132,9 @@ response3.generated_images[0].image.show()
1132
1132
 
1133
1133
  ### Veo
1134
1134
 
1135
- #### Generate Videos
1135
+ Support for generating videos is considered public preview
1136
1136
 
1137
- Support for generate videos in Vertex and Gemini Developer API is behind an allowlist
1137
+ #### Generate Videos (Text to Video)
1138
1138
 
1139
1139
  ```python
1140
1140
  from google.genai import types
@@ -1145,7 +1145,6 @@ operation = client.models.generate_videos(
1145
1145
  prompt='A neon hologram of a cat driving at top speed',
1146
1146
  config=types.GenerateVideosConfig(
1147
1147
  number_of_videos=1,
1148
- fps=24,
1149
1148
  duration_seconds=5,
1150
1149
  enhance_prompt=True,
1151
1150
  ),
@@ -1156,7 +1155,73 @@ while not operation.done:
1156
1155
  time.sleep(20)
1157
1156
  operation = client.operations.get(operation)
1158
1157
 
1159
- video = operation.result.generated_videos[0].video
1158
+ video = operation.response.generated_videos[0].video
1159
+ video.show()
1160
+ ```
1161
+
1162
+ #### Generate Videos (Image to Video)
1163
+
1164
+ ```python
1165
+ from google.genai import types
1166
+
1167
+ # Read local image (uses mimetypes.guess_type to infer mime type)
1168
+ image = types.Image.from_file("local/path/file.png")
1169
+
1170
+ # Create operation
1171
+ operation = client.models.generate_videos(
1172
+ model='veo-2.0-generate-001',
1173
+ # Prompt is optional if image is provided
1174
+ prompt='Night sky',
1175
+ image=image,
1176
+ config=types.GenerateVideosConfig(
1177
+ number_of_videos=1,
1178
+ duration_seconds=5,
1179
+ enhance_prompt=True,
1180
+ # Can also pass an Image into last_frame for frame interpolation
1181
+ ),
1182
+ )
1183
+
1184
+ # Poll operation
1185
+ while not operation.done:
1186
+ time.sleep(20)
1187
+ operation = client.operations.get(operation)
1188
+
1189
+ video = operation.response.generated_videos[0].video
1190
+ video.show()
1191
+ ```
1192
+
1193
+ #### Generate Videos (Video to Video)
1194
+
1195
+ Currently, only Vertex supports Video to Video generation (Video extension).
1196
+
1197
+ ```python
1198
+ from google.genai import types
1199
+
1200
+ # Read local video (uses mimetypes.guess_type to infer mime type)
1201
+ video = types.Video.from_file("local/path/video.mp4")
1202
+
1203
+ # Create operation
1204
+ operation = client.models.generate_videos(
1205
+ model='veo-2.0-generate-001',
1206
+ # Prompt is optional if Video is provided
1207
+ prompt='Night sky',
1208
+ # Input video must be in GCS
1209
+ video=types.Video(
1210
+ uri="gs://bucket-name/inputs/videos/cat_driving.mp4",
1211
+ ),
1212
+ config=types.GenerateVideosConfig(
1213
+ number_of_videos=1,
1214
+ duration_seconds=5,
1215
+ enhance_prompt=True,
1216
+ ),
1217
+ )
1218
+
1219
+ # Poll operation
1220
+ while not operation.done:
1221
+ time.sleep(20)
1222
+ operation = client.operations.get(operation)
1223
+
1224
+ video = operation.response.generated_videos[0].video
1160
1225
  video.show()
1161
1226
  ```
1162
1227
 
@@ -1,35 +1,35 @@
1
1
  google/genai/__init__.py,sha256=SYTxz3Ho06pP2TBlvDU0FkUJz8ytbR3MgEpS9HvVYq4,709
2
2
  google/genai/_adapters.py,sha256=Kok38miNYJff2n--l0zEK_hbq0y2rWOH7k75J7SMYbQ,1744
3
- google/genai/_api_client.py,sha256=bbuu6LUCEf6MH-DzhEg-w7iv84SqRy5vIluXDKOn1UU,52447
3
+ google/genai/_api_client.py,sha256=ISgrtT7-XVOdyv3Dtwz2Eve9w3C3RO4ylEY1bND8ElY,52757
4
4
  google/genai/_api_module.py,sha256=lj8eUWx8_LBGBz-49qz6_ywWm3GYp3d8Bg5JoOHbtbI,902
5
5
  google/genai/_automatic_function_calling_util.py,sha256=IJkPq2fT9pYxYm5Pbu5-e0nBoZKoZla7yT4_txWRKLs,10324
6
6
  google/genai/_base_url.py,sha256=E5H4dew14Y16qfnB3XRnjSCi19cJVlkaMNoM_8ip-PM,1597
7
7
  google/genai/_common.py,sha256=CuG7wvroFu9kV0Im-asXJGmfbaFCAjCocZyRxYDss5g,19849
8
8
  google/genai/_extra_utils.py,sha256=GoIh_SxB5nf_0sjErYkjm8wdg93sfemLKrU_5QhlcBo,20562
9
- google/genai/_live_converters.py,sha256=lbpN5E8DjL74a2XLcgND4pzs3bHDeVpUtPDN8s7IZCU,108613
9
+ google/genai/_live_converters.py,sha256=mkxudlXXXAxuK6eWMj_-jVLQs9eOr4EX0GYCBvhIZAw,108962
10
10
  google/genai/_mcp_utils.py,sha256=khECx-DMuHemKzOQQ3msWp7FivPeEOnl3n1lvWc_b5o,3833
11
11
  google/genai/_replay_api_client.py,sha256=0IXroewCZbyZ01qN3ZQwW5OUZRMzCrf2-3nyfTerqNY,21363
12
12
  google/genai/_test_api_client.py,sha256=4ruFIy5_1qcbKqqIBu3HSQbpSOBrxiecBtDZaTGFR1s,4797
13
- google/genai/_tokens_converters.py,sha256=LxLZGgSWn6VC2-1R-4ArcuaPK45svg5P-bpC1LjBb3w,48901
13
+ google/genai/_tokens_converters.py,sha256=jQlwRZU4mlIBv6i8Lu62e6u9dvgNtOnko5WEYnjkU_A,49159
14
14
  google/genai/_transformers.py,sha256=Nd_h_zYVOkWN1XTSnM9r3IR7R_qg3tPe2mE9jozaX-Q,36935
15
- google/genai/batches.py,sha256=ZpF3qgJUkPcpWjbaJtESiQq5qiZ0obsJl77yCtgZknA,170525
16
- google/genai/caches.py,sha256=Ckqqi0osoxNmkqYGvBGpvrZUx19D6hmuwS9UXcnGWmk,65911
15
+ google/genai/batches.py,sha256=qnyWQ1RfAdSVQgV7vGor9BIWmRwUilJ0wfqOvxUwpq8,172745
16
+ google/genai/caches.py,sha256=q8N3YIpgJYWrLWSy-zUZ6w9CPRjH113E8ff4MyykYA8,66169
17
17
  google/genai/chats.py,sha256=0QdOUeWEYDQgAWBy1f7a3z3yY9S8tXSowUzNrzazzj4,16651
18
18
  google/genai/client.py,sha256=wXnfZBSv9p-yKtX_gabUrfBXoYHuqHhzK_VgwRttMgY,10777
19
19
  google/genai/errors.py,sha256=UebysH1cDeIdtp1O06CW7lQjnNrWtuqZTeVgEJylX48,5589
20
20
  google/genai/files.py,sha256=MCcHRXiMFKjbnt78yVPejszEgGz_MHRXfJyDi5-07Gs,39655
21
21
  google/genai/live.py,sha256=8Vts1bX8ZWOa0PiS3zmYhG1QMhLtBPC_ATLTSAIrazs,38945
22
22
  google/genai/live_music.py,sha256=3GG9nsto8Vhkohcs-4CPMS4DFp1ZtMuLYzHfvEPYAeg,6971
23
- google/genai/models.py,sha256=7gBXwg6_RdW_HRD_iRFIAdqu0bkUkW0fAp_PMEPVwoU,239309
23
+ google/genai/models.py,sha256=DQx31b43CxVg2YCWHVGGKBzcuB-AfBApmPm9zPVLq6o,239567
24
24
  google/genai/operations.py,sha256=99zs__fTWsyQu7rMGmBI1_4tuAJxLR0g3yp7ymsUsBA,19609
25
25
  google/genai/pagers.py,sha256=nyVYxp92rS-UaewO_oBgP593knofeLU6yOn6RolNoGQ,6797
26
26
  google/genai/py.typed,sha256=RsMFoLwBkAvY05t6izop4UHZtqOPLiKp3GkIEizzmQY,40
27
27
  google/genai/tokens.py,sha256=oew9I0fGuGLlXMdCn2Ot9Lv_herHMnvZOYjjdOz2CAM,12324
28
- google/genai/tunings.py,sha256=u6Hcfkc-nUYB_spSfY98h7EIiSz0dH3wVH0b2feMh1M,49072
29
- google/genai/types.py,sha256=LGLNmXkmnCLU-narShhG_1rtglfARNm6pvvZOiO5_lA,460023
30
- google/genai/version.py,sha256=Snuhu088Fxuibck04VaPaZ69LvJ5pKNdicb9oZYwcrY,627
31
- google_genai-1.23.0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
32
- google_genai-1.23.0.dist-info/METADATA,sha256=Yylx0cTXrq87K2-VIbM9e1RT80LHMcvUC5ZB8Y0YTqc,38902
33
- google_genai-1.23.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
34
- google_genai-1.23.0.dist-info/top_level.txt,sha256=_1QvSJIhFAGfxb79D6DhB7SUw2X6T4rwnz_LLrbcD3c,7
35
- google_genai-1.23.0.dist-info/RECORD,,
28
+ google/genai/tunings.py,sha256=fSiD4RQZI8YsFaPbBoXOIoSDA0BIuJwGg2Ac_uy5_kM,49596
29
+ google/genai/types.py,sha256=dj1Va75V8kLkrtFPIiIYXQNukE5xuogoJmqo0nu0-N4,469923
30
+ google/genai/version.py,sha256=3V_J-TpVrcSp70_3LzpCOt3SQpDmFAXnGSiq5eVjSrU,627
31
+ google_genai-1.24.0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
32
+ google_genai-1.24.0.dist-info/METADATA,sha256=yxyVgjMGvqGuGrRM8HO9fO35MTuewHnGMQYohChHULs,40539
33
+ google_genai-1.24.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
34
+ google_genai-1.24.0.dist-info/top_level.txt,sha256=_1QvSJIhFAGfxb79D6DhB7SUw2X6T4rwnz_LLrbcD3c,7
35
+ google_genai-1.24.0.dist-info/RECORD,,