google-genai 1.40.0__py3-none-any.whl → 1.42.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/_api_client.py +2 -1
- google/genai/_common.py +213 -77
- google/genai/_extra_utils.py +72 -1
- google/genai/_live_converters.py +729 -3078
- google/genai/_replay_api_client.py +8 -4
- google/genai/_tokens_converters.py +20 -424
- google/genai/_transformers.py +42 -12
- google/genai/batches.py +113 -1063
- google/genai/caches.py +67 -863
- google/genai/errors.py +9 -2
- google/genai/files.py +29 -268
- google/genai/live.py +10 -11
- google/genai/live_music.py +24 -27
- google/genai/models.py +322 -1835
- google/genai/operations.py +6 -32
- google/genai/tokens.py +2 -12
- google/genai/tunings.py +24 -197
- google/genai/types.py +187 -5
- google/genai/version.py +1 -1
- {google_genai-1.40.0.dist-info → google_genai-1.42.0.dist-info}/METADATA +40 -38
- google_genai-1.42.0.dist-info/RECORD +39 -0
- google_genai-1.40.0.dist-info/RECORD +0 -39
- {google_genai-1.40.0.dist-info → google_genai-1.42.0.dist-info}/WHEEL +0 -0
- {google_genai-1.40.0.dist-info → google_genai-1.42.0.dist-info}/licenses/LICENSE +0 -0
- {google_genai-1.40.0.dist-info → google_genai-1.42.0.dist-info}/top_level.txt +0 -0
google/genai/batches.py
CHANGED
@@ -27,6 +27,7 @@ from . import _transformers as t
|
|
27
27
|
from . import types
|
28
28
|
from ._api_client import BaseApiClient
|
29
29
|
from ._common import get_value_by_path as getv
|
30
|
+
from ._common import move_value_by_path as movev
|
30
31
|
from ._common import set_value_by_path as setv
|
31
32
|
from .pagers import AsyncPager, Pager
|
32
33
|
|
@@ -63,7 +64,7 @@ def _BatchJobDestination_from_mldev(
|
|
63
64
|
to_object,
|
64
65
|
['inlined_embed_content_responses'],
|
65
66
|
[
|
66
|
-
|
67
|
+
item
|
67
68
|
for item in getv(
|
68
69
|
from_object,
|
69
70
|
['inlinedEmbedContentResponses', 'inlinedResponses'],
|
@@ -291,11 +292,7 @@ def _BatchJob_from_vertex(
|
|
291
292
|
setv(to_object, ['state'], t.t_job_state(getv(from_object, ['state'])))
|
292
293
|
|
293
294
|
if getv(from_object, ['error']) is not None:
|
294
|
-
setv(
|
295
|
-
to_object,
|
296
|
-
['error'],
|
297
|
-
_JobError_from_vertex(getv(from_object, ['error']), to_object),
|
298
|
-
)
|
295
|
+
setv(to_object, ['error'], getv(from_object, ['error']))
|
299
296
|
|
300
297
|
if getv(from_object, ['createTime']) is not None:
|
301
298
|
setv(to_object, ['create_time'], getv(from_object, ['createTime']))
|
@@ -334,21 +331,6 @@ def _BatchJob_from_vertex(
|
|
334
331
|
return to_object
|
335
332
|
|
336
333
|
|
337
|
-
def _Blob_from_mldev(
|
338
|
-
from_object: Union[dict[str, Any], object],
|
339
|
-
parent_object: Optional[dict[str, Any]] = None,
|
340
|
-
) -> dict[str, Any]:
|
341
|
-
to_object: dict[str, Any] = {}
|
342
|
-
|
343
|
-
if getv(from_object, ['data']) is not None:
|
344
|
-
setv(to_object, ['data'], getv(from_object, ['data']))
|
345
|
-
|
346
|
-
if getv(from_object, ['mimeType']) is not None:
|
347
|
-
setv(to_object, ['mime_type'], getv(from_object, ['mimeType']))
|
348
|
-
|
349
|
-
return to_object
|
350
|
-
|
351
|
-
|
352
334
|
def _Blob_to_mldev(
|
353
335
|
from_object: Union[dict[str, Any], object],
|
354
336
|
parent_object: Optional[dict[str, Any]] = None,
|
@@ -404,11 +386,7 @@ def _Candidate_from_mldev(
|
|
404
386
|
) -> dict[str, Any]:
|
405
387
|
to_object: dict[str, Any] = {}
|
406
388
|
if getv(from_object, ['content']) is not None:
|
407
|
-
setv(
|
408
|
-
to_object,
|
409
|
-
['content'],
|
410
|
-
_Content_from_mldev(getv(from_object, ['content']), to_object),
|
411
|
-
)
|
389
|
+
setv(to_object, ['content'], getv(from_object, ['content']))
|
412
390
|
|
413
391
|
if getv(from_object, ['citationMetadata']) is not None:
|
414
392
|
setv(
|
@@ -429,9 +407,7 @@ def _Candidate_from_mldev(
|
|
429
407
|
setv(
|
430
408
|
to_object,
|
431
409
|
['url_context_metadata'],
|
432
|
-
|
433
|
-
getv(from_object, ['urlContextMetadata']), to_object
|
434
|
-
),
|
410
|
+
getv(from_object, ['urlContextMetadata']),
|
435
411
|
)
|
436
412
|
|
437
413
|
if getv(from_object, ['avgLogprobs']) is not None:
|
@@ -451,69 +427,27 @@ def _Candidate_from_mldev(
|
|
451
427
|
setv(to_object, ['logprobs_result'], getv(from_object, ['logprobsResult']))
|
452
428
|
|
453
429
|
if getv(from_object, ['safetyRatings']) is not None:
|
454
|
-
setv(to_object, ['safety_ratings'], getv(from_object, ['safetyRatings']))
|
455
|
-
|
456
|
-
return to_object
|
457
|
-
|
458
|
-
|
459
|
-
def _CitationMetadata_from_mldev(
|
460
|
-
from_object: Union[dict[str, Any], object],
|
461
|
-
parent_object: Optional[dict[str, Any]] = None,
|
462
|
-
) -> dict[str, Any]:
|
463
|
-
to_object: dict[str, Any] = {}
|
464
|
-
if getv(from_object, ['citationSources']) is not None:
|
465
|
-
setv(to_object, ['citations'], getv(from_object, ['citationSources']))
|
466
|
-
|
467
|
-
return to_object
|
468
|
-
|
469
|
-
|
470
|
-
def _ComputerUse_to_mldev(
|
471
|
-
from_object: Union[dict[str, Any], object],
|
472
|
-
parent_object: Optional[dict[str, Any]] = None,
|
473
|
-
) -> dict[str, Any]:
|
474
|
-
to_object: dict[str, Any] = {}
|
475
|
-
if getv(from_object, ['environment']) is not None:
|
476
|
-
setv(to_object, ['environment'], getv(from_object, ['environment']))
|
477
|
-
|
478
|
-
if getv(from_object, ['excluded_predefined_functions']) is not None:
|
479
430
|
setv(
|
480
431
|
to_object,
|
481
|
-
['
|
482
|
-
getv(from_object, ['
|
432
|
+
['safety_ratings'],
|
433
|
+
[item for item in getv(from_object, ['safetyRatings'])],
|
483
434
|
)
|
484
435
|
|
485
436
|
return to_object
|
486
437
|
|
487
438
|
|
488
|
-
def
|
489
|
-
from_object: Union[dict[str, Any], object],
|
490
|
-
parent_object: Optional[dict[str, Any]] = None,
|
491
|
-
) -> dict[str, Any]:
|
492
|
-
to_object: dict[str, Any] = {}
|
493
|
-
if getv(from_object, ['values']) is not None:
|
494
|
-
setv(to_object, ['values'], getv(from_object, ['values']))
|
495
|
-
|
496
|
-
return to_object
|
497
|
-
|
498
|
-
|
499
|
-
def _Content_from_mldev(
|
439
|
+
def _CitationMetadata_from_mldev(
|
500
440
|
from_object: Union[dict[str, Any], object],
|
501
441
|
parent_object: Optional[dict[str, Any]] = None,
|
502
442
|
) -> dict[str, Any]:
|
503
443
|
to_object: dict[str, Any] = {}
|
504
|
-
if getv(from_object, ['
|
444
|
+
if getv(from_object, ['citationSources']) is not None:
|
505
445
|
setv(
|
506
446
|
to_object,
|
507
|
-
['
|
508
|
-
[
|
509
|
-
_Part_from_mldev(item, to_object)
|
510
|
-
for item in getv(from_object, ['parts'])
|
511
|
-
],
|
447
|
+
['citations'],
|
448
|
+
[item for item in getv(from_object, ['citationSources'])],
|
512
449
|
)
|
513
450
|
|
514
|
-
if getv(from_object, ['role']) is not None:
|
515
|
-
setv(to_object, ['role'], getv(from_object, ['role']))
|
516
|
-
|
517
451
|
return to_object
|
518
452
|
|
519
453
|
|
@@ -732,11 +666,7 @@ def _DeleteResourceJob_from_mldev(
|
|
732
666
|
setv(to_object, ['done'], getv(from_object, ['done']))
|
733
667
|
|
734
668
|
if getv(from_object, ['error']) is not None:
|
735
|
-
setv(
|
736
|
-
to_object,
|
737
|
-
['error'],
|
738
|
-
_JobError_from_mldev(getv(from_object, ['error']), to_object),
|
739
|
-
)
|
669
|
+
setv(to_object, ['error'], getv(from_object, ['error']))
|
740
670
|
|
741
671
|
return to_object
|
742
672
|
|
@@ -758,29 +688,7 @@ def _DeleteResourceJob_from_vertex(
|
|
758
688
|
setv(to_object, ['done'], getv(from_object, ['done']))
|
759
689
|
|
760
690
|
if getv(from_object, ['error']) is not None:
|
761
|
-
setv(
|
762
|
-
to_object,
|
763
|
-
['error'],
|
764
|
-
_JobError_from_vertex(getv(from_object, ['error']), to_object),
|
765
|
-
)
|
766
|
-
|
767
|
-
return to_object
|
768
|
-
|
769
|
-
|
770
|
-
def _DynamicRetrievalConfig_to_mldev(
|
771
|
-
from_object: Union[dict[str, Any], object],
|
772
|
-
parent_object: Optional[dict[str, Any]] = None,
|
773
|
-
) -> dict[str, Any]:
|
774
|
-
to_object: dict[str, Any] = {}
|
775
|
-
if getv(from_object, ['mode']) is not None:
|
776
|
-
setv(to_object, ['mode'], getv(from_object, ['mode']))
|
777
|
-
|
778
|
-
if getv(from_object, ['dynamic_threshold']) is not None:
|
779
|
-
setv(
|
780
|
-
to_object,
|
781
|
-
['dynamicThreshold'],
|
782
|
-
getv(from_object, ['dynamic_threshold']),
|
783
|
-
)
|
691
|
+
setv(to_object, ['error'], getv(from_object, ['error']))
|
784
692
|
|
785
693
|
return to_object
|
786
694
|
|
@@ -795,16 +703,21 @@ def _EmbedContentBatch_to_mldev(
|
|
795
703
|
setv(
|
796
704
|
to_object,
|
797
705
|
['requests[]', 'request', 'content'],
|
798
|
-
|
706
|
+
[
|
707
|
+
item
|
708
|
+
for item in t.t_contents_for_embed(
|
709
|
+
api_client, getv(from_object, ['contents'])
|
710
|
+
)
|
711
|
+
],
|
799
712
|
)
|
800
713
|
|
801
714
|
if getv(from_object, ['config']) is not None:
|
802
715
|
setv(
|
803
716
|
to_object,
|
804
|
-
['
|
717
|
+
['_self'],
|
805
718
|
_EmbedContentConfig_to_mldev(getv(from_object, ['config']), to_object),
|
806
719
|
)
|
807
|
-
|
720
|
+
movev(to_object, {'requests[].*': 'requests[].request.*'})
|
808
721
|
return to_object
|
809
722
|
|
810
723
|
|
@@ -861,21 +774,6 @@ def _EmbeddingsBatchJobSource_to_mldev(
|
|
861
774
|
return to_object
|
862
775
|
|
863
776
|
|
864
|
-
def _FileData_from_mldev(
|
865
|
-
from_object: Union[dict[str, Any], object],
|
866
|
-
parent_object: Optional[dict[str, Any]] = None,
|
867
|
-
) -> dict[str, Any]:
|
868
|
-
to_object: dict[str, Any] = {}
|
869
|
-
|
870
|
-
if getv(from_object, ['fileUri']) is not None:
|
871
|
-
setv(to_object, ['file_uri'], getv(from_object, ['fileUri']))
|
872
|
-
|
873
|
-
if getv(from_object, ['mimeType']) is not None:
|
874
|
-
setv(to_object, ['mime_type'], getv(from_object, ['mimeType']))
|
875
|
-
|
876
|
-
return to_object
|
877
|
-
|
878
|
-
|
879
777
|
def _FileData_to_mldev(
|
880
778
|
from_object: Union[dict[str, Any], object],
|
881
779
|
parent_object: Optional[dict[str, Any]] = None,
|
@@ -893,95 +791,6 @@ def _FileData_to_mldev(
|
|
893
791
|
return to_object
|
894
792
|
|
895
793
|
|
896
|
-
def _FunctionCall_from_mldev(
|
897
|
-
from_object: Union[dict[str, Any], object],
|
898
|
-
parent_object: Optional[dict[str, Any]] = None,
|
899
|
-
) -> dict[str, Any]:
|
900
|
-
to_object: dict[str, Any] = {}
|
901
|
-
if getv(from_object, ['id']) is not None:
|
902
|
-
setv(to_object, ['id'], getv(from_object, ['id']))
|
903
|
-
|
904
|
-
if getv(from_object, ['args']) is not None:
|
905
|
-
setv(to_object, ['args'], getv(from_object, ['args']))
|
906
|
-
|
907
|
-
if getv(from_object, ['name']) is not None:
|
908
|
-
setv(to_object, ['name'], getv(from_object, ['name']))
|
909
|
-
|
910
|
-
return to_object
|
911
|
-
|
912
|
-
|
913
|
-
def _FunctionCall_to_mldev(
|
914
|
-
from_object: Union[dict[str, Any], object],
|
915
|
-
parent_object: Optional[dict[str, Any]] = None,
|
916
|
-
) -> dict[str, Any]:
|
917
|
-
to_object: dict[str, Any] = {}
|
918
|
-
if getv(from_object, ['id']) is not None:
|
919
|
-
setv(to_object, ['id'], getv(from_object, ['id']))
|
920
|
-
|
921
|
-
if getv(from_object, ['args']) is not None:
|
922
|
-
setv(to_object, ['args'], getv(from_object, ['args']))
|
923
|
-
|
924
|
-
if getv(from_object, ['name']) is not None:
|
925
|
-
setv(to_object, ['name'], getv(from_object, ['name']))
|
926
|
-
|
927
|
-
return to_object
|
928
|
-
|
929
|
-
|
930
|
-
def _FunctionCallingConfig_to_mldev(
|
931
|
-
from_object: Union[dict[str, Any], object],
|
932
|
-
parent_object: Optional[dict[str, Any]] = None,
|
933
|
-
) -> dict[str, Any]:
|
934
|
-
to_object: dict[str, Any] = {}
|
935
|
-
if getv(from_object, ['mode']) is not None:
|
936
|
-
setv(to_object, ['mode'], getv(from_object, ['mode']))
|
937
|
-
|
938
|
-
if getv(from_object, ['allowed_function_names']) is not None:
|
939
|
-
setv(
|
940
|
-
to_object,
|
941
|
-
['allowedFunctionNames'],
|
942
|
-
getv(from_object, ['allowed_function_names']),
|
943
|
-
)
|
944
|
-
|
945
|
-
return to_object
|
946
|
-
|
947
|
-
|
948
|
-
def _FunctionDeclaration_to_mldev(
|
949
|
-
from_object: Union[dict[str, Any], object],
|
950
|
-
parent_object: Optional[dict[str, Any]] = None,
|
951
|
-
) -> dict[str, Any]:
|
952
|
-
to_object: dict[str, Any] = {}
|
953
|
-
if getv(from_object, ['behavior']) is not None:
|
954
|
-
setv(to_object, ['behavior'], getv(from_object, ['behavior']))
|
955
|
-
|
956
|
-
if getv(from_object, ['description']) is not None:
|
957
|
-
setv(to_object, ['description'], getv(from_object, ['description']))
|
958
|
-
|
959
|
-
if getv(from_object, ['name']) is not None:
|
960
|
-
setv(to_object, ['name'], getv(from_object, ['name']))
|
961
|
-
|
962
|
-
if getv(from_object, ['parameters']) is not None:
|
963
|
-
setv(to_object, ['parameters'], getv(from_object, ['parameters']))
|
964
|
-
|
965
|
-
if getv(from_object, ['parameters_json_schema']) is not None:
|
966
|
-
setv(
|
967
|
-
to_object,
|
968
|
-
['parametersJsonSchema'],
|
969
|
-
getv(from_object, ['parameters_json_schema']),
|
970
|
-
)
|
971
|
-
|
972
|
-
if getv(from_object, ['response']) is not None:
|
973
|
-
setv(to_object, ['response'], getv(from_object, ['response']))
|
974
|
-
|
975
|
-
if getv(from_object, ['response_json_schema']) is not None:
|
976
|
-
setv(
|
977
|
-
to_object,
|
978
|
-
['responseJsonSchema'],
|
979
|
-
getv(from_object, ['response_json_schema']),
|
980
|
-
)
|
981
|
-
|
982
|
-
return to_object
|
983
|
-
|
984
|
-
|
985
794
|
def _GenerateContentConfig_to_mldev(
|
986
795
|
api_client: BaseApiClient,
|
987
796
|
from_object: Union[dict[str, Any], object],
|
@@ -1054,10 +863,7 @@ def _GenerateContentConfig_to_mldev(
|
|
1054
863
|
setv(
|
1055
864
|
to_object,
|
1056
865
|
['responseSchema'],
|
1057
|
-
|
1058
|
-
t.t_schema(api_client, getv(from_object, ['response_schema'])),
|
1059
|
-
to_object,
|
1060
|
-
),
|
866
|
+
t.t_schema(api_client, getv(from_object, ['response_schema'])),
|
1061
867
|
)
|
1062
868
|
|
1063
869
|
if getv(from_object, ['response_json_schema']) is not None:
|
@@ -1096,11 +902,7 @@ def _GenerateContentConfig_to_mldev(
|
|
1096
902
|
)
|
1097
903
|
|
1098
904
|
if getv(from_object, ['tool_config']) is not None:
|
1099
|
-
setv(
|
1100
|
-
parent_object,
|
1101
|
-
['toolConfig'],
|
1102
|
-
_ToolConfig_to_mldev(getv(from_object, ['tool_config']), to_object),
|
1103
|
-
)
|
905
|
+
setv(parent_object, ['toolConfig'], getv(from_object, ['tool_config']))
|
1104
906
|
|
1105
907
|
if getv(from_object, ['labels']) is not None:
|
1106
908
|
raise ValueError('labels parameter is not supported in Gemini API.')
|
@@ -1130,9 +932,7 @@ def _GenerateContentConfig_to_mldev(
|
|
1130
932
|
setv(
|
1131
933
|
to_object,
|
1132
934
|
['speechConfig'],
|
1133
|
-
|
1134
|
-
t.t_speech_config(getv(from_object, ['speech_config'])), to_object
|
1135
|
-
),
|
935
|
+
t.t_speech_config(getv(from_object, ['speech_config'])),
|
1136
936
|
)
|
1137
937
|
|
1138
938
|
if getv(from_object, ['audio_timestamp']) is not None:
|
@@ -1141,20 +941,10 @@ def _GenerateContentConfig_to_mldev(
|
|
1141
941
|
)
|
1142
942
|
|
1143
943
|
if getv(from_object, ['thinking_config']) is not None:
|
1144
|
-
setv(
|
1145
|
-
to_object,
|
1146
|
-
['thinkingConfig'],
|
1147
|
-
_ThinkingConfig_to_mldev(
|
1148
|
-
getv(from_object, ['thinking_config']), to_object
|
1149
|
-
),
|
1150
|
-
)
|
944
|
+
setv(to_object, ['thinkingConfig'], getv(from_object, ['thinking_config']))
|
1151
945
|
|
1152
946
|
if getv(from_object, ['image_config']) is not None:
|
1153
|
-
setv(
|
1154
|
-
to_object,
|
1155
|
-
['imageConfig'],
|
1156
|
-
_ImageConfig_to_mldev(getv(from_object, ['image_config']), to_object),
|
1157
|
-
)
|
947
|
+
setv(to_object, ['imageConfig'], getv(from_object, ['image_config']))
|
1158
948
|
|
1159
949
|
return to_object
|
1160
950
|
|
@@ -1226,23 +1016,6 @@ def _GetBatchJobParameters_to_vertex(
|
|
1226
1016
|
return to_object
|
1227
1017
|
|
1228
1018
|
|
1229
|
-
def _GoogleSearchRetrieval_to_mldev(
|
1230
|
-
from_object: Union[dict[str, Any], object],
|
1231
|
-
parent_object: Optional[dict[str, Any]] = None,
|
1232
|
-
) -> dict[str, Any]:
|
1233
|
-
to_object: dict[str, Any] = {}
|
1234
|
-
if getv(from_object, ['dynamic_retrieval_config']) is not None:
|
1235
|
-
setv(
|
1236
|
-
to_object,
|
1237
|
-
['dynamicRetrievalConfig'],
|
1238
|
-
_DynamicRetrievalConfig_to_mldev(
|
1239
|
-
getv(from_object, ['dynamic_retrieval_config']), to_object
|
1240
|
-
),
|
1241
|
-
)
|
1242
|
-
|
1243
|
-
return to_object
|
1244
|
-
|
1245
|
-
|
1246
1019
|
def _GoogleSearch_to_mldev(
|
1247
1020
|
from_object: Union[dict[str, Any], object],
|
1248
1021
|
parent_object: Optional[dict[str, Any]] = None,
|
@@ -1250,9 +1023,7 @@ def _GoogleSearch_to_mldev(
|
|
1250
1023
|
to_object: dict[str, Any] = {}
|
1251
1024
|
if getv(from_object, ['time_range_filter']) is not None:
|
1252
1025
|
setv(
|
1253
|
-
to_object,
|
1254
|
-
['timeRangeFilter'],
|
1255
|
-
_Interval_to_mldev(getv(from_object, ['time_range_filter']), to_object),
|
1026
|
+
to_object, ['timeRangeFilter'], getv(from_object, ['time_range_filter'])
|
1256
1027
|
)
|
1257
1028
|
|
1258
1029
|
if getv(from_object, ['exclude_domains']) is not None:
|
@@ -1263,41 +1034,6 @@ def _GoogleSearch_to_mldev(
|
|
1263
1034
|
return to_object
|
1264
1035
|
|
1265
1036
|
|
1266
|
-
def _ImageConfig_to_mldev(
|
1267
|
-
from_object: Union[dict[str, Any], object],
|
1268
|
-
parent_object: Optional[dict[str, Any]] = None,
|
1269
|
-
) -> dict[str, Any]:
|
1270
|
-
to_object: dict[str, Any] = {}
|
1271
|
-
if getv(from_object, ['aspect_ratio']) is not None:
|
1272
|
-
setv(to_object, ['aspectRatio'], getv(from_object, ['aspect_ratio']))
|
1273
|
-
|
1274
|
-
return to_object
|
1275
|
-
|
1276
|
-
|
1277
|
-
def _InlinedEmbedContentResponse_from_mldev(
|
1278
|
-
from_object: Union[dict[str, Any], object],
|
1279
|
-
parent_object: Optional[dict[str, Any]] = None,
|
1280
|
-
) -> dict[str, Any]:
|
1281
|
-
to_object: dict[str, Any] = {}
|
1282
|
-
if getv(from_object, ['response']) is not None:
|
1283
|
-
setv(
|
1284
|
-
to_object,
|
1285
|
-
['response'],
|
1286
|
-
_SingleEmbedContentResponse_from_mldev(
|
1287
|
-
getv(from_object, ['response']), to_object
|
1288
|
-
),
|
1289
|
-
)
|
1290
|
-
|
1291
|
-
if getv(from_object, ['error']) is not None:
|
1292
|
-
setv(
|
1293
|
-
to_object,
|
1294
|
-
['error'],
|
1295
|
-
_JobError_from_mldev(getv(from_object, ['error']), to_object),
|
1296
|
-
)
|
1297
|
-
|
1298
|
-
return to_object
|
1299
|
-
|
1300
|
-
|
1301
1037
|
def _InlinedRequest_to_mldev(
|
1302
1038
|
api_client: BaseApiClient,
|
1303
1039
|
from_object: Union[dict[str, Any], object],
|
@@ -1326,7 +1062,9 @@ def _InlinedRequest_to_mldev(
|
|
1326
1062
|
to_object,
|
1327
1063
|
['request', 'generationConfig'],
|
1328
1064
|
_GenerateContentConfig_to_mldev(
|
1329
|
-
api_client,
|
1065
|
+
api_client,
|
1066
|
+
getv(from_object, ['config']),
|
1067
|
+
getv(to_object, ['request'], default_value={}),
|
1330
1068
|
),
|
1331
1069
|
)
|
1332
1070
|
|
@@ -1348,73 +1086,7 @@ def _InlinedResponse_from_mldev(
|
|
1348
1086
|
)
|
1349
1087
|
|
1350
1088
|
if getv(from_object, ['error']) is not None:
|
1351
|
-
setv(
|
1352
|
-
to_object,
|
1353
|
-
['error'],
|
1354
|
-
_JobError_from_mldev(getv(from_object, ['error']), to_object),
|
1355
|
-
)
|
1356
|
-
|
1357
|
-
return to_object
|
1358
|
-
|
1359
|
-
|
1360
|
-
def _Interval_to_mldev(
|
1361
|
-
from_object: Union[dict[str, Any], object],
|
1362
|
-
parent_object: Optional[dict[str, Any]] = None,
|
1363
|
-
) -> dict[str, Any]:
|
1364
|
-
to_object: dict[str, Any] = {}
|
1365
|
-
if getv(from_object, ['start_time']) is not None:
|
1366
|
-
setv(to_object, ['startTime'], getv(from_object, ['start_time']))
|
1367
|
-
|
1368
|
-
if getv(from_object, ['end_time']) is not None:
|
1369
|
-
setv(to_object, ['endTime'], getv(from_object, ['end_time']))
|
1370
|
-
|
1371
|
-
return to_object
|
1372
|
-
|
1373
|
-
|
1374
|
-
def _JobError_from_mldev(
|
1375
|
-
from_object: Union[dict[str, Any], object],
|
1376
|
-
parent_object: Optional[dict[str, Any]] = None,
|
1377
|
-
) -> dict[str, Any]:
|
1378
|
-
to_object: dict[str, Any] = {}
|
1379
|
-
if getv(from_object, ['details']) is not None:
|
1380
|
-
setv(to_object, ['details'], getv(from_object, ['details']))
|
1381
|
-
|
1382
|
-
if getv(from_object, ['code']) is not None:
|
1383
|
-
setv(to_object, ['code'], getv(from_object, ['code']))
|
1384
|
-
|
1385
|
-
if getv(from_object, ['message']) is not None:
|
1386
|
-
setv(to_object, ['message'], getv(from_object, ['message']))
|
1387
|
-
|
1388
|
-
return to_object
|
1389
|
-
|
1390
|
-
|
1391
|
-
def _JobError_from_vertex(
|
1392
|
-
from_object: Union[dict[str, Any], object],
|
1393
|
-
parent_object: Optional[dict[str, Any]] = None,
|
1394
|
-
) -> dict[str, Any]:
|
1395
|
-
to_object: dict[str, Any] = {}
|
1396
|
-
if getv(from_object, ['details']) is not None:
|
1397
|
-
setv(to_object, ['details'], getv(from_object, ['details']))
|
1398
|
-
|
1399
|
-
if getv(from_object, ['code']) is not None:
|
1400
|
-
setv(to_object, ['code'], getv(from_object, ['code']))
|
1401
|
-
|
1402
|
-
if getv(from_object, ['message']) is not None:
|
1403
|
-
setv(to_object, ['message'], getv(from_object, ['message']))
|
1404
|
-
|
1405
|
-
return to_object
|
1406
|
-
|
1407
|
-
|
1408
|
-
def _LatLng_to_mldev(
|
1409
|
-
from_object: Union[dict[str, Any], object],
|
1410
|
-
parent_object: Optional[dict[str, Any]] = None,
|
1411
|
-
) -> dict[str, Any]:
|
1412
|
-
to_object: dict[str, Any] = {}
|
1413
|
-
if getv(from_object, ['latitude']) is not None:
|
1414
|
-
setv(to_object, ['latitude'], getv(from_object, ['latitude']))
|
1415
|
-
|
1416
|
-
if getv(from_object, ['longitude']) is not None:
|
1417
|
-
setv(to_object, ['longitude'], getv(from_object, ['longitude']))
|
1089
|
+
setv(to_object, ['error'], getv(from_object, ['error']))
|
1418
1090
|
|
1419
1091
|
return to_object
|
1420
1092
|
|
@@ -1508,433 +1180,110 @@ def _ListBatchJobsResponse_from_mldev(
|
|
1508
1180
|
['batch_jobs'],
|
1509
1181
|
[
|
1510
1182
|
_BatchJob_from_mldev(item, to_object)
|
1511
|
-
for item in getv(from_object, ['operations'])
|
1512
|
-
],
|
1513
|
-
)
|
1514
|
-
|
1515
|
-
return to_object
|
1516
|
-
|
1517
|
-
|
1518
|
-
def _ListBatchJobsResponse_from_vertex(
|
1519
|
-
from_object: Union[dict[str, Any], object],
|
1520
|
-
parent_object: Optional[dict[str, Any]] = None,
|
1521
|
-
) -> dict[str, Any]:
|
1522
|
-
to_object: dict[str, Any] = {}
|
1523
|
-
if getv(from_object, ['sdkHttpResponse']) is not None:
|
1524
|
-
setv(
|
1525
|
-
to_object, ['sdk_http_response'], getv(from_object, ['sdkHttpResponse'])
|
1526
|
-
)
|
1527
|
-
|
1528
|
-
if getv(from_object, ['nextPageToken']) is not None:
|
1529
|
-
setv(to_object, ['next_page_token'], getv(from_object, ['nextPageToken']))
|
1530
|
-
|
1531
|
-
if getv(from_object, ['batchPredictionJobs']) is not None:
|
1532
|
-
setv(
|
1533
|
-
to_object,
|
1534
|
-
['batch_jobs'],
|
1535
|
-
[
|
1536
|
-
_BatchJob_from_vertex(item, to_object)
|
1537
|
-
for item in getv(from_object, ['batchPredictionJobs'])
|
1538
|
-
],
|
1539
|
-
)
|
1540
|
-
|
1541
|
-
return to_object
|
1542
|
-
|
1543
|
-
|
1544
|
-
def _MultiSpeakerVoiceConfig_to_mldev(
|
1545
|
-
from_object: Union[dict[str, Any], object],
|
1546
|
-
parent_object: Optional[dict[str, Any]] = None,
|
1547
|
-
) -> dict[str, Any]:
|
1548
|
-
to_object: dict[str, Any] = {}
|
1549
|
-
if getv(from_object, ['speaker_voice_configs']) is not None:
|
1550
|
-
setv(
|
1551
|
-
to_object,
|
1552
|
-
['speakerVoiceConfigs'],
|
1553
|
-
[
|
1554
|
-
_SpeakerVoiceConfig_to_mldev(item, to_object)
|
1555
|
-
for item in getv(from_object, ['speaker_voice_configs'])
|
1556
|
-
],
|
1557
|
-
)
|
1558
|
-
|
1559
|
-
return to_object
|
1560
|
-
|
1561
|
-
|
1562
|
-
def _Part_from_mldev(
|
1563
|
-
from_object: Union[dict[str, Any], object],
|
1564
|
-
parent_object: Optional[dict[str, Any]] = None,
|
1565
|
-
) -> dict[str, Any]:
|
1566
|
-
to_object: dict[str, Any] = {}
|
1567
|
-
if getv(from_object, ['videoMetadata']) is not None:
|
1568
|
-
setv(
|
1569
|
-
to_object,
|
1570
|
-
['video_metadata'],
|
1571
|
-
_VideoMetadata_from_mldev(
|
1572
|
-
getv(from_object, ['videoMetadata']), to_object
|
1573
|
-
),
|
1574
|
-
)
|
1575
|
-
|
1576
|
-
if getv(from_object, ['thought']) is not None:
|
1577
|
-
setv(to_object, ['thought'], getv(from_object, ['thought']))
|
1578
|
-
|
1579
|
-
if getv(from_object, ['inlineData']) is not None:
|
1580
|
-
setv(
|
1581
|
-
to_object,
|
1582
|
-
['inline_data'],
|
1583
|
-
_Blob_from_mldev(getv(from_object, ['inlineData']), to_object),
|
1584
|
-
)
|
1585
|
-
|
1586
|
-
if getv(from_object, ['fileData']) is not None:
|
1587
|
-
setv(
|
1588
|
-
to_object,
|
1589
|
-
['file_data'],
|
1590
|
-
_FileData_from_mldev(getv(from_object, ['fileData']), to_object),
|
1591
|
-
)
|
1592
|
-
|
1593
|
-
if getv(from_object, ['thoughtSignature']) is not None:
|
1594
|
-
setv(
|
1595
|
-
to_object,
|
1596
|
-
['thought_signature'],
|
1597
|
-
getv(from_object, ['thoughtSignature']),
|
1598
|
-
)
|
1599
|
-
|
1600
|
-
if getv(from_object, ['functionCall']) is not None:
|
1601
|
-
setv(
|
1602
|
-
to_object,
|
1603
|
-
['function_call'],
|
1604
|
-
_FunctionCall_from_mldev(
|
1605
|
-
getv(from_object, ['functionCall']), to_object
|
1606
|
-
),
|
1607
|
-
)
|
1608
|
-
|
1609
|
-
if getv(from_object, ['codeExecutionResult']) is not None:
|
1610
|
-
setv(
|
1611
|
-
to_object,
|
1612
|
-
['code_execution_result'],
|
1613
|
-
getv(from_object, ['codeExecutionResult']),
|
1614
|
-
)
|
1615
|
-
|
1616
|
-
if getv(from_object, ['executableCode']) is not None:
|
1617
|
-
setv(to_object, ['executable_code'], getv(from_object, ['executableCode']))
|
1618
|
-
|
1619
|
-
if getv(from_object, ['functionResponse']) is not None:
|
1620
|
-
setv(
|
1621
|
-
to_object,
|
1622
|
-
['function_response'],
|
1623
|
-
getv(from_object, ['functionResponse']),
|
1624
|
-
)
|
1625
|
-
|
1626
|
-
if getv(from_object, ['text']) is not None:
|
1627
|
-
setv(to_object, ['text'], getv(from_object, ['text']))
|
1628
|
-
|
1629
|
-
return to_object
|
1630
|
-
|
1631
|
-
|
1632
|
-
def _Part_to_mldev(
|
1633
|
-
from_object: Union[dict[str, Any], object],
|
1634
|
-
parent_object: Optional[dict[str, Any]] = None,
|
1635
|
-
) -> dict[str, Any]:
|
1636
|
-
to_object: dict[str, Any] = {}
|
1637
|
-
if getv(from_object, ['video_metadata']) is not None:
|
1638
|
-
setv(
|
1639
|
-
to_object,
|
1640
|
-
['videoMetadata'],
|
1641
|
-
_VideoMetadata_to_mldev(
|
1642
|
-
getv(from_object, ['video_metadata']), to_object
|
1643
|
-
),
|
1644
|
-
)
|
1645
|
-
|
1646
|
-
if getv(from_object, ['thought']) is not None:
|
1647
|
-
setv(to_object, ['thought'], getv(from_object, ['thought']))
|
1648
|
-
|
1649
|
-
if getv(from_object, ['inline_data']) is not None:
|
1650
|
-
setv(
|
1651
|
-
to_object,
|
1652
|
-
['inlineData'],
|
1653
|
-
_Blob_to_mldev(getv(from_object, ['inline_data']), to_object),
|
1654
|
-
)
|
1655
|
-
|
1656
|
-
if getv(from_object, ['file_data']) is not None:
|
1657
|
-
setv(
|
1658
|
-
to_object,
|
1659
|
-
['fileData'],
|
1660
|
-
_FileData_to_mldev(getv(from_object, ['file_data']), to_object),
|
1661
|
-
)
|
1662
|
-
|
1663
|
-
if getv(from_object, ['thought_signature']) is not None:
|
1664
|
-
setv(
|
1665
|
-
to_object,
|
1666
|
-
['thoughtSignature'],
|
1667
|
-
getv(from_object, ['thought_signature']),
|
1668
|
-
)
|
1669
|
-
|
1670
|
-
if getv(from_object, ['function_call']) is not None:
|
1671
|
-
setv(
|
1672
|
-
to_object,
|
1673
|
-
['functionCall'],
|
1674
|
-
_FunctionCall_to_mldev(getv(from_object, ['function_call']), to_object),
|
1675
|
-
)
|
1676
|
-
|
1677
|
-
if getv(from_object, ['code_execution_result']) is not None:
|
1678
|
-
setv(
|
1679
|
-
to_object,
|
1680
|
-
['codeExecutionResult'],
|
1681
|
-
getv(from_object, ['code_execution_result']),
|
1682
|
-
)
|
1683
|
-
|
1684
|
-
if getv(from_object, ['executable_code']) is not None:
|
1685
|
-
setv(to_object, ['executableCode'], getv(from_object, ['executable_code']))
|
1686
|
-
|
1687
|
-
if getv(from_object, ['function_response']) is not None:
|
1688
|
-
setv(
|
1689
|
-
to_object,
|
1690
|
-
['functionResponse'],
|
1691
|
-
getv(from_object, ['function_response']),
|
1692
|
-
)
|
1693
|
-
|
1694
|
-
if getv(from_object, ['text']) is not None:
|
1695
|
-
setv(to_object, ['text'], getv(from_object, ['text']))
|
1696
|
-
|
1697
|
-
return to_object
|
1698
|
-
|
1699
|
-
|
1700
|
-
def _PrebuiltVoiceConfig_to_mldev(
|
1701
|
-
from_object: Union[dict[str, Any], object],
|
1702
|
-
parent_object: Optional[dict[str, Any]] = None,
|
1703
|
-
) -> dict[str, Any]:
|
1704
|
-
to_object: dict[str, Any] = {}
|
1705
|
-
if getv(from_object, ['voice_name']) is not None:
|
1706
|
-
setv(to_object, ['voiceName'], getv(from_object, ['voice_name']))
|
1707
|
-
|
1708
|
-
return to_object
|
1709
|
-
|
1710
|
-
|
1711
|
-
def _RetrievalConfig_to_mldev(
|
1712
|
-
from_object: Union[dict[str, Any], object],
|
1713
|
-
parent_object: Optional[dict[str, Any]] = None,
|
1714
|
-
) -> dict[str, Any]:
|
1715
|
-
to_object: dict[str, Any] = {}
|
1716
|
-
if getv(from_object, ['lat_lng']) is not None:
|
1717
|
-
setv(
|
1718
|
-
to_object,
|
1719
|
-
['latLng'],
|
1720
|
-
_LatLng_to_mldev(getv(from_object, ['lat_lng']), to_object),
|
1721
|
-
)
|
1722
|
-
|
1723
|
-
if getv(from_object, ['language_code']) is not None:
|
1724
|
-
setv(to_object, ['languageCode'], getv(from_object, ['language_code']))
|
1725
|
-
|
1726
|
-
return to_object
|
1727
|
-
|
1728
|
-
|
1729
|
-
def _SafetySetting_to_mldev(
|
1730
|
-
from_object: Union[dict[str, Any], object],
|
1731
|
-
parent_object: Optional[dict[str, Any]] = None,
|
1732
|
-
) -> dict[str, Any]:
|
1733
|
-
to_object: dict[str, Any] = {}
|
1734
|
-
if getv(from_object, ['method']) is not None:
|
1735
|
-
raise ValueError('method parameter is not supported in Gemini API.')
|
1736
|
-
|
1737
|
-
if getv(from_object, ['category']) is not None:
|
1738
|
-
setv(to_object, ['category'], getv(from_object, ['category']))
|
1739
|
-
|
1740
|
-
if getv(from_object, ['threshold']) is not None:
|
1741
|
-
setv(to_object, ['threshold'], getv(from_object, ['threshold']))
|
1742
|
-
|
1743
|
-
return to_object
|
1744
|
-
|
1745
|
-
|
1746
|
-
def _Schema_to_mldev(
|
1747
|
-
from_object: Union[dict[str, Any], object],
|
1748
|
-
parent_object: Optional[dict[str, Any]] = None,
|
1749
|
-
) -> dict[str, Any]:
|
1750
|
-
to_object: dict[str, Any] = {}
|
1751
|
-
if getv(from_object, ['additional_properties']) is not None:
|
1752
|
-
raise ValueError(
|
1753
|
-
'additional_properties parameter is not supported in Gemini API.'
|
1754
|
-
)
|
1755
|
-
|
1756
|
-
if getv(from_object, ['defs']) is not None:
|
1757
|
-
raise ValueError('defs parameter is not supported in Gemini API.')
|
1758
|
-
|
1759
|
-
if getv(from_object, ['ref']) is not None:
|
1760
|
-
raise ValueError('ref parameter is not supported in Gemini API.')
|
1761
|
-
|
1762
|
-
if getv(from_object, ['any_of']) is not None:
|
1763
|
-
setv(to_object, ['anyOf'], getv(from_object, ['any_of']))
|
1764
|
-
|
1765
|
-
if getv(from_object, ['default']) is not None:
|
1766
|
-
setv(to_object, ['default'], getv(from_object, ['default']))
|
1767
|
-
|
1768
|
-
if getv(from_object, ['description']) is not None:
|
1769
|
-
setv(to_object, ['description'], getv(from_object, ['description']))
|
1770
|
-
|
1771
|
-
if getv(from_object, ['enum']) is not None:
|
1772
|
-
setv(to_object, ['enum'], getv(from_object, ['enum']))
|
1773
|
-
|
1774
|
-
if getv(from_object, ['example']) is not None:
|
1775
|
-
setv(to_object, ['example'], getv(from_object, ['example']))
|
1776
|
-
|
1777
|
-
if getv(from_object, ['format']) is not None:
|
1778
|
-
setv(to_object, ['format'], getv(from_object, ['format']))
|
1779
|
-
|
1780
|
-
if getv(from_object, ['items']) is not None:
|
1781
|
-
setv(to_object, ['items'], getv(from_object, ['items']))
|
1782
|
-
|
1783
|
-
if getv(from_object, ['max_items']) is not None:
|
1784
|
-
setv(to_object, ['maxItems'], getv(from_object, ['max_items']))
|
1785
|
-
|
1786
|
-
if getv(from_object, ['max_length']) is not None:
|
1787
|
-
setv(to_object, ['maxLength'], getv(from_object, ['max_length']))
|
1788
|
-
|
1789
|
-
if getv(from_object, ['max_properties']) is not None:
|
1790
|
-
setv(to_object, ['maxProperties'], getv(from_object, ['max_properties']))
|
1791
|
-
|
1792
|
-
if getv(from_object, ['maximum']) is not None:
|
1793
|
-
setv(to_object, ['maximum'], getv(from_object, ['maximum']))
|
1794
|
-
|
1795
|
-
if getv(from_object, ['min_items']) is not None:
|
1796
|
-
setv(to_object, ['minItems'], getv(from_object, ['min_items']))
|
1797
|
-
|
1798
|
-
if getv(from_object, ['min_length']) is not None:
|
1799
|
-
setv(to_object, ['minLength'], getv(from_object, ['min_length']))
|
1800
|
-
|
1801
|
-
if getv(from_object, ['min_properties']) is not None:
|
1802
|
-
setv(to_object, ['minProperties'], getv(from_object, ['min_properties']))
|
1803
|
-
|
1804
|
-
if getv(from_object, ['minimum']) is not None:
|
1805
|
-
setv(to_object, ['minimum'], getv(from_object, ['minimum']))
|
1806
|
-
|
1807
|
-
if getv(from_object, ['nullable']) is not None:
|
1808
|
-
setv(to_object, ['nullable'], getv(from_object, ['nullable']))
|
1809
|
-
|
1810
|
-
if getv(from_object, ['pattern']) is not None:
|
1811
|
-
setv(to_object, ['pattern'], getv(from_object, ['pattern']))
|
1812
|
-
|
1813
|
-
if getv(from_object, ['properties']) is not None:
|
1814
|
-
setv(to_object, ['properties'], getv(from_object, ['properties']))
|
1815
|
-
|
1816
|
-
if getv(from_object, ['property_ordering']) is not None:
|
1817
|
-
setv(
|
1818
|
-
to_object,
|
1819
|
-
['propertyOrdering'],
|
1820
|
-
getv(from_object, ['property_ordering']),
|
1183
|
+
for item in getv(from_object, ['operations'])
|
1184
|
+
],
|
1821
1185
|
)
|
1822
1186
|
|
1823
|
-
if getv(from_object, ['required']) is not None:
|
1824
|
-
setv(to_object, ['required'], getv(from_object, ['required']))
|
1825
|
-
|
1826
|
-
if getv(from_object, ['title']) is not None:
|
1827
|
-
setv(to_object, ['title'], getv(from_object, ['title']))
|
1828
|
-
|
1829
|
-
if getv(from_object, ['type']) is not None:
|
1830
|
-
setv(to_object, ['type'], getv(from_object, ['type']))
|
1831
|
-
|
1832
1187
|
return to_object
|
1833
1188
|
|
1834
1189
|
|
1835
|
-
def
|
1190
|
+
def _ListBatchJobsResponse_from_vertex(
|
1836
1191
|
from_object: Union[dict[str, Any], object],
|
1837
1192
|
parent_object: Optional[dict[str, Any]] = None,
|
1838
1193
|
) -> dict[str, Any]:
|
1839
1194
|
to_object: dict[str, Any] = {}
|
1840
|
-
if getv(from_object, ['
|
1195
|
+
if getv(from_object, ['sdkHttpResponse']) is not None:
|
1841
1196
|
setv(
|
1842
|
-
to_object,
|
1843
|
-
['embedding'],
|
1844
|
-
_ContentEmbedding_from_mldev(
|
1845
|
-
getv(from_object, ['embedding']), to_object
|
1846
|
-
),
|
1197
|
+
to_object, ['sdk_http_response'], getv(from_object, ['sdkHttpResponse'])
|
1847
1198
|
)
|
1848
1199
|
|
1849
|
-
if getv(from_object, ['
|
1850
|
-
setv(to_object, ['
|
1200
|
+
if getv(from_object, ['nextPageToken']) is not None:
|
1201
|
+
setv(to_object, ['next_page_token'], getv(from_object, ['nextPageToken']))
|
1202
|
+
|
1203
|
+
if getv(from_object, ['batchPredictionJobs']) is not None:
|
1204
|
+
setv(
|
1205
|
+
to_object,
|
1206
|
+
['batch_jobs'],
|
1207
|
+
[
|
1208
|
+
_BatchJob_from_vertex(item, to_object)
|
1209
|
+
for item in getv(from_object, ['batchPredictionJobs'])
|
1210
|
+
],
|
1211
|
+
)
|
1851
1212
|
|
1852
1213
|
return to_object
|
1853
1214
|
|
1854
1215
|
|
1855
|
-
def
|
1216
|
+
def _Part_to_mldev(
|
1856
1217
|
from_object: Union[dict[str, Any], object],
|
1857
1218
|
parent_object: Optional[dict[str, Any]] = None,
|
1858
1219
|
) -> dict[str, Any]:
|
1859
1220
|
to_object: dict[str, Any] = {}
|
1860
|
-
if getv(from_object, ['
|
1861
|
-
setv(to_object, ['
|
1221
|
+
if getv(from_object, ['video_metadata']) is not None:
|
1222
|
+
setv(to_object, ['videoMetadata'], getv(from_object, ['video_metadata']))
|
1223
|
+
|
1224
|
+
if getv(from_object, ['thought']) is not None:
|
1225
|
+
setv(to_object, ['thought'], getv(from_object, ['thought']))
|
1862
1226
|
|
1863
|
-
if getv(from_object, ['
|
1227
|
+
if getv(from_object, ['inline_data']) is not None:
|
1864
1228
|
setv(
|
1865
1229
|
to_object,
|
1866
|
-
['
|
1867
|
-
|
1230
|
+
['inlineData'],
|
1231
|
+
_Blob_to_mldev(getv(from_object, ['inline_data']), to_object),
|
1868
1232
|
)
|
1869
1233
|
|
1870
|
-
|
1871
|
-
|
1872
|
-
|
1873
|
-
def _SpeechConfig_to_mldev(
|
1874
|
-
from_object: Union[dict[str, Any], object],
|
1875
|
-
parent_object: Optional[dict[str, Any]] = None,
|
1876
|
-
) -> dict[str, Any]:
|
1877
|
-
to_object: dict[str, Any] = {}
|
1878
|
-
if getv(from_object, ['voice_config']) is not None:
|
1234
|
+
if getv(from_object, ['file_data']) is not None:
|
1879
1235
|
setv(
|
1880
1236
|
to_object,
|
1881
|
-
['
|
1882
|
-
|
1237
|
+
['fileData'],
|
1238
|
+
_FileData_to_mldev(getv(from_object, ['file_data']), to_object),
|
1883
1239
|
)
|
1884
1240
|
|
1885
|
-
if getv(from_object, ['
|
1241
|
+
if getv(from_object, ['thought_signature']) is not None:
|
1886
1242
|
setv(
|
1887
1243
|
to_object,
|
1888
|
-
['
|
1889
|
-
|
1890
|
-
getv(from_object, ['multi_speaker_voice_config']), to_object
|
1891
|
-
),
|
1244
|
+
['thoughtSignature'],
|
1245
|
+
getv(from_object, ['thought_signature']),
|
1892
1246
|
)
|
1893
1247
|
|
1894
|
-
if getv(from_object, ['
|
1895
|
-
setv(to_object, ['
|
1248
|
+
if getv(from_object, ['function_call']) is not None:
|
1249
|
+
setv(to_object, ['functionCall'], getv(from_object, ['function_call']))
|
1896
1250
|
|
1897
|
-
|
1251
|
+
if getv(from_object, ['code_execution_result']) is not None:
|
1252
|
+
setv(
|
1253
|
+
to_object,
|
1254
|
+
['codeExecutionResult'],
|
1255
|
+
getv(from_object, ['code_execution_result']),
|
1256
|
+
)
|
1898
1257
|
|
1258
|
+
if getv(from_object, ['executable_code']) is not None:
|
1259
|
+
setv(to_object, ['executableCode'], getv(from_object, ['executable_code']))
|
1899
1260
|
|
1900
|
-
|
1901
|
-
from_object: Union[dict[str, Any], object],
|
1902
|
-
parent_object: Optional[dict[str, Any]] = None,
|
1903
|
-
) -> dict[str, Any]:
|
1904
|
-
to_object: dict[str, Any] = {}
|
1905
|
-
if getv(from_object, ['include_thoughts']) is not None:
|
1261
|
+
if getv(from_object, ['function_response']) is not None:
|
1906
1262
|
setv(
|
1907
|
-
to_object,
|
1263
|
+
to_object,
|
1264
|
+
['functionResponse'],
|
1265
|
+
getv(from_object, ['function_response']),
|
1908
1266
|
)
|
1909
1267
|
|
1910
|
-
if getv(from_object, ['
|
1911
|
-
setv(to_object, ['
|
1268
|
+
if getv(from_object, ['text']) is not None:
|
1269
|
+
setv(to_object, ['text'], getv(from_object, ['text']))
|
1912
1270
|
|
1913
1271
|
return to_object
|
1914
1272
|
|
1915
1273
|
|
1916
|
-
def
|
1274
|
+
def _SafetySetting_to_mldev(
|
1917
1275
|
from_object: Union[dict[str, Any], object],
|
1918
1276
|
parent_object: Optional[dict[str, Any]] = None,
|
1919
1277
|
) -> dict[str, Any]:
|
1920
1278
|
to_object: dict[str, Any] = {}
|
1921
|
-
if getv(from_object, ['
|
1922
|
-
|
1923
|
-
to_object,
|
1924
|
-
['functionCallingConfig'],
|
1925
|
-
_FunctionCallingConfig_to_mldev(
|
1926
|
-
getv(from_object, ['function_calling_config']), to_object
|
1927
|
-
),
|
1928
|
-
)
|
1279
|
+
if getv(from_object, ['method']) is not None:
|
1280
|
+
raise ValueError('method parameter is not supported in Gemini API.')
|
1929
1281
|
|
1930
|
-
if getv(from_object, ['
|
1931
|
-
setv(
|
1932
|
-
|
1933
|
-
|
1934
|
-
|
1935
|
-
getv(from_object, ['retrieval_config']), to_object
|
1936
|
-
),
|
1937
|
-
)
|
1282
|
+
if getv(from_object, ['category']) is not None:
|
1283
|
+
setv(to_object, ['category'], getv(from_object, ['category']))
|
1284
|
+
|
1285
|
+
if getv(from_object, ['threshold']) is not None:
|
1286
|
+
setv(to_object, ['threshold'], getv(from_object, ['threshold']))
|
1938
1287
|
|
1939
1288
|
return to_object
|
1940
1289
|
|
@@ -1948,10 +1297,7 @@ def _Tool_to_mldev(
|
|
1948
1297
|
setv(
|
1949
1298
|
to_object,
|
1950
1299
|
['functionDeclarations'],
|
1951
|
-
[
|
1952
|
-
_FunctionDeclaration_to_mldev(item, to_object)
|
1953
|
-
for item in getv(from_object, ['function_declarations'])
|
1954
|
-
],
|
1300
|
+
[item for item in getv(from_object, ['function_declarations'])],
|
1955
1301
|
)
|
1956
1302
|
|
1957
1303
|
if getv(from_object, ['retrieval']) is not None:
|
@@ -1968,9 +1314,7 @@ def _Tool_to_mldev(
|
|
1968
1314
|
setv(
|
1969
1315
|
to_object,
|
1970
1316
|
['googleSearchRetrieval'],
|
1971
|
-
|
1972
|
-
getv(from_object, ['google_search_retrieval']), to_object
|
1973
|
-
),
|
1317
|
+
getv(from_object, ['google_search_retrieval']),
|
1974
1318
|
)
|
1975
1319
|
|
1976
1320
|
if getv(from_object, ['enterprise_web_search']) is not None:
|
@@ -1982,18 +1326,10 @@ def _Tool_to_mldev(
|
|
1982
1326
|
raise ValueError('google_maps parameter is not supported in Gemini API.')
|
1983
1327
|
|
1984
1328
|
if getv(from_object, ['url_context']) is not None:
|
1985
|
-
setv(
|
1986
|
-
to_object,
|
1987
|
-
['urlContext'],
|
1988
|
-
_UrlContext_to_mldev(getv(from_object, ['url_context']), to_object),
|
1989
|
-
)
|
1329
|
+
setv(to_object, ['urlContext'], getv(from_object, ['url_context']))
|
1990
1330
|
|
1991
1331
|
if getv(from_object, ['computer_use']) is not None:
|
1992
|
-
setv(
|
1993
|
-
to_object,
|
1994
|
-
['computerUse'],
|
1995
|
-
_ComputerUse_to_mldev(getv(from_object, ['computer_use']), to_object),
|
1996
|
-
)
|
1332
|
+
setv(to_object, ['computerUse'], getv(from_object, ['computer_use']))
|
1997
1333
|
|
1998
1334
|
if getv(from_object, ['code_execution']) is not None:
|
1999
1335
|
setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
|
@@ -2001,102 +1337,6 @@ def _Tool_to_mldev(
|
|
2001
1337
|
return to_object
|
2002
1338
|
|
2003
1339
|
|
2004
|
-
def _UrlContextMetadata_from_mldev(
|
2005
|
-
from_object: Union[dict[str, Any], object],
|
2006
|
-
parent_object: Optional[dict[str, Any]] = None,
|
2007
|
-
) -> dict[str, Any]:
|
2008
|
-
to_object: dict[str, Any] = {}
|
2009
|
-
if getv(from_object, ['urlMetadata']) is not None:
|
2010
|
-
setv(
|
2011
|
-
to_object,
|
2012
|
-
['url_metadata'],
|
2013
|
-
[
|
2014
|
-
_UrlMetadata_from_mldev(item, to_object)
|
2015
|
-
for item in getv(from_object, ['urlMetadata'])
|
2016
|
-
],
|
2017
|
-
)
|
2018
|
-
|
2019
|
-
return to_object
|
2020
|
-
|
2021
|
-
|
2022
|
-
def _UrlContext_to_mldev(
|
2023
|
-
from_object: Union[dict[str, Any], object],
|
2024
|
-
parent_object: Optional[dict[str, Any]] = None,
|
2025
|
-
) -> dict[str, Any]:
|
2026
|
-
to_object: dict[str, Any] = {}
|
2027
|
-
|
2028
|
-
return to_object
|
2029
|
-
|
2030
|
-
|
2031
|
-
def _UrlMetadata_from_mldev(
|
2032
|
-
from_object: Union[dict[str, Any], object],
|
2033
|
-
parent_object: Optional[dict[str, Any]] = None,
|
2034
|
-
) -> dict[str, Any]:
|
2035
|
-
to_object: dict[str, Any] = {}
|
2036
|
-
if getv(from_object, ['retrievedUrl']) is not None:
|
2037
|
-
setv(to_object, ['retrieved_url'], getv(from_object, ['retrievedUrl']))
|
2038
|
-
|
2039
|
-
if getv(from_object, ['urlRetrievalStatus']) is not None:
|
2040
|
-
setv(
|
2041
|
-
to_object,
|
2042
|
-
['url_retrieval_status'],
|
2043
|
-
getv(from_object, ['urlRetrievalStatus']),
|
2044
|
-
)
|
2045
|
-
|
2046
|
-
return to_object
|
2047
|
-
|
2048
|
-
|
2049
|
-
def _VideoMetadata_from_mldev(
|
2050
|
-
from_object: Union[dict[str, Any], object],
|
2051
|
-
parent_object: Optional[dict[str, Any]] = None,
|
2052
|
-
) -> dict[str, Any]:
|
2053
|
-
to_object: dict[str, Any] = {}
|
2054
|
-
if getv(from_object, ['fps']) is not None:
|
2055
|
-
setv(to_object, ['fps'], getv(from_object, ['fps']))
|
2056
|
-
|
2057
|
-
if getv(from_object, ['endOffset']) is not None:
|
2058
|
-
setv(to_object, ['end_offset'], getv(from_object, ['endOffset']))
|
2059
|
-
|
2060
|
-
if getv(from_object, ['startOffset']) is not None:
|
2061
|
-
setv(to_object, ['start_offset'], getv(from_object, ['startOffset']))
|
2062
|
-
|
2063
|
-
return to_object
|
2064
|
-
|
2065
|
-
|
2066
|
-
def _VideoMetadata_to_mldev(
|
2067
|
-
from_object: Union[dict[str, Any], object],
|
2068
|
-
parent_object: Optional[dict[str, Any]] = None,
|
2069
|
-
) -> dict[str, Any]:
|
2070
|
-
to_object: dict[str, Any] = {}
|
2071
|
-
if getv(from_object, ['fps']) is not None:
|
2072
|
-
setv(to_object, ['fps'], getv(from_object, ['fps']))
|
2073
|
-
|
2074
|
-
if getv(from_object, ['end_offset']) is not None:
|
2075
|
-
setv(to_object, ['endOffset'], getv(from_object, ['end_offset']))
|
2076
|
-
|
2077
|
-
if getv(from_object, ['start_offset']) is not None:
|
2078
|
-
setv(to_object, ['startOffset'], getv(from_object, ['start_offset']))
|
2079
|
-
|
2080
|
-
return to_object
|
2081
|
-
|
2082
|
-
|
2083
|
-
def _VoiceConfig_to_mldev(
|
2084
|
-
from_object: Union[dict[str, Any], object],
|
2085
|
-
parent_object: Optional[dict[str, Any]] = None,
|
2086
|
-
) -> dict[str, Any]:
|
2087
|
-
to_object: dict[str, Any] = {}
|
2088
|
-
if getv(from_object, ['prebuilt_voice_config']) is not None:
|
2089
|
-
setv(
|
2090
|
-
to_object,
|
2091
|
-
['prebuiltVoiceConfig'],
|
2092
|
-
_PrebuiltVoiceConfig_to_mldev(
|
2093
|
-
getv(from_object, ['prebuilt_voice_config']), to_object
|
2094
|
-
),
|
2095
|
-
)
|
2096
|
-
|
2097
|
-
return to_object
|
2098
|
-
|
2099
|
-
|
2100
1340
|
class Batches(_api_module.BaseModule):
|
2101
1341
|
|
2102
1342
|
def _create(
|
@@ -2152,12 +1392,12 @@ class Batches(_api_module.BaseModule):
|
|
2152
1392
|
'post', path, request_dict, http_options
|
2153
1393
|
)
|
2154
1394
|
|
2155
|
-
response_dict =
|
1395
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
2156
1396
|
|
2157
1397
|
if self._api_client.vertexai:
|
2158
1398
|
response_dict = _BatchJob_from_vertex(response_dict)
|
2159
1399
|
|
2160
|
-
|
1400
|
+
if not self._api_client.vertexai:
|
2161
1401
|
response_dict = _BatchJob_from_mldev(response_dict)
|
2162
1402
|
|
2163
1403
|
return_value = types.BatchJob._from_response(
|
@@ -2215,7 +1455,7 @@ class Batches(_api_module.BaseModule):
|
|
2215
1455
|
'post', path, request_dict, http_options
|
2216
1456
|
)
|
2217
1457
|
|
2218
|
-
response_dict =
|
1458
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
2219
1459
|
|
2220
1460
|
if not self._api_client.vertexai:
|
2221
1461
|
response_dict = _BatchJob_from_mldev(response_dict)
|
@@ -2292,12 +1532,12 @@ class Batches(_api_module.BaseModule):
|
|
2292
1532
|
|
2293
1533
|
response = self._api_client.request('get', path, request_dict, http_options)
|
2294
1534
|
|
2295
|
-
response_dict =
|
1535
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
2296
1536
|
|
2297
1537
|
if self._api_client.vertexai:
|
2298
1538
|
response_dict = _BatchJob_from_vertex(response_dict)
|
2299
1539
|
|
2300
|
-
|
1540
|
+
if not self._api_client.vertexai:
|
2301
1541
|
response_dict = _BatchJob_from_mldev(response_dict)
|
2302
1542
|
|
2303
1543
|
return_value = types.BatchJob._from_response(
|
@@ -2416,12 +1656,12 @@ class Batches(_api_module.BaseModule):
|
|
2416
1656
|
|
2417
1657
|
response = self._api_client.request('get', path, request_dict, http_options)
|
2418
1658
|
|
2419
|
-
response_dict =
|
1659
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
2420
1660
|
|
2421
1661
|
if self._api_client.vertexai:
|
2422
1662
|
response_dict = _ListBatchJobsResponse_from_vertex(response_dict)
|
2423
1663
|
|
2424
|
-
|
1664
|
+
if not self._api_client.vertexai:
|
2425
1665
|
response_dict = _ListBatchJobsResponse_from_mldev(response_dict)
|
2426
1666
|
|
2427
1667
|
return_value = types.ListBatchJobsResponse._from_response(
|
@@ -2501,12 +1741,12 @@ class Batches(_api_module.BaseModule):
|
|
2501
1741
|
'delete', path, request_dict, http_options
|
2502
1742
|
)
|
2503
1743
|
|
2504
|
-
response_dict =
|
1744
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
2505
1745
|
|
2506
1746
|
if self._api_client.vertexai:
|
2507
1747
|
response_dict = _DeleteResourceJob_from_vertex(response_dict)
|
2508
1748
|
|
2509
|
-
|
1749
|
+
if not self._api_client.vertexai:
|
2510
1750
|
response_dict = _DeleteResourceJob_from_mldev(response_dict)
|
2511
1751
|
|
2512
1752
|
return_value = types.DeleteResourceJob._from_response(
|
@@ -2557,37 +1797,12 @@ class Batches(_api_module.BaseModule):
|
|
2557
1797
|
config=config,
|
2558
1798
|
)
|
2559
1799
|
|
2560
|
-
http_options: Optional[types.HttpOptions] = None
|
2561
|
-
if (
|
2562
|
-
parameter_model.config is not None
|
2563
|
-
and parameter_model.config.http_options is not None
|
2564
|
-
):
|
2565
|
-
http_options = parameter_model.config.http_options
|
2566
|
-
|
2567
1800
|
if self._api_client.vertexai:
|
2568
1801
|
config = _extra_utils.format_destination(src, parameter_model.config)
|
2569
1802
|
return self._create(model=model, src=src, config=config)
|
2570
|
-
|
1803
|
+
else:
|
2571
1804
|
return self._create(model=model, src=src, config=config)
|
2572
1805
|
|
2573
|
-
path, request_dict = _create_inlined_generate_content_request_dict(
|
2574
|
-
self._api_client, parameter_model
|
2575
|
-
)
|
2576
|
-
|
2577
|
-
response = self._api_client.request(
|
2578
|
-
'post', path, request_dict, http_options
|
2579
|
-
)
|
2580
|
-
|
2581
|
-
response_dict = '' if not response.body else json.loads(response.body)
|
2582
|
-
response_dict = _BatchJob_from_mldev(response_dict)
|
2583
|
-
|
2584
|
-
return_value = types.BatchJob._from_response(
|
2585
|
-
response=response_dict, kwargs=parameter_model.model_dump()
|
2586
|
-
)
|
2587
|
-
|
2588
|
-
self._api_client._verify_response(return_value)
|
2589
|
-
return return_value
|
2590
|
-
|
2591
1806
|
def create_embeddings(
|
2592
1807
|
self,
|
2593
1808
|
*,
|
@@ -2633,36 +1848,11 @@ class Batches(_api_module.BaseModule):
|
|
2633
1848
|
config=config,
|
2634
1849
|
)
|
2635
1850
|
|
2636
|
-
http_options: Optional[types.HttpOptions] = None
|
2637
|
-
if (
|
2638
|
-
parameter_model.config is not None
|
2639
|
-
and parameter_model.config.http_options is not None
|
2640
|
-
):
|
2641
|
-
http_options = parameter_model.config.http_options
|
2642
|
-
|
2643
1851
|
if self._api_client.vertexai:
|
2644
1852
|
raise ValueError('Vertex AI does not support batches.create_embeddings.')
|
2645
|
-
|
1853
|
+
else:
|
2646
1854
|
return self._create_embeddings(model=model, src=src, config=config)
|
2647
1855
|
|
2648
|
-
path, request_dict = _create_inlined_embedding_request_dict(
|
2649
|
-
self._api_client, parameter_model
|
2650
|
-
)
|
2651
|
-
|
2652
|
-
response = self._api_client.request(
|
2653
|
-
'post', path, request_dict, http_options
|
2654
|
-
)
|
2655
|
-
|
2656
|
-
response_dict = '' if not response.body else json.loads(response.body)
|
2657
|
-
response_dict = _BatchJob_from_mldev(response_dict)
|
2658
|
-
|
2659
|
-
return_value = types.BatchJob._from_response(
|
2660
|
-
response=response_dict, kwargs=parameter_model.model_dump()
|
2661
|
-
)
|
2662
|
-
|
2663
|
-
self._api_client._verify_response(return_value)
|
2664
|
-
return return_value
|
2665
|
-
|
2666
1856
|
def list(
|
2667
1857
|
self, *, config: Optional[types.ListBatchJobsConfigOrDict] = None
|
2668
1858
|
) -> Pager[types.BatchJob]:
|
@@ -2748,12 +1938,12 @@ class AsyncBatches(_api_module.BaseModule):
|
|
2748
1938
|
'post', path, request_dict, http_options
|
2749
1939
|
)
|
2750
1940
|
|
2751
|
-
response_dict =
|
1941
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
2752
1942
|
|
2753
1943
|
if self._api_client.vertexai:
|
2754
1944
|
response_dict = _BatchJob_from_vertex(response_dict)
|
2755
1945
|
|
2756
|
-
|
1946
|
+
if not self._api_client.vertexai:
|
2757
1947
|
response_dict = _BatchJob_from_mldev(response_dict)
|
2758
1948
|
|
2759
1949
|
return_value = types.BatchJob._from_response(
|
@@ -2811,7 +2001,7 @@ class AsyncBatches(_api_module.BaseModule):
|
|
2811
2001
|
'post', path, request_dict, http_options
|
2812
2002
|
)
|
2813
2003
|
|
2814
|
-
response_dict =
|
2004
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
2815
2005
|
|
2816
2006
|
if not self._api_client.vertexai:
|
2817
2007
|
response_dict = _BatchJob_from_mldev(response_dict)
|
@@ -2890,12 +2080,12 @@ class AsyncBatches(_api_module.BaseModule):
|
|
2890
2080
|
'get', path, request_dict, http_options
|
2891
2081
|
)
|
2892
2082
|
|
2893
|
-
response_dict =
|
2083
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
2894
2084
|
|
2895
2085
|
if self._api_client.vertexai:
|
2896
2086
|
response_dict = _BatchJob_from_vertex(response_dict)
|
2897
2087
|
|
2898
|
-
|
2088
|
+
if not self._api_client.vertexai:
|
2899
2089
|
response_dict = _BatchJob_from_mldev(response_dict)
|
2900
2090
|
|
2901
2091
|
return_value = types.BatchJob._from_response(
|
@@ -3016,12 +2206,12 @@ class AsyncBatches(_api_module.BaseModule):
|
|
3016
2206
|
'get', path, request_dict, http_options
|
3017
2207
|
)
|
3018
2208
|
|
3019
|
-
response_dict =
|
2209
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
3020
2210
|
|
3021
2211
|
if self._api_client.vertexai:
|
3022
2212
|
response_dict = _ListBatchJobsResponse_from_vertex(response_dict)
|
3023
2213
|
|
3024
|
-
|
2214
|
+
if not self._api_client.vertexai:
|
3025
2215
|
response_dict = _ListBatchJobsResponse_from_mldev(response_dict)
|
3026
2216
|
|
3027
2217
|
return_value = types.ListBatchJobsResponse._from_response(
|
@@ -3101,12 +2291,12 @@ class AsyncBatches(_api_module.BaseModule):
|
|
3101
2291
|
'delete', path, request_dict, http_options
|
3102
2292
|
)
|
3103
2293
|
|
3104
|
-
response_dict =
|
2294
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
3105
2295
|
|
3106
2296
|
if self._api_client.vertexai:
|
3107
2297
|
response_dict = _DeleteResourceJob_from_vertex(response_dict)
|
3108
2298
|
|
3109
|
-
|
2299
|
+
if not self._api_client.vertexai:
|
3110
2300
|
response_dict = _DeleteResourceJob_from_mldev(response_dict)
|
3111
2301
|
|
3112
2302
|
return_value = types.DeleteResourceJob._from_response(
|
@@ -3156,37 +2346,12 @@ class AsyncBatches(_api_module.BaseModule):
|
|
3156
2346
|
config=config,
|
3157
2347
|
)
|
3158
2348
|
|
3159
|
-
http_options: Optional[types.HttpOptions] = None
|
3160
|
-
if (
|
3161
|
-
parameter_model.config is not None
|
3162
|
-
and parameter_model.config.http_options is not None
|
3163
|
-
):
|
3164
|
-
http_options = parameter_model.config.http_options
|
3165
|
-
|
3166
2349
|
if self._api_client.vertexai:
|
3167
2350
|
config = _extra_utils.format_destination(src, parameter_model.config)
|
3168
2351
|
return await self._create(model=model, src=src, config=config)
|
3169
|
-
|
2352
|
+
else:
|
3170
2353
|
return await self._create(model=model, src=src, config=config)
|
3171
2354
|
|
3172
|
-
path, request_dict = _create_inlined_generate_content_request_dict(
|
3173
|
-
self._api_client, parameter_model
|
3174
|
-
)
|
3175
|
-
|
3176
|
-
response = await self._api_client.async_request(
|
3177
|
-
'post', path, request_dict, http_options
|
3178
|
-
)
|
3179
|
-
|
3180
|
-
response_dict = '' if not response.body else json.loads(response.body)
|
3181
|
-
response_dict = _BatchJob_from_mldev(response_dict)
|
3182
|
-
|
3183
|
-
return_value = types.BatchJob._from_response(
|
3184
|
-
response=response_dict, kwargs=parameter_model.model_dump()
|
3185
|
-
)
|
3186
|
-
|
3187
|
-
self._api_client._verify_response(return_value)
|
3188
|
-
return return_value
|
3189
|
-
|
3190
2355
|
async def create_embeddings(
|
3191
2356
|
self,
|
3192
2357
|
*,
|
@@ -3241,27 +2406,9 @@ class AsyncBatches(_api_module.BaseModule):
|
|
3241
2406
|
|
3242
2407
|
if self._api_client.vertexai:
|
3243
2408
|
raise ValueError('Vertex AI does not support batches.create_embeddings.')
|
3244
|
-
|
2409
|
+
else:
|
3245
2410
|
return await self._create_embeddings(model=model, src=src, config=config)
|
3246
2411
|
|
3247
|
-
path, request_dict = _create_inlined_embedding_request_dict(
|
3248
|
-
self._api_client, parameter_model
|
3249
|
-
)
|
3250
|
-
|
3251
|
-
response = await self._api_client.async_request(
|
3252
|
-
'post', path, request_dict, http_options
|
3253
|
-
)
|
3254
|
-
|
3255
|
-
response_dict = '' if not response.body else json.loads(response.body)
|
3256
|
-
response_dict = _BatchJob_from_mldev(response_dict)
|
3257
|
-
|
3258
|
-
return_value = types.BatchJob._from_response(
|
3259
|
-
response=response_dict, kwargs=parameter_model.model_dump()
|
3260
|
-
)
|
3261
|
-
|
3262
|
-
self._api_client._verify_response(return_value)
|
3263
|
-
return return_value
|
3264
|
-
|
3265
2412
|
async def list(
|
3266
2413
|
self, *, config: Optional[types.ListBatchJobsConfigOrDict] = None
|
3267
2414
|
) -> AsyncPager[types.BatchJob]:
|
@@ -3291,100 +2438,3 @@ class AsyncBatches(_api_module.BaseModule):
|
|
3291
2438
|
await self._list(config=config),
|
3292
2439
|
config,
|
3293
2440
|
)
|
3294
|
-
|
3295
|
-
|
3296
|
-
def _create_inlined_generate_content_request_dict(
|
3297
|
-
client: BaseApiClient, parameter_model: types._CreateBatchJobParameters
|
3298
|
-
) -> tuple[str, dict[str, Any]]:
|
3299
|
-
request_url_dict: Optional[dict[str, str]]
|
3300
|
-
|
3301
|
-
request_dict: dict[str, Any] = _CreateBatchJobParameters_to_mldev(
|
3302
|
-
client, parameter_model
|
3303
|
-
)
|
3304
|
-
|
3305
|
-
request_url_dict = request_dict.get('_url')
|
3306
|
-
if request_url_dict:
|
3307
|
-
path = '{model}:batchGenerateContent'.format_map(request_url_dict)
|
3308
|
-
else:
|
3309
|
-
path = '{model}:batchGenerateContent'
|
3310
|
-
query_params = request_dict.get('_query')
|
3311
|
-
if query_params:
|
3312
|
-
path = f'{path}?{urlencode(query_params)}'
|
3313
|
-
request_dict.pop('config', None)
|
3314
|
-
|
3315
|
-
request_dict = _common.convert_to_dict(request_dict)
|
3316
|
-
request_dict = _common.encode_unserializable_types(request_dict)
|
3317
|
-
# Move system instruction to 'request':
|
3318
|
-
# {'systemInstruction': system_instruction}
|
3319
|
-
requests = []
|
3320
|
-
batch_dict = request_dict.get('batch')
|
3321
|
-
if batch_dict and isinstance(batch_dict, dict):
|
3322
|
-
input_config_dict = batch_dict.get('inputConfig')
|
3323
|
-
if input_config_dict and isinstance(input_config_dict, dict):
|
3324
|
-
requests_dict = input_config_dict.get('requests')
|
3325
|
-
if requests_dict and isinstance(requests_dict, dict):
|
3326
|
-
requests = requests_dict.get('requests')
|
3327
|
-
new_requests = []
|
3328
|
-
if requests:
|
3329
|
-
for req in requests:
|
3330
|
-
if req.get('systemInstruction'):
|
3331
|
-
value = req.pop('systemInstruction')
|
3332
|
-
req['request'].update({'systemInstruction': value})
|
3333
|
-
new_requests.append(req)
|
3334
|
-
request_dict['batch']['inputConfig']['requests'][ # type: ignore
|
3335
|
-
'requests'
|
3336
|
-
] = new_requests
|
3337
|
-
return path, request_dict
|
3338
|
-
|
3339
|
-
|
3340
|
-
def _create_inlined_embedding_request_dict(
|
3341
|
-
client: BaseApiClient,
|
3342
|
-
parameter_model: types._CreateEmbeddingsBatchJobParameters,
|
3343
|
-
) -> tuple[str, dict[str, Any]]:
|
3344
|
-
src = parameter_model.src
|
3345
|
-
if not isinstance(src, types.EmbeddingsBatchJobSource):
|
3346
|
-
raise ValueError(f'Invalid batch job source: {src}.')
|
3347
|
-
|
3348
|
-
request_url_dict: Optional[dict[str, str]]
|
3349
|
-
|
3350
|
-
request_dict: dict[str, Any] = _CreateEmbeddingsBatchJobParameters_to_mldev(
|
3351
|
-
client, parameter_model
|
3352
|
-
)
|
3353
|
-
|
3354
|
-
request_url_dict = request_dict.get('_url')
|
3355
|
-
if request_url_dict:
|
3356
|
-
path = '{model}:asyncBatchEmbedContent'.format_map(request_url_dict)
|
3357
|
-
else:
|
3358
|
-
path = '{model}:asyncBatchEmbedContent'
|
3359
|
-
query_params = request_dict.get('_query')
|
3360
|
-
if query_params:
|
3361
|
-
path = f'{path}?{urlencode(query_params)}'
|
3362
|
-
|
3363
|
-
request_dict.pop('config', None)
|
3364
|
-
request_dict.get('batch', {}).get('inputConfig', {}).get('requests', {}).pop(
|
3365
|
-
'config', None
|
3366
|
-
)
|
3367
|
-
|
3368
|
-
request_dict = _common.convert_to_dict(request_dict)
|
3369
|
-
request_dict = _common.encode_unserializable_types(request_dict)
|
3370
|
-
|
3371
|
-
requests = []
|
3372
|
-
batch_dict = request_dict.get('batch')
|
3373
|
-
if batch_dict and isinstance(batch_dict, dict):
|
3374
|
-
input_config_dict = batch_dict.get('inputConfig')
|
3375
|
-
if input_config_dict and isinstance(input_config_dict, dict):
|
3376
|
-
requests_dict = input_config_dict.get('requests')
|
3377
|
-
if requests_dict and isinstance(requests_dict, dict):
|
3378
|
-
requests = requests_dict.get('requests')
|
3379
|
-
new_requests = []
|
3380
|
-
if requests:
|
3381
|
-
for req in requests:
|
3382
|
-
for k in list(req.keys()):
|
3383
|
-
if k != 'request':
|
3384
|
-
req['request'][k] = req.pop(k)
|
3385
|
-
new_requests.append(req)
|
3386
|
-
request_dict['batch']['inputConfig']['requests'][ # type: ignore
|
3387
|
-
'requests'
|
3388
|
-
] = new_requests
|
3389
|
-
|
3390
|
-
return path, request_dict
|