google-genai 1.23.0__py3-none-any.whl → 1.25.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
@@ -234,8 +232,18 @@ class HttpResponse:
234
232
  byte_stream: Union[Any, bytes] = None,
235
233
  session: Optional['aiohttp.ClientSession'] = None,
236
234
  ):
235
+ if isinstance(headers, dict):
236
+ self.headers = headers
237
+ elif isinstance(headers, httpx.Headers):
238
+ self.headers = {
239
+ key: ', '.join(headers.get_list(key))
240
+ for key in headers.keys()}
241
+ elif type(headers).__name__ == 'CIMultiDictProxy':
242
+ self.headers = {
243
+ key: ', '.join(headers.getall(key))
244
+ for key in headers.keys()}
245
+
237
246
  self.status_code: int = 200
238
- self.headers = headers
239
247
  self.response_stream = response_stream
240
248
  self.byte_stream = byte_stream
241
249
  self._session = session
@@ -338,9 +346,11 @@ class HttpResponse:
338
346
 
339
347
  # Default retry options.
340
348
  # The config is based on https://cloud.google.com/storage/docs/retry-strategy.
341
- _RETRY_ATTEMPTS = 3
349
+ # By default, the client will retry 4 times with approximately 1.0, 2.0, 4.0,
350
+ # 8.0 seconds between each attempt.
351
+ _RETRY_ATTEMPTS = 5 # including the initial call.
342
352
  _RETRY_INITIAL_DELAY = 1.0 # seconds
343
- _RETRY_MAX_DELAY = 120.0 # seconds
353
+ _RETRY_MAX_DELAY = 60.0 # seconds
344
354
  _RETRY_EXP_BASE = 2
345
355
  _RETRY_JITTER = 1
346
356
  _RETRY_HTTP_STATUS_CODES = (
@@ -364,14 +374,13 @@ def _retry_args(options: Optional[HttpRetryOptions]) -> dict[str, Any]:
364
374
  The arguments passed to the tenacity.(Async)Retrying constructor.
365
375
  """
366
376
  if options is None:
367
- return {'stop': tenacity.stop_after_attempt(1)}
377
+ return {'stop': tenacity.stop_after_attempt(1), 'reraise': True}
368
378
 
369
379
  stop = tenacity.stop_after_attempt(options.attempts or _RETRY_ATTEMPTS)
370
380
  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,
381
+ retry = tenacity.retry_if_exception(
382
+ lambda e: isinstance(e, errors.APIError) and e.code in retriable_codes,
373
383
  )
374
- retry_error_callback = lambda retry_state: retry_state.outcome.result()
375
384
  wait = tenacity.wait_exponential_jitter(
376
385
  initial=options.initial_delay or _RETRY_INITIAL_DELAY,
377
386
  max=options.max_delay or _RETRY_MAX_DELAY,
@@ -381,7 +390,7 @@ def _retry_args(options: Optional[HttpRetryOptions]) -> dict[str, Any]:
381
390
  return {
382
391
  'stop': stop,
383
392
  'retry': retry,
384
- 'retry_error_callback': retry_error_callback,
393
+ 'reraise': True,
385
394
  'wait': wait,
386
395
  }
387
396
 
@@ -569,18 +578,16 @@ class BaseApiClient:
569
578
  )
570
579
  self._httpx_client = SyncHttpxClient(**client_args)
571
580
  self._async_httpx_client = AsyncHttpxClient(**async_client_args)
572
- if has_aiohttp:
581
+ if self._use_aiohttp():
573
582
  # Do it once at the genai.Client level. Share among all requests.
574
583
  self._async_client_session_request_args = self._ensure_aiohttp_ssl_ctx(
575
584
  self._http_options
576
- )
577
- self._websocket_ssl_ctx = self._ensure_websocket_ssl_ctx(
578
- self._http_options
579
- )
585
+ )
586
+ self._websocket_ssl_ctx = self._ensure_websocket_ssl_ctx(self._http_options)
580
587
 
581
588
  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)
589
+ self._retry = tenacity.Retrying(**retry_kwargs)
590
+ self._async_retry = tenacity.AsyncRetrying(**retry_kwargs)
584
591
 
585
592
  @staticmethod
586
593
  def _ensure_httpx_ssl_ctx(
@@ -706,7 +713,6 @@ class BaseApiClient:
706
713
 
707
714
  return _maybe_set(async_args, ctx)
708
715
 
709
-
710
716
  @staticmethod
711
717
  def _ensure_websocket_ssl_ctx(options: HttpOptions) -> dict[str, Any]:
712
718
  """Ensures the SSL context is present in the async client args.
@@ -762,6 +768,14 @@ class BaseApiClient:
762
768
 
763
769
  return _maybe_set(async_args, ctx)
764
770
 
771
+ def _use_aiohttp(self) -> bool:
772
+ # If the instantiator has passed a custom transport, they want httpx not
773
+ # aiohttp.
774
+ return (
775
+ has_aiohttp
776
+ and (self._http_options.async_client_args or {}).get('transport')
777
+ is None
778
+ )
765
779
 
766
780
  def _websocket_base_url(self) -> str:
767
781
  url_parts = urlparse(self._http_options.base_url)
@@ -975,7 +989,7 @@ class BaseApiClient:
975
989
  data = http_request.data
976
990
 
977
991
  if stream:
978
- if has_aiohttp:
992
+ if self._use_aiohttp():
979
993
  session = aiohttp.ClientSession(
980
994
  headers=http_request.headers,
981
995
  trust_env=True,
@@ -1007,7 +1021,7 @@ class BaseApiClient:
1007
1021
  await errors.APIError.raise_for_async_response(client_response)
1008
1022
  return HttpResponse(client_response.headers, client_response)
1009
1023
  else:
1010
- if has_aiohttp:
1024
+ if self._use_aiohttp():
1011
1025
  async with aiohttp.ClientSession(
1012
1026
  headers=http_request.headers,
1013
1027
  trust_env=True,
@@ -1061,11 +1075,10 @@ class BaseApiClient:
1061
1075
  http_method, path, request_dict, http_options
1062
1076
  )
1063
1077
  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
1078
+ response_body = (
1079
+ response.response_stream[0] if response.response_stream else ''
1067
1080
  )
1068
-
1081
+ return SdkHttpResponse(headers=response.headers, body=response_body)
1069
1082
 
1070
1083
  def request_streamed(
1071
1084
  self,
@@ -1080,7 +1093,9 @@ class BaseApiClient:
1080
1093
 
1081
1094
  session_response = self._request(http_request, stream=True)
1082
1095
  for chunk in session_response.segments():
1083
- yield SdkHttpResponse(headers=session_response.headers, body=json.dumps(chunk))
1096
+ yield SdkHttpResponse(
1097
+ headers=session_response.headers, body=json.dumps(chunk)
1098
+ )
1084
1099
 
1085
1100
  async def async_request(
1086
1101
  self,
@@ -1095,10 +1110,7 @@ class BaseApiClient:
1095
1110
 
1096
1111
  result = await self._async_request(http_request=http_request, stream=False)
1097
1112
  response_body = result.response_stream[0] if result.response_stream else ''
1098
- return SdkHttpResponse(
1099
- headers=result.headers, body=response_body
1100
- )
1101
-
1113
+ return SdkHttpResponse(headers=result.headers, body=response_body)
1102
1114
 
1103
1115
  async def async_request_streamed(
1104
1116
  self,
@@ -1324,7 +1336,7 @@ class BaseApiClient:
1324
1336
  """
1325
1337
  offset = 0
1326
1338
  # Upload the file in chunks
1327
- if has_aiohttp: # pylint: disable=g-import-not-at-top
1339
+ if self._use_aiohttp(): # pylint: disable=g-import-not-at-top
1328
1340
  async with aiohttp.ClientSession(
1329
1341
  headers=self._http_options.headers,
1330
1342
  trust_env=True,
@@ -1507,7 +1519,7 @@ class BaseApiClient:
1507
1519
  else:
1508
1520
  data = http_request.data
1509
1521
 
1510
- if has_aiohttp:
1522
+ if self._use_aiohttp():
1511
1523
  async with aiohttp.ClientSession(
1512
1524
  headers=http_request.headers,
1513
1525
  trust_env=True,
google/genai/_common.py CHANGED
@@ -29,11 +29,13 @@ import warnings
29
29
  import pydantic
30
30
  from pydantic import alias_generators
31
31
 
32
- from . import _api_client
33
- from . import errors
34
-
35
32
  logger = logging.getLogger('google_genai._common')
36
33
 
34
+
35
+ class ExperimentalWarning(Warning):
36
+ """Warning for experimental features."""
37
+
38
+
37
39
  def set_value_by_path(data: Optional[dict[Any, Any]], keys: list[str], value: Any) -> None:
38
40
  """Examples:
39
41
 
@@ -540,7 +542,7 @@ def experimental_warning(message: str) -> Callable[[Callable[..., Any]], Callabl
540
542
  warning_done = True
541
543
  warnings.warn(
542
544
  message=message,
543
- category=errors.ExperimentalWarning,
545
+ category=ExperimentalWarning,
544
546
  stacklevel=2,
545
547
  )
546
548
  return func(*args, **kwargs)
@@ -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
 
@@ -200,6 +200,12 @@ def _debug_print(message: str) -> None:
200
200
  )
201
201
 
202
202
 
203
+ def pop_undeterministic_headers(headers: dict[str, str]) -> None:
204
+ """Remove headers that are not deterministic."""
205
+ headers.pop('Date', None) # pytype: disable=attribute-error
206
+ headers.pop('Server-Timing', None) # pytype: disable=attribute-error
207
+
208
+
203
209
  class ReplayRequest(BaseModel):
204
210
  """Represents a single request in a replay."""
205
211
 
@@ -219,10 +225,7 @@ class ReplayResponse(BaseModel):
219
225
  sdk_response_segments: list[dict[str, object]]
220
226
 
221
227
  def model_post_init(self, __context: Any) -> None:
222
- # Remove headers that are not deterministic so the replay files don't change
223
- # every time they are recorded.
224
- self.headers.pop('Date', None)
225
- self.headers.pop('Server-Timing', None)
228
+ pop_undeterministic_headers(self.headers)
226
229
 
227
230
 
228
231
  class ReplayInteraction(BaseModel):
@@ -447,11 +450,15 @@ class ReplayApiClient(BaseApiClient):
447
450
  if self._should_update_replay():
448
451
  if isinstance(response_model, list):
449
452
  response_model = response_model[0]
450
- if (
451
- response_model
452
- and getattr(response_model, 'sdk_http_response', None) is not None
453
+ sdk_response_response = getattr(response_model, 'sdk_http_response', None)
454
+ if response_model and (
455
+ sdk_response_response is not None
453
456
  ):
454
- response_model.sdk_http_response.headers.pop('Date', None) # type: ignore[attr-defined]
457
+ headers = getattr(
458
+ sdk_response_response, 'headers', None
459
+ )
460
+ if headers:
461
+ pop_undeterministic_headers(headers)
455
462
  interaction.response.sdk_response_segments.append(
456
463
  response_model.model_dump(exclude_none=True)
457
464
  )
@@ -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
 
@@ -625,17 +625,22 @@ def _raise_for_unsupported_schema_type(origin: Any) -> None:
625
625
 
626
626
 
627
627
  def _raise_for_unsupported_mldev_properties(
628
- schema: Any, client: _api_client.BaseApiClient
628
+ schema: Any, client: Optional[_api_client.BaseApiClient]
629
629
  ) -> None:
630
- if not client.vertexai and (
631
- schema.get('additionalProperties') or schema.get('additional_properties')
630
+ if (
631
+ client
632
+ and not client.vertexai
633
+ and (
634
+ schema.get('additionalProperties')
635
+ or schema.get('additional_properties')
636
+ )
632
637
  ):
633
638
  raise ValueError('additionalProperties is not supported in the Gemini API.')
634
639
 
635
640
 
636
641
  def process_schema(
637
642
  schema: dict[str, Any],
638
- client: _api_client.BaseApiClient,
643
+ client: Optional[_api_client.BaseApiClient],
639
644
  defs: Optional[dict[str, Any]] = None,
640
645
  *,
641
646
  order_properties: bool = True,
@@ -785,7 +790,7 @@ def process_schema(
785
790
 
786
791
 
787
792
  def _process_enum(
788
- enum: EnumMeta, client: _api_client.BaseApiClient
793
+ enum: EnumMeta, client: Optional[_api_client.BaseApiClient]
789
794
  ) -> types.Schema:
790
795
  is_integer_enum = False
791
796
 
@@ -823,7 +828,8 @@ def _is_type_dict_str_any(
823
828
 
824
829
 
825
830
  def t_schema(
826
- client: _api_client.BaseApiClient, origin: Union[types.SchemaUnionDict, Any]
831
+ client: Optional[_api_client.BaseApiClient],
832
+ origin: Union[types.SchemaUnionDict, Any],
827
833
  ) -> Optional[types.Schema]:
828
834
  if not origin:
829
835
  return None
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/errors.py CHANGED
@@ -18,6 +18,7 @@
18
18
  from typing import Any, Optional, TYPE_CHECKING, Union
19
19
  import httpx
20
20
  import json
21
+ from . import _common
21
22
 
22
23
 
23
24
  if TYPE_CHECKING:
@@ -185,5 +186,4 @@ class FunctionInvocationError(ValueError):
185
186
  pass
186
187
 
187
188
 
188
- class ExperimentalWarning(Warning):
189
- """Warning for experimental features."""
189
+ ExperimentalWarning = _common.ExperimentalWarning