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/_api_client.py +2 -1
- google/genai/_common.py +213 -77
- google/genai/_live_converters.py +717 -3098
- google/genai/_replay_api_client.py +9 -5
- google/genai/_tokens_converters.py +23 -434
- google/genai/_transformers.py +42 -12
- google/genai/batches.py +125 -1054
- google/genai/caches.py +69 -847
- google/genai/errors.py +9 -2
- google/genai/files.py +12 -171
- google/genai/live.py +10 -11
- google/genai/live_music.py +24 -27
- google/genai/models.py +333 -1828
- google/genai/operations.py +6 -32
- google/genai/tokens.py +2 -12
- google/genai/tunings.py +18 -197
- google/genai/types.py +154 -3
- google/genai/version.py +1 -1
- {google_genai-1.41.0.dist-info → google_genai-1.43.0.dist-info}/METADATA +40 -38
- google_genai-1.43.0.dist-info/RECORD +39 -0
- google_genai-1.41.0.dist-info/RECORD +0 -39
- {google_genai-1.41.0.dist-info → google_genai-1.43.0.dist-info}/WHEEL +0 -0
- {google_genai-1.41.0.dist-info → google_genai-1.43.0.dist-info}/licenses/LICENSE +0 -0
- {google_genai-1.41.0.dist-info → google_genai-1.43.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,19 +1016,16 @@ def _GetBatchJobParameters_to_vertex(
|
|
1226
1016
|
return to_object
|
1227
1017
|
|
1228
1018
|
|
1229
|
-
def
|
1019
|
+
def _GoogleMaps_to_mldev(
|
1230
1020
|
from_object: Union[dict[str, Any], object],
|
1231
1021
|
parent_object: Optional[dict[str, Any]] = None,
|
1232
1022
|
) -> dict[str, Any]:
|
1233
1023
|
to_object: dict[str, Any] = {}
|
1234
|
-
if getv(from_object, ['
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1239
|
-
getv(from_object, ['dynamic_retrieval_config']), to_object
|
1240
|
-
),
|
1241
|
-
)
|
1024
|
+
if getv(from_object, ['auth_config']) is not None:
|
1025
|
+
raise ValueError('auth_config parameter is not supported in Gemini API.')
|
1026
|
+
|
1027
|
+
if getv(from_object, ['enable_widget']) is not None:
|
1028
|
+
setv(to_object, ['enableWidget'], getv(from_object, ['enable_widget']))
|
1242
1029
|
|
1243
1030
|
return to_object
|
1244
1031
|
|
@@ -1250,9 +1037,7 @@ def _GoogleSearch_to_mldev(
|
|
1250
1037
|
to_object: dict[str, Any] = {}
|
1251
1038
|
if getv(from_object, ['time_range_filter']) is not None:
|
1252
1039
|
setv(
|
1253
|
-
to_object,
|
1254
|
-
['timeRangeFilter'],
|
1255
|
-
_Interval_to_mldev(getv(from_object, ['time_range_filter']), to_object),
|
1040
|
+
to_object, ['timeRangeFilter'], getv(from_object, ['time_range_filter'])
|
1256
1041
|
)
|
1257
1042
|
|
1258
1043
|
if getv(from_object, ['exclude_domains']) is not None:
|
@@ -1263,41 +1048,6 @@ def _GoogleSearch_to_mldev(
|
|
1263
1048
|
return to_object
|
1264
1049
|
|
1265
1050
|
|
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
1051
|
def _InlinedRequest_to_mldev(
|
1302
1052
|
api_client: BaseApiClient,
|
1303
1053
|
from_object: Union[dict[str, Any], object],
|
@@ -1321,12 +1071,17 @@ def _InlinedRequest_to_mldev(
|
|
1321
1071
|
],
|
1322
1072
|
)
|
1323
1073
|
|
1074
|
+
if getv(from_object, ['metadata']) is not None:
|
1075
|
+
setv(to_object, ['metadata'], getv(from_object, ['metadata']))
|
1076
|
+
|
1324
1077
|
if getv(from_object, ['config']) is not None:
|
1325
1078
|
setv(
|
1326
1079
|
to_object,
|
1327
1080
|
['request', 'generationConfig'],
|
1328
1081
|
_GenerateContentConfig_to_mldev(
|
1329
|
-
api_client,
|
1082
|
+
api_client,
|
1083
|
+
getv(from_object, ['config']),
|
1084
|
+
getv(to_object, ['request'], default_value={}),
|
1330
1085
|
),
|
1331
1086
|
)
|
1332
1087
|
|
@@ -1348,73 +1103,7 @@ def _InlinedResponse_from_mldev(
|
|
1348
1103
|
)
|
1349
1104
|
|
1350
1105
|
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']))
|
1106
|
+
setv(to_object, ['error'], getv(from_object, ['error']))
|
1418
1107
|
|
1419
1108
|
return to_object
|
1420
1109
|
|
@@ -1509,432 +1198,109 @@ def _ListBatchJobsResponse_from_mldev(
|
|
1509
1198
|
[
|
1510
1199
|
_BatchJob_from_mldev(item, to_object)
|
1511
1200
|
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']),
|
1201
|
+
],
|
1821
1202
|
)
|
1822
1203
|
|
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
1204
|
return to_object
|
1833
1205
|
|
1834
1206
|
|
1835
|
-
def
|
1207
|
+
def _ListBatchJobsResponse_from_vertex(
|
1836
1208
|
from_object: Union[dict[str, Any], object],
|
1837
1209
|
parent_object: Optional[dict[str, Any]] = None,
|
1838
1210
|
) -> dict[str, Any]:
|
1839
1211
|
to_object: dict[str, Any] = {}
|
1840
|
-
if getv(from_object, ['
|
1212
|
+
if getv(from_object, ['sdkHttpResponse']) is not None:
|
1841
1213
|
setv(
|
1842
|
-
to_object,
|
1843
|
-
['embedding'],
|
1844
|
-
_ContentEmbedding_from_mldev(
|
1845
|
-
getv(from_object, ['embedding']), to_object
|
1846
|
-
),
|
1214
|
+
to_object, ['sdk_http_response'], getv(from_object, ['sdkHttpResponse'])
|
1847
1215
|
)
|
1848
1216
|
|
1849
|
-
if getv(from_object, ['
|
1850
|
-
setv(to_object, ['
|
1217
|
+
if getv(from_object, ['nextPageToken']) is not None:
|
1218
|
+
setv(to_object, ['next_page_token'], getv(from_object, ['nextPageToken']))
|
1219
|
+
|
1220
|
+
if getv(from_object, ['batchPredictionJobs']) is not None:
|
1221
|
+
setv(
|
1222
|
+
to_object,
|
1223
|
+
['batch_jobs'],
|
1224
|
+
[
|
1225
|
+
_BatchJob_from_vertex(item, to_object)
|
1226
|
+
for item in getv(from_object, ['batchPredictionJobs'])
|
1227
|
+
],
|
1228
|
+
)
|
1851
1229
|
|
1852
1230
|
return to_object
|
1853
1231
|
|
1854
1232
|
|
1855
|
-
def
|
1233
|
+
def _Part_to_mldev(
|
1856
1234
|
from_object: Union[dict[str, Any], object],
|
1857
1235
|
parent_object: Optional[dict[str, Any]] = None,
|
1858
1236
|
) -> dict[str, Any]:
|
1859
1237
|
to_object: dict[str, Any] = {}
|
1860
|
-
if getv(from_object, ['
|
1861
|
-
setv(to_object, ['
|
1238
|
+
if getv(from_object, ['video_metadata']) is not None:
|
1239
|
+
setv(to_object, ['videoMetadata'], getv(from_object, ['video_metadata']))
|
1240
|
+
|
1241
|
+
if getv(from_object, ['thought']) is not None:
|
1242
|
+
setv(to_object, ['thought'], getv(from_object, ['thought']))
|
1862
1243
|
|
1863
|
-
if getv(from_object, ['
|
1244
|
+
if getv(from_object, ['inline_data']) is not None:
|
1864
1245
|
setv(
|
1865
1246
|
to_object,
|
1866
|
-
['
|
1867
|
-
|
1247
|
+
['inlineData'],
|
1248
|
+
_Blob_to_mldev(getv(from_object, ['inline_data']), to_object),
|
1868
1249
|
)
|
1869
1250
|
|
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:
|
1251
|
+
if getv(from_object, ['file_data']) is not None:
|
1879
1252
|
setv(
|
1880
1253
|
to_object,
|
1881
|
-
['
|
1882
|
-
|
1254
|
+
['fileData'],
|
1255
|
+
_FileData_to_mldev(getv(from_object, ['file_data']), to_object),
|
1883
1256
|
)
|
1884
1257
|
|
1885
|
-
if getv(from_object, ['
|
1258
|
+
if getv(from_object, ['thought_signature']) is not None:
|
1886
1259
|
setv(
|
1887
1260
|
to_object,
|
1888
|
-
['
|
1889
|
-
|
1890
|
-
getv(from_object, ['multi_speaker_voice_config']), to_object
|
1891
|
-
),
|
1261
|
+
['thoughtSignature'],
|
1262
|
+
getv(from_object, ['thought_signature']),
|
1892
1263
|
)
|
1893
1264
|
|
1894
|
-
if getv(from_object, ['
|
1895
|
-
setv(to_object, ['
|
1265
|
+
if getv(from_object, ['function_call']) is not None:
|
1266
|
+
setv(to_object, ['functionCall'], getv(from_object, ['function_call']))
|
1896
1267
|
|
1897
|
-
|
1268
|
+
if getv(from_object, ['code_execution_result']) is not None:
|
1269
|
+
setv(
|
1270
|
+
to_object,
|
1271
|
+
['codeExecutionResult'],
|
1272
|
+
getv(from_object, ['code_execution_result']),
|
1273
|
+
)
|
1898
1274
|
|
1275
|
+
if getv(from_object, ['executable_code']) is not None:
|
1276
|
+
setv(to_object, ['executableCode'], getv(from_object, ['executable_code']))
|
1899
1277
|
|
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:
|
1278
|
+
if getv(from_object, ['function_response']) is not None:
|
1906
1279
|
setv(
|
1907
|
-
to_object,
|
1280
|
+
to_object,
|
1281
|
+
['functionResponse'],
|
1282
|
+
getv(from_object, ['function_response']),
|
1908
1283
|
)
|
1909
1284
|
|
1910
|
-
if getv(from_object, ['
|
1911
|
-
setv(to_object, ['
|
1285
|
+
if getv(from_object, ['text']) is not None:
|
1286
|
+
setv(to_object, ['text'], getv(from_object, ['text']))
|
1912
1287
|
|
1913
1288
|
return to_object
|
1914
1289
|
|
1915
1290
|
|
1916
|
-
def
|
1291
|
+
def _SafetySetting_to_mldev(
|
1917
1292
|
from_object: Union[dict[str, Any], object],
|
1918
1293
|
parent_object: Optional[dict[str, Any]] = None,
|
1919
1294
|
) -> dict[str, Any]:
|
1920
1295
|
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
|
-
)
|
1296
|
+
if getv(from_object, ['method']) is not None:
|
1297
|
+
raise ValueError('method parameter is not supported in Gemini API.')
|
1929
1298
|
|
1930
|
-
if getv(from_object, ['
|
1931
|
-
setv(
|
1932
|
-
|
1933
|
-
|
1934
|
-
|
1935
|
-
getv(from_object, ['retrieval_config']), to_object
|
1936
|
-
),
|
1937
|
-
)
|
1299
|
+
if getv(from_object, ['category']) is not None:
|
1300
|
+
setv(to_object, ['category'], getv(from_object, ['category']))
|
1301
|
+
|
1302
|
+
if getv(from_object, ['threshold']) is not None:
|
1303
|
+
setv(to_object, ['threshold'], getv(from_object, ['threshold']))
|
1938
1304
|
|
1939
1305
|
return to_object
|
1940
1306
|
|
@@ -1948,10 +1314,7 @@ def _Tool_to_mldev(
|
|
1948
1314
|
setv(
|
1949
1315
|
to_object,
|
1950
1316
|
['functionDeclarations'],
|
1951
|
-
[
|
1952
|
-
_FunctionDeclaration_to_mldev(item, to_object)
|
1953
|
-
for item in getv(from_object, ['function_declarations'])
|
1954
|
-
],
|
1317
|
+
[item for item in getv(from_object, ['function_declarations'])],
|
1955
1318
|
)
|
1956
1319
|
|
1957
1320
|
if getv(from_object, ['retrieval']) is not None:
|
@@ -1968,9 +1331,7 @@ def _Tool_to_mldev(
|
|
1968
1331
|
setv(
|
1969
1332
|
to_object,
|
1970
1333
|
['googleSearchRetrieval'],
|
1971
|
-
|
1972
|
-
getv(from_object, ['google_search_retrieval']), to_object
|
1973
|
-
),
|
1334
|
+
getv(from_object, ['google_search_retrieval']),
|
1974
1335
|
)
|
1975
1336
|
|
1976
1337
|
if getv(from_object, ['enterprise_web_search']) is not None:
|
@@ -1979,21 +1340,17 @@ def _Tool_to_mldev(
|
|
1979
1340
|
)
|
1980
1341
|
|
1981
1342
|
if getv(from_object, ['google_maps']) is not None:
|
1982
|
-
raise ValueError('google_maps parameter is not supported in Gemini API.')
|
1983
|
-
|
1984
|
-
if getv(from_object, ['url_context']) is not None:
|
1985
1343
|
setv(
|
1986
1344
|
to_object,
|
1987
|
-
['
|
1988
|
-
|
1345
|
+
['googleMaps'],
|
1346
|
+
_GoogleMaps_to_mldev(getv(from_object, ['google_maps']), to_object),
|
1989
1347
|
)
|
1990
1348
|
|
1349
|
+
if getv(from_object, ['url_context']) is not None:
|
1350
|
+
setv(to_object, ['urlContext'], getv(from_object, ['url_context']))
|
1351
|
+
|
1991
1352
|
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
|
-
)
|
1353
|
+
setv(to_object, ['computerUse'], getv(from_object, ['computer_use']))
|
1997
1354
|
|
1998
1355
|
if getv(from_object, ['code_execution']) is not None:
|
1999
1356
|
setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
|
@@ -2001,102 +1358,6 @@ def _Tool_to_mldev(
|
|
2001
1358
|
return to_object
|
2002
1359
|
|
2003
1360
|
|
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
1361
|
class Batches(_api_module.BaseModule):
|
2101
1362
|
|
2102
1363
|
def _create(
|
@@ -2152,12 +1413,12 @@ class Batches(_api_module.BaseModule):
|
|
2152
1413
|
'post', path, request_dict, http_options
|
2153
1414
|
)
|
2154
1415
|
|
2155
|
-
response_dict =
|
1416
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
2156
1417
|
|
2157
1418
|
if self._api_client.vertexai:
|
2158
1419
|
response_dict = _BatchJob_from_vertex(response_dict)
|
2159
1420
|
|
2160
|
-
|
1421
|
+
if not self._api_client.vertexai:
|
2161
1422
|
response_dict = _BatchJob_from_mldev(response_dict)
|
2162
1423
|
|
2163
1424
|
return_value = types.BatchJob._from_response(
|
@@ -2215,7 +1476,7 @@ class Batches(_api_module.BaseModule):
|
|
2215
1476
|
'post', path, request_dict, http_options
|
2216
1477
|
)
|
2217
1478
|
|
2218
|
-
response_dict =
|
1479
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
2219
1480
|
|
2220
1481
|
if not self._api_client.vertexai:
|
2221
1482
|
response_dict = _BatchJob_from_mldev(response_dict)
|
@@ -2292,12 +1553,12 @@ class Batches(_api_module.BaseModule):
|
|
2292
1553
|
|
2293
1554
|
response = self._api_client.request('get', path, request_dict, http_options)
|
2294
1555
|
|
2295
|
-
response_dict =
|
1556
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
2296
1557
|
|
2297
1558
|
if self._api_client.vertexai:
|
2298
1559
|
response_dict = _BatchJob_from_vertex(response_dict)
|
2299
1560
|
|
2300
|
-
|
1561
|
+
if not self._api_client.vertexai:
|
2301
1562
|
response_dict = _BatchJob_from_mldev(response_dict)
|
2302
1563
|
|
2303
1564
|
return_value = types.BatchJob._from_response(
|
@@ -2416,12 +1677,12 @@ class Batches(_api_module.BaseModule):
|
|
2416
1677
|
|
2417
1678
|
response = self._api_client.request('get', path, request_dict, http_options)
|
2418
1679
|
|
2419
|
-
response_dict =
|
1680
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
2420
1681
|
|
2421
1682
|
if self._api_client.vertexai:
|
2422
1683
|
response_dict = _ListBatchJobsResponse_from_vertex(response_dict)
|
2423
1684
|
|
2424
|
-
|
1685
|
+
if not self._api_client.vertexai:
|
2425
1686
|
response_dict = _ListBatchJobsResponse_from_mldev(response_dict)
|
2426
1687
|
|
2427
1688
|
return_value = types.ListBatchJobsResponse._from_response(
|
@@ -2501,12 +1762,12 @@ class Batches(_api_module.BaseModule):
|
|
2501
1762
|
'delete', path, request_dict, http_options
|
2502
1763
|
)
|
2503
1764
|
|
2504
|
-
response_dict =
|
1765
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
2505
1766
|
|
2506
1767
|
if self._api_client.vertexai:
|
2507
1768
|
response_dict = _DeleteResourceJob_from_vertex(response_dict)
|
2508
1769
|
|
2509
|
-
|
1770
|
+
if not self._api_client.vertexai:
|
2510
1771
|
response_dict = _DeleteResourceJob_from_mldev(response_dict)
|
2511
1772
|
|
2512
1773
|
return_value = types.DeleteResourceJob._from_response(
|
@@ -2557,37 +1818,12 @@ class Batches(_api_module.BaseModule):
|
|
2557
1818
|
config=config,
|
2558
1819
|
)
|
2559
1820
|
|
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
1821
|
if self._api_client.vertexai:
|
2568
1822
|
config = _extra_utils.format_destination(src, parameter_model.config)
|
2569
1823
|
return self._create(model=model, src=src, config=config)
|
2570
|
-
|
1824
|
+
else:
|
2571
1825
|
return self._create(model=model, src=src, config=config)
|
2572
1826
|
|
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
1827
|
def create_embeddings(
|
2592
1828
|
self,
|
2593
1829
|
*,
|
@@ -2633,36 +1869,11 @@ class Batches(_api_module.BaseModule):
|
|
2633
1869
|
config=config,
|
2634
1870
|
)
|
2635
1871
|
|
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
1872
|
if self._api_client.vertexai:
|
2644
1873
|
raise ValueError('Vertex AI does not support batches.create_embeddings.')
|
2645
|
-
|
1874
|
+
else:
|
2646
1875
|
return self._create_embeddings(model=model, src=src, config=config)
|
2647
1876
|
|
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
1877
|
def list(
|
2667
1878
|
self, *, config: Optional[types.ListBatchJobsConfigOrDict] = None
|
2668
1879
|
) -> Pager[types.BatchJob]:
|
@@ -2748,12 +1959,12 @@ class AsyncBatches(_api_module.BaseModule):
|
|
2748
1959
|
'post', path, request_dict, http_options
|
2749
1960
|
)
|
2750
1961
|
|
2751
|
-
response_dict =
|
1962
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
2752
1963
|
|
2753
1964
|
if self._api_client.vertexai:
|
2754
1965
|
response_dict = _BatchJob_from_vertex(response_dict)
|
2755
1966
|
|
2756
|
-
|
1967
|
+
if not self._api_client.vertexai:
|
2757
1968
|
response_dict = _BatchJob_from_mldev(response_dict)
|
2758
1969
|
|
2759
1970
|
return_value = types.BatchJob._from_response(
|
@@ -2811,7 +2022,7 @@ class AsyncBatches(_api_module.BaseModule):
|
|
2811
2022
|
'post', path, request_dict, http_options
|
2812
2023
|
)
|
2813
2024
|
|
2814
|
-
response_dict =
|
2025
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
2815
2026
|
|
2816
2027
|
if not self._api_client.vertexai:
|
2817
2028
|
response_dict = _BatchJob_from_mldev(response_dict)
|
@@ -2890,12 +2101,12 @@ class AsyncBatches(_api_module.BaseModule):
|
|
2890
2101
|
'get', path, request_dict, http_options
|
2891
2102
|
)
|
2892
2103
|
|
2893
|
-
response_dict =
|
2104
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
2894
2105
|
|
2895
2106
|
if self._api_client.vertexai:
|
2896
2107
|
response_dict = _BatchJob_from_vertex(response_dict)
|
2897
2108
|
|
2898
|
-
|
2109
|
+
if not self._api_client.vertexai:
|
2899
2110
|
response_dict = _BatchJob_from_mldev(response_dict)
|
2900
2111
|
|
2901
2112
|
return_value = types.BatchJob._from_response(
|
@@ -3016,12 +2227,12 @@ class AsyncBatches(_api_module.BaseModule):
|
|
3016
2227
|
'get', path, request_dict, http_options
|
3017
2228
|
)
|
3018
2229
|
|
3019
|
-
response_dict =
|
2230
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
3020
2231
|
|
3021
2232
|
if self._api_client.vertexai:
|
3022
2233
|
response_dict = _ListBatchJobsResponse_from_vertex(response_dict)
|
3023
2234
|
|
3024
|
-
|
2235
|
+
if not self._api_client.vertexai:
|
3025
2236
|
response_dict = _ListBatchJobsResponse_from_mldev(response_dict)
|
3026
2237
|
|
3027
2238
|
return_value = types.ListBatchJobsResponse._from_response(
|
@@ -3101,12 +2312,12 @@ class AsyncBatches(_api_module.BaseModule):
|
|
3101
2312
|
'delete', path, request_dict, http_options
|
3102
2313
|
)
|
3103
2314
|
|
3104
|
-
response_dict =
|
2315
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
3105
2316
|
|
3106
2317
|
if self._api_client.vertexai:
|
3107
2318
|
response_dict = _DeleteResourceJob_from_vertex(response_dict)
|
3108
2319
|
|
3109
|
-
|
2320
|
+
if not self._api_client.vertexai:
|
3110
2321
|
response_dict = _DeleteResourceJob_from_mldev(response_dict)
|
3111
2322
|
|
3112
2323
|
return_value = types.DeleteResourceJob._from_response(
|
@@ -3156,37 +2367,12 @@ class AsyncBatches(_api_module.BaseModule):
|
|
3156
2367
|
config=config,
|
3157
2368
|
)
|
3158
2369
|
|
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
2370
|
if self._api_client.vertexai:
|
3167
2371
|
config = _extra_utils.format_destination(src, parameter_model.config)
|
3168
2372
|
return await self._create(model=model, src=src, config=config)
|
3169
|
-
|
2373
|
+
else:
|
3170
2374
|
return await self._create(model=model, src=src, config=config)
|
3171
2375
|
|
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
2376
|
async def create_embeddings(
|
3191
2377
|
self,
|
3192
2378
|
*,
|
@@ -3241,27 +2427,9 @@ class AsyncBatches(_api_module.BaseModule):
|
|
3241
2427
|
|
3242
2428
|
if self._api_client.vertexai:
|
3243
2429
|
raise ValueError('Vertex AI does not support batches.create_embeddings.')
|
3244
|
-
|
2430
|
+
else:
|
3245
2431
|
return await self._create_embeddings(model=model, src=src, config=config)
|
3246
2432
|
|
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
2433
|
async def list(
|
3266
2434
|
self, *, config: Optional[types.ListBatchJobsConfigOrDict] = None
|
3267
2435
|
) -> AsyncPager[types.BatchJob]:
|
@@ -3291,100 +2459,3 @@ class AsyncBatches(_api_module.BaseModule):
|
|
3291
2459
|
await self._list(config=config),
|
3292
2460
|
config,
|
3293
2461
|
)
|
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
|