@google/genai 0.10.0 → 0.12.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 +576 -39
- package/dist/index.js +1320 -894
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1319 -895
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.js +1320 -894
- package/dist/node/index.js.map +1 -1
- package/dist/node/node.d.ts +576 -39
- package/dist/web/index.mjs +1319 -895
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +576 -39
- package/package.json +1 -1
package/dist/node/index.js
CHANGED
|
@@ -524,6 +524,20 @@ function tCachedContentName(apiClient, name) {
|
|
|
524
524
|
}
|
|
525
525
|
return resourceName(apiClient, name, 'cachedContents');
|
|
526
526
|
}
|
|
527
|
+
function tTuningJobStatus(apiClient, status) {
|
|
528
|
+
switch (status) {
|
|
529
|
+
case 'STATE_UNSPECIFIED':
|
|
530
|
+
return 'JOB_STATE_UNSPECIFIED';
|
|
531
|
+
case 'CREATING':
|
|
532
|
+
return 'JOB_STATE_RUNNING';
|
|
533
|
+
case 'ACTIVE':
|
|
534
|
+
return 'JOB_STATE_SUCCEEDED';
|
|
535
|
+
case 'FAILED':
|
|
536
|
+
return 'JOB_STATE_FAILED';
|
|
537
|
+
default:
|
|
538
|
+
return status;
|
|
539
|
+
}
|
|
540
|
+
}
|
|
527
541
|
function tBytes(apiClient, fromImageBytes) {
|
|
528
542
|
if (typeof fromImageBytes !== 'string') {
|
|
529
543
|
throw new Error('fromImageBytes must be a string');
|
|
@@ -596,14 +610,13 @@ function contentToMldev$2(apiClient, fromObject) {
|
|
|
596
610
|
const toObject = {};
|
|
597
611
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
598
612
|
if (fromParts != null) {
|
|
599
|
-
|
|
600
|
-
|
|
613
|
+
let transformedList = fromParts;
|
|
614
|
+
if (Array.isArray(transformedList)) {
|
|
615
|
+
transformedList = transformedList.map((item) => {
|
|
601
616
|
return partToMldev$2(apiClient, item);
|
|
602
|
-
})
|
|
603
|
-
}
|
|
604
|
-
else {
|
|
605
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
617
|
+
});
|
|
606
618
|
}
|
|
619
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
607
620
|
}
|
|
608
621
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
609
622
|
if (fromRole != null) {
|
|
@@ -611,25 +624,6 @@ function contentToMldev$2(apiClient, fromObject) {
|
|
|
611
624
|
}
|
|
612
625
|
return toObject;
|
|
613
626
|
}
|
|
614
|
-
function functionDeclarationToMldev$2(apiClient, fromObject) {
|
|
615
|
-
const toObject = {};
|
|
616
|
-
if (getValueByPath(fromObject, ['response']) !== undefined) {
|
|
617
|
-
throw new Error('response parameter is not supported in Gemini API.');
|
|
618
|
-
}
|
|
619
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
620
|
-
if (fromDescription != null) {
|
|
621
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
622
|
-
}
|
|
623
|
-
const fromName = getValueByPath(fromObject, ['name']);
|
|
624
|
-
if (fromName != null) {
|
|
625
|
-
setValueByPath(toObject, ['name'], fromName);
|
|
626
|
-
}
|
|
627
|
-
const fromParameters = getValueByPath(fromObject, ['parameters']);
|
|
628
|
-
if (fromParameters != null) {
|
|
629
|
-
setValueByPath(toObject, ['parameters'], fromParameters);
|
|
630
|
-
}
|
|
631
|
-
return toObject;
|
|
632
|
-
}
|
|
633
627
|
function googleSearchToMldev$2() {
|
|
634
628
|
const toObject = {};
|
|
635
629
|
return toObject;
|
|
@@ -660,19 +654,6 @@ function googleSearchRetrievalToMldev$2(apiClient, fromObject) {
|
|
|
660
654
|
}
|
|
661
655
|
function toolToMldev$2(apiClient, fromObject) {
|
|
662
656
|
const toObject = {};
|
|
663
|
-
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
664
|
-
'functionDeclarations',
|
|
665
|
-
]);
|
|
666
|
-
if (fromFunctionDeclarations != null) {
|
|
667
|
-
if (Array.isArray(fromFunctionDeclarations)) {
|
|
668
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations.map((item) => {
|
|
669
|
-
return functionDeclarationToMldev$2(apiClient, item);
|
|
670
|
-
}));
|
|
671
|
-
}
|
|
672
|
-
else {
|
|
673
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
674
|
-
}
|
|
675
|
-
}
|
|
676
657
|
if (getValueByPath(fromObject, ['retrieval']) !== undefined) {
|
|
677
658
|
throw new Error('retrieval parameter is not supported in Gemini API.');
|
|
678
659
|
}
|
|
@@ -692,6 +673,12 @@ function toolToMldev$2(apiClient, fromObject) {
|
|
|
692
673
|
if (fromCodeExecution != null) {
|
|
693
674
|
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
694
675
|
}
|
|
676
|
+
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
677
|
+
'functionDeclarations',
|
|
678
|
+
]);
|
|
679
|
+
if (fromFunctionDeclarations != null) {
|
|
680
|
+
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
681
|
+
}
|
|
695
682
|
return toObject;
|
|
696
683
|
}
|
|
697
684
|
function functionCallingConfigToMldev$1(apiClient, fromObject) {
|
|
@@ -734,14 +721,13 @@ function createCachedContentConfigToMldev(apiClient, fromObject, parentObject) {
|
|
|
734
721
|
}
|
|
735
722
|
const fromContents = getValueByPath(fromObject, ['contents']);
|
|
736
723
|
if (parentObject !== undefined && fromContents != null) {
|
|
737
|
-
|
|
738
|
-
|
|
724
|
+
let transformedList = tContents(apiClient, fromContents);
|
|
725
|
+
if (Array.isArray(transformedList)) {
|
|
726
|
+
transformedList = transformedList.map((item) => {
|
|
739
727
|
return contentToMldev$2(apiClient, item);
|
|
740
|
-
})
|
|
741
|
-
}
|
|
742
|
-
else {
|
|
743
|
-
setValueByPath(parentObject, ['contents'], tContents(apiClient, fromContents));
|
|
728
|
+
});
|
|
744
729
|
}
|
|
730
|
+
setValueByPath(parentObject, ['contents'], transformedList);
|
|
745
731
|
}
|
|
746
732
|
const fromSystemInstruction = getValueByPath(fromObject, [
|
|
747
733
|
'systemInstruction',
|
|
@@ -751,14 +737,13 @@ function createCachedContentConfigToMldev(apiClient, fromObject, parentObject) {
|
|
|
751
737
|
}
|
|
752
738
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
753
739
|
if (parentObject !== undefined && fromTools != null) {
|
|
754
|
-
|
|
755
|
-
|
|
740
|
+
let transformedList = fromTools;
|
|
741
|
+
if (Array.isArray(transformedList)) {
|
|
742
|
+
transformedList = transformedList.map((item) => {
|
|
756
743
|
return toolToMldev$2(apiClient, item);
|
|
757
|
-
})
|
|
758
|
-
}
|
|
759
|
-
else {
|
|
760
|
-
setValueByPath(parentObject, ['tools'], fromTools);
|
|
744
|
+
});
|
|
761
745
|
}
|
|
746
|
+
setValueByPath(parentObject, ['tools'], transformedList);
|
|
762
747
|
}
|
|
763
748
|
const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
|
|
764
749
|
if (parentObject !== undefined && fromToolConfig != null) {
|
|
@@ -898,14 +883,13 @@ function contentToVertex$2(apiClient, fromObject) {
|
|
|
898
883
|
const toObject = {};
|
|
899
884
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
900
885
|
if (fromParts != null) {
|
|
901
|
-
|
|
902
|
-
|
|
886
|
+
let transformedList = fromParts;
|
|
887
|
+
if (Array.isArray(transformedList)) {
|
|
888
|
+
transformedList = transformedList.map((item) => {
|
|
903
889
|
return partToVertex$2(apiClient, item);
|
|
904
|
-
})
|
|
905
|
-
}
|
|
906
|
-
else {
|
|
907
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
890
|
+
});
|
|
908
891
|
}
|
|
892
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
909
893
|
}
|
|
910
894
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
911
895
|
if (fromRole != null) {
|
|
@@ -913,124 +897,6 @@ function contentToVertex$2(apiClient, fromObject) {
|
|
|
913
897
|
}
|
|
914
898
|
return toObject;
|
|
915
899
|
}
|
|
916
|
-
function schemaToVertex$2(apiClient, fromObject) {
|
|
917
|
-
const toObject = {};
|
|
918
|
-
const fromExample = getValueByPath(fromObject, ['example']);
|
|
919
|
-
if (fromExample != null) {
|
|
920
|
-
setValueByPath(toObject, ['example'], fromExample);
|
|
921
|
-
}
|
|
922
|
-
const fromPattern = getValueByPath(fromObject, ['pattern']);
|
|
923
|
-
if (fromPattern != null) {
|
|
924
|
-
setValueByPath(toObject, ['pattern'], fromPattern);
|
|
925
|
-
}
|
|
926
|
-
const fromDefault = getValueByPath(fromObject, ['default']);
|
|
927
|
-
if (fromDefault != null) {
|
|
928
|
-
setValueByPath(toObject, ['default'], fromDefault);
|
|
929
|
-
}
|
|
930
|
-
const fromMaxLength = getValueByPath(fromObject, ['maxLength']);
|
|
931
|
-
if (fromMaxLength != null) {
|
|
932
|
-
setValueByPath(toObject, ['maxLength'], fromMaxLength);
|
|
933
|
-
}
|
|
934
|
-
const fromMinLength = getValueByPath(fromObject, ['minLength']);
|
|
935
|
-
if (fromMinLength != null) {
|
|
936
|
-
setValueByPath(toObject, ['minLength'], fromMinLength);
|
|
937
|
-
}
|
|
938
|
-
const fromMinProperties = getValueByPath(fromObject, [
|
|
939
|
-
'minProperties',
|
|
940
|
-
]);
|
|
941
|
-
if (fromMinProperties != null) {
|
|
942
|
-
setValueByPath(toObject, ['minProperties'], fromMinProperties);
|
|
943
|
-
}
|
|
944
|
-
const fromMaxProperties = getValueByPath(fromObject, [
|
|
945
|
-
'maxProperties',
|
|
946
|
-
]);
|
|
947
|
-
if (fromMaxProperties != null) {
|
|
948
|
-
setValueByPath(toObject, ['maxProperties'], fromMaxProperties);
|
|
949
|
-
}
|
|
950
|
-
const fromAnyOf = getValueByPath(fromObject, ['anyOf']);
|
|
951
|
-
if (fromAnyOf != null) {
|
|
952
|
-
setValueByPath(toObject, ['anyOf'], fromAnyOf);
|
|
953
|
-
}
|
|
954
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
955
|
-
if (fromDescription != null) {
|
|
956
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
957
|
-
}
|
|
958
|
-
const fromEnum = getValueByPath(fromObject, ['enum']);
|
|
959
|
-
if (fromEnum != null) {
|
|
960
|
-
setValueByPath(toObject, ['enum'], fromEnum);
|
|
961
|
-
}
|
|
962
|
-
const fromFormat = getValueByPath(fromObject, ['format']);
|
|
963
|
-
if (fromFormat != null) {
|
|
964
|
-
setValueByPath(toObject, ['format'], fromFormat);
|
|
965
|
-
}
|
|
966
|
-
const fromItems = getValueByPath(fromObject, ['items']);
|
|
967
|
-
if (fromItems != null) {
|
|
968
|
-
setValueByPath(toObject, ['items'], fromItems);
|
|
969
|
-
}
|
|
970
|
-
const fromMaxItems = getValueByPath(fromObject, ['maxItems']);
|
|
971
|
-
if (fromMaxItems != null) {
|
|
972
|
-
setValueByPath(toObject, ['maxItems'], fromMaxItems);
|
|
973
|
-
}
|
|
974
|
-
const fromMaximum = getValueByPath(fromObject, ['maximum']);
|
|
975
|
-
if (fromMaximum != null) {
|
|
976
|
-
setValueByPath(toObject, ['maximum'], fromMaximum);
|
|
977
|
-
}
|
|
978
|
-
const fromMinItems = getValueByPath(fromObject, ['minItems']);
|
|
979
|
-
if (fromMinItems != null) {
|
|
980
|
-
setValueByPath(toObject, ['minItems'], fromMinItems);
|
|
981
|
-
}
|
|
982
|
-
const fromMinimum = getValueByPath(fromObject, ['minimum']);
|
|
983
|
-
if (fromMinimum != null) {
|
|
984
|
-
setValueByPath(toObject, ['minimum'], fromMinimum);
|
|
985
|
-
}
|
|
986
|
-
const fromNullable = getValueByPath(fromObject, ['nullable']);
|
|
987
|
-
if (fromNullable != null) {
|
|
988
|
-
setValueByPath(toObject, ['nullable'], fromNullable);
|
|
989
|
-
}
|
|
990
|
-
const fromProperties = getValueByPath(fromObject, ['properties']);
|
|
991
|
-
if (fromProperties != null) {
|
|
992
|
-
setValueByPath(toObject, ['properties'], fromProperties);
|
|
993
|
-
}
|
|
994
|
-
const fromPropertyOrdering = getValueByPath(fromObject, [
|
|
995
|
-
'propertyOrdering',
|
|
996
|
-
]);
|
|
997
|
-
if (fromPropertyOrdering != null) {
|
|
998
|
-
setValueByPath(toObject, ['propertyOrdering'], fromPropertyOrdering);
|
|
999
|
-
}
|
|
1000
|
-
const fromRequired = getValueByPath(fromObject, ['required']);
|
|
1001
|
-
if (fromRequired != null) {
|
|
1002
|
-
setValueByPath(toObject, ['required'], fromRequired);
|
|
1003
|
-
}
|
|
1004
|
-
const fromTitle = getValueByPath(fromObject, ['title']);
|
|
1005
|
-
if (fromTitle != null) {
|
|
1006
|
-
setValueByPath(toObject, ['title'], fromTitle);
|
|
1007
|
-
}
|
|
1008
|
-
const fromType = getValueByPath(fromObject, ['type']);
|
|
1009
|
-
if (fromType != null) {
|
|
1010
|
-
setValueByPath(toObject, ['type'], fromType);
|
|
1011
|
-
}
|
|
1012
|
-
return toObject;
|
|
1013
|
-
}
|
|
1014
|
-
function functionDeclarationToVertex$2(apiClient, fromObject) {
|
|
1015
|
-
const toObject = {};
|
|
1016
|
-
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
1017
|
-
if (fromResponse != null) {
|
|
1018
|
-
setValueByPath(toObject, ['response'], schemaToVertex$2(apiClient, fromResponse));
|
|
1019
|
-
}
|
|
1020
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
1021
|
-
if (fromDescription != null) {
|
|
1022
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
1023
|
-
}
|
|
1024
|
-
const fromName = getValueByPath(fromObject, ['name']);
|
|
1025
|
-
if (fromName != null) {
|
|
1026
|
-
setValueByPath(toObject, ['name'], fromName);
|
|
1027
|
-
}
|
|
1028
|
-
const fromParameters = getValueByPath(fromObject, ['parameters']);
|
|
1029
|
-
if (fromParameters != null) {
|
|
1030
|
-
setValueByPath(toObject, ['parameters'], fromParameters);
|
|
1031
|
-
}
|
|
1032
|
-
return toObject;
|
|
1033
|
-
}
|
|
1034
900
|
function googleSearchToVertex$2() {
|
|
1035
901
|
const toObject = {};
|
|
1036
902
|
return toObject;
|
|
@@ -1061,19 +927,6 @@ function googleSearchRetrievalToVertex$2(apiClient, fromObject) {
|
|
|
1061
927
|
}
|
|
1062
928
|
function toolToVertex$2(apiClient, fromObject) {
|
|
1063
929
|
const toObject = {};
|
|
1064
|
-
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
1065
|
-
'functionDeclarations',
|
|
1066
|
-
]);
|
|
1067
|
-
if (fromFunctionDeclarations != null) {
|
|
1068
|
-
if (Array.isArray(fromFunctionDeclarations)) {
|
|
1069
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations.map((item) => {
|
|
1070
|
-
return functionDeclarationToVertex$2(apiClient, item);
|
|
1071
|
-
}));
|
|
1072
|
-
}
|
|
1073
|
-
else {
|
|
1074
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
1075
|
-
}
|
|
1076
|
-
}
|
|
1077
930
|
const fromRetrieval = getValueByPath(fromObject, ['retrieval']);
|
|
1078
931
|
if (fromRetrieval != null) {
|
|
1079
932
|
setValueByPath(toObject, ['retrieval'], fromRetrieval);
|
|
@@ -1094,6 +947,12 @@ function toolToVertex$2(apiClient, fromObject) {
|
|
|
1094
947
|
if (fromCodeExecution != null) {
|
|
1095
948
|
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
1096
949
|
}
|
|
950
|
+
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
951
|
+
'functionDeclarations',
|
|
952
|
+
]);
|
|
953
|
+
if (fromFunctionDeclarations != null) {
|
|
954
|
+
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
955
|
+
}
|
|
1097
956
|
return toObject;
|
|
1098
957
|
}
|
|
1099
958
|
function functionCallingConfigToVertex$1(apiClient, fromObject) {
|
|
@@ -1136,14 +995,13 @@ function createCachedContentConfigToVertex(apiClient, fromObject, parentObject)
|
|
|
1136
995
|
}
|
|
1137
996
|
const fromContents = getValueByPath(fromObject, ['contents']);
|
|
1138
997
|
if (parentObject !== undefined && fromContents != null) {
|
|
1139
|
-
|
|
1140
|
-
|
|
998
|
+
let transformedList = tContents(apiClient, fromContents);
|
|
999
|
+
if (Array.isArray(transformedList)) {
|
|
1000
|
+
transformedList = transformedList.map((item) => {
|
|
1141
1001
|
return contentToVertex$2(apiClient, item);
|
|
1142
|
-
})
|
|
1143
|
-
}
|
|
1144
|
-
else {
|
|
1145
|
-
setValueByPath(parentObject, ['contents'], tContents(apiClient, fromContents));
|
|
1002
|
+
});
|
|
1146
1003
|
}
|
|
1004
|
+
setValueByPath(parentObject, ['contents'], transformedList);
|
|
1147
1005
|
}
|
|
1148
1006
|
const fromSystemInstruction = getValueByPath(fromObject, [
|
|
1149
1007
|
'systemInstruction',
|
|
@@ -1153,14 +1011,13 @@ function createCachedContentConfigToVertex(apiClient, fromObject, parentObject)
|
|
|
1153
1011
|
}
|
|
1154
1012
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
1155
1013
|
if (parentObject !== undefined && fromTools != null) {
|
|
1156
|
-
|
|
1157
|
-
|
|
1014
|
+
let transformedList = fromTools;
|
|
1015
|
+
if (Array.isArray(transformedList)) {
|
|
1016
|
+
transformedList = transformedList.map((item) => {
|
|
1158
1017
|
return toolToVertex$2(apiClient, item);
|
|
1159
|
-
})
|
|
1160
|
-
}
|
|
1161
|
-
else {
|
|
1162
|
-
setValueByPath(parentObject, ['tools'], fromTools);
|
|
1018
|
+
});
|
|
1163
1019
|
}
|
|
1020
|
+
setValueByPath(parentObject, ['tools'], transformedList);
|
|
1164
1021
|
}
|
|
1165
1022
|
const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
|
|
1166
1023
|
if (parentObject !== undefined && fromToolConfig != null) {
|
|
@@ -1298,14 +1155,13 @@ function listCachedContentsResponseFromMldev(apiClient, fromObject) {
|
|
|
1298
1155
|
'cachedContents',
|
|
1299
1156
|
]);
|
|
1300
1157
|
if (fromCachedContents != null) {
|
|
1301
|
-
|
|
1302
|
-
|
|
1158
|
+
let transformedList = fromCachedContents;
|
|
1159
|
+
if (Array.isArray(transformedList)) {
|
|
1160
|
+
transformedList = transformedList.map((item) => {
|
|
1303
1161
|
return cachedContentFromMldev(apiClient, item);
|
|
1304
|
-
})
|
|
1305
|
-
}
|
|
1306
|
-
else {
|
|
1307
|
-
setValueByPath(toObject, ['cachedContents'], fromCachedContents);
|
|
1162
|
+
});
|
|
1308
1163
|
}
|
|
1164
|
+
setValueByPath(toObject, ['cachedContents'], transformedList);
|
|
1309
1165
|
}
|
|
1310
1166
|
return toObject;
|
|
1311
1167
|
}
|
|
@@ -1359,14 +1215,13 @@ function listCachedContentsResponseFromVertex(apiClient, fromObject) {
|
|
|
1359
1215
|
'cachedContents',
|
|
1360
1216
|
]);
|
|
1361
1217
|
if (fromCachedContents != null) {
|
|
1362
|
-
|
|
1363
|
-
|
|
1218
|
+
let transformedList = fromCachedContents;
|
|
1219
|
+
if (Array.isArray(transformedList)) {
|
|
1220
|
+
transformedList = transformedList.map((item) => {
|
|
1364
1221
|
return cachedContentFromVertex(apiClient, item);
|
|
1365
|
-
})
|
|
1366
|
-
}
|
|
1367
|
-
else {
|
|
1368
|
-
setValueByPath(toObject, ['cachedContents'], fromCachedContents);
|
|
1222
|
+
});
|
|
1369
1223
|
}
|
|
1224
|
+
setValueByPath(toObject, ['cachedContents'], transformedList);
|
|
1370
1225
|
}
|
|
1371
1226
|
return toObject;
|
|
1372
1227
|
}
|
|
@@ -1568,17 +1423,6 @@ exports.Language = void 0;
|
|
|
1568
1423
|
Language["LANGUAGE_UNSPECIFIED"] = "LANGUAGE_UNSPECIFIED";
|
|
1569
1424
|
Language["PYTHON"] = "PYTHON";
|
|
1570
1425
|
})(exports.Language || (exports.Language = {}));
|
|
1571
|
-
/** Optional. The type of the data. */
|
|
1572
|
-
exports.Type = void 0;
|
|
1573
|
-
(function (Type) {
|
|
1574
|
-
Type["TYPE_UNSPECIFIED"] = "TYPE_UNSPECIFIED";
|
|
1575
|
-
Type["STRING"] = "STRING";
|
|
1576
|
-
Type["NUMBER"] = "NUMBER";
|
|
1577
|
-
Type["INTEGER"] = "INTEGER";
|
|
1578
|
-
Type["BOOLEAN"] = "BOOLEAN";
|
|
1579
|
-
Type["ARRAY"] = "ARRAY";
|
|
1580
|
-
Type["OBJECT"] = "OBJECT";
|
|
1581
|
-
})(exports.Type || (exports.Type = {}));
|
|
1582
1426
|
/** Required. Harm category. */
|
|
1583
1427
|
exports.HarmCategory = void 0;
|
|
1584
1428
|
(function (HarmCategory) {
|
|
@@ -1612,6 +1456,17 @@ exports.Mode = void 0;
|
|
|
1612
1456
|
Mode["MODE_UNSPECIFIED"] = "MODE_UNSPECIFIED";
|
|
1613
1457
|
Mode["MODE_DYNAMIC"] = "MODE_DYNAMIC";
|
|
1614
1458
|
})(exports.Mode || (exports.Mode = {}));
|
|
1459
|
+
/** Optional. The type of the data. */
|
|
1460
|
+
exports.Type = void 0;
|
|
1461
|
+
(function (Type) {
|
|
1462
|
+
Type["TYPE_UNSPECIFIED"] = "TYPE_UNSPECIFIED";
|
|
1463
|
+
Type["STRING"] = "STRING";
|
|
1464
|
+
Type["NUMBER"] = "NUMBER";
|
|
1465
|
+
Type["INTEGER"] = "INTEGER";
|
|
1466
|
+
Type["BOOLEAN"] = "BOOLEAN";
|
|
1467
|
+
Type["ARRAY"] = "ARRAY";
|
|
1468
|
+
Type["OBJECT"] = "OBJECT";
|
|
1469
|
+
})(exports.Type || (exports.Type = {}));
|
|
1615
1470
|
/** Output only. The reason why the model stopped generating tokens.
|
|
1616
1471
|
|
|
1617
1472
|
If empty, the model has not stopped generating the tokens.
|
|
@@ -1681,6 +1536,33 @@ exports.MediaResolution = void 0;
|
|
|
1681
1536
|
MediaResolution["MEDIA_RESOLUTION_MEDIUM"] = "MEDIA_RESOLUTION_MEDIUM";
|
|
1682
1537
|
MediaResolution["MEDIA_RESOLUTION_HIGH"] = "MEDIA_RESOLUTION_HIGH";
|
|
1683
1538
|
})(exports.MediaResolution || (exports.MediaResolution = {}));
|
|
1539
|
+
/** Output only. The detailed state of the job. */
|
|
1540
|
+
exports.JobState = void 0;
|
|
1541
|
+
(function (JobState) {
|
|
1542
|
+
JobState["JOB_STATE_UNSPECIFIED"] = "JOB_STATE_UNSPECIFIED";
|
|
1543
|
+
JobState["JOB_STATE_QUEUED"] = "JOB_STATE_QUEUED";
|
|
1544
|
+
JobState["JOB_STATE_PENDING"] = "JOB_STATE_PENDING";
|
|
1545
|
+
JobState["JOB_STATE_RUNNING"] = "JOB_STATE_RUNNING";
|
|
1546
|
+
JobState["JOB_STATE_SUCCEEDED"] = "JOB_STATE_SUCCEEDED";
|
|
1547
|
+
JobState["JOB_STATE_FAILED"] = "JOB_STATE_FAILED";
|
|
1548
|
+
JobState["JOB_STATE_CANCELLING"] = "JOB_STATE_CANCELLING";
|
|
1549
|
+
JobState["JOB_STATE_CANCELLED"] = "JOB_STATE_CANCELLED";
|
|
1550
|
+
JobState["JOB_STATE_PAUSED"] = "JOB_STATE_PAUSED";
|
|
1551
|
+
JobState["JOB_STATE_EXPIRED"] = "JOB_STATE_EXPIRED";
|
|
1552
|
+
JobState["JOB_STATE_UPDATING"] = "JOB_STATE_UPDATING";
|
|
1553
|
+
JobState["JOB_STATE_PARTIALLY_SUCCEEDED"] = "JOB_STATE_PARTIALLY_SUCCEEDED";
|
|
1554
|
+
})(exports.JobState || (exports.JobState = {}));
|
|
1555
|
+
/** Optional. Adapter size for tuning. */
|
|
1556
|
+
exports.AdapterSize = void 0;
|
|
1557
|
+
(function (AdapterSize) {
|
|
1558
|
+
AdapterSize["ADAPTER_SIZE_UNSPECIFIED"] = "ADAPTER_SIZE_UNSPECIFIED";
|
|
1559
|
+
AdapterSize["ADAPTER_SIZE_ONE"] = "ADAPTER_SIZE_ONE";
|
|
1560
|
+
AdapterSize["ADAPTER_SIZE_TWO"] = "ADAPTER_SIZE_TWO";
|
|
1561
|
+
AdapterSize["ADAPTER_SIZE_FOUR"] = "ADAPTER_SIZE_FOUR";
|
|
1562
|
+
AdapterSize["ADAPTER_SIZE_EIGHT"] = "ADAPTER_SIZE_EIGHT";
|
|
1563
|
+
AdapterSize["ADAPTER_SIZE_SIXTEEN"] = "ADAPTER_SIZE_SIXTEEN";
|
|
1564
|
+
AdapterSize["ADAPTER_SIZE_THIRTY_TWO"] = "ADAPTER_SIZE_THIRTY_TWO";
|
|
1565
|
+
})(exports.AdapterSize || (exports.AdapterSize = {}));
|
|
1684
1566
|
/** Options for feature selection preference. */
|
|
1685
1567
|
exports.FeatureSelectionPreference = void 0;
|
|
1686
1568
|
(function (FeatureSelectionPreference) {
|
|
@@ -2181,6 +2063,8 @@ class EmbedContentResponse {
|
|
|
2181
2063
|
/** The output images response. */
|
|
2182
2064
|
class GenerateImagesResponse {
|
|
2183
2065
|
}
|
|
2066
|
+
class DeleteModelResponse {
|
|
2067
|
+
}
|
|
2184
2068
|
/** Response for counting tokens. */
|
|
2185
2069
|
class CountTokensResponse {
|
|
2186
2070
|
}
|
|
@@ -2190,6 +2074,9 @@ class ComputeTokensResponse {
|
|
|
2190
2074
|
/** Response with generated videos. */
|
|
2191
2075
|
class GenerateVideosResponse {
|
|
2192
2076
|
}
|
|
2077
|
+
/** Response for the list tuning jobs method. */
|
|
2078
|
+
class ListTuningJobsResponse {
|
|
2079
|
+
}
|
|
2193
2080
|
/** Empty response for caches.delete method. */
|
|
2194
2081
|
class DeleteCachedContentResponse {
|
|
2195
2082
|
}
|
|
@@ -2286,7 +2173,7 @@ class Caches extends BaseModule {
|
|
|
2286
2173
|
* ```ts
|
|
2287
2174
|
* const contents = ...; // Initialize the content to cache.
|
|
2288
2175
|
* const response = await ai.caches.create({
|
|
2289
|
-
* model: 'gemini-
|
|
2176
|
+
* model: 'gemini-2.0-flash-001',
|
|
2290
2177
|
* config: {
|
|
2291
2178
|
* 'contents': contents,
|
|
2292
2179
|
* 'displayName': 'test cache',
|
|
@@ -2358,7 +2245,7 @@ class Caches extends BaseModule {
|
|
|
2358
2245
|
*
|
|
2359
2246
|
* @example
|
|
2360
2247
|
* ```ts
|
|
2361
|
-
* await ai.caches.get({name: '
|
|
2248
|
+
* await ai.caches.get({name: '...'}); // The server-generated resource name.
|
|
2362
2249
|
* ```
|
|
2363
2250
|
*/
|
|
2364
2251
|
async get(params) {
|
|
@@ -2423,7 +2310,7 @@ class Caches extends BaseModule {
|
|
|
2423
2310
|
*
|
|
2424
2311
|
* @example
|
|
2425
2312
|
* ```ts
|
|
2426
|
-
* await ai.caches.delete({name: '
|
|
2313
|
+
* await ai.caches.delete({name: '...'}); // The server-generated resource name.
|
|
2427
2314
|
* ```
|
|
2428
2315
|
*/
|
|
2429
2316
|
async delete(params) {
|
|
@@ -2493,7 +2380,7 @@ class Caches extends BaseModule {
|
|
|
2493
2380
|
* @example
|
|
2494
2381
|
* ```ts
|
|
2495
2382
|
* const response = await ai.caches.update({
|
|
2496
|
-
* name: '
|
|
2383
|
+
* name: '...', // The server-generated resource name.
|
|
2497
2384
|
* config: {'ttl': '7600s'}
|
|
2498
2385
|
* });
|
|
2499
2386
|
* ```
|
|
@@ -2891,7 +2778,12 @@ class Chat {
|
|
|
2891
2778
|
contents: this.getHistory(true).concat(inputContent),
|
|
2892
2779
|
config: (_a = params.config) !== null && _a !== void 0 ? _a : this.config,
|
|
2893
2780
|
});
|
|
2894
|
-
|
|
2781
|
+
// Resolve the internal tracking of send completion promise - `sendPromise`
|
|
2782
|
+
// for both success and failure response. The actual failure is still
|
|
2783
|
+
// propagated by the `await streamResponse`.
|
|
2784
|
+
this.sendPromise = streamResponse
|
|
2785
|
+
.then(() => undefined)
|
|
2786
|
+
.catch(() => undefined);
|
|
2895
2787
|
const response = await streamResponse;
|
|
2896
2788
|
const result = this.processStreamResponse(response, inputContent);
|
|
2897
2789
|
return result;
|
|
@@ -3201,14 +3093,13 @@ function listFilesResponseFromMldev(apiClient, fromObject) {
|
|
|
3201
3093
|
}
|
|
3202
3094
|
const fromFiles = getValueByPath(fromObject, ['files']);
|
|
3203
3095
|
if (fromFiles != null) {
|
|
3204
|
-
|
|
3205
|
-
|
|
3096
|
+
let transformedList = fromFiles;
|
|
3097
|
+
if (Array.isArray(transformedList)) {
|
|
3098
|
+
transformedList = transformedList.map((item) => {
|
|
3206
3099
|
return fileFromMldev(apiClient, item);
|
|
3207
|
-
})
|
|
3208
|
-
}
|
|
3209
|
-
else {
|
|
3210
|
-
setValueByPath(toObject, ['files'], fromFiles);
|
|
3100
|
+
});
|
|
3211
3101
|
}
|
|
3102
|
+
setValueByPath(toObject, ['files'], transformedList);
|
|
3212
3103
|
}
|
|
3213
3104
|
return toObject;
|
|
3214
3105
|
}
|
|
@@ -3575,14 +3466,13 @@ function contentToMldev$1(apiClient, fromObject) {
|
|
|
3575
3466
|
const toObject = {};
|
|
3576
3467
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
3577
3468
|
if (fromParts != null) {
|
|
3578
|
-
|
|
3579
|
-
|
|
3469
|
+
let transformedList = fromParts;
|
|
3470
|
+
if (Array.isArray(transformedList)) {
|
|
3471
|
+
transformedList = transformedList.map((item) => {
|
|
3580
3472
|
return partToMldev$1(apiClient, item);
|
|
3581
|
-
})
|
|
3582
|
-
}
|
|
3583
|
-
else {
|
|
3584
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
3473
|
+
});
|
|
3585
3474
|
}
|
|
3475
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
3586
3476
|
}
|
|
3587
3477
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
3588
3478
|
if (fromRole != null) {
|
|
@@ -3594,14 +3484,13 @@ function contentToVertex$1(apiClient, fromObject) {
|
|
|
3594
3484
|
const toObject = {};
|
|
3595
3485
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
3596
3486
|
if (fromParts != null) {
|
|
3597
|
-
|
|
3598
|
-
|
|
3487
|
+
let transformedList = fromParts;
|
|
3488
|
+
if (Array.isArray(transformedList)) {
|
|
3489
|
+
transformedList = transformedList.map((item) => {
|
|
3599
3490
|
return partToVertex$1(apiClient, item);
|
|
3600
|
-
})
|
|
3601
|
-
}
|
|
3602
|
-
else {
|
|
3603
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
3491
|
+
});
|
|
3604
3492
|
}
|
|
3493
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
3605
3494
|
}
|
|
3606
3495
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
3607
3496
|
if (fromRole != null) {
|
|
@@ -3609,143 +3498,6 @@ function contentToVertex$1(apiClient, fromObject) {
|
|
|
3609
3498
|
}
|
|
3610
3499
|
return toObject;
|
|
3611
3500
|
}
|
|
3612
|
-
function schemaToVertex$1(apiClient, fromObject) {
|
|
3613
|
-
const toObject = {};
|
|
3614
|
-
const fromExample = getValueByPath(fromObject, ['example']);
|
|
3615
|
-
if (fromExample != null) {
|
|
3616
|
-
setValueByPath(toObject, ['example'], fromExample);
|
|
3617
|
-
}
|
|
3618
|
-
const fromPattern = getValueByPath(fromObject, ['pattern']);
|
|
3619
|
-
if (fromPattern != null) {
|
|
3620
|
-
setValueByPath(toObject, ['pattern'], fromPattern);
|
|
3621
|
-
}
|
|
3622
|
-
const fromDefault = getValueByPath(fromObject, ['default']);
|
|
3623
|
-
if (fromDefault != null) {
|
|
3624
|
-
setValueByPath(toObject, ['default'], fromDefault);
|
|
3625
|
-
}
|
|
3626
|
-
const fromMaxLength = getValueByPath(fromObject, ['maxLength']);
|
|
3627
|
-
if (fromMaxLength != null) {
|
|
3628
|
-
setValueByPath(toObject, ['maxLength'], fromMaxLength);
|
|
3629
|
-
}
|
|
3630
|
-
const fromMinLength = getValueByPath(fromObject, ['minLength']);
|
|
3631
|
-
if (fromMinLength != null) {
|
|
3632
|
-
setValueByPath(toObject, ['minLength'], fromMinLength);
|
|
3633
|
-
}
|
|
3634
|
-
const fromMinProperties = getValueByPath(fromObject, [
|
|
3635
|
-
'minProperties',
|
|
3636
|
-
]);
|
|
3637
|
-
if (fromMinProperties != null) {
|
|
3638
|
-
setValueByPath(toObject, ['minProperties'], fromMinProperties);
|
|
3639
|
-
}
|
|
3640
|
-
const fromMaxProperties = getValueByPath(fromObject, [
|
|
3641
|
-
'maxProperties',
|
|
3642
|
-
]);
|
|
3643
|
-
if (fromMaxProperties != null) {
|
|
3644
|
-
setValueByPath(toObject, ['maxProperties'], fromMaxProperties);
|
|
3645
|
-
}
|
|
3646
|
-
const fromAnyOf = getValueByPath(fromObject, ['anyOf']);
|
|
3647
|
-
if (fromAnyOf != null) {
|
|
3648
|
-
setValueByPath(toObject, ['anyOf'], fromAnyOf);
|
|
3649
|
-
}
|
|
3650
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
3651
|
-
if (fromDescription != null) {
|
|
3652
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
3653
|
-
}
|
|
3654
|
-
const fromEnum = getValueByPath(fromObject, ['enum']);
|
|
3655
|
-
if (fromEnum != null) {
|
|
3656
|
-
setValueByPath(toObject, ['enum'], fromEnum);
|
|
3657
|
-
}
|
|
3658
|
-
const fromFormat = getValueByPath(fromObject, ['format']);
|
|
3659
|
-
if (fromFormat != null) {
|
|
3660
|
-
setValueByPath(toObject, ['format'], fromFormat);
|
|
3661
|
-
}
|
|
3662
|
-
const fromItems = getValueByPath(fromObject, ['items']);
|
|
3663
|
-
if (fromItems != null) {
|
|
3664
|
-
setValueByPath(toObject, ['items'], fromItems);
|
|
3665
|
-
}
|
|
3666
|
-
const fromMaxItems = getValueByPath(fromObject, ['maxItems']);
|
|
3667
|
-
if (fromMaxItems != null) {
|
|
3668
|
-
setValueByPath(toObject, ['maxItems'], fromMaxItems);
|
|
3669
|
-
}
|
|
3670
|
-
const fromMaximum = getValueByPath(fromObject, ['maximum']);
|
|
3671
|
-
if (fromMaximum != null) {
|
|
3672
|
-
setValueByPath(toObject, ['maximum'], fromMaximum);
|
|
3673
|
-
}
|
|
3674
|
-
const fromMinItems = getValueByPath(fromObject, ['minItems']);
|
|
3675
|
-
if (fromMinItems != null) {
|
|
3676
|
-
setValueByPath(toObject, ['minItems'], fromMinItems);
|
|
3677
|
-
}
|
|
3678
|
-
const fromMinimum = getValueByPath(fromObject, ['minimum']);
|
|
3679
|
-
if (fromMinimum != null) {
|
|
3680
|
-
setValueByPath(toObject, ['minimum'], fromMinimum);
|
|
3681
|
-
}
|
|
3682
|
-
const fromNullable = getValueByPath(fromObject, ['nullable']);
|
|
3683
|
-
if (fromNullable != null) {
|
|
3684
|
-
setValueByPath(toObject, ['nullable'], fromNullable);
|
|
3685
|
-
}
|
|
3686
|
-
const fromProperties = getValueByPath(fromObject, ['properties']);
|
|
3687
|
-
if (fromProperties != null) {
|
|
3688
|
-
setValueByPath(toObject, ['properties'], fromProperties);
|
|
3689
|
-
}
|
|
3690
|
-
const fromPropertyOrdering = getValueByPath(fromObject, [
|
|
3691
|
-
'propertyOrdering',
|
|
3692
|
-
]);
|
|
3693
|
-
if (fromPropertyOrdering != null) {
|
|
3694
|
-
setValueByPath(toObject, ['propertyOrdering'], fromPropertyOrdering);
|
|
3695
|
-
}
|
|
3696
|
-
const fromRequired = getValueByPath(fromObject, ['required']);
|
|
3697
|
-
if (fromRequired != null) {
|
|
3698
|
-
setValueByPath(toObject, ['required'], fromRequired);
|
|
3699
|
-
}
|
|
3700
|
-
const fromTitle = getValueByPath(fromObject, ['title']);
|
|
3701
|
-
if (fromTitle != null) {
|
|
3702
|
-
setValueByPath(toObject, ['title'], fromTitle);
|
|
3703
|
-
}
|
|
3704
|
-
const fromType = getValueByPath(fromObject, ['type']);
|
|
3705
|
-
if (fromType != null) {
|
|
3706
|
-
setValueByPath(toObject, ['type'], fromType);
|
|
3707
|
-
}
|
|
3708
|
-
return toObject;
|
|
3709
|
-
}
|
|
3710
|
-
function functionDeclarationToMldev$1(apiClient, fromObject) {
|
|
3711
|
-
const toObject = {};
|
|
3712
|
-
if (getValueByPath(fromObject, ['response']) !== undefined) {
|
|
3713
|
-
throw new Error('response parameter is not supported in Gemini API.');
|
|
3714
|
-
}
|
|
3715
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
3716
|
-
if (fromDescription != null) {
|
|
3717
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
3718
|
-
}
|
|
3719
|
-
const fromName = getValueByPath(fromObject, ['name']);
|
|
3720
|
-
if (fromName != null) {
|
|
3721
|
-
setValueByPath(toObject, ['name'], fromName);
|
|
3722
|
-
}
|
|
3723
|
-
const fromParameters = getValueByPath(fromObject, ['parameters']);
|
|
3724
|
-
if (fromParameters != null) {
|
|
3725
|
-
setValueByPath(toObject, ['parameters'], fromParameters);
|
|
3726
|
-
}
|
|
3727
|
-
return toObject;
|
|
3728
|
-
}
|
|
3729
|
-
function functionDeclarationToVertex$1(apiClient, fromObject) {
|
|
3730
|
-
const toObject = {};
|
|
3731
|
-
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
3732
|
-
if (fromResponse != null) {
|
|
3733
|
-
setValueByPath(toObject, ['response'], schemaToVertex$1(apiClient, fromResponse));
|
|
3734
|
-
}
|
|
3735
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
3736
|
-
if (fromDescription != null) {
|
|
3737
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
3738
|
-
}
|
|
3739
|
-
const fromName = getValueByPath(fromObject, ['name']);
|
|
3740
|
-
if (fromName != null) {
|
|
3741
|
-
setValueByPath(toObject, ['name'], fromName);
|
|
3742
|
-
}
|
|
3743
|
-
const fromParameters = getValueByPath(fromObject, ['parameters']);
|
|
3744
|
-
if (fromParameters != null) {
|
|
3745
|
-
setValueByPath(toObject, ['parameters'], fromParameters);
|
|
3746
|
-
}
|
|
3747
|
-
return toObject;
|
|
3748
|
-
}
|
|
3749
3501
|
function googleSearchToMldev$1() {
|
|
3750
3502
|
const toObject = {};
|
|
3751
3503
|
return toObject;
|
|
@@ -3804,19 +3556,6 @@ function googleSearchRetrievalToVertex$1(apiClient, fromObject) {
|
|
|
3804
3556
|
}
|
|
3805
3557
|
function toolToMldev$1(apiClient, fromObject) {
|
|
3806
3558
|
const toObject = {};
|
|
3807
|
-
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
3808
|
-
'functionDeclarations',
|
|
3809
|
-
]);
|
|
3810
|
-
if (fromFunctionDeclarations != null) {
|
|
3811
|
-
if (Array.isArray(fromFunctionDeclarations)) {
|
|
3812
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations.map((item) => {
|
|
3813
|
-
return functionDeclarationToMldev$1(apiClient, item);
|
|
3814
|
-
}));
|
|
3815
|
-
}
|
|
3816
|
-
else {
|
|
3817
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
3818
|
-
}
|
|
3819
|
-
}
|
|
3820
3559
|
if (getValueByPath(fromObject, ['retrieval']) !== undefined) {
|
|
3821
3560
|
throw new Error('retrieval parameter is not supported in Gemini API.');
|
|
3822
3561
|
}
|
|
@@ -3836,23 +3575,16 @@ function toolToMldev$1(apiClient, fromObject) {
|
|
|
3836
3575
|
if (fromCodeExecution != null) {
|
|
3837
3576
|
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
3838
3577
|
}
|
|
3839
|
-
return toObject;
|
|
3840
|
-
}
|
|
3841
|
-
function toolToVertex$1(apiClient, fromObject) {
|
|
3842
|
-
const toObject = {};
|
|
3843
3578
|
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
3844
3579
|
'functionDeclarations',
|
|
3845
3580
|
]);
|
|
3846
3581
|
if (fromFunctionDeclarations != null) {
|
|
3847
|
-
|
|
3848
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations.map((item) => {
|
|
3849
|
-
return functionDeclarationToVertex$1(apiClient, item);
|
|
3850
|
-
}));
|
|
3851
|
-
}
|
|
3852
|
-
else {
|
|
3853
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
3854
|
-
}
|
|
3582
|
+
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
3855
3583
|
}
|
|
3584
|
+
return toObject;
|
|
3585
|
+
}
|
|
3586
|
+
function toolToVertex$1(apiClient, fromObject) {
|
|
3587
|
+
const toObject = {};
|
|
3856
3588
|
const fromRetrieval = getValueByPath(fromObject, ['retrieval']);
|
|
3857
3589
|
if (fromRetrieval != null) {
|
|
3858
3590
|
setValueByPath(toObject, ['retrieval'], fromRetrieval);
|
|
@@ -3873,6 +3605,12 @@ function toolToVertex$1(apiClient, fromObject) {
|
|
|
3873
3605
|
if (fromCodeExecution != null) {
|
|
3874
3606
|
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
3875
3607
|
}
|
|
3608
|
+
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
3609
|
+
'functionDeclarations',
|
|
3610
|
+
]);
|
|
3611
|
+
if (fromFunctionDeclarations != null) {
|
|
3612
|
+
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
3613
|
+
}
|
|
3876
3614
|
return toObject;
|
|
3877
3615
|
}
|
|
3878
3616
|
function sessionResumptionConfigToMldev(apiClient, fromObject) {
|
|
@@ -4112,14 +3850,13 @@ function liveConnectConfigToMldev(apiClient, fromObject, parentObject) {
|
|
|
4112
3850
|
}
|
|
4113
3851
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
4114
3852
|
if (parentObject !== undefined && fromTools != null) {
|
|
4115
|
-
|
|
4116
|
-
|
|
3853
|
+
let transformedList = tTools(apiClient, fromTools);
|
|
3854
|
+
if (Array.isArray(transformedList)) {
|
|
3855
|
+
transformedList = transformedList.map((item) => {
|
|
4117
3856
|
return toolToMldev$1(apiClient, tTool(apiClient, item));
|
|
4118
|
-
})
|
|
4119
|
-
}
|
|
4120
|
-
else {
|
|
4121
|
-
setValueByPath(parentObject, ['setup', 'tools'], tTools(apiClient, fromTools));
|
|
3857
|
+
});
|
|
4122
3858
|
}
|
|
3859
|
+
setValueByPath(parentObject, ['setup', 'tools'], transformedList);
|
|
4123
3860
|
}
|
|
4124
3861
|
const fromSessionResumption = getValueByPath(fromObject, [
|
|
4125
3862
|
'sessionResumption',
|
|
@@ -4204,14 +3941,13 @@ function liveConnectConfigToVertex(apiClient, fromObject, parentObject) {
|
|
|
4204
3941
|
}
|
|
4205
3942
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
4206
3943
|
if (parentObject !== undefined && fromTools != null) {
|
|
4207
|
-
|
|
4208
|
-
|
|
3944
|
+
let transformedList = tTools(apiClient, fromTools);
|
|
3945
|
+
if (Array.isArray(transformedList)) {
|
|
3946
|
+
transformedList = transformedList.map((item) => {
|
|
4209
3947
|
return toolToVertex$1(apiClient, tTool(apiClient, item));
|
|
4210
|
-
})
|
|
4211
|
-
}
|
|
4212
|
-
else {
|
|
4213
|
-
setValueByPath(parentObject, ['setup', 'tools'], tTools(apiClient, fromTools));
|
|
3948
|
+
});
|
|
4214
3949
|
}
|
|
3950
|
+
setValueByPath(parentObject, ['setup', 'tools'], transformedList);
|
|
4215
3951
|
}
|
|
4216
3952
|
const fromSessionResumption = getValueByPath(fromObject, [
|
|
4217
3953
|
'sessionResumption',
|
|
@@ -4456,14 +4192,13 @@ function contentFromMldev$1(apiClient, fromObject) {
|
|
|
4456
4192
|
const toObject = {};
|
|
4457
4193
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
4458
4194
|
if (fromParts != null) {
|
|
4459
|
-
|
|
4460
|
-
|
|
4195
|
+
let transformedList = fromParts;
|
|
4196
|
+
if (Array.isArray(transformedList)) {
|
|
4197
|
+
transformedList = transformedList.map((item) => {
|
|
4461
4198
|
return partFromMldev$1(apiClient, item);
|
|
4462
|
-
})
|
|
4463
|
-
}
|
|
4464
|
-
else {
|
|
4465
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
4199
|
+
});
|
|
4466
4200
|
}
|
|
4201
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
4467
4202
|
}
|
|
4468
4203
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
4469
4204
|
if (fromRole != null) {
|
|
@@ -4475,14 +4210,13 @@ function contentFromVertex$1(apiClient, fromObject) {
|
|
|
4475
4210
|
const toObject = {};
|
|
4476
4211
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
4477
4212
|
if (fromParts != null) {
|
|
4478
|
-
|
|
4479
|
-
|
|
4213
|
+
let transformedList = fromParts;
|
|
4214
|
+
if (Array.isArray(transformedList)) {
|
|
4215
|
+
transformedList = transformedList.map((item) => {
|
|
4480
4216
|
return partFromVertex$1(apiClient, item);
|
|
4481
|
-
})
|
|
4482
|
-
}
|
|
4483
|
-
else {
|
|
4484
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
4217
|
+
});
|
|
4485
4218
|
}
|
|
4219
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
4486
4220
|
}
|
|
4487
4221
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
4488
4222
|
if (fromRole != null) {
|
|
@@ -4528,6 +4262,12 @@ function liveServerContentFromMldev(apiClient, fromObject) {
|
|
|
4528
4262
|
if (fromInterrupted != null) {
|
|
4529
4263
|
setValueByPath(toObject, ['interrupted'], fromInterrupted);
|
|
4530
4264
|
}
|
|
4265
|
+
const fromGroundingMetadata = getValueByPath(fromObject, [
|
|
4266
|
+
'groundingMetadata',
|
|
4267
|
+
]);
|
|
4268
|
+
if (fromGroundingMetadata != null) {
|
|
4269
|
+
setValueByPath(toObject, ['groundingMetadata'], fromGroundingMetadata);
|
|
4270
|
+
}
|
|
4531
4271
|
const fromGenerationComplete = getValueByPath(fromObject, [
|
|
4532
4272
|
'generationComplete',
|
|
4533
4273
|
]);
|
|
@@ -4562,6 +4302,12 @@ function liveServerContentFromVertex(apiClient, fromObject) {
|
|
|
4562
4302
|
if (fromInterrupted != null) {
|
|
4563
4303
|
setValueByPath(toObject, ['interrupted'], fromInterrupted);
|
|
4564
4304
|
}
|
|
4305
|
+
const fromGroundingMetadata = getValueByPath(fromObject, [
|
|
4306
|
+
'groundingMetadata',
|
|
4307
|
+
]);
|
|
4308
|
+
if (fromGroundingMetadata != null) {
|
|
4309
|
+
setValueByPath(toObject, ['groundingMetadata'], fromGroundingMetadata);
|
|
4310
|
+
}
|
|
4565
4311
|
const fromGenerationComplete = getValueByPath(fromObject, [
|
|
4566
4312
|
'generationComplete',
|
|
4567
4313
|
]);
|
|
@@ -4616,14 +4362,13 @@ function liveServerToolCallFromMldev(apiClient, fromObject) {
|
|
|
4616
4362
|
'functionCalls',
|
|
4617
4363
|
]);
|
|
4618
4364
|
if (fromFunctionCalls != null) {
|
|
4619
|
-
|
|
4620
|
-
|
|
4365
|
+
let transformedList = fromFunctionCalls;
|
|
4366
|
+
if (Array.isArray(transformedList)) {
|
|
4367
|
+
transformedList = transformedList.map((item) => {
|
|
4621
4368
|
return functionCallFromMldev(apiClient, item);
|
|
4622
|
-
})
|
|
4623
|
-
}
|
|
4624
|
-
else {
|
|
4625
|
-
setValueByPath(toObject, ['functionCalls'], fromFunctionCalls);
|
|
4369
|
+
});
|
|
4626
4370
|
}
|
|
4371
|
+
setValueByPath(toObject, ['functionCalls'], transformedList);
|
|
4627
4372
|
}
|
|
4628
4373
|
return toObject;
|
|
4629
4374
|
}
|
|
@@ -4633,14 +4378,13 @@ function liveServerToolCallFromVertex(apiClient, fromObject) {
|
|
|
4633
4378
|
'functionCalls',
|
|
4634
4379
|
]);
|
|
4635
4380
|
if (fromFunctionCalls != null) {
|
|
4636
|
-
|
|
4637
|
-
|
|
4381
|
+
let transformedList = fromFunctionCalls;
|
|
4382
|
+
if (Array.isArray(transformedList)) {
|
|
4383
|
+
transformedList = transformedList.map((item) => {
|
|
4638
4384
|
return functionCallFromVertex(apiClient, item);
|
|
4639
|
-
})
|
|
4640
|
-
}
|
|
4641
|
-
else {
|
|
4642
|
-
setValueByPath(toObject, ['functionCalls'], fromFunctionCalls);
|
|
4385
|
+
});
|
|
4643
4386
|
}
|
|
4387
|
+
setValueByPath(toObject, ['functionCalls'], transformedList);
|
|
4644
4388
|
}
|
|
4645
4389
|
return toObject;
|
|
4646
4390
|
}
|
|
@@ -4726,53 +4470,49 @@ function usageMetadataFromMldev(apiClient, fromObject) {
|
|
|
4726
4470
|
'promptTokensDetails',
|
|
4727
4471
|
]);
|
|
4728
4472
|
if (fromPromptTokensDetails != null) {
|
|
4729
|
-
|
|
4730
|
-
|
|
4473
|
+
let transformedList = fromPromptTokensDetails;
|
|
4474
|
+
if (Array.isArray(transformedList)) {
|
|
4475
|
+
transformedList = transformedList.map((item) => {
|
|
4731
4476
|
return modalityTokenCountFromMldev(apiClient, item);
|
|
4732
|
-
})
|
|
4733
|
-
}
|
|
4734
|
-
else {
|
|
4735
|
-
setValueByPath(toObject, ['promptTokensDetails'], fromPromptTokensDetails);
|
|
4477
|
+
});
|
|
4736
4478
|
}
|
|
4479
|
+
setValueByPath(toObject, ['promptTokensDetails'], transformedList);
|
|
4737
4480
|
}
|
|
4738
4481
|
const fromCacheTokensDetails = getValueByPath(fromObject, [
|
|
4739
4482
|
'cacheTokensDetails',
|
|
4740
4483
|
]);
|
|
4741
4484
|
if (fromCacheTokensDetails != null) {
|
|
4742
|
-
|
|
4743
|
-
|
|
4485
|
+
let transformedList = fromCacheTokensDetails;
|
|
4486
|
+
if (Array.isArray(transformedList)) {
|
|
4487
|
+
transformedList = transformedList.map((item) => {
|
|
4744
4488
|
return modalityTokenCountFromMldev(apiClient, item);
|
|
4745
|
-
})
|
|
4746
|
-
}
|
|
4747
|
-
else {
|
|
4748
|
-
setValueByPath(toObject, ['cacheTokensDetails'], fromCacheTokensDetails);
|
|
4489
|
+
});
|
|
4749
4490
|
}
|
|
4491
|
+
setValueByPath(toObject, ['cacheTokensDetails'], transformedList);
|
|
4750
4492
|
}
|
|
4751
4493
|
const fromResponseTokensDetails = getValueByPath(fromObject, [
|
|
4752
4494
|
'responseTokensDetails',
|
|
4753
4495
|
]);
|
|
4754
4496
|
if (fromResponseTokensDetails != null) {
|
|
4755
|
-
|
|
4756
|
-
|
|
4497
|
+
let transformedList = fromResponseTokensDetails;
|
|
4498
|
+
if (Array.isArray(transformedList)) {
|
|
4499
|
+
transformedList = transformedList.map((item) => {
|
|
4757
4500
|
return modalityTokenCountFromMldev(apiClient, item);
|
|
4758
|
-
})
|
|
4759
|
-
}
|
|
4760
|
-
else {
|
|
4761
|
-
setValueByPath(toObject, ['responseTokensDetails'], fromResponseTokensDetails);
|
|
4501
|
+
});
|
|
4762
4502
|
}
|
|
4503
|
+
setValueByPath(toObject, ['responseTokensDetails'], transformedList);
|
|
4763
4504
|
}
|
|
4764
4505
|
const fromToolUsePromptTokensDetails = getValueByPath(fromObject, [
|
|
4765
4506
|
'toolUsePromptTokensDetails',
|
|
4766
4507
|
]);
|
|
4767
4508
|
if (fromToolUsePromptTokensDetails != null) {
|
|
4768
|
-
|
|
4769
|
-
|
|
4509
|
+
let transformedList = fromToolUsePromptTokensDetails;
|
|
4510
|
+
if (Array.isArray(transformedList)) {
|
|
4511
|
+
transformedList = transformedList.map((item) => {
|
|
4770
4512
|
return modalityTokenCountFromMldev(apiClient, item);
|
|
4771
|
-
})
|
|
4772
|
-
}
|
|
4773
|
-
else {
|
|
4774
|
-
setValueByPath(toObject, ['toolUsePromptTokensDetails'], fromToolUsePromptTokensDetails);
|
|
4513
|
+
});
|
|
4775
4514
|
}
|
|
4515
|
+
setValueByPath(toObject, ['toolUsePromptTokensDetails'], transformedList);
|
|
4776
4516
|
}
|
|
4777
4517
|
return toObject;
|
|
4778
4518
|
}
|
|
@@ -4818,53 +4558,49 @@ function usageMetadataFromVertex(apiClient, fromObject) {
|
|
|
4818
4558
|
'promptTokensDetails',
|
|
4819
4559
|
]);
|
|
4820
4560
|
if (fromPromptTokensDetails != null) {
|
|
4821
|
-
|
|
4822
|
-
|
|
4561
|
+
let transformedList = fromPromptTokensDetails;
|
|
4562
|
+
if (Array.isArray(transformedList)) {
|
|
4563
|
+
transformedList = transformedList.map((item) => {
|
|
4823
4564
|
return modalityTokenCountFromVertex(apiClient, item);
|
|
4824
|
-
})
|
|
4825
|
-
}
|
|
4826
|
-
else {
|
|
4827
|
-
setValueByPath(toObject, ['promptTokensDetails'], fromPromptTokensDetails);
|
|
4565
|
+
});
|
|
4828
4566
|
}
|
|
4567
|
+
setValueByPath(toObject, ['promptTokensDetails'], transformedList);
|
|
4829
4568
|
}
|
|
4830
4569
|
const fromCacheTokensDetails = getValueByPath(fromObject, [
|
|
4831
4570
|
'cacheTokensDetails',
|
|
4832
4571
|
]);
|
|
4833
4572
|
if (fromCacheTokensDetails != null) {
|
|
4834
|
-
|
|
4835
|
-
|
|
4573
|
+
let transformedList = fromCacheTokensDetails;
|
|
4574
|
+
if (Array.isArray(transformedList)) {
|
|
4575
|
+
transformedList = transformedList.map((item) => {
|
|
4836
4576
|
return modalityTokenCountFromVertex(apiClient, item);
|
|
4837
|
-
})
|
|
4838
|
-
}
|
|
4839
|
-
else {
|
|
4840
|
-
setValueByPath(toObject, ['cacheTokensDetails'], fromCacheTokensDetails);
|
|
4577
|
+
});
|
|
4841
4578
|
}
|
|
4579
|
+
setValueByPath(toObject, ['cacheTokensDetails'], transformedList);
|
|
4842
4580
|
}
|
|
4843
4581
|
const fromResponseTokensDetails = getValueByPath(fromObject, [
|
|
4844
4582
|
'candidatesTokensDetails',
|
|
4845
4583
|
]);
|
|
4846
4584
|
if (fromResponseTokensDetails != null) {
|
|
4847
|
-
|
|
4848
|
-
|
|
4585
|
+
let transformedList = fromResponseTokensDetails;
|
|
4586
|
+
if (Array.isArray(transformedList)) {
|
|
4587
|
+
transformedList = transformedList.map((item) => {
|
|
4849
4588
|
return modalityTokenCountFromVertex(apiClient, item);
|
|
4850
|
-
})
|
|
4851
|
-
}
|
|
4852
|
-
else {
|
|
4853
|
-
setValueByPath(toObject, ['responseTokensDetails'], fromResponseTokensDetails);
|
|
4589
|
+
});
|
|
4854
4590
|
}
|
|
4591
|
+
setValueByPath(toObject, ['responseTokensDetails'], transformedList);
|
|
4855
4592
|
}
|
|
4856
4593
|
const fromToolUsePromptTokensDetails = getValueByPath(fromObject, [
|
|
4857
4594
|
'toolUsePromptTokensDetails',
|
|
4858
4595
|
]);
|
|
4859
4596
|
if (fromToolUsePromptTokensDetails != null) {
|
|
4860
|
-
|
|
4861
|
-
|
|
4597
|
+
let transformedList = fromToolUsePromptTokensDetails;
|
|
4598
|
+
if (Array.isArray(transformedList)) {
|
|
4599
|
+
transformedList = transformedList.map((item) => {
|
|
4862
4600
|
return modalityTokenCountFromVertex(apiClient, item);
|
|
4863
|
-
})
|
|
4864
|
-
}
|
|
4865
|
-
else {
|
|
4866
|
-
setValueByPath(toObject, ['toolUsePromptTokensDetails'], fromToolUsePromptTokensDetails);
|
|
4601
|
+
});
|
|
4867
4602
|
}
|
|
4603
|
+
setValueByPath(toObject, ['toolUsePromptTokensDetails'], transformedList);
|
|
4868
4604
|
}
|
|
4869
4605
|
const fromTrafficType = getValueByPath(fromObject, ['trafficType']);
|
|
4870
4606
|
if (fromTrafficType != null) {
|
|
@@ -5063,14 +4799,13 @@ function contentToMldev(apiClient, fromObject) {
|
|
|
5063
4799
|
const toObject = {};
|
|
5064
4800
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
5065
4801
|
if (fromParts != null) {
|
|
5066
|
-
|
|
5067
|
-
|
|
4802
|
+
let transformedList = fromParts;
|
|
4803
|
+
if (Array.isArray(transformedList)) {
|
|
4804
|
+
transformedList = transformedList.map((item) => {
|
|
5068
4805
|
return partToMldev(apiClient, item);
|
|
5069
|
-
})
|
|
5070
|
-
}
|
|
5071
|
-
else {
|
|
5072
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
4806
|
+
});
|
|
5073
4807
|
}
|
|
4808
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
5074
4809
|
}
|
|
5075
4810
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
5076
4811
|
if (fromRole != null) {
|
|
@@ -5078,93 +4813,6 @@ function contentToMldev(apiClient, fromObject) {
|
|
|
5078
4813
|
}
|
|
5079
4814
|
return toObject;
|
|
5080
4815
|
}
|
|
5081
|
-
function schemaToMldev(apiClient, fromObject) {
|
|
5082
|
-
const toObject = {};
|
|
5083
|
-
if (getValueByPath(fromObject, ['example']) !== undefined) {
|
|
5084
|
-
throw new Error('example parameter is not supported in Gemini API.');
|
|
5085
|
-
}
|
|
5086
|
-
if (getValueByPath(fromObject, ['pattern']) !== undefined) {
|
|
5087
|
-
throw new Error('pattern parameter is not supported in Gemini API.');
|
|
5088
|
-
}
|
|
5089
|
-
if (getValueByPath(fromObject, ['default']) !== undefined) {
|
|
5090
|
-
throw new Error('default parameter is not supported in Gemini API.');
|
|
5091
|
-
}
|
|
5092
|
-
if (getValueByPath(fromObject, ['maxLength']) !== undefined) {
|
|
5093
|
-
throw new Error('maxLength parameter is not supported in Gemini API.');
|
|
5094
|
-
}
|
|
5095
|
-
if (getValueByPath(fromObject, ['minLength']) !== undefined) {
|
|
5096
|
-
throw new Error('minLength parameter is not supported in Gemini API.');
|
|
5097
|
-
}
|
|
5098
|
-
if (getValueByPath(fromObject, ['minProperties']) !== undefined) {
|
|
5099
|
-
throw new Error('minProperties parameter is not supported in Gemini API.');
|
|
5100
|
-
}
|
|
5101
|
-
if (getValueByPath(fromObject, ['maxProperties']) !== undefined) {
|
|
5102
|
-
throw new Error('maxProperties parameter is not supported in Gemini API.');
|
|
5103
|
-
}
|
|
5104
|
-
const fromAnyOf = getValueByPath(fromObject, ['anyOf']);
|
|
5105
|
-
if (fromAnyOf != null) {
|
|
5106
|
-
setValueByPath(toObject, ['anyOf'], fromAnyOf);
|
|
5107
|
-
}
|
|
5108
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
5109
|
-
if (fromDescription != null) {
|
|
5110
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
5111
|
-
}
|
|
5112
|
-
const fromEnum = getValueByPath(fromObject, ['enum']);
|
|
5113
|
-
if (fromEnum != null) {
|
|
5114
|
-
setValueByPath(toObject, ['enum'], fromEnum);
|
|
5115
|
-
}
|
|
5116
|
-
const fromFormat = getValueByPath(fromObject, ['format']);
|
|
5117
|
-
if (fromFormat != null) {
|
|
5118
|
-
setValueByPath(toObject, ['format'], fromFormat);
|
|
5119
|
-
}
|
|
5120
|
-
const fromItems = getValueByPath(fromObject, ['items']);
|
|
5121
|
-
if (fromItems != null) {
|
|
5122
|
-
setValueByPath(toObject, ['items'], fromItems);
|
|
5123
|
-
}
|
|
5124
|
-
const fromMaxItems = getValueByPath(fromObject, ['maxItems']);
|
|
5125
|
-
if (fromMaxItems != null) {
|
|
5126
|
-
setValueByPath(toObject, ['maxItems'], fromMaxItems);
|
|
5127
|
-
}
|
|
5128
|
-
const fromMaximum = getValueByPath(fromObject, ['maximum']);
|
|
5129
|
-
if (fromMaximum != null) {
|
|
5130
|
-
setValueByPath(toObject, ['maximum'], fromMaximum);
|
|
5131
|
-
}
|
|
5132
|
-
const fromMinItems = getValueByPath(fromObject, ['minItems']);
|
|
5133
|
-
if (fromMinItems != null) {
|
|
5134
|
-
setValueByPath(toObject, ['minItems'], fromMinItems);
|
|
5135
|
-
}
|
|
5136
|
-
const fromMinimum = getValueByPath(fromObject, ['minimum']);
|
|
5137
|
-
if (fromMinimum != null) {
|
|
5138
|
-
setValueByPath(toObject, ['minimum'], fromMinimum);
|
|
5139
|
-
}
|
|
5140
|
-
const fromNullable = getValueByPath(fromObject, ['nullable']);
|
|
5141
|
-
if (fromNullable != null) {
|
|
5142
|
-
setValueByPath(toObject, ['nullable'], fromNullable);
|
|
5143
|
-
}
|
|
5144
|
-
const fromProperties = getValueByPath(fromObject, ['properties']);
|
|
5145
|
-
if (fromProperties != null) {
|
|
5146
|
-
setValueByPath(toObject, ['properties'], fromProperties);
|
|
5147
|
-
}
|
|
5148
|
-
const fromPropertyOrdering = getValueByPath(fromObject, [
|
|
5149
|
-
'propertyOrdering',
|
|
5150
|
-
]);
|
|
5151
|
-
if (fromPropertyOrdering != null) {
|
|
5152
|
-
setValueByPath(toObject, ['propertyOrdering'], fromPropertyOrdering);
|
|
5153
|
-
}
|
|
5154
|
-
const fromRequired = getValueByPath(fromObject, ['required']);
|
|
5155
|
-
if (fromRequired != null) {
|
|
5156
|
-
setValueByPath(toObject, ['required'], fromRequired);
|
|
5157
|
-
}
|
|
5158
|
-
const fromTitle = getValueByPath(fromObject, ['title']);
|
|
5159
|
-
if (fromTitle != null) {
|
|
5160
|
-
setValueByPath(toObject, ['title'], fromTitle);
|
|
5161
|
-
}
|
|
5162
|
-
const fromType = getValueByPath(fromObject, ['type']);
|
|
5163
|
-
if (fromType != null) {
|
|
5164
|
-
setValueByPath(toObject, ['type'], fromType);
|
|
5165
|
-
}
|
|
5166
|
-
return toObject;
|
|
5167
|
-
}
|
|
5168
4816
|
function safetySettingToMldev(apiClient, fromObject) {
|
|
5169
4817
|
const toObject = {};
|
|
5170
4818
|
if (getValueByPath(fromObject, ['method']) !== undefined) {
|
|
@@ -5180,25 +4828,6 @@ function safetySettingToMldev(apiClient, fromObject) {
|
|
|
5180
4828
|
}
|
|
5181
4829
|
return toObject;
|
|
5182
4830
|
}
|
|
5183
|
-
function functionDeclarationToMldev(apiClient, fromObject) {
|
|
5184
|
-
const toObject = {};
|
|
5185
|
-
if (getValueByPath(fromObject, ['response']) !== undefined) {
|
|
5186
|
-
throw new Error('response parameter is not supported in Gemini API.');
|
|
5187
|
-
}
|
|
5188
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
5189
|
-
if (fromDescription != null) {
|
|
5190
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
5191
|
-
}
|
|
5192
|
-
const fromName = getValueByPath(fromObject, ['name']);
|
|
5193
|
-
if (fromName != null) {
|
|
5194
|
-
setValueByPath(toObject, ['name'], fromName);
|
|
5195
|
-
}
|
|
5196
|
-
const fromParameters = getValueByPath(fromObject, ['parameters']);
|
|
5197
|
-
if (fromParameters != null) {
|
|
5198
|
-
setValueByPath(toObject, ['parameters'], fromParameters);
|
|
5199
|
-
}
|
|
5200
|
-
return toObject;
|
|
5201
|
-
}
|
|
5202
4831
|
function googleSearchToMldev() {
|
|
5203
4832
|
const toObject = {};
|
|
5204
4833
|
return toObject;
|
|
@@ -5229,19 +4858,6 @@ function googleSearchRetrievalToMldev(apiClient, fromObject) {
|
|
|
5229
4858
|
}
|
|
5230
4859
|
function toolToMldev(apiClient, fromObject) {
|
|
5231
4860
|
const toObject = {};
|
|
5232
|
-
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
5233
|
-
'functionDeclarations',
|
|
5234
|
-
]);
|
|
5235
|
-
if (fromFunctionDeclarations != null) {
|
|
5236
|
-
if (Array.isArray(fromFunctionDeclarations)) {
|
|
5237
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations.map((item) => {
|
|
5238
|
-
return functionDeclarationToMldev(apiClient, item);
|
|
5239
|
-
}));
|
|
5240
|
-
}
|
|
5241
|
-
else {
|
|
5242
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
5243
|
-
}
|
|
5244
|
-
}
|
|
5245
4861
|
if (getValueByPath(fromObject, ['retrieval']) !== undefined) {
|
|
5246
4862
|
throw new Error('retrieval parameter is not supported in Gemini API.');
|
|
5247
4863
|
}
|
|
@@ -5261,6 +4877,12 @@ function toolToMldev(apiClient, fromObject) {
|
|
|
5261
4877
|
if (fromCodeExecution != null) {
|
|
5262
4878
|
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
5263
4879
|
}
|
|
4880
|
+
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
4881
|
+
'functionDeclarations',
|
|
4882
|
+
]);
|
|
4883
|
+
if (fromFunctionDeclarations != null) {
|
|
4884
|
+
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
4885
|
+
}
|
|
5264
4886
|
return toObject;
|
|
5265
4887
|
}
|
|
5266
4888
|
function functionCallingConfigToMldev(apiClient, fromObject) {
|
|
@@ -5407,7 +5029,7 @@ function generateContentConfigToMldev(apiClient, fromObject, parentObject) {
|
|
|
5407
5029
|
'responseSchema',
|
|
5408
5030
|
]);
|
|
5409
5031
|
if (fromResponseSchema != null) {
|
|
5410
|
-
setValueByPath(toObject, ['responseSchema'],
|
|
5032
|
+
setValueByPath(toObject, ['responseSchema'], tSchema(apiClient, fromResponseSchema));
|
|
5411
5033
|
}
|
|
5412
5034
|
if (getValueByPath(fromObject, ['routingConfig']) !== undefined) {
|
|
5413
5035
|
throw new Error('routingConfig parameter is not supported in Gemini API.');
|
|
@@ -5419,25 +5041,23 @@ function generateContentConfigToMldev(apiClient, fromObject, parentObject) {
|
|
|
5419
5041
|
'safetySettings',
|
|
5420
5042
|
]);
|
|
5421
5043
|
if (parentObject !== undefined && fromSafetySettings != null) {
|
|
5422
|
-
|
|
5423
|
-
|
|
5044
|
+
let transformedList = fromSafetySettings;
|
|
5045
|
+
if (Array.isArray(transformedList)) {
|
|
5046
|
+
transformedList = transformedList.map((item) => {
|
|
5424
5047
|
return safetySettingToMldev(apiClient, item);
|
|
5425
|
-
})
|
|
5426
|
-
}
|
|
5427
|
-
else {
|
|
5428
|
-
setValueByPath(parentObject, ['safetySettings'], fromSafetySettings);
|
|
5048
|
+
});
|
|
5429
5049
|
}
|
|
5050
|
+
setValueByPath(parentObject, ['safetySettings'], transformedList);
|
|
5430
5051
|
}
|
|
5431
5052
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
5432
5053
|
if (parentObject !== undefined && fromTools != null) {
|
|
5433
|
-
|
|
5434
|
-
|
|
5054
|
+
let transformedList = tTools(apiClient, fromTools);
|
|
5055
|
+
if (Array.isArray(transformedList)) {
|
|
5056
|
+
transformedList = transformedList.map((item) => {
|
|
5435
5057
|
return toolToMldev(apiClient, tTool(apiClient, item));
|
|
5436
|
-
})
|
|
5437
|
-
}
|
|
5438
|
-
else {
|
|
5439
|
-
setValueByPath(parentObject, ['tools'], tTools(apiClient, fromTools));
|
|
5058
|
+
});
|
|
5440
5059
|
}
|
|
5060
|
+
setValueByPath(parentObject, ['tools'], transformedList);
|
|
5441
5061
|
}
|
|
5442
5062
|
const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
|
|
5443
5063
|
if (parentObject !== undefined && fromToolConfig != null) {
|
|
@@ -5487,14 +5107,13 @@ function generateContentParametersToMldev(apiClient, fromObject) {
|
|
|
5487
5107
|
}
|
|
5488
5108
|
const fromContents = getValueByPath(fromObject, ['contents']);
|
|
5489
5109
|
if (fromContents != null) {
|
|
5490
|
-
|
|
5491
|
-
|
|
5110
|
+
let transformedList = tContents(apiClient, fromContents);
|
|
5111
|
+
if (Array.isArray(transformedList)) {
|
|
5112
|
+
transformedList = transformedList.map((item) => {
|
|
5492
5113
|
return contentToMldev(apiClient, item);
|
|
5493
|
-
})
|
|
5494
|
-
}
|
|
5495
|
-
else {
|
|
5496
|
-
setValueByPath(toObject, ['contents'], tContents(apiClient, fromContents));
|
|
5114
|
+
});
|
|
5497
5115
|
}
|
|
5116
|
+
setValueByPath(toObject, ['contents'], transformedList);
|
|
5498
5117
|
}
|
|
5499
5118
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
5500
5119
|
if (fromConfig != null) {
|
|
@@ -5649,6 +5268,42 @@ function getModelParametersToMldev(apiClient, fromObject) {
|
|
|
5649
5268
|
}
|
|
5650
5269
|
return toObject;
|
|
5651
5270
|
}
|
|
5271
|
+
function updateModelConfigToMldev(apiClient, fromObject, parentObject) {
|
|
5272
|
+
const toObject = {};
|
|
5273
|
+
const fromDisplayName = getValueByPath(fromObject, ['displayName']);
|
|
5274
|
+
if (parentObject !== undefined && fromDisplayName != null) {
|
|
5275
|
+
setValueByPath(parentObject, ['displayName'], fromDisplayName);
|
|
5276
|
+
}
|
|
5277
|
+
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
5278
|
+
if (parentObject !== undefined && fromDescription != null) {
|
|
5279
|
+
setValueByPath(parentObject, ['description'], fromDescription);
|
|
5280
|
+
}
|
|
5281
|
+
return toObject;
|
|
5282
|
+
}
|
|
5283
|
+
function updateModelParametersToMldev(apiClient, fromObject) {
|
|
5284
|
+
const toObject = {};
|
|
5285
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
5286
|
+
if (fromModel != null) {
|
|
5287
|
+
setValueByPath(toObject, ['_url', 'name'], tModel(apiClient, fromModel));
|
|
5288
|
+
}
|
|
5289
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
5290
|
+
if (fromConfig != null) {
|
|
5291
|
+
setValueByPath(toObject, ['config'], updateModelConfigToMldev(apiClient, fromConfig, toObject));
|
|
5292
|
+
}
|
|
5293
|
+
return toObject;
|
|
5294
|
+
}
|
|
5295
|
+
function deleteModelParametersToMldev(apiClient, fromObject) {
|
|
5296
|
+
const toObject = {};
|
|
5297
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
5298
|
+
if (fromModel != null) {
|
|
5299
|
+
setValueByPath(toObject, ['_url', 'name'], tModel(apiClient, fromModel));
|
|
5300
|
+
}
|
|
5301
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
5302
|
+
if (fromConfig != null) {
|
|
5303
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
5304
|
+
}
|
|
5305
|
+
return toObject;
|
|
5306
|
+
}
|
|
5652
5307
|
function countTokensConfigToMldev(apiClient, fromObject) {
|
|
5653
5308
|
const toObject = {};
|
|
5654
5309
|
if (getValueByPath(fromObject, ['systemInstruction']) !== undefined) {
|
|
@@ -5670,14 +5325,13 @@ function countTokensParametersToMldev(apiClient, fromObject) {
|
|
|
5670
5325
|
}
|
|
5671
5326
|
const fromContents = getValueByPath(fromObject, ['contents']);
|
|
5672
5327
|
if (fromContents != null) {
|
|
5673
|
-
|
|
5674
|
-
|
|
5328
|
+
let transformedList = tContents(apiClient, fromContents);
|
|
5329
|
+
if (Array.isArray(transformedList)) {
|
|
5330
|
+
transformedList = transformedList.map((item) => {
|
|
5675
5331
|
return contentToMldev(apiClient, item);
|
|
5676
|
-
})
|
|
5677
|
-
}
|
|
5678
|
-
else {
|
|
5679
|
-
setValueByPath(toObject, ['contents'], tContents(apiClient, fromContents));
|
|
5332
|
+
});
|
|
5680
5333
|
}
|
|
5334
|
+
setValueByPath(toObject, ['contents'], transformedList);
|
|
5681
5335
|
}
|
|
5682
5336
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
5683
5337
|
if (fromConfig != null) {
|
|
@@ -5822,14 +5476,13 @@ function contentToVertex(apiClient, fromObject) {
|
|
|
5822
5476
|
const toObject = {};
|
|
5823
5477
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
5824
5478
|
if (fromParts != null) {
|
|
5825
|
-
|
|
5826
|
-
|
|
5479
|
+
let transformedList = fromParts;
|
|
5480
|
+
if (Array.isArray(transformedList)) {
|
|
5481
|
+
transformedList = transformedList.map((item) => {
|
|
5827
5482
|
return partToVertex(apiClient, item);
|
|
5828
|
-
})
|
|
5829
|
-
}
|
|
5830
|
-
else {
|
|
5831
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
5483
|
+
});
|
|
5832
5484
|
}
|
|
5485
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
5833
5486
|
}
|
|
5834
5487
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
5835
5488
|
if (fromRole != null) {
|
|
@@ -5837,104 +5490,6 @@ function contentToVertex(apiClient, fromObject) {
|
|
|
5837
5490
|
}
|
|
5838
5491
|
return toObject;
|
|
5839
5492
|
}
|
|
5840
|
-
function schemaToVertex(apiClient, fromObject) {
|
|
5841
|
-
const toObject = {};
|
|
5842
|
-
const fromExample = getValueByPath(fromObject, ['example']);
|
|
5843
|
-
if (fromExample != null) {
|
|
5844
|
-
setValueByPath(toObject, ['example'], fromExample);
|
|
5845
|
-
}
|
|
5846
|
-
const fromPattern = getValueByPath(fromObject, ['pattern']);
|
|
5847
|
-
if (fromPattern != null) {
|
|
5848
|
-
setValueByPath(toObject, ['pattern'], fromPattern);
|
|
5849
|
-
}
|
|
5850
|
-
const fromDefault = getValueByPath(fromObject, ['default']);
|
|
5851
|
-
if (fromDefault != null) {
|
|
5852
|
-
setValueByPath(toObject, ['default'], fromDefault);
|
|
5853
|
-
}
|
|
5854
|
-
const fromMaxLength = getValueByPath(fromObject, ['maxLength']);
|
|
5855
|
-
if (fromMaxLength != null) {
|
|
5856
|
-
setValueByPath(toObject, ['maxLength'], fromMaxLength);
|
|
5857
|
-
}
|
|
5858
|
-
const fromMinLength = getValueByPath(fromObject, ['minLength']);
|
|
5859
|
-
if (fromMinLength != null) {
|
|
5860
|
-
setValueByPath(toObject, ['minLength'], fromMinLength);
|
|
5861
|
-
}
|
|
5862
|
-
const fromMinProperties = getValueByPath(fromObject, [
|
|
5863
|
-
'minProperties',
|
|
5864
|
-
]);
|
|
5865
|
-
if (fromMinProperties != null) {
|
|
5866
|
-
setValueByPath(toObject, ['minProperties'], fromMinProperties);
|
|
5867
|
-
}
|
|
5868
|
-
const fromMaxProperties = getValueByPath(fromObject, [
|
|
5869
|
-
'maxProperties',
|
|
5870
|
-
]);
|
|
5871
|
-
if (fromMaxProperties != null) {
|
|
5872
|
-
setValueByPath(toObject, ['maxProperties'], fromMaxProperties);
|
|
5873
|
-
}
|
|
5874
|
-
const fromAnyOf = getValueByPath(fromObject, ['anyOf']);
|
|
5875
|
-
if (fromAnyOf != null) {
|
|
5876
|
-
setValueByPath(toObject, ['anyOf'], fromAnyOf);
|
|
5877
|
-
}
|
|
5878
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
5879
|
-
if (fromDescription != null) {
|
|
5880
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
5881
|
-
}
|
|
5882
|
-
const fromEnum = getValueByPath(fromObject, ['enum']);
|
|
5883
|
-
if (fromEnum != null) {
|
|
5884
|
-
setValueByPath(toObject, ['enum'], fromEnum);
|
|
5885
|
-
}
|
|
5886
|
-
const fromFormat = getValueByPath(fromObject, ['format']);
|
|
5887
|
-
if (fromFormat != null) {
|
|
5888
|
-
setValueByPath(toObject, ['format'], fromFormat);
|
|
5889
|
-
}
|
|
5890
|
-
const fromItems = getValueByPath(fromObject, ['items']);
|
|
5891
|
-
if (fromItems != null) {
|
|
5892
|
-
setValueByPath(toObject, ['items'], fromItems);
|
|
5893
|
-
}
|
|
5894
|
-
const fromMaxItems = getValueByPath(fromObject, ['maxItems']);
|
|
5895
|
-
if (fromMaxItems != null) {
|
|
5896
|
-
setValueByPath(toObject, ['maxItems'], fromMaxItems);
|
|
5897
|
-
}
|
|
5898
|
-
const fromMaximum = getValueByPath(fromObject, ['maximum']);
|
|
5899
|
-
if (fromMaximum != null) {
|
|
5900
|
-
setValueByPath(toObject, ['maximum'], fromMaximum);
|
|
5901
|
-
}
|
|
5902
|
-
const fromMinItems = getValueByPath(fromObject, ['minItems']);
|
|
5903
|
-
if (fromMinItems != null) {
|
|
5904
|
-
setValueByPath(toObject, ['minItems'], fromMinItems);
|
|
5905
|
-
}
|
|
5906
|
-
const fromMinimum = getValueByPath(fromObject, ['minimum']);
|
|
5907
|
-
if (fromMinimum != null) {
|
|
5908
|
-
setValueByPath(toObject, ['minimum'], fromMinimum);
|
|
5909
|
-
}
|
|
5910
|
-
const fromNullable = getValueByPath(fromObject, ['nullable']);
|
|
5911
|
-
if (fromNullable != null) {
|
|
5912
|
-
setValueByPath(toObject, ['nullable'], fromNullable);
|
|
5913
|
-
}
|
|
5914
|
-
const fromProperties = getValueByPath(fromObject, ['properties']);
|
|
5915
|
-
if (fromProperties != null) {
|
|
5916
|
-
setValueByPath(toObject, ['properties'], fromProperties);
|
|
5917
|
-
}
|
|
5918
|
-
const fromPropertyOrdering = getValueByPath(fromObject, [
|
|
5919
|
-
'propertyOrdering',
|
|
5920
|
-
]);
|
|
5921
|
-
if (fromPropertyOrdering != null) {
|
|
5922
|
-
setValueByPath(toObject, ['propertyOrdering'], fromPropertyOrdering);
|
|
5923
|
-
}
|
|
5924
|
-
const fromRequired = getValueByPath(fromObject, ['required']);
|
|
5925
|
-
if (fromRequired != null) {
|
|
5926
|
-
setValueByPath(toObject, ['required'], fromRequired);
|
|
5927
|
-
}
|
|
5928
|
-
const fromTitle = getValueByPath(fromObject, ['title']);
|
|
5929
|
-
if (fromTitle != null) {
|
|
5930
|
-
setValueByPath(toObject, ['title'], fromTitle);
|
|
5931
|
-
}
|
|
5932
|
-
const fromType = getValueByPath(fromObject, ['type']);
|
|
5933
|
-
if (fromType != null) {
|
|
5934
|
-
setValueByPath(toObject, ['type'], fromType);
|
|
5935
|
-
}
|
|
5936
|
-
return toObject;
|
|
5937
|
-
}
|
|
5938
5493
|
function modelSelectionConfigToVertex(apiClient, fromObject) {
|
|
5939
5494
|
const toObject = {};
|
|
5940
5495
|
const fromFeatureSelectionPreference = getValueByPath(fromObject, [
|
|
@@ -5961,26 +5516,6 @@ function safetySettingToVertex(apiClient, fromObject) {
|
|
|
5961
5516
|
}
|
|
5962
5517
|
return toObject;
|
|
5963
5518
|
}
|
|
5964
|
-
function functionDeclarationToVertex(apiClient, fromObject) {
|
|
5965
|
-
const toObject = {};
|
|
5966
|
-
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
5967
|
-
if (fromResponse != null) {
|
|
5968
|
-
setValueByPath(toObject, ['response'], schemaToVertex(apiClient, fromResponse));
|
|
5969
|
-
}
|
|
5970
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
5971
|
-
if (fromDescription != null) {
|
|
5972
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
5973
|
-
}
|
|
5974
|
-
const fromName = getValueByPath(fromObject, ['name']);
|
|
5975
|
-
if (fromName != null) {
|
|
5976
|
-
setValueByPath(toObject, ['name'], fromName);
|
|
5977
|
-
}
|
|
5978
|
-
const fromParameters = getValueByPath(fromObject, ['parameters']);
|
|
5979
|
-
if (fromParameters != null) {
|
|
5980
|
-
setValueByPath(toObject, ['parameters'], fromParameters);
|
|
5981
|
-
}
|
|
5982
|
-
return toObject;
|
|
5983
|
-
}
|
|
5984
5519
|
function googleSearchToVertex() {
|
|
5985
5520
|
const toObject = {};
|
|
5986
5521
|
return toObject;
|
|
@@ -6011,19 +5546,6 @@ function googleSearchRetrievalToVertex(apiClient, fromObject) {
|
|
|
6011
5546
|
}
|
|
6012
5547
|
function toolToVertex(apiClient, fromObject) {
|
|
6013
5548
|
const toObject = {};
|
|
6014
|
-
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
6015
|
-
'functionDeclarations',
|
|
6016
|
-
]);
|
|
6017
|
-
if (fromFunctionDeclarations != null) {
|
|
6018
|
-
if (Array.isArray(fromFunctionDeclarations)) {
|
|
6019
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations.map((item) => {
|
|
6020
|
-
return functionDeclarationToVertex(apiClient, item);
|
|
6021
|
-
}));
|
|
6022
|
-
}
|
|
6023
|
-
else {
|
|
6024
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
6025
|
-
}
|
|
6026
|
-
}
|
|
6027
5549
|
const fromRetrieval = getValueByPath(fromObject, ['retrieval']);
|
|
6028
5550
|
if (fromRetrieval != null) {
|
|
6029
5551
|
setValueByPath(toObject, ['retrieval'], fromRetrieval);
|
|
@@ -6044,6 +5566,12 @@ function toolToVertex(apiClient, fromObject) {
|
|
|
6044
5566
|
if (fromCodeExecution != null) {
|
|
6045
5567
|
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
6046
5568
|
}
|
|
5569
|
+
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
5570
|
+
'functionDeclarations',
|
|
5571
|
+
]);
|
|
5572
|
+
if (fromFunctionDeclarations != null) {
|
|
5573
|
+
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
5574
|
+
}
|
|
6047
5575
|
return toObject;
|
|
6048
5576
|
}
|
|
6049
5577
|
function functionCallingConfigToVertex(apiClient, fromObject) {
|
|
@@ -6190,7 +5718,7 @@ function generateContentConfigToVertex(apiClient, fromObject, parentObject) {
|
|
|
6190
5718
|
'responseSchema',
|
|
6191
5719
|
]);
|
|
6192
5720
|
if (fromResponseSchema != null) {
|
|
6193
|
-
setValueByPath(toObject, ['responseSchema'],
|
|
5721
|
+
setValueByPath(toObject, ['responseSchema'], tSchema(apiClient, fromResponseSchema));
|
|
6194
5722
|
}
|
|
6195
5723
|
const fromRoutingConfig = getValueByPath(fromObject, [
|
|
6196
5724
|
'routingConfig',
|
|
@@ -6208,25 +5736,23 @@ function generateContentConfigToVertex(apiClient, fromObject, parentObject) {
|
|
|
6208
5736
|
'safetySettings',
|
|
6209
5737
|
]);
|
|
6210
5738
|
if (parentObject !== undefined && fromSafetySettings != null) {
|
|
6211
|
-
|
|
6212
|
-
|
|
5739
|
+
let transformedList = fromSafetySettings;
|
|
5740
|
+
if (Array.isArray(transformedList)) {
|
|
5741
|
+
transformedList = transformedList.map((item) => {
|
|
6213
5742
|
return safetySettingToVertex(apiClient, item);
|
|
6214
|
-
})
|
|
6215
|
-
}
|
|
6216
|
-
else {
|
|
6217
|
-
setValueByPath(parentObject, ['safetySettings'], fromSafetySettings);
|
|
5743
|
+
});
|
|
6218
5744
|
}
|
|
5745
|
+
setValueByPath(parentObject, ['safetySettings'], transformedList);
|
|
6219
5746
|
}
|
|
6220
5747
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
6221
5748
|
if (parentObject !== undefined && fromTools != null) {
|
|
6222
|
-
|
|
6223
|
-
|
|
5749
|
+
let transformedList = tTools(apiClient, fromTools);
|
|
5750
|
+
if (Array.isArray(transformedList)) {
|
|
5751
|
+
transformedList = transformedList.map((item) => {
|
|
6224
5752
|
return toolToVertex(apiClient, tTool(apiClient, item));
|
|
6225
|
-
})
|
|
6226
|
-
}
|
|
6227
|
-
else {
|
|
6228
|
-
setValueByPath(parentObject, ['tools'], tTools(apiClient, fromTools));
|
|
5753
|
+
});
|
|
6229
5754
|
}
|
|
5755
|
+
setValueByPath(parentObject, ['tools'], transformedList);
|
|
6230
5756
|
}
|
|
6231
5757
|
const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
|
|
6232
5758
|
if (parentObject !== undefined && fromToolConfig != null) {
|
|
@@ -6280,14 +5806,13 @@ function generateContentParametersToVertex(apiClient, fromObject) {
|
|
|
6280
5806
|
}
|
|
6281
5807
|
const fromContents = getValueByPath(fromObject, ['contents']);
|
|
6282
5808
|
if (fromContents != null) {
|
|
6283
|
-
|
|
6284
|
-
|
|
5809
|
+
let transformedList = tContents(apiClient, fromContents);
|
|
5810
|
+
if (Array.isArray(transformedList)) {
|
|
5811
|
+
transformedList = transformedList.map((item) => {
|
|
6285
5812
|
return contentToVertex(apiClient, item);
|
|
6286
|
-
})
|
|
6287
|
-
}
|
|
6288
|
-
else {
|
|
6289
|
-
setValueByPath(toObject, ['contents'], tContents(apiClient, fromContents));
|
|
5813
|
+
});
|
|
6290
5814
|
}
|
|
5815
|
+
setValueByPath(toObject, ['contents'], transformedList);
|
|
6291
5816
|
}
|
|
6292
5817
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
6293
5818
|
if (fromConfig != null) {
|
|
@@ -6449,6 +5974,42 @@ function getModelParametersToVertex(apiClient, fromObject) {
|
|
|
6449
5974
|
}
|
|
6450
5975
|
return toObject;
|
|
6451
5976
|
}
|
|
5977
|
+
function updateModelConfigToVertex(apiClient, fromObject, parentObject) {
|
|
5978
|
+
const toObject = {};
|
|
5979
|
+
const fromDisplayName = getValueByPath(fromObject, ['displayName']);
|
|
5980
|
+
if (parentObject !== undefined && fromDisplayName != null) {
|
|
5981
|
+
setValueByPath(parentObject, ['displayName'], fromDisplayName);
|
|
5982
|
+
}
|
|
5983
|
+
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
5984
|
+
if (parentObject !== undefined && fromDescription != null) {
|
|
5985
|
+
setValueByPath(parentObject, ['description'], fromDescription);
|
|
5986
|
+
}
|
|
5987
|
+
return toObject;
|
|
5988
|
+
}
|
|
5989
|
+
function updateModelParametersToVertex(apiClient, fromObject) {
|
|
5990
|
+
const toObject = {};
|
|
5991
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
5992
|
+
if (fromModel != null) {
|
|
5993
|
+
setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
|
|
5994
|
+
}
|
|
5995
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
5996
|
+
if (fromConfig != null) {
|
|
5997
|
+
setValueByPath(toObject, ['config'], updateModelConfigToVertex(apiClient, fromConfig, toObject));
|
|
5998
|
+
}
|
|
5999
|
+
return toObject;
|
|
6000
|
+
}
|
|
6001
|
+
function deleteModelParametersToVertex(apiClient, fromObject) {
|
|
6002
|
+
const toObject = {};
|
|
6003
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
6004
|
+
if (fromModel != null) {
|
|
6005
|
+
setValueByPath(toObject, ['_url', 'name'], tModel(apiClient, fromModel));
|
|
6006
|
+
}
|
|
6007
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
6008
|
+
if (fromConfig != null) {
|
|
6009
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
6010
|
+
}
|
|
6011
|
+
return toObject;
|
|
6012
|
+
}
|
|
6452
6013
|
function countTokensConfigToVertex(apiClient, fromObject, parentObject) {
|
|
6453
6014
|
const toObject = {};
|
|
6454
6015
|
const fromSystemInstruction = getValueByPath(fromObject, [
|
|
@@ -6459,14 +6020,13 @@ function countTokensConfigToVertex(apiClient, fromObject, parentObject) {
|
|
|
6459
6020
|
}
|
|
6460
6021
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
6461
6022
|
if (parentObject !== undefined && fromTools != null) {
|
|
6462
|
-
|
|
6463
|
-
|
|
6023
|
+
let transformedList = fromTools;
|
|
6024
|
+
if (Array.isArray(transformedList)) {
|
|
6025
|
+
transformedList = transformedList.map((item) => {
|
|
6464
6026
|
return toolToVertex(apiClient, item);
|
|
6465
|
-
})
|
|
6466
|
-
}
|
|
6467
|
-
else {
|
|
6468
|
-
setValueByPath(parentObject, ['tools'], fromTools);
|
|
6027
|
+
});
|
|
6469
6028
|
}
|
|
6029
|
+
setValueByPath(parentObject, ['tools'], transformedList);
|
|
6470
6030
|
}
|
|
6471
6031
|
const fromGenerationConfig = getValueByPath(fromObject, [
|
|
6472
6032
|
'generationConfig',
|
|
@@ -6484,14 +6044,13 @@ function countTokensParametersToVertex(apiClient, fromObject) {
|
|
|
6484
6044
|
}
|
|
6485
6045
|
const fromContents = getValueByPath(fromObject, ['contents']);
|
|
6486
6046
|
if (fromContents != null) {
|
|
6487
|
-
|
|
6488
|
-
|
|
6047
|
+
let transformedList = tContents(apiClient, fromContents);
|
|
6048
|
+
if (Array.isArray(transformedList)) {
|
|
6049
|
+
transformedList = transformedList.map((item) => {
|
|
6489
6050
|
return contentToVertex(apiClient, item);
|
|
6490
|
-
})
|
|
6491
|
-
}
|
|
6492
|
-
else {
|
|
6493
|
-
setValueByPath(toObject, ['contents'], tContents(apiClient, fromContents));
|
|
6051
|
+
});
|
|
6494
6052
|
}
|
|
6053
|
+
setValueByPath(toObject, ['contents'], transformedList);
|
|
6495
6054
|
}
|
|
6496
6055
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
6497
6056
|
if (fromConfig != null) {
|
|
@@ -6507,14 +6066,13 @@ function computeTokensParametersToVertex(apiClient, fromObject) {
|
|
|
6507
6066
|
}
|
|
6508
6067
|
const fromContents = getValueByPath(fromObject, ['contents']);
|
|
6509
6068
|
if (fromContents != null) {
|
|
6510
|
-
|
|
6511
|
-
|
|
6069
|
+
let transformedList = tContents(apiClient, fromContents);
|
|
6070
|
+
if (Array.isArray(transformedList)) {
|
|
6071
|
+
transformedList = transformedList.map((item) => {
|
|
6512
6072
|
return contentToVertex(apiClient, item);
|
|
6513
|
-
})
|
|
6514
|
-
}
|
|
6515
|
-
else {
|
|
6516
|
-
setValueByPath(toObject, ['contents'], tContents(apiClient, fromContents));
|
|
6073
|
+
});
|
|
6517
6074
|
}
|
|
6075
|
+
setValueByPath(toObject, ['contents'], transformedList);
|
|
6518
6076
|
}
|
|
6519
6077
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
6520
6078
|
if (fromConfig != null) {
|
|
@@ -6662,14 +6220,13 @@ function contentFromMldev(apiClient, fromObject) {
|
|
|
6662
6220
|
const toObject = {};
|
|
6663
6221
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
6664
6222
|
if (fromParts != null) {
|
|
6665
|
-
|
|
6666
|
-
|
|
6223
|
+
let transformedList = fromParts;
|
|
6224
|
+
if (Array.isArray(transformedList)) {
|
|
6225
|
+
transformedList = transformedList.map((item) => {
|
|
6667
6226
|
return partFromMldev(apiClient, item);
|
|
6668
|
-
})
|
|
6669
|
-
}
|
|
6670
|
-
else {
|
|
6671
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
6227
|
+
});
|
|
6672
6228
|
}
|
|
6229
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
6673
6230
|
}
|
|
6674
6231
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
6675
6232
|
if (fromRole != null) {
|
|
@@ -6737,14 +6294,13 @@ function generateContentResponseFromMldev(apiClient, fromObject) {
|
|
|
6737
6294
|
const toObject = {};
|
|
6738
6295
|
const fromCandidates = getValueByPath(fromObject, ['candidates']);
|
|
6739
6296
|
if (fromCandidates != null) {
|
|
6740
|
-
|
|
6741
|
-
|
|
6297
|
+
let transformedList = fromCandidates;
|
|
6298
|
+
if (Array.isArray(transformedList)) {
|
|
6299
|
+
transformedList = transformedList.map((item) => {
|
|
6742
6300
|
return candidateFromMldev(apiClient, item);
|
|
6743
|
-
})
|
|
6744
|
-
}
|
|
6745
|
-
else {
|
|
6746
|
-
setValueByPath(toObject, ['candidates'], fromCandidates);
|
|
6301
|
+
});
|
|
6747
6302
|
}
|
|
6303
|
+
setValueByPath(toObject, ['candidates'], transformedList);
|
|
6748
6304
|
}
|
|
6749
6305
|
const fromModelVersion = getValueByPath(fromObject, ['modelVersion']);
|
|
6750
6306
|
if (fromModelVersion != null) {
|
|
@@ -6780,14 +6336,13 @@ function embedContentResponseFromMldev(apiClient, fromObject) {
|
|
|
6780
6336
|
const toObject = {};
|
|
6781
6337
|
const fromEmbeddings = getValueByPath(fromObject, ['embeddings']);
|
|
6782
6338
|
if (fromEmbeddings != null) {
|
|
6783
|
-
|
|
6784
|
-
|
|
6339
|
+
let transformedList = fromEmbeddings;
|
|
6340
|
+
if (Array.isArray(transformedList)) {
|
|
6341
|
+
transformedList = transformedList.map((item) => {
|
|
6785
6342
|
return contentEmbeddingFromMldev(apiClient, item);
|
|
6786
|
-
})
|
|
6787
|
-
}
|
|
6788
|
-
else {
|
|
6789
|
-
setValueByPath(toObject, ['embeddings'], fromEmbeddings);
|
|
6343
|
+
});
|
|
6790
6344
|
}
|
|
6345
|
+
setValueByPath(toObject, ['embeddings'], transformedList);
|
|
6791
6346
|
}
|
|
6792
6347
|
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
6793
6348
|
if (fromMetadata != null) {
|
|
@@ -6855,14 +6410,13 @@ function generateImagesResponseFromMldev(apiClient, fromObject) {
|
|
|
6855
6410
|
'predictions',
|
|
6856
6411
|
]);
|
|
6857
6412
|
if (fromGeneratedImages != null) {
|
|
6858
|
-
|
|
6859
|
-
|
|
6413
|
+
let transformedList = fromGeneratedImages;
|
|
6414
|
+
if (Array.isArray(transformedList)) {
|
|
6415
|
+
transformedList = transformedList.map((item) => {
|
|
6860
6416
|
return generatedImageFromMldev(apiClient, item);
|
|
6861
|
-
})
|
|
6862
|
-
}
|
|
6863
|
-
else {
|
|
6864
|
-
setValueByPath(toObject, ['generatedImages'], fromGeneratedImages);
|
|
6417
|
+
});
|
|
6865
6418
|
}
|
|
6419
|
+
setValueByPath(toObject, ['generatedImages'], transformedList);
|
|
6866
6420
|
}
|
|
6867
6421
|
const fromPositivePromptSafetyAttributes = getValueByPath(fromObject, [
|
|
6868
6422
|
'positivePromptSafetyAttributes',
|
|
@@ -6930,6 +6484,10 @@ function modelFromMldev(apiClient, fromObject) {
|
|
|
6930
6484
|
}
|
|
6931
6485
|
return toObject;
|
|
6932
6486
|
}
|
|
6487
|
+
function deleteModelResponseFromMldev() {
|
|
6488
|
+
const toObject = {};
|
|
6489
|
+
return toObject;
|
|
6490
|
+
}
|
|
6933
6491
|
function countTokensResponseFromMldev(apiClient, fromObject) {
|
|
6934
6492
|
const toObject = {};
|
|
6935
6493
|
const fromTotalTokens = getValueByPath(fromObject, ['totalTokens']);
|
|
@@ -6977,14 +6535,13 @@ function generateVideosResponseFromMldev$1(apiClient, fromObject) {
|
|
|
6977
6535
|
'generatedSamples',
|
|
6978
6536
|
]);
|
|
6979
6537
|
if (fromGeneratedVideos != null) {
|
|
6980
|
-
|
|
6981
|
-
|
|
6538
|
+
let transformedList = fromGeneratedVideos;
|
|
6539
|
+
if (Array.isArray(transformedList)) {
|
|
6540
|
+
transformedList = transformedList.map((item) => {
|
|
6982
6541
|
return generatedVideoFromMldev$1(apiClient, item);
|
|
6983
|
-
})
|
|
6984
|
-
}
|
|
6985
|
-
else {
|
|
6986
|
-
setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos);
|
|
6542
|
+
});
|
|
6987
6543
|
}
|
|
6544
|
+
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
6988
6545
|
}
|
|
6989
6546
|
const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
|
|
6990
6547
|
'raiMediaFilteredCount',
|
|
@@ -7079,14 +6636,13 @@ function contentFromVertex(apiClient, fromObject) {
|
|
|
7079
6636
|
const toObject = {};
|
|
7080
6637
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
7081
6638
|
if (fromParts != null) {
|
|
7082
|
-
|
|
7083
|
-
|
|
6639
|
+
let transformedList = fromParts;
|
|
6640
|
+
if (Array.isArray(transformedList)) {
|
|
6641
|
+
transformedList = transformedList.map((item) => {
|
|
7084
6642
|
return partFromVertex(apiClient, item);
|
|
7085
|
-
})
|
|
7086
|
-
}
|
|
7087
|
-
else {
|
|
7088
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
6643
|
+
});
|
|
7089
6644
|
}
|
|
6645
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
7090
6646
|
}
|
|
7091
6647
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
7092
6648
|
if (fromRole != null) {
|
|
@@ -7156,14 +6712,13 @@ function generateContentResponseFromVertex(apiClient, fromObject) {
|
|
|
7156
6712
|
const toObject = {};
|
|
7157
6713
|
const fromCandidates = getValueByPath(fromObject, ['candidates']);
|
|
7158
6714
|
if (fromCandidates != null) {
|
|
7159
|
-
|
|
7160
|
-
|
|
6715
|
+
let transformedList = fromCandidates;
|
|
6716
|
+
if (Array.isArray(transformedList)) {
|
|
6717
|
+
transformedList = transformedList.map((item) => {
|
|
7161
6718
|
return candidateFromVertex(apiClient, item);
|
|
7162
|
-
})
|
|
7163
|
-
}
|
|
7164
|
-
else {
|
|
7165
|
-
setValueByPath(toObject, ['candidates'], fromCandidates);
|
|
6719
|
+
});
|
|
7166
6720
|
}
|
|
6721
|
+
setValueByPath(toObject, ['candidates'], transformedList);
|
|
7167
6722
|
}
|
|
7168
6723
|
const fromCreateTime = getValueByPath(fromObject, ['createTime']);
|
|
7169
6724
|
if (fromCreateTime != null) {
|
|
@@ -7232,14 +6787,13 @@ function embedContentResponseFromVertex(apiClient, fromObject) {
|
|
|
7232
6787
|
'embeddings',
|
|
7233
6788
|
]);
|
|
7234
6789
|
if (fromEmbeddings != null) {
|
|
7235
|
-
|
|
7236
|
-
|
|
6790
|
+
let transformedList = fromEmbeddings;
|
|
6791
|
+
if (Array.isArray(transformedList)) {
|
|
6792
|
+
transformedList = transformedList.map((item) => {
|
|
7237
6793
|
return contentEmbeddingFromVertex(apiClient, item);
|
|
7238
|
-
})
|
|
7239
|
-
}
|
|
7240
|
-
else {
|
|
7241
|
-
setValueByPath(toObject, ['embeddings'], fromEmbeddings);
|
|
6794
|
+
});
|
|
7242
6795
|
}
|
|
6796
|
+
setValueByPath(toObject, ['embeddings'], transformedList);
|
|
7243
6797
|
}
|
|
7244
6798
|
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
7245
6799
|
if (fromMetadata != null) {
|
|
@@ -7315,14 +6869,13 @@ function generateImagesResponseFromVertex(apiClient, fromObject) {
|
|
|
7315
6869
|
'predictions',
|
|
7316
6870
|
]);
|
|
7317
6871
|
if (fromGeneratedImages != null) {
|
|
7318
|
-
|
|
7319
|
-
|
|
6872
|
+
let transformedList = fromGeneratedImages;
|
|
6873
|
+
if (Array.isArray(transformedList)) {
|
|
6874
|
+
transformedList = transformedList.map((item) => {
|
|
7320
6875
|
return generatedImageFromVertex(apiClient, item);
|
|
7321
|
-
})
|
|
7322
|
-
}
|
|
7323
|
-
else {
|
|
7324
|
-
setValueByPath(toObject, ['generatedImages'], fromGeneratedImages);
|
|
6876
|
+
});
|
|
7325
6877
|
}
|
|
6878
|
+
setValueByPath(toObject, ['generatedImages'], transformedList);
|
|
7326
6879
|
}
|
|
7327
6880
|
const fromPositivePromptSafetyAttributes = getValueByPath(fromObject, [
|
|
7328
6881
|
'positivePromptSafetyAttributes',
|
|
@@ -7385,14 +6938,13 @@ function modelFromVertex(apiClient, fromObject) {
|
|
|
7385
6938
|
}
|
|
7386
6939
|
const fromEndpoints = getValueByPath(fromObject, ['deployedModels']);
|
|
7387
6940
|
if (fromEndpoints != null) {
|
|
7388
|
-
|
|
7389
|
-
|
|
6941
|
+
let transformedList = fromEndpoints;
|
|
6942
|
+
if (Array.isArray(transformedList)) {
|
|
6943
|
+
transformedList = transformedList.map((item) => {
|
|
7390
6944
|
return endpointFromVertex(apiClient, item);
|
|
7391
|
-
})
|
|
7392
|
-
}
|
|
7393
|
-
else {
|
|
7394
|
-
setValueByPath(toObject, ['endpoints'], fromEndpoints);
|
|
6945
|
+
});
|
|
7395
6946
|
}
|
|
6947
|
+
setValueByPath(toObject, ['endpoints'], transformedList);
|
|
7396
6948
|
}
|
|
7397
6949
|
const fromLabels = getValueByPath(fromObject, ['labels']);
|
|
7398
6950
|
if (fromLabels != null) {
|
|
@@ -7404,6 +6956,10 @@ function modelFromVertex(apiClient, fromObject) {
|
|
|
7404
6956
|
}
|
|
7405
6957
|
return toObject;
|
|
7406
6958
|
}
|
|
6959
|
+
function deleteModelResponseFromVertex() {
|
|
6960
|
+
const toObject = {};
|
|
6961
|
+
return toObject;
|
|
6962
|
+
}
|
|
7407
6963
|
function countTokensResponseFromVertex(apiClient, fromObject) {
|
|
7408
6964
|
const toObject = {};
|
|
7409
6965
|
const fromTotalTokens = getValueByPath(fromObject, ['totalTokens']);
|
|
@@ -7450,14 +7006,13 @@ function generateVideosResponseFromVertex$1(apiClient, fromObject) {
|
|
|
7450
7006
|
const toObject = {};
|
|
7451
7007
|
const fromGeneratedVideos = getValueByPath(fromObject, ['videos']);
|
|
7452
7008
|
if (fromGeneratedVideos != null) {
|
|
7453
|
-
|
|
7454
|
-
|
|
7009
|
+
let transformedList = fromGeneratedVideos;
|
|
7010
|
+
if (Array.isArray(transformedList)) {
|
|
7011
|
+
transformedList = transformedList.map((item) => {
|
|
7455
7012
|
return generatedVideoFromVertex$1(apiClient, item);
|
|
7456
|
-
})
|
|
7457
|
-
}
|
|
7458
|
-
else {
|
|
7459
|
-
setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos);
|
|
7013
|
+
});
|
|
7460
7014
|
}
|
|
7015
|
+
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
7461
7016
|
}
|
|
7462
7017
|
const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
|
|
7463
7018
|
'raiMediaFilteredCount',
|
|
@@ -8400,6 +7955,146 @@ class Models extends BaseModule {
|
|
|
8400
7955
|
});
|
|
8401
7956
|
}
|
|
8402
7957
|
}
|
|
7958
|
+
/**
|
|
7959
|
+
* Updates a tuned model by its name.
|
|
7960
|
+
*
|
|
7961
|
+
* @param params - The parameters for updating the model.
|
|
7962
|
+
* @return The response from the API.
|
|
7963
|
+
*
|
|
7964
|
+
* @example
|
|
7965
|
+
* ```ts
|
|
7966
|
+
* const response = await ai.models.update({
|
|
7967
|
+
* model: 'tuned-model-name',
|
|
7968
|
+
* config: {
|
|
7969
|
+
* displayName: 'New display name',
|
|
7970
|
+
* description: 'New description',
|
|
7971
|
+
* },
|
|
7972
|
+
* });
|
|
7973
|
+
* ```
|
|
7974
|
+
*/
|
|
7975
|
+
async update(params) {
|
|
7976
|
+
var _a, _b, _c, _d;
|
|
7977
|
+
let response;
|
|
7978
|
+
let path = '';
|
|
7979
|
+
let queryParams = {};
|
|
7980
|
+
if (this.apiClient.isVertexAI()) {
|
|
7981
|
+
const body = updateModelParametersToVertex(this.apiClient, params);
|
|
7982
|
+
path = formatMap('{model}', body['_url']);
|
|
7983
|
+
queryParams = body['_query'];
|
|
7984
|
+
delete body['config'];
|
|
7985
|
+
delete body['_url'];
|
|
7986
|
+
delete body['_query'];
|
|
7987
|
+
response = this.apiClient
|
|
7988
|
+
.request({
|
|
7989
|
+
path: path,
|
|
7990
|
+
queryParams: queryParams,
|
|
7991
|
+
body: JSON.stringify(body),
|
|
7992
|
+
httpMethod: 'PATCH',
|
|
7993
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
7994
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
7995
|
+
})
|
|
7996
|
+
.then((httpResponse) => {
|
|
7997
|
+
return httpResponse.json();
|
|
7998
|
+
});
|
|
7999
|
+
return response.then((apiResponse) => {
|
|
8000
|
+
const resp = modelFromVertex(this.apiClient, apiResponse);
|
|
8001
|
+
return resp;
|
|
8002
|
+
});
|
|
8003
|
+
}
|
|
8004
|
+
else {
|
|
8005
|
+
const body = updateModelParametersToMldev(this.apiClient, params);
|
|
8006
|
+
path = formatMap('{name}', body['_url']);
|
|
8007
|
+
queryParams = body['_query'];
|
|
8008
|
+
delete body['config'];
|
|
8009
|
+
delete body['_url'];
|
|
8010
|
+
delete body['_query'];
|
|
8011
|
+
response = this.apiClient
|
|
8012
|
+
.request({
|
|
8013
|
+
path: path,
|
|
8014
|
+
queryParams: queryParams,
|
|
8015
|
+
body: JSON.stringify(body),
|
|
8016
|
+
httpMethod: 'PATCH',
|
|
8017
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
8018
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
8019
|
+
})
|
|
8020
|
+
.then((httpResponse) => {
|
|
8021
|
+
return httpResponse.json();
|
|
8022
|
+
});
|
|
8023
|
+
return response.then((apiResponse) => {
|
|
8024
|
+
const resp = modelFromMldev(this.apiClient, apiResponse);
|
|
8025
|
+
return resp;
|
|
8026
|
+
});
|
|
8027
|
+
}
|
|
8028
|
+
}
|
|
8029
|
+
/**
|
|
8030
|
+
* Deletes a tuned model by its name.
|
|
8031
|
+
*
|
|
8032
|
+
* @param params - The parameters for deleting the model.
|
|
8033
|
+
* @return The response from the API.
|
|
8034
|
+
*
|
|
8035
|
+
* @example
|
|
8036
|
+
* ```ts
|
|
8037
|
+
* const response = await ai.models.delete({model: 'tuned-model-name'});
|
|
8038
|
+
* ```
|
|
8039
|
+
*/
|
|
8040
|
+
async delete(params) {
|
|
8041
|
+
var _a, _b, _c, _d;
|
|
8042
|
+
let response;
|
|
8043
|
+
let path = '';
|
|
8044
|
+
let queryParams = {};
|
|
8045
|
+
if (this.apiClient.isVertexAI()) {
|
|
8046
|
+
const body = deleteModelParametersToVertex(this.apiClient, params);
|
|
8047
|
+
path = formatMap('{name}', body['_url']);
|
|
8048
|
+
queryParams = body['_query'];
|
|
8049
|
+
delete body['config'];
|
|
8050
|
+
delete body['_url'];
|
|
8051
|
+
delete body['_query'];
|
|
8052
|
+
response = this.apiClient
|
|
8053
|
+
.request({
|
|
8054
|
+
path: path,
|
|
8055
|
+
queryParams: queryParams,
|
|
8056
|
+
body: JSON.stringify(body),
|
|
8057
|
+
httpMethod: 'DELETE',
|
|
8058
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
8059
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
8060
|
+
})
|
|
8061
|
+
.then((httpResponse) => {
|
|
8062
|
+
return httpResponse.json();
|
|
8063
|
+
});
|
|
8064
|
+
return response.then(() => {
|
|
8065
|
+
const resp = deleteModelResponseFromVertex();
|
|
8066
|
+
const typedResp = new DeleteModelResponse();
|
|
8067
|
+
Object.assign(typedResp, resp);
|
|
8068
|
+
return typedResp;
|
|
8069
|
+
});
|
|
8070
|
+
}
|
|
8071
|
+
else {
|
|
8072
|
+
const body = deleteModelParametersToMldev(this.apiClient, params);
|
|
8073
|
+
path = formatMap('{name}', body['_url']);
|
|
8074
|
+
queryParams = body['_query'];
|
|
8075
|
+
delete body['config'];
|
|
8076
|
+
delete body['_url'];
|
|
8077
|
+
delete body['_query'];
|
|
8078
|
+
response = this.apiClient
|
|
8079
|
+
.request({
|
|
8080
|
+
path: path,
|
|
8081
|
+
queryParams: queryParams,
|
|
8082
|
+
body: JSON.stringify(body),
|
|
8083
|
+
httpMethod: 'DELETE',
|
|
8084
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
8085
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
8086
|
+
})
|
|
8087
|
+
.then((httpResponse) => {
|
|
8088
|
+
return httpResponse.json();
|
|
8089
|
+
});
|
|
8090
|
+
return response.then(() => {
|
|
8091
|
+
const resp = deleteModelResponseFromMldev();
|
|
8092
|
+
const typedResp = new DeleteModelResponse();
|
|
8093
|
+
Object.assign(typedResp, resp);
|
|
8094
|
+
return typedResp;
|
|
8095
|
+
});
|
|
8096
|
+
}
|
|
8097
|
+
}
|
|
8403
8098
|
/**
|
|
8404
8099
|
* Counts the number of tokens in the given contents. Multimodal input is
|
|
8405
8100
|
* supported for Gemini models.
|
|
@@ -8690,14 +8385,13 @@ function generateVideosResponseFromMldev(apiClient, fromObject) {
|
|
|
8690
8385
|
'generatedSamples',
|
|
8691
8386
|
]);
|
|
8692
8387
|
if (fromGeneratedVideos != null) {
|
|
8693
|
-
|
|
8694
|
-
|
|
8388
|
+
let transformedList = fromGeneratedVideos;
|
|
8389
|
+
if (Array.isArray(transformedList)) {
|
|
8390
|
+
transformedList = transformedList.map((item) => {
|
|
8695
8391
|
return generatedVideoFromMldev(apiClient, item);
|
|
8696
|
-
})
|
|
8697
|
-
}
|
|
8698
|
-
else {
|
|
8699
|
-
setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos);
|
|
8392
|
+
});
|
|
8700
8393
|
}
|
|
8394
|
+
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
8701
8395
|
}
|
|
8702
8396
|
const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
|
|
8703
8397
|
'raiMediaFilteredCount',
|
|
@@ -8770,14 +8464,13 @@ function generateVideosResponseFromVertex(apiClient, fromObject) {
|
|
|
8770
8464
|
const toObject = {};
|
|
8771
8465
|
const fromGeneratedVideos = getValueByPath(fromObject, ['videos']);
|
|
8772
8466
|
if (fromGeneratedVideos != null) {
|
|
8773
|
-
|
|
8774
|
-
|
|
8467
|
+
let transformedList = fromGeneratedVideos;
|
|
8468
|
+
if (Array.isArray(transformedList)) {
|
|
8469
|
+
transformedList = transformedList.map((item) => {
|
|
8775
8470
|
return generatedVideoFromVertex(apiClient, item);
|
|
8776
|
-
})
|
|
8777
|
-
}
|
|
8778
|
-
else {
|
|
8779
|
-
setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos);
|
|
8471
|
+
});
|
|
8780
8472
|
}
|
|
8473
|
+
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
8781
8474
|
}
|
|
8782
8475
|
const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
|
|
8783
8476
|
'raiMediaFilteredCount',
|
|
@@ -8957,7 +8650,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
8957
8650
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
8958
8651
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
8959
8652
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
8960
|
-
const SDK_VERSION = '0.
|
|
8653
|
+
const SDK_VERSION = '0.12.0'; // x-release-please-version
|
|
8961
8654
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
8962
8655
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
8963
8656
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -9545,6 +9238,736 @@ class NodeWebSocket {
|
|
|
9545
9238
|
}
|
|
9546
9239
|
}
|
|
9547
9240
|
|
|
9241
|
+
/**
|
|
9242
|
+
* @license
|
|
9243
|
+
* Copyright 2025 Google LLC
|
|
9244
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
9245
|
+
*/
|
|
9246
|
+
function getTuningJobParametersToMldev(apiClient, fromObject) {
|
|
9247
|
+
const toObject = {};
|
|
9248
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
9249
|
+
if (fromName != null) {
|
|
9250
|
+
setValueByPath(toObject, ['_url', 'name'], fromName);
|
|
9251
|
+
}
|
|
9252
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
9253
|
+
if (fromConfig != null) {
|
|
9254
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
9255
|
+
}
|
|
9256
|
+
return toObject;
|
|
9257
|
+
}
|
|
9258
|
+
function listTuningJobsConfigToMldev(apiClient, fromObject, parentObject) {
|
|
9259
|
+
const toObject = {};
|
|
9260
|
+
const fromPageSize = getValueByPath(fromObject, ['pageSize']);
|
|
9261
|
+
if (parentObject !== undefined && fromPageSize != null) {
|
|
9262
|
+
setValueByPath(parentObject, ['_query', 'pageSize'], fromPageSize);
|
|
9263
|
+
}
|
|
9264
|
+
const fromPageToken = getValueByPath(fromObject, ['pageToken']);
|
|
9265
|
+
if (parentObject !== undefined && fromPageToken != null) {
|
|
9266
|
+
setValueByPath(parentObject, ['_query', 'pageToken'], fromPageToken);
|
|
9267
|
+
}
|
|
9268
|
+
const fromFilter = getValueByPath(fromObject, ['filter']);
|
|
9269
|
+
if (parentObject !== undefined && fromFilter != null) {
|
|
9270
|
+
setValueByPath(parentObject, ['_query', 'filter'], fromFilter);
|
|
9271
|
+
}
|
|
9272
|
+
return toObject;
|
|
9273
|
+
}
|
|
9274
|
+
function listTuningJobsParametersToMldev(apiClient, fromObject) {
|
|
9275
|
+
const toObject = {};
|
|
9276
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
9277
|
+
if (fromConfig != null) {
|
|
9278
|
+
setValueByPath(toObject, ['config'], listTuningJobsConfigToMldev(apiClient, fromConfig, toObject));
|
|
9279
|
+
}
|
|
9280
|
+
return toObject;
|
|
9281
|
+
}
|
|
9282
|
+
function tuningExampleToMldev(apiClient, fromObject) {
|
|
9283
|
+
const toObject = {};
|
|
9284
|
+
const fromTextInput = getValueByPath(fromObject, ['textInput']);
|
|
9285
|
+
if (fromTextInput != null) {
|
|
9286
|
+
setValueByPath(toObject, ['textInput'], fromTextInput);
|
|
9287
|
+
}
|
|
9288
|
+
const fromOutput = getValueByPath(fromObject, ['output']);
|
|
9289
|
+
if (fromOutput != null) {
|
|
9290
|
+
setValueByPath(toObject, ['output'], fromOutput);
|
|
9291
|
+
}
|
|
9292
|
+
return toObject;
|
|
9293
|
+
}
|
|
9294
|
+
function tuningDatasetToMldev(apiClient, fromObject) {
|
|
9295
|
+
const toObject = {};
|
|
9296
|
+
if (getValueByPath(fromObject, ['gcsUri']) !== undefined) {
|
|
9297
|
+
throw new Error('gcsUri parameter is not supported in Gemini API.');
|
|
9298
|
+
}
|
|
9299
|
+
const fromExamples = getValueByPath(fromObject, ['examples']);
|
|
9300
|
+
if (fromExamples != null) {
|
|
9301
|
+
let transformedList = fromExamples;
|
|
9302
|
+
if (Array.isArray(transformedList)) {
|
|
9303
|
+
transformedList = transformedList.map((item) => {
|
|
9304
|
+
return tuningExampleToMldev(apiClient, item);
|
|
9305
|
+
});
|
|
9306
|
+
}
|
|
9307
|
+
setValueByPath(toObject, ['examples', 'examples'], transformedList);
|
|
9308
|
+
}
|
|
9309
|
+
return toObject;
|
|
9310
|
+
}
|
|
9311
|
+
function createTuningJobConfigToMldev(apiClient, fromObject, parentObject) {
|
|
9312
|
+
const toObject = {};
|
|
9313
|
+
if (getValueByPath(fromObject, ['validationDataset']) !== undefined) {
|
|
9314
|
+
throw new Error('validationDataset parameter is not supported in Gemini API.');
|
|
9315
|
+
}
|
|
9316
|
+
const fromTunedModelDisplayName = getValueByPath(fromObject, [
|
|
9317
|
+
'tunedModelDisplayName',
|
|
9318
|
+
]);
|
|
9319
|
+
if (parentObject !== undefined && fromTunedModelDisplayName != null) {
|
|
9320
|
+
setValueByPath(parentObject, ['displayName'], fromTunedModelDisplayName);
|
|
9321
|
+
}
|
|
9322
|
+
if (getValueByPath(fromObject, ['description']) !== undefined) {
|
|
9323
|
+
throw new Error('description parameter is not supported in Gemini API.');
|
|
9324
|
+
}
|
|
9325
|
+
const fromEpochCount = getValueByPath(fromObject, ['epochCount']);
|
|
9326
|
+
if (parentObject !== undefined && fromEpochCount != null) {
|
|
9327
|
+
setValueByPath(parentObject, ['tuningTask', 'hyperparameters', 'epochCount'], fromEpochCount);
|
|
9328
|
+
}
|
|
9329
|
+
const fromLearningRateMultiplier = getValueByPath(fromObject, [
|
|
9330
|
+
'learningRateMultiplier',
|
|
9331
|
+
]);
|
|
9332
|
+
if (fromLearningRateMultiplier != null) {
|
|
9333
|
+
setValueByPath(toObject, ['tuningTask', 'hyperparameters', 'learningRateMultiplier'], fromLearningRateMultiplier);
|
|
9334
|
+
}
|
|
9335
|
+
if (getValueByPath(fromObject, ['adapterSize']) !== undefined) {
|
|
9336
|
+
throw new Error('adapterSize parameter is not supported in Gemini API.');
|
|
9337
|
+
}
|
|
9338
|
+
const fromBatchSize = getValueByPath(fromObject, ['batchSize']);
|
|
9339
|
+
if (parentObject !== undefined && fromBatchSize != null) {
|
|
9340
|
+
setValueByPath(parentObject, ['tuningTask', 'hyperparameters', 'batchSize'], fromBatchSize);
|
|
9341
|
+
}
|
|
9342
|
+
const fromLearningRate = getValueByPath(fromObject, ['learningRate']);
|
|
9343
|
+
if (parentObject !== undefined && fromLearningRate != null) {
|
|
9344
|
+
setValueByPath(parentObject, ['tuningTask', 'hyperparameters', 'learningRate'], fromLearningRate);
|
|
9345
|
+
}
|
|
9346
|
+
return toObject;
|
|
9347
|
+
}
|
|
9348
|
+
function createTuningJobParametersToMldev(apiClient, fromObject) {
|
|
9349
|
+
const toObject = {};
|
|
9350
|
+
const fromBaseModel = getValueByPath(fromObject, ['baseModel']);
|
|
9351
|
+
if (fromBaseModel != null) {
|
|
9352
|
+
setValueByPath(toObject, ['baseModel'], fromBaseModel);
|
|
9353
|
+
}
|
|
9354
|
+
const fromTrainingDataset = getValueByPath(fromObject, [
|
|
9355
|
+
'trainingDataset',
|
|
9356
|
+
]);
|
|
9357
|
+
if (fromTrainingDataset != null) {
|
|
9358
|
+
setValueByPath(toObject, ['tuningTask', 'trainingData'], tuningDatasetToMldev(apiClient, fromTrainingDataset));
|
|
9359
|
+
}
|
|
9360
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
9361
|
+
if (fromConfig != null) {
|
|
9362
|
+
setValueByPath(toObject, ['config'], createTuningJobConfigToMldev(apiClient, fromConfig, toObject));
|
|
9363
|
+
}
|
|
9364
|
+
return toObject;
|
|
9365
|
+
}
|
|
9366
|
+
function getTuningJobParametersToVertex(apiClient, fromObject) {
|
|
9367
|
+
const toObject = {};
|
|
9368
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
9369
|
+
if (fromName != null) {
|
|
9370
|
+
setValueByPath(toObject, ['_url', 'name'], fromName);
|
|
9371
|
+
}
|
|
9372
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
9373
|
+
if (fromConfig != null) {
|
|
9374
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
9375
|
+
}
|
|
9376
|
+
return toObject;
|
|
9377
|
+
}
|
|
9378
|
+
function listTuningJobsConfigToVertex(apiClient, fromObject, parentObject) {
|
|
9379
|
+
const toObject = {};
|
|
9380
|
+
const fromPageSize = getValueByPath(fromObject, ['pageSize']);
|
|
9381
|
+
if (parentObject !== undefined && fromPageSize != null) {
|
|
9382
|
+
setValueByPath(parentObject, ['_query', 'pageSize'], fromPageSize);
|
|
9383
|
+
}
|
|
9384
|
+
const fromPageToken = getValueByPath(fromObject, ['pageToken']);
|
|
9385
|
+
if (parentObject !== undefined && fromPageToken != null) {
|
|
9386
|
+
setValueByPath(parentObject, ['_query', 'pageToken'], fromPageToken);
|
|
9387
|
+
}
|
|
9388
|
+
const fromFilter = getValueByPath(fromObject, ['filter']);
|
|
9389
|
+
if (parentObject !== undefined && fromFilter != null) {
|
|
9390
|
+
setValueByPath(parentObject, ['_query', 'filter'], fromFilter);
|
|
9391
|
+
}
|
|
9392
|
+
return toObject;
|
|
9393
|
+
}
|
|
9394
|
+
function listTuningJobsParametersToVertex(apiClient, fromObject) {
|
|
9395
|
+
const toObject = {};
|
|
9396
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
9397
|
+
if (fromConfig != null) {
|
|
9398
|
+
setValueByPath(toObject, ['config'], listTuningJobsConfigToVertex(apiClient, fromConfig, toObject));
|
|
9399
|
+
}
|
|
9400
|
+
return toObject;
|
|
9401
|
+
}
|
|
9402
|
+
function tuningDatasetToVertex(apiClient, fromObject, parentObject) {
|
|
9403
|
+
const toObject = {};
|
|
9404
|
+
const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
|
|
9405
|
+
if (parentObject !== undefined && fromGcsUri != null) {
|
|
9406
|
+
setValueByPath(parentObject, ['supervisedTuningSpec', 'trainingDatasetUri'], fromGcsUri);
|
|
9407
|
+
}
|
|
9408
|
+
if (getValueByPath(fromObject, ['examples']) !== undefined) {
|
|
9409
|
+
throw new Error('examples parameter is not supported in Vertex AI.');
|
|
9410
|
+
}
|
|
9411
|
+
return toObject;
|
|
9412
|
+
}
|
|
9413
|
+
function tuningValidationDatasetToVertex(apiClient, fromObject) {
|
|
9414
|
+
const toObject = {};
|
|
9415
|
+
const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
|
|
9416
|
+
if (fromGcsUri != null) {
|
|
9417
|
+
setValueByPath(toObject, ['validationDatasetUri'], fromGcsUri);
|
|
9418
|
+
}
|
|
9419
|
+
return toObject;
|
|
9420
|
+
}
|
|
9421
|
+
function createTuningJobConfigToVertex(apiClient, fromObject, parentObject) {
|
|
9422
|
+
const toObject = {};
|
|
9423
|
+
const fromValidationDataset = getValueByPath(fromObject, [
|
|
9424
|
+
'validationDataset',
|
|
9425
|
+
]);
|
|
9426
|
+
if (parentObject !== undefined && fromValidationDataset != null) {
|
|
9427
|
+
setValueByPath(parentObject, ['supervisedTuningSpec'], tuningValidationDatasetToVertex(apiClient, fromValidationDataset));
|
|
9428
|
+
}
|
|
9429
|
+
const fromTunedModelDisplayName = getValueByPath(fromObject, [
|
|
9430
|
+
'tunedModelDisplayName',
|
|
9431
|
+
]);
|
|
9432
|
+
if (parentObject !== undefined && fromTunedModelDisplayName != null) {
|
|
9433
|
+
setValueByPath(parentObject, ['tunedModelDisplayName'], fromTunedModelDisplayName);
|
|
9434
|
+
}
|
|
9435
|
+
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
9436
|
+
if (parentObject !== undefined && fromDescription != null) {
|
|
9437
|
+
setValueByPath(parentObject, ['description'], fromDescription);
|
|
9438
|
+
}
|
|
9439
|
+
const fromEpochCount = getValueByPath(fromObject, ['epochCount']);
|
|
9440
|
+
if (parentObject !== undefined && fromEpochCount != null) {
|
|
9441
|
+
setValueByPath(parentObject, ['supervisedTuningSpec', 'hyperParameters', 'epochCount'], fromEpochCount);
|
|
9442
|
+
}
|
|
9443
|
+
const fromLearningRateMultiplier = getValueByPath(fromObject, [
|
|
9444
|
+
'learningRateMultiplier',
|
|
9445
|
+
]);
|
|
9446
|
+
if (parentObject !== undefined && fromLearningRateMultiplier != null) {
|
|
9447
|
+
setValueByPath(parentObject, ['supervisedTuningSpec', 'hyperParameters', 'learningRateMultiplier'], fromLearningRateMultiplier);
|
|
9448
|
+
}
|
|
9449
|
+
const fromAdapterSize = getValueByPath(fromObject, ['adapterSize']);
|
|
9450
|
+
if (parentObject !== undefined && fromAdapterSize != null) {
|
|
9451
|
+
setValueByPath(parentObject, ['supervisedTuningSpec', 'hyperParameters', 'adapterSize'], fromAdapterSize);
|
|
9452
|
+
}
|
|
9453
|
+
if (getValueByPath(fromObject, ['batchSize']) !== undefined) {
|
|
9454
|
+
throw new Error('batchSize parameter is not supported in Vertex AI.');
|
|
9455
|
+
}
|
|
9456
|
+
if (getValueByPath(fromObject, ['learningRate']) !== undefined) {
|
|
9457
|
+
throw new Error('learningRate parameter is not supported in Vertex AI.');
|
|
9458
|
+
}
|
|
9459
|
+
return toObject;
|
|
9460
|
+
}
|
|
9461
|
+
function createTuningJobParametersToVertex(apiClient, fromObject) {
|
|
9462
|
+
const toObject = {};
|
|
9463
|
+
const fromBaseModel = getValueByPath(fromObject, ['baseModel']);
|
|
9464
|
+
if (fromBaseModel != null) {
|
|
9465
|
+
setValueByPath(toObject, ['baseModel'], fromBaseModel);
|
|
9466
|
+
}
|
|
9467
|
+
const fromTrainingDataset = getValueByPath(fromObject, [
|
|
9468
|
+
'trainingDataset',
|
|
9469
|
+
]);
|
|
9470
|
+
if (fromTrainingDataset != null) {
|
|
9471
|
+
setValueByPath(toObject, ['supervisedTuningSpec', 'trainingDatasetUri'], tuningDatasetToVertex(apiClient, fromTrainingDataset, toObject));
|
|
9472
|
+
}
|
|
9473
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
9474
|
+
if (fromConfig != null) {
|
|
9475
|
+
setValueByPath(toObject, ['config'], createTuningJobConfigToVertex(apiClient, fromConfig, toObject));
|
|
9476
|
+
}
|
|
9477
|
+
return toObject;
|
|
9478
|
+
}
|
|
9479
|
+
function tunedModelFromMldev(apiClient, fromObject) {
|
|
9480
|
+
const toObject = {};
|
|
9481
|
+
const fromModel = getValueByPath(fromObject, ['name']);
|
|
9482
|
+
if (fromModel != null) {
|
|
9483
|
+
setValueByPath(toObject, ['model'], fromModel);
|
|
9484
|
+
}
|
|
9485
|
+
const fromEndpoint = getValueByPath(fromObject, ['name']);
|
|
9486
|
+
if (fromEndpoint != null) {
|
|
9487
|
+
setValueByPath(toObject, ['endpoint'], fromEndpoint);
|
|
9488
|
+
}
|
|
9489
|
+
return toObject;
|
|
9490
|
+
}
|
|
9491
|
+
function tuningJobFromMldev(apiClient, fromObject) {
|
|
9492
|
+
const toObject = {};
|
|
9493
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
9494
|
+
if (fromName != null) {
|
|
9495
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
9496
|
+
}
|
|
9497
|
+
const fromState = getValueByPath(fromObject, ['state']);
|
|
9498
|
+
if (fromState != null) {
|
|
9499
|
+
setValueByPath(toObject, ['state'], tTuningJobStatus(apiClient, fromState));
|
|
9500
|
+
}
|
|
9501
|
+
const fromCreateTime = getValueByPath(fromObject, ['createTime']);
|
|
9502
|
+
if (fromCreateTime != null) {
|
|
9503
|
+
setValueByPath(toObject, ['createTime'], fromCreateTime);
|
|
9504
|
+
}
|
|
9505
|
+
const fromStartTime = getValueByPath(fromObject, [
|
|
9506
|
+
'tuningTask',
|
|
9507
|
+
'startTime',
|
|
9508
|
+
]);
|
|
9509
|
+
if (fromStartTime != null) {
|
|
9510
|
+
setValueByPath(toObject, ['startTime'], fromStartTime);
|
|
9511
|
+
}
|
|
9512
|
+
const fromEndTime = getValueByPath(fromObject, [
|
|
9513
|
+
'tuningTask',
|
|
9514
|
+
'completeTime',
|
|
9515
|
+
]);
|
|
9516
|
+
if (fromEndTime != null) {
|
|
9517
|
+
setValueByPath(toObject, ['endTime'], fromEndTime);
|
|
9518
|
+
}
|
|
9519
|
+
const fromUpdateTime = getValueByPath(fromObject, ['updateTime']);
|
|
9520
|
+
if (fromUpdateTime != null) {
|
|
9521
|
+
setValueByPath(toObject, ['updateTime'], fromUpdateTime);
|
|
9522
|
+
}
|
|
9523
|
+
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
9524
|
+
if (fromDescription != null) {
|
|
9525
|
+
setValueByPath(toObject, ['description'], fromDescription);
|
|
9526
|
+
}
|
|
9527
|
+
const fromBaseModel = getValueByPath(fromObject, ['baseModel']);
|
|
9528
|
+
if (fromBaseModel != null) {
|
|
9529
|
+
setValueByPath(toObject, ['baseModel'], fromBaseModel);
|
|
9530
|
+
}
|
|
9531
|
+
const fromTunedModel = getValueByPath(fromObject, ['_self']);
|
|
9532
|
+
if (fromTunedModel != null) {
|
|
9533
|
+
setValueByPath(toObject, ['tunedModel'], tunedModelFromMldev(apiClient, fromTunedModel));
|
|
9534
|
+
}
|
|
9535
|
+
const fromDistillationSpec = getValueByPath(fromObject, [
|
|
9536
|
+
'distillationSpec',
|
|
9537
|
+
]);
|
|
9538
|
+
if (fromDistillationSpec != null) {
|
|
9539
|
+
setValueByPath(toObject, ['distillationSpec'], fromDistillationSpec);
|
|
9540
|
+
}
|
|
9541
|
+
const fromExperiment = getValueByPath(fromObject, ['experiment']);
|
|
9542
|
+
if (fromExperiment != null) {
|
|
9543
|
+
setValueByPath(toObject, ['experiment'], fromExperiment);
|
|
9544
|
+
}
|
|
9545
|
+
const fromLabels = getValueByPath(fromObject, ['labels']);
|
|
9546
|
+
if (fromLabels != null) {
|
|
9547
|
+
setValueByPath(toObject, ['labels'], fromLabels);
|
|
9548
|
+
}
|
|
9549
|
+
const fromPipelineJob = getValueByPath(fromObject, ['pipelineJob']);
|
|
9550
|
+
if (fromPipelineJob != null) {
|
|
9551
|
+
setValueByPath(toObject, ['pipelineJob'], fromPipelineJob);
|
|
9552
|
+
}
|
|
9553
|
+
const fromTunedModelDisplayName = getValueByPath(fromObject, [
|
|
9554
|
+
'tunedModelDisplayName',
|
|
9555
|
+
]);
|
|
9556
|
+
if (fromTunedModelDisplayName != null) {
|
|
9557
|
+
setValueByPath(toObject, ['tunedModelDisplayName'], fromTunedModelDisplayName);
|
|
9558
|
+
}
|
|
9559
|
+
return toObject;
|
|
9560
|
+
}
|
|
9561
|
+
function listTuningJobsResponseFromMldev(apiClient, fromObject) {
|
|
9562
|
+
const toObject = {};
|
|
9563
|
+
const fromNextPageToken = getValueByPath(fromObject, [
|
|
9564
|
+
'nextPageToken',
|
|
9565
|
+
]);
|
|
9566
|
+
if (fromNextPageToken != null) {
|
|
9567
|
+
setValueByPath(toObject, ['nextPageToken'], fromNextPageToken);
|
|
9568
|
+
}
|
|
9569
|
+
const fromTuningJobs = getValueByPath(fromObject, ['tunedModels']);
|
|
9570
|
+
if (fromTuningJobs != null) {
|
|
9571
|
+
let transformedList = fromTuningJobs;
|
|
9572
|
+
if (Array.isArray(transformedList)) {
|
|
9573
|
+
transformedList = transformedList.map((item) => {
|
|
9574
|
+
return tuningJobFromMldev(apiClient, item);
|
|
9575
|
+
});
|
|
9576
|
+
}
|
|
9577
|
+
setValueByPath(toObject, ['tuningJobs'], transformedList);
|
|
9578
|
+
}
|
|
9579
|
+
return toObject;
|
|
9580
|
+
}
|
|
9581
|
+
function operationFromMldev(apiClient, fromObject) {
|
|
9582
|
+
const toObject = {};
|
|
9583
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
9584
|
+
if (fromName != null) {
|
|
9585
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
9586
|
+
}
|
|
9587
|
+
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
9588
|
+
if (fromMetadata != null) {
|
|
9589
|
+
setValueByPath(toObject, ['metadata'], fromMetadata);
|
|
9590
|
+
}
|
|
9591
|
+
const fromDone = getValueByPath(fromObject, ['done']);
|
|
9592
|
+
if (fromDone != null) {
|
|
9593
|
+
setValueByPath(toObject, ['done'], fromDone);
|
|
9594
|
+
}
|
|
9595
|
+
const fromError = getValueByPath(fromObject, ['error']);
|
|
9596
|
+
if (fromError != null) {
|
|
9597
|
+
setValueByPath(toObject, ['error'], fromError);
|
|
9598
|
+
}
|
|
9599
|
+
return toObject;
|
|
9600
|
+
}
|
|
9601
|
+
function tunedModelFromVertex(apiClient, fromObject) {
|
|
9602
|
+
const toObject = {};
|
|
9603
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
9604
|
+
if (fromModel != null) {
|
|
9605
|
+
setValueByPath(toObject, ['model'], fromModel);
|
|
9606
|
+
}
|
|
9607
|
+
const fromEndpoint = getValueByPath(fromObject, ['endpoint']);
|
|
9608
|
+
if (fromEndpoint != null) {
|
|
9609
|
+
setValueByPath(toObject, ['endpoint'], fromEndpoint);
|
|
9610
|
+
}
|
|
9611
|
+
return toObject;
|
|
9612
|
+
}
|
|
9613
|
+
function tuningJobFromVertex(apiClient, fromObject) {
|
|
9614
|
+
const toObject = {};
|
|
9615
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
9616
|
+
if (fromName != null) {
|
|
9617
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
9618
|
+
}
|
|
9619
|
+
const fromState = getValueByPath(fromObject, ['state']);
|
|
9620
|
+
if (fromState != null) {
|
|
9621
|
+
setValueByPath(toObject, ['state'], tTuningJobStatus(apiClient, fromState));
|
|
9622
|
+
}
|
|
9623
|
+
const fromCreateTime = getValueByPath(fromObject, ['createTime']);
|
|
9624
|
+
if (fromCreateTime != null) {
|
|
9625
|
+
setValueByPath(toObject, ['createTime'], fromCreateTime);
|
|
9626
|
+
}
|
|
9627
|
+
const fromStartTime = getValueByPath(fromObject, ['startTime']);
|
|
9628
|
+
if (fromStartTime != null) {
|
|
9629
|
+
setValueByPath(toObject, ['startTime'], fromStartTime);
|
|
9630
|
+
}
|
|
9631
|
+
const fromEndTime = getValueByPath(fromObject, ['endTime']);
|
|
9632
|
+
if (fromEndTime != null) {
|
|
9633
|
+
setValueByPath(toObject, ['endTime'], fromEndTime);
|
|
9634
|
+
}
|
|
9635
|
+
const fromUpdateTime = getValueByPath(fromObject, ['updateTime']);
|
|
9636
|
+
if (fromUpdateTime != null) {
|
|
9637
|
+
setValueByPath(toObject, ['updateTime'], fromUpdateTime);
|
|
9638
|
+
}
|
|
9639
|
+
const fromError = getValueByPath(fromObject, ['error']);
|
|
9640
|
+
if (fromError != null) {
|
|
9641
|
+
setValueByPath(toObject, ['error'], fromError);
|
|
9642
|
+
}
|
|
9643
|
+
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
9644
|
+
if (fromDescription != null) {
|
|
9645
|
+
setValueByPath(toObject, ['description'], fromDescription);
|
|
9646
|
+
}
|
|
9647
|
+
const fromBaseModel = getValueByPath(fromObject, ['baseModel']);
|
|
9648
|
+
if (fromBaseModel != null) {
|
|
9649
|
+
setValueByPath(toObject, ['baseModel'], fromBaseModel);
|
|
9650
|
+
}
|
|
9651
|
+
const fromTunedModel = getValueByPath(fromObject, ['tunedModel']);
|
|
9652
|
+
if (fromTunedModel != null) {
|
|
9653
|
+
setValueByPath(toObject, ['tunedModel'], tunedModelFromVertex(apiClient, fromTunedModel));
|
|
9654
|
+
}
|
|
9655
|
+
const fromSupervisedTuningSpec = getValueByPath(fromObject, [
|
|
9656
|
+
'supervisedTuningSpec',
|
|
9657
|
+
]);
|
|
9658
|
+
if (fromSupervisedTuningSpec != null) {
|
|
9659
|
+
setValueByPath(toObject, ['supervisedTuningSpec'], fromSupervisedTuningSpec);
|
|
9660
|
+
}
|
|
9661
|
+
const fromTuningDataStats = getValueByPath(fromObject, [
|
|
9662
|
+
'tuningDataStats',
|
|
9663
|
+
]);
|
|
9664
|
+
if (fromTuningDataStats != null) {
|
|
9665
|
+
setValueByPath(toObject, ['tuningDataStats'], fromTuningDataStats);
|
|
9666
|
+
}
|
|
9667
|
+
const fromEncryptionSpec = getValueByPath(fromObject, [
|
|
9668
|
+
'encryptionSpec',
|
|
9669
|
+
]);
|
|
9670
|
+
if (fromEncryptionSpec != null) {
|
|
9671
|
+
setValueByPath(toObject, ['encryptionSpec'], fromEncryptionSpec);
|
|
9672
|
+
}
|
|
9673
|
+
const fromPartnerModelTuningSpec = getValueByPath(fromObject, [
|
|
9674
|
+
'partnerModelTuningSpec',
|
|
9675
|
+
]);
|
|
9676
|
+
if (fromPartnerModelTuningSpec != null) {
|
|
9677
|
+
setValueByPath(toObject, ['partnerModelTuningSpec'], fromPartnerModelTuningSpec);
|
|
9678
|
+
}
|
|
9679
|
+
const fromDistillationSpec = getValueByPath(fromObject, [
|
|
9680
|
+
'distillationSpec',
|
|
9681
|
+
]);
|
|
9682
|
+
if (fromDistillationSpec != null) {
|
|
9683
|
+
setValueByPath(toObject, ['distillationSpec'], fromDistillationSpec);
|
|
9684
|
+
}
|
|
9685
|
+
const fromExperiment = getValueByPath(fromObject, ['experiment']);
|
|
9686
|
+
if (fromExperiment != null) {
|
|
9687
|
+
setValueByPath(toObject, ['experiment'], fromExperiment);
|
|
9688
|
+
}
|
|
9689
|
+
const fromLabels = getValueByPath(fromObject, ['labels']);
|
|
9690
|
+
if (fromLabels != null) {
|
|
9691
|
+
setValueByPath(toObject, ['labels'], fromLabels);
|
|
9692
|
+
}
|
|
9693
|
+
const fromPipelineJob = getValueByPath(fromObject, ['pipelineJob']);
|
|
9694
|
+
if (fromPipelineJob != null) {
|
|
9695
|
+
setValueByPath(toObject, ['pipelineJob'], fromPipelineJob);
|
|
9696
|
+
}
|
|
9697
|
+
const fromTunedModelDisplayName = getValueByPath(fromObject, [
|
|
9698
|
+
'tunedModelDisplayName',
|
|
9699
|
+
]);
|
|
9700
|
+
if (fromTunedModelDisplayName != null) {
|
|
9701
|
+
setValueByPath(toObject, ['tunedModelDisplayName'], fromTunedModelDisplayName);
|
|
9702
|
+
}
|
|
9703
|
+
return toObject;
|
|
9704
|
+
}
|
|
9705
|
+
function listTuningJobsResponseFromVertex(apiClient, fromObject) {
|
|
9706
|
+
const toObject = {};
|
|
9707
|
+
const fromNextPageToken = getValueByPath(fromObject, [
|
|
9708
|
+
'nextPageToken',
|
|
9709
|
+
]);
|
|
9710
|
+
if (fromNextPageToken != null) {
|
|
9711
|
+
setValueByPath(toObject, ['nextPageToken'], fromNextPageToken);
|
|
9712
|
+
}
|
|
9713
|
+
const fromTuningJobs = getValueByPath(fromObject, ['tuningJobs']);
|
|
9714
|
+
if (fromTuningJobs != null) {
|
|
9715
|
+
let transformedList = fromTuningJobs;
|
|
9716
|
+
if (Array.isArray(transformedList)) {
|
|
9717
|
+
transformedList = transformedList.map((item) => {
|
|
9718
|
+
return tuningJobFromVertex(apiClient, item);
|
|
9719
|
+
});
|
|
9720
|
+
}
|
|
9721
|
+
setValueByPath(toObject, ['tuningJobs'], transformedList);
|
|
9722
|
+
}
|
|
9723
|
+
return toObject;
|
|
9724
|
+
}
|
|
9725
|
+
|
|
9726
|
+
/**
|
|
9727
|
+
* @license
|
|
9728
|
+
* Copyright 2025 Google LLC
|
|
9729
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
9730
|
+
*/
|
|
9731
|
+
class Tunings extends BaseModule {
|
|
9732
|
+
constructor(apiClient) {
|
|
9733
|
+
super();
|
|
9734
|
+
this.apiClient = apiClient;
|
|
9735
|
+
/**
|
|
9736
|
+
* Gets a TuningJob.
|
|
9737
|
+
*
|
|
9738
|
+
* @param name - The resource name of the tuning job.
|
|
9739
|
+
* @return - A TuningJob object.
|
|
9740
|
+
*
|
|
9741
|
+
* @experimental - The SDK's tuning implementation is experimental, and may
|
|
9742
|
+
* change in future versions.
|
|
9743
|
+
*/
|
|
9744
|
+
this.get = async (params) => {
|
|
9745
|
+
return await this.getInternal(params);
|
|
9746
|
+
};
|
|
9747
|
+
/**
|
|
9748
|
+
* Lists tuning jobs.
|
|
9749
|
+
*
|
|
9750
|
+
* @param config - The configuration for the list request.
|
|
9751
|
+
* @return - A list of tuning jobs.
|
|
9752
|
+
*
|
|
9753
|
+
* @experimental - The SDK's tuning implementation is experimental, and may
|
|
9754
|
+
* change in future versions.
|
|
9755
|
+
*/
|
|
9756
|
+
this.list = async (params = {}) => {
|
|
9757
|
+
return new Pager(exports.PagedItem.PAGED_ITEM_TUNING_JOBS, (x) => this.listInternal(x), await this.listInternal(params), params);
|
|
9758
|
+
};
|
|
9759
|
+
/**
|
|
9760
|
+
* Creates a supervised fine-tuning job.
|
|
9761
|
+
*
|
|
9762
|
+
* @param params - The parameters for the tuning job.
|
|
9763
|
+
* @return - A TuningJob operation.
|
|
9764
|
+
*
|
|
9765
|
+
* @experimental - The SDK's tuning implementation is experimental, and may
|
|
9766
|
+
* change in future versions.
|
|
9767
|
+
*/
|
|
9768
|
+
this.tune = async (params) => {
|
|
9769
|
+
if (this.apiClient.isVertexAI()) {
|
|
9770
|
+
return await this.tuneInternal(params);
|
|
9771
|
+
}
|
|
9772
|
+
else {
|
|
9773
|
+
const operation = await this.tuneMldevInternal(params);
|
|
9774
|
+
let tunedModelName = '';
|
|
9775
|
+
if (operation['metadata'] !== undefined &&
|
|
9776
|
+
operation['metadata']['tunedModel'] !== undefined) {
|
|
9777
|
+
tunedModelName = operation['metadata']['tunedModel'];
|
|
9778
|
+
}
|
|
9779
|
+
else if (operation['name'] !== undefined &&
|
|
9780
|
+
operation['name'].includes('/operations/')) {
|
|
9781
|
+
tunedModelName = operation['name'].split('/operations/')[0];
|
|
9782
|
+
}
|
|
9783
|
+
const tuningJob = {
|
|
9784
|
+
name: tunedModelName,
|
|
9785
|
+
state: exports.JobState.JOB_STATE_QUEUED,
|
|
9786
|
+
};
|
|
9787
|
+
return tuningJob;
|
|
9788
|
+
}
|
|
9789
|
+
};
|
|
9790
|
+
}
|
|
9791
|
+
async getInternal(params) {
|
|
9792
|
+
var _a, _b, _c, _d;
|
|
9793
|
+
let response;
|
|
9794
|
+
let path = '';
|
|
9795
|
+
let queryParams = {};
|
|
9796
|
+
if (this.apiClient.isVertexAI()) {
|
|
9797
|
+
const body = getTuningJobParametersToVertex(this.apiClient, params);
|
|
9798
|
+
path = formatMap('{name}', 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: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
9810
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
9811
|
+
})
|
|
9812
|
+
.then((httpResponse) => {
|
|
9813
|
+
return httpResponse.json();
|
|
9814
|
+
});
|
|
9815
|
+
return response.then((apiResponse) => {
|
|
9816
|
+
const resp = tuningJobFromVertex(this.apiClient, apiResponse);
|
|
9817
|
+
return resp;
|
|
9818
|
+
});
|
|
9819
|
+
}
|
|
9820
|
+
else {
|
|
9821
|
+
const body = getTuningJobParametersToMldev(this.apiClient, params);
|
|
9822
|
+
path = formatMap('{name}', body['_url']);
|
|
9823
|
+
queryParams = body['_query'];
|
|
9824
|
+
delete body['config'];
|
|
9825
|
+
delete body['_url'];
|
|
9826
|
+
delete body['_query'];
|
|
9827
|
+
response = this.apiClient
|
|
9828
|
+
.request({
|
|
9829
|
+
path: path,
|
|
9830
|
+
queryParams: queryParams,
|
|
9831
|
+
body: JSON.stringify(body),
|
|
9832
|
+
httpMethod: 'GET',
|
|
9833
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
9834
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
9835
|
+
})
|
|
9836
|
+
.then((httpResponse) => {
|
|
9837
|
+
return httpResponse.json();
|
|
9838
|
+
});
|
|
9839
|
+
return response.then((apiResponse) => {
|
|
9840
|
+
const resp = tuningJobFromMldev(this.apiClient, apiResponse);
|
|
9841
|
+
return resp;
|
|
9842
|
+
});
|
|
9843
|
+
}
|
|
9844
|
+
}
|
|
9845
|
+
async listInternal(params) {
|
|
9846
|
+
var _a, _b, _c, _d;
|
|
9847
|
+
let response;
|
|
9848
|
+
let path = '';
|
|
9849
|
+
let queryParams = {};
|
|
9850
|
+
if (this.apiClient.isVertexAI()) {
|
|
9851
|
+
const body = listTuningJobsParametersToVertex(this.apiClient, params);
|
|
9852
|
+
path = formatMap('tuningJobs', body['_url']);
|
|
9853
|
+
queryParams = body['_query'];
|
|
9854
|
+
delete body['config'];
|
|
9855
|
+
delete body['_url'];
|
|
9856
|
+
delete body['_query'];
|
|
9857
|
+
response = this.apiClient
|
|
9858
|
+
.request({
|
|
9859
|
+
path: path,
|
|
9860
|
+
queryParams: queryParams,
|
|
9861
|
+
body: JSON.stringify(body),
|
|
9862
|
+
httpMethod: 'GET',
|
|
9863
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
9864
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
9865
|
+
})
|
|
9866
|
+
.then((httpResponse) => {
|
|
9867
|
+
return httpResponse.json();
|
|
9868
|
+
});
|
|
9869
|
+
return response.then((apiResponse) => {
|
|
9870
|
+
const resp = listTuningJobsResponseFromVertex(this.apiClient, apiResponse);
|
|
9871
|
+
const typedResp = new ListTuningJobsResponse();
|
|
9872
|
+
Object.assign(typedResp, resp);
|
|
9873
|
+
return typedResp;
|
|
9874
|
+
});
|
|
9875
|
+
}
|
|
9876
|
+
else {
|
|
9877
|
+
const body = listTuningJobsParametersToMldev(this.apiClient, params);
|
|
9878
|
+
path = formatMap('tunedModels', body['_url']);
|
|
9879
|
+
queryParams = body['_query'];
|
|
9880
|
+
delete body['config'];
|
|
9881
|
+
delete body['_url'];
|
|
9882
|
+
delete body['_query'];
|
|
9883
|
+
response = this.apiClient
|
|
9884
|
+
.request({
|
|
9885
|
+
path: path,
|
|
9886
|
+
queryParams: queryParams,
|
|
9887
|
+
body: JSON.stringify(body),
|
|
9888
|
+
httpMethod: 'GET',
|
|
9889
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
9890
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
9891
|
+
})
|
|
9892
|
+
.then((httpResponse) => {
|
|
9893
|
+
return httpResponse.json();
|
|
9894
|
+
});
|
|
9895
|
+
return response.then((apiResponse) => {
|
|
9896
|
+
const resp = listTuningJobsResponseFromMldev(this.apiClient, apiResponse);
|
|
9897
|
+
const typedResp = new ListTuningJobsResponse();
|
|
9898
|
+
Object.assign(typedResp, resp);
|
|
9899
|
+
return typedResp;
|
|
9900
|
+
});
|
|
9901
|
+
}
|
|
9902
|
+
}
|
|
9903
|
+
async tuneInternal(params) {
|
|
9904
|
+
var _a, _b;
|
|
9905
|
+
let response;
|
|
9906
|
+
let path = '';
|
|
9907
|
+
let queryParams = {};
|
|
9908
|
+
if (this.apiClient.isVertexAI()) {
|
|
9909
|
+
const body = createTuningJobParametersToVertex(this.apiClient, params);
|
|
9910
|
+
path = formatMap('tuningJobs', body['_url']);
|
|
9911
|
+
queryParams = body['_query'];
|
|
9912
|
+
delete body['config'];
|
|
9913
|
+
delete body['_url'];
|
|
9914
|
+
delete body['_query'];
|
|
9915
|
+
response = this.apiClient
|
|
9916
|
+
.request({
|
|
9917
|
+
path: path,
|
|
9918
|
+
queryParams: queryParams,
|
|
9919
|
+
body: JSON.stringify(body),
|
|
9920
|
+
httpMethod: 'POST',
|
|
9921
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
9922
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
9923
|
+
})
|
|
9924
|
+
.then((httpResponse) => {
|
|
9925
|
+
return httpResponse.json();
|
|
9926
|
+
});
|
|
9927
|
+
return response.then((apiResponse) => {
|
|
9928
|
+
const resp = tuningJobFromVertex(this.apiClient, apiResponse);
|
|
9929
|
+
return resp;
|
|
9930
|
+
});
|
|
9931
|
+
}
|
|
9932
|
+
else {
|
|
9933
|
+
throw new Error('This method is only supported by the Vertex AI.');
|
|
9934
|
+
}
|
|
9935
|
+
}
|
|
9936
|
+
async tuneMldevInternal(params) {
|
|
9937
|
+
var _a, _b;
|
|
9938
|
+
let response;
|
|
9939
|
+
let path = '';
|
|
9940
|
+
let queryParams = {};
|
|
9941
|
+
if (this.apiClient.isVertexAI()) {
|
|
9942
|
+
throw new Error('This method is only supported by the Gemini Developer API.');
|
|
9943
|
+
}
|
|
9944
|
+
else {
|
|
9945
|
+
const body = createTuningJobParametersToMldev(this.apiClient, params);
|
|
9946
|
+
path = formatMap('tunedModels', body['_url']);
|
|
9947
|
+
queryParams = body['_query'];
|
|
9948
|
+
delete body['config'];
|
|
9949
|
+
delete body['_url'];
|
|
9950
|
+
delete body['_query'];
|
|
9951
|
+
response = this.apiClient
|
|
9952
|
+
.request({
|
|
9953
|
+
path: path,
|
|
9954
|
+
queryParams: queryParams,
|
|
9955
|
+
body: JSON.stringify(body),
|
|
9956
|
+
httpMethod: 'POST',
|
|
9957
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
9958
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
9959
|
+
})
|
|
9960
|
+
.then((httpResponse) => {
|
|
9961
|
+
return httpResponse.json();
|
|
9962
|
+
});
|
|
9963
|
+
return response.then((apiResponse) => {
|
|
9964
|
+
const resp = operationFromMldev(this.apiClient, apiResponse);
|
|
9965
|
+
return resp;
|
|
9966
|
+
});
|
|
9967
|
+
}
|
|
9968
|
+
}
|
|
9969
|
+
}
|
|
9970
|
+
|
|
9548
9971
|
const MAX_CHUNK_SIZE = 1024 * 1024 * 8; // bytes
|
|
9549
9972
|
async function uploadBlob(file, uploadUrl, apiClient) {
|
|
9550
9973
|
var _a, _b;
|
|
@@ -9890,6 +10313,7 @@ class GoogleGenAI {
|
|
|
9890
10313
|
this.caches = new Caches(this.apiClient);
|
|
9891
10314
|
this.files = new Files(this.apiClient);
|
|
9892
10315
|
this.operations = new Operations(this.apiClient);
|
|
10316
|
+
this.tunings = new Tunings(this.apiClient);
|
|
9893
10317
|
}
|
|
9894
10318
|
}
|
|
9895
10319
|
function getEnv(env) {
|
|
@@ -9914,6 +10338,7 @@ exports.CountTokensResponse = CountTokensResponse;
|
|
|
9914
10338
|
exports.CreateFileResponse = CreateFileResponse;
|
|
9915
10339
|
exports.DeleteCachedContentResponse = DeleteCachedContentResponse;
|
|
9916
10340
|
exports.DeleteFileResponse = DeleteFileResponse;
|
|
10341
|
+
exports.DeleteModelResponse = DeleteModelResponse;
|
|
9917
10342
|
exports.EmbedContentResponse = EmbedContentResponse;
|
|
9918
10343
|
exports.Files = Files;
|
|
9919
10344
|
exports.FunctionResponse = FunctionResponse;
|
|
@@ -9926,6 +10351,7 @@ exports.GoogleGenAI = GoogleGenAI;
|
|
|
9926
10351
|
exports.HttpResponse = HttpResponse;
|
|
9927
10352
|
exports.ListCachedContentsResponse = ListCachedContentsResponse;
|
|
9928
10353
|
exports.ListFilesResponse = ListFilesResponse;
|
|
10354
|
+
exports.ListTuningJobsResponse = ListTuningJobsResponse;
|
|
9929
10355
|
exports.Live = Live;
|
|
9930
10356
|
exports.LiveClientToolResponse = LiveClientToolResponse;
|
|
9931
10357
|
exports.LiveSendToolResponseParameters = LiveSendToolResponseParameters;
|