@google/genai 0.10.0 → 0.11.0
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.
- package/dist/genai.d.ts +574 -39
- package/dist/index.js +1308 -894
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1307 -895
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.js +1308 -894
- package/dist/node/index.js.map +1 -1
- package/dist/node/node.d.ts +574 -39
- package/dist/web/index.mjs +1307 -895
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +574 -39
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -470,6 +470,20 @@ function tCachedContentName(apiClient, name) {
|
|
|
470
470
|
}
|
|
471
471
|
return resourceName(apiClient, name, 'cachedContents');
|
|
472
472
|
}
|
|
473
|
+
function tTuningJobStatus(apiClient, status) {
|
|
474
|
+
switch (status) {
|
|
475
|
+
case 'STATE_UNSPECIFIED':
|
|
476
|
+
return 'JOB_STATE_UNSPECIFIED';
|
|
477
|
+
case 'CREATING':
|
|
478
|
+
return 'JOB_STATE_RUNNING';
|
|
479
|
+
case 'ACTIVE':
|
|
480
|
+
return 'JOB_STATE_SUCCEEDED';
|
|
481
|
+
case 'FAILED':
|
|
482
|
+
return 'JOB_STATE_FAILED';
|
|
483
|
+
default:
|
|
484
|
+
return status;
|
|
485
|
+
}
|
|
486
|
+
}
|
|
473
487
|
function tBytes(apiClient, fromImageBytes) {
|
|
474
488
|
if (typeof fromImageBytes !== 'string') {
|
|
475
489
|
throw new Error('fromImageBytes must be a string');
|
|
@@ -542,14 +556,13 @@ function contentToMldev$2(apiClient, fromObject) {
|
|
|
542
556
|
const toObject = {};
|
|
543
557
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
544
558
|
if (fromParts != null) {
|
|
545
|
-
|
|
546
|
-
|
|
559
|
+
let transformedList = fromParts;
|
|
560
|
+
if (Array.isArray(transformedList)) {
|
|
561
|
+
transformedList = transformedList.map((item) => {
|
|
547
562
|
return partToMldev$2(apiClient, item);
|
|
548
|
-
})
|
|
549
|
-
}
|
|
550
|
-
else {
|
|
551
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
563
|
+
});
|
|
552
564
|
}
|
|
565
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
553
566
|
}
|
|
554
567
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
555
568
|
if (fromRole != null) {
|
|
@@ -557,25 +570,6 @@ function contentToMldev$2(apiClient, fromObject) {
|
|
|
557
570
|
}
|
|
558
571
|
return toObject;
|
|
559
572
|
}
|
|
560
|
-
function functionDeclarationToMldev$2(apiClient, fromObject) {
|
|
561
|
-
const toObject = {};
|
|
562
|
-
if (getValueByPath(fromObject, ['response']) !== undefined) {
|
|
563
|
-
throw new Error('response parameter is not supported in Gemini API.');
|
|
564
|
-
}
|
|
565
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
566
|
-
if (fromDescription != null) {
|
|
567
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
568
|
-
}
|
|
569
|
-
const fromName = getValueByPath(fromObject, ['name']);
|
|
570
|
-
if (fromName != null) {
|
|
571
|
-
setValueByPath(toObject, ['name'], fromName);
|
|
572
|
-
}
|
|
573
|
-
const fromParameters = getValueByPath(fromObject, ['parameters']);
|
|
574
|
-
if (fromParameters != null) {
|
|
575
|
-
setValueByPath(toObject, ['parameters'], fromParameters);
|
|
576
|
-
}
|
|
577
|
-
return toObject;
|
|
578
|
-
}
|
|
579
573
|
function googleSearchToMldev$2() {
|
|
580
574
|
const toObject = {};
|
|
581
575
|
return toObject;
|
|
@@ -606,19 +600,6 @@ function googleSearchRetrievalToMldev$2(apiClient, fromObject) {
|
|
|
606
600
|
}
|
|
607
601
|
function toolToMldev$2(apiClient, fromObject) {
|
|
608
602
|
const toObject = {};
|
|
609
|
-
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
610
|
-
'functionDeclarations',
|
|
611
|
-
]);
|
|
612
|
-
if (fromFunctionDeclarations != null) {
|
|
613
|
-
if (Array.isArray(fromFunctionDeclarations)) {
|
|
614
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations.map((item) => {
|
|
615
|
-
return functionDeclarationToMldev$2(apiClient, item);
|
|
616
|
-
}));
|
|
617
|
-
}
|
|
618
|
-
else {
|
|
619
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
603
|
if (getValueByPath(fromObject, ['retrieval']) !== undefined) {
|
|
623
604
|
throw new Error('retrieval parameter is not supported in Gemini API.');
|
|
624
605
|
}
|
|
@@ -638,6 +619,12 @@ function toolToMldev$2(apiClient, fromObject) {
|
|
|
638
619
|
if (fromCodeExecution != null) {
|
|
639
620
|
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
640
621
|
}
|
|
622
|
+
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
623
|
+
'functionDeclarations',
|
|
624
|
+
]);
|
|
625
|
+
if (fromFunctionDeclarations != null) {
|
|
626
|
+
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
627
|
+
}
|
|
641
628
|
return toObject;
|
|
642
629
|
}
|
|
643
630
|
function functionCallingConfigToMldev$1(apiClient, fromObject) {
|
|
@@ -680,14 +667,13 @@ function createCachedContentConfigToMldev(apiClient, fromObject, parentObject) {
|
|
|
680
667
|
}
|
|
681
668
|
const fromContents = getValueByPath(fromObject, ['contents']);
|
|
682
669
|
if (parentObject !== undefined && fromContents != null) {
|
|
683
|
-
|
|
684
|
-
|
|
670
|
+
let transformedList = tContents(apiClient, fromContents);
|
|
671
|
+
if (Array.isArray(transformedList)) {
|
|
672
|
+
transformedList = transformedList.map((item) => {
|
|
685
673
|
return contentToMldev$2(apiClient, item);
|
|
686
|
-
})
|
|
687
|
-
}
|
|
688
|
-
else {
|
|
689
|
-
setValueByPath(parentObject, ['contents'], tContents(apiClient, fromContents));
|
|
674
|
+
});
|
|
690
675
|
}
|
|
676
|
+
setValueByPath(parentObject, ['contents'], transformedList);
|
|
691
677
|
}
|
|
692
678
|
const fromSystemInstruction = getValueByPath(fromObject, [
|
|
693
679
|
'systemInstruction',
|
|
@@ -697,14 +683,13 @@ function createCachedContentConfigToMldev(apiClient, fromObject, parentObject) {
|
|
|
697
683
|
}
|
|
698
684
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
699
685
|
if (parentObject !== undefined && fromTools != null) {
|
|
700
|
-
|
|
701
|
-
|
|
686
|
+
let transformedList = fromTools;
|
|
687
|
+
if (Array.isArray(transformedList)) {
|
|
688
|
+
transformedList = transformedList.map((item) => {
|
|
702
689
|
return toolToMldev$2(apiClient, item);
|
|
703
|
-
})
|
|
704
|
-
}
|
|
705
|
-
else {
|
|
706
|
-
setValueByPath(parentObject, ['tools'], fromTools);
|
|
690
|
+
});
|
|
707
691
|
}
|
|
692
|
+
setValueByPath(parentObject, ['tools'], transformedList);
|
|
708
693
|
}
|
|
709
694
|
const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
|
|
710
695
|
if (parentObject !== undefined && fromToolConfig != null) {
|
|
@@ -844,14 +829,13 @@ function contentToVertex$2(apiClient, fromObject) {
|
|
|
844
829
|
const toObject = {};
|
|
845
830
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
846
831
|
if (fromParts != null) {
|
|
847
|
-
|
|
848
|
-
|
|
832
|
+
let transformedList = fromParts;
|
|
833
|
+
if (Array.isArray(transformedList)) {
|
|
834
|
+
transformedList = transformedList.map((item) => {
|
|
849
835
|
return partToVertex$2(apiClient, item);
|
|
850
|
-
})
|
|
851
|
-
}
|
|
852
|
-
else {
|
|
853
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
836
|
+
});
|
|
854
837
|
}
|
|
838
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
855
839
|
}
|
|
856
840
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
857
841
|
if (fromRole != null) {
|
|
@@ -859,124 +843,6 @@ function contentToVertex$2(apiClient, fromObject) {
|
|
|
859
843
|
}
|
|
860
844
|
return toObject;
|
|
861
845
|
}
|
|
862
|
-
function schemaToVertex$2(apiClient, fromObject) {
|
|
863
|
-
const toObject = {};
|
|
864
|
-
const fromExample = getValueByPath(fromObject, ['example']);
|
|
865
|
-
if (fromExample != null) {
|
|
866
|
-
setValueByPath(toObject, ['example'], fromExample);
|
|
867
|
-
}
|
|
868
|
-
const fromPattern = getValueByPath(fromObject, ['pattern']);
|
|
869
|
-
if (fromPattern != null) {
|
|
870
|
-
setValueByPath(toObject, ['pattern'], fromPattern);
|
|
871
|
-
}
|
|
872
|
-
const fromDefault = getValueByPath(fromObject, ['default']);
|
|
873
|
-
if (fromDefault != null) {
|
|
874
|
-
setValueByPath(toObject, ['default'], fromDefault);
|
|
875
|
-
}
|
|
876
|
-
const fromMaxLength = getValueByPath(fromObject, ['maxLength']);
|
|
877
|
-
if (fromMaxLength != null) {
|
|
878
|
-
setValueByPath(toObject, ['maxLength'], fromMaxLength);
|
|
879
|
-
}
|
|
880
|
-
const fromMinLength = getValueByPath(fromObject, ['minLength']);
|
|
881
|
-
if (fromMinLength != null) {
|
|
882
|
-
setValueByPath(toObject, ['minLength'], fromMinLength);
|
|
883
|
-
}
|
|
884
|
-
const fromMinProperties = getValueByPath(fromObject, [
|
|
885
|
-
'minProperties',
|
|
886
|
-
]);
|
|
887
|
-
if (fromMinProperties != null) {
|
|
888
|
-
setValueByPath(toObject, ['minProperties'], fromMinProperties);
|
|
889
|
-
}
|
|
890
|
-
const fromMaxProperties = getValueByPath(fromObject, [
|
|
891
|
-
'maxProperties',
|
|
892
|
-
]);
|
|
893
|
-
if (fromMaxProperties != null) {
|
|
894
|
-
setValueByPath(toObject, ['maxProperties'], fromMaxProperties);
|
|
895
|
-
}
|
|
896
|
-
const fromAnyOf = getValueByPath(fromObject, ['anyOf']);
|
|
897
|
-
if (fromAnyOf != null) {
|
|
898
|
-
setValueByPath(toObject, ['anyOf'], fromAnyOf);
|
|
899
|
-
}
|
|
900
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
901
|
-
if (fromDescription != null) {
|
|
902
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
903
|
-
}
|
|
904
|
-
const fromEnum = getValueByPath(fromObject, ['enum']);
|
|
905
|
-
if (fromEnum != null) {
|
|
906
|
-
setValueByPath(toObject, ['enum'], fromEnum);
|
|
907
|
-
}
|
|
908
|
-
const fromFormat = getValueByPath(fromObject, ['format']);
|
|
909
|
-
if (fromFormat != null) {
|
|
910
|
-
setValueByPath(toObject, ['format'], fromFormat);
|
|
911
|
-
}
|
|
912
|
-
const fromItems = getValueByPath(fromObject, ['items']);
|
|
913
|
-
if (fromItems != null) {
|
|
914
|
-
setValueByPath(toObject, ['items'], fromItems);
|
|
915
|
-
}
|
|
916
|
-
const fromMaxItems = getValueByPath(fromObject, ['maxItems']);
|
|
917
|
-
if (fromMaxItems != null) {
|
|
918
|
-
setValueByPath(toObject, ['maxItems'], fromMaxItems);
|
|
919
|
-
}
|
|
920
|
-
const fromMaximum = getValueByPath(fromObject, ['maximum']);
|
|
921
|
-
if (fromMaximum != null) {
|
|
922
|
-
setValueByPath(toObject, ['maximum'], fromMaximum);
|
|
923
|
-
}
|
|
924
|
-
const fromMinItems = getValueByPath(fromObject, ['minItems']);
|
|
925
|
-
if (fromMinItems != null) {
|
|
926
|
-
setValueByPath(toObject, ['minItems'], fromMinItems);
|
|
927
|
-
}
|
|
928
|
-
const fromMinimum = getValueByPath(fromObject, ['minimum']);
|
|
929
|
-
if (fromMinimum != null) {
|
|
930
|
-
setValueByPath(toObject, ['minimum'], fromMinimum);
|
|
931
|
-
}
|
|
932
|
-
const fromNullable = getValueByPath(fromObject, ['nullable']);
|
|
933
|
-
if (fromNullable != null) {
|
|
934
|
-
setValueByPath(toObject, ['nullable'], fromNullable);
|
|
935
|
-
}
|
|
936
|
-
const fromProperties = getValueByPath(fromObject, ['properties']);
|
|
937
|
-
if (fromProperties != null) {
|
|
938
|
-
setValueByPath(toObject, ['properties'], fromProperties);
|
|
939
|
-
}
|
|
940
|
-
const fromPropertyOrdering = getValueByPath(fromObject, [
|
|
941
|
-
'propertyOrdering',
|
|
942
|
-
]);
|
|
943
|
-
if (fromPropertyOrdering != null) {
|
|
944
|
-
setValueByPath(toObject, ['propertyOrdering'], fromPropertyOrdering);
|
|
945
|
-
}
|
|
946
|
-
const fromRequired = getValueByPath(fromObject, ['required']);
|
|
947
|
-
if (fromRequired != null) {
|
|
948
|
-
setValueByPath(toObject, ['required'], fromRequired);
|
|
949
|
-
}
|
|
950
|
-
const fromTitle = getValueByPath(fromObject, ['title']);
|
|
951
|
-
if (fromTitle != null) {
|
|
952
|
-
setValueByPath(toObject, ['title'], fromTitle);
|
|
953
|
-
}
|
|
954
|
-
const fromType = getValueByPath(fromObject, ['type']);
|
|
955
|
-
if (fromType != null) {
|
|
956
|
-
setValueByPath(toObject, ['type'], fromType);
|
|
957
|
-
}
|
|
958
|
-
return toObject;
|
|
959
|
-
}
|
|
960
|
-
function functionDeclarationToVertex$2(apiClient, fromObject) {
|
|
961
|
-
const toObject = {};
|
|
962
|
-
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
963
|
-
if (fromResponse != null) {
|
|
964
|
-
setValueByPath(toObject, ['response'], schemaToVertex$2(apiClient, fromResponse));
|
|
965
|
-
}
|
|
966
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
967
|
-
if (fromDescription != null) {
|
|
968
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
969
|
-
}
|
|
970
|
-
const fromName = getValueByPath(fromObject, ['name']);
|
|
971
|
-
if (fromName != null) {
|
|
972
|
-
setValueByPath(toObject, ['name'], fromName);
|
|
973
|
-
}
|
|
974
|
-
const fromParameters = getValueByPath(fromObject, ['parameters']);
|
|
975
|
-
if (fromParameters != null) {
|
|
976
|
-
setValueByPath(toObject, ['parameters'], fromParameters);
|
|
977
|
-
}
|
|
978
|
-
return toObject;
|
|
979
|
-
}
|
|
980
846
|
function googleSearchToVertex$2() {
|
|
981
847
|
const toObject = {};
|
|
982
848
|
return toObject;
|
|
@@ -1007,19 +873,6 @@ function googleSearchRetrievalToVertex$2(apiClient, fromObject) {
|
|
|
1007
873
|
}
|
|
1008
874
|
function toolToVertex$2(apiClient, fromObject) {
|
|
1009
875
|
const toObject = {};
|
|
1010
|
-
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
1011
|
-
'functionDeclarations',
|
|
1012
|
-
]);
|
|
1013
|
-
if (fromFunctionDeclarations != null) {
|
|
1014
|
-
if (Array.isArray(fromFunctionDeclarations)) {
|
|
1015
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations.map((item) => {
|
|
1016
|
-
return functionDeclarationToVertex$2(apiClient, item);
|
|
1017
|
-
}));
|
|
1018
|
-
}
|
|
1019
|
-
else {
|
|
1020
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
1021
|
-
}
|
|
1022
|
-
}
|
|
1023
876
|
const fromRetrieval = getValueByPath(fromObject, ['retrieval']);
|
|
1024
877
|
if (fromRetrieval != null) {
|
|
1025
878
|
setValueByPath(toObject, ['retrieval'], fromRetrieval);
|
|
@@ -1040,6 +893,12 @@ function toolToVertex$2(apiClient, fromObject) {
|
|
|
1040
893
|
if (fromCodeExecution != null) {
|
|
1041
894
|
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
1042
895
|
}
|
|
896
|
+
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
897
|
+
'functionDeclarations',
|
|
898
|
+
]);
|
|
899
|
+
if (fromFunctionDeclarations != null) {
|
|
900
|
+
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
901
|
+
}
|
|
1043
902
|
return toObject;
|
|
1044
903
|
}
|
|
1045
904
|
function functionCallingConfigToVertex$1(apiClient, fromObject) {
|
|
@@ -1082,14 +941,13 @@ function createCachedContentConfigToVertex(apiClient, fromObject, parentObject)
|
|
|
1082
941
|
}
|
|
1083
942
|
const fromContents = getValueByPath(fromObject, ['contents']);
|
|
1084
943
|
if (parentObject !== undefined && fromContents != null) {
|
|
1085
|
-
|
|
1086
|
-
|
|
944
|
+
let transformedList = tContents(apiClient, fromContents);
|
|
945
|
+
if (Array.isArray(transformedList)) {
|
|
946
|
+
transformedList = transformedList.map((item) => {
|
|
1087
947
|
return contentToVertex$2(apiClient, item);
|
|
1088
|
-
})
|
|
1089
|
-
}
|
|
1090
|
-
else {
|
|
1091
|
-
setValueByPath(parentObject, ['contents'], tContents(apiClient, fromContents));
|
|
948
|
+
});
|
|
1092
949
|
}
|
|
950
|
+
setValueByPath(parentObject, ['contents'], transformedList);
|
|
1093
951
|
}
|
|
1094
952
|
const fromSystemInstruction = getValueByPath(fromObject, [
|
|
1095
953
|
'systemInstruction',
|
|
@@ -1099,14 +957,13 @@ function createCachedContentConfigToVertex(apiClient, fromObject, parentObject)
|
|
|
1099
957
|
}
|
|
1100
958
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
1101
959
|
if (parentObject !== undefined && fromTools != null) {
|
|
1102
|
-
|
|
1103
|
-
|
|
960
|
+
let transformedList = fromTools;
|
|
961
|
+
if (Array.isArray(transformedList)) {
|
|
962
|
+
transformedList = transformedList.map((item) => {
|
|
1104
963
|
return toolToVertex$2(apiClient, item);
|
|
1105
|
-
})
|
|
1106
|
-
}
|
|
1107
|
-
else {
|
|
1108
|
-
setValueByPath(parentObject, ['tools'], fromTools);
|
|
964
|
+
});
|
|
1109
965
|
}
|
|
966
|
+
setValueByPath(parentObject, ['tools'], transformedList);
|
|
1110
967
|
}
|
|
1111
968
|
const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
|
|
1112
969
|
if (parentObject !== undefined && fromToolConfig != null) {
|
|
@@ -1244,14 +1101,13 @@ function listCachedContentsResponseFromMldev(apiClient, fromObject) {
|
|
|
1244
1101
|
'cachedContents',
|
|
1245
1102
|
]);
|
|
1246
1103
|
if (fromCachedContents != null) {
|
|
1247
|
-
|
|
1248
|
-
|
|
1104
|
+
let transformedList = fromCachedContents;
|
|
1105
|
+
if (Array.isArray(transformedList)) {
|
|
1106
|
+
transformedList = transformedList.map((item) => {
|
|
1249
1107
|
return cachedContentFromMldev(apiClient, item);
|
|
1250
|
-
})
|
|
1251
|
-
}
|
|
1252
|
-
else {
|
|
1253
|
-
setValueByPath(toObject, ['cachedContents'], fromCachedContents);
|
|
1108
|
+
});
|
|
1254
1109
|
}
|
|
1110
|
+
setValueByPath(toObject, ['cachedContents'], transformedList);
|
|
1255
1111
|
}
|
|
1256
1112
|
return toObject;
|
|
1257
1113
|
}
|
|
@@ -1305,14 +1161,13 @@ function listCachedContentsResponseFromVertex(apiClient, fromObject) {
|
|
|
1305
1161
|
'cachedContents',
|
|
1306
1162
|
]);
|
|
1307
1163
|
if (fromCachedContents != null) {
|
|
1308
|
-
|
|
1309
|
-
|
|
1164
|
+
let transformedList = fromCachedContents;
|
|
1165
|
+
if (Array.isArray(transformedList)) {
|
|
1166
|
+
transformedList = transformedList.map((item) => {
|
|
1310
1167
|
return cachedContentFromVertex(apiClient, item);
|
|
1311
|
-
})
|
|
1312
|
-
}
|
|
1313
|
-
else {
|
|
1314
|
-
setValueByPath(toObject, ['cachedContents'], fromCachedContents);
|
|
1168
|
+
});
|
|
1315
1169
|
}
|
|
1170
|
+
setValueByPath(toObject, ['cachedContents'], transformedList);
|
|
1316
1171
|
}
|
|
1317
1172
|
return toObject;
|
|
1318
1173
|
}
|
|
@@ -1514,17 +1369,6 @@ exports.Language = void 0;
|
|
|
1514
1369
|
Language["LANGUAGE_UNSPECIFIED"] = "LANGUAGE_UNSPECIFIED";
|
|
1515
1370
|
Language["PYTHON"] = "PYTHON";
|
|
1516
1371
|
})(exports.Language || (exports.Language = {}));
|
|
1517
|
-
/** Optional. The type of the data. */
|
|
1518
|
-
exports.Type = void 0;
|
|
1519
|
-
(function (Type) {
|
|
1520
|
-
Type["TYPE_UNSPECIFIED"] = "TYPE_UNSPECIFIED";
|
|
1521
|
-
Type["STRING"] = "STRING";
|
|
1522
|
-
Type["NUMBER"] = "NUMBER";
|
|
1523
|
-
Type["INTEGER"] = "INTEGER";
|
|
1524
|
-
Type["BOOLEAN"] = "BOOLEAN";
|
|
1525
|
-
Type["ARRAY"] = "ARRAY";
|
|
1526
|
-
Type["OBJECT"] = "OBJECT";
|
|
1527
|
-
})(exports.Type || (exports.Type = {}));
|
|
1528
1372
|
/** Required. Harm category. */
|
|
1529
1373
|
exports.HarmCategory = void 0;
|
|
1530
1374
|
(function (HarmCategory) {
|
|
@@ -1558,6 +1402,17 @@ exports.Mode = void 0;
|
|
|
1558
1402
|
Mode["MODE_UNSPECIFIED"] = "MODE_UNSPECIFIED";
|
|
1559
1403
|
Mode["MODE_DYNAMIC"] = "MODE_DYNAMIC";
|
|
1560
1404
|
})(exports.Mode || (exports.Mode = {}));
|
|
1405
|
+
/** Optional. The type of the data. */
|
|
1406
|
+
exports.Type = void 0;
|
|
1407
|
+
(function (Type) {
|
|
1408
|
+
Type["TYPE_UNSPECIFIED"] = "TYPE_UNSPECIFIED";
|
|
1409
|
+
Type["STRING"] = "STRING";
|
|
1410
|
+
Type["NUMBER"] = "NUMBER";
|
|
1411
|
+
Type["INTEGER"] = "INTEGER";
|
|
1412
|
+
Type["BOOLEAN"] = "BOOLEAN";
|
|
1413
|
+
Type["ARRAY"] = "ARRAY";
|
|
1414
|
+
Type["OBJECT"] = "OBJECT";
|
|
1415
|
+
})(exports.Type || (exports.Type = {}));
|
|
1561
1416
|
/** Output only. The reason why the model stopped generating tokens.
|
|
1562
1417
|
|
|
1563
1418
|
If empty, the model has not stopped generating the tokens.
|
|
@@ -1627,6 +1482,33 @@ exports.MediaResolution = void 0;
|
|
|
1627
1482
|
MediaResolution["MEDIA_RESOLUTION_MEDIUM"] = "MEDIA_RESOLUTION_MEDIUM";
|
|
1628
1483
|
MediaResolution["MEDIA_RESOLUTION_HIGH"] = "MEDIA_RESOLUTION_HIGH";
|
|
1629
1484
|
})(exports.MediaResolution || (exports.MediaResolution = {}));
|
|
1485
|
+
/** Output only. The detailed state of the job. */
|
|
1486
|
+
exports.JobState = void 0;
|
|
1487
|
+
(function (JobState) {
|
|
1488
|
+
JobState["JOB_STATE_UNSPECIFIED"] = "JOB_STATE_UNSPECIFIED";
|
|
1489
|
+
JobState["JOB_STATE_QUEUED"] = "JOB_STATE_QUEUED";
|
|
1490
|
+
JobState["JOB_STATE_PENDING"] = "JOB_STATE_PENDING";
|
|
1491
|
+
JobState["JOB_STATE_RUNNING"] = "JOB_STATE_RUNNING";
|
|
1492
|
+
JobState["JOB_STATE_SUCCEEDED"] = "JOB_STATE_SUCCEEDED";
|
|
1493
|
+
JobState["JOB_STATE_FAILED"] = "JOB_STATE_FAILED";
|
|
1494
|
+
JobState["JOB_STATE_CANCELLING"] = "JOB_STATE_CANCELLING";
|
|
1495
|
+
JobState["JOB_STATE_CANCELLED"] = "JOB_STATE_CANCELLED";
|
|
1496
|
+
JobState["JOB_STATE_PAUSED"] = "JOB_STATE_PAUSED";
|
|
1497
|
+
JobState["JOB_STATE_EXPIRED"] = "JOB_STATE_EXPIRED";
|
|
1498
|
+
JobState["JOB_STATE_UPDATING"] = "JOB_STATE_UPDATING";
|
|
1499
|
+
JobState["JOB_STATE_PARTIALLY_SUCCEEDED"] = "JOB_STATE_PARTIALLY_SUCCEEDED";
|
|
1500
|
+
})(exports.JobState || (exports.JobState = {}));
|
|
1501
|
+
/** Optional. Adapter size for tuning. */
|
|
1502
|
+
exports.AdapterSize = void 0;
|
|
1503
|
+
(function (AdapterSize) {
|
|
1504
|
+
AdapterSize["ADAPTER_SIZE_UNSPECIFIED"] = "ADAPTER_SIZE_UNSPECIFIED";
|
|
1505
|
+
AdapterSize["ADAPTER_SIZE_ONE"] = "ADAPTER_SIZE_ONE";
|
|
1506
|
+
AdapterSize["ADAPTER_SIZE_TWO"] = "ADAPTER_SIZE_TWO";
|
|
1507
|
+
AdapterSize["ADAPTER_SIZE_FOUR"] = "ADAPTER_SIZE_FOUR";
|
|
1508
|
+
AdapterSize["ADAPTER_SIZE_EIGHT"] = "ADAPTER_SIZE_EIGHT";
|
|
1509
|
+
AdapterSize["ADAPTER_SIZE_SIXTEEN"] = "ADAPTER_SIZE_SIXTEEN";
|
|
1510
|
+
AdapterSize["ADAPTER_SIZE_THIRTY_TWO"] = "ADAPTER_SIZE_THIRTY_TWO";
|
|
1511
|
+
})(exports.AdapterSize || (exports.AdapterSize = {}));
|
|
1630
1512
|
/** Options for feature selection preference. */
|
|
1631
1513
|
exports.FeatureSelectionPreference = void 0;
|
|
1632
1514
|
(function (FeatureSelectionPreference) {
|
|
@@ -2127,6 +2009,8 @@ class EmbedContentResponse {
|
|
|
2127
2009
|
/** The output images response. */
|
|
2128
2010
|
class GenerateImagesResponse {
|
|
2129
2011
|
}
|
|
2012
|
+
class DeleteModelResponse {
|
|
2013
|
+
}
|
|
2130
2014
|
/** Response for counting tokens. */
|
|
2131
2015
|
class CountTokensResponse {
|
|
2132
2016
|
}
|
|
@@ -2136,6 +2020,9 @@ class ComputeTokensResponse {
|
|
|
2136
2020
|
/** Response with generated videos. */
|
|
2137
2021
|
class GenerateVideosResponse {
|
|
2138
2022
|
}
|
|
2023
|
+
/** Response for the list tuning jobs method. */
|
|
2024
|
+
class ListTuningJobsResponse {
|
|
2025
|
+
}
|
|
2139
2026
|
/** Empty response for caches.delete method. */
|
|
2140
2027
|
class DeleteCachedContentResponse {
|
|
2141
2028
|
}
|
|
@@ -2232,7 +2119,7 @@ class Caches extends BaseModule {
|
|
|
2232
2119
|
* ```ts
|
|
2233
2120
|
* const contents = ...; // Initialize the content to cache.
|
|
2234
2121
|
* const response = await ai.caches.create({
|
|
2235
|
-
* model: 'gemini-
|
|
2122
|
+
* model: 'gemini-2.0-flash-001',
|
|
2236
2123
|
* config: {
|
|
2237
2124
|
* 'contents': contents,
|
|
2238
2125
|
* 'displayName': 'test cache',
|
|
@@ -2304,7 +2191,7 @@ class Caches extends BaseModule {
|
|
|
2304
2191
|
*
|
|
2305
2192
|
* @example
|
|
2306
2193
|
* ```ts
|
|
2307
|
-
* await ai.caches.get({name: '
|
|
2194
|
+
* await ai.caches.get({name: '...'}); // The server-generated resource name.
|
|
2308
2195
|
* ```
|
|
2309
2196
|
*/
|
|
2310
2197
|
async get(params) {
|
|
@@ -2369,7 +2256,7 @@ class Caches extends BaseModule {
|
|
|
2369
2256
|
*
|
|
2370
2257
|
* @example
|
|
2371
2258
|
* ```ts
|
|
2372
|
-
* await ai.caches.delete({name: '
|
|
2259
|
+
* await ai.caches.delete({name: '...'}); // The server-generated resource name.
|
|
2373
2260
|
* ```
|
|
2374
2261
|
*/
|
|
2375
2262
|
async delete(params) {
|
|
@@ -2439,7 +2326,7 @@ class Caches extends BaseModule {
|
|
|
2439
2326
|
* @example
|
|
2440
2327
|
* ```ts
|
|
2441
2328
|
* const response = await ai.caches.update({
|
|
2442
|
-
* name: '
|
|
2329
|
+
* name: '...', // The server-generated resource name.
|
|
2443
2330
|
* config: {'ttl': '7600s'}
|
|
2444
2331
|
* });
|
|
2445
2332
|
* ```
|
|
@@ -2837,7 +2724,12 @@ class Chat {
|
|
|
2837
2724
|
contents: this.getHistory(true).concat(inputContent),
|
|
2838
2725
|
config: (_a = params.config) !== null && _a !== void 0 ? _a : this.config,
|
|
2839
2726
|
});
|
|
2840
|
-
|
|
2727
|
+
// Resolve the internal tracking of send completion promise - `sendPromise`
|
|
2728
|
+
// for both success and failure response. The actual failure is still
|
|
2729
|
+
// propagated by the `await streamResponse`.
|
|
2730
|
+
this.sendPromise = streamResponse
|
|
2731
|
+
.then(() => undefined)
|
|
2732
|
+
.catch(() => undefined);
|
|
2841
2733
|
const response = await streamResponse;
|
|
2842
2734
|
const result = this.processStreamResponse(response, inputContent);
|
|
2843
2735
|
return result;
|
|
@@ -2925,7 +2817,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
2925
2817
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
2926
2818
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
2927
2819
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
2928
|
-
const SDK_VERSION = '0.
|
|
2820
|
+
const SDK_VERSION = '0.11.0'; // x-release-please-version
|
|
2929
2821
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
2930
2822
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
2931
2823
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -3730,14 +3622,13 @@ function listFilesResponseFromMldev(apiClient, fromObject) {
|
|
|
3730
3622
|
}
|
|
3731
3623
|
const fromFiles = getValueByPath(fromObject, ['files']);
|
|
3732
3624
|
if (fromFiles != null) {
|
|
3733
|
-
|
|
3734
|
-
|
|
3625
|
+
let transformedList = fromFiles;
|
|
3626
|
+
if (Array.isArray(transformedList)) {
|
|
3627
|
+
transformedList = transformedList.map((item) => {
|
|
3735
3628
|
return fileFromMldev(apiClient, item);
|
|
3736
|
-
})
|
|
3737
|
-
}
|
|
3738
|
-
else {
|
|
3739
|
-
setValueByPath(toObject, ['files'], fromFiles);
|
|
3629
|
+
});
|
|
3740
3630
|
}
|
|
3631
|
+
setValueByPath(toObject, ['files'], transformedList);
|
|
3741
3632
|
}
|
|
3742
3633
|
return toObject;
|
|
3743
3634
|
}
|
|
@@ -4104,14 +3995,13 @@ function contentToMldev$1(apiClient, fromObject) {
|
|
|
4104
3995
|
const toObject = {};
|
|
4105
3996
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
4106
3997
|
if (fromParts != null) {
|
|
4107
|
-
|
|
4108
|
-
|
|
3998
|
+
let transformedList = fromParts;
|
|
3999
|
+
if (Array.isArray(transformedList)) {
|
|
4000
|
+
transformedList = transformedList.map((item) => {
|
|
4109
4001
|
return partToMldev$1(apiClient, item);
|
|
4110
|
-
})
|
|
4111
|
-
}
|
|
4112
|
-
else {
|
|
4113
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
4002
|
+
});
|
|
4114
4003
|
}
|
|
4004
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
4115
4005
|
}
|
|
4116
4006
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
4117
4007
|
if (fromRole != null) {
|
|
@@ -4123,14 +4013,13 @@ function contentToVertex$1(apiClient, fromObject) {
|
|
|
4123
4013
|
const toObject = {};
|
|
4124
4014
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
4125
4015
|
if (fromParts != null) {
|
|
4126
|
-
|
|
4127
|
-
|
|
4016
|
+
let transformedList = fromParts;
|
|
4017
|
+
if (Array.isArray(transformedList)) {
|
|
4018
|
+
transformedList = transformedList.map((item) => {
|
|
4128
4019
|
return partToVertex$1(apiClient, item);
|
|
4129
|
-
})
|
|
4130
|
-
}
|
|
4131
|
-
else {
|
|
4132
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
4020
|
+
});
|
|
4133
4021
|
}
|
|
4022
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
4134
4023
|
}
|
|
4135
4024
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
4136
4025
|
if (fromRole != null) {
|
|
@@ -4138,143 +4027,6 @@ function contentToVertex$1(apiClient, fromObject) {
|
|
|
4138
4027
|
}
|
|
4139
4028
|
return toObject;
|
|
4140
4029
|
}
|
|
4141
|
-
function schemaToVertex$1(apiClient, fromObject) {
|
|
4142
|
-
const toObject = {};
|
|
4143
|
-
const fromExample = getValueByPath(fromObject, ['example']);
|
|
4144
|
-
if (fromExample != null) {
|
|
4145
|
-
setValueByPath(toObject, ['example'], fromExample);
|
|
4146
|
-
}
|
|
4147
|
-
const fromPattern = getValueByPath(fromObject, ['pattern']);
|
|
4148
|
-
if (fromPattern != null) {
|
|
4149
|
-
setValueByPath(toObject, ['pattern'], fromPattern);
|
|
4150
|
-
}
|
|
4151
|
-
const fromDefault = getValueByPath(fromObject, ['default']);
|
|
4152
|
-
if (fromDefault != null) {
|
|
4153
|
-
setValueByPath(toObject, ['default'], fromDefault);
|
|
4154
|
-
}
|
|
4155
|
-
const fromMaxLength = getValueByPath(fromObject, ['maxLength']);
|
|
4156
|
-
if (fromMaxLength != null) {
|
|
4157
|
-
setValueByPath(toObject, ['maxLength'], fromMaxLength);
|
|
4158
|
-
}
|
|
4159
|
-
const fromMinLength = getValueByPath(fromObject, ['minLength']);
|
|
4160
|
-
if (fromMinLength != null) {
|
|
4161
|
-
setValueByPath(toObject, ['minLength'], fromMinLength);
|
|
4162
|
-
}
|
|
4163
|
-
const fromMinProperties = getValueByPath(fromObject, [
|
|
4164
|
-
'minProperties',
|
|
4165
|
-
]);
|
|
4166
|
-
if (fromMinProperties != null) {
|
|
4167
|
-
setValueByPath(toObject, ['minProperties'], fromMinProperties);
|
|
4168
|
-
}
|
|
4169
|
-
const fromMaxProperties = getValueByPath(fromObject, [
|
|
4170
|
-
'maxProperties',
|
|
4171
|
-
]);
|
|
4172
|
-
if (fromMaxProperties != null) {
|
|
4173
|
-
setValueByPath(toObject, ['maxProperties'], fromMaxProperties);
|
|
4174
|
-
}
|
|
4175
|
-
const fromAnyOf = getValueByPath(fromObject, ['anyOf']);
|
|
4176
|
-
if (fromAnyOf != null) {
|
|
4177
|
-
setValueByPath(toObject, ['anyOf'], fromAnyOf);
|
|
4178
|
-
}
|
|
4179
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
4180
|
-
if (fromDescription != null) {
|
|
4181
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
4182
|
-
}
|
|
4183
|
-
const fromEnum = getValueByPath(fromObject, ['enum']);
|
|
4184
|
-
if (fromEnum != null) {
|
|
4185
|
-
setValueByPath(toObject, ['enum'], fromEnum);
|
|
4186
|
-
}
|
|
4187
|
-
const fromFormat = getValueByPath(fromObject, ['format']);
|
|
4188
|
-
if (fromFormat != null) {
|
|
4189
|
-
setValueByPath(toObject, ['format'], fromFormat);
|
|
4190
|
-
}
|
|
4191
|
-
const fromItems = getValueByPath(fromObject, ['items']);
|
|
4192
|
-
if (fromItems != null) {
|
|
4193
|
-
setValueByPath(toObject, ['items'], fromItems);
|
|
4194
|
-
}
|
|
4195
|
-
const fromMaxItems = getValueByPath(fromObject, ['maxItems']);
|
|
4196
|
-
if (fromMaxItems != null) {
|
|
4197
|
-
setValueByPath(toObject, ['maxItems'], fromMaxItems);
|
|
4198
|
-
}
|
|
4199
|
-
const fromMaximum = getValueByPath(fromObject, ['maximum']);
|
|
4200
|
-
if (fromMaximum != null) {
|
|
4201
|
-
setValueByPath(toObject, ['maximum'], fromMaximum);
|
|
4202
|
-
}
|
|
4203
|
-
const fromMinItems = getValueByPath(fromObject, ['minItems']);
|
|
4204
|
-
if (fromMinItems != null) {
|
|
4205
|
-
setValueByPath(toObject, ['minItems'], fromMinItems);
|
|
4206
|
-
}
|
|
4207
|
-
const fromMinimum = getValueByPath(fromObject, ['minimum']);
|
|
4208
|
-
if (fromMinimum != null) {
|
|
4209
|
-
setValueByPath(toObject, ['minimum'], fromMinimum);
|
|
4210
|
-
}
|
|
4211
|
-
const fromNullable = getValueByPath(fromObject, ['nullable']);
|
|
4212
|
-
if (fromNullable != null) {
|
|
4213
|
-
setValueByPath(toObject, ['nullable'], fromNullable);
|
|
4214
|
-
}
|
|
4215
|
-
const fromProperties = getValueByPath(fromObject, ['properties']);
|
|
4216
|
-
if (fromProperties != null) {
|
|
4217
|
-
setValueByPath(toObject, ['properties'], fromProperties);
|
|
4218
|
-
}
|
|
4219
|
-
const fromPropertyOrdering = getValueByPath(fromObject, [
|
|
4220
|
-
'propertyOrdering',
|
|
4221
|
-
]);
|
|
4222
|
-
if (fromPropertyOrdering != null) {
|
|
4223
|
-
setValueByPath(toObject, ['propertyOrdering'], fromPropertyOrdering);
|
|
4224
|
-
}
|
|
4225
|
-
const fromRequired = getValueByPath(fromObject, ['required']);
|
|
4226
|
-
if (fromRequired != null) {
|
|
4227
|
-
setValueByPath(toObject, ['required'], fromRequired);
|
|
4228
|
-
}
|
|
4229
|
-
const fromTitle = getValueByPath(fromObject, ['title']);
|
|
4230
|
-
if (fromTitle != null) {
|
|
4231
|
-
setValueByPath(toObject, ['title'], fromTitle);
|
|
4232
|
-
}
|
|
4233
|
-
const fromType = getValueByPath(fromObject, ['type']);
|
|
4234
|
-
if (fromType != null) {
|
|
4235
|
-
setValueByPath(toObject, ['type'], fromType);
|
|
4236
|
-
}
|
|
4237
|
-
return toObject;
|
|
4238
|
-
}
|
|
4239
|
-
function functionDeclarationToMldev$1(apiClient, fromObject) {
|
|
4240
|
-
const toObject = {};
|
|
4241
|
-
if (getValueByPath(fromObject, ['response']) !== undefined) {
|
|
4242
|
-
throw new Error('response parameter is not supported in Gemini API.');
|
|
4243
|
-
}
|
|
4244
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
4245
|
-
if (fromDescription != null) {
|
|
4246
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
4247
|
-
}
|
|
4248
|
-
const fromName = getValueByPath(fromObject, ['name']);
|
|
4249
|
-
if (fromName != null) {
|
|
4250
|
-
setValueByPath(toObject, ['name'], fromName);
|
|
4251
|
-
}
|
|
4252
|
-
const fromParameters = getValueByPath(fromObject, ['parameters']);
|
|
4253
|
-
if (fromParameters != null) {
|
|
4254
|
-
setValueByPath(toObject, ['parameters'], fromParameters);
|
|
4255
|
-
}
|
|
4256
|
-
return toObject;
|
|
4257
|
-
}
|
|
4258
|
-
function functionDeclarationToVertex$1(apiClient, fromObject) {
|
|
4259
|
-
const toObject = {};
|
|
4260
|
-
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
4261
|
-
if (fromResponse != null) {
|
|
4262
|
-
setValueByPath(toObject, ['response'], schemaToVertex$1(apiClient, fromResponse));
|
|
4263
|
-
}
|
|
4264
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
4265
|
-
if (fromDescription != null) {
|
|
4266
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
4267
|
-
}
|
|
4268
|
-
const fromName = getValueByPath(fromObject, ['name']);
|
|
4269
|
-
if (fromName != null) {
|
|
4270
|
-
setValueByPath(toObject, ['name'], fromName);
|
|
4271
|
-
}
|
|
4272
|
-
const fromParameters = getValueByPath(fromObject, ['parameters']);
|
|
4273
|
-
if (fromParameters != null) {
|
|
4274
|
-
setValueByPath(toObject, ['parameters'], fromParameters);
|
|
4275
|
-
}
|
|
4276
|
-
return toObject;
|
|
4277
|
-
}
|
|
4278
4030
|
function googleSearchToMldev$1() {
|
|
4279
4031
|
const toObject = {};
|
|
4280
4032
|
return toObject;
|
|
@@ -4333,19 +4085,6 @@ function googleSearchRetrievalToVertex$1(apiClient, fromObject) {
|
|
|
4333
4085
|
}
|
|
4334
4086
|
function toolToMldev$1(apiClient, fromObject) {
|
|
4335
4087
|
const toObject = {};
|
|
4336
|
-
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
4337
|
-
'functionDeclarations',
|
|
4338
|
-
]);
|
|
4339
|
-
if (fromFunctionDeclarations != null) {
|
|
4340
|
-
if (Array.isArray(fromFunctionDeclarations)) {
|
|
4341
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations.map((item) => {
|
|
4342
|
-
return functionDeclarationToMldev$1(apiClient, item);
|
|
4343
|
-
}));
|
|
4344
|
-
}
|
|
4345
|
-
else {
|
|
4346
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
4347
|
-
}
|
|
4348
|
-
}
|
|
4349
4088
|
if (getValueByPath(fromObject, ['retrieval']) !== undefined) {
|
|
4350
4089
|
throw new Error('retrieval parameter is not supported in Gemini API.');
|
|
4351
4090
|
}
|
|
@@ -4365,23 +4104,16 @@ function toolToMldev$1(apiClient, fromObject) {
|
|
|
4365
4104
|
if (fromCodeExecution != null) {
|
|
4366
4105
|
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
4367
4106
|
}
|
|
4368
|
-
return toObject;
|
|
4369
|
-
}
|
|
4370
|
-
function toolToVertex$1(apiClient, fromObject) {
|
|
4371
|
-
const toObject = {};
|
|
4372
4107
|
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
4373
4108
|
'functionDeclarations',
|
|
4374
4109
|
]);
|
|
4375
4110
|
if (fromFunctionDeclarations != null) {
|
|
4376
|
-
|
|
4377
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations.map((item) => {
|
|
4378
|
-
return functionDeclarationToVertex$1(apiClient, item);
|
|
4379
|
-
}));
|
|
4380
|
-
}
|
|
4381
|
-
else {
|
|
4382
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
4383
|
-
}
|
|
4111
|
+
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
4384
4112
|
}
|
|
4113
|
+
return toObject;
|
|
4114
|
+
}
|
|
4115
|
+
function toolToVertex$1(apiClient, fromObject) {
|
|
4116
|
+
const toObject = {};
|
|
4385
4117
|
const fromRetrieval = getValueByPath(fromObject, ['retrieval']);
|
|
4386
4118
|
if (fromRetrieval != null) {
|
|
4387
4119
|
setValueByPath(toObject, ['retrieval'], fromRetrieval);
|
|
@@ -4402,6 +4134,12 @@ function toolToVertex$1(apiClient, fromObject) {
|
|
|
4402
4134
|
if (fromCodeExecution != null) {
|
|
4403
4135
|
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
4404
4136
|
}
|
|
4137
|
+
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
4138
|
+
'functionDeclarations',
|
|
4139
|
+
]);
|
|
4140
|
+
if (fromFunctionDeclarations != null) {
|
|
4141
|
+
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
4142
|
+
}
|
|
4405
4143
|
return toObject;
|
|
4406
4144
|
}
|
|
4407
4145
|
function sessionResumptionConfigToMldev(apiClient, fromObject) {
|
|
@@ -4641,14 +4379,13 @@ function liveConnectConfigToMldev(apiClient, fromObject, parentObject) {
|
|
|
4641
4379
|
}
|
|
4642
4380
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
4643
4381
|
if (parentObject !== undefined && fromTools != null) {
|
|
4644
|
-
|
|
4645
|
-
|
|
4382
|
+
let transformedList = tTools(apiClient, fromTools);
|
|
4383
|
+
if (Array.isArray(transformedList)) {
|
|
4384
|
+
transformedList = transformedList.map((item) => {
|
|
4646
4385
|
return toolToMldev$1(apiClient, tTool(apiClient, item));
|
|
4647
|
-
})
|
|
4648
|
-
}
|
|
4649
|
-
else {
|
|
4650
|
-
setValueByPath(parentObject, ['setup', 'tools'], tTools(apiClient, fromTools));
|
|
4386
|
+
});
|
|
4651
4387
|
}
|
|
4388
|
+
setValueByPath(parentObject, ['setup', 'tools'], transformedList);
|
|
4652
4389
|
}
|
|
4653
4390
|
const fromSessionResumption = getValueByPath(fromObject, [
|
|
4654
4391
|
'sessionResumption',
|
|
@@ -4733,14 +4470,13 @@ function liveConnectConfigToVertex(apiClient, fromObject, parentObject) {
|
|
|
4733
4470
|
}
|
|
4734
4471
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
4735
4472
|
if (parentObject !== undefined && fromTools != null) {
|
|
4736
|
-
|
|
4737
|
-
|
|
4473
|
+
let transformedList = tTools(apiClient, fromTools);
|
|
4474
|
+
if (Array.isArray(transformedList)) {
|
|
4475
|
+
transformedList = transformedList.map((item) => {
|
|
4738
4476
|
return toolToVertex$1(apiClient, tTool(apiClient, item));
|
|
4739
|
-
})
|
|
4740
|
-
}
|
|
4741
|
-
else {
|
|
4742
|
-
setValueByPath(parentObject, ['setup', 'tools'], tTools(apiClient, fromTools));
|
|
4477
|
+
});
|
|
4743
4478
|
}
|
|
4479
|
+
setValueByPath(parentObject, ['setup', 'tools'], transformedList);
|
|
4744
4480
|
}
|
|
4745
4481
|
const fromSessionResumption = getValueByPath(fromObject, [
|
|
4746
4482
|
'sessionResumption',
|
|
@@ -4985,14 +4721,13 @@ function contentFromMldev$1(apiClient, fromObject) {
|
|
|
4985
4721
|
const toObject = {};
|
|
4986
4722
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
4987
4723
|
if (fromParts != null) {
|
|
4988
|
-
|
|
4989
|
-
|
|
4724
|
+
let transformedList = fromParts;
|
|
4725
|
+
if (Array.isArray(transformedList)) {
|
|
4726
|
+
transformedList = transformedList.map((item) => {
|
|
4990
4727
|
return partFromMldev$1(apiClient, item);
|
|
4991
|
-
})
|
|
4992
|
-
}
|
|
4993
|
-
else {
|
|
4994
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
4728
|
+
});
|
|
4995
4729
|
}
|
|
4730
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
4996
4731
|
}
|
|
4997
4732
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
4998
4733
|
if (fromRole != null) {
|
|
@@ -5004,14 +4739,13 @@ function contentFromVertex$1(apiClient, fromObject) {
|
|
|
5004
4739
|
const toObject = {};
|
|
5005
4740
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
5006
4741
|
if (fromParts != null) {
|
|
5007
|
-
|
|
5008
|
-
|
|
4742
|
+
let transformedList = fromParts;
|
|
4743
|
+
if (Array.isArray(transformedList)) {
|
|
4744
|
+
transformedList = transformedList.map((item) => {
|
|
5009
4745
|
return partFromVertex$1(apiClient, item);
|
|
5010
|
-
})
|
|
5011
|
-
}
|
|
5012
|
-
else {
|
|
5013
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
4746
|
+
});
|
|
5014
4747
|
}
|
|
4748
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
5015
4749
|
}
|
|
5016
4750
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
5017
4751
|
if (fromRole != null) {
|
|
@@ -5145,14 +4879,13 @@ function liveServerToolCallFromMldev(apiClient, fromObject) {
|
|
|
5145
4879
|
'functionCalls',
|
|
5146
4880
|
]);
|
|
5147
4881
|
if (fromFunctionCalls != null) {
|
|
5148
|
-
|
|
5149
|
-
|
|
4882
|
+
let transformedList = fromFunctionCalls;
|
|
4883
|
+
if (Array.isArray(transformedList)) {
|
|
4884
|
+
transformedList = transformedList.map((item) => {
|
|
5150
4885
|
return functionCallFromMldev(apiClient, item);
|
|
5151
|
-
})
|
|
5152
|
-
}
|
|
5153
|
-
else {
|
|
5154
|
-
setValueByPath(toObject, ['functionCalls'], fromFunctionCalls);
|
|
4886
|
+
});
|
|
5155
4887
|
}
|
|
4888
|
+
setValueByPath(toObject, ['functionCalls'], transformedList);
|
|
5156
4889
|
}
|
|
5157
4890
|
return toObject;
|
|
5158
4891
|
}
|
|
@@ -5162,14 +4895,13 @@ function liveServerToolCallFromVertex(apiClient, fromObject) {
|
|
|
5162
4895
|
'functionCalls',
|
|
5163
4896
|
]);
|
|
5164
4897
|
if (fromFunctionCalls != null) {
|
|
5165
|
-
|
|
5166
|
-
|
|
4898
|
+
let transformedList = fromFunctionCalls;
|
|
4899
|
+
if (Array.isArray(transformedList)) {
|
|
4900
|
+
transformedList = transformedList.map((item) => {
|
|
5167
4901
|
return functionCallFromVertex(apiClient, item);
|
|
5168
|
-
})
|
|
5169
|
-
}
|
|
5170
|
-
else {
|
|
5171
|
-
setValueByPath(toObject, ['functionCalls'], fromFunctionCalls);
|
|
4902
|
+
});
|
|
5172
4903
|
}
|
|
4904
|
+
setValueByPath(toObject, ['functionCalls'], transformedList);
|
|
5173
4905
|
}
|
|
5174
4906
|
return toObject;
|
|
5175
4907
|
}
|
|
@@ -5255,53 +4987,49 @@ function usageMetadataFromMldev(apiClient, fromObject) {
|
|
|
5255
4987
|
'promptTokensDetails',
|
|
5256
4988
|
]);
|
|
5257
4989
|
if (fromPromptTokensDetails != null) {
|
|
5258
|
-
|
|
5259
|
-
|
|
4990
|
+
let transformedList = fromPromptTokensDetails;
|
|
4991
|
+
if (Array.isArray(transformedList)) {
|
|
4992
|
+
transformedList = transformedList.map((item) => {
|
|
5260
4993
|
return modalityTokenCountFromMldev(apiClient, item);
|
|
5261
|
-
})
|
|
5262
|
-
}
|
|
5263
|
-
else {
|
|
5264
|
-
setValueByPath(toObject, ['promptTokensDetails'], fromPromptTokensDetails);
|
|
4994
|
+
});
|
|
5265
4995
|
}
|
|
4996
|
+
setValueByPath(toObject, ['promptTokensDetails'], transformedList);
|
|
5266
4997
|
}
|
|
5267
4998
|
const fromCacheTokensDetails = getValueByPath(fromObject, [
|
|
5268
4999
|
'cacheTokensDetails',
|
|
5269
5000
|
]);
|
|
5270
5001
|
if (fromCacheTokensDetails != null) {
|
|
5271
|
-
|
|
5272
|
-
|
|
5002
|
+
let transformedList = fromCacheTokensDetails;
|
|
5003
|
+
if (Array.isArray(transformedList)) {
|
|
5004
|
+
transformedList = transformedList.map((item) => {
|
|
5273
5005
|
return modalityTokenCountFromMldev(apiClient, item);
|
|
5274
|
-
})
|
|
5275
|
-
}
|
|
5276
|
-
else {
|
|
5277
|
-
setValueByPath(toObject, ['cacheTokensDetails'], fromCacheTokensDetails);
|
|
5006
|
+
});
|
|
5278
5007
|
}
|
|
5008
|
+
setValueByPath(toObject, ['cacheTokensDetails'], transformedList);
|
|
5279
5009
|
}
|
|
5280
5010
|
const fromResponseTokensDetails = getValueByPath(fromObject, [
|
|
5281
5011
|
'responseTokensDetails',
|
|
5282
5012
|
]);
|
|
5283
5013
|
if (fromResponseTokensDetails != null) {
|
|
5284
|
-
|
|
5285
|
-
|
|
5014
|
+
let transformedList = fromResponseTokensDetails;
|
|
5015
|
+
if (Array.isArray(transformedList)) {
|
|
5016
|
+
transformedList = transformedList.map((item) => {
|
|
5286
5017
|
return modalityTokenCountFromMldev(apiClient, item);
|
|
5287
|
-
})
|
|
5288
|
-
}
|
|
5289
|
-
else {
|
|
5290
|
-
setValueByPath(toObject, ['responseTokensDetails'], fromResponseTokensDetails);
|
|
5018
|
+
});
|
|
5291
5019
|
}
|
|
5020
|
+
setValueByPath(toObject, ['responseTokensDetails'], transformedList);
|
|
5292
5021
|
}
|
|
5293
5022
|
const fromToolUsePromptTokensDetails = getValueByPath(fromObject, [
|
|
5294
5023
|
'toolUsePromptTokensDetails',
|
|
5295
5024
|
]);
|
|
5296
5025
|
if (fromToolUsePromptTokensDetails != null) {
|
|
5297
|
-
|
|
5298
|
-
|
|
5026
|
+
let transformedList = fromToolUsePromptTokensDetails;
|
|
5027
|
+
if (Array.isArray(transformedList)) {
|
|
5028
|
+
transformedList = transformedList.map((item) => {
|
|
5299
5029
|
return modalityTokenCountFromMldev(apiClient, item);
|
|
5300
|
-
})
|
|
5301
|
-
}
|
|
5302
|
-
else {
|
|
5303
|
-
setValueByPath(toObject, ['toolUsePromptTokensDetails'], fromToolUsePromptTokensDetails);
|
|
5030
|
+
});
|
|
5304
5031
|
}
|
|
5032
|
+
setValueByPath(toObject, ['toolUsePromptTokensDetails'], transformedList);
|
|
5305
5033
|
}
|
|
5306
5034
|
return toObject;
|
|
5307
5035
|
}
|
|
@@ -5347,53 +5075,49 @@ function usageMetadataFromVertex(apiClient, fromObject) {
|
|
|
5347
5075
|
'promptTokensDetails',
|
|
5348
5076
|
]);
|
|
5349
5077
|
if (fromPromptTokensDetails != null) {
|
|
5350
|
-
|
|
5351
|
-
|
|
5078
|
+
let transformedList = fromPromptTokensDetails;
|
|
5079
|
+
if (Array.isArray(transformedList)) {
|
|
5080
|
+
transformedList = transformedList.map((item) => {
|
|
5352
5081
|
return modalityTokenCountFromVertex(apiClient, item);
|
|
5353
|
-
})
|
|
5354
|
-
}
|
|
5355
|
-
else {
|
|
5356
|
-
setValueByPath(toObject, ['promptTokensDetails'], fromPromptTokensDetails);
|
|
5082
|
+
});
|
|
5357
5083
|
}
|
|
5084
|
+
setValueByPath(toObject, ['promptTokensDetails'], transformedList);
|
|
5358
5085
|
}
|
|
5359
5086
|
const fromCacheTokensDetails = getValueByPath(fromObject, [
|
|
5360
5087
|
'cacheTokensDetails',
|
|
5361
5088
|
]);
|
|
5362
5089
|
if (fromCacheTokensDetails != null) {
|
|
5363
|
-
|
|
5364
|
-
|
|
5090
|
+
let transformedList = fromCacheTokensDetails;
|
|
5091
|
+
if (Array.isArray(transformedList)) {
|
|
5092
|
+
transformedList = transformedList.map((item) => {
|
|
5365
5093
|
return modalityTokenCountFromVertex(apiClient, item);
|
|
5366
|
-
})
|
|
5367
|
-
}
|
|
5368
|
-
else {
|
|
5369
|
-
setValueByPath(toObject, ['cacheTokensDetails'], fromCacheTokensDetails);
|
|
5094
|
+
});
|
|
5370
5095
|
}
|
|
5096
|
+
setValueByPath(toObject, ['cacheTokensDetails'], transformedList);
|
|
5371
5097
|
}
|
|
5372
5098
|
const fromResponseTokensDetails = getValueByPath(fromObject, [
|
|
5373
5099
|
'candidatesTokensDetails',
|
|
5374
5100
|
]);
|
|
5375
5101
|
if (fromResponseTokensDetails != null) {
|
|
5376
|
-
|
|
5377
|
-
|
|
5102
|
+
let transformedList = fromResponseTokensDetails;
|
|
5103
|
+
if (Array.isArray(transformedList)) {
|
|
5104
|
+
transformedList = transformedList.map((item) => {
|
|
5378
5105
|
return modalityTokenCountFromVertex(apiClient, item);
|
|
5379
|
-
})
|
|
5380
|
-
}
|
|
5381
|
-
else {
|
|
5382
|
-
setValueByPath(toObject, ['responseTokensDetails'], fromResponseTokensDetails);
|
|
5106
|
+
});
|
|
5383
5107
|
}
|
|
5108
|
+
setValueByPath(toObject, ['responseTokensDetails'], transformedList);
|
|
5384
5109
|
}
|
|
5385
5110
|
const fromToolUsePromptTokensDetails = getValueByPath(fromObject, [
|
|
5386
5111
|
'toolUsePromptTokensDetails',
|
|
5387
5112
|
]);
|
|
5388
5113
|
if (fromToolUsePromptTokensDetails != null) {
|
|
5389
|
-
|
|
5390
|
-
|
|
5114
|
+
let transformedList = fromToolUsePromptTokensDetails;
|
|
5115
|
+
if (Array.isArray(transformedList)) {
|
|
5116
|
+
transformedList = transformedList.map((item) => {
|
|
5391
5117
|
return modalityTokenCountFromVertex(apiClient, item);
|
|
5392
|
-
})
|
|
5393
|
-
}
|
|
5394
|
-
else {
|
|
5395
|
-
setValueByPath(toObject, ['toolUsePromptTokensDetails'], fromToolUsePromptTokensDetails);
|
|
5118
|
+
});
|
|
5396
5119
|
}
|
|
5120
|
+
setValueByPath(toObject, ['toolUsePromptTokensDetails'], transformedList);
|
|
5397
5121
|
}
|
|
5398
5122
|
const fromTrafficType = getValueByPath(fromObject, ['trafficType']);
|
|
5399
5123
|
if (fromTrafficType != null) {
|
|
@@ -5592,14 +5316,13 @@ function contentToMldev(apiClient, fromObject) {
|
|
|
5592
5316
|
const toObject = {};
|
|
5593
5317
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
5594
5318
|
if (fromParts != null) {
|
|
5595
|
-
|
|
5596
|
-
|
|
5319
|
+
let transformedList = fromParts;
|
|
5320
|
+
if (Array.isArray(transformedList)) {
|
|
5321
|
+
transformedList = transformedList.map((item) => {
|
|
5597
5322
|
return partToMldev(apiClient, item);
|
|
5598
|
-
})
|
|
5599
|
-
}
|
|
5600
|
-
else {
|
|
5601
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
5323
|
+
});
|
|
5602
5324
|
}
|
|
5325
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
5603
5326
|
}
|
|
5604
5327
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
5605
5328
|
if (fromRole != null) {
|
|
@@ -5607,93 +5330,6 @@ function contentToMldev(apiClient, fromObject) {
|
|
|
5607
5330
|
}
|
|
5608
5331
|
return toObject;
|
|
5609
5332
|
}
|
|
5610
|
-
function schemaToMldev(apiClient, fromObject) {
|
|
5611
|
-
const toObject = {};
|
|
5612
|
-
if (getValueByPath(fromObject, ['example']) !== undefined) {
|
|
5613
|
-
throw new Error('example parameter is not supported in Gemini API.');
|
|
5614
|
-
}
|
|
5615
|
-
if (getValueByPath(fromObject, ['pattern']) !== undefined) {
|
|
5616
|
-
throw new Error('pattern parameter is not supported in Gemini API.');
|
|
5617
|
-
}
|
|
5618
|
-
if (getValueByPath(fromObject, ['default']) !== undefined) {
|
|
5619
|
-
throw new Error('default parameter is not supported in Gemini API.');
|
|
5620
|
-
}
|
|
5621
|
-
if (getValueByPath(fromObject, ['maxLength']) !== undefined) {
|
|
5622
|
-
throw new Error('maxLength parameter is not supported in Gemini API.');
|
|
5623
|
-
}
|
|
5624
|
-
if (getValueByPath(fromObject, ['minLength']) !== undefined) {
|
|
5625
|
-
throw new Error('minLength parameter is not supported in Gemini API.');
|
|
5626
|
-
}
|
|
5627
|
-
if (getValueByPath(fromObject, ['minProperties']) !== undefined) {
|
|
5628
|
-
throw new Error('minProperties parameter is not supported in Gemini API.');
|
|
5629
|
-
}
|
|
5630
|
-
if (getValueByPath(fromObject, ['maxProperties']) !== undefined) {
|
|
5631
|
-
throw new Error('maxProperties parameter is not supported in Gemini API.');
|
|
5632
|
-
}
|
|
5633
|
-
const fromAnyOf = getValueByPath(fromObject, ['anyOf']);
|
|
5634
|
-
if (fromAnyOf != null) {
|
|
5635
|
-
setValueByPath(toObject, ['anyOf'], fromAnyOf);
|
|
5636
|
-
}
|
|
5637
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
5638
|
-
if (fromDescription != null) {
|
|
5639
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
5640
|
-
}
|
|
5641
|
-
const fromEnum = getValueByPath(fromObject, ['enum']);
|
|
5642
|
-
if (fromEnum != null) {
|
|
5643
|
-
setValueByPath(toObject, ['enum'], fromEnum);
|
|
5644
|
-
}
|
|
5645
|
-
const fromFormat = getValueByPath(fromObject, ['format']);
|
|
5646
|
-
if (fromFormat != null) {
|
|
5647
|
-
setValueByPath(toObject, ['format'], fromFormat);
|
|
5648
|
-
}
|
|
5649
|
-
const fromItems = getValueByPath(fromObject, ['items']);
|
|
5650
|
-
if (fromItems != null) {
|
|
5651
|
-
setValueByPath(toObject, ['items'], fromItems);
|
|
5652
|
-
}
|
|
5653
|
-
const fromMaxItems = getValueByPath(fromObject, ['maxItems']);
|
|
5654
|
-
if (fromMaxItems != null) {
|
|
5655
|
-
setValueByPath(toObject, ['maxItems'], fromMaxItems);
|
|
5656
|
-
}
|
|
5657
|
-
const fromMaximum = getValueByPath(fromObject, ['maximum']);
|
|
5658
|
-
if (fromMaximum != null) {
|
|
5659
|
-
setValueByPath(toObject, ['maximum'], fromMaximum);
|
|
5660
|
-
}
|
|
5661
|
-
const fromMinItems = getValueByPath(fromObject, ['minItems']);
|
|
5662
|
-
if (fromMinItems != null) {
|
|
5663
|
-
setValueByPath(toObject, ['minItems'], fromMinItems);
|
|
5664
|
-
}
|
|
5665
|
-
const fromMinimum = getValueByPath(fromObject, ['minimum']);
|
|
5666
|
-
if (fromMinimum != null) {
|
|
5667
|
-
setValueByPath(toObject, ['minimum'], fromMinimum);
|
|
5668
|
-
}
|
|
5669
|
-
const fromNullable = getValueByPath(fromObject, ['nullable']);
|
|
5670
|
-
if (fromNullable != null) {
|
|
5671
|
-
setValueByPath(toObject, ['nullable'], fromNullable);
|
|
5672
|
-
}
|
|
5673
|
-
const fromProperties = getValueByPath(fromObject, ['properties']);
|
|
5674
|
-
if (fromProperties != null) {
|
|
5675
|
-
setValueByPath(toObject, ['properties'], fromProperties);
|
|
5676
|
-
}
|
|
5677
|
-
const fromPropertyOrdering = getValueByPath(fromObject, [
|
|
5678
|
-
'propertyOrdering',
|
|
5679
|
-
]);
|
|
5680
|
-
if (fromPropertyOrdering != null) {
|
|
5681
|
-
setValueByPath(toObject, ['propertyOrdering'], fromPropertyOrdering);
|
|
5682
|
-
}
|
|
5683
|
-
const fromRequired = getValueByPath(fromObject, ['required']);
|
|
5684
|
-
if (fromRequired != null) {
|
|
5685
|
-
setValueByPath(toObject, ['required'], fromRequired);
|
|
5686
|
-
}
|
|
5687
|
-
const fromTitle = getValueByPath(fromObject, ['title']);
|
|
5688
|
-
if (fromTitle != null) {
|
|
5689
|
-
setValueByPath(toObject, ['title'], fromTitle);
|
|
5690
|
-
}
|
|
5691
|
-
const fromType = getValueByPath(fromObject, ['type']);
|
|
5692
|
-
if (fromType != null) {
|
|
5693
|
-
setValueByPath(toObject, ['type'], fromType);
|
|
5694
|
-
}
|
|
5695
|
-
return toObject;
|
|
5696
|
-
}
|
|
5697
5333
|
function safetySettingToMldev(apiClient, fromObject) {
|
|
5698
5334
|
const toObject = {};
|
|
5699
5335
|
if (getValueByPath(fromObject, ['method']) !== undefined) {
|
|
@@ -5709,25 +5345,6 @@ function safetySettingToMldev(apiClient, fromObject) {
|
|
|
5709
5345
|
}
|
|
5710
5346
|
return toObject;
|
|
5711
5347
|
}
|
|
5712
|
-
function functionDeclarationToMldev(apiClient, fromObject) {
|
|
5713
|
-
const toObject = {};
|
|
5714
|
-
if (getValueByPath(fromObject, ['response']) !== undefined) {
|
|
5715
|
-
throw new Error('response parameter is not supported in Gemini API.');
|
|
5716
|
-
}
|
|
5717
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
5718
|
-
if (fromDescription != null) {
|
|
5719
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
5720
|
-
}
|
|
5721
|
-
const fromName = getValueByPath(fromObject, ['name']);
|
|
5722
|
-
if (fromName != null) {
|
|
5723
|
-
setValueByPath(toObject, ['name'], fromName);
|
|
5724
|
-
}
|
|
5725
|
-
const fromParameters = getValueByPath(fromObject, ['parameters']);
|
|
5726
|
-
if (fromParameters != null) {
|
|
5727
|
-
setValueByPath(toObject, ['parameters'], fromParameters);
|
|
5728
|
-
}
|
|
5729
|
-
return toObject;
|
|
5730
|
-
}
|
|
5731
5348
|
function googleSearchToMldev() {
|
|
5732
5349
|
const toObject = {};
|
|
5733
5350
|
return toObject;
|
|
@@ -5758,19 +5375,6 @@ function googleSearchRetrievalToMldev(apiClient, fromObject) {
|
|
|
5758
5375
|
}
|
|
5759
5376
|
function toolToMldev(apiClient, fromObject) {
|
|
5760
5377
|
const toObject = {};
|
|
5761
|
-
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
5762
|
-
'functionDeclarations',
|
|
5763
|
-
]);
|
|
5764
|
-
if (fromFunctionDeclarations != null) {
|
|
5765
|
-
if (Array.isArray(fromFunctionDeclarations)) {
|
|
5766
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations.map((item) => {
|
|
5767
|
-
return functionDeclarationToMldev(apiClient, item);
|
|
5768
|
-
}));
|
|
5769
|
-
}
|
|
5770
|
-
else {
|
|
5771
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
5772
|
-
}
|
|
5773
|
-
}
|
|
5774
5378
|
if (getValueByPath(fromObject, ['retrieval']) !== undefined) {
|
|
5775
5379
|
throw new Error('retrieval parameter is not supported in Gemini API.');
|
|
5776
5380
|
}
|
|
@@ -5790,6 +5394,12 @@ function toolToMldev(apiClient, fromObject) {
|
|
|
5790
5394
|
if (fromCodeExecution != null) {
|
|
5791
5395
|
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
5792
5396
|
}
|
|
5397
|
+
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
5398
|
+
'functionDeclarations',
|
|
5399
|
+
]);
|
|
5400
|
+
if (fromFunctionDeclarations != null) {
|
|
5401
|
+
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
5402
|
+
}
|
|
5793
5403
|
return toObject;
|
|
5794
5404
|
}
|
|
5795
5405
|
function functionCallingConfigToMldev(apiClient, fromObject) {
|
|
@@ -5936,7 +5546,7 @@ function generateContentConfigToMldev(apiClient, fromObject, parentObject) {
|
|
|
5936
5546
|
'responseSchema',
|
|
5937
5547
|
]);
|
|
5938
5548
|
if (fromResponseSchema != null) {
|
|
5939
|
-
setValueByPath(toObject, ['responseSchema'],
|
|
5549
|
+
setValueByPath(toObject, ['responseSchema'], tSchema(apiClient, fromResponseSchema));
|
|
5940
5550
|
}
|
|
5941
5551
|
if (getValueByPath(fromObject, ['routingConfig']) !== undefined) {
|
|
5942
5552
|
throw new Error('routingConfig parameter is not supported in Gemini API.');
|
|
@@ -5948,25 +5558,23 @@ function generateContentConfigToMldev(apiClient, fromObject, parentObject) {
|
|
|
5948
5558
|
'safetySettings',
|
|
5949
5559
|
]);
|
|
5950
5560
|
if (parentObject !== undefined && fromSafetySettings != null) {
|
|
5951
|
-
|
|
5952
|
-
|
|
5561
|
+
let transformedList = fromSafetySettings;
|
|
5562
|
+
if (Array.isArray(transformedList)) {
|
|
5563
|
+
transformedList = transformedList.map((item) => {
|
|
5953
5564
|
return safetySettingToMldev(apiClient, item);
|
|
5954
|
-
})
|
|
5955
|
-
}
|
|
5956
|
-
else {
|
|
5957
|
-
setValueByPath(parentObject, ['safetySettings'], fromSafetySettings);
|
|
5565
|
+
});
|
|
5958
5566
|
}
|
|
5567
|
+
setValueByPath(parentObject, ['safetySettings'], transformedList);
|
|
5959
5568
|
}
|
|
5960
5569
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
5961
5570
|
if (parentObject !== undefined && fromTools != null) {
|
|
5962
|
-
|
|
5963
|
-
|
|
5571
|
+
let transformedList = tTools(apiClient, fromTools);
|
|
5572
|
+
if (Array.isArray(transformedList)) {
|
|
5573
|
+
transformedList = transformedList.map((item) => {
|
|
5964
5574
|
return toolToMldev(apiClient, tTool(apiClient, item));
|
|
5965
|
-
})
|
|
5966
|
-
}
|
|
5967
|
-
else {
|
|
5968
|
-
setValueByPath(parentObject, ['tools'], tTools(apiClient, fromTools));
|
|
5575
|
+
});
|
|
5969
5576
|
}
|
|
5577
|
+
setValueByPath(parentObject, ['tools'], transformedList);
|
|
5970
5578
|
}
|
|
5971
5579
|
const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
|
|
5972
5580
|
if (parentObject !== undefined && fromToolConfig != null) {
|
|
@@ -6016,14 +5624,13 @@ function generateContentParametersToMldev(apiClient, fromObject) {
|
|
|
6016
5624
|
}
|
|
6017
5625
|
const fromContents = getValueByPath(fromObject, ['contents']);
|
|
6018
5626
|
if (fromContents != null) {
|
|
6019
|
-
|
|
6020
|
-
|
|
5627
|
+
let transformedList = tContents(apiClient, fromContents);
|
|
5628
|
+
if (Array.isArray(transformedList)) {
|
|
5629
|
+
transformedList = transformedList.map((item) => {
|
|
6021
5630
|
return contentToMldev(apiClient, item);
|
|
6022
|
-
})
|
|
6023
|
-
}
|
|
6024
|
-
else {
|
|
6025
|
-
setValueByPath(toObject, ['contents'], tContents(apiClient, fromContents));
|
|
5631
|
+
});
|
|
6026
5632
|
}
|
|
5633
|
+
setValueByPath(toObject, ['contents'], transformedList);
|
|
6027
5634
|
}
|
|
6028
5635
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
6029
5636
|
if (fromConfig != null) {
|
|
@@ -6178,6 +5785,42 @@ function getModelParametersToMldev(apiClient, fromObject) {
|
|
|
6178
5785
|
}
|
|
6179
5786
|
return toObject;
|
|
6180
5787
|
}
|
|
5788
|
+
function updateModelConfigToMldev(apiClient, fromObject, parentObject) {
|
|
5789
|
+
const toObject = {};
|
|
5790
|
+
const fromDisplayName = getValueByPath(fromObject, ['displayName']);
|
|
5791
|
+
if (parentObject !== undefined && fromDisplayName != null) {
|
|
5792
|
+
setValueByPath(parentObject, ['displayName'], fromDisplayName);
|
|
5793
|
+
}
|
|
5794
|
+
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
5795
|
+
if (parentObject !== undefined && fromDescription != null) {
|
|
5796
|
+
setValueByPath(parentObject, ['description'], fromDescription);
|
|
5797
|
+
}
|
|
5798
|
+
return toObject;
|
|
5799
|
+
}
|
|
5800
|
+
function updateModelParametersToMldev(apiClient, fromObject) {
|
|
5801
|
+
const toObject = {};
|
|
5802
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
5803
|
+
if (fromModel != null) {
|
|
5804
|
+
setValueByPath(toObject, ['_url', 'name'], tModel(apiClient, fromModel));
|
|
5805
|
+
}
|
|
5806
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
5807
|
+
if (fromConfig != null) {
|
|
5808
|
+
setValueByPath(toObject, ['config'], updateModelConfigToMldev(apiClient, fromConfig, toObject));
|
|
5809
|
+
}
|
|
5810
|
+
return toObject;
|
|
5811
|
+
}
|
|
5812
|
+
function deleteModelParametersToMldev(apiClient, fromObject) {
|
|
5813
|
+
const toObject = {};
|
|
5814
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
5815
|
+
if (fromModel != null) {
|
|
5816
|
+
setValueByPath(toObject, ['_url', 'name'], tModel(apiClient, fromModel));
|
|
5817
|
+
}
|
|
5818
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
5819
|
+
if (fromConfig != null) {
|
|
5820
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
5821
|
+
}
|
|
5822
|
+
return toObject;
|
|
5823
|
+
}
|
|
6181
5824
|
function countTokensConfigToMldev(apiClient, fromObject) {
|
|
6182
5825
|
const toObject = {};
|
|
6183
5826
|
if (getValueByPath(fromObject, ['systemInstruction']) !== undefined) {
|
|
@@ -6199,14 +5842,13 @@ function countTokensParametersToMldev(apiClient, fromObject) {
|
|
|
6199
5842
|
}
|
|
6200
5843
|
const fromContents = getValueByPath(fromObject, ['contents']);
|
|
6201
5844
|
if (fromContents != null) {
|
|
6202
|
-
|
|
6203
|
-
|
|
5845
|
+
let transformedList = tContents(apiClient, fromContents);
|
|
5846
|
+
if (Array.isArray(transformedList)) {
|
|
5847
|
+
transformedList = transformedList.map((item) => {
|
|
6204
5848
|
return contentToMldev(apiClient, item);
|
|
6205
|
-
})
|
|
6206
|
-
}
|
|
6207
|
-
else {
|
|
6208
|
-
setValueByPath(toObject, ['contents'], tContents(apiClient, fromContents));
|
|
5849
|
+
});
|
|
6209
5850
|
}
|
|
5851
|
+
setValueByPath(toObject, ['contents'], transformedList);
|
|
6210
5852
|
}
|
|
6211
5853
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
6212
5854
|
if (fromConfig != null) {
|
|
@@ -6351,14 +5993,13 @@ function contentToVertex(apiClient, fromObject) {
|
|
|
6351
5993
|
const toObject = {};
|
|
6352
5994
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
6353
5995
|
if (fromParts != null) {
|
|
6354
|
-
|
|
6355
|
-
|
|
5996
|
+
let transformedList = fromParts;
|
|
5997
|
+
if (Array.isArray(transformedList)) {
|
|
5998
|
+
transformedList = transformedList.map((item) => {
|
|
6356
5999
|
return partToVertex(apiClient, item);
|
|
6357
|
-
})
|
|
6358
|
-
}
|
|
6359
|
-
else {
|
|
6360
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
6000
|
+
});
|
|
6361
6001
|
}
|
|
6002
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
6362
6003
|
}
|
|
6363
6004
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
6364
6005
|
if (fromRole != null) {
|
|
@@ -6366,104 +6007,6 @@ function contentToVertex(apiClient, fromObject) {
|
|
|
6366
6007
|
}
|
|
6367
6008
|
return toObject;
|
|
6368
6009
|
}
|
|
6369
|
-
function schemaToVertex(apiClient, fromObject) {
|
|
6370
|
-
const toObject = {};
|
|
6371
|
-
const fromExample = getValueByPath(fromObject, ['example']);
|
|
6372
|
-
if (fromExample != null) {
|
|
6373
|
-
setValueByPath(toObject, ['example'], fromExample);
|
|
6374
|
-
}
|
|
6375
|
-
const fromPattern = getValueByPath(fromObject, ['pattern']);
|
|
6376
|
-
if (fromPattern != null) {
|
|
6377
|
-
setValueByPath(toObject, ['pattern'], fromPattern);
|
|
6378
|
-
}
|
|
6379
|
-
const fromDefault = getValueByPath(fromObject, ['default']);
|
|
6380
|
-
if (fromDefault != null) {
|
|
6381
|
-
setValueByPath(toObject, ['default'], fromDefault);
|
|
6382
|
-
}
|
|
6383
|
-
const fromMaxLength = getValueByPath(fromObject, ['maxLength']);
|
|
6384
|
-
if (fromMaxLength != null) {
|
|
6385
|
-
setValueByPath(toObject, ['maxLength'], fromMaxLength);
|
|
6386
|
-
}
|
|
6387
|
-
const fromMinLength = getValueByPath(fromObject, ['minLength']);
|
|
6388
|
-
if (fromMinLength != null) {
|
|
6389
|
-
setValueByPath(toObject, ['minLength'], fromMinLength);
|
|
6390
|
-
}
|
|
6391
|
-
const fromMinProperties = getValueByPath(fromObject, [
|
|
6392
|
-
'minProperties',
|
|
6393
|
-
]);
|
|
6394
|
-
if (fromMinProperties != null) {
|
|
6395
|
-
setValueByPath(toObject, ['minProperties'], fromMinProperties);
|
|
6396
|
-
}
|
|
6397
|
-
const fromMaxProperties = getValueByPath(fromObject, [
|
|
6398
|
-
'maxProperties',
|
|
6399
|
-
]);
|
|
6400
|
-
if (fromMaxProperties != null) {
|
|
6401
|
-
setValueByPath(toObject, ['maxProperties'], fromMaxProperties);
|
|
6402
|
-
}
|
|
6403
|
-
const fromAnyOf = getValueByPath(fromObject, ['anyOf']);
|
|
6404
|
-
if (fromAnyOf != null) {
|
|
6405
|
-
setValueByPath(toObject, ['anyOf'], fromAnyOf);
|
|
6406
|
-
}
|
|
6407
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
6408
|
-
if (fromDescription != null) {
|
|
6409
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
6410
|
-
}
|
|
6411
|
-
const fromEnum = getValueByPath(fromObject, ['enum']);
|
|
6412
|
-
if (fromEnum != null) {
|
|
6413
|
-
setValueByPath(toObject, ['enum'], fromEnum);
|
|
6414
|
-
}
|
|
6415
|
-
const fromFormat = getValueByPath(fromObject, ['format']);
|
|
6416
|
-
if (fromFormat != null) {
|
|
6417
|
-
setValueByPath(toObject, ['format'], fromFormat);
|
|
6418
|
-
}
|
|
6419
|
-
const fromItems = getValueByPath(fromObject, ['items']);
|
|
6420
|
-
if (fromItems != null) {
|
|
6421
|
-
setValueByPath(toObject, ['items'], fromItems);
|
|
6422
|
-
}
|
|
6423
|
-
const fromMaxItems = getValueByPath(fromObject, ['maxItems']);
|
|
6424
|
-
if (fromMaxItems != null) {
|
|
6425
|
-
setValueByPath(toObject, ['maxItems'], fromMaxItems);
|
|
6426
|
-
}
|
|
6427
|
-
const fromMaximum = getValueByPath(fromObject, ['maximum']);
|
|
6428
|
-
if (fromMaximum != null) {
|
|
6429
|
-
setValueByPath(toObject, ['maximum'], fromMaximum);
|
|
6430
|
-
}
|
|
6431
|
-
const fromMinItems = getValueByPath(fromObject, ['minItems']);
|
|
6432
|
-
if (fromMinItems != null) {
|
|
6433
|
-
setValueByPath(toObject, ['minItems'], fromMinItems);
|
|
6434
|
-
}
|
|
6435
|
-
const fromMinimum = getValueByPath(fromObject, ['minimum']);
|
|
6436
|
-
if (fromMinimum != null) {
|
|
6437
|
-
setValueByPath(toObject, ['minimum'], fromMinimum);
|
|
6438
|
-
}
|
|
6439
|
-
const fromNullable = getValueByPath(fromObject, ['nullable']);
|
|
6440
|
-
if (fromNullable != null) {
|
|
6441
|
-
setValueByPath(toObject, ['nullable'], fromNullable);
|
|
6442
|
-
}
|
|
6443
|
-
const fromProperties = getValueByPath(fromObject, ['properties']);
|
|
6444
|
-
if (fromProperties != null) {
|
|
6445
|
-
setValueByPath(toObject, ['properties'], fromProperties);
|
|
6446
|
-
}
|
|
6447
|
-
const fromPropertyOrdering = getValueByPath(fromObject, [
|
|
6448
|
-
'propertyOrdering',
|
|
6449
|
-
]);
|
|
6450
|
-
if (fromPropertyOrdering != null) {
|
|
6451
|
-
setValueByPath(toObject, ['propertyOrdering'], fromPropertyOrdering);
|
|
6452
|
-
}
|
|
6453
|
-
const fromRequired = getValueByPath(fromObject, ['required']);
|
|
6454
|
-
if (fromRequired != null) {
|
|
6455
|
-
setValueByPath(toObject, ['required'], fromRequired);
|
|
6456
|
-
}
|
|
6457
|
-
const fromTitle = getValueByPath(fromObject, ['title']);
|
|
6458
|
-
if (fromTitle != null) {
|
|
6459
|
-
setValueByPath(toObject, ['title'], fromTitle);
|
|
6460
|
-
}
|
|
6461
|
-
const fromType = getValueByPath(fromObject, ['type']);
|
|
6462
|
-
if (fromType != null) {
|
|
6463
|
-
setValueByPath(toObject, ['type'], fromType);
|
|
6464
|
-
}
|
|
6465
|
-
return toObject;
|
|
6466
|
-
}
|
|
6467
6010
|
function modelSelectionConfigToVertex(apiClient, fromObject) {
|
|
6468
6011
|
const toObject = {};
|
|
6469
6012
|
const fromFeatureSelectionPreference = getValueByPath(fromObject, [
|
|
@@ -6490,26 +6033,6 @@ function safetySettingToVertex(apiClient, fromObject) {
|
|
|
6490
6033
|
}
|
|
6491
6034
|
return toObject;
|
|
6492
6035
|
}
|
|
6493
|
-
function functionDeclarationToVertex(apiClient, fromObject) {
|
|
6494
|
-
const toObject = {};
|
|
6495
|
-
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
6496
|
-
if (fromResponse != null) {
|
|
6497
|
-
setValueByPath(toObject, ['response'], schemaToVertex(apiClient, fromResponse));
|
|
6498
|
-
}
|
|
6499
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
6500
|
-
if (fromDescription != null) {
|
|
6501
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
6502
|
-
}
|
|
6503
|
-
const fromName = getValueByPath(fromObject, ['name']);
|
|
6504
|
-
if (fromName != null) {
|
|
6505
|
-
setValueByPath(toObject, ['name'], fromName);
|
|
6506
|
-
}
|
|
6507
|
-
const fromParameters = getValueByPath(fromObject, ['parameters']);
|
|
6508
|
-
if (fromParameters != null) {
|
|
6509
|
-
setValueByPath(toObject, ['parameters'], fromParameters);
|
|
6510
|
-
}
|
|
6511
|
-
return toObject;
|
|
6512
|
-
}
|
|
6513
6036
|
function googleSearchToVertex() {
|
|
6514
6037
|
const toObject = {};
|
|
6515
6038
|
return toObject;
|
|
@@ -6540,19 +6063,6 @@ function googleSearchRetrievalToVertex(apiClient, fromObject) {
|
|
|
6540
6063
|
}
|
|
6541
6064
|
function toolToVertex(apiClient, fromObject) {
|
|
6542
6065
|
const toObject = {};
|
|
6543
|
-
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
6544
|
-
'functionDeclarations',
|
|
6545
|
-
]);
|
|
6546
|
-
if (fromFunctionDeclarations != null) {
|
|
6547
|
-
if (Array.isArray(fromFunctionDeclarations)) {
|
|
6548
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations.map((item) => {
|
|
6549
|
-
return functionDeclarationToVertex(apiClient, item);
|
|
6550
|
-
}));
|
|
6551
|
-
}
|
|
6552
|
-
else {
|
|
6553
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
6554
|
-
}
|
|
6555
|
-
}
|
|
6556
6066
|
const fromRetrieval = getValueByPath(fromObject, ['retrieval']);
|
|
6557
6067
|
if (fromRetrieval != null) {
|
|
6558
6068
|
setValueByPath(toObject, ['retrieval'], fromRetrieval);
|
|
@@ -6573,6 +6083,12 @@ function toolToVertex(apiClient, fromObject) {
|
|
|
6573
6083
|
if (fromCodeExecution != null) {
|
|
6574
6084
|
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
6575
6085
|
}
|
|
6086
|
+
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
6087
|
+
'functionDeclarations',
|
|
6088
|
+
]);
|
|
6089
|
+
if (fromFunctionDeclarations != null) {
|
|
6090
|
+
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
6091
|
+
}
|
|
6576
6092
|
return toObject;
|
|
6577
6093
|
}
|
|
6578
6094
|
function functionCallingConfigToVertex(apiClient, fromObject) {
|
|
@@ -6719,7 +6235,7 @@ function generateContentConfigToVertex(apiClient, fromObject, parentObject) {
|
|
|
6719
6235
|
'responseSchema',
|
|
6720
6236
|
]);
|
|
6721
6237
|
if (fromResponseSchema != null) {
|
|
6722
|
-
setValueByPath(toObject, ['responseSchema'],
|
|
6238
|
+
setValueByPath(toObject, ['responseSchema'], tSchema(apiClient, fromResponseSchema));
|
|
6723
6239
|
}
|
|
6724
6240
|
const fromRoutingConfig = getValueByPath(fromObject, [
|
|
6725
6241
|
'routingConfig',
|
|
@@ -6737,25 +6253,23 @@ function generateContentConfigToVertex(apiClient, fromObject, parentObject) {
|
|
|
6737
6253
|
'safetySettings',
|
|
6738
6254
|
]);
|
|
6739
6255
|
if (parentObject !== undefined && fromSafetySettings != null) {
|
|
6740
|
-
|
|
6741
|
-
|
|
6256
|
+
let transformedList = fromSafetySettings;
|
|
6257
|
+
if (Array.isArray(transformedList)) {
|
|
6258
|
+
transformedList = transformedList.map((item) => {
|
|
6742
6259
|
return safetySettingToVertex(apiClient, item);
|
|
6743
|
-
})
|
|
6744
|
-
}
|
|
6745
|
-
else {
|
|
6746
|
-
setValueByPath(parentObject, ['safetySettings'], fromSafetySettings);
|
|
6260
|
+
});
|
|
6747
6261
|
}
|
|
6262
|
+
setValueByPath(parentObject, ['safetySettings'], transformedList);
|
|
6748
6263
|
}
|
|
6749
6264
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
6750
6265
|
if (parentObject !== undefined && fromTools != null) {
|
|
6751
|
-
|
|
6752
|
-
|
|
6266
|
+
let transformedList = tTools(apiClient, fromTools);
|
|
6267
|
+
if (Array.isArray(transformedList)) {
|
|
6268
|
+
transformedList = transformedList.map((item) => {
|
|
6753
6269
|
return toolToVertex(apiClient, tTool(apiClient, item));
|
|
6754
|
-
})
|
|
6755
|
-
}
|
|
6756
|
-
else {
|
|
6757
|
-
setValueByPath(parentObject, ['tools'], tTools(apiClient, fromTools));
|
|
6270
|
+
});
|
|
6758
6271
|
}
|
|
6272
|
+
setValueByPath(parentObject, ['tools'], transformedList);
|
|
6759
6273
|
}
|
|
6760
6274
|
const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
|
|
6761
6275
|
if (parentObject !== undefined && fromToolConfig != null) {
|
|
@@ -6809,14 +6323,13 @@ function generateContentParametersToVertex(apiClient, fromObject) {
|
|
|
6809
6323
|
}
|
|
6810
6324
|
const fromContents = getValueByPath(fromObject, ['contents']);
|
|
6811
6325
|
if (fromContents != null) {
|
|
6812
|
-
|
|
6813
|
-
|
|
6326
|
+
let transformedList = tContents(apiClient, fromContents);
|
|
6327
|
+
if (Array.isArray(transformedList)) {
|
|
6328
|
+
transformedList = transformedList.map((item) => {
|
|
6814
6329
|
return contentToVertex(apiClient, item);
|
|
6815
|
-
})
|
|
6816
|
-
}
|
|
6817
|
-
else {
|
|
6818
|
-
setValueByPath(toObject, ['contents'], tContents(apiClient, fromContents));
|
|
6330
|
+
});
|
|
6819
6331
|
}
|
|
6332
|
+
setValueByPath(toObject, ['contents'], transformedList);
|
|
6820
6333
|
}
|
|
6821
6334
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
6822
6335
|
if (fromConfig != null) {
|
|
@@ -6978,6 +6491,42 @@ function getModelParametersToVertex(apiClient, fromObject) {
|
|
|
6978
6491
|
}
|
|
6979
6492
|
return toObject;
|
|
6980
6493
|
}
|
|
6494
|
+
function updateModelConfigToVertex(apiClient, fromObject, parentObject) {
|
|
6495
|
+
const toObject = {};
|
|
6496
|
+
const fromDisplayName = getValueByPath(fromObject, ['displayName']);
|
|
6497
|
+
if (parentObject !== undefined && fromDisplayName != null) {
|
|
6498
|
+
setValueByPath(parentObject, ['displayName'], fromDisplayName);
|
|
6499
|
+
}
|
|
6500
|
+
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
6501
|
+
if (parentObject !== undefined && fromDescription != null) {
|
|
6502
|
+
setValueByPath(parentObject, ['description'], fromDescription);
|
|
6503
|
+
}
|
|
6504
|
+
return toObject;
|
|
6505
|
+
}
|
|
6506
|
+
function updateModelParametersToVertex(apiClient, fromObject) {
|
|
6507
|
+
const toObject = {};
|
|
6508
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
6509
|
+
if (fromModel != null) {
|
|
6510
|
+
setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
|
|
6511
|
+
}
|
|
6512
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
6513
|
+
if (fromConfig != null) {
|
|
6514
|
+
setValueByPath(toObject, ['config'], updateModelConfigToVertex(apiClient, fromConfig, toObject));
|
|
6515
|
+
}
|
|
6516
|
+
return toObject;
|
|
6517
|
+
}
|
|
6518
|
+
function deleteModelParametersToVertex(apiClient, fromObject) {
|
|
6519
|
+
const toObject = {};
|
|
6520
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
6521
|
+
if (fromModel != null) {
|
|
6522
|
+
setValueByPath(toObject, ['_url', 'name'], tModel(apiClient, fromModel));
|
|
6523
|
+
}
|
|
6524
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
6525
|
+
if (fromConfig != null) {
|
|
6526
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
6527
|
+
}
|
|
6528
|
+
return toObject;
|
|
6529
|
+
}
|
|
6981
6530
|
function countTokensConfigToVertex(apiClient, fromObject, parentObject) {
|
|
6982
6531
|
const toObject = {};
|
|
6983
6532
|
const fromSystemInstruction = getValueByPath(fromObject, [
|
|
@@ -6988,14 +6537,13 @@ function countTokensConfigToVertex(apiClient, fromObject, parentObject) {
|
|
|
6988
6537
|
}
|
|
6989
6538
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
6990
6539
|
if (parentObject !== undefined && fromTools != null) {
|
|
6991
|
-
|
|
6992
|
-
|
|
6540
|
+
let transformedList = fromTools;
|
|
6541
|
+
if (Array.isArray(transformedList)) {
|
|
6542
|
+
transformedList = transformedList.map((item) => {
|
|
6993
6543
|
return toolToVertex(apiClient, item);
|
|
6994
|
-
})
|
|
6995
|
-
}
|
|
6996
|
-
else {
|
|
6997
|
-
setValueByPath(parentObject, ['tools'], fromTools);
|
|
6544
|
+
});
|
|
6998
6545
|
}
|
|
6546
|
+
setValueByPath(parentObject, ['tools'], transformedList);
|
|
6999
6547
|
}
|
|
7000
6548
|
const fromGenerationConfig = getValueByPath(fromObject, [
|
|
7001
6549
|
'generationConfig',
|
|
@@ -7013,14 +6561,13 @@ function countTokensParametersToVertex(apiClient, fromObject) {
|
|
|
7013
6561
|
}
|
|
7014
6562
|
const fromContents = getValueByPath(fromObject, ['contents']);
|
|
7015
6563
|
if (fromContents != null) {
|
|
7016
|
-
|
|
7017
|
-
|
|
6564
|
+
let transformedList = tContents(apiClient, fromContents);
|
|
6565
|
+
if (Array.isArray(transformedList)) {
|
|
6566
|
+
transformedList = transformedList.map((item) => {
|
|
7018
6567
|
return contentToVertex(apiClient, item);
|
|
7019
|
-
})
|
|
7020
|
-
}
|
|
7021
|
-
else {
|
|
7022
|
-
setValueByPath(toObject, ['contents'], tContents(apiClient, fromContents));
|
|
6568
|
+
});
|
|
7023
6569
|
}
|
|
6570
|
+
setValueByPath(toObject, ['contents'], transformedList);
|
|
7024
6571
|
}
|
|
7025
6572
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
7026
6573
|
if (fromConfig != null) {
|
|
@@ -7036,14 +6583,13 @@ function computeTokensParametersToVertex(apiClient, fromObject) {
|
|
|
7036
6583
|
}
|
|
7037
6584
|
const fromContents = getValueByPath(fromObject, ['contents']);
|
|
7038
6585
|
if (fromContents != null) {
|
|
7039
|
-
|
|
7040
|
-
|
|
6586
|
+
let transformedList = tContents(apiClient, fromContents);
|
|
6587
|
+
if (Array.isArray(transformedList)) {
|
|
6588
|
+
transformedList = transformedList.map((item) => {
|
|
7041
6589
|
return contentToVertex(apiClient, item);
|
|
7042
|
-
})
|
|
7043
|
-
}
|
|
7044
|
-
else {
|
|
7045
|
-
setValueByPath(toObject, ['contents'], tContents(apiClient, fromContents));
|
|
6590
|
+
});
|
|
7046
6591
|
}
|
|
6592
|
+
setValueByPath(toObject, ['contents'], transformedList);
|
|
7047
6593
|
}
|
|
7048
6594
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
7049
6595
|
if (fromConfig != null) {
|
|
@@ -7191,14 +6737,13 @@ function contentFromMldev(apiClient, fromObject) {
|
|
|
7191
6737
|
const toObject = {};
|
|
7192
6738
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
7193
6739
|
if (fromParts != null) {
|
|
7194
|
-
|
|
7195
|
-
|
|
6740
|
+
let transformedList = fromParts;
|
|
6741
|
+
if (Array.isArray(transformedList)) {
|
|
6742
|
+
transformedList = transformedList.map((item) => {
|
|
7196
6743
|
return partFromMldev(apiClient, item);
|
|
7197
|
-
})
|
|
7198
|
-
}
|
|
7199
|
-
else {
|
|
7200
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
6744
|
+
});
|
|
7201
6745
|
}
|
|
6746
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
7202
6747
|
}
|
|
7203
6748
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
7204
6749
|
if (fromRole != null) {
|
|
@@ -7266,14 +6811,13 @@ function generateContentResponseFromMldev(apiClient, fromObject) {
|
|
|
7266
6811
|
const toObject = {};
|
|
7267
6812
|
const fromCandidates = getValueByPath(fromObject, ['candidates']);
|
|
7268
6813
|
if (fromCandidates != null) {
|
|
7269
|
-
|
|
7270
|
-
|
|
6814
|
+
let transformedList = fromCandidates;
|
|
6815
|
+
if (Array.isArray(transformedList)) {
|
|
6816
|
+
transformedList = transformedList.map((item) => {
|
|
7271
6817
|
return candidateFromMldev(apiClient, item);
|
|
7272
|
-
})
|
|
7273
|
-
}
|
|
7274
|
-
else {
|
|
7275
|
-
setValueByPath(toObject, ['candidates'], fromCandidates);
|
|
6818
|
+
});
|
|
7276
6819
|
}
|
|
6820
|
+
setValueByPath(toObject, ['candidates'], transformedList);
|
|
7277
6821
|
}
|
|
7278
6822
|
const fromModelVersion = getValueByPath(fromObject, ['modelVersion']);
|
|
7279
6823
|
if (fromModelVersion != null) {
|
|
@@ -7309,14 +6853,13 @@ function embedContentResponseFromMldev(apiClient, fromObject) {
|
|
|
7309
6853
|
const toObject = {};
|
|
7310
6854
|
const fromEmbeddings = getValueByPath(fromObject, ['embeddings']);
|
|
7311
6855
|
if (fromEmbeddings != null) {
|
|
7312
|
-
|
|
7313
|
-
|
|
6856
|
+
let transformedList = fromEmbeddings;
|
|
6857
|
+
if (Array.isArray(transformedList)) {
|
|
6858
|
+
transformedList = transformedList.map((item) => {
|
|
7314
6859
|
return contentEmbeddingFromMldev(apiClient, item);
|
|
7315
|
-
})
|
|
7316
|
-
}
|
|
7317
|
-
else {
|
|
7318
|
-
setValueByPath(toObject, ['embeddings'], fromEmbeddings);
|
|
6860
|
+
});
|
|
7319
6861
|
}
|
|
6862
|
+
setValueByPath(toObject, ['embeddings'], transformedList);
|
|
7320
6863
|
}
|
|
7321
6864
|
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
7322
6865
|
if (fromMetadata != null) {
|
|
@@ -7384,14 +6927,13 @@ function generateImagesResponseFromMldev(apiClient, fromObject) {
|
|
|
7384
6927
|
'predictions',
|
|
7385
6928
|
]);
|
|
7386
6929
|
if (fromGeneratedImages != null) {
|
|
7387
|
-
|
|
7388
|
-
|
|
6930
|
+
let transformedList = fromGeneratedImages;
|
|
6931
|
+
if (Array.isArray(transformedList)) {
|
|
6932
|
+
transformedList = transformedList.map((item) => {
|
|
7389
6933
|
return generatedImageFromMldev(apiClient, item);
|
|
7390
|
-
})
|
|
7391
|
-
}
|
|
7392
|
-
else {
|
|
7393
|
-
setValueByPath(toObject, ['generatedImages'], fromGeneratedImages);
|
|
6934
|
+
});
|
|
7394
6935
|
}
|
|
6936
|
+
setValueByPath(toObject, ['generatedImages'], transformedList);
|
|
7395
6937
|
}
|
|
7396
6938
|
const fromPositivePromptSafetyAttributes = getValueByPath(fromObject, [
|
|
7397
6939
|
'positivePromptSafetyAttributes',
|
|
@@ -7459,6 +7001,10 @@ function modelFromMldev(apiClient, fromObject) {
|
|
|
7459
7001
|
}
|
|
7460
7002
|
return toObject;
|
|
7461
7003
|
}
|
|
7004
|
+
function deleteModelResponseFromMldev() {
|
|
7005
|
+
const toObject = {};
|
|
7006
|
+
return toObject;
|
|
7007
|
+
}
|
|
7462
7008
|
function countTokensResponseFromMldev(apiClient, fromObject) {
|
|
7463
7009
|
const toObject = {};
|
|
7464
7010
|
const fromTotalTokens = getValueByPath(fromObject, ['totalTokens']);
|
|
@@ -7506,14 +7052,13 @@ function generateVideosResponseFromMldev$1(apiClient, fromObject) {
|
|
|
7506
7052
|
'generatedSamples',
|
|
7507
7053
|
]);
|
|
7508
7054
|
if (fromGeneratedVideos != null) {
|
|
7509
|
-
|
|
7510
|
-
|
|
7055
|
+
let transformedList = fromGeneratedVideos;
|
|
7056
|
+
if (Array.isArray(transformedList)) {
|
|
7057
|
+
transformedList = transformedList.map((item) => {
|
|
7511
7058
|
return generatedVideoFromMldev$1(apiClient, item);
|
|
7512
|
-
})
|
|
7513
|
-
}
|
|
7514
|
-
else {
|
|
7515
|
-
setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos);
|
|
7059
|
+
});
|
|
7516
7060
|
}
|
|
7061
|
+
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
7517
7062
|
}
|
|
7518
7063
|
const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
|
|
7519
7064
|
'raiMediaFilteredCount',
|
|
@@ -7608,14 +7153,13 @@ function contentFromVertex(apiClient, fromObject) {
|
|
|
7608
7153
|
const toObject = {};
|
|
7609
7154
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
7610
7155
|
if (fromParts != null) {
|
|
7611
|
-
|
|
7612
|
-
|
|
7156
|
+
let transformedList = fromParts;
|
|
7157
|
+
if (Array.isArray(transformedList)) {
|
|
7158
|
+
transformedList = transformedList.map((item) => {
|
|
7613
7159
|
return partFromVertex(apiClient, item);
|
|
7614
|
-
})
|
|
7615
|
-
}
|
|
7616
|
-
else {
|
|
7617
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
7160
|
+
});
|
|
7618
7161
|
}
|
|
7162
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
7619
7163
|
}
|
|
7620
7164
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
7621
7165
|
if (fromRole != null) {
|
|
@@ -7685,14 +7229,13 @@ function generateContentResponseFromVertex(apiClient, fromObject) {
|
|
|
7685
7229
|
const toObject = {};
|
|
7686
7230
|
const fromCandidates = getValueByPath(fromObject, ['candidates']);
|
|
7687
7231
|
if (fromCandidates != null) {
|
|
7688
|
-
|
|
7689
|
-
|
|
7232
|
+
let transformedList = fromCandidates;
|
|
7233
|
+
if (Array.isArray(transformedList)) {
|
|
7234
|
+
transformedList = transformedList.map((item) => {
|
|
7690
7235
|
return candidateFromVertex(apiClient, item);
|
|
7691
|
-
})
|
|
7692
|
-
}
|
|
7693
|
-
else {
|
|
7694
|
-
setValueByPath(toObject, ['candidates'], fromCandidates);
|
|
7236
|
+
});
|
|
7695
7237
|
}
|
|
7238
|
+
setValueByPath(toObject, ['candidates'], transformedList);
|
|
7696
7239
|
}
|
|
7697
7240
|
const fromCreateTime = getValueByPath(fromObject, ['createTime']);
|
|
7698
7241
|
if (fromCreateTime != null) {
|
|
@@ -7761,14 +7304,13 @@ function embedContentResponseFromVertex(apiClient, fromObject) {
|
|
|
7761
7304
|
'embeddings',
|
|
7762
7305
|
]);
|
|
7763
7306
|
if (fromEmbeddings != null) {
|
|
7764
|
-
|
|
7765
|
-
|
|
7307
|
+
let transformedList = fromEmbeddings;
|
|
7308
|
+
if (Array.isArray(transformedList)) {
|
|
7309
|
+
transformedList = transformedList.map((item) => {
|
|
7766
7310
|
return contentEmbeddingFromVertex(apiClient, item);
|
|
7767
|
-
})
|
|
7768
|
-
}
|
|
7769
|
-
else {
|
|
7770
|
-
setValueByPath(toObject, ['embeddings'], fromEmbeddings);
|
|
7311
|
+
});
|
|
7771
7312
|
}
|
|
7313
|
+
setValueByPath(toObject, ['embeddings'], transformedList);
|
|
7772
7314
|
}
|
|
7773
7315
|
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
7774
7316
|
if (fromMetadata != null) {
|
|
@@ -7844,14 +7386,13 @@ function generateImagesResponseFromVertex(apiClient, fromObject) {
|
|
|
7844
7386
|
'predictions',
|
|
7845
7387
|
]);
|
|
7846
7388
|
if (fromGeneratedImages != null) {
|
|
7847
|
-
|
|
7848
|
-
|
|
7389
|
+
let transformedList = fromGeneratedImages;
|
|
7390
|
+
if (Array.isArray(transformedList)) {
|
|
7391
|
+
transformedList = transformedList.map((item) => {
|
|
7849
7392
|
return generatedImageFromVertex(apiClient, item);
|
|
7850
|
-
})
|
|
7851
|
-
}
|
|
7852
|
-
else {
|
|
7853
|
-
setValueByPath(toObject, ['generatedImages'], fromGeneratedImages);
|
|
7393
|
+
});
|
|
7854
7394
|
}
|
|
7395
|
+
setValueByPath(toObject, ['generatedImages'], transformedList);
|
|
7855
7396
|
}
|
|
7856
7397
|
const fromPositivePromptSafetyAttributes = getValueByPath(fromObject, [
|
|
7857
7398
|
'positivePromptSafetyAttributes',
|
|
@@ -7914,14 +7455,13 @@ function modelFromVertex(apiClient, fromObject) {
|
|
|
7914
7455
|
}
|
|
7915
7456
|
const fromEndpoints = getValueByPath(fromObject, ['deployedModels']);
|
|
7916
7457
|
if (fromEndpoints != null) {
|
|
7917
|
-
|
|
7918
|
-
|
|
7458
|
+
let transformedList = fromEndpoints;
|
|
7459
|
+
if (Array.isArray(transformedList)) {
|
|
7460
|
+
transformedList = transformedList.map((item) => {
|
|
7919
7461
|
return endpointFromVertex(apiClient, item);
|
|
7920
|
-
})
|
|
7921
|
-
}
|
|
7922
|
-
else {
|
|
7923
|
-
setValueByPath(toObject, ['endpoints'], fromEndpoints);
|
|
7462
|
+
});
|
|
7924
7463
|
}
|
|
7464
|
+
setValueByPath(toObject, ['endpoints'], transformedList);
|
|
7925
7465
|
}
|
|
7926
7466
|
const fromLabels = getValueByPath(fromObject, ['labels']);
|
|
7927
7467
|
if (fromLabels != null) {
|
|
@@ -7933,6 +7473,10 @@ function modelFromVertex(apiClient, fromObject) {
|
|
|
7933
7473
|
}
|
|
7934
7474
|
return toObject;
|
|
7935
7475
|
}
|
|
7476
|
+
function deleteModelResponseFromVertex() {
|
|
7477
|
+
const toObject = {};
|
|
7478
|
+
return toObject;
|
|
7479
|
+
}
|
|
7936
7480
|
function countTokensResponseFromVertex(apiClient, fromObject) {
|
|
7937
7481
|
const toObject = {};
|
|
7938
7482
|
const fromTotalTokens = getValueByPath(fromObject, ['totalTokens']);
|
|
@@ -7979,14 +7523,13 @@ function generateVideosResponseFromVertex$1(apiClient, fromObject) {
|
|
|
7979
7523
|
const toObject = {};
|
|
7980
7524
|
const fromGeneratedVideos = getValueByPath(fromObject, ['videos']);
|
|
7981
7525
|
if (fromGeneratedVideos != null) {
|
|
7982
|
-
|
|
7983
|
-
|
|
7526
|
+
let transformedList = fromGeneratedVideos;
|
|
7527
|
+
if (Array.isArray(transformedList)) {
|
|
7528
|
+
transformedList = transformedList.map((item) => {
|
|
7984
7529
|
return generatedVideoFromVertex$1(apiClient, item);
|
|
7985
|
-
})
|
|
7986
|
-
}
|
|
7987
|
-
else {
|
|
7988
|
-
setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos);
|
|
7530
|
+
});
|
|
7989
7531
|
}
|
|
7532
|
+
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
7990
7533
|
}
|
|
7991
7534
|
const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
|
|
7992
7535
|
'raiMediaFilteredCount',
|
|
@@ -8929,6 +8472,146 @@ class Models extends BaseModule {
|
|
|
8929
8472
|
});
|
|
8930
8473
|
}
|
|
8931
8474
|
}
|
|
8475
|
+
/**
|
|
8476
|
+
* Updates a tuned model by its name.
|
|
8477
|
+
*
|
|
8478
|
+
* @param params - The parameters for updating the model.
|
|
8479
|
+
* @return The response from the API.
|
|
8480
|
+
*
|
|
8481
|
+
* @example
|
|
8482
|
+
* ```ts
|
|
8483
|
+
* const response = await ai.models.update({
|
|
8484
|
+
* model: 'tuned-model-name',
|
|
8485
|
+
* config: {
|
|
8486
|
+
* displayName: 'New display name',
|
|
8487
|
+
* description: 'New description',
|
|
8488
|
+
* },
|
|
8489
|
+
* });
|
|
8490
|
+
* ```
|
|
8491
|
+
*/
|
|
8492
|
+
async update(params) {
|
|
8493
|
+
var _a, _b, _c, _d;
|
|
8494
|
+
let response;
|
|
8495
|
+
let path = '';
|
|
8496
|
+
let queryParams = {};
|
|
8497
|
+
if (this.apiClient.isVertexAI()) {
|
|
8498
|
+
const body = updateModelParametersToVertex(this.apiClient, params);
|
|
8499
|
+
path = formatMap('{model}', body['_url']);
|
|
8500
|
+
queryParams = body['_query'];
|
|
8501
|
+
delete body['config'];
|
|
8502
|
+
delete body['_url'];
|
|
8503
|
+
delete body['_query'];
|
|
8504
|
+
response = this.apiClient
|
|
8505
|
+
.request({
|
|
8506
|
+
path: path,
|
|
8507
|
+
queryParams: queryParams,
|
|
8508
|
+
body: JSON.stringify(body),
|
|
8509
|
+
httpMethod: 'PATCH',
|
|
8510
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
8511
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
8512
|
+
})
|
|
8513
|
+
.then((httpResponse) => {
|
|
8514
|
+
return httpResponse.json();
|
|
8515
|
+
});
|
|
8516
|
+
return response.then((apiResponse) => {
|
|
8517
|
+
const resp = modelFromVertex(this.apiClient, apiResponse);
|
|
8518
|
+
return resp;
|
|
8519
|
+
});
|
|
8520
|
+
}
|
|
8521
|
+
else {
|
|
8522
|
+
const body = updateModelParametersToMldev(this.apiClient, params);
|
|
8523
|
+
path = formatMap('{name}', body['_url']);
|
|
8524
|
+
queryParams = body['_query'];
|
|
8525
|
+
delete body['config'];
|
|
8526
|
+
delete body['_url'];
|
|
8527
|
+
delete body['_query'];
|
|
8528
|
+
response = this.apiClient
|
|
8529
|
+
.request({
|
|
8530
|
+
path: path,
|
|
8531
|
+
queryParams: queryParams,
|
|
8532
|
+
body: JSON.stringify(body),
|
|
8533
|
+
httpMethod: 'PATCH',
|
|
8534
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
8535
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
8536
|
+
})
|
|
8537
|
+
.then((httpResponse) => {
|
|
8538
|
+
return httpResponse.json();
|
|
8539
|
+
});
|
|
8540
|
+
return response.then((apiResponse) => {
|
|
8541
|
+
const resp = modelFromMldev(this.apiClient, apiResponse);
|
|
8542
|
+
return resp;
|
|
8543
|
+
});
|
|
8544
|
+
}
|
|
8545
|
+
}
|
|
8546
|
+
/**
|
|
8547
|
+
* Deletes a tuned model by its name.
|
|
8548
|
+
*
|
|
8549
|
+
* @param params - The parameters for deleting the model.
|
|
8550
|
+
* @return The response from the API.
|
|
8551
|
+
*
|
|
8552
|
+
* @example
|
|
8553
|
+
* ```ts
|
|
8554
|
+
* const response = await ai.models.delete({model: 'tuned-model-name'});
|
|
8555
|
+
* ```
|
|
8556
|
+
*/
|
|
8557
|
+
async delete(params) {
|
|
8558
|
+
var _a, _b, _c, _d;
|
|
8559
|
+
let response;
|
|
8560
|
+
let path = '';
|
|
8561
|
+
let queryParams = {};
|
|
8562
|
+
if (this.apiClient.isVertexAI()) {
|
|
8563
|
+
const body = deleteModelParametersToVertex(this.apiClient, params);
|
|
8564
|
+
path = formatMap('{name}', body['_url']);
|
|
8565
|
+
queryParams = body['_query'];
|
|
8566
|
+
delete body['config'];
|
|
8567
|
+
delete body['_url'];
|
|
8568
|
+
delete body['_query'];
|
|
8569
|
+
response = this.apiClient
|
|
8570
|
+
.request({
|
|
8571
|
+
path: path,
|
|
8572
|
+
queryParams: queryParams,
|
|
8573
|
+
body: JSON.stringify(body),
|
|
8574
|
+
httpMethod: 'DELETE',
|
|
8575
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
8576
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
8577
|
+
})
|
|
8578
|
+
.then((httpResponse) => {
|
|
8579
|
+
return httpResponse.json();
|
|
8580
|
+
});
|
|
8581
|
+
return response.then(() => {
|
|
8582
|
+
const resp = deleteModelResponseFromVertex();
|
|
8583
|
+
const typedResp = new DeleteModelResponse();
|
|
8584
|
+
Object.assign(typedResp, resp);
|
|
8585
|
+
return typedResp;
|
|
8586
|
+
});
|
|
8587
|
+
}
|
|
8588
|
+
else {
|
|
8589
|
+
const body = deleteModelParametersToMldev(this.apiClient, params);
|
|
8590
|
+
path = formatMap('{name}', body['_url']);
|
|
8591
|
+
queryParams = body['_query'];
|
|
8592
|
+
delete body['config'];
|
|
8593
|
+
delete body['_url'];
|
|
8594
|
+
delete body['_query'];
|
|
8595
|
+
response = this.apiClient
|
|
8596
|
+
.request({
|
|
8597
|
+
path: path,
|
|
8598
|
+
queryParams: queryParams,
|
|
8599
|
+
body: JSON.stringify(body),
|
|
8600
|
+
httpMethod: 'DELETE',
|
|
8601
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
8602
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
8603
|
+
})
|
|
8604
|
+
.then((httpResponse) => {
|
|
8605
|
+
return httpResponse.json();
|
|
8606
|
+
});
|
|
8607
|
+
return response.then(() => {
|
|
8608
|
+
const resp = deleteModelResponseFromMldev();
|
|
8609
|
+
const typedResp = new DeleteModelResponse();
|
|
8610
|
+
Object.assign(typedResp, resp);
|
|
8611
|
+
return typedResp;
|
|
8612
|
+
});
|
|
8613
|
+
}
|
|
8614
|
+
}
|
|
8932
8615
|
/**
|
|
8933
8616
|
* Counts the number of tokens in the given contents. Multimodal input is
|
|
8934
8617
|
* supported for Gemini models.
|
|
@@ -9219,14 +8902,13 @@ function generateVideosResponseFromMldev(apiClient, fromObject) {
|
|
|
9219
8902
|
'generatedSamples',
|
|
9220
8903
|
]);
|
|
9221
8904
|
if (fromGeneratedVideos != null) {
|
|
9222
|
-
|
|
9223
|
-
|
|
8905
|
+
let transformedList = fromGeneratedVideos;
|
|
8906
|
+
if (Array.isArray(transformedList)) {
|
|
8907
|
+
transformedList = transformedList.map((item) => {
|
|
9224
8908
|
return generatedVideoFromMldev(apiClient, item);
|
|
9225
|
-
})
|
|
9226
|
-
}
|
|
9227
|
-
else {
|
|
9228
|
-
setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos);
|
|
8909
|
+
});
|
|
9229
8910
|
}
|
|
8911
|
+
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
9230
8912
|
}
|
|
9231
8913
|
const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
|
|
9232
8914
|
'raiMediaFilteredCount',
|
|
@@ -9299,14 +8981,13 @@ function generateVideosResponseFromVertex(apiClient, fromObject) {
|
|
|
9299
8981
|
const toObject = {};
|
|
9300
8982
|
const fromGeneratedVideos = getValueByPath(fromObject, ['videos']);
|
|
9301
8983
|
if (fromGeneratedVideos != null) {
|
|
9302
|
-
|
|
9303
|
-
|
|
8984
|
+
let transformedList = fromGeneratedVideos;
|
|
8985
|
+
if (Array.isArray(transformedList)) {
|
|
8986
|
+
transformedList = transformedList.map((item) => {
|
|
9304
8987
|
return generatedVideoFromVertex(apiClient, item);
|
|
9305
|
-
})
|
|
9306
|
-
}
|
|
9307
|
-
else {
|
|
9308
|
-
setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos);
|
|
8988
|
+
});
|
|
9309
8989
|
}
|
|
8990
|
+
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
9310
8991
|
}
|
|
9311
8992
|
const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
|
|
9312
8993
|
'raiMediaFilteredCount',
|
|
@@ -9477,6 +9158,736 @@ class Operations extends BaseModule {
|
|
|
9477
9158
|
}
|
|
9478
9159
|
}
|
|
9479
9160
|
|
|
9161
|
+
/**
|
|
9162
|
+
* @license
|
|
9163
|
+
* Copyright 2025 Google LLC
|
|
9164
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
9165
|
+
*/
|
|
9166
|
+
function getTuningJobParametersToMldev(apiClient, fromObject) {
|
|
9167
|
+
const toObject = {};
|
|
9168
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
9169
|
+
if (fromName != null) {
|
|
9170
|
+
setValueByPath(toObject, ['_url', 'name'], fromName);
|
|
9171
|
+
}
|
|
9172
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
9173
|
+
if (fromConfig != null) {
|
|
9174
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
9175
|
+
}
|
|
9176
|
+
return toObject;
|
|
9177
|
+
}
|
|
9178
|
+
function listTuningJobsConfigToMldev(apiClient, fromObject, parentObject) {
|
|
9179
|
+
const toObject = {};
|
|
9180
|
+
const fromPageSize = getValueByPath(fromObject, ['pageSize']);
|
|
9181
|
+
if (parentObject !== undefined && fromPageSize != null) {
|
|
9182
|
+
setValueByPath(parentObject, ['_query', 'pageSize'], fromPageSize);
|
|
9183
|
+
}
|
|
9184
|
+
const fromPageToken = getValueByPath(fromObject, ['pageToken']);
|
|
9185
|
+
if (parentObject !== undefined && fromPageToken != null) {
|
|
9186
|
+
setValueByPath(parentObject, ['_query', 'pageToken'], fromPageToken);
|
|
9187
|
+
}
|
|
9188
|
+
const fromFilter = getValueByPath(fromObject, ['filter']);
|
|
9189
|
+
if (parentObject !== undefined && fromFilter != null) {
|
|
9190
|
+
setValueByPath(parentObject, ['_query', 'filter'], fromFilter);
|
|
9191
|
+
}
|
|
9192
|
+
return toObject;
|
|
9193
|
+
}
|
|
9194
|
+
function listTuningJobsParametersToMldev(apiClient, fromObject) {
|
|
9195
|
+
const toObject = {};
|
|
9196
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
9197
|
+
if (fromConfig != null) {
|
|
9198
|
+
setValueByPath(toObject, ['config'], listTuningJobsConfigToMldev(apiClient, fromConfig, toObject));
|
|
9199
|
+
}
|
|
9200
|
+
return toObject;
|
|
9201
|
+
}
|
|
9202
|
+
function tuningExampleToMldev(apiClient, fromObject) {
|
|
9203
|
+
const toObject = {};
|
|
9204
|
+
const fromTextInput = getValueByPath(fromObject, ['textInput']);
|
|
9205
|
+
if (fromTextInput != null) {
|
|
9206
|
+
setValueByPath(toObject, ['textInput'], fromTextInput);
|
|
9207
|
+
}
|
|
9208
|
+
const fromOutput = getValueByPath(fromObject, ['output']);
|
|
9209
|
+
if (fromOutput != null) {
|
|
9210
|
+
setValueByPath(toObject, ['output'], fromOutput);
|
|
9211
|
+
}
|
|
9212
|
+
return toObject;
|
|
9213
|
+
}
|
|
9214
|
+
function tuningDatasetToMldev(apiClient, fromObject) {
|
|
9215
|
+
const toObject = {};
|
|
9216
|
+
if (getValueByPath(fromObject, ['gcsUri']) !== undefined) {
|
|
9217
|
+
throw new Error('gcsUri parameter is not supported in Gemini API.');
|
|
9218
|
+
}
|
|
9219
|
+
const fromExamples = getValueByPath(fromObject, ['examples']);
|
|
9220
|
+
if (fromExamples != null) {
|
|
9221
|
+
let transformedList = fromExamples;
|
|
9222
|
+
if (Array.isArray(transformedList)) {
|
|
9223
|
+
transformedList = transformedList.map((item) => {
|
|
9224
|
+
return tuningExampleToMldev(apiClient, item);
|
|
9225
|
+
});
|
|
9226
|
+
}
|
|
9227
|
+
setValueByPath(toObject, ['examples', 'examples'], transformedList);
|
|
9228
|
+
}
|
|
9229
|
+
return toObject;
|
|
9230
|
+
}
|
|
9231
|
+
function createTuningJobConfigToMldev(apiClient, fromObject, parentObject) {
|
|
9232
|
+
const toObject = {};
|
|
9233
|
+
if (getValueByPath(fromObject, ['validationDataset']) !== undefined) {
|
|
9234
|
+
throw new Error('validationDataset parameter is not supported in Gemini API.');
|
|
9235
|
+
}
|
|
9236
|
+
const fromTunedModelDisplayName = getValueByPath(fromObject, [
|
|
9237
|
+
'tunedModelDisplayName',
|
|
9238
|
+
]);
|
|
9239
|
+
if (parentObject !== undefined && fromTunedModelDisplayName != null) {
|
|
9240
|
+
setValueByPath(parentObject, ['displayName'], fromTunedModelDisplayName);
|
|
9241
|
+
}
|
|
9242
|
+
if (getValueByPath(fromObject, ['description']) !== undefined) {
|
|
9243
|
+
throw new Error('description parameter is not supported in Gemini API.');
|
|
9244
|
+
}
|
|
9245
|
+
const fromEpochCount = getValueByPath(fromObject, ['epochCount']);
|
|
9246
|
+
if (parentObject !== undefined && fromEpochCount != null) {
|
|
9247
|
+
setValueByPath(parentObject, ['tuningTask', 'hyperparameters', 'epochCount'], fromEpochCount);
|
|
9248
|
+
}
|
|
9249
|
+
const fromLearningRateMultiplier = getValueByPath(fromObject, [
|
|
9250
|
+
'learningRateMultiplier',
|
|
9251
|
+
]);
|
|
9252
|
+
if (fromLearningRateMultiplier != null) {
|
|
9253
|
+
setValueByPath(toObject, ['tuningTask', 'hyperparameters', 'learningRateMultiplier'], fromLearningRateMultiplier);
|
|
9254
|
+
}
|
|
9255
|
+
if (getValueByPath(fromObject, ['adapterSize']) !== undefined) {
|
|
9256
|
+
throw new Error('adapterSize parameter is not supported in Gemini API.');
|
|
9257
|
+
}
|
|
9258
|
+
const fromBatchSize = getValueByPath(fromObject, ['batchSize']);
|
|
9259
|
+
if (parentObject !== undefined && fromBatchSize != null) {
|
|
9260
|
+
setValueByPath(parentObject, ['tuningTask', 'hyperparameters', 'batchSize'], fromBatchSize);
|
|
9261
|
+
}
|
|
9262
|
+
const fromLearningRate = getValueByPath(fromObject, ['learningRate']);
|
|
9263
|
+
if (parentObject !== undefined && fromLearningRate != null) {
|
|
9264
|
+
setValueByPath(parentObject, ['tuningTask', 'hyperparameters', 'learningRate'], fromLearningRate);
|
|
9265
|
+
}
|
|
9266
|
+
return toObject;
|
|
9267
|
+
}
|
|
9268
|
+
function createTuningJobParametersToMldev(apiClient, fromObject) {
|
|
9269
|
+
const toObject = {};
|
|
9270
|
+
const fromBaseModel = getValueByPath(fromObject, ['baseModel']);
|
|
9271
|
+
if (fromBaseModel != null) {
|
|
9272
|
+
setValueByPath(toObject, ['baseModel'], fromBaseModel);
|
|
9273
|
+
}
|
|
9274
|
+
const fromTrainingDataset = getValueByPath(fromObject, [
|
|
9275
|
+
'trainingDataset',
|
|
9276
|
+
]);
|
|
9277
|
+
if (fromTrainingDataset != null) {
|
|
9278
|
+
setValueByPath(toObject, ['tuningTask', 'trainingData'], tuningDatasetToMldev(apiClient, fromTrainingDataset));
|
|
9279
|
+
}
|
|
9280
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
9281
|
+
if (fromConfig != null) {
|
|
9282
|
+
setValueByPath(toObject, ['config'], createTuningJobConfigToMldev(apiClient, fromConfig, toObject));
|
|
9283
|
+
}
|
|
9284
|
+
return toObject;
|
|
9285
|
+
}
|
|
9286
|
+
function getTuningJobParametersToVertex(apiClient, fromObject) {
|
|
9287
|
+
const toObject = {};
|
|
9288
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
9289
|
+
if (fromName != null) {
|
|
9290
|
+
setValueByPath(toObject, ['_url', 'name'], fromName);
|
|
9291
|
+
}
|
|
9292
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
9293
|
+
if (fromConfig != null) {
|
|
9294
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
9295
|
+
}
|
|
9296
|
+
return toObject;
|
|
9297
|
+
}
|
|
9298
|
+
function listTuningJobsConfigToVertex(apiClient, fromObject, parentObject) {
|
|
9299
|
+
const toObject = {};
|
|
9300
|
+
const fromPageSize = getValueByPath(fromObject, ['pageSize']);
|
|
9301
|
+
if (parentObject !== undefined && fromPageSize != null) {
|
|
9302
|
+
setValueByPath(parentObject, ['_query', 'pageSize'], fromPageSize);
|
|
9303
|
+
}
|
|
9304
|
+
const fromPageToken = getValueByPath(fromObject, ['pageToken']);
|
|
9305
|
+
if (parentObject !== undefined && fromPageToken != null) {
|
|
9306
|
+
setValueByPath(parentObject, ['_query', 'pageToken'], fromPageToken);
|
|
9307
|
+
}
|
|
9308
|
+
const fromFilter = getValueByPath(fromObject, ['filter']);
|
|
9309
|
+
if (parentObject !== undefined && fromFilter != null) {
|
|
9310
|
+
setValueByPath(parentObject, ['_query', 'filter'], fromFilter);
|
|
9311
|
+
}
|
|
9312
|
+
return toObject;
|
|
9313
|
+
}
|
|
9314
|
+
function listTuningJobsParametersToVertex(apiClient, fromObject) {
|
|
9315
|
+
const toObject = {};
|
|
9316
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
9317
|
+
if (fromConfig != null) {
|
|
9318
|
+
setValueByPath(toObject, ['config'], listTuningJobsConfigToVertex(apiClient, fromConfig, toObject));
|
|
9319
|
+
}
|
|
9320
|
+
return toObject;
|
|
9321
|
+
}
|
|
9322
|
+
function tuningDatasetToVertex(apiClient, fromObject, parentObject) {
|
|
9323
|
+
const toObject = {};
|
|
9324
|
+
const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
|
|
9325
|
+
if (parentObject !== undefined && fromGcsUri != null) {
|
|
9326
|
+
setValueByPath(parentObject, ['supervisedTuningSpec', 'trainingDatasetUri'], fromGcsUri);
|
|
9327
|
+
}
|
|
9328
|
+
if (getValueByPath(fromObject, ['examples']) !== undefined) {
|
|
9329
|
+
throw new Error('examples parameter is not supported in Vertex AI.');
|
|
9330
|
+
}
|
|
9331
|
+
return toObject;
|
|
9332
|
+
}
|
|
9333
|
+
function tuningValidationDatasetToVertex(apiClient, fromObject) {
|
|
9334
|
+
const toObject = {};
|
|
9335
|
+
const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
|
|
9336
|
+
if (fromGcsUri != null) {
|
|
9337
|
+
setValueByPath(toObject, ['validationDatasetUri'], fromGcsUri);
|
|
9338
|
+
}
|
|
9339
|
+
return toObject;
|
|
9340
|
+
}
|
|
9341
|
+
function createTuningJobConfigToVertex(apiClient, fromObject, parentObject) {
|
|
9342
|
+
const toObject = {};
|
|
9343
|
+
const fromValidationDataset = getValueByPath(fromObject, [
|
|
9344
|
+
'validationDataset',
|
|
9345
|
+
]);
|
|
9346
|
+
if (parentObject !== undefined && fromValidationDataset != null) {
|
|
9347
|
+
setValueByPath(parentObject, ['supervisedTuningSpec'], tuningValidationDatasetToVertex(apiClient, fromValidationDataset));
|
|
9348
|
+
}
|
|
9349
|
+
const fromTunedModelDisplayName = getValueByPath(fromObject, [
|
|
9350
|
+
'tunedModelDisplayName',
|
|
9351
|
+
]);
|
|
9352
|
+
if (parentObject !== undefined && fromTunedModelDisplayName != null) {
|
|
9353
|
+
setValueByPath(parentObject, ['tunedModelDisplayName'], fromTunedModelDisplayName);
|
|
9354
|
+
}
|
|
9355
|
+
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
9356
|
+
if (parentObject !== undefined && fromDescription != null) {
|
|
9357
|
+
setValueByPath(parentObject, ['description'], fromDescription);
|
|
9358
|
+
}
|
|
9359
|
+
const fromEpochCount = getValueByPath(fromObject, ['epochCount']);
|
|
9360
|
+
if (parentObject !== undefined && fromEpochCount != null) {
|
|
9361
|
+
setValueByPath(parentObject, ['supervisedTuningSpec', 'hyperParameters', 'epochCount'], fromEpochCount);
|
|
9362
|
+
}
|
|
9363
|
+
const fromLearningRateMultiplier = getValueByPath(fromObject, [
|
|
9364
|
+
'learningRateMultiplier',
|
|
9365
|
+
]);
|
|
9366
|
+
if (parentObject !== undefined && fromLearningRateMultiplier != null) {
|
|
9367
|
+
setValueByPath(parentObject, ['supervisedTuningSpec', 'hyperParameters', 'learningRateMultiplier'], fromLearningRateMultiplier);
|
|
9368
|
+
}
|
|
9369
|
+
const fromAdapterSize = getValueByPath(fromObject, ['adapterSize']);
|
|
9370
|
+
if (parentObject !== undefined && fromAdapterSize != null) {
|
|
9371
|
+
setValueByPath(parentObject, ['supervisedTuningSpec', 'hyperParameters', 'adapterSize'], fromAdapterSize);
|
|
9372
|
+
}
|
|
9373
|
+
if (getValueByPath(fromObject, ['batchSize']) !== undefined) {
|
|
9374
|
+
throw new Error('batchSize parameter is not supported in Vertex AI.');
|
|
9375
|
+
}
|
|
9376
|
+
if (getValueByPath(fromObject, ['learningRate']) !== undefined) {
|
|
9377
|
+
throw new Error('learningRate parameter is not supported in Vertex AI.');
|
|
9378
|
+
}
|
|
9379
|
+
return toObject;
|
|
9380
|
+
}
|
|
9381
|
+
function createTuningJobParametersToVertex(apiClient, fromObject) {
|
|
9382
|
+
const toObject = {};
|
|
9383
|
+
const fromBaseModel = getValueByPath(fromObject, ['baseModel']);
|
|
9384
|
+
if (fromBaseModel != null) {
|
|
9385
|
+
setValueByPath(toObject, ['baseModel'], fromBaseModel);
|
|
9386
|
+
}
|
|
9387
|
+
const fromTrainingDataset = getValueByPath(fromObject, [
|
|
9388
|
+
'trainingDataset',
|
|
9389
|
+
]);
|
|
9390
|
+
if (fromTrainingDataset != null) {
|
|
9391
|
+
setValueByPath(toObject, ['supervisedTuningSpec', 'trainingDatasetUri'], tuningDatasetToVertex(apiClient, fromTrainingDataset, toObject));
|
|
9392
|
+
}
|
|
9393
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
9394
|
+
if (fromConfig != null) {
|
|
9395
|
+
setValueByPath(toObject, ['config'], createTuningJobConfigToVertex(apiClient, fromConfig, toObject));
|
|
9396
|
+
}
|
|
9397
|
+
return toObject;
|
|
9398
|
+
}
|
|
9399
|
+
function tunedModelFromMldev(apiClient, fromObject) {
|
|
9400
|
+
const toObject = {};
|
|
9401
|
+
const fromModel = getValueByPath(fromObject, ['name']);
|
|
9402
|
+
if (fromModel != null) {
|
|
9403
|
+
setValueByPath(toObject, ['model'], fromModel);
|
|
9404
|
+
}
|
|
9405
|
+
const fromEndpoint = getValueByPath(fromObject, ['name']);
|
|
9406
|
+
if (fromEndpoint != null) {
|
|
9407
|
+
setValueByPath(toObject, ['endpoint'], fromEndpoint);
|
|
9408
|
+
}
|
|
9409
|
+
return toObject;
|
|
9410
|
+
}
|
|
9411
|
+
function tuningJobFromMldev(apiClient, fromObject) {
|
|
9412
|
+
const toObject = {};
|
|
9413
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
9414
|
+
if (fromName != null) {
|
|
9415
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
9416
|
+
}
|
|
9417
|
+
const fromState = getValueByPath(fromObject, ['state']);
|
|
9418
|
+
if (fromState != null) {
|
|
9419
|
+
setValueByPath(toObject, ['state'], tTuningJobStatus(apiClient, fromState));
|
|
9420
|
+
}
|
|
9421
|
+
const fromCreateTime = getValueByPath(fromObject, ['createTime']);
|
|
9422
|
+
if (fromCreateTime != null) {
|
|
9423
|
+
setValueByPath(toObject, ['createTime'], fromCreateTime);
|
|
9424
|
+
}
|
|
9425
|
+
const fromStartTime = getValueByPath(fromObject, [
|
|
9426
|
+
'tuningTask',
|
|
9427
|
+
'startTime',
|
|
9428
|
+
]);
|
|
9429
|
+
if (fromStartTime != null) {
|
|
9430
|
+
setValueByPath(toObject, ['startTime'], fromStartTime);
|
|
9431
|
+
}
|
|
9432
|
+
const fromEndTime = getValueByPath(fromObject, [
|
|
9433
|
+
'tuningTask',
|
|
9434
|
+
'completeTime',
|
|
9435
|
+
]);
|
|
9436
|
+
if (fromEndTime != null) {
|
|
9437
|
+
setValueByPath(toObject, ['endTime'], fromEndTime);
|
|
9438
|
+
}
|
|
9439
|
+
const fromUpdateTime = getValueByPath(fromObject, ['updateTime']);
|
|
9440
|
+
if (fromUpdateTime != null) {
|
|
9441
|
+
setValueByPath(toObject, ['updateTime'], fromUpdateTime);
|
|
9442
|
+
}
|
|
9443
|
+
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
9444
|
+
if (fromDescription != null) {
|
|
9445
|
+
setValueByPath(toObject, ['description'], fromDescription);
|
|
9446
|
+
}
|
|
9447
|
+
const fromBaseModel = getValueByPath(fromObject, ['baseModel']);
|
|
9448
|
+
if (fromBaseModel != null) {
|
|
9449
|
+
setValueByPath(toObject, ['baseModel'], fromBaseModel);
|
|
9450
|
+
}
|
|
9451
|
+
const fromTunedModel = getValueByPath(fromObject, ['_self']);
|
|
9452
|
+
if (fromTunedModel != null) {
|
|
9453
|
+
setValueByPath(toObject, ['tunedModel'], tunedModelFromMldev(apiClient, fromTunedModel));
|
|
9454
|
+
}
|
|
9455
|
+
const fromDistillationSpec = getValueByPath(fromObject, [
|
|
9456
|
+
'distillationSpec',
|
|
9457
|
+
]);
|
|
9458
|
+
if (fromDistillationSpec != null) {
|
|
9459
|
+
setValueByPath(toObject, ['distillationSpec'], fromDistillationSpec);
|
|
9460
|
+
}
|
|
9461
|
+
const fromExperiment = getValueByPath(fromObject, ['experiment']);
|
|
9462
|
+
if (fromExperiment != null) {
|
|
9463
|
+
setValueByPath(toObject, ['experiment'], fromExperiment);
|
|
9464
|
+
}
|
|
9465
|
+
const fromLabels = getValueByPath(fromObject, ['labels']);
|
|
9466
|
+
if (fromLabels != null) {
|
|
9467
|
+
setValueByPath(toObject, ['labels'], fromLabels);
|
|
9468
|
+
}
|
|
9469
|
+
const fromPipelineJob = getValueByPath(fromObject, ['pipelineJob']);
|
|
9470
|
+
if (fromPipelineJob != null) {
|
|
9471
|
+
setValueByPath(toObject, ['pipelineJob'], fromPipelineJob);
|
|
9472
|
+
}
|
|
9473
|
+
const fromTunedModelDisplayName = getValueByPath(fromObject, [
|
|
9474
|
+
'tunedModelDisplayName',
|
|
9475
|
+
]);
|
|
9476
|
+
if (fromTunedModelDisplayName != null) {
|
|
9477
|
+
setValueByPath(toObject, ['tunedModelDisplayName'], fromTunedModelDisplayName);
|
|
9478
|
+
}
|
|
9479
|
+
return toObject;
|
|
9480
|
+
}
|
|
9481
|
+
function listTuningJobsResponseFromMldev(apiClient, fromObject) {
|
|
9482
|
+
const toObject = {};
|
|
9483
|
+
const fromNextPageToken = getValueByPath(fromObject, [
|
|
9484
|
+
'nextPageToken',
|
|
9485
|
+
]);
|
|
9486
|
+
if (fromNextPageToken != null) {
|
|
9487
|
+
setValueByPath(toObject, ['nextPageToken'], fromNextPageToken);
|
|
9488
|
+
}
|
|
9489
|
+
const fromTuningJobs = getValueByPath(fromObject, ['tunedModels']);
|
|
9490
|
+
if (fromTuningJobs != null) {
|
|
9491
|
+
let transformedList = fromTuningJobs;
|
|
9492
|
+
if (Array.isArray(transformedList)) {
|
|
9493
|
+
transformedList = transformedList.map((item) => {
|
|
9494
|
+
return tuningJobFromMldev(apiClient, item);
|
|
9495
|
+
});
|
|
9496
|
+
}
|
|
9497
|
+
setValueByPath(toObject, ['tuningJobs'], transformedList);
|
|
9498
|
+
}
|
|
9499
|
+
return toObject;
|
|
9500
|
+
}
|
|
9501
|
+
function operationFromMldev(apiClient, fromObject) {
|
|
9502
|
+
const toObject = {};
|
|
9503
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
9504
|
+
if (fromName != null) {
|
|
9505
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
9506
|
+
}
|
|
9507
|
+
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
9508
|
+
if (fromMetadata != null) {
|
|
9509
|
+
setValueByPath(toObject, ['metadata'], fromMetadata);
|
|
9510
|
+
}
|
|
9511
|
+
const fromDone = getValueByPath(fromObject, ['done']);
|
|
9512
|
+
if (fromDone != null) {
|
|
9513
|
+
setValueByPath(toObject, ['done'], fromDone);
|
|
9514
|
+
}
|
|
9515
|
+
const fromError = getValueByPath(fromObject, ['error']);
|
|
9516
|
+
if (fromError != null) {
|
|
9517
|
+
setValueByPath(toObject, ['error'], fromError);
|
|
9518
|
+
}
|
|
9519
|
+
return toObject;
|
|
9520
|
+
}
|
|
9521
|
+
function tunedModelFromVertex(apiClient, fromObject) {
|
|
9522
|
+
const toObject = {};
|
|
9523
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
9524
|
+
if (fromModel != null) {
|
|
9525
|
+
setValueByPath(toObject, ['model'], fromModel);
|
|
9526
|
+
}
|
|
9527
|
+
const fromEndpoint = getValueByPath(fromObject, ['endpoint']);
|
|
9528
|
+
if (fromEndpoint != null) {
|
|
9529
|
+
setValueByPath(toObject, ['endpoint'], fromEndpoint);
|
|
9530
|
+
}
|
|
9531
|
+
return toObject;
|
|
9532
|
+
}
|
|
9533
|
+
function tuningJobFromVertex(apiClient, fromObject) {
|
|
9534
|
+
const toObject = {};
|
|
9535
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
9536
|
+
if (fromName != null) {
|
|
9537
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
9538
|
+
}
|
|
9539
|
+
const fromState = getValueByPath(fromObject, ['state']);
|
|
9540
|
+
if (fromState != null) {
|
|
9541
|
+
setValueByPath(toObject, ['state'], tTuningJobStatus(apiClient, fromState));
|
|
9542
|
+
}
|
|
9543
|
+
const fromCreateTime = getValueByPath(fromObject, ['createTime']);
|
|
9544
|
+
if (fromCreateTime != null) {
|
|
9545
|
+
setValueByPath(toObject, ['createTime'], fromCreateTime);
|
|
9546
|
+
}
|
|
9547
|
+
const fromStartTime = getValueByPath(fromObject, ['startTime']);
|
|
9548
|
+
if (fromStartTime != null) {
|
|
9549
|
+
setValueByPath(toObject, ['startTime'], fromStartTime);
|
|
9550
|
+
}
|
|
9551
|
+
const fromEndTime = getValueByPath(fromObject, ['endTime']);
|
|
9552
|
+
if (fromEndTime != null) {
|
|
9553
|
+
setValueByPath(toObject, ['endTime'], fromEndTime);
|
|
9554
|
+
}
|
|
9555
|
+
const fromUpdateTime = getValueByPath(fromObject, ['updateTime']);
|
|
9556
|
+
if (fromUpdateTime != null) {
|
|
9557
|
+
setValueByPath(toObject, ['updateTime'], fromUpdateTime);
|
|
9558
|
+
}
|
|
9559
|
+
const fromError = getValueByPath(fromObject, ['error']);
|
|
9560
|
+
if (fromError != null) {
|
|
9561
|
+
setValueByPath(toObject, ['error'], fromError);
|
|
9562
|
+
}
|
|
9563
|
+
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
9564
|
+
if (fromDescription != null) {
|
|
9565
|
+
setValueByPath(toObject, ['description'], fromDescription);
|
|
9566
|
+
}
|
|
9567
|
+
const fromBaseModel = getValueByPath(fromObject, ['baseModel']);
|
|
9568
|
+
if (fromBaseModel != null) {
|
|
9569
|
+
setValueByPath(toObject, ['baseModel'], fromBaseModel);
|
|
9570
|
+
}
|
|
9571
|
+
const fromTunedModel = getValueByPath(fromObject, ['tunedModel']);
|
|
9572
|
+
if (fromTunedModel != null) {
|
|
9573
|
+
setValueByPath(toObject, ['tunedModel'], tunedModelFromVertex(apiClient, fromTunedModel));
|
|
9574
|
+
}
|
|
9575
|
+
const fromSupervisedTuningSpec = getValueByPath(fromObject, [
|
|
9576
|
+
'supervisedTuningSpec',
|
|
9577
|
+
]);
|
|
9578
|
+
if (fromSupervisedTuningSpec != null) {
|
|
9579
|
+
setValueByPath(toObject, ['supervisedTuningSpec'], fromSupervisedTuningSpec);
|
|
9580
|
+
}
|
|
9581
|
+
const fromTuningDataStats = getValueByPath(fromObject, [
|
|
9582
|
+
'tuningDataStats',
|
|
9583
|
+
]);
|
|
9584
|
+
if (fromTuningDataStats != null) {
|
|
9585
|
+
setValueByPath(toObject, ['tuningDataStats'], fromTuningDataStats);
|
|
9586
|
+
}
|
|
9587
|
+
const fromEncryptionSpec = getValueByPath(fromObject, [
|
|
9588
|
+
'encryptionSpec',
|
|
9589
|
+
]);
|
|
9590
|
+
if (fromEncryptionSpec != null) {
|
|
9591
|
+
setValueByPath(toObject, ['encryptionSpec'], fromEncryptionSpec);
|
|
9592
|
+
}
|
|
9593
|
+
const fromPartnerModelTuningSpec = getValueByPath(fromObject, [
|
|
9594
|
+
'partnerModelTuningSpec',
|
|
9595
|
+
]);
|
|
9596
|
+
if (fromPartnerModelTuningSpec != null) {
|
|
9597
|
+
setValueByPath(toObject, ['partnerModelTuningSpec'], fromPartnerModelTuningSpec);
|
|
9598
|
+
}
|
|
9599
|
+
const fromDistillationSpec = getValueByPath(fromObject, [
|
|
9600
|
+
'distillationSpec',
|
|
9601
|
+
]);
|
|
9602
|
+
if (fromDistillationSpec != null) {
|
|
9603
|
+
setValueByPath(toObject, ['distillationSpec'], fromDistillationSpec);
|
|
9604
|
+
}
|
|
9605
|
+
const fromExperiment = getValueByPath(fromObject, ['experiment']);
|
|
9606
|
+
if (fromExperiment != null) {
|
|
9607
|
+
setValueByPath(toObject, ['experiment'], fromExperiment);
|
|
9608
|
+
}
|
|
9609
|
+
const fromLabels = getValueByPath(fromObject, ['labels']);
|
|
9610
|
+
if (fromLabels != null) {
|
|
9611
|
+
setValueByPath(toObject, ['labels'], fromLabels);
|
|
9612
|
+
}
|
|
9613
|
+
const fromPipelineJob = getValueByPath(fromObject, ['pipelineJob']);
|
|
9614
|
+
if (fromPipelineJob != null) {
|
|
9615
|
+
setValueByPath(toObject, ['pipelineJob'], fromPipelineJob);
|
|
9616
|
+
}
|
|
9617
|
+
const fromTunedModelDisplayName = getValueByPath(fromObject, [
|
|
9618
|
+
'tunedModelDisplayName',
|
|
9619
|
+
]);
|
|
9620
|
+
if (fromTunedModelDisplayName != null) {
|
|
9621
|
+
setValueByPath(toObject, ['tunedModelDisplayName'], fromTunedModelDisplayName);
|
|
9622
|
+
}
|
|
9623
|
+
return toObject;
|
|
9624
|
+
}
|
|
9625
|
+
function listTuningJobsResponseFromVertex(apiClient, fromObject) {
|
|
9626
|
+
const toObject = {};
|
|
9627
|
+
const fromNextPageToken = getValueByPath(fromObject, [
|
|
9628
|
+
'nextPageToken',
|
|
9629
|
+
]);
|
|
9630
|
+
if (fromNextPageToken != null) {
|
|
9631
|
+
setValueByPath(toObject, ['nextPageToken'], fromNextPageToken);
|
|
9632
|
+
}
|
|
9633
|
+
const fromTuningJobs = getValueByPath(fromObject, ['tuningJobs']);
|
|
9634
|
+
if (fromTuningJobs != null) {
|
|
9635
|
+
let transformedList = fromTuningJobs;
|
|
9636
|
+
if (Array.isArray(transformedList)) {
|
|
9637
|
+
transformedList = transformedList.map((item) => {
|
|
9638
|
+
return tuningJobFromVertex(apiClient, item);
|
|
9639
|
+
});
|
|
9640
|
+
}
|
|
9641
|
+
setValueByPath(toObject, ['tuningJobs'], transformedList);
|
|
9642
|
+
}
|
|
9643
|
+
return toObject;
|
|
9644
|
+
}
|
|
9645
|
+
|
|
9646
|
+
/**
|
|
9647
|
+
* @license
|
|
9648
|
+
* Copyright 2025 Google LLC
|
|
9649
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
9650
|
+
*/
|
|
9651
|
+
class Tunings extends BaseModule {
|
|
9652
|
+
constructor(apiClient) {
|
|
9653
|
+
super();
|
|
9654
|
+
this.apiClient = apiClient;
|
|
9655
|
+
/**
|
|
9656
|
+
* Gets a TuningJob.
|
|
9657
|
+
*
|
|
9658
|
+
* @param name - The resource name of the tuning job.
|
|
9659
|
+
* @return - A TuningJob object.
|
|
9660
|
+
*
|
|
9661
|
+
* @experimental - The SDK's tuning implementation is experimental, and may
|
|
9662
|
+
* change in future versions.
|
|
9663
|
+
*/
|
|
9664
|
+
this.get = async (params) => {
|
|
9665
|
+
return await this.getInternal(params);
|
|
9666
|
+
};
|
|
9667
|
+
/**
|
|
9668
|
+
* Lists tuning jobs.
|
|
9669
|
+
*
|
|
9670
|
+
* @param config - The configuration for the list request.
|
|
9671
|
+
* @return - A list of tuning jobs.
|
|
9672
|
+
*
|
|
9673
|
+
* @experimental - The SDK's tuning implementation is experimental, and may
|
|
9674
|
+
* change in future versions.
|
|
9675
|
+
*/
|
|
9676
|
+
this.list = async (params = {}) => {
|
|
9677
|
+
return new Pager(exports.PagedItem.PAGED_ITEM_TUNING_JOBS, (x) => this.listInternal(x), await this.listInternal(params), params);
|
|
9678
|
+
};
|
|
9679
|
+
/**
|
|
9680
|
+
* Creates a supervised fine-tuning job.
|
|
9681
|
+
*
|
|
9682
|
+
* @param params - The parameters for the tuning job.
|
|
9683
|
+
* @return - A TuningJob operation.
|
|
9684
|
+
*
|
|
9685
|
+
* @experimental - The SDK's tuning implementation is experimental, and may
|
|
9686
|
+
* change in future versions.
|
|
9687
|
+
*/
|
|
9688
|
+
this.tune = async (params) => {
|
|
9689
|
+
if (this.apiClient.isVertexAI()) {
|
|
9690
|
+
return await this.tuneInternal(params);
|
|
9691
|
+
}
|
|
9692
|
+
else {
|
|
9693
|
+
const operation = await this.tuneMldevInternal(params);
|
|
9694
|
+
let tunedModelName = '';
|
|
9695
|
+
if (operation['metadata'] !== undefined &&
|
|
9696
|
+
operation['metadata']['tunedModel'] !== undefined) {
|
|
9697
|
+
tunedModelName = operation['metadata']['tunedModel'];
|
|
9698
|
+
}
|
|
9699
|
+
else if (operation['name'] !== undefined &&
|
|
9700
|
+
operation['name'].includes('/operations/')) {
|
|
9701
|
+
tunedModelName = operation['name'].split('/operations/')[0];
|
|
9702
|
+
}
|
|
9703
|
+
const tuningJob = {
|
|
9704
|
+
name: tunedModelName,
|
|
9705
|
+
state: exports.JobState.JOB_STATE_QUEUED,
|
|
9706
|
+
};
|
|
9707
|
+
return tuningJob;
|
|
9708
|
+
}
|
|
9709
|
+
};
|
|
9710
|
+
}
|
|
9711
|
+
async getInternal(params) {
|
|
9712
|
+
var _a, _b, _c, _d;
|
|
9713
|
+
let response;
|
|
9714
|
+
let path = '';
|
|
9715
|
+
let queryParams = {};
|
|
9716
|
+
if (this.apiClient.isVertexAI()) {
|
|
9717
|
+
const body = getTuningJobParametersToVertex(this.apiClient, params);
|
|
9718
|
+
path = formatMap('{name}', body['_url']);
|
|
9719
|
+
queryParams = body['_query'];
|
|
9720
|
+
delete body['config'];
|
|
9721
|
+
delete body['_url'];
|
|
9722
|
+
delete body['_query'];
|
|
9723
|
+
response = this.apiClient
|
|
9724
|
+
.request({
|
|
9725
|
+
path: path,
|
|
9726
|
+
queryParams: queryParams,
|
|
9727
|
+
body: JSON.stringify(body),
|
|
9728
|
+
httpMethod: 'GET',
|
|
9729
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
9730
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
9731
|
+
})
|
|
9732
|
+
.then((httpResponse) => {
|
|
9733
|
+
return httpResponse.json();
|
|
9734
|
+
});
|
|
9735
|
+
return response.then((apiResponse) => {
|
|
9736
|
+
const resp = tuningJobFromVertex(this.apiClient, apiResponse);
|
|
9737
|
+
return resp;
|
|
9738
|
+
});
|
|
9739
|
+
}
|
|
9740
|
+
else {
|
|
9741
|
+
const body = getTuningJobParametersToMldev(this.apiClient, params);
|
|
9742
|
+
path = formatMap('{name}', body['_url']);
|
|
9743
|
+
queryParams = body['_query'];
|
|
9744
|
+
delete body['config'];
|
|
9745
|
+
delete body['_url'];
|
|
9746
|
+
delete body['_query'];
|
|
9747
|
+
response = this.apiClient
|
|
9748
|
+
.request({
|
|
9749
|
+
path: path,
|
|
9750
|
+
queryParams: queryParams,
|
|
9751
|
+
body: JSON.stringify(body),
|
|
9752
|
+
httpMethod: 'GET',
|
|
9753
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
9754
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
9755
|
+
})
|
|
9756
|
+
.then((httpResponse) => {
|
|
9757
|
+
return httpResponse.json();
|
|
9758
|
+
});
|
|
9759
|
+
return response.then((apiResponse) => {
|
|
9760
|
+
const resp = tuningJobFromMldev(this.apiClient, apiResponse);
|
|
9761
|
+
return resp;
|
|
9762
|
+
});
|
|
9763
|
+
}
|
|
9764
|
+
}
|
|
9765
|
+
async listInternal(params) {
|
|
9766
|
+
var _a, _b, _c, _d;
|
|
9767
|
+
let response;
|
|
9768
|
+
let path = '';
|
|
9769
|
+
let queryParams = {};
|
|
9770
|
+
if (this.apiClient.isVertexAI()) {
|
|
9771
|
+
const body = listTuningJobsParametersToVertex(this.apiClient, params);
|
|
9772
|
+
path = formatMap('tuningJobs', body['_url']);
|
|
9773
|
+
queryParams = body['_query'];
|
|
9774
|
+
delete body['config'];
|
|
9775
|
+
delete body['_url'];
|
|
9776
|
+
delete body['_query'];
|
|
9777
|
+
response = this.apiClient
|
|
9778
|
+
.request({
|
|
9779
|
+
path: path,
|
|
9780
|
+
queryParams: queryParams,
|
|
9781
|
+
body: JSON.stringify(body),
|
|
9782
|
+
httpMethod: 'GET',
|
|
9783
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
9784
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
9785
|
+
})
|
|
9786
|
+
.then((httpResponse) => {
|
|
9787
|
+
return httpResponse.json();
|
|
9788
|
+
});
|
|
9789
|
+
return response.then((apiResponse) => {
|
|
9790
|
+
const resp = listTuningJobsResponseFromVertex(this.apiClient, apiResponse);
|
|
9791
|
+
const typedResp = new ListTuningJobsResponse();
|
|
9792
|
+
Object.assign(typedResp, resp);
|
|
9793
|
+
return typedResp;
|
|
9794
|
+
});
|
|
9795
|
+
}
|
|
9796
|
+
else {
|
|
9797
|
+
const body = listTuningJobsParametersToMldev(this.apiClient, params);
|
|
9798
|
+
path = formatMap('tunedModels', body['_url']);
|
|
9799
|
+
queryParams = body['_query'];
|
|
9800
|
+
delete body['config'];
|
|
9801
|
+
delete body['_url'];
|
|
9802
|
+
delete body['_query'];
|
|
9803
|
+
response = this.apiClient
|
|
9804
|
+
.request({
|
|
9805
|
+
path: path,
|
|
9806
|
+
queryParams: queryParams,
|
|
9807
|
+
body: JSON.stringify(body),
|
|
9808
|
+
httpMethod: 'GET',
|
|
9809
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
9810
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
9811
|
+
})
|
|
9812
|
+
.then((httpResponse) => {
|
|
9813
|
+
return httpResponse.json();
|
|
9814
|
+
});
|
|
9815
|
+
return response.then((apiResponse) => {
|
|
9816
|
+
const resp = listTuningJobsResponseFromMldev(this.apiClient, apiResponse);
|
|
9817
|
+
const typedResp = new ListTuningJobsResponse();
|
|
9818
|
+
Object.assign(typedResp, resp);
|
|
9819
|
+
return typedResp;
|
|
9820
|
+
});
|
|
9821
|
+
}
|
|
9822
|
+
}
|
|
9823
|
+
async tuneInternal(params) {
|
|
9824
|
+
var _a, _b;
|
|
9825
|
+
let response;
|
|
9826
|
+
let path = '';
|
|
9827
|
+
let queryParams = {};
|
|
9828
|
+
if (this.apiClient.isVertexAI()) {
|
|
9829
|
+
const body = createTuningJobParametersToVertex(this.apiClient, params);
|
|
9830
|
+
path = formatMap('tuningJobs', body['_url']);
|
|
9831
|
+
queryParams = body['_query'];
|
|
9832
|
+
delete body['config'];
|
|
9833
|
+
delete body['_url'];
|
|
9834
|
+
delete body['_query'];
|
|
9835
|
+
response = this.apiClient
|
|
9836
|
+
.request({
|
|
9837
|
+
path: path,
|
|
9838
|
+
queryParams: queryParams,
|
|
9839
|
+
body: JSON.stringify(body),
|
|
9840
|
+
httpMethod: 'POST',
|
|
9841
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
9842
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
9843
|
+
})
|
|
9844
|
+
.then((httpResponse) => {
|
|
9845
|
+
return httpResponse.json();
|
|
9846
|
+
});
|
|
9847
|
+
return response.then((apiResponse) => {
|
|
9848
|
+
const resp = tuningJobFromVertex(this.apiClient, apiResponse);
|
|
9849
|
+
return resp;
|
|
9850
|
+
});
|
|
9851
|
+
}
|
|
9852
|
+
else {
|
|
9853
|
+
throw new Error('This method is only supported by the Vertex AI.');
|
|
9854
|
+
}
|
|
9855
|
+
}
|
|
9856
|
+
async tuneMldevInternal(params) {
|
|
9857
|
+
var _a, _b;
|
|
9858
|
+
let response;
|
|
9859
|
+
let path = '';
|
|
9860
|
+
let queryParams = {};
|
|
9861
|
+
if (this.apiClient.isVertexAI()) {
|
|
9862
|
+
throw new Error('This method is only supported by the Gemini Developer API.');
|
|
9863
|
+
}
|
|
9864
|
+
else {
|
|
9865
|
+
const body = createTuningJobParametersToMldev(this.apiClient, params);
|
|
9866
|
+
path = formatMap('tunedModels', body['_url']);
|
|
9867
|
+
queryParams = body['_query'];
|
|
9868
|
+
delete body['config'];
|
|
9869
|
+
delete body['_url'];
|
|
9870
|
+
delete body['_query'];
|
|
9871
|
+
response = this.apiClient
|
|
9872
|
+
.request({
|
|
9873
|
+
path: path,
|
|
9874
|
+
queryParams: queryParams,
|
|
9875
|
+
body: JSON.stringify(body),
|
|
9876
|
+
httpMethod: 'POST',
|
|
9877
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
9878
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
9879
|
+
})
|
|
9880
|
+
.then((httpResponse) => {
|
|
9881
|
+
return httpResponse.json();
|
|
9882
|
+
});
|
|
9883
|
+
return response.then((apiResponse) => {
|
|
9884
|
+
const resp = operationFromMldev(this.apiClient, apiResponse);
|
|
9885
|
+
return resp;
|
|
9886
|
+
});
|
|
9887
|
+
}
|
|
9888
|
+
}
|
|
9889
|
+
}
|
|
9890
|
+
|
|
9480
9891
|
/**
|
|
9481
9892
|
* @license
|
|
9482
9893
|
* Copyright 2025 Google LLC
|
|
@@ -9558,6 +9969,7 @@ class GoogleGenAI {
|
|
|
9558
9969
|
this.caches = new Caches(this.apiClient);
|
|
9559
9970
|
this.files = new Files(this.apiClient);
|
|
9560
9971
|
this.operations = new Operations(this.apiClient);
|
|
9972
|
+
this.tunings = new Tunings(this.apiClient);
|
|
9561
9973
|
}
|
|
9562
9974
|
}
|
|
9563
9975
|
|
|
@@ -9569,6 +9981,7 @@ exports.CountTokensResponse = CountTokensResponse;
|
|
|
9569
9981
|
exports.CreateFileResponse = CreateFileResponse;
|
|
9570
9982
|
exports.DeleteCachedContentResponse = DeleteCachedContentResponse;
|
|
9571
9983
|
exports.DeleteFileResponse = DeleteFileResponse;
|
|
9984
|
+
exports.DeleteModelResponse = DeleteModelResponse;
|
|
9572
9985
|
exports.EmbedContentResponse = EmbedContentResponse;
|
|
9573
9986
|
exports.Files = Files;
|
|
9574
9987
|
exports.FunctionResponse = FunctionResponse;
|
|
@@ -9581,6 +9994,7 @@ exports.GoogleGenAI = GoogleGenAI;
|
|
|
9581
9994
|
exports.HttpResponse = HttpResponse;
|
|
9582
9995
|
exports.ListCachedContentsResponse = ListCachedContentsResponse;
|
|
9583
9996
|
exports.ListFilesResponse = ListFilesResponse;
|
|
9997
|
+
exports.ListTuningJobsResponse = ListTuningJobsResponse;
|
|
9584
9998
|
exports.Live = Live;
|
|
9585
9999
|
exports.LiveClientToolResponse = LiveClientToolResponse;
|
|
9586
10000
|
exports.LiveSendToolResponseParameters = LiveSendToolResponseParameters;
|