google-genai 1.41.0__py3-none-any.whl → 1.43.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
google/genai/caches.py CHANGED
@@ -33,62 +33,6 @@ from .pagers import AsyncPager, Pager
33
33
  logger = logging.getLogger('google_genai.caches')
34
34
 
35
35
 
36
- def _Behavior_to_vertex_enum_validate(enum_value: Any) -> None:
37
- if enum_value in set(['UNSPECIFIED', 'BLOCKING', 'NON_BLOCKING']):
38
- raise ValueError(f'{enum_value} enum value is not supported in Vertex AI.')
39
-
40
-
41
- def _ApiKeyConfig_to_vertex(
42
- from_object: Union[dict[str, Any], object],
43
- parent_object: Optional[dict[str, Any]] = None,
44
- ) -> dict[str, Any]:
45
- to_object: dict[str, Any] = {}
46
- if getv(from_object, ['api_key_string']) is not None:
47
- setv(to_object, ['apiKeyString'], getv(from_object, ['api_key_string']))
48
-
49
- return to_object
50
-
51
-
52
- def _AuthConfig_to_vertex(
53
- from_object: Union[dict[str, Any], object],
54
- parent_object: Optional[dict[str, Any]] = None,
55
- ) -> dict[str, Any]:
56
- to_object: dict[str, Any] = {}
57
- if getv(from_object, ['api_key_config']) is not None:
58
- setv(
59
- to_object,
60
- ['apiKeyConfig'],
61
- _ApiKeyConfig_to_vertex(
62
- getv(from_object, ['api_key_config']), to_object
63
- ),
64
- )
65
-
66
- if getv(from_object, ['auth_type']) is not None:
67
- setv(to_object, ['authType'], getv(from_object, ['auth_type']))
68
-
69
- if getv(from_object, ['google_service_account_config']) is not None:
70
- setv(
71
- to_object,
72
- ['googleServiceAccountConfig'],
73
- getv(from_object, ['google_service_account_config']),
74
- )
75
-
76
- if getv(from_object, ['http_basic_auth_config']) is not None:
77
- setv(
78
- to_object,
79
- ['httpBasicAuthConfig'],
80
- getv(from_object, ['http_basic_auth_config']),
81
- )
82
-
83
- if getv(from_object, ['oauth_config']) is not None:
84
- setv(to_object, ['oauthConfig'], getv(from_object, ['oauth_config']))
85
-
86
- if getv(from_object, ['oidc_config']) is not None:
87
- setv(to_object, ['oidcConfig'], getv(from_object, ['oidc_config']))
88
-
89
- return to_object
90
-
91
-
92
36
  def _Blob_to_mldev(
93
37
  from_object: Union[dict[str, Any], object],
94
38
  parent_object: Optional[dict[str, Any]] = None,
@@ -106,117 +50,6 @@ def _Blob_to_mldev(
106
50
  return to_object
107
51
 
108
52
 
109
- def _Blob_to_vertex(
110
- from_object: Union[dict[str, Any], object],
111
- parent_object: Optional[dict[str, Any]] = None,
112
- ) -> dict[str, Any]:
113
- to_object: dict[str, Any] = {}
114
- if getv(from_object, ['display_name']) is not None:
115
- setv(to_object, ['displayName'], getv(from_object, ['display_name']))
116
-
117
- if getv(from_object, ['data']) is not None:
118
- setv(to_object, ['data'], getv(from_object, ['data']))
119
-
120
- if getv(from_object, ['mime_type']) is not None:
121
- setv(to_object, ['mimeType'], getv(from_object, ['mime_type']))
122
-
123
- return to_object
124
-
125
-
126
- def _CachedContent_from_mldev(
127
- from_object: Union[dict[str, Any], object],
128
- parent_object: Optional[dict[str, Any]] = None,
129
- ) -> dict[str, Any]:
130
- to_object: dict[str, Any] = {}
131
- if getv(from_object, ['name']) is not None:
132
- setv(to_object, ['name'], getv(from_object, ['name']))
133
-
134
- if getv(from_object, ['displayName']) is not None:
135
- setv(to_object, ['display_name'], getv(from_object, ['displayName']))
136
-
137
- if getv(from_object, ['model']) is not None:
138
- setv(to_object, ['model'], getv(from_object, ['model']))
139
-
140
- if getv(from_object, ['createTime']) is not None:
141
- setv(to_object, ['create_time'], getv(from_object, ['createTime']))
142
-
143
- if getv(from_object, ['updateTime']) is not None:
144
- setv(to_object, ['update_time'], getv(from_object, ['updateTime']))
145
-
146
- if getv(from_object, ['expireTime']) is not None:
147
- setv(to_object, ['expire_time'], getv(from_object, ['expireTime']))
148
-
149
- if getv(from_object, ['usageMetadata']) is not None:
150
- setv(to_object, ['usage_metadata'], getv(from_object, ['usageMetadata']))
151
-
152
- return to_object
153
-
154
-
155
- def _CachedContent_from_vertex(
156
- from_object: Union[dict[str, Any], object],
157
- parent_object: Optional[dict[str, Any]] = None,
158
- ) -> dict[str, Any]:
159
- to_object: dict[str, Any] = {}
160
- if getv(from_object, ['name']) is not None:
161
- setv(to_object, ['name'], getv(from_object, ['name']))
162
-
163
- if getv(from_object, ['displayName']) is not None:
164
- setv(to_object, ['display_name'], getv(from_object, ['displayName']))
165
-
166
- if getv(from_object, ['model']) is not None:
167
- setv(to_object, ['model'], getv(from_object, ['model']))
168
-
169
- if getv(from_object, ['createTime']) is not None:
170
- setv(to_object, ['create_time'], getv(from_object, ['createTime']))
171
-
172
- if getv(from_object, ['updateTime']) is not None:
173
- setv(to_object, ['update_time'], getv(from_object, ['updateTime']))
174
-
175
- if getv(from_object, ['expireTime']) is not None:
176
- setv(to_object, ['expire_time'], getv(from_object, ['expireTime']))
177
-
178
- if getv(from_object, ['usageMetadata']) is not None:
179
- setv(to_object, ['usage_metadata'], getv(from_object, ['usageMetadata']))
180
-
181
- return to_object
182
-
183
-
184
- def _ComputerUse_to_mldev(
185
- from_object: Union[dict[str, Any], object],
186
- parent_object: Optional[dict[str, Any]] = None,
187
- ) -> dict[str, Any]:
188
- to_object: dict[str, Any] = {}
189
- if getv(from_object, ['environment']) is not None:
190
- setv(to_object, ['environment'], getv(from_object, ['environment']))
191
-
192
- if getv(from_object, ['excluded_predefined_functions']) is not None:
193
- setv(
194
- to_object,
195
- ['excludedPredefinedFunctions'],
196
- getv(from_object, ['excluded_predefined_functions']),
197
- )
198
-
199
- return to_object
200
-
201
-
202
- def _ComputerUse_to_vertex(
203
- from_object: Union[dict[str, Any], object],
204
- parent_object: Optional[dict[str, Any]] = None,
205
- ) -> dict[str, Any]:
206
- to_object: dict[str, Any] = {}
207
- if getv(from_object, ['environment']) is not None:
208
- setv(to_object, ['environment'], getv(from_object, ['environment']))
209
-
210
- if getv(from_object, ['excluded_predefined_functions']) is not None:
211
- setv(
212
- to_object,
213
- ['excludedPredefinedFunctions'],
214
- getv(from_object, ['excluded_predefined_functions']),
215
- )
216
-
217
- return to_object
218
-
219
-
220
53
  def _Content_to_mldev(
221
54
  from_object: Union[dict[str, Any], object],
222
55
  parent_object: Optional[dict[str, Any]] = None,
@@ -238,27 +71,6 @@ def _Content_to_mldev(
238
71
  return to_object
239
72
 
240
73
 
241
- def _Content_to_vertex(
242
- from_object: Union[dict[str, Any], object],
243
- parent_object: Optional[dict[str, Any]] = None,
244
- ) -> dict[str, Any]:
245
- to_object: dict[str, Any] = {}
246
- if getv(from_object, ['parts']) is not None:
247
- setv(
248
- to_object,
249
- ['parts'],
250
- [
251
- _Part_to_vertex(item, to_object)
252
- for item in getv(from_object, ['parts'])
253
- ],
254
- )
255
-
256
- if getv(from_object, ['role']) is not None:
257
- setv(to_object, ['role'], getv(from_object, ['role']))
258
-
259
- return to_object
260
-
261
-
262
74
  def _CreateCachedContentConfig_to_mldev(
263
75
  from_object: Union[dict[str, Any], object],
264
76
  parent_object: Optional[dict[str, Any]] = None,
@@ -304,11 +116,7 @@ def _CreateCachedContentConfig_to_mldev(
304
116
  )
305
117
 
306
118
  if getv(from_object, ['tool_config']) is not None:
307
- setv(
308
- parent_object,
309
- ['toolConfig'],
310
- _ToolConfig_to_mldev(getv(from_object, ['tool_config']), to_object),
311
- )
119
+ setv(parent_object, ['toolConfig'], getv(from_object, ['tool_config']))
312
120
 
313
121
  if getv(from_object, ['kms_key_name']) is not None:
314
122
  raise ValueError('kms_key_name parameter is not supported in Gemini API.')
@@ -335,19 +143,14 @@ def _CreateCachedContentConfig_to_vertex(
335
143
  setv(
336
144
  parent_object,
337
145
  ['contents'],
338
- [
339
- _Content_to_vertex(item, to_object)
340
- for item in t.t_contents(getv(from_object, ['contents']))
341
- ],
146
+ [item for item in t.t_contents(getv(from_object, ['contents']))],
342
147
  )
343
148
 
344
149
  if getv(from_object, ['system_instruction']) is not None:
345
150
  setv(
346
151
  parent_object,
347
152
  ['systemInstruction'],
348
- _Content_to_vertex(
349
- t.t_content(getv(from_object, ['system_instruction'])), to_object
350
- ),
153
+ t.t_content(getv(from_object, ['system_instruction'])),
351
154
  )
352
155
 
353
156
  if getv(from_object, ['tools']) is not None:
@@ -361,11 +164,7 @@ def _CreateCachedContentConfig_to_vertex(
361
164
  )
362
165
 
363
166
  if getv(from_object, ['tool_config']) is not None:
364
- setv(
365
- parent_object,
366
- ['toolConfig'],
367
- _ToolConfig_to_vertex(getv(from_object, ['tool_config']), to_object),
368
- )
167
+ setv(parent_object, ['toolConfig'], getv(from_object, ['tool_config']))
369
168
 
370
169
  if getv(from_object, ['kms_key_name']) is not None:
371
170
  setv(
@@ -477,53 +276,6 @@ def _DeleteCachedContentResponse_from_vertex(
477
276
  return to_object
478
277
 
479
278
 
480
- def _DynamicRetrievalConfig_to_mldev(
481
- from_object: Union[dict[str, Any], object],
482
- parent_object: Optional[dict[str, Any]] = None,
483
- ) -> dict[str, Any]:
484
- to_object: dict[str, Any] = {}
485
- if getv(from_object, ['mode']) is not None:
486
- setv(to_object, ['mode'], getv(from_object, ['mode']))
487
-
488
- if getv(from_object, ['dynamic_threshold']) is not None:
489
- setv(
490
- to_object,
491
- ['dynamicThreshold'],
492
- getv(from_object, ['dynamic_threshold']),
493
- )
494
-
495
- return to_object
496
-
497
-
498
- def _DynamicRetrievalConfig_to_vertex(
499
- from_object: Union[dict[str, Any], object],
500
- parent_object: Optional[dict[str, Any]] = None,
501
- ) -> dict[str, Any]:
502
- to_object: dict[str, Any] = {}
503
- if getv(from_object, ['mode']) is not None:
504
- setv(to_object, ['mode'], getv(from_object, ['mode']))
505
-
506
- if getv(from_object, ['dynamic_threshold']) is not None:
507
- setv(
508
- to_object,
509
- ['dynamicThreshold'],
510
- getv(from_object, ['dynamic_threshold']),
511
- )
512
-
513
- return to_object
514
-
515
-
516
- def _EnterpriseWebSearch_to_vertex(
517
- from_object: Union[dict[str, Any], object],
518
- parent_object: Optional[dict[str, Any]] = None,
519
- ) -> dict[str, Any]:
520
- to_object: dict[str, Any] = {}
521
- if getv(from_object, ['exclude_domains']) is not None:
522
- setv(to_object, ['excludeDomains'], getv(from_object, ['exclude_domains']))
523
-
524
- return to_object
525
-
526
-
527
279
  def _FileData_to_mldev(
528
280
  from_object: Union[dict[str, Any], object],
529
281
  parent_object: Optional[dict[str, Any]] = None,
@@ -541,130 +293,6 @@ def _FileData_to_mldev(
541
293
  return to_object
542
294
 
543
295
 
544
- def _FileData_to_vertex(
545
- from_object: Union[dict[str, Any], object],
546
- parent_object: Optional[dict[str, Any]] = None,
547
- ) -> dict[str, Any]:
548
- to_object: dict[str, Any] = {}
549
- if getv(from_object, ['display_name']) is not None:
550
- setv(to_object, ['displayName'], getv(from_object, ['display_name']))
551
-
552
- if getv(from_object, ['file_uri']) is not None:
553
- setv(to_object, ['fileUri'], getv(from_object, ['file_uri']))
554
-
555
- if getv(from_object, ['mime_type']) is not None:
556
- setv(to_object, ['mimeType'], getv(from_object, ['mime_type']))
557
-
558
- return to_object
559
-
560
-
561
- def _FunctionCall_to_mldev(
562
- from_object: Union[dict[str, Any], object],
563
- parent_object: Optional[dict[str, Any]] = None,
564
- ) -> dict[str, Any]:
565
- to_object: dict[str, Any] = {}
566
- if getv(from_object, ['id']) is not None:
567
- setv(to_object, ['id'], getv(from_object, ['id']))
568
-
569
- if getv(from_object, ['args']) is not None:
570
- setv(to_object, ['args'], getv(from_object, ['args']))
571
-
572
- if getv(from_object, ['name']) is not None:
573
- setv(to_object, ['name'], getv(from_object, ['name']))
574
-
575
- return to_object
576
-
577
-
578
- def _FunctionCall_to_vertex(
579
- from_object: Union[dict[str, Any], object],
580
- parent_object: Optional[dict[str, Any]] = None,
581
- ) -> dict[str, Any]:
582
- to_object: dict[str, Any] = {}
583
- if getv(from_object, ['id']) is not None:
584
- setv(to_object, ['id'], getv(from_object, ['id']))
585
-
586
- if getv(from_object, ['args']) is not None:
587
- setv(to_object, ['args'], getv(from_object, ['args']))
588
-
589
- if getv(from_object, ['name']) is not None:
590
- setv(to_object, ['name'], getv(from_object, ['name']))
591
-
592
- return to_object
593
-
594
-
595
- def _FunctionCallingConfig_to_mldev(
596
- from_object: Union[dict[str, Any], object],
597
- parent_object: Optional[dict[str, Any]] = None,
598
- ) -> dict[str, Any]:
599
- to_object: dict[str, Any] = {}
600
- if getv(from_object, ['mode']) is not None:
601
- setv(to_object, ['mode'], getv(from_object, ['mode']))
602
-
603
- if getv(from_object, ['allowed_function_names']) is not None:
604
- setv(
605
- to_object,
606
- ['allowedFunctionNames'],
607
- getv(from_object, ['allowed_function_names']),
608
- )
609
-
610
- return to_object
611
-
612
-
613
- def _FunctionCallingConfig_to_vertex(
614
- from_object: Union[dict[str, Any], object],
615
- parent_object: Optional[dict[str, Any]] = None,
616
- ) -> dict[str, Any]:
617
- to_object: dict[str, Any] = {}
618
- if getv(from_object, ['mode']) is not None:
619
- setv(to_object, ['mode'], getv(from_object, ['mode']))
620
-
621
- if getv(from_object, ['allowed_function_names']) is not None:
622
- setv(
623
- to_object,
624
- ['allowedFunctionNames'],
625
- getv(from_object, ['allowed_function_names']),
626
- )
627
-
628
- return to_object
629
-
630
-
631
- def _FunctionDeclaration_to_mldev(
632
- from_object: Union[dict[str, Any], object],
633
- parent_object: Optional[dict[str, Any]] = None,
634
- ) -> dict[str, Any]:
635
- to_object: dict[str, Any] = {}
636
- if getv(from_object, ['behavior']) is not None:
637
- setv(to_object, ['behavior'], getv(from_object, ['behavior']))
638
-
639
- if getv(from_object, ['description']) is not None:
640
- setv(to_object, ['description'], getv(from_object, ['description']))
641
-
642
- if getv(from_object, ['name']) is not None:
643
- setv(to_object, ['name'], getv(from_object, ['name']))
644
-
645
- if getv(from_object, ['parameters']) is not None:
646
- setv(to_object, ['parameters'], getv(from_object, ['parameters']))
647
-
648
- if getv(from_object, ['parameters_json_schema']) is not None:
649
- setv(
650
- to_object,
651
- ['parametersJsonSchema'],
652
- getv(from_object, ['parameters_json_schema']),
653
- )
654
-
655
- if getv(from_object, ['response']) is not None:
656
- setv(to_object, ['response'], getv(from_object, ['response']))
657
-
658
- if getv(from_object, ['response_json_schema']) is not None:
659
- setv(
660
- to_object,
661
- ['responseJsonSchema'],
662
- getv(from_object, ['response_json_schema']),
663
- )
664
-
665
- return to_object
666
-
667
-
668
296
  def _FunctionDeclaration_to_vertex(
669
297
  from_object: Union[dict[str, Any], object],
670
298
  parent_object: Optional[dict[str, Any]] = None,
@@ -692,189 +320,76 @@ def _FunctionDeclaration_to_vertex(
692
320
  if getv(from_object, ['response']) is not None:
693
321
  setv(to_object, ['response'], getv(from_object, ['response']))
694
322
 
695
- if getv(from_object, ['response_json_schema']) is not None:
696
- setv(
697
- to_object,
698
- ['responseJsonSchema'],
699
- getv(from_object, ['response_json_schema']),
700
- )
701
-
702
- return to_object
703
-
704
-
705
- def _GetCachedContentParameters_to_mldev(
706
- api_client: BaseApiClient,
707
- from_object: Union[dict[str, Any], object],
708
- parent_object: Optional[dict[str, Any]] = None,
709
- ) -> dict[str, Any]:
710
- to_object: dict[str, Any] = {}
711
- if getv(from_object, ['name']) is not None:
712
- setv(
713
- to_object,
714
- ['_url', 'name'],
715
- t.t_cached_content_name(api_client, getv(from_object, ['name'])),
716
- )
717
-
718
- return to_object
719
-
720
-
721
- def _GetCachedContentParameters_to_vertex(
722
- api_client: BaseApiClient,
723
- from_object: Union[dict[str, Any], object],
724
- parent_object: Optional[dict[str, Any]] = None,
725
- ) -> dict[str, Any]:
726
- to_object: dict[str, Any] = {}
727
- if getv(from_object, ['name']) is not None:
728
- setv(
729
- to_object,
730
- ['_url', 'name'],
731
- t.t_cached_content_name(api_client, getv(from_object, ['name'])),
732
- )
733
-
734
- return to_object
735
-
736
-
737
- def _GoogleMaps_to_vertex(
738
- from_object: Union[dict[str, Any], object],
739
- parent_object: Optional[dict[str, Any]] = None,
740
- ) -> dict[str, Any]:
741
- to_object: dict[str, Any] = {}
742
- if getv(from_object, ['auth_config']) is not None:
743
- setv(
744
- to_object,
745
- ['authConfig'],
746
- _AuthConfig_to_vertex(getv(from_object, ['auth_config']), to_object),
747
- )
748
-
749
- return to_object
750
-
751
-
752
- def _GoogleSearchRetrieval_to_mldev(
753
- from_object: Union[dict[str, Any], object],
754
- parent_object: Optional[dict[str, Any]] = None,
755
- ) -> dict[str, Any]:
756
- to_object: dict[str, Any] = {}
757
- if getv(from_object, ['dynamic_retrieval_config']) is not None:
758
- setv(
759
- to_object,
760
- ['dynamicRetrievalConfig'],
761
- _DynamicRetrievalConfig_to_mldev(
762
- getv(from_object, ['dynamic_retrieval_config']), to_object
763
- ),
764
- )
765
-
766
- return to_object
767
-
768
-
769
- def _GoogleSearchRetrieval_to_vertex(
770
- from_object: Union[dict[str, Any], object],
771
- parent_object: Optional[dict[str, Any]] = None,
772
- ) -> dict[str, Any]:
773
- to_object: dict[str, Any] = {}
774
- if getv(from_object, ['dynamic_retrieval_config']) is not None:
775
- setv(
776
- to_object,
777
- ['dynamicRetrievalConfig'],
778
- _DynamicRetrievalConfig_to_vertex(
779
- getv(from_object, ['dynamic_retrieval_config']), to_object
780
- ),
781
- )
782
-
783
- return to_object
784
-
785
-
786
- def _GoogleSearch_to_mldev(
787
- from_object: Union[dict[str, Any], object],
788
- parent_object: Optional[dict[str, Any]] = None,
789
- ) -> dict[str, Any]:
790
- to_object: dict[str, Any] = {}
791
- if getv(from_object, ['time_range_filter']) is not None:
792
- setv(
793
- to_object,
794
- ['timeRangeFilter'],
795
- _Interval_to_mldev(getv(from_object, ['time_range_filter']), to_object),
796
- )
797
-
798
- if getv(from_object, ['exclude_domains']) is not None:
799
- raise ValueError(
800
- 'exclude_domains parameter is not supported in Gemini API.'
801
- )
802
-
803
- return to_object
804
-
805
-
806
- def _GoogleSearch_to_vertex(
807
- from_object: Union[dict[str, Any], object],
808
- parent_object: Optional[dict[str, Any]] = None,
809
- ) -> dict[str, Any]:
810
- to_object: dict[str, Any] = {}
811
- if getv(from_object, ['time_range_filter']) is not None:
323
+ if getv(from_object, ['response_json_schema']) is not None:
812
324
  setv(
813
325
  to_object,
814
- ['timeRangeFilter'],
815
- _Interval_to_vertex(
816
- getv(from_object, ['time_range_filter']), to_object
817
- ),
326
+ ['responseJsonSchema'],
327
+ getv(from_object, ['response_json_schema']),
818
328
  )
819
329
 
820
- if getv(from_object, ['exclude_domains']) is not None:
821
- setv(to_object, ['excludeDomains'], getv(from_object, ['exclude_domains']))
822
-
823
330
  return to_object
824
331
 
825
332
 
826
- def _Interval_to_mldev(
333
+ def _GetCachedContentParameters_to_mldev(
334
+ api_client: BaseApiClient,
827
335
  from_object: Union[dict[str, Any], object],
828
336
  parent_object: Optional[dict[str, Any]] = None,
829
337
  ) -> dict[str, Any]:
830
338
  to_object: dict[str, Any] = {}
831
- if getv(from_object, ['start_time']) is not None:
832
- setv(to_object, ['startTime'], getv(from_object, ['start_time']))
833
-
834
- if getv(from_object, ['end_time']) is not None:
835
- setv(to_object, ['endTime'], getv(from_object, ['end_time']))
339
+ if getv(from_object, ['name']) is not None:
340
+ setv(
341
+ to_object,
342
+ ['_url', 'name'],
343
+ t.t_cached_content_name(api_client, getv(from_object, ['name'])),
344
+ )
836
345
 
837
346
  return to_object
838
347
 
839
348
 
840
- def _Interval_to_vertex(
349
+ def _GetCachedContentParameters_to_vertex(
350
+ api_client: BaseApiClient,
841
351
  from_object: Union[dict[str, Any], object],
842
352
  parent_object: Optional[dict[str, Any]] = None,
843
353
  ) -> dict[str, Any]:
844
354
  to_object: dict[str, Any] = {}
845
- if getv(from_object, ['start_time']) is not None:
846
- setv(to_object, ['startTime'], getv(from_object, ['start_time']))
847
-
848
- if getv(from_object, ['end_time']) is not None:
849
- setv(to_object, ['endTime'], getv(from_object, ['end_time']))
355
+ if getv(from_object, ['name']) is not None:
356
+ setv(
357
+ to_object,
358
+ ['_url', 'name'],
359
+ t.t_cached_content_name(api_client, getv(from_object, ['name'])),
360
+ )
850
361
 
851
362
  return to_object
852
363
 
853
364
 
854
- def _LatLng_to_mldev(
365
+ def _GoogleMaps_to_mldev(
855
366
  from_object: Union[dict[str, Any], object],
856
367
  parent_object: Optional[dict[str, Any]] = None,
857
368
  ) -> dict[str, Any]:
858
369
  to_object: dict[str, Any] = {}
859
- if getv(from_object, ['latitude']) is not None:
860
- setv(to_object, ['latitude'], getv(from_object, ['latitude']))
370
+ if getv(from_object, ['auth_config']) is not None:
371
+ raise ValueError('auth_config parameter is not supported in Gemini API.')
861
372
 
862
- if getv(from_object, ['longitude']) is not None:
863
- setv(to_object, ['longitude'], getv(from_object, ['longitude']))
373
+ if getv(from_object, ['enable_widget']) is not None:
374
+ setv(to_object, ['enableWidget'], getv(from_object, ['enable_widget']))
864
375
 
865
376
  return to_object
866
377
 
867
378
 
868
- def _LatLng_to_vertex(
379
+ def _GoogleSearch_to_mldev(
869
380
  from_object: Union[dict[str, Any], object],
870
381
  parent_object: Optional[dict[str, Any]] = None,
871
382
  ) -> dict[str, Any]:
872
383
  to_object: dict[str, Any] = {}
873
- if getv(from_object, ['latitude']) is not None:
874
- setv(to_object, ['latitude'], getv(from_object, ['latitude']))
384
+ if getv(from_object, ['time_range_filter']) is not None:
385
+ setv(
386
+ to_object, ['timeRangeFilter'], getv(from_object, ['time_range_filter'])
387
+ )
875
388
 
876
- if getv(from_object, ['longitude']) is not None:
877
- setv(to_object, ['longitude'], getv(from_object, ['longitude']))
389
+ if getv(from_object, ['exclude_domains']) is not None:
390
+ raise ValueError(
391
+ 'exclude_domains parameter is not supported in Gemini API.'
392
+ )
878
393
 
879
394
  return to_object
880
395
 
@@ -962,10 +477,7 @@ def _ListCachedContentsResponse_from_mldev(
962
477
  setv(
963
478
  to_object,
964
479
  ['cached_contents'],
965
- [
966
- _CachedContent_from_mldev(item, to_object)
967
- for item in getv(from_object, ['cachedContents'])
968
- ],
480
+ [item for item in getv(from_object, ['cachedContents'])],
969
481
  )
970
482
 
971
483
  return to_object
@@ -988,10 +500,7 @@ def _ListCachedContentsResponse_from_vertex(
988
500
  setv(
989
501
  to_object,
990
502
  ['cached_contents'],
991
- [
992
- _CachedContent_from_vertex(item, to_object)
993
- for item in getv(from_object, ['cachedContents'])
994
- ],
503
+ [item for item in getv(from_object, ['cachedContents'])],
995
504
  )
996
505
 
997
506
  return to_object
@@ -1003,13 +512,7 @@ def _Part_to_mldev(
1003
512
  ) -> dict[str, Any]:
1004
513
  to_object: dict[str, Any] = {}
1005
514
  if getv(from_object, ['video_metadata']) is not None:
1006
- setv(
1007
- to_object,
1008
- ['videoMetadata'],
1009
- _VideoMetadata_to_mldev(
1010
- getv(from_object, ['video_metadata']), to_object
1011
- ),
1012
- )
515
+ setv(to_object, ['videoMetadata'], getv(from_object, ['video_metadata']))
1013
516
 
1014
517
  if getv(from_object, ['thought']) is not None:
1015
518
  setv(to_object, ['thought'], getv(from_object, ['thought']))
@@ -1036,81 +539,7 @@ def _Part_to_mldev(
1036
539
  )
1037
540
 
1038
541
  if getv(from_object, ['function_call']) is not None:
1039
- setv(
1040
- to_object,
1041
- ['functionCall'],
1042
- _FunctionCall_to_mldev(getv(from_object, ['function_call']), to_object),
1043
- )
1044
-
1045
- if getv(from_object, ['code_execution_result']) is not None:
1046
- setv(
1047
- to_object,
1048
- ['codeExecutionResult'],
1049
- getv(from_object, ['code_execution_result']),
1050
- )
1051
-
1052
- if getv(from_object, ['executable_code']) is not None:
1053
- setv(to_object, ['executableCode'], getv(from_object, ['executable_code']))
1054
-
1055
- if getv(from_object, ['function_response']) is not None:
1056
- setv(
1057
- to_object,
1058
- ['functionResponse'],
1059
- getv(from_object, ['function_response']),
1060
- )
1061
-
1062
- if getv(from_object, ['text']) is not None:
1063
- setv(to_object, ['text'], getv(from_object, ['text']))
1064
-
1065
- return to_object
1066
-
1067
-
1068
- def _Part_to_vertex(
1069
- from_object: Union[dict[str, Any], object],
1070
- parent_object: Optional[dict[str, Any]] = None,
1071
- ) -> dict[str, Any]:
1072
- to_object: dict[str, Any] = {}
1073
- if getv(from_object, ['video_metadata']) is not None:
1074
- setv(
1075
- to_object,
1076
- ['videoMetadata'],
1077
- _VideoMetadata_to_vertex(
1078
- getv(from_object, ['video_metadata']), to_object
1079
- ),
1080
- )
1081
-
1082
- if getv(from_object, ['thought']) is not None:
1083
- setv(to_object, ['thought'], getv(from_object, ['thought']))
1084
-
1085
- if getv(from_object, ['inline_data']) is not None:
1086
- setv(
1087
- to_object,
1088
- ['inlineData'],
1089
- _Blob_to_vertex(getv(from_object, ['inline_data']), to_object),
1090
- )
1091
-
1092
- if getv(from_object, ['file_data']) is not None:
1093
- setv(
1094
- to_object,
1095
- ['fileData'],
1096
- _FileData_to_vertex(getv(from_object, ['file_data']), to_object),
1097
- )
1098
-
1099
- if getv(from_object, ['thought_signature']) is not None:
1100
- setv(
1101
- to_object,
1102
- ['thoughtSignature'],
1103
- getv(from_object, ['thought_signature']),
1104
- )
1105
-
1106
- if getv(from_object, ['function_call']) is not None:
1107
- setv(
1108
- to_object,
1109
- ['functionCall'],
1110
- _FunctionCall_to_vertex(
1111
- getv(from_object, ['function_call']), to_object
1112
- ),
1113
- )
542
+ setv(to_object, ['functionCall'], getv(from_object, ['function_call']))
1114
543
 
1115
544
  if getv(from_object, ['code_execution_result']) is not None:
1116
545
  setv(
@@ -1135,94 +564,6 @@ def _Part_to_vertex(
1135
564
  return to_object
1136
565
 
1137
566
 
1138
- def _RetrievalConfig_to_mldev(
1139
- from_object: Union[dict[str, Any], object],
1140
- parent_object: Optional[dict[str, Any]] = None,
1141
- ) -> dict[str, Any]:
1142
- to_object: dict[str, Any] = {}
1143
- if getv(from_object, ['lat_lng']) is not None:
1144
- setv(
1145
- to_object,
1146
- ['latLng'],
1147
- _LatLng_to_mldev(getv(from_object, ['lat_lng']), to_object),
1148
- )
1149
-
1150
- if getv(from_object, ['language_code']) is not None:
1151
- setv(to_object, ['languageCode'], getv(from_object, ['language_code']))
1152
-
1153
- return to_object
1154
-
1155
-
1156
- def _RetrievalConfig_to_vertex(
1157
- from_object: Union[dict[str, Any], object],
1158
- parent_object: Optional[dict[str, Any]] = None,
1159
- ) -> dict[str, Any]:
1160
- to_object: dict[str, Any] = {}
1161
- if getv(from_object, ['lat_lng']) is not None:
1162
- setv(
1163
- to_object,
1164
- ['latLng'],
1165
- _LatLng_to_vertex(getv(from_object, ['lat_lng']), to_object),
1166
- )
1167
-
1168
- if getv(from_object, ['language_code']) is not None:
1169
- setv(to_object, ['languageCode'], getv(from_object, ['language_code']))
1170
-
1171
- return to_object
1172
-
1173
-
1174
- def _ToolConfig_to_mldev(
1175
- from_object: Union[dict[str, Any], object],
1176
- parent_object: Optional[dict[str, Any]] = None,
1177
- ) -> dict[str, Any]:
1178
- to_object: dict[str, Any] = {}
1179
- if getv(from_object, ['function_calling_config']) is not None:
1180
- setv(
1181
- to_object,
1182
- ['functionCallingConfig'],
1183
- _FunctionCallingConfig_to_mldev(
1184
- getv(from_object, ['function_calling_config']), to_object
1185
- ),
1186
- )
1187
-
1188
- if getv(from_object, ['retrieval_config']) is not None:
1189
- setv(
1190
- to_object,
1191
- ['retrievalConfig'],
1192
- _RetrievalConfig_to_mldev(
1193
- getv(from_object, ['retrieval_config']), to_object
1194
- ),
1195
- )
1196
-
1197
- return to_object
1198
-
1199
-
1200
- def _ToolConfig_to_vertex(
1201
- from_object: Union[dict[str, Any], object],
1202
- parent_object: Optional[dict[str, Any]] = None,
1203
- ) -> dict[str, Any]:
1204
- to_object: dict[str, Any] = {}
1205
- if getv(from_object, ['function_calling_config']) is not None:
1206
- setv(
1207
- to_object,
1208
- ['functionCallingConfig'],
1209
- _FunctionCallingConfig_to_vertex(
1210
- getv(from_object, ['function_calling_config']), to_object
1211
- ),
1212
- )
1213
-
1214
- if getv(from_object, ['retrieval_config']) is not None:
1215
- setv(
1216
- to_object,
1217
- ['retrievalConfig'],
1218
- _RetrievalConfig_to_vertex(
1219
- getv(from_object, ['retrieval_config']), to_object
1220
- ),
1221
- )
1222
-
1223
- return to_object
1224
-
1225
-
1226
567
  def _Tool_to_mldev(
1227
568
  from_object: Union[dict[str, Any], object],
1228
569
  parent_object: Optional[dict[str, Any]] = None,
@@ -1232,10 +573,7 @@ def _Tool_to_mldev(
1232
573
  setv(
1233
574
  to_object,
1234
575
  ['functionDeclarations'],
1235
- [
1236
- _FunctionDeclaration_to_mldev(item, to_object)
1237
- for item in getv(from_object, ['function_declarations'])
1238
- ],
576
+ [item for item in getv(from_object, ['function_declarations'])],
1239
577
  )
1240
578
 
1241
579
  if getv(from_object, ['retrieval']) is not None:
@@ -1252,9 +590,7 @@ def _Tool_to_mldev(
1252
590
  setv(
1253
591
  to_object,
1254
592
  ['googleSearchRetrieval'],
1255
- _GoogleSearchRetrieval_to_mldev(
1256
- getv(from_object, ['google_search_retrieval']), to_object
1257
- ),
593
+ getv(from_object, ['google_search_retrieval']),
1258
594
  )
1259
595
 
1260
596
  if getv(from_object, ['enterprise_web_search']) is not None:
@@ -1263,21 +599,17 @@ def _Tool_to_mldev(
1263
599
  )
1264
600
 
1265
601
  if getv(from_object, ['google_maps']) is not None:
1266
- raise ValueError('google_maps parameter is not supported in Gemini API.')
1267
-
1268
- if getv(from_object, ['url_context']) is not None:
1269
602
  setv(
1270
603
  to_object,
1271
- ['urlContext'],
1272
- _UrlContext_to_mldev(getv(from_object, ['url_context']), to_object),
604
+ ['googleMaps'],
605
+ _GoogleMaps_to_mldev(getv(from_object, ['google_maps']), to_object),
1273
606
  )
1274
607
 
608
+ if getv(from_object, ['url_context']) is not None:
609
+ setv(to_object, ['urlContext'], getv(from_object, ['url_context']))
610
+
1275
611
  if getv(from_object, ['computer_use']) is not None:
1276
- setv(
1277
- to_object,
1278
- ['computerUse'],
1279
- _ComputerUse_to_mldev(getv(from_object, ['computer_use']), to_object),
1280
- )
612
+ setv(to_object, ['computerUse'], getv(from_object, ['computer_use']))
1281
613
 
1282
614
  if getv(from_object, ['code_execution']) is not None:
1283
615
  setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
@@ -1304,52 +636,30 @@ def _Tool_to_vertex(
1304
636
  setv(to_object, ['retrieval'], getv(from_object, ['retrieval']))
1305
637
 
1306
638
  if getv(from_object, ['google_search']) is not None:
1307
- setv(
1308
- to_object,
1309
- ['googleSearch'],
1310
- _GoogleSearch_to_vertex(
1311
- getv(from_object, ['google_search']), to_object
1312
- ),
1313
- )
639
+ setv(to_object, ['googleSearch'], getv(from_object, ['google_search']))
1314
640
 
1315
641
  if getv(from_object, ['google_search_retrieval']) is not None:
1316
642
  setv(
1317
643
  to_object,
1318
644
  ['googleSearchRetrieval'],
1319
- _GoogleSearchRetrieval_to_vertex(
1320
- getv(from_object, ['google_search_retrieval']), to_object
1321
- ),
645
+ getv(from_object, ['google_search_retrieval']),
1322
646
  )
1323
647
 
1324
648
  if getv(from_object, ['enterprise_web_search']) is not None:
1325
649
  setv(
1326
650
  to_object,
1327
651
  ['enterpriseWebSearch'],
1328
- _EnterpriseWebSearch_to_vertex(
1329
- getv(from_object, ['enterprise_web_search']), to_object
1330
- ),
652
+ getv(from_object, ['enterprise_web_search']),
1331
653
  )
1332
654
 
1333
655
  if getv(from_object, ['google_maps']) is not None:
1334
- setv(
1335
- to_object,
1336
- ['googleMaps'],
1337
- _GoogleMaps_to_vertex(getv(from_object, ['google_maps']), to_object),
1338
- )
656
+ setv(to_object, ['googleMaps'], getv(from_object, ['google_maps']))
1339
657
 
1340
658
  if getv(from_object, ['url_context']) is not None:
1341
- setv(
1342
- to_object,
1343
- ['urlContext'],
1344
- _UrlContext_to_vertex(getv(from_object, ['url_context']), to_object),
1345
- )
659
+ setv(to_object, ['urlContext'], getv(from_object, ['url_context']))
1346
660
 
1347
661
  if getv(from_object, ['computer_use']) is not None:
1348
- setv(
1349
- to_object,
1350
- ['computerUse'],
1351
- _ComputerUse_to_vertex(getv(from_object, ['computer_use']), to_object),
1352
- )
662
+ setv(to_object, ['computerUse'], getv(from_object, ['computer_use']))
1353
663
 
1354
664
  if getv(from_object, ['code_execution']) is not None:
1355
665
  setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
@@ -1429,58 +739,6 @@ def _UpdateCachedContentParameters_to_vertex(
1429
739
  return to_object
1430
740
 
1431
741
 
1432
- def _UrlContext_to_mldev(
1433
- from_object: Union[dict[str, Any], object],
1434
- parent_object: Optional[dict[str, Any]] = None,
1435
- ) -> dict[str, Any]:
1436
- to_object: dict[str, Any] = {}
1437
-
1438
- return to_object
1439
-
1440
-
1441
- def _UrlContext_to_vertex(
1442
- from_object: Union[dict[str, Any], object],
1443
- parent_object: Optional[dict[str, Any]] = None,
1444
- ) -> dict[str, Any]:
1445
- to_object: dict[str, Any] = {}
1446
-
1447
- return to_object
1448
-
1449
-
1450
- def _VideoMetadata_to_mldev(
1451
- from_object: Union[dict[str, Any], object],
1452
- parent_object: Optional[dict[str, Any]] = None,
1453
- ) -> dict[str, Any]:
1454
- to_object: dict[str, Any] = {}
1455
- if getv(from_object, ['fps']) is not None:
1456
- setv(to_object, ['fps'], getv(from_object, ['fps']))
1457
-
1458
- if getv(from_object, ['end_offset']) is not None:
1459
- setv(to_object, ['endOffset'], getv(from_object, ['end_offset']))
1460
-
1461
- if getv(from_object, ['start_offset']) is not None:
1462
- setv(to_object, ['startOffset'], getv(from_object, ['start_offset']))
1463
-
1464
- return to_object
1465
-
1466
-
1467
- def _VideoMetadata_to_vertex(
1468
- from_object: Union[dict[str, Any], object],
1469
- parent_object: Optional[dict[str, Any]] = None,
1470
- ) -> dict[str, Any]:
1471
- to_object: dict[str, Any] = {}
1472
- if getv(from_object, ['fps']) is not None:
1473
- setv(to_object, ['fps'], getv(from_object, ['fps']))
1474
-
1475
- if getv(from_object, ['end_offset']) is not None:
1476
- setv(to_object, ['endOffset'], getv(from_object, ['end_offset']))
1477
-
1478
- if getv(from_object, ['start_offset']) is not None:
1479
- setv(to_object, ['startOffset'], getv(from_object, ['start_offset']))
1480
-
1481
- return to_object
1482
-
1483
-
1484
742
  class Caches(_api_module.BaseModule):
1485
743
 
1486
744
  def create(
@@ -1552,13 +810,7 @@ class Caches(_api_module.BaseModule):
1552
810
  'post', path, request_dict, http_options
1553
811
  )
1554
812
 
1555
- response_dict = '' if not response.body else json.loads(response.body)
1556
-
1557
- if self._api_client.vertexai:
1558
- response_dict = _CachedContent_from_vertex(response_dict)
1559
-
1560
- else:
1561
- response_dict = _CachedContent_from_mldev(response_dict)
813
+ response_dict = {} if not response.body else json.loads(response.body)
1562
814
 
1563
815
  return_value = types.CachedContent._from_response(
1564
816
  response=response_dict, kwargs=parameter_model.model_dump()
@@ -1623,13 +875,7 @@ class Caches(_api_module.BaseModule):
1623
875
 
1624
876
  response = self._api_client.request('get', path, request_dict, http_options)
1625
877
 
1626
- response_dict = '' if not response.body else json.loads(response.body)
1627
-
1628
- if self._api_client.vertexai:
1629
- response_dict = _CachedContent_from_vertex(response_dict)
1630
-
1631
- else:
1632
- response_dict = _CachedContent_from_mldev(response_dict)
878
+ response_dict = {} if not response.body else json.loads(response.body)
1633
879
 
1634
880
  return_value = types.CachedContent._from_response(
1635
881
  response=response_dict, kwargs=parameter_model.model_dump()
@@ -1698,12 +944,12 @@ class Caches(_api_module.BaseModule):
1698
944
  'delete', path, request_dict, http_options
1699
945
  )
1700
946
 
1701
- response_dict = '' if not response.body else json.loads(response.body)
947
+ response_dict = {} if not response.body else json.loads(response.body)
1702
948
 
1703
949
  if self._api_client.vertexai:
1704
950
  response_dict = _DeleteCachedContentResponse_from_vertex(response_dict)
1705
951
 
1706
- else:
952
+ if not self._api_client.vertexai:
1707
953
  response_dict = _DeleteCachedContentResponse_from_mldev(response_dict)
1708
954
 
1709
955
  return_value = types.DeleteCachedContentResponse._from_response(
@@ -1778,13 +1024,7 @@ class Caches(_api_module.BaseModule):
1778
1024
  'patch', path, request_dict, http_options
1779
1025
  )
1780
1026
 
1781
- response_dict = '' if not response.body else json.loads(response.body)
1782
-
1783
- if self._api_client.vertexai:
1784
- response_dict = _CachedContent_from_vertex(response_dict)
1785
-
1786
- else:
1787
- response_dict = _CachedContent_from_mldev(response_dict)
1027
+ response_dict = {} if not response.body else json.loads(response.body)
1788
1028
 
1789
1029
  return_value = types.CachedContent._from_response(
1790
1030
  response=response_dict, kwargs=parameter_model.model_dump()
@@ -1843,12 +1083,12 @@ class Caches(_api_module.BaseModule):
1843
1083
 
1844
1084
  response = self._api_client.request('get', path, request_dict, http_options)
1845
1085
 
1846
- response_dict = '' if not response.body else json.loads(response.body)
1086
+ response_dict = {} if not response.body else json.loads(response.body)
1847
1087
 
1848
1088
  if self._api_client.vertexai:
1849
1089
  response_dict = _ListCachedContentsResponse_from_vertex(response_dict)
1850
1090
 
1851
- else:
1091
+ if not self._api_client.vertexai:
1852
1092
  response_dict = _ListCachedContentsResponse_from_mldev(response_dict)
1853
1093
 
1854
1094
  return_value = types.ListCachedContentsResponse._from_response(
@@ -1942,13 +1182,7 @@ class AsyncCaches(_api_module.BaseModule):
1942
1182
  'post', path, request_dict, http_options
1943
1183
  )
1944
1184
 
1945
- response_dict = '' if not response.body else json.loads(response.body)
1946
-
1947
- if self._api_client.vertexai:
1948
- response_dict = _CachedContent_from_vertex(response_dict)
1949
-
1950
- else:
1951
- response_dict = _CachedContent_from_mldev(response_dict)
1185
+ response_dict = {} if not response.body else json.loads(response.body)
1952
1186
 
1953
1187
  return_value = types.CachedContent._from_response(
1954
1188
  response=response_dict, kwargs=parameter_model.model_dump()
@@ -2016,13 +1250,7 @@ class AsyncCaches(_api_module.BaseModule):
2016
1250
  'get', path, request_dict, http_options
2017
1251
  )
2018
1252
 
2019
- response_dict = '' if not response.body else json.loads(response.body)
2020
-
2021
- if self._api_client.vertexai:
2022
- response_dict = _CachedContent_from_vertex(response_dict)
2023
-
2024
- else:
2025
- response_dict = _CachedContent_from_mldev(response_dict)
1253
+ response_dict = {} if not response.body else json.loads(response.body)
2026
1254
 
2027
1255
  return_value = types.CachedContent._from_response(
2028
1256
  response=response_dict, kwargs=parameter_model.model_dump()
@@ -2092,12 +1320,12 @@ class AsyncCaches(_api_module.BaseModule):
2092
1320
  'delete', path, request_dict, http_options
2093
1321
  )
2094
1322
 
2095
- response_dict = '' if not response.body else json.loads(response.body)
1323
+ response_dict = {} if not response.body else json.loads(response.body)
2096
1324
 
2097
1325
  if self._api_client.vertexai:
2098
1326
  response_dict = _DeleteCachedContentResponse_from_vertex(response_dict)
2099
1327
 
2100
- else:
1328
+ if not self._api_client.vertexai:
2101
1329
  response_dict = _DeleteCachedContentResponse_from_mldev(response_dict)
2102
1330
 
2103
1331
  return_value = types.DeleteCachedContentResponse._from_response(
@@ -2172,13 +1400,7 @@ class AsyncCaches(_api_module.BaseModule):
2172
1400
  'patch', path, request_dict, http_options
2173
1401
  )
2174
1402
 
2175
- response_dict = '' if not response.body else json.loads(response.body)
2176
-
2177
- if self._api_client.vertexai:
2178
- response_dict = _CachedContent_from_vertex(response_dict)
2179
-
2180
- else:
2181
- response_dict = _CachedContent_from_mldev(response_dict)
1403
+ response_dict = {} if not response.body else json.loads(response.body)
2182
1404
 
2183
1405
  return_value = types.CachedContent._from_response(
2184
1406
  response=response_dict, kwargs=parameter_model.model_dump()
@@ -2239,12 +1461,12 @@ class AsyncCaches(_api_module.BaseModule):
2239
1461
  'get', path, request_dict, http_options
2240
1462
  )
2241
1463
 
2242
- response_dict = '' if not response.body else json.loads(response.body)
1464
+ response_dict = {} if not response.body else json.loads(response.body)
2243
1465
 
2244
1466
  if self._api_client.vertexai:
2245
1467
  response_dict = _ListCachedContentsResponse_from_vertex(response_dict)
2246
1468
 
2247
- else:
1469
+ if not self._api_client.vertexai:
2248
1470
  response_dict = _ListCachedContentsResponse_from_mldev(response_dict)
2249
1471
 
2250
1472
  return_value = types.ListCachedContentsResponse._from_response(