@google/genai 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/genai.d.ts +574 -39
- package/dist/index.js +1308 -894
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1307 -895
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.js +1308 -894
- package/dist/node/index.js.map +1 -1
- package/dist/node/node.d.ts +574 -39
- package/dist/web/index.mjs +1307 -895
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +574 -39
- package/package.json +1 -1
package/dist/web/index.mjs
CHANGED
|
@@ -498,6 +498,20 @@ function tCachedContentName(apiClient, name) {
|
|
|
498
498
|
}
|
|
499
499
|
return resourceName(apiClient, name, 'cachedContents');
|
|
500
500
|
}
|
|
501
|
+
function tTuningJobStatus(apiClient, status) {
|
|
502
|
+
switch (status) {
|
|
503
|
+
case 'STATE_UNSPECIFIED':
|
|
504
|
+
return 'JOB_STATE_UNSPECIFIED';
|
|
505
|
+
case 'CREATING':
|
|
506
|
+
return 'JOB_STATE_RUNNING';
|
|
507
|
+
case 'ACTIVE':
|
|
508
|
+
return 'JOB_STATE_SUCCEEDED';
|
|
509
|
+
case 'FAILED':
|
|
510
|
+
return 'JOB_STATE_FAILED';
|
|
511
|
+
default:
|
|
512
|
+
return status;
|
|
513
|
+
}
|
|
514
|
+
}
|
|
501
515
|
function tBytes(apiClient, fromImageBytes) {
|
|
502
516
|
if (typeof fromImageBytes !== 'string') {
|
|
503
517
|
throw new Error('fromImageBytes must be a string');
|
|
@@ -570,14 +584,13 @@ function contentToMldev$2(apiClient, fromObject) {
|
|
|
570
584
|
const toObject = {};
|
|
571
585
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
572
586
|
if (fromParts != null) {
|
|
573
|
-
|
|
574
|
-
|
|
587
|
+
let transformedList = fromParts;
|
|
588
|
+
if (Array.isArray(transformedList)) {
|
|
589
|
+
transformedList = transformedList.map((item) => {
|
|
575
590
|
return partToMldev$2(apiClient, item);
|
|
576
|
-
})
|
|
577
|
-
}
|
|
578
|
-
else {
|
|
579
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
591
|
+
});
|
|
580
592
|
}
|
|
593
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
581
594
|
}
|
|
582
595
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
583
596
|
if (fromRole != null) {
|
|
@@ -585,25 +598,6 @@ function contentToMldev$2(apiClient, fromObject) {
|
|
|
585
598
|
}
|
|
586
599
|
return toObject;
|
|
587
600
|
}
|
|
588
|
-
function functionDeclarationToMldev$2(apiClient, fromObject) {
|
|
589
|
-
const toObject = {};
|
|
590
|
-
if (getValueByPath(fromObject, ['response']) !== undefined) {
|
|
591
|
-
throw new Error('response parameter is not supported in Gemini API.');
|
|
592
|
-
}
|
|
593
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
594
|
-
if (fromDescription != null) {
|
|
595
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
596
|
-
}
|
|
597
|
-
const fromName = getValueByPath(fromObject, ['name']);
|
|
598
|
-
if (fromName != null) {
|
|
599
|
-
setValueByPath(toObject, ['name'], fromName);
|
|
600
|
-
}
|
|
601
|
-
const fromParameters = getValueByPath(fromObject, ['parameters']);
|
|
602
|
-
if (fromParameters != null) {
|
|
603
|
-
setValueByPath(toObject, ['parameters'], fromParameters);
|
|
604
|
-
}
|
|
605
|
-
return toObject;
|
|
606
|
-
}
|
|
607
601
|
function googleSearchToMldev$2() {
|
|
608
602
|
const toObject = {};
|
|
609
603
|
return toObject;
|
|
@@ -634,19 +628,6 @@ function googleSearchRetrievalToMldev$2(apiClient, fromObject) {
|
|
|
634
628
|
}
|
|
635
629
|
function toolToMldev$2(apiClient, fromObject) {
|
|
636
630
|
const toObject = {};
|
|
637
|
-
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
638
|
-
'functionDeclarations',
|
|
639
|
-
]);
|
|
640
|
-
if (fromFunctionDeclarations != null) {
|
|
641
|
-
if (Array.isArray(fromFunctionDeclarations)) {
|
|
642
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations.map((item) => {
|
|
643
|
-
return functionDeclarationToMldev$2(apiClient, item);
|
|
644
|
-
}));
|
|
645
|
-
}
|
|
646
|
-
else {
|
|
647
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
631
|
if (getValueByPath(fromObject, ['retrieval']) !== undefined) {
|
|
651
632
|
throw new Error('retrieval parameter is not supported in Gemini API.');
|
|
652
633
|
}
|
|
@@ -666,6 +647,12 @@ function toolToMldev$2(apiClient, fromObject) {
|
|
|
666
647
|
if (fromCodeExecution != null) {
|
|
667
648
|
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
668
649
|
}
|
|
650
|
+
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
651
|
+
'functionDeclarations',
|
|
652
|
+
]);
|
|
653
|
+
if (fromFunctionDeclarations != null) {
|
|
654
|
+
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
655
|
+
}
|
|
669
656
|
return toObject;
|
|
670
657
|
}
|
|
671
658
|
function functionCallingConfigToMldev$1(apiClient, fromObject) {
|
|
@@ -708,14 +695,13 @@ function createCachedContentConfigToMldev(apiClient, fromObject, parentObject) {
|
|
|
708
695
|
}
|
|
709
696
|
const fromContents = getValueByPath(fromObject, ['contents']);
|
|
710
697
|
if (parentObject !== undefined && fromContents != null) {
|
|
711
|
-
|
|
712
|
-
|
|
698
|
+
let transformedList = tContents(apiClient, fromContents);
|
|
699
|
+
if (Array.isArray(transformedList)) {
|
|
700
|
+
transformedList = transformedList.map((item) => {
|
|
713
701
|
return contentToMldev$2(apiClient, item);
|
|
714
|
-
})
|
|
715
|
-
}
|
|
716
|
-
else {
|
|
717
|
-
setValueByPath(parentObject, ['contents'], tContents(apiClient, fromContents));
|
|
702
|
+
});
|
|
718
703
|
}
|
|
704
|
+
setValueByPath(parentObject, ['contents'], transformedList);
|
|
719
705
|
}
|
|
720
706
|
const fromSystemInstruction = getValueByPath(fromObject, [
|
|
721
707
|
'systemInstruction',
|
|
@@ -725,14 +711,13 @@ function createCachedContentConfigToMldev(apiClient, fromObject, parentObject) {
|
|
|
725
711
|
}
|
|
726
712
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
727
713
|
if (parentObject !== undefined && fromTools != null) {
|
|
728
|
-
|
|
729
|
-
|
|
714
|
+
let transformedList = fromTools;
|
|
715
|
+
if (Array.isArray(transformedList)) {
|
|
716
|
+
transformedList = transformedList.map((item) => {
|
|
730
717
|
return toolToMldev$2(apiClient, item);
|
|
731
|
-
})
|
|
732
|
-
}
|
|
733
|
-
else {
|
|
734
|
-
setValueByPath(parentObject, ['tools'], fromTools);
|
|
718
|
+
});
|
|
735
719
|
}
|
|
720
|
+
setValueByPath(parentObject, ['tools'], transformedList);
|
|
736
721
|
}
|
|
737
722
|
const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
|
|
738
723
|
if (parentObject !== undefined && fromToolConfig != null) {
|
|
@@ -872,14 +857,13 @@ function contentToVertex$2(apiClient, fromObject) {
|
|
|
872
857
|
const toObject = {};
|
|
873
858
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
874
859
|
if (fromParts != null) {
|
|
875
|
-
|
|
876
|
-
|
|
860
|
+
let transformedList = fromParts;
|
|
861
|
+
if (Array.isArray(transformedList)) {
|
|
862
|
+
transformedList = transformedList.map((item) => {
|
|
877
863
|
return partToVertex$2(apiClient, item);
|
|
878
|
-
})
|
|
879
|
-
}
|
|
880
|
-
else {
|
|
881
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
864
|
+
});
|
|
882
865
|
}
|
|
866
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
883
867
|
}
|
|
884
868
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
885
869
|
if (fromRole != null) {
|
|
@@ -887,124 +871,6 @@ function contentToVertex$2(apiClient, fromObject) {
|
|
|
887
871
|
}
|
|
888
872
|
return toObject;
|
|
889
873
|
}
|
|
890
|
-
function schemaToVertex$2(apiClient, fromObject) {
|
|
891
|
-
const toObject = {};
|
|
892
|
-
const fromExample = getValueByPath(fromObject, ['example']);
|
|
893
|
-
if (fromExample != null) {
|
|
894
|
-
setValueByPath(toObject, ['example'], fromExample);
|
|
895
|
-
}
|
|
896
|
-
const fromPattern = getValueByPath(fromObject, ['pattern']);
|
|
897
|
-
if (fromPattern != null) {
|
|
898
|
-
setValueByPath(toObject, ['pattern'], fromPattern);
|
|
899
|
-
}
|
|
900
|
-
const fromDefault = getValueByPath(fromObject, ['default']);
|
|
901
|
-
if (fromDefault != null) {
|
|
902
|
-
setValueByPath(toObject, ['default'], fromDefault);
|
|
903
|
-
}
|
|
904
|
-
const fromMaxLength = getValueByPath(fromObject, ['maxLength']);
|
|
905
|
-
if (fromMaxLength != null) {
|
|
906
|
-
setValueByPath(toObject, ['maxLength'], fromMaxLength);
|
|
907
|
-
}
|
|
908
|
-
const fromMinLength = getValueByPath(fromObject, ['minLength']);
|
|
909
|
-
if (fromMinLength != null) {
|
|
910
|
-
setValueByPath(toObject, ['minLength'], fromMinLength);
|
|
911
|
-
}
|
|
912
|
-
const fromMinProperties = getValueByPath(fromObject, [
|
|
913
|
-
'minProperties',
|
|
914
|
-
]);
|
|
915
|
-
if (fromMinProperties != null) {
|
|
916
|
-
setValueByPath(toObject, ['minProperties'], fromMinProperties);
|
|
917
|
-
}
|
|
918
|
-
const fromMaxProperties = getValueByPath(fromObject, [
|
|
919
|
-
'maxProperties',
|
|
920
|
-
]);
|
|
921
|
-
if (fromMaxProperties != null) {
|
|
922
|
-
setValueByPath(toObject, ['maxProperties'], fromMaxProperties);
|
|
923
|
-
}
|
|
924
|
-
const fromAnyOf = getValueByPath(fromObject, ['anyOf']);
|
|
925
|
-
if (fromAnyOf != null) {
|
|
926
|
-
setValueByPath(toObject, ['anyOf'], fromAnyOf);
|
|
927
|
-
}
|
|
928
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
929
|
-
if (fromDescription != null) {
|
|
930
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
931
|
-
}
|
|
932
|
-
const fromEnum = getValueByPath(fromObject, ['enum']);
|
|
933
|
-
if (fromEnum != null) {
|
|
934
|
-
setValueByPath(toObject, ['enum'], fromEnum);
|
|
935
|
-
}
|
|
936
|
-
const fromFormat = getValueByPath(fromObject, ['format']);
|
|
937
|
-
if (fromFormat != null) {
|
|
938
|
-
setValueByPath(toObject, ['format'], fromFormat);
|
|
939
|
-
}
|
|
940
|
-
const fromItems = getValueByPath(fromObject, ['items']);
|
|
941
|
-
if (fromItems != null) {
|
|
942
|
-
setValueByPath(toObject, ['items'], fromItems);
|
|
943
|
-
}
|
|
944
|
-
const fromMaxItems = getValueByPath(fromObject, ['maxItems']);
|
|
945
|
-
if (fromMaxItems != null) {
|
|
946
|
-
setValueByPath(toObject, ['maxItems'], fromMaxItems);
|
|
947
|
-
}
|
|
948
|
-
const fromMaximum = getValueByPath(fromObject, ['maximum']);
|
|
949
|
-
if (fromMaximum != null) {
|
|
950
|
-
setValueByPath(toObject, ['maximum'], fromMaximum);
|
|
951
|
-
}
|
|
952
|
-
const fromMinItems = getValueByPath(fromObject, ['minItems']);
|
|
953
|
-
if (fromMinItems != null) {
|
|
954
|
-
setValueByPath(toObject, ['minItems'], fromMinItems);
|
|
955
|
-
}
|
|
956
|
-
const fromMinimum = getValueByPath(fromObject, ['minimum']);
|
|
957
|
-
if (fromMinimum != null) {
|
|
958
|
-
setValueByPath(toObject, ['minimum'], fromMinimum);
|
|
959
|
-
}
|
|
960
|
-
const fromNullable = getValueByPath(fromObject, ['nullable']);
|
|
961
|
-
if (fromNullable != null) {
|
|
962
|
-
setValueByPath(toObject, ['nullable'], fromNullable);
|
|
963
|
-
}
|
|
964
|
-
const fromProperties = getValueByPath(fromObject, ['properties']);
|
|
965
|
-
if (fromProperties != null) {
|
|
966
|
-
setValueByPath(toObject, ['properties'], fromProperties);
|
|
967
|
-
}
|
|
968
|
-
const fromPropertyOrdering = getValueByPath(fromObject, [
|
|
969
|
-
'propertyOrdering',
|
|
970
|
-
]);
|
|
971
|
-
if (fromPropertyOrdering != null) {
|
|
972
|
-
setValueByPath(toObject, ['propertyOrdering'], fromPropertyOrdering);
|
|
973
|
-
}
|
|
974
|
-
const fromRequired = getValueByPath(fromObject, ['required']);
|
|
975
|
-
if (fromRequired != null) {
|
|
976
|
-
setValueByPath(toObject, ['required'], fromRequired);
|
|
977
|
-
}
|
|
978
|
-
const fromTitle = getValueByPath(fromObject, ['title']);
|
|
979
|
-
if (fromTitle != null) {
|
|
980
|
-
setValueByPath(toObject, ['title'], fromTitle);
|
|
981
|
-
}
|
|
982
|
-
const fromType = getValueByPath(fromObject, ['type']);
|
|
983
|
-
if (fromType != null) {
|
|
984
|
-
setValueByPath(toObject, ['type'], fromType);
|
|
985
|
-
}
|
|
986
|
-
return toObject;
|
|
987
|
-
}
|
|
988
|
-
function functionDeclarationToVertex$2(apiClient, fromObject) {
|
|
989
|
-
const toObject = {};
|
|
990
|
-
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
991
|
-
if (fromResponse != null) {
|
|
992
|
-
setValueByPath(toObject, ['response'], schemaToVertex$2(apiClient, fromResponse));
|
|
993
|
-
}
|
|
994
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
995
|
-
if (fromDescription != null) {
|
|
996
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
997
|
-
}
|
|
998
|
-
const fromName = getValueByPath(fromObject, ['name']);
|
|
999
|
-
if (fromName != null) {
|
|
1000
|
-
setValueByPath(toObject, ['name'], fromName);
|
|
1001
|
-
}
|
|
1002
|
-
const fromParameters = getValueByPath(fromObject, ['parameters']);
|
|
1003
|
-
if (fromParameters != null) {
|
|
1004
|
-
setValueByPath(toObject, ['parameters'], fromParameters);
|
|
1005
|
-
}
|
|
1006
|
-
return toObject;
|
|
1007
|
-
}
|
|
1008
874
|
function googleSearchToVertex$2() {
|
|
1009
875
|
const toObject = {};
|
|
1010
876
|
return toObject;
|
|
@@ -1035,19 +901,6 @@ function googleSearchRetrievalToVertex$2(apiClient, fromObject) {
|
|
|
1035
901
|
}
|
|
1036
902
|
function toolToVertex$2(apiClient, fromObject) {
|
|
1037
903
|
const toObject = {};
|
|
1038
|
-
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
1039
|
-
'functionDeclarations',
|
|
1040
|
-
]);
|
|
1041
|
-
if (fromFunctionDeclarations != null) {
|
|
1042
|
-
if (Array.isArray(fromFunctionDeclarations)) {
|
|
1043
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations.map((item) => {
|
|
1044
|
-
return functionDeclarationToVertex$2(apiClient, item);
|
|
1045
|
-
}));
|
|
1046
|
-
}
|
|
1047
|
-
else {
|
|
1048
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
1049
|
-
}
|
|
1050
|
-
}
|
|
1051
904
|
const fromRetrieval = getValueByPath(fromObject, ['retrieval']);
|
|
1052
905
|
if (fromRetrieval != null) {
|
|
1053
906
|
setValueByPath(toObject, ['retrieval'], fromRetrieval);
|
|
@@ -1068,6 +921,12 @@ function toolToVertex$2(apiClient, fromObject) {
|
|
|
1068
921
|
if (fromCodeExecution != null) {
|
|
1069
922
|
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
1070
923
|
}
|
|
924
|
+
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
925
|
+
'functionDeclarations',
|
|
926
|
+
]);
|
|
927
|
+
if (fromFunctionDeclarations != null) {
|
|
928
|
+
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
929
|
+
}
|
|
1071
930
|
return toObject;
|
|
1072
931
|
}
|
|
1073
932
|
function functionCallingConfigToVertex$1(apiClient, fromObject) {
|
|
@@ -1110,14 +969,13 @@ function createCachedContentConfigToVertex(apiClient, fromObject, parentObject)
|
|
|
1110
969
|
}
|
|
1111
970
|
const fromContents = getValueByPath(fromObject, ['contents']);
|
|
1112
971
|
if (parentObject !== undefined && fromContents != null) {
|
|
1113
|
-
|
|
1114
|
-
|
|
972
|
+
let transformedList = tContents(apiClient, fromContents);
|
|
973
|
+
if (Array.isArray(transformedList)) {
|
|
974
|
+
transformedList = transformedList.map((item) => {
|
|
1115
975
|
return contentToVertex$2(apiClient, item);
|
|
1116
|
-
})
|
|
1117
|
-
}
|
|
1118
|
-
else {
|
|
1119
|
-
setValueByPath(parentObject, ['contents'], tContents(apiClient, fromContents));
|
|
976
|
+
});
|
|
1120
977
|
}
|
|
978
|
+
setValueByPath(parentObject, ['contents'], transformedList);
|
|
1121
979
|
}
|
|
1122
980
|
const fromSystemInstruction = getValueByPath(fromObject, [
|
|
1123
981
|
'systemInstruction',
|
|
@@ -1127,14 +985,13 @@ function createCachedContentConfigToVertex(apiClient, fromObject, parentObject)
|
|
|
1127
985
|
}
|
|
1128
986
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
1129
987
|
if (parentObject !== undefined && fromTools != null) {
|
|
1130
|
-
|
|
1131
|
-
|
|
988
|
+
let transformedList = fromTools;
|
|
989
|
+
if (Array.isArray(transformedList)) {
|
|
990
|
+
transformedList = transformedList.map((item) => {
|
|
1132
991
|
return toolToVertex$2(apiClient, item);
|
|
1133
|
-
})
|
|
1134
|
-
}
|
|
1135
|
-
else {
|
|
1136
|
-
setValueByPath(parentObject, ['tools'], fromTools);
|
|
992
|
+
});
|
|
1137
993
|
}
|
|
994
|
+
setValueByPath(parentObject, ['tools'], transformedList);
|
|
1138
995
|
}
|
|
1139
996
|
const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
|
|
1140
997
|
if (parentObject !== undefined && fromToolConfig != null) {
|
|
@@ -1272,14 +1129,13 @@ function listCachedContentsResponseFromMldev(apiClient, fromObject) {
|
|
|
1272
1129
|
'cachedContents',
|
|
1273
1130
|
]);
|
|
1274
1131
|
if (fromCachedContents != null) {
|
|
1275
|
-
|
|
1276
|
-
|
|
1132
|
+
let transformedList = fromCachedContents;
|
|
1133
|
+
if (Array.isArray(transformedList)) {
|
|
1134
|
+
transformedList = transformedList.map((item) => {
|
|
1277
1135
|
return cachedContentFromMldev(apiClient, item);
|
|
1278
|
-
})
|
|
1279
|
-
}
|
|
1280
|
-
else {
|
|
1281
|
-
setValueByPath(toObject, ['cachedContents'], fromCachedContents);
|
|
1136
|
+
});
|
|
1282
1137
|
}
|
|
1138
|
+
setValueByPath(toObject, ['cachedContents'], transformedList);
|
|
1283
1139
|
}
|
|
1284
1140
|
return toObject;
|
|
1285
1141
|
}
|
|
@@ -1333,14 +1189,13 @@ function listCachedContentsResponseFromVertex(apiClient, fromObject) {
|
|
|
1333
1189
|
'cachedContents',
|
|
1334
1190
|
]);
|
|
1335
1191
|
if (fromCachedContents != null) {
|
|
1336
|
-
|
|
1337
|
-
|
|
1192
|
+
let transformedList = fromCachedContents;
|
|
1193
|
+
if (Array.isArray(transformedList)) {
|
|
1194
|
+
transformedList = transformedList.map((item) => {
|
|
1338
1195
|
return cachedContentFromVertex(apiClient, item);
|
|
1339
|
-
})
|
|
1340
|
-
}
|
|
1341
|
-
else {
|
|
1342
|
-
setValueByPath(toObject, ['cachedContents'], fromCachedContents);
|
|
1196
|
+
});
|
|
1343
1197
|
}
|
|
1198
|
+
setValueByPath(toObject, ['cachedContents'], transformedList);
|
|
1344
1199
|
}
|
|
1345
1200
|
return toObject;
|
|
1346
1201
|
}
|
|
@@ -1542,17 +1397,6 @@ var Language;
|
|
|
1542
1397
|
Language["LANGUAGE_UNSPECIFIED"] = "LANGUAGE_UNSPECIFIED";
|
|
1543
1398
|
Language["PYTHON"] = "PYTHON";
|
|
1544
1399
|
})(Language || (Language = {}));
|
|
1545
|
-
/** Optional. The type of the data. */
|
|
1546
|
-
var Type;
|
|
1547
|
-
(function (Type) {
|
|
1548
|
-
Type["TYPE_UNSPECIFIED"] = "TYPE_UNSPECIFIED";
|
|
1549
|
-
Type["STRING"] = "STRING";
|
|
1550
|
-
Type["NUMBER"] = "NUMBER";
|
|
1551
|
-
Type["INTEGER"] = "INTEGER";
|
|
1552
|
-
Type["BOOLEAN"] = "BOOLEAN";
|
|
1553
|
-
Type["ARRAY"] = "ARRAY";
|
|
1554
|
-
Type["OBJECT"] = "OBJECT";
|
|
1555
|
-
})(Type || (Type = {}));
|
|
1556
1400
|
/** Required. Harm category. */
|
|
1557
1401
|
var HarmCategory;
|
|
1558
1402
|
(function (HarmCategory) {
|
|
@@ -1586,6 +1430,17 @@ var Mode;
|
|
|
1586
1430
|
Mode["MODE_UNSPECIFIED"] = "MODE_UNSPECIFIED";
|
|
1587
1431
|
Mode["MODE_DYNAMIC"] = "MODE_DYNAMIC";
|
|
1588
1432
|
})(Mode || (Mode = {}));
|
|
1433
|
+
/** Optional. The type of the data. */
|
|
1434
|
+
var Type;
|
|
1435
|
+
(function (Type) {
|
|
1436
|
+
Type["TYPE_UNSPECIFIED"] = "TYPE_UNSPECIFIED";
|
|
1437
|
+
Type["STRING"] = "STRING";
|
|
1438
|
+
Type["NUMBER"] = "NUMBER";
|
|
1439
|
+
Type["INTEGER"] = "INTEGER";
|
|
1440
|
+
Type["BOOLEAN"] = "BOOLEAN";
|
|
1441
|
+
Type["ARRAY"] = "ARRAY";
|
|
1442
|
+
Type["OBJECT"] = "OBJECT";
|
|
1443
|
+
})(Type || (Type = {}));
|
|
1589
1444
|
/** Output only. The reason why the model stopped generating tokens.
|
|
1590
1445
|
|
|
1591
1446
|
If empty, the model has not stopped generating the tokens.
|
|
@@ -1655,6 +1510,33 @@ var MediaResolution;
|
|
|
1655
1510
|
MediaResolution["MEDIA_RESOLUTION_MEDIUM"] = "MEDIA_RESOLUTION_MEDIUM";
|
|
1656
1511
|
MediaResolution["MEDIA_RESOLUTION_HIGH"] = "MEDIA_RESOLUTION_HIGH";
|
|
1657
1512
|
})(MediaResolution || (MediaResolution = {}));
|
|
1513
|
+
/** Output only. The detailed state of the job. */
|
|
1514
|
+
var JobState;
|
|
1515
|
+
(function (JobState) {
|
|
1516
|
+
JobState["JOB_STATE_UNSPECIFIED"] = "JOB_STATE_UNSPECIFIED";
|
|
1517
|
+
JobState["JOB_STATE_QUEUED"] = "JOB_STATE_QUEUED";
|
|
1518
|
+
JobState["JOB_STATE_PENDING"] = "JOB_STATE_PENDING";
|
|
1519
|
+
JobState["JOB_STATE_RUNNING"] = "JOB_STATE_RUNNING";
|
|
1520
|
+
JobState["JOB_STATE_SUCCEEDED"] = "JOB_STATE_SUCCEEDED";
|
|
1521
|
+
JobState["JOB_STATE_FAILED"] = "JOB_STATE_FAILED";
|
|
1522
|
+
JobState["JOB_STATE_CANCELLING"] = "JOB_STATE_CANCELLING";
|
|
1523
|
+
JobState["JOB_STATE_CANCELLED"] = "JOB_STATE_CANCELLED";
|
|
1524
|
+
JobState["JOB_STATE_PAUSED"] = "JOB_STATE_PAUSED";
|
|
1525
|
+
JobState["JOB_STATE_EXPIRED"] = "JOB_STATE_EXPIRED";
|
|
1526
|
+
JobState["JOB_STATE_UPDATING"] = "JOB_STATE_UPDATING";
|
|
1527
|
+
JobState["JOB_STATE_PARTIALLY_SUCCEEDED"] = "JOB_STATE_PARTIALLY_SUCCEEDED";
|
|
1528
|
+
})(JobState || (JobState = {}));
|
|
1529
|
+
/** Optional. Adapter size for tuning. */
|
|
1530
|
+
var AdapterSize;
|
|
1531
|
+
(function (AdapterSize) {
|
|
1532
|
+
AdapterSize["ADAPTER_SIZE_UNSPECIFIED"] = "ADAPTER_SIZE_UNSPECIFIED";
|
|
1533
|
+
AdapterSize["ADAPTER_SIZE_ONE"] = "ADAPTER_SIZE_ONE";
|
|
1534
|
+
AdapterSize["ADAPTER_SIZE_TWO"] = "ADAPTER_SIZE_TWO";
|
|
1535
|
+
AdapterSize["ADAPTER_SIZE_FOUR"] = "ADAPTER_SIZE_FOUR";
|
|
1536
|
+
AdapterSize["ADAPTER_SIZE_EIGHT"] = "ADAPTER_SIZE_EIGHT";
|
|
1537
|
+
AdapterSize["ADAPTER_SIZE_SIXTEEN"] = "ADAPTER_SIZE_SIXTEEN";
|
|
1538
|
+
AdapterSize["ADAPTER_SIZE_THIRTY_TWO"] = "ADAPTER_SIZE_THIRTY_TWO";
|
|
1539
|
+
})(AdapterSize || (AdapterSize = {}));
|
|
1658
1540
|
/** Options for feature selection preference. */
|
|
1659
1541
|
var FeatureSelectionPreference;
|
|
1660
1542
|
(function (FeatureSelectionPreference) {
|
|
@@ -2155,6 +2037,8 @@ class EmbedContentResponse {
|
|
|
2155
2037
|
/** The output images response. */
|
|
2156
2038
|
class GenerateImagesResponse {
|
|
2157
2039
|
}
|
|
2040
|
+
class DeleteModelResponse {
|
|
2041
|
+
}
|
|
2158
2042
|
/** Response for counting tokens. */
|
|
2159
2043
|
class CountTokensResponse {
|
|
2160
2044
|
}
|
|
@@ -2164,6 +2048,9 @@ class ComputeTokensResponse {
|
|
|
2164
2048
|
/** Response with generated videos. */
|
|
2165
2049
|
class GenerateVideosResponse {
|
|
2166
2050
|
}
|
|
2051
|
+
/** Response for the list tuning jobs method. */
|
|
2052
|
+
class ListTuningJobsResponse {
|
|
2053
|
+
}
|
|
2167
2054
|
/** Empty response for caches.delete method. */
|
|
2168
2055
|
class DeleteCachedContentResponse {
|
|
2169
2056
|
}
|
|
@@ -2260,7 +2147,7 @@ class Caches extends BaseModule {
|
|
|
2260
2147
|
* ```ts
|
|
2261
2148
|
* const contents = ...; // Initialize the content to cache.
|
|
2262
2149
|
* const response = await ai.caches.create({
|
|
2263
|
-
* model: 'gemini-
|
|
2150
|
+
* model: 'gemini-2.0-flash-001',
|
|
2264
2151
|
* config: {
|
|
2265
2152
|
* 'contents': contents,
|
|
2266
2153
|
* 'displayName': 'test cache',
|
|
@@ -2332,7 +2219,7 @@ class Caches extends BaseModule {
|
|
|
2332
2219
|
*
|
|
2333
2220
|
* @example
|
|
2334
2221
|
* ```ts
|
|
2335
|
-
* await ai.caches.get({name: '
|
|
2222
|
+
* await ai.caches.get({name: '...'}); // The server-generated resource name.
|
|
2336
2223
|
* ```
|
|
2337
2224
|
*/
|
|
2338
2225
|
async get(params) {
|
|
@@ -2397,7 +2284,7 @@ class Caches extends BaseModule {
|
|
|
2397
2284
|
*
|
|
2398
2285
|
* @example
|
|
2399
2286
|
* ```ts
|
|
2400
|
-
* await ai.caches.delete({name: '
|
|
2287
|
+
* await ai.caches.delete({name: '...'}); // The server-generated resource name.
|
|
2401
2288
|
* ```
|
|
2402
2289
|
*/
|
|
2403
2290
|
async delete(params) {
|
|
@@ -2467,7 +2354,7 @@ class Caches extends BaseModule {
|
|
|
2467
2354
|
* @example
|
|
2468
2355
|
* ```ts
|
|
2469
2356
|
* const response = await ai.caches.update({
|
|
2470
|
-
* name: '
|
|
2357
|
+
* name: '...', // The server-generated resource name.
|
|
2471
2358
|
* config: {'ttl': '7600s'}
|
|
2472
2359
|
* });
|
|
2473
2360
|
* ```
|
|
@@ -2865,7 +2752,12 @@ class Chat {
|
|
|
2865
2752
|
contents: this.getHistory(true).concat(inputContent),
|
|
2866
2753
|
config: (_a = params.config) !== null && _a !== void 0 ? _a : this.config,
|
|
2867
2754
|
});
|
|
2868
|
-
|
|
2755
|
+
// Resolve the internal tracking of send completion promise - `sendPromise`
|
|
2756
|
+
// for both success and failure response. The actual failure is still
|
|
2757
|
+
// propagated by the `await streamResponse`.
|
|
2758
|
+
this.sendPromise = streamResponse
|
|
2759
|
+
.then(() => undefined)
|
|
2760
|
+
.catch(() => undefined);
|
|
2869
2761
|
const response = await streamResponse;
|
|
2870
2762
|
const result = this.processStreamResponse(response, inputContent);
|
|
2871
2763
|
return result;
|
|
@@ -3175,14 +3067,13 @@ function listFilesResponseFromMldev(apiClient, fromObject) {
|
|
|
3175
3067
|
}
|
|
3176
3068
|
const fromFiles = getValueByPath(fromObject, ['files']);
|
|
3177
3069
|
if (fromFiles != null) {
|
|
3178
|
-
|
|
3179
|
-
|
|
3070
|
+
let transformedList = fromFiles;
|
|
3071
|
+
if (Array.isArray(transformedList)) {
|
|
3072
|
+
transformedList = transformedList.map((item) => {
|
|
3180
3073
|
return fileFromMldev(apiClient, item);
|
|
3181
|
-
})
|
|
3182
|
-
}
|
|
3183
|
-
else {
|
|
3184
|
-
setValueByPath(toObject, ['files'], fromFiles);
|
|
3074
|
+
});
|
|
3185
3075
|
}
|
|
3076
|
+
setValueByPath(toObject, ['files'], transformedList);
|
|
3186
3077
|
}
|
|
3187
3078
|
return toObject;
|
|
3188
3079
|
}
|
|
@@ -3549,14 +3440,13 @@ function contentToMldev$1(apiClient, fromObject) {
|
|
|
3549
3440
|
const toObject = {};
|
|
3550
3441
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
3551
3442
|
if (fromParts != null) {
|
|
3552
|
-
|
|
3553
|
-
|
|
3443
|
+
let transformedList = fromParts;
|
|
3444
|
+
if (Array.isArray(transformedList)) {
|
|
3445
|
+
transformedList = transformedList.map((item) => {
|
|
3554
3446
|
return partToMldev$1(apiClient, item);
|
|
3555
|
-
})
|
|
3556
|
-
}
|
|
3557
|
-
else {
|
|
3558
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
3447
|
+
});
|
|
3559
3448
|
}
|
|
3449
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
3560
3450
|
}
|
|
3561
3451
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
3562
3452
|
if (fromRole != null) {
|
|
@@ -3568,14 +3458,13 @@ function contentToVertex$1(apiClient, fromObject) {
|
|
|
3568
3458
|
const toObject = {};
|
|
3569
3459
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
3570
3460
|
if (fromParts != null) {
|
|
3571
|
-
|
|
3572
|
-
|
|
3461
|
+
let transformedList = fromParts;
|
|
3462
|
+
if (Array.isArray(transformedList)) {
|
|
3463
|
+
transformedList = transformedList.map((item) => {
|
|
3573
3464
|
return partToVertex$1(apiClient, item);
|
|
3574
|
-
})
|
|
3575
|
-
}
|
|
3576
|
-
else {
|
|
3577
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
3465
|
+
});
|
|
3578
3466
|
}
|
|
3467
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
3579
3468
|
}
|
|
3580
3469
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
3581
3470
|
if (fromRole != null) {
|
|
@@ -3583,143 +3472,6 @@ function contentToVertex$1(apiClient, fromObject) {
|
|
|
3583
3472
|
}
|
|
3584
3473
|
return toObject;
|
|
3585
3474
|
}
|
|
3586
|
-
function schemaToVertex$1(apiClient, fromObject) {
|
|
3587
|
-
const toObject = {};
|
|
3588
|
-
const fromExample = getValueByPath(fromObject, ['example']);
|
|
3589
|
-
if (fromExample != null) {
|
|
3590
|
-
setValueByPath(toObject, ['example'], fromExample);
|
|
3591
|
-
}
|
|
3592
|
-
const fromPattern = getValueByPath(fromObject, ['pattern']);
|
|
3593
|
-
if (fromPattern != null) {
|
|
3594
|
-
setValueByPath(toObject, ['pattern'], fromPattern);
|
|
3595
|
-
}
|
|
3596
|
-
const fromDefault = getValueByPath(fromObject, ['default']);
|
|
3597
|
-
if (fromDefault != null) {
|
|
3598
|
-
setValueByPath(toObject, ['default'], fromDefault);
|
|
3599
|
-
}
|
|
3600
|
-
const fromMaxLength = getValueByPath(fromObject, ['maxLength']);
|
|
3601
|
-
if (fromMaxLength != null) {
|
|
3602
|
-
setValueByPath(toObject, ['maxLength'], fromMaxLength);
|
|
3603
|
-
}
|
|
3604
|
-
const fromMinLength = getValueByPath(fromObject, ['minLength']);
|
|
3605
|
-
if (fromMinLength != null) {
|
|
3606
|
-
setValueByPath(toObject, ['minLength'], fromMinLength);
|
|
3607
|
-
}
|
|
3608
|
-
const fromMinProperties = getValueByPath(fromObject, [
|
|
3609
|
-
'minProperties',
|
|
3610
|
-
]);
|
|
3611
|
-
if (fromMinProperties != null) {
|
|
3612
|
-
setValueByPath(toObject, ['minProperties'], fromMinProperties);
|
|
3613
|
-
}
|
|
3614
|
-
const fromMaxProperties = getValueByPath(fromObject, [
|
|
3615
|
-
'maxProperties',
|
|
3616
|
-
]);
|
|
3617
|
-
if (fromMaxProperties != null) {
|
|
3618
|
-
setValueByPath(toObject, ['maxProperties'], fromMaxProperties);
|
|
3619
|
-
}
|
|
3620
|
-
const fromAnyOf = getValueByPath(fromObject, ['anyOf']);
|
|
3621
|
-
if (fromAnyOf != null) {
|
|
3622
|
-
setValueByPath(toObject, ['anyOf'], fromAnyOf);
|
|
3623
|
-
}
|
|
3624
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
3625
|
-
if (fromDescription != null) {
|
|
3626
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
3627
|
-
}
|
|
3628
|
-
const fromEnum = getValueByPath(fromObject, ['enum']);
|
|
3629
|
-
if (fromEnum != null) {
|
|
3630
|
-
setValueByPath(toObject, ['enum'], fromEnum);
|
|
3631
|
-
}
|
|
3632
|
-
const fromFormat = getValueByPath(fromObject, ['format']);
|
|
3633
|
-
if (fromFormat != null) {
|
|
3634
|
-
setValueByPath(toObject, ['format'], fromFormat);
|
|
3635
|
-
}
|
|
3636
|
-
const fromItems = getValueByPath(fromObject, ['items']);
|
|
3637
|
-
if (fromItems != null) {
|
|
3638
|
-
setValueByPath(toObject, ['items'], fromItems);
|
|
3639
|
-
}
|
|
3640
|
-
const fromMaxItems = getValueByPath(fromObject, ['maxItems']);
|
|
3641
|
-
if (fromMaxItems != null) {
|
|
3642
|
-
setValueByPath(toObject, ['maxItems'], fromMaxItems);
|
|
3643
|
-
}
|
|
3644
|
-
const fromMaximum = getValueByPath(fromObject, ['maximum']);
|
|
3645
|
-
if (fromMaximum != null) {
|
|
3646
|
-
setValueByPath(toObject, ['maximum'], fromMaximum);
|
|
3647
|
-
}
|
|
3648
|
-
const fromMinItems = getValueByPath(fromObject, ['minItems']);
|
|
3649
|
-
if (fromMinItems != null) {
|
|
3650
|
-
setValueByPath(toObject, ['minItems'], fromMinItems);
|
|
3651
|
-
}
|
|
3652
|
-
const fromMinimum = getValueByPath(fromObject, ['minimum']);
|
|
3653
|
-
if (fromMinimum != null) {
|
|
3654
|
-
setValueByPath(toObject, ['minimum'], fromMinimum);
|
|
3655
|
-
}
|
|
3656
|
-
const fromNullable = getValueByPath(fromObject, ['nullable']);
|
|
3657
|
-
if (fromNullable != null) {
|
|
3658
|
-
setValueByPath(toObject, ['nullable'], fromNullable);
|
|
3659
|
-
}
|
|
3660
|
-
const fromProperties = getValueByPath(fromObject, ['properties']);
|
|
3661
|
-
if (fromProperties != null) {
|
|
3662
|
-
setValueByPath(toObject, ['properties'], fromProperties);
|
|
3663
|
-
}
|
|
3664
|
-
const fromPropertyOrdering = getValueByPath(fromObject, [
|
|
3665
|
-
'propertyOrdering',
|
|
3666
|
-
]);
|
|
3667
|
-
if (fromPropertyOrdering != null) {
|
|
3668
|
-
setValueByPath(toObject, ['propertyOrdering'], fromPropertyOrdering);
|
|
3669
|
-
}
|
|
3670
|
-
const fromRequired = getValueByPath(fromObject, ['required']);
|
|
3671
|
-
if (fromRequired != null) {
|
|
3672
|
-
setValueByPath(toObject, ['required'], fromRequired);
|
|
3673
|
-
}
|
|
3674
|
-
const fromTitle = getValueByPath(fromObject, ['title']);
|
|
3675
|
-
if (fromTitle != null) {
|
|
3676
|
-
setValueByPath(toObject, ['title'], fromTitle);
|
|
3677
|
-
}
|
|
3678
|
-
const fromType = getValueByPath(fromObject, ['type']);
|
|
3679
|
-
if (fromType != null) {
|
|
3680
|
-
setValueByPath(toObject, ['type'], fromType);
|
|
3681
|
-
}
|
|
3682
|
-
return toObject;
|
|
3683
|
-
}
|
|
3684
|
-
function functionDeclarationToMldev$1(apiClient, fromObject) {
|
|
3685
|
-
const toObject = {};
|
|
3686
|
-
if (getValueByPath(fromObject, ['response']) !== undefined) {
|
|
3687
|
-
throw new Error('response parameter is not supported in Gemini API.');
|
|
3688
|
-
}
|
|
3689
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
3690
|
-
if (fromDescription != null) {
|
|
3691
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
3692
|
-
}
|
|
3693
|
-
const fromName = getValueByPath(fromObject, ['name']);
|
|
3694
|
-
if (fromName != null) {
|
|
3695
|
-
setValueByPath(toObject, ['name'], fromName);
|
|
3696
|
-
}
|
|
3697
|
-
const fromParameters = getValueByPath(fromObject, ['parameters']);
|
|
3698
|
-
if (fromParameters != null) {
|
|
3699
|
-
setValueByPath(toObject, ['parameters'], fromParameters);
|
|
3700
|
-
}
|
|
3701
|
-
return toObject;
|
|
3702
|
-
}
|
|
3703
|
-
function functionDeclarationToVertex$1(apiClient, fromObject) {
|
|
3704
|
-
const toObject = {};
|
|
3705
|
-
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
3706
|
-
if (fromResponse != null) {
|
|
3707
|
-
setValueByPath(toObject, ['response'], schemaToVertex$1(apiClient, fromResponse));
|
|
3708
|
-
}
|
|
3709
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
3710
|
-
if (fromDescription != null) {
|
|
3711
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
3712
|
-
}
|
|
3713
|
-
const fromName = getValueByPath(fromObject, ['name']);
|
|
3714
|
-
if (fromName != null) {
|
|
3715
|
-
setValueByPath(toObject, ['name'], fromName);
|
|
3716
|
-
}
|
|
3717
|
-
const fromParameters = getValueByPath(fromObject, ['parameters']);
|
|
3718
|
-
if (fromParameters != null) {
|
|
3719
|
-
setValueByPath(toObject, ['parameters'], fromParameters);
|
|
3720
|
-
}
|
|
3721
|
-
return toObject;
|
|
3722
|
-
}
|
|
3723
3475
|
function googleSearchToMldev$1() {
|
|
3724
3476
|
const toObject = {};
|
|
3725
3477
|
return toObject;
|
|
@@ -3778,19 +3530,6 @@ function googleSearchRetrievalToVertex$1(apiClient, fromObject) {
|
|
|
3778
3530
|
}
|
|
3779
3531
|
function toolToMldev$1(apiClient, fromObject) {
|
|
3780
3532
|
const toObject = {};
|
|
3781
|
-
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
3782
|
-
'functionDeclarations',
|
|
3783
|
-
]);
|
|
3784
|
-
if (fromFunctionDeclarations != null) {
|
|
3785
|
-
if (Array.isArray(fromFunctionDeclarations)) {
|
|
3786
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations.map((item) => {
|
|
3787
|
-
return functionDeclarationToMldev$1(apiClient, item);
|
|
3788
|
-
}));
|
|
3789
|
-
}
|
|
3790
|
-
else {
|
|
3791
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
3792
|
-
}
|
|
3793
|
-
}
|
|
3794
3533
|
if (getValueByPath(fromObject, ['retrieval']) !== undefined) {
|
|
3795
3534
|
throw new Error('retrieval parameter is not supported in Gemini API.');
|
|
3796
3535
|
}
|
|
@@ -3810,23 +3549,16 @@ function toolToMldev$1(apiClient, fromObject) {
|
|
|
3810
3549
|
if (fromCodeExecution != null) {
|
|
3811
3550
|
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
3812
3551
|
}
|
|
3813
|
-
return toObject;
|
|
3814
|
-
}
|
|
3815
|
-
function toolToVertex$1(apiClient, fromObject) {
|
|
3816
|
-
const toObject = {};
|
|
3817
3552
|
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
3818
3553
|
'functionDeclarations',
|
|
3819
3554
|
]);
|
|
3820
3555
|
if (fromFunctionDeclarations != null) {
|
|
3821
|
-
|
|
3822
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations.map((item) => {
|
|
3823
|
-
return functionDeclarationToVertex$1(apiClient, item);
|
|
3824
|
-
}));
|
|
3825
|
-
}
|
|
3826
|
-
else {
|
|
3827
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
3828
|
-
}
|
|
3556
|
+
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
3829
3557
|
}
|
|
3558
|
+
return toObject;
|
|
3559
|
+
}
|
|
3560
|
+
function toolToVertex$1(apiClient, fromObject) {
|
|
3561
|
+
const toObject = {};
|
|
3830
3562
|
const fromRetrieval = getValueByPath(fromObject, ['retrieval']);
|
|
3831
3563
|
if (fromRetrieval != null) {
|
|
3832
3564
|
setValueByPath(toObject, ['retrieval'], fromRetrieval);
|
|
@@ -3847,6 +3579,12 @@ function toolToVertex$1(apiClient, fromObject) {
|
|
|
3847
3579
|
if (fromCodeExecution != null) {
|
|
3848
3580
|
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
3849
3581
|
}
|
|
3582
|
+
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
3583
|
+
'functionDeclarations',
|
|
3584
|
+
]);
|
|
3585
|
+
if (fromFunctionDeclarations != null) {
|
|
3586
|
+
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
3587
|
+
}
|
|
3850
3588
|
return toObject;
|
|
3851
3589
|
}
|
|
3852
3590
|
function sessionResumptionConfigToMldev(apiClient, fromObject) {
|
|
@@ -4086,14 +3824,13 @@ function liveConnectConfigToMldev(apiClient, fromObject, parentObject) {
|
|
|
4086
3824
|
}
|
|
4087
3825
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
4088
3826
|
if (parentObject !== undefined && fromTools != null) {
|
|
4089
|
-
|
|
4090
|
-
|
|
3827
|
+
let transformedList = tTools(apiClient, fromTools);
|
|
3828
|
+
if (Array.isArray(transformedList)) {
|
|
3829
|
+
transformedList = transformedList.map((item) => {
|
|
4091
3830
|
return toolToMldev$1(apiClient, tTool(apiClient, item));
|
|
4092
|
-
})
|
|
4093
|
-
}
|
|
4094
|
-
else {
|
|
4095
|
-
setValueByPath(parentObject, ['setup', 'tools'], tTools(apiClient, fromTools));
|
|
3831
|
+
});
|
|
4096
3832
|
}
|
|
3833
|
+
setValueByPath(parentObject, ['setup', 'tools'], transformedList);
|
|
4097
3834
|
}
|
|
4098
3835
|
const fromSessionResumption = getValueByPath(fromObject, [
|
|
4099
3836
|
'sessionResumption',
|
|
@@ -4178,14 +3915,13 @@ function liveConnectConfigToVertex(apiClient, fromObject, parentObject) {
|
|
|
4178
3915
|
}
|
|
4179
3916
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
4180
3917
|
if (parentObject !== undefined && fromTools != null) {
|
|
4181
|
-
|
|
4182
|
-
|
|
3918
|
+
let transformedList = tTools(apiClient, fromTools);
|
|
3919
|
+
if (Array.isArray(transformedList)) {
|
|
3920
|
+
transformedList = transformedList.map((item) => {
|
|
4183
3921
|
return toolToVertex$1(apiClient, tTool(apiClient, item));
|
|
4184
|
-
})
|
|
4185
|
-
}
|
|
4186
|
-
else {
|
|
4187
|
-
setValueByPath(parentObject, ['setup', 'tools'], tTools(apiClient, fromTools));
|
|
3922
|
+
});
|
|
4188
3923
|
}
|
|
3924
|
+
setValueByPath(parentObject, ['setup', 'tools'], transformedList);
|
|
4189
3925
|
}
|
|
4190
3926
|
const fromSessionResumption = getValueByPath(fromObject, [
|
|
4191
3927
|
'sessionResumption',
|
|
@@ -4430,14 +4166,13 @@ function contentFromMldev$1(apiClient, fromObject) {
|
|
|
4430
4166
|
const toObject = {};
|
|
4431
4167
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
4432
4168
|
if (fromParts != null) {
|
|
4433
|
-
|
|
4434
|
-
|
|
4169
|
+
let transformedList = fromParts;
|
|
4170
|
+
if (Array.isArray(transformedList)) {
|
|
4171
|
+
transformedList = transformedList.map((item) => {
|
|
4435
4172
|
return partFromMldev$1(apiClient, item);
|
|
4436
|
-
})
|
|
4437
|
-
}
|
|
4438
|
-
else {
|
|
4439
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
4173
|
+
});
|
|
4440
4174
|
}
|
|
4175
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
4441
4176
|
}
|
|
4442
4177
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
4443
4178
|
if (fromRole != null) {
|
|
@@ -4449,14 +4184,13 @@ function contentFromVertex$1(apiClient, fromObject) {
|
|
|
4449
4184
|
const toObject = {};
|
|
4450
4185
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
4451
4186
|
if (fromParts != null) {
|
|
4452
|
-
|
|
4453
|
-
|
|
4187
|
+
let transformedList = fromParts;
|
|
4188
|
+
if (Array.isArray(transformedList)) {
|
|
4189
|
+
transformedList = transformedList.map((item) => {
|
|
4454
4190
|
return partFromVertex$1(apiClient, item);
|
|
4455
|
-
})
|
|
4456
|
-
}
|
|
4457
|
-
else {
|
|
4458
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
4191
|
+
});
|
|
4459
4192
|
}
|
|
4193
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
4460
4194
|
}
|
|
4461
4195
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
4462
4196
|
if (fromRole != null) {
|
|
@@ -4590,14 +4324,13 @@ function liveServerToolCallFromMldev(apiClient, fromObject) {
|
|
|
4590
4324
|
'functionCalls',
|
|
4591
4325
|
]);
|
|
4592
4326
|
if (fromFunctionCalls != null) {
|
|
4593
|
-
|
|
4594
|
-
|
|
4327
|
+
let transformedList = fromFunctionCalls;
|
|
4328
|
+
if (Array.isArray(transformedList)) {
|
|
4329
|
+
transformedList = transformedList.map((item) => {
|
|
4595
4330
|
return functionCallFromMldev(apiClient, item);
|
|
4596
|
-
})
|
|
4597
|
-
}
|
|
4598
|
-
else {
|
|
4599
|
-
setValueByPath(toObject, ['functionCalls'], fromFunctionCalls);
|
|
4331
|
+
});
|
|
4600
4332
|
}
|
|
4333
|
+
setValueByPath(toObject, ['functionCalls'], transformedList);
|
|
4601
4334
|
}
|
|
4602
4335
|
return toObject;
|
|
4603
4336
|
}
|
|
@@ -4607,14 +4340,13 @@ function liveServerToolCallFromVertex(apiClient, fromObject) {
|
|
|
4607
4340
|
'functionCalls',
|
|
4608
4341
|
]);
|
|
4609
4342
|
if (fromFunctionCalls != null) {
|
|
4610
|
-
|
|
4611
|
-
|
|
4343
|
+
let transformedList = fromFunctionCalls;
|
|
4344
|
+
if (Array.isArray(transformedList)) {
|
|
4345
|
+
transformedList = transformedList.map((item) => {
|
|
4612
4346
|
return functionCallFromVertex(apiClient, item);
|
|
4613
|
-
})
|
|
4614
|
-
}
|
|
4615
|
-
else {
|
|
4616
|
-
setValueByPath(toObject, ['functionCalls'], fromFunctionCalls);
|
|
4347
|
+
});
|
|
4617
4348
|
}
|
|
4349
|
+
setValueByPath(toObject, ['functionCalls'], transformedList);
|
|
4618
4350
|
}
|
|
4619
4351
|
return toObject;
|
|
4620
4352
|
}
|
|
@@ -4700,53 +4432,49 @@ function usageMetadataFromMldev(apiClient, fromObject) {
|
|
|
4700
4432
|
'promptTokensDetails',
|
|
4701
4433
|
]);
|
|
4702
4434
|
if (fromPromptTokensDetails != null) {
|
|
4703
|
-
|
|
4704
|
-
|
|
4435
|
+
let transformedList = fromPromptTokensDetails;
|
|
4436
|
+
if (Array.isArray(transformedList)) {
|
|
4437
|
+
transformedList = transformedList.map((item) => {
|
|
4705
4438
|
return modalityTokenCountFromMldev(apiClient, item);
|
|
4706
|
-
})
|
|
4707
|
-
}
|
|
4708
|
-
else {
|
|
4709
|
-
setValueByPath(toObject, ['promptTokensDetails'], fromPromptTokensDetails);
|
|
4439
|
+
});
|
|
4710
4440
|
}
|
|
4441
|
+
setValueByPath(toObject, ['promptTokensDetails'], transformedList);
|
|
4711
4442
|
}
|
|
4712
4443
|
const fromCacheTokensDetails = getValueByPath(fromObject, [
|
|
4713
4444
|
'cacheTokensDetails',
|
|
4714
4445
|
]);
|
|
4715
4446
|
if (fromCacheTokensDetails != null) {
|
|
4716
|
-
|
|
4717
|
-
|
|
4447
|
+
let transformedList = fromCacheTokensDetails;
|
|
4448
|
+
if (Array.isArray(transformedList)) {
|
|
4449
|
+
transformedList = transformedList.map((item) => {
|
|
4718
4450
|
return modalityTokenCountFromMldev(apiClient, item);
|
|
4719
|
-
})
|
|
4720
|
-
}
|
|
4721
|
-
else {
|
|
4722
|
-
setValueByPath(toObject, ['cacheTokensDetails'], fromCacheTokensDetails);
|
|
4451
|
+
});
|
|
4723
4452
|
}
|
|
4453
|
+
setValueByPath(toObject, ['cacheTokensDetails'], transformedList);
|
|
4724
4454
|
}
|
|
4725
4455
|
const fromResponseTokensDetails = getValueByPath(fromObject, [
|
|
4726
4456
|
'responseTokensDetails',
|
|
4727
4457
|
]);
|
|
4728
4458
|
if (fromResponseTokensDetails != null) {
|
|
4729
|
-
|
|
4730
|
-
|
|
4459
|
+
let transformedList = fromResponseTokensDetails;
|
|
4460
|
+
if (Array.isArray(transformedList)) {
|
|
4461
|
+
transformedList = transformedList.map((item) => {
|
|
4731
4462
|
return modalityTokenCountFromMldev(apiClient, item);
|
|
4732
|
-
})
|
|
4733
|
-
}
|
|
4734
|
-
else {
|
|
4735
|
-
setValueByPath(toObject, ['responseTokensDetails'], fromResponseTokensDetails);
|
|
4463
|
+
});
|
|
4736
4464
|
}
|
|
4465
|
+
setValueByPath(toObject, ['responseTokensDetails'], transformedList);
|
|
4737
4466
|
}
|
|
4738
4467
|
const fromToolUsePromptTokensDetails = getValueByPath(fromObject, [
|
|
4739
4468
|
'toolUsePromptTokensDetails',
|
|
4740
4469
|
]);
|
|
4741
4470
|
if (fromToolUsePromptTokensDetails != null) {
|
|
4742
|
-
|
|
4743
|
-
|
|
4471
|
+
let transformedList = fromToolUsePromptTokensDetails;
|
|
4472
|
+
if (Array.isArray(transformedList)) {
|
|
4473
|
+
transformedList = transformedList.map((item) => {
|
|
4744
4474
|
return modalityTokenCountFromMldev(apiClient, item);
|
|
4745
|
-
})
|
|
4746
|
-
}
|
|
4747
|
-
else {
|
|
4748
|
-
setValueByPath(toObject, ['toolUsePromptTokensDetails'], fromToolUsePromptTokensDetails);
|
|
4475
|
+
});
|
|
4749
4476
|
}
|
|
4477
|
+
setValueByPath(toObject, ['toolUsePromptTokensDetails'], transformedList);
|
|
4750
4478
|
}
|
|
4751
4479
|
return toObject;
|
|
4752
4480
|
}
|
|
@@ -4792,53 +4520,49 @@ function usageMetadataFromVertex(apiClient, fromObject) {
|
|
|
4792
4520
|
'promptTokensDetails',
|
|
4793
4521
|
]);
|
|
4794
4522
|
if (fromPromptTokensDetails != null) {
|
|
4795
|
-
|
|
4796
|
-
|
|
4523
|
+
let transformedList = fromPromptTokensDetails;
|
|
4524
|
+
if (Array.isArray(transformedList)) {
|
|
4525
|
+
transformedList = transformedList.map((item) => {
|
|
4797
4526
|
return modalityTokenCountFromVertex(apiClient, item);
|
|
4798
|
-
})
|
|
4799
|
-
}
|
|
4800
|
-
else {
|
|
4801
|
-
setValueByPath(toObject, ['promptTokensDetails'], fromPromptTokensDetails);
|
|
4527
|
+
});
|
|
4802
4528
|
}
|
|
4529
|
+
setValueByPath(toObject, ['promptTokensDetails'], transformedList);
|
|
4803
4530
|
}
|
|
4804
4531
|
const fromCacheTokensDetails = getValueByPath(fromObject, [
|
|
4805
4532
|
'cacheTokensDetails',
|
|
4806
4533
|
]);
|
|
4807
4534
|
if (fromCacheTokensDetails != null) {
|
|
4808
|
-
|
|
4809
|
-
|
|
4535
|
+
let transformedList = fromCacheTokensDetails;
|
|
4536
|
+
if (Array.isArray(transformedList)) {
|
|
4537
|
+
transformedList = transformedList.map((item) => {
|
|
4810
4538
|
return modalityTokenCountFromVertex(apiClient, item);
|
|
4811
|
-
})
|
|
4812
|
-
}
|
|
4813
|
-
else {
|
|
4814
|
-
setValueByPath(toObject, ['cacheTokensDetails'], fromCacheTokensDetails);
|
|
4539
|
+
});
|
|
4815
4540
|
}
|
|
4541
|
+
setValueByPath(toObject, ['cacheTokensDetails'], transformedList);
|
|
4816
4542
|
}
|
|
4817
4543
|
const fromResponseTokensDetails = getValueByPath(fromObject, [
|
|
4818
4544
|
'candidatesTokensDetails',
|
|
4819
4545
|
]);
|
|
4820
4546
|
if (fromResponseTokensDetails != null) {
|
|
4821
|
-
|
|
4822
|
-
|
|
4547
|
+
let transformedList = fromResponseTokensDetails;
|
|
4548
|
+
if (Array.isArray(transformedList)) {
|
|
4549
|
+
transformedList = transformedList.map((item) => {
|
|
4823
4550
|
return modalityTokenCountFromVertex(apiClient, item);
|
|
4824
|
-
})
|
|
4825
|
-
}
|
|
4826
|
-
else {
|
|
4827
|
-
setValueByPath(toObject, ['responseTokensDetails'], fromResponseTokensDetails);
|
|
4551
|
+
});
|
|
4828
4552
|
}
|
|
4553
|
+
setValueByPath(toObject, ['responseTokensDetails'], transformedList);
|
|
4829
4554
|
}
|
|
4830
4555
|
const fromToolUsePromptTokensDetails = getValueByPath(fromObject, [
|
|
4831
4556
|
'toolUsePromptTokensDetails',
|
|
4832
4557
|
]);
|
|
4833
4558
|
if (fromToolUsePromptTokensDetails != null) {
|
|
4834
|
-
|
|
4835
|
-
|
|
4559
|
+
let transformedList = fromToolUsePromptTokensDetails;
|
|
4560
|
+
if (Array.isArray(transformedList)) {
|
|
4561
|
+
transformedList = transformedList.map((item) => {
|
|
4836
4562
|
return modalityTokenCountFromVertex(apiClient, item);
|
|
4837
|
-
})
|
|
4838
|
-
}
|
|
4839
|
-
else {
|
|
4840
|
-
setValueByPath(toObject, ['toolUsePromptTokensDetails'], fromToolUsePromptTokensDetails);
|
|
4563
|
+
});
|
|
4841
4564
|
}
|
|
4565
|
+
setValueByPath(toObject, ['toolUsePromptTokensDetails'], transformedList);
|
|
4842
4566
|
}
|
|
4843
4567
|
const fromTrafficType = getValueByPath(fromObject, ['trafficType']);
|
|
4844
4568
|
if (fromTrafficType != null) {
|
|
@@ -5037,14 +4761,13 @@ function contentToMldev(apiClient, fromObject) {
|
|
|
5037
4761
|
const toObject = {};
|
|
5038
4762
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
5039
4763
|
if (fromParts != null) {
|
|
5040
|
-
|
|
5041
|
-
|
|
4764
|
+
let transformedList = fromParts;
|
|
4765
|
+
if (Array.isArray(transformedList)) {
|
|
4766
|
+
transformedList = transformedList.map((item) => {
|
|
5042
4767
|
return partToMldev(apiClient, item);
|
|
5043
|
-
})
|
|
5044
|
-
}
|
|
5045
|
-
else {
|
|
5046
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
4768
|
+
});
|
|
5047
4769
|
}
|
|
4770
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
5048
4771
|
}
|
|
5049
4772
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
5050
4773
|
if (fromRole != null) {
|
|
@@ -5052,93 +4775,6 @@ function contentToMldev(apiClient, fromObject) {
|
|
|
5052
4775
|
}
|
|
5053
4776
|
return toObject;
|
|
5054
4777
|
}
|
|
5055
|
-
function schemaToMldev(apiClient, fromObject) {
|
|
5056
|
-
const toObject = {};
|
|
5057
|
-
if (getValueByPath(fromObject, ['example']) !== undefined) {
|
|
5058
|
-
throw new Error('example parameter is not supported in Gemini API.');
|
|
5059
|
-
}
|
|
5060
|
-
if (getValueByPath(fromObject, ['pattern']) !== undefined) {
|
|
5061
|
-
throw new Error('pattern parameter is not supported in Gemini API.');
|
|
5062
|
-
}
|
|
5063
|
-
if (getValueByPath(fromObject, ['default']) !== undefined) {
|
|
5064
|
-
throw new Error('default parameter is not supported in Gemini API.');
|
|
5065
|
-
}
|
|
5066
|
-
if (getValueByPath(fromObject, ['maxLength']) !== undefined) {
|
|
5067
|
-
throw new Error('maxLength parameter is not supported in Gemini API.');
|
|
5068
|
-
}
|
|
5069
|
-
if (getValueByPath(fromObject, ['minLength']) !== undefined) {
|
|
5070
|
-
throw new Error('minLength parameter is not supported in Gemini API.');
|
|
5071
|
-
}
|
|
5072
|
-
if (getValueByPath(fromObject, ['minProperties']) !== undefined) {
|
|
5073
|
-
throw new Error('minProperties parameter is not supported in Gemini API.');
|
|
5074
|
-
}
|
|
5075
|
-
if (getValueByPath(fromObject, ['maxProperties']) !== undefined) {
|
|
5076
|
-
throw new Error('maxProperties parameter is not supported in Gemini API.');
|
|
5077
|
-
}
|
|
5078
|
-
const fromAnyOf = getValueByPath(fromObject, ['anyOf']);
|
|
5079
|
-
if (fromAnyOf != null) {
|
|
5080
|
-
setValueByPath(toObject, ['anyOf'], fromAnyOf);
|
|
5081
|
-
}
|
|
5082
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
5083
|
-
if (fromDescription != null) {
|
|
5084
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
5085
|
-
}
|
|
5086
|
-
const fromEnum = getValueByPath(fromObject, ['enum']);
|
|
5087
|
-
if (fromEnum != null) {
|
|
5088
|
-
setValueByPath(toObject, ['enum'], fromEnum);
|
|
5089
|
-
}
|
|
5090
|
-
const fromFormat = getValueByPath(fromObject, ['format']);
|
|
5091
|
-
if (fromFormat != null) {
|
|
5092
|
-
setValueByPath(toObject, ['format'], fromFormat);
|
|
5093
|
-
}
|
|
5094
|
-
const fromItems = getValueByPath(fromObject, ['items']);
|
|
5095
|
-
if (fromItems != null) {
|
|
5096
|
-
setValueByPath(toObject, ['items'], fromItems);
|
|
5097
|
-
}
|
|
5098
|
-
const fromMaxItems = getValueByPath(fromObject, ['maxItems']);
|
|
5099
|
-
if (fromMaxItems != null) {
|
|
5100
|
-
setValueByPath(toObject, ['maxItems'], fromMaxItems);
|
|
5101
|
-
}
|
|
5102
|
-
const fromMaximum = getValueByPath(fromObject, ['maximum']);
|
|
5103
|
-
if (fromMaximum != null) {
|
|
5104
|
-
setValueByPath(toObject, ['maximum'], fromMaximum);
|
|
5105
|
-
}
|
|
5106
|
-
const fromMinItems = getValueByPath(fromObject, ['minItems']);
|
|
5107
|
-
if (fromMinItems != null) {
|
|
5108
|
-
setValueByPath(toObject, ['minItems'], fromMinItems);
|
|
5109
|
-
}
|
|
5110
|
-
const fromMinimum = getValueByPath(fromObject, ['minimum']);
|
|
5111
|
-
if (fromMinimum != null) {
|
|
5112
|
-
setValueByPath(toObject, ['minimum'], fromMinimum);
|
|
5113
|
-
}
|
|
5114
|
-
const fromNullable = getValueByPath(fromObject, ['nullable']);
|
|
5115
|
-
if (fromNullable != null) {
|
|
5116
|
-
setValueByPath(toObject, ['nullable'], fromNullable);
|
|
5117
|
-
}
|
|
5118
|
-
const fromProperties = getValueByPath(fromObject, ['properties']);
|
|
5119
|
-
if (fromProperties != null) {
|
|
5120
|
-
setValueByPath(toObject, ['properties'], fromProperties);
|
|
5121
|
-
}
|
|
5122
|
-
const fromPropertyOrdering = getValueByPath(fromObject, [
|
|
5123
|
-
'propertyOrdering',
|
|
5124
|
-
]);
|
|
5125
|
-
if (fromPropertyOrdering != null) {
|
|
5126
|
-
setValueByPath(toObject, ['propertyOrdering'], fromPropertyOrdering);
|
|
5127
|
-
}
|
|
5128
|
-
const fromRequired = getValueByPath(fromObject, ['required']);
|
|
5129
|
-
if (fromRequired != null) {
|
|
5130
|
-
setValueByPath(toObject, ['required'], fromRequired);
|
|
5131
|
-
}
|
|
5132
|
-
const fromTitle = getValueByPath(fromObject, ['title']);
|
|
5133
|
-
if (fromTitle != null) {
|
|
5134
|
-
setValueByPath(toObject, ['title'], fromTitle);
|
|
5135
|
-
}
|
|
5136
|
-
const fromType = getValueByPath(fromObject, ['type']);
|
|
5137
|
-
if (fromType != null) {
|
|
5138
|
-
setValueByPath(toObject, ['type'], fromType);
|
|
5139
|
-
}
|
|
5140
|
-
return toObject;
|
|
5141
|
-
}
|
|
5142
4778
|
function safetySettingToMldev(apiClient, fromObject) {
|
|
5143
4779
|
const toObject = {};
|
|
5144
4780
|
if (getValueByPath(fromObject, ['method']) !== undefined) {
|
|
@@ -5154,25 +4790,6 @@ function safetySettingToMldev(apiClient, fromObject) {
|
|
|
5154
4790
|
}
|
|
5155
4791
|
return toObject;
|
|
5156
4792
|
}
|
|
5157
|
-
function functionDeclarationToMldev(apiClient, fromObject) {
|
|
5158
|
-
const toObject = {};
|
|
5159
|
-
if (getValueByPath(fromObject, ['response']) !== undefined) {
|
|
5160
|
-
throw new Error('response parameter is not supported in Gemini API.');
|
|
5161
|
-
}
|
|
5162
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
5163
|
-
if (fromDescription != null) {
|
|
5164
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
5165
|
-
}
|
|
5166
|
-
const fromName = getValueByPath(fromObject, ['name']);
|
|
5167
|
-
if (fromName != null) {
|
|
5168
|
-
setValueByPath(toObject, ['name'], fromName);
|
|
5169
|
-
}
|
|
5170
|
-
const fromParameters = getValueByPath(fromObject, ['parameters']);
|
|
5171
|
-
if (fromParameters != null) {
|
|
5172
|
-
setValueByPath(toObject, ['parameters'], fromParameters);
|
|
5173
|
-
}
|
|
5174
|
-
return toObject;
|
|
5175
|
-
}
|
|
5176
4793
|
function googleSearchToMldev() {
|
|
5177
4794
|
const toObject = {};
|
|
5178
4795
|
return toObject;
|
|
@@ -5203,19 +4820,6 @@ function googleSearchRetrievalToMldev(apiClient, fromObject) {
|
|
|
5203
4820
|
}
|
|
5204
4821
|
function toolToMldev(apiClient, fromObject) {
|
|
5205
4822
|
const toObject = {};
|
|
5206
|
-
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
5207
|
-
'functionDeclarations',
|
|
5208
|
-
]);
|
|
5209
|
-
if (fromFunctionDeclarations != null) {
|
|
5210
|
-
if (Array.isArray(fromFunctionDeclarations)) {
|
|
5211
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations.map((item) => {
|
|
5212
|
-
return functionDeclarationToMldev(apiClient, item);
|
|
5213
|
-
}));
|
|
5214
|
-
}
|
|
5215
|
-
else {
|
|
5216
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
5217
|
-
}
|
|
5218
|
-
}
|
|
5219
4823
|
if (getValueByPath(fromObject, ['retrieval']) !== undefined) {
|
|
5220
4824
|
throw new Error('retrieval parameter is not supported in Gemini API.');
|
|
5221
4825
|
}
|
|
@@ -5235,6 +4839,12 @@ function toolToMldev(apiClient, fromObject) {
|
|
|
5235
4839
|
if (fromCodeExecution != null) {
|
|
5236
4840
|
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
5237
4841
|
}
|
|
4842
|
+
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
4843
|
+
'functionDeclarations',
|
|
4844
|
+
]);
|
|
4845
|
+
if (fromFunctionDeclarations != null) {
|
|
4846
|
+
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
4847
|
+
}
|
|
5238
4848
|
return toObject;
|
|
5239
4849
|
}
|
|
5240
4850
|
function functionCallingConfigToMldev(apiClient, fromObject) {
|
|
@@ -5381,7 +4991,7 @@ function generateContentConfigToMldev(apiClient, fromObject, parentObject) {
|
|
|
5381
4991
|
'responseSchema',
|
|
5382
4992
|
]);
|
|
5383
4993
|
if (fromResponseSchema != null) {
|
|
5384
|
-
setValueByPath(toObject, ['responseSchema'],
|
|
4994
|
+
setValueByPath(toObject, ['responseSchema'], tSchema(apiClient, fromResponseSchema));
|
|
5385
4995
|
}
|
|
5386
4996
|
if (getValueByPath(fromObject, ['routingConfig']) !== undefined) {
|
|
5387
4997
|
throw new Error('routingConfig parameter is not supported in Gemini API.');
|
|
@@ -5393,25 +5003,23 @@ function generateContentConfigToMldev(apiClient, fromObject, parentObject) {
|
|
|
5393
5003
|
'safetySettings',
|
|
5394
5004
|
]);
|
|
5395
5005
|
if (parentObject !== undefined && fromSafetySettings != null) {
|
|
5396
|
-
|
|
5397
|
-
|
|
5006
|
+
let transformedList = fromSafetySettings;
|
|
5007
|
+
if (Array.isArray(transformedList)) {
|
|
5008
|
+
transformedList = transformedList.map((item) => {
|
|
5398
5009
|
return safetySettingToMldev(apiClient, item);
|
|
5399
|
-
})
|
|
5400
|
-
}
|
|
5401
|
-
else {
|
|
5402
|
-
setValueByPath(parentObject, ['safetySettings'], fromSafetySettings);
|
|
5010
|
+
});
|
|
5403
5011
|
}
|
|
5012
|
+
setValueByPath(parentObject, ['safetySettings'], transformedList);
|
|
5404
5013
|
}
|
|
5405
5014
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
5406
5015
|
if (parentObject !== undefined && fromTools != null) {
|
|
5407
|
-
|
|
5408
|
-
|
|
5016
|
+
let transformedList = tTools(apiClient, fromTools);
|
|
5017
|
+
if (Array.isArray(transformedList)) {
|
|
5018
|
+
transformedList = transformedList.map((item) => {
|
|
5409
5019
|
return toolToMldev(apiClient, tTool(apiClient, item));
|
|
5410
|
-
})
|
|
5411
|
-
}
|
|
5412
|
-
else {
|
|
5413
|
-
setValueByPath(parentObject, ['tools'], tTools(apiClient, fromTools));
|
|
5020
|
+
});
|
|
5414
5021
|
}
|
|
5022
|
+
setValueByPath(parentObject, ['tools'], transformedList);
|
|
5415
5023
|
}
|
|
5416
5024
|
const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
|
|
5417
5025
|
if (parentObject !== undefined && fromToolConfig != null) {
|
|
@@ -5461,14 +5069,13 @@ function generateContentParametersToMldev(apiClient, fromObject) {
|
|
|
5461
5069
|
}
|
|
5462
5070
|
const fromContents = getValueByPath(fromObject, ['contents']);
|
|
5463
5071
|
if (fromContents != null) {
|
|
5464
|
-
|
|
5465
|
-
|
|
5072
|
+
let transformedList = tContents(apiClient, fromContents);
|
|
5073
|
+
if (Array.isArray(transformedList)) {
|
|
5074
|
+
transformedList = transformedList.map((item) => {
|
|
5466
5075
|
return contentToMldev(apiClient, item);
|
|
5467
|
-
})
|
|
5468
|
-
}
|
|
5469
|
-
else {
|
|
5470
|
-
setValueByPath(toObject, ['contents'], tContents(apiClient, fromContents));
|
|
5076
|
+
});
|
|
5471
5077
|
}
|
|
5078
|
+
setValueByPath(toObject, ['contents'], transformedList);
|
|
5472
5079
|
}
|
|
5473
5080
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
5474
5081
|
if (fromConfig != null) {
|
|
@@ -5623,6 +5230,42 @@ function getModelParametersToMldev(apiClient, fromObject) {
|
|
|
5623
5230
|
}
|
|
5624
5231
|
return toObject;
|
|
5625
5232
|
}
|
|
5233
|
+
function updateModelConfigToMldev(apiClient, fromObject, parentObject) {
|
|
5234
|
+
const toObject = {};
|
|
5235
|
+
const fromDisplayName = getValueByPath(fromObject, ['displayName']);
|
|
5236
|
+
if (parentObject !== undefined && fromDisplayName != null) {
|
|
5237
|
+
setValueByPath(parentObject, ['displayName'], fromDisplayName);
|
|
5238
|
+
}
|
|
5239
|
+
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
5240
|
+
if (parentObject !== undefined && fromDescription != null) {
|
|
5241
|
+
setValueByPath(parentObject, ['description'], fromDescription);
|
|
5242
|
+
}
|
|
5243
|
+
return toObject;
|
|
5244
|
+
}
|
|
5245
|
+
function updateModelParametersToMldev(apiClient, fromObject) {
|
|
5246
|
+
const toObject = {};
|
|
5247
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
5248
|
+
if (fromModel != null) {
|
|
5249
|
+
setValueByPath(toObject, ['_url', 'name'], tModel(apiClient, fromModel));
|
|
5250
|
+
}
|
|
5251
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
5252
|
+
if (fromConfig != null) {
|
|
5253
|
+
setValueByPath(toObject, ['config'], updateModelConfigToMldev(apiClient, fromConfig, toObject));
|
|
5254
|
+
}
|
|
5255
|
+
return toObject;
|
|
5256
|
+
}
|
|
5257
|
+
function deleteModelParametersToMldev(apiClient, fromObject) {
|
|
5258
|
+
const toObject = {};
|
|
5259
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
5260
|
+
if (fromModel != null) {
|
|
5261
|
+
setValueByPath(toObject, ['_url', 'name'], tModel(apiClient, fromModel));
|
|
5262
|
+
}
|
|
5263
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
5264
|
+
if (fromConfig != null) {
|
|
5265
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
5266
|
+
}
|
|
5267
|
+
return toObject;
|
|
5268
|
+
}
|
|
5626
5269
|
function countTokensConfigToMldev(apiClient, fromObject) {
|
|
5627
5270
|
const toObject = {};
|
|
5628
5271
|
if (getValueByPath(fromObject, ['systemInstruction']) !== undefined) {
|
|
@@ -5644,14 +5287,13 @@ function countTokensParametersToMldev(apiClient, fromObject) {
|
|
|
5644
5287
|
}
|
|
5645
5288
|
const fromContents = getValueByPath(fromObject, ['contents']);
|
|
5646
5289
|
if (fromContents != null) {
|
|
5647
|
-
|
|
5648
|
-
|
|
5290
|
+
let transformedList = tContents(apiClient, fromContents);
|
|
5291
|
+
if (Array.isArray(transformedList)) {
|
|
5292
|
+
transformedList = transformedList.map((item) => {
|
|
5649
5293
|
return contentToMldev(apiClient, item);
|
|
5650
|
-
})
|
|
5651
|
-
}
|
|
5652
|
-
else {
|
|
5653
|
-
setValueByPath(toObject, ['contents'], tContents(apiClient, fromContents));
|
|
5294
|
+
});
|
|
5654
5295
|
}
|
|
5296
|
+
setValueByPath(toObject, ['contents'], transformedList);
|
|
5655
5297
|
}
|
|
5656
5298
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
5657
5299
|
if (fromConfig != null) {
|
|
@@ -5796,14 +5438,13 @@ function contentToVertex(apiClient, fromObject) {
|
|
|
5796
5438
|
const toObject = {};
|
|
5797
5439
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
5798
5440
|
if (fromParts != null) {
|
|
5799
|
-
|
|
5800
|
-
|
|
5441
|
+
let transformedList = fromParts;
|
|
5442
|
+
if (Array.isArray(transformedList)) {
|
|
5443
|
+
transformedList = transformedList.map((item) => {
|
|
5801
5444
|
return partToVertex(apiClient, item);
|
|
5802
|
-
})
|
|
5803
|
-
}
|
|
5804
|
-
else {
|
|
5805
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
5445
|
+
});
|
|
5806
5446
|
}
|
|
5447
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
5807
5448
|
}
|
|
5808
5449
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
5809
5450
|
if (fromRole != null) {
|
|
@@ -5811,104 +5452,6 @@ function contentToVertex(apiClient, fromObject) {
|
|
|
5811
5452
|
}
|
|
5812
5453
|
return toObject;
|
|
5813
5454
|
}
|
|
5814
|
-
function schemaToVertex(apiClient, fromObject) {
|
|
5815
|
-
const toObject = {};
|
|
5816
|
-
const fromExample = getValueByPath(fromObject, ['example']);
|
|
5817
|
-
if (fromExample != null) {
|
|
5818
|
-
setValueByPath(toObject, ['example'], fromExample);
|
|
5819
|
-
}
|
|
5820
|
-
const fromPattern = getValueByPath(fromObject, ['pattern']);
|
|
5821
|
-
if (fromPattern != null) {
|
|
5822
|
-
setValueByPath(toObject, ['pattern'], fromPattern);
|
|
5823
|
-
}
|
|
5824
|
-
const fromDefault = getValueByPath(fromObject, ['default']);
|
|
5825
|
-
if (fromDefault != null) {
|
|
5826
|
-
setValueByPath(toObject, ['default'], fromDefault);
|
|
5827
|
-
}
|
|
5828
|
-
const fromMaxLength = getValueByPath(fromObject, ['maxLength']);
|
|
5829
|
-
if (fromMaxLength != null) {
|
|
5830
|
-
setValueByPath(toObject, ['maxLength'], fromMaxLength);
|
|
5831
|
-
}
|
|
5832
|
-
const fromMinLength = getValueByPath(fromObject, ['minLength']);
|
|
5833
|
-
if (fromMinLength != null) {
|
|
5834
|
-
setValueByPath(toObject, ['minLength'], fromMinLength);
|
|
5835
|
-
}
|
|
5836
|
-
const fromMinProperties = getValueByPath(fromObject, [
|
|
5837
|
-
'minProperties',
|
|
5838
|
-
]);
|
|
5839
|
-
if (fromMinProperties != null) {
|
|
5840
|
-
setValueByPath(toObject, ['minProperties'], fromMinProperties);
|
|
5841
|
-
}
|
|
5842
|
-
const fromMaxProperties = getValueByPath(fromObject, [
|
|
5843
|
-
'maxProperties',
|
|
5844
|
-
]);
|
|
5845
|
-
if (fromMaxProperties != null) {
|
|
5846
|
-
setValueByPath(toObject, ['maxProperties'], fromMaxProperties);
|
|
5847
|
-
}
|
|
5848
|
-
const fromAnyOf = getValueByPath(fromObject, ['anyOf']);
|
|
5849
|
-
if (fromAnyOf != null) {
|
|
5850
|
-
setValueByPath(toObject, ['anyOf'], fromAnyOf);
|
|
5851
|
-
}
|
|
5852
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
5853
|
-
if (fromDescription != null) {
|
|
5854
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
5855
|
-
}
|
|
5856
|
-
const fromEnum = getValueByPath(fromObject, ['enum']);
|
|
5857
|
-
if (fromEnum != null) {
|
|
5858
|
-
setValueByPath(toObject, ['enum'], fromEnum);
|
|
5859
|
-
}
|
|
5860
|
-
const fromFormat = getValueByPath(fromObject, ['format']);
|
|
5861
|
-
if (fromFormat != null) {
|
|
5862
|
-
setValueByPath(toObject, ['format'], fromFormat);
|
|
5863
|
-
}
|
|
5864
|
-
const fromItems = getValueByPath(fromObject, ['items']);
|
|
5865
|
-
if (fromItems != null) {
|
|
5866
|
-
setValueByPath(toObject, ['items'], fromItems);
|
|
5867
|
-
}
|
|
5868
|
-
const fromMaxItems = getValueByPath(fromObject, ['maxItems']);
|
|
5869
|
-
if (fromMaxItems != null) {
|
|
5870
|
-
setValueByPath(toObject, ['maxItems'], fromMaxItems);
|
|
5871
|
-
}
|
|
5872
|
-
const fromMaximum = getValueByPath(fromObject, ['maximum']);
|
|
5873
|
-
if (fromMaximum != null) {
|
|
5874
|
-
setValueByPath(toObject, ['maximum'], fromMaximum);
|
|
5875
|
-
}
|
|
5876
|
-
const fromMinItems = getValueByPath(fromObject, ['minItems']);
|
|
5877
|
-
if (fromMinItems != null) {
|
|
5878
|
-
setValueByPath(toObject, ['minItems'], fromMinItems);
|
|
5879
|
-
}
|
|
5880
|
-
const fromMinimum = getValueByPath(fromObject, ['minimum']);
|
|
5881
|
-
if (fromMinimum != null) {
|
|
5882
|
-
setValueByPath(toObject, ['minimum'], fromMinimum);
|
|
5883
|
-
}
|
|
5884
|
-
const fromNullable = getValueByPath(fromObject, ['nullable']);
|
|
5885
|
-
if (fromNullable != null) {
|
|
5886
|
-
setValueByPath(toObject, ['nullable'], fromNullable);
|
|
5887
|
-
}
|
|
5888
|
-
const fromProperties = getValueByPath(fromObject, ['properties']);
|
|
5889
|
-
if (fromProperties != null) {
|
|
5890
|
-
setValueByPath(toObject, ['properties'], fromProperties);
|
|
5891
|
-
}
|
|
5892
|
-
const fromPropertyOrdering = getValueByPath(fromObject, [
|
|
5893
|
-
'propertyOrdering',
|
|
5894
|
-
]);
|
|
5895
|
-
if (fromPropertyOrdering != null) {
|
|
5896
|
-
setValueByPath(toObject, ['propertyOrdering'], fromPropertyOrdering);
|
|
5897
|
-
}
|
|
5898
|
-
const fromRequired = getValueByPath(fromObject, ['required']);
|
|
5899
|
-
if (fromRequired != null) {
|
|
5900
|
-
setValueByPath(toObject, ['required'], fromRequired);
|
|
5901
|
-
}
|
|
5902
|
-
const fromTitle = getValueByPath(fromObject, ['title']);
|
|
5903
|
-
if (fromTitle != null) {
|
|
5904
|
-
setValueByPath(toObject, ['title'], fromTitle);
|
|
5905
|
-
}
|
|
5906
|
-
const fromType = getValueByPath(fromObject, ['type']);
|
|
5907
|
-
if (fromType != null) {
|
|
5908
|
-
setValueByPath(toObject, ['type'], fromType);
|
|
5909
|
-
}
|
|
5910
|
-
return toObject;
|
|
5911
|
-
}
|
|
5912
5455
|
function modelSelectionConfigToVertex(apiClient, fromObject) {
|
|
5913
5456
|
const toObject = {};
|
|
5914
5457
|
const fromFeatureSelectionPreference = getValueByPath(fromObject, [
|
|
@@ -5935,26 +5478,6 @@ function safetySettingToVertex(apiClient, fromObject) {
|
|
|
5935
5478
|
}
|
|
5936
5479
|
return toObject;
|
|
5937
5480
|
}
|
|
5938
|
-
function functionDeclarationToVertex(apiClient, fromObject) {
|
|
5939
|
-
const toObject = {};
|
|
5940
|
-
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
5941
|
-
if (fromResponse != null) {
|
|
5942
|
-
setValueByPath(toObject, ['response'], schemaToVertex(apiClient, fromResponse));
|
|
5943
|
-
}
|
|
5944
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
5945
|
-
if (fromDescription != null) {
|
|
5946
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
5947
|
-
}
|
|
5948
|
-
const fromName = getValueByPath(fromObject, ['name']);
|
|
5949
|
-
if (fromName != null) {
|
|
5950
|
-
setValueByPath(toObject, ['name'], fromName);
|
|
5951
|
-
}
|
|
5952
|
-
const fromParameters = getValueByPath(fromObject, ['parameters']);
|
|
5953
|
-
if (fromParameters != null) {
|
|
5954
|
-
setValueByPath(toObject, ['parameters'], fromParameters);
|
|
5955
|
-
}
|
|
5956
|
-
return toObject;
|
|
5957
|
-
}
|
|
5958
5481
|
function googleSearchToVertex() {
|
|
5959
5482
|
const toObject = {};
|
|
5960
5483
|
return toObject;
|
|
@@ -5985,19 +5508,6 @@ function googleSearchRetrievalToVertex(apiClient, fromObject) {
|
|
|
5985
5508
|
}
|
|
5986
5509
|
function toolToVertex(apiClient, fromObject) {
|
|
5987
5510
|
const toObject = {};
|
|
5988
|
-
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
5989
|
-
'functionDeclarations',
|
|
5990
|
-
]);
|
|
5991
|
-
if (fromFunctionDeclarations != null) {
|
|
5992
|
-
if (Array.isArray(fromFunctionDeclarations)) {
|
|
5993
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations.map((item) => {
|
|
5994
|
-
return functionDeclarationToVertex(apiClient, item);
|
|
5995
|
-
}));
|
|
5996
|
-
}
|
|
5997
|
-
else {
|
|
5998
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
5999
|
-
}
|
|
6000
|
-
}
|
|
6001
5511
|
const fromRetrieval = getValueByPath(fromObject, ['retrieval']);
|
|
6002
5512
|
if (fromRetrieval != null) {
|
|
6003
5513
|
setValueByPath(toObject, ['retrieval'], fromRetrieval);
|
|
@@ -6018,6 +5528,12 @@ function toolToVertex(apiClient, fromObject) {
|
|
|
6018
5528
|
if (fromCodeExecution != null) {
|
|
6019
5529
|
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
6020
5530
|
}
|
|
5531
|
+
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
5532
|
+
'functionDeclarations',
|
|
5533
|
+
]);
|
|
5534
|
+
if (fromFunctionDeclarations != null) {
|
|
5535
|
+
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
5536
|
+
}
|
|
6021
5537
|
return toObject;
|
|
6022
5538
|
}
|
|
6023
5539
|
function functionCallingConfigToVertex(apiClient, fromObject) {
|
|
@@ -6164,7 +5680,7 @@ function generateContentConfigToVertex(apiClient, fromObject, parentObject) {
|
|
|
6164
5680
|
'responseSchema',
|
|
6165
5681
|
]);
|
|
6166
5682
|
if (fromResponseSchema != null) {
|
|
6167
|
-
setValueByPath(toObject, ['responseSchema'],
|
|
5683
|
+
setValueByPath(toObject, ['responseSchema'], tSchema(apiClient, fromResponseSchema));
|
|
6168
5684
|
}
|
|
6169
5685
|
const fromRoutingConfig = getValueByPath(fromObject, [
|
|
6170
5686
|
'routingConfig',
|
|
@@ -6182,25 +5698,23 @@ function generateContentConfigToVertex(apiClient, fromObject, parentObject) {
|
|
|
6182
5698
|
'safetySettings',
|
|
6183
5699
|
]);
|
|
6184
5700
|
if (parentObject !== undefined && fromSafetySettings != null) {
|
|
6185
|
-
|
|
6186
|
-
|
|
5701
|
+
let transformedList = fromSafetySettings;
|
|
5702
|
+
if (Array.isArray(transformedList)) {
|
|
5703
|
+
transformedList = transformedList.map((item) => {
|
|
6187
5704
|
return safetySettingToVertex(apiClient, item);
|
|
6188
|
-
})
|
|
6189
|
-
}
|
|
6190
|
-
else {
|
|
6191
|
-
setValueByPath(parentObject, ['safetySettings'], fromSafetySettings);
|
|
5705
|
+
});
|
|
6192
5706
|
}
|
|
5707
|
+
setValueByPath(parentObject, ['safetySettings'], transformedList);
|
|
6193
5708
|
}
|
|
6194
5709
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
6195
5710
|
if (parentObject !== undefined && fromTools != null) {
|
|
6196
|
-
|
|
6197
|
-
|
|
5711
|
+
let transformedList = tTools(apiClient, fromTools);
|
|
5712
|
+
if (Array.isArray(transformedList)) {
|
|
5713
|
+
transformedList = transformedList.map((item) => {
|
|
6198
5714
|
return toolToVertex(apiClient, tTool(apiClient, item));
|
|
6199
|
-
})
|
|
6200
|
-
}
|
|
6201
|
-
else {
|
|
6202
|
-
setValueByPath(parentObject, ['tools'], tTools(apiClient, fromTools));
|
|
5715
|
+
});
|
|
6203
5716
|
}
|
|
5717
|
+
setValueByPath(parentObject, ['tools'], transformedList);
|
|
6204
5718
|
}
|
|
6205
5719
|
const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
|
|
6206
5720
|
if (parentObject !== undefined && fromToolConfig != null) {
|
|
@@ -6254,14 +5768,13 @@ function generateContentParametersToVertex(apiClient, fromObject) {
|
|
|
6254
5768
|
}
|
|
6255
5769
|
const fromContents = getValueByPath(fromObject, ['contents']);
|
|
6256
5770
|
if (fromContents != null) {
|
|
6257
|
-
|
|
6258
|
-
|
|
5771
|
+
let transformedList = tContents(apiClient, fromContents);
|
|
5772
|
+
if (Array.isArray(transformedList)) {
|
|
5773
|
+
transformedList = transformedList.map((item) => {
|
|
6259
5774
|
return contentToVertex(apiClient, item);
|
|
6260
|
-
})
|
|
6261
|
-
}
|
|
6262
|
-
else {
|
|
6263
|
-
setValueByPath(toObject, ['contents'], tContents(apiClient, fromContents));
|
|
5775
|
+
});
|
|
6264
5776
|
}
|
|
5777
|
+
setValueByPath(toObject, ['contents'], transformedList);
|
|
6265
5778
|
}
|
|
6266
5779
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
6267
5780
|
if (fromConfig != null) {
|
|
@@ -6423,6 +5936,42 @@ function getModelParametersToVertex(apiClient, fromObject) {
|
|
|
6423
5936
|
}
|
|
6424
5937
|
return toObject;
|
|
6425
5938
|
}
|
|
5939
|
+
function updateModelConfigToVertex(apiClient, fromObject, parentObject) {
|
|
5940
|
+
const toObject = {};
|
|
5941
|
+
const fromDisplayName = getValueByPath(fromObject, ['displayName']);
|
|
5942
|
+
if (parentObject !== undefined && fromDisplayName != null) {
|
|
5943
|
+
setValueByPath(parentObject, ['displayName'], fromDisplayName);
|
|
5944
|
+
}
|
|
5945
|
+
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
5946
|
+
if (parentObject !== undefined && fromDescription != null) {
|
|
5947
|
+
setValueByPath(parentObject, ['description'], fromDescription);
|
|
5948
|
+
}
|
|
5949
|
+
return toObject;
|
|
5950
|
+
}
|
|
5951
|
+
function updateModelParametersToVertex(apiClient, fromObject) {
|
|
5952
|
+
const toObject = {};
|
|
5953
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
5954
|
+
if (fromModel != null) {
|
|
5955
|
+
setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
|
|
5956
|
+
}
|
|
5957
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
5958
|
+
if (fromConfig != null) {
|
|
5959
|
+
setValueByPath(toObject, ['config'], updateModelConfigToVertex(apiClient, fromConfig, toObject));
|
|
5960
|
+
}
|
|
5961
|
+
return toObject;
|
|
5962
|
+
}
|
|
5963
|
+
function deleteModelParametersToVertex(apiClient, fromObject) {
|
|
5964
|
+
const toObject = {};
|
|
5965
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
5966
|
+
if (fromModel != null) {
|
|
5967
|
+
setValueByPath(toObject, ['_url', 'name'], tModel(apiClient, fromModel));
|
|
5968
|
+
}
|
|
5969
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
5970
|
+
if (fromConfig != null) {
|
|
5971
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
5972
|
+
}
|
|
5973
|
+
return toObject;
|
|
5974
|
+
}
|
|
6426
5975
|
function countTokensConfigToVertex(apiClient, fromObject, parentObject) {
|
|
6427
5976
|
const toObject = {};
|
|
6428
5977
|
const fromSystemInstruction = getValueByPath(fromObject, [
|
|
@@ -6433,14 +5982,13 @@ function countTokensConfigToVertex(apiClient, fromObject, parentObject) {
|
|
|
6433
5982
|
}
|
|
6434
5983
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
6435
5984
|
if (parentObject !== undefined && fromTools != null) {
|
|
6436
|
-
|
|
6437
|
-
|
|
5985
|
+
let transformedList = fromTools;
|
|
5986
|
+
if (Array.isArray(transformedList)) {
|
|
5987
|
+
transformedList = transformedList.map((item) => {
|
|
6438
5988
|
return toolToVertex(apiClient, item);
|
|
6439
|
-
})
|
|
6440
|
-
}
|
|
6441
|
-
else {
|
|
6442
|
-
setValueByPath(parentObject, ['tools'], fromTools);
|
|
5989
|
+
});
|
|
6443
5990
|
}
|
|
5991
|
+
setValueByPath(parentObject, ['tools'], transformedList);
|
|
6444
5992
|
}
|
|
6445
5993
|
const fromGenerationConfig = getValueByPath(fromObject, [
|
|
6446
5994
|
'generationConfig',
|
|
@@ -6458,14 +6006,13 @@ function countTokensParametersToVertex(apiClient, fromObject) {
|
|
|
6458
6006
|
}
|
|
6459
6007
|
const fromContents = getValueByPath(fromObject, ['contents']);
|
|
6460
6008
|
if (fromContents != null) {
|
|
6461
|
-
|
|
6462
|
-
|
|
6009
|
+
let transformedList = tContents(apiClient, fromContents);
|
|
6010
|
+
if (Array.isArray(transformedList)) {
|
|
6011
|
+
transformedList = transformedList.map((item) => {
|
|
6463
6012
|
return contentToVertex(apiClient, item);
|
|
6464
|
-
})
|
|
6465
|
-
}
|
|
6466
|
-
else {
|
|
6467
|
-
setValueByPath(toObject, ['contents'], tContents(apiClient, fromContents));
|
|
6013
|
+
});
|
|
6468
6014
|
}
|
|
6015
|
+
setValueByPath(toObject, ['contents'], transformedList);
|
|
6469
6016
|
}
|
|
6470
6017
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
6471
6018
|
if (fromConfig != null) {
|
|
@@ -6481,14 +6028,13 @@ function computeTokensParametersToVertex(apiClient, fromObject) {
|
|
|
6481
6028
|
}
|
|
6482
6029
|
const fromContents = getValueByPath(fromObject, ['contents']);
|
|
6483
6030
|
if (fromContents != null) {
|
|
6484
|
-
|
|
6485
|
-
|
|
6031
|
+
let transformedList = tContents(apiClient, fromContents);
|
|
6032
|
+
if (Array.isArray(transformedList)) {
|
|
6033
|
+
transformedList = transformedList.map((item) => {
|
|
6486
6034
|
return contentToVertex(apiClient, item);
|
|
6487
|
-
})
|
|
6488
|
-
}
|
|
6489
|
-
else {
|
|
6490
|
-
setValueByPath(toObject, ['contents'], tContents(apiClient, fromContents));
|
|
6035
|
+
});
|
|
6491
6036
|
}
|
|
6037
|
+
setValueByPath(toObject, ['contents'], transformedList);
|
|
6492
6038
|
}
|
|
6493
6039
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
6494
6040
|
if (fromConfig != null) {
|
|
@@ -6636,14 +6182,13 @@ function contentFromMldev(apiClient, fromObject) {
|
|
|
6636
6182
|
const toObject = {};
|
|
6637
6183
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
6638
6184
|
if (fromParts != null) {
|
|
6639
|
-
|
|
6640
|
-
|
|
6185
|
+
let transformedList = fromParts;
|
|
6186
|
+
if (Array.isArray(transformedList)) {
|
|
6187
|
+
transformedList = transformedList.map((item) => {
|
|
6641
6188
|
return partFromMldev(apiClient, item);
|
|
6642
|
-
})
|
|
6643
|
-
}
|
|
6644
|
-
else {
|
|
6645
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
6189
|
+
});
|
|
6646
6190
|
}
|
|
6191
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
6647
6192
|
}
|
|
6648
6193
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
6649
6194
|
if (fromRole != null) {
|
|
@@ -6711,14 +6256,13 @@ function generateContentResponseFromMldev(apiClient, fromObject) {
|
|
|
6711
6256
|
const toObject = {};
|
|
6712
6257
|
const fromCandidates = getValueByPath(fromObject, ['candidates']);
|
|
6713
6258
|
if (fromCandidates != null) {
|
|
6714
|
-
|
|
6715
|
-
|
|
6259
|
+
let transformedList = fromCandidates;
|
|
6260
|
+
if (Array.isArray(transformedList)) {
|
|
6261
|
+
transformedList = transformedList.map((item) => {
|
|
6716
6262
|
return candidateFromMldev(apiClient, item);
|
|
6717
|
-
})
|
|
6718
|
-
}
|
|
6719
|
-
else {
|
|
6720
|
-
setValueByPath(toObject, ['candidates'], fromCandidates);
|
|
6263
|
+
});
|
|
6721
6264
|
}
|
|
6265
|
+
setValueByPath(toObject, ['candidates'], transformedList);
|
|
6722
6266
|
}
|
|
6723
6267
|
const fromModelVersion = getValueByPath(fromObject, ['modelVersion']);
|
|
6724
6268
|
if (fromModelVersion != null) {
|
|
@@ -6754,14 +6298,13 @@ function embedContentResponseFromMldev(apiClient, fromObject) {
|
|
|
6754
6298
|
const toObject = {};
|
|
6755
6299
|
const fromEmbeddings = getValueByPath(fromObject, ['embeddings']);
|
|
6756
6300
|
if (fromEmbeddings != null) {
|
|
6757
|
-
|
|
6758
|
-
|
|
6301
|
+
let transformedList = fromEmbeddings;
|
|
6302
|
+
if (Array.isArray(transformedList)) {
|
|
6303
|
+
transformedList = transformedList.map((item) => {
|
|
6759
6304
|
return contentEmbeddingFromMldev(apiClient, item);
|
|
6760
|
-
})
|
|
6761
|
-
}
|
|
6762
|
-
else {
|
|
6763
|
-
setValueByPath(toObject, ['embeddings'], fromEmbeddings);
|
|
6305
|
+
});
|
|
6764
6306
|
}
|
|
6307
|
+
setValueByPath(toObject, ['embeddings'], transformedList);
|
|
6765
6308
|
}
|
|
6766
6309
|
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
6767
6310
|
if (fromMetadata != null) {
|
|
@@ -6829,14 +6372,13 @@ function generateImagesResponseFromMldev(apiClient, fromObject) {
|
|
|
6829
6372
|
'predictions',
|
|
6830
6373
|
]);
|
|
6831
6374
|
if (fromGeneratedImages != null) {
|
|
6832
|
-
|
|
6833
|
-
|
|
6375
|
+
let transformedList = fromGeneratedImages;
|
|
6376
|
+
if (Array.isArray(transformedList)) {
|
|
6377
|
+
transformedList = transformedList.map((item) => {
|
|
6834
6378
|
return generatedImageFromMldev(apiClient, item);
|
|
6835
|
-
})
|
|
6836
|
-
}
|
|
6837
|
-
else {
|
|
6838
|
-
setValueByPath(toObject, ['generatedImages'], fromGeneratedImages);
|
|
6379
|
+
});
|
|
6839
6380
|
}
|
|
6381
|
+
setValueByPath(toObject, ['generatedImages'], transformedList);
|
|
6840
6382
|
}
|
|
6841
6383
|
const fromPositivePromptSafetyAttributes = getValueByPath(fromObject, [
|
|
6842
6384
|
'positivePromptSafetyAttributes',
|
|
@@ -6904,6 +6446,10 @@ function modelFromMldev(apiClient, fromObject) {
|
|
|
6904
6446
|
}
|
|
6905
6447
|
return toObject;
|
|
6906
6448
|
}
|
|
6449
|
+
function deleteModelResponseFromMldev() {
|
|
6450
|
+
const toObject = {};
|
|
6451
|
+
return toObject;
|
|
6452
|
+
}
|
|
6907
6453
|
function countTokensResponseFromMldev(apiClient, fromObject) {
|
|
6908
6454
|
const toObject = {};
|
|
6909
6455
|
const fromTotalTokens = getValueByPath(fromObject, ['totalTokens']);
|
|
@@ -6951,14 +6497,13 @@ function generateVideosResponseFromMldev$1(apiClient, fromObject) {
|
|
|
6951
6497
|
'generatedSamples',
|
|
6952
6498
|
]);
|
|
6953
6499
|
if (fromGeneratedVideos != null) {
|
|
6954
|
-
|
|
6955
|
-
|
|
6500
|
+
let transformedList = fromGeneratedVideos;
|
|
6501
|
+
if (Array.isArray(transformedList)) {
|
|
6502
|
+
transformedList = transformedList.map((item) => {
|
|
6956
6503
|
return generatedVideoFromMldev$1(apiClient, item);
|
|
6957
|
-
})
|
|
6958
|
-
}
|
|
6959
|
-
else {
|
|
6960
|
-
setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos);
|
|
6504
|
+
});
|
|
6961
6505
|
}
|
|
6506
|
+
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
6962
6507
|
}
|
|
6963
6508
|
const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
|
|
6964
6509
|
'raiMediaFilteredCount',
|
|
@@ -7053,14 +6598,13 @@ function contentFromVertex(apiClient, fromObject) {
|
|
|
7053
6598
|
const toObject = {};
|
|
7054
6599
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
7055
6600
|
if (fromParts != null) {
|
|
7056
|
-
|
|
7057
|
-
|
|
6601
|
+
let transformedList = fromParts;
|
|
6602
|
+
if (Array.isArray(transformedList)) {
|
|
6603
|
+
transformedList = transformedList.map((item) => {
|
|
7058
6604
|
return partFromVertex(apiClient, item);
|
|
7059
|
-
})
|
|
7060
|
-
}
|
|
7061
|
-
else {
|
|
7062
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
6605
|
+
});
|
|
7063
6606
|
}
|
|
6607
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
7064
6608
|
}
|
|
7065
6609
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
7066
6610
|
if (fromRole != null) {
|
|
@@ -7130,14 +6674,13 @@ function generateContentResponseFromVertex(apiClient, fromObject) {
|
|
|
7130
6674
|
const toObject = {};
|
|
7131
6675
|
const fromCandidates = getValueByPath(fromObject, ['candidates']);
|
|
7132
6676
|
if (fromCandidates != null) {
|
|
7133
|
-
|
|
7134
|
-
|
|
6677
|
+
let transformedList = fromCandidates;
|
|
6678
|
+
if (Array.isArray(transformedList)) {
|
|
6679
|
+
transformedList = transformedList.map((item) => {
|
|
7135
6680
|
return candidateFromVertex(apiClient, item);
|
|
7136
|
-
})
|
|
7137
|
-
}
|
|
7138
|
-
else {
|
|
7139
|
-
setValueByPath(toObject, ['candidates'], fromCandidates);
|
|
6681
|
+
});
|
|
7140
6682
|
}
|
|
6683
|
+
setValueByPath(toObject, ['candidates'], transformedList);
|
|
7141
6684
|
}
|
|
7142
6685
|
const fromCreateTime = getValueByPath(fromObject, ['createTime']);
|
|
7143
6686
|
if (fromCreateTime != null) {
|
|
@@ -7206,14 +6749,13 @@ function embedContentResponseFromVertex(apiClient, fromObject) {
|
|
|
7206
6749
|
'embeddings',
|
|
7207
6750
|
]);
|
|
7208
6751
|
if (fromEmbeddings != null) {
|
|
7209
|
-
|
|
7210
|
-
|
|
6752
|
+
let transformedList = fromEmbeddings;
|
|
6753
|
+
if (Array.isArray(transformedList)) {
|
|
6754
|
+
transformedList = transformedList.map((item) => {
|
|
7211
6755
|
return contentEmbeddingFromVertex(apiClient, item);
|
|
7212
|
-
})
|
|
7213
|
-
}
|
|
7214
|
-
else {
|
|
7215
|
-
setValueByPath(toObject, ['embeddings'], fromEmbeddings);
|
|
6756
|
+
});
|
|
7216
6757
|
}
|
|
6758
|
+
setValueByPath(toObject, ['embeddings'], transformedList);
|
|
7217
6759
|
}
|
|
7218
6760
|
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
7219
6761
|
if (fromMetadata != null) {
|
|
@@ -7289,14 +6831,13 @@ function generateImagesResponseFromVertex(apiClient, fromObject) {
|
|
|
7289
6831
|
'predictions',
|
|
7290
6832
|
]);
|
|
7291
6833
|
if (fromGeneratedImages != null) {
|
|
7292
|
-
|
|
7293
|
-
|
|
6834
|
+
let transformedList = fromGeneratedImages;
|
|
6835
|
+
if (Array.isArray(transformedList)) {
|
|
6836
|
+
transformedList = transformedList.map((item) => {
|
|
7294
6837
|
return generatedImageFromVertex(apiClient, item);
|
|
7295
|
-
})
|
|
7296
|
-
}
|
|
7297
|
-
else {
|
|
7298
|
-
setValueByPath(toObject, ['generatedImages'], fromGeneratedImages);
|
|
6838
|
+
});
|
|
7299
6839
|
}
|
|
6840
|
+
setValueByPath(toObject, ['generatedImages'], transformedList);
|
|
7300
6841
|
}
|
|
7301
6842
|
const fromPositivePromptSafetyAttributes = getValueByPath(fromObject, [
|
|
7302
6843
|
'positivePromptSafetyAttributes',
|
|
@@ -7359,14 +6900,13 @@ function modelFromVertex(apiClient, fromObject) {
|
|
|
7359
6900
|
}
|
|
7360
6901
|
const fromEndpoints = getValueByPath(fromObject, ['deployedModels']);
|
|
7361
6902
|
if (fromEndpoints != null) {
|
|
7362
|
-
|
|
7363
|
-
|
|
6903
|
+
let transformedList = fromEndpoints;
|
|
6904
|
+
if (Array.isArray(transformedList)) {
|
|
6905
|
+
transformedList = transformedList.map((item) => {
|
|
7364
6906
|
return endpointFromVertex(apiClient, item);
|
|
7365
|
-
})
|
|
7366
|
-
}
|
|
7367
|
-
else {
|
|
7368
|
-
setValueByPath(toObject, ['endpoints'], fromEndpoints);
|
|
6907
|
+
});
|
|
7369
6908
|
}
|
|
6909
|
+
setValueByPath(toObject, ['endpoints'], transformedList);
|
|
7370
6910
|
}
|
|
7371
6911
|
const fromLabels = getValueByPath(fromObject, ['labels']);
|
|
7372
6912
|
if (fromLabels != null) {
|
|
@@ -7378,6 +6918,10 @@ function modelFromVertex(apiClient, fromObject) {
|
|
|
7378
6918
|
}
|
|
7379
6919
|
return toObject;
|
|
7380
6920
|
}
|
|
6921
|
+
function deleteModelResponseFromVertex() {
|
|
6922
|
+
const toObject = {};
|
|
6923
|
+
return toObject;
|
|
6924
|
+
}
|
|
7381
6925
|
function countTokensResponseFromVertex(apiClient, fromObject) {
|
|
7382
6926
|
const toObject = {};
|
|
7383
6927
|
const fromTotalTokens = getValueByPath(fromObject, ['totalTokens']);
|
|
@@ -7424,14 +6968,13 @@ function generateVideosResponseFromVertex$1(apiClient, fromObject) {
|
|
|
7424
6968
|
const toObject = {};
|
|
7425
6969
|
const fromGeneratedVideos = getValueByPath(fromObject, ['videos']);
|
|
7426
6970
|
if (fromGeneratedVideos != null) {
|
|
7427
|
-
|
|
7428
|
-
|
|
6971
|
+
let transformedList = fromGeneratedVideos;
|
|
6972
|
+
if (Array.isArray(transformedList)) {
|
|
6973
|
+
transformedList = transformedList.map((item) => {
|
|
7429
6974
|
return generatedVideoFromVertex$1(apiClient, item);
|
|
7430
|
-
})
|
|
7431
|
-
}
|
|
7432
|
-
else {
|
|
7433
|
-
setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos);
|
|
6975
|
+
});
|
|
7434
6976
|
}
|
|
6977
|
+
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
7435
6978
|
}
|
|
7436
6979
|
const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
|
|
7437
6980
|
'raiMediaFilteredCount',
|
|
@@ -8374,6 +7917,146 @@ class Models extends BaseModule {
|
|
|
8374
7917
|
});
|
|
8375
7918
|
}
|
|
8376
7919
|
}
|
|
7920
|
+
/**
|
|
7921
|
+
* Updates a tuned model by its name.
|
|
7922
|
+
*
|
|
7923
|
+
* @param params - The parameters for updating the model.
|
|
7924
|
+
* @return The response from the API.
|
|
7925
|
+
*
|
|
7926
|
+
* @example
|
|
7927
|
+
* ```ts
|
|
7928
|
+
* const response = await ai.models.update({
|
|
7929
|
+
* model: 'tuned-model-name',
|
|
7930
|
+
* config: {
|
|
7931
|
+
* displayName: 'New display name',
|
|
7932
|
+
* description: 'New description',
|
|
7933
|
+
* },
|
|
7934
|
+
* });
|
|
7935
|
+
* ```
|
|
7936
|
+
*/
|
|
7937
|
+
async update(params) {
|
|
7938
|
+
var _a, _b, _c, _d;
|
|
7939
|
+
let response;
|
|
7940
|
+
let path = '';
|
|
7941
|
+
let queryParams = {};
|
|
7942
|
+
if (this.apiClient.isVertexAI()) {
|
|
7943
|
+
const body = updateModelParametersToVertex(this.apiClient, params);
|
|
7944
|
+
path = formatMap('{model}', body['_url']);
|
|
7945
|
+
queryParams = body['_query'];
|
|
7946
|
+
delete body['config'];
|
|
7947
|
+
delete body['_url'];
|
|
7948
|
+
delete body['_query'];
|
|
7949
|
+
response = this.apiClient
|
|
7950
|
+
.request({
|
|
7951
|
+
path: path,
|
|
7952
|
+
queryParams: queryParams,
|
|
7953
|
+
body: JSON.stringify(body),
|
|
7954
|
+
httpMethod: 'PATCH',
|
|
7955
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
7956
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
7957
|
+
})
|
|
7958
|
+
.then((httpResponse) => {
|
|
7959
|
+
return httpResponse.json();
|
|
7960
|
+
});
|
|
7961
|
+
return response.then((apiResponse) => {
|
|
7962
|
+
const resp = modelFromVertex(this.apiClient, apiResponse);
|
|
7963
|
+
return resp;
|
|
7964
|
+
});
|
|
7965
|
+
}
|
|
7966
|
+
else {
|
|
7967
|
+
const body = updateModelParametersToMldev(this.apiClient, params);
|
|
7968
|
+
path = formatMap('{name}', body['_url']);
|
|
7969
|
+
queryParams = body['_query'];
|
|
7970
|
+
delete body['config'];
|
|
7971
|
+
delete body['_url'];
|
|
7972
|
+
delete body['_query'];
|
|
7973
|
+
response = this.apiClient
|
|
7974
|
+
.request({
|
|
7975
|
+
path: path,
|
|
7976
|
+
queryParams: queryParams,
|
|
7977
|
+
body: JSON.stringify(body),
|
|
7978
|
+
httpMethod: 'PATCH',
|
|
7979
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
7980
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
7981
|
+
})
|
|
7982
|
+
.then((httpResponse) => {
|
|
7983
|
+
return httpResponse.json();
|
|
7984
|
+
});
|
|
7985
|
+
return response.then((apiResponse) => {
|
|
7986
|
+
const resp = modelFromMldev(this.apiClient, apiResponse);
|
|
7987
|
+
return resp;
|
|
7988
|
+
});
|
|
7989
|
+
}
|
|
7990
|
+
}
|
|
7991
|
+
/**
|
|
7992
|
+
* Deletes a tuned model by its name.
|
|
7993
|
+
*
|
|
7994
|
+
* @param params - The parameters for deleting the model.
|
|
7995
|
+
* @return The response from the API.
|
|
7996
|
+
*
|
|
7997
|
+
* @example
|
|
7998
|
+
* ```ts
|
|
7999
|
+
* const response = await ai.models.delete({model: 'tuned-model-name'});
|
|
8000
|
+
* ```
|
|
8001
|
+
*/
|
|
8002
|
+
async delete(params) {
|
|
8003
|
+
var _a, _b, _c, _d;
|
|
8004
|
+
let response;
|
|
8005
|
+
let path = '';
|
|
8006
|
+
let queryParams = {};
|
|
8007
|
+
if (this.apiClient.isVertexAI()) {
|
|
8008
|
+
const body = deleteModelParametersToVertex(this.apiClient, params);
|
|
8009
|
+
path = formatMap('{name}', body['_url']);
|
|
8010
|
+
queryParams = body['_query'];
|
|
8011
|
+
delete body['config'];
|
|
8012
|
+
delete body['_url'];
|
|
8013
|
+
delete body['_query'];
|
|
8014
|
+
response = this.apiClient
|
|
8015
|
+
.request({
|
|
8016
|
+
path: path,
|
|
8017
|
+
queryParams: queryParams,
|
|
8018
|
+
body: JSON.stringify(body),
|
|
8019
|
+
httpMethod: 'DELETE',
|
|
8020
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
8021
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
8022
|
+
})
|
|
8023
|
+
.then((httpResponse) => {
|
|
8024
|
+
return httpResponse.json();
|
|
8025
|
+
});
|
|
8026
|
+
return response.then(() => {
|
|
8027
|
+
const resp = deleteModelResponseFromVertex();
|
|
8028
|
+
const typedResp = new DeleteModelResponse();
|
|
8029
|
+
Object.assign(typedResp, resp);
|
|
8030
|
+
return typedResp;
|
|
8031
|
+
});
|
|
8032
|
+
}
|
|
8033
|
+
else {
|
|
8034
|
+
const body = deleteModelParametersToMldev(this.apiClient, params);
|
|
8035
|
+
path = formatMap('{name}', body['_url']);
|
|
8036
|
+
queryParams = body['_query'];
|
|
8037
|
+
delete body['config'];
|
|
8038
|
+
delete body['_url'];
|
|
8039
|
+
delete body['_query'];
|
|
8040
|
+
response = this.apiClient
|
|
8041
|
+
.request({
|
|
8042
|
+
path: path,
|
|
8043
|
+
queryParams: queryParams,
|
|
8044
|
+
body: JSON.stringify(body),
|
|
8045
|
+
httpMethod: 'DELETE',
|
|
8046
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
8047
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
8048
|
+
})
|
|
8049
|
+
.then((httpResponse) => {
|
|
8050
|
+
return httpResponse.json();
|
|
8051
|
+
});
|
|
8052
|
+
return response.then(() => {
|
|
8053
|
+
const resp = deleteModelResponseFromMldev();
|
|
8054
|
+
const typedResp = new DeleteModelResponse();
|
|
8055
|
+
Object.assign(typedResp, resp);
|
|
8056
|
+
return typedResp;
|
|
8057
|
+
});
|
|
8058
|
+
}
|
|
8059
|
+
}
|
|
8377
8060
|
/**
|
|
8378
8061
|
* Counts the number of tokens in the given contents. Multimodal input is
|
|
8379
8062
|
* supported for Gemini models.
|
|
@@ -8664,14 +8347,13 @@ function generateVideosResponseFromMldev(apiClient, fromObject) {
|
|
|
8664
8347
|
'generatedSamples',
|
|
8665
8348
|
]);
|
|
8666
8349
|
if (fromGeneratedVideos != null) {
|
|
8667
|
-
|
|
8668
|
-
|
|
8350
|
+
let transformedList = fromGeneratedVideos;
|
|
8351
|
+
if (Array.isArray(transformedList)) {
|
|
8352
|
+
transformedList = transformedList.map((item) => {
|
|
8669
8353
|
return generatedVideoFromMldev(apiClient, item);
|
|
8670
|
-
})
|
|
8671
|
-
}
|
|
8672
|
-
else {
|
|
8673
|
-
setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos);
|
|
8354
|
+
});
|
|
8674
8355
|
}
|
|
8356
|
+
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
8675
8357
|
}
|
|
8676
8358
|
const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
|
|
8677
8359
|
'raiMediaFilteredCount',
|
|
@@ -8744,14 +8426,13 @@ function generateVideosResponseFromVertex(apiClient, fromObject) {
|
|
|
8744
8426
|
const toObject = {};
|
|
8745
8427
|
const fromGeneratedVideos = getValueByPath(fromObject, ['videos']);
|
|
8746
8428
|
if (fromGeneratedVideos != null) {
|
|
8747
|
-
|
|
8748
|
-
|
|
8429
|
+
let transformedList = fromGeneratedVideos;
|
|
8430
|
+
if (Array.isArray(transformedList)) {
|
|
8431
|
+
transformedList = transformedList.map((item) => {
|
|
8749
8432
|
return generatedVideoFromVertex(apiClient, item);
|
|
8750
|
-
})
|
|
8751
|
-
}
|
|
8752
|
-
else {
|
|
8753
|
-
setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos);
|
|
8433
|
+
});
|
|
8754
8434
|
}
|
|
8435
|
+
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
8755
8436
|
}
|
|
8756
8437
|
const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
|
|
8757
8438
|
'raiMediaFilteredCount',
|
|
@@ -8931,7 +8612,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
8931
8612
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
8932
8613
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
8933
8614
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
8934
|
-
const SDK_VERSION = '0.
|
|
8615
|
+
const SDK_VERSION = '0.11.0'; // x-release-please-version
|
|
8935
8616
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
8936
8617
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
8937
8618
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -9408,6 +9089,736 @@ async function throwErrorIfNotOK(response) {
|
|
|
9408
9089
|
}
|
|
9409
9090
|
}
|
|
9410
9091
|
|
|
9092
|
+
/**
|
|
9093
|
+
* @license
|
|
9094
|
+
* Copyright 2025 Google LLC
|
|
9095
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
9096
|
+
*/
|
|
9097
|
+
function getTuningJobParametersToMldev(apiClient, fromObject) {
|
|
9098
|
+
const toObject = {};
|
|
9099
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
9100
|
+
if (fromName != null) {
|
|
9101
|
+
setValueByPath(toObject, ['_url', 'name'], fromName);
|
|
9102
|
+
}
|
|
9103
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
9104
|
+
if (fromConfig != null) {
|
|
9105
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
9106
|
+
}
|
|
9107
|
+
return toObject;
|
|
9108
|
+
}
|
|
9109
|
+
function listTuningJobsConfigToMldev(apiClient, fromObject, parentObject) {
|
|
9110
|
+
const toObject = {};
|
|
9111
|
+
const fromPageSize = getValueByPath(fromObject, ['pageSize']);
|
|
9112
|
+
if (parentObject !== undefined && fromPageSize != null) {
|
|
9113
|
+
setValueByPath(parentObject, ['_query', 'pageSize'], fromPageSize);
|
|
9114
|
+
}
|
|
9115
|
+
const fromPageToken = getValueByPath(fromObject, ['pageToken']);
|
|
9116
|
+
if (parentObject !== undefined && fromPageToken != null) {
|
|
9117
|
+
setValueByPath(parentObject, ['_query', 'pageToken'], fromPageToken);
|
|
9118
|
+
}
|
|
9119
|
+
const fromFilter = getValueByPath(fromObject, ['filter']);
|
|
9120
|
+
if (parentObject !== undefined && fromFilter != null) {
|
|
9121
|
+
setValueByPath(parentObject, ['_query', 'filter'], fromFilter);
|
|
9122
|
+
}
|
|
9123
|
+
return toObject;
|
|
9124
|
+
}
|
|
9125
|
+
function listTuningJobsParametersToMldev(apiClient, fromObject) {
|
|
9126
|
+
const toObject = {};
|
|
9127
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
9128
|
+
if (fromConfig != null) {
|
|
9129
|
+
setValueByPath(toObject, ['config'], listTuningJobsConfigToMldev(apiClient, fromConfig, toObject));
|
|
9130
|
+
}
|
|
9131
|
+
return toObject;
|
|
9132
|
+
}
|
|
9133
|
+
function tuningExampleToMldev(apiClient, fromObject) {
|
|
9134
|
+
const toObject = {};
|
|
9135
|
+
const fromTextInput = getValueByPath(fromObject, ['textInput']);
|
|
9136
|
+
if (fromTextInput != null) {
|
|
9137
|
+
setValueByPath(toObject, ['textInput'], fromTextInput);
|
|
9138
|
+
}
|
|
9139
|
+
const fromOutput = getValueByPath(fromObject, ['output']);
|
|
9140
|
+
if (fromOutput != null) {
|
|
9141
|
+
setValueByPath(toObject, ['output'], fromOutput);
|
|
9142
|
+
}
|
|
9143
|
+
return toObject;
|
|
9144
|
+
}
|
|
9145
|
+
function tuningDatasetToMldev(apiClient, fromObject) {
|
|
9146
|
+
const toObject = {};
|
|
9147
|
+
if (getValueByPath(fromObject, ['gcsUri']) !== undefined) {
|
|
9148
|
+
throw new Error('gcsUri parameter is not supported in Gemini API.');
|
|
9149
|
+
}
|
|
9150
|
+
const fromExamples = getValueByPath(fromObject, ['examples']);
|
|
9151
|
+
if (fromExamples != null) {
|
|
9152
|
+
let transformedList = fromExamples;
|
|
9153
|
+
if (Array.isArray(transformedList)) {
|
|
9154
|
+
transformedList = transformedList.map((item) => {
|
|
9155
|
+
return tuningExampleToMldev(apiClient, item);
|
|
9156
|
+
});
|
|
9157
|
+
}
|
|
9158
|
+
setValueByPath(toObject, ['examples', 'examples'], transformedList);
|
|
9159
|
+
}
|
|
9160
|
+
return toObject;
|
|
9161
|
+
}
|
|
9162
|
+
function createTuningJobConfigToMldev(apiClient, fromObject, parentObject) {
|
|
9163
|
+
const toObject = {};
|
|
9164
|
+
if (getValueByPath(fromObject, ['validationDataset']) !== undefined) {
|
|
9165
|
+
throw new Error('validationDataset parameter is not supported in Gemini API.');
|
|
9166
|
+
}
|
|
9167
|
+
const fromTunedModelDisplayName = getValueByPath(fromObject, [
|
|
9168
|
+
'tunedModelDisplayName',
|
|
9169
|
+
]);
|
|
9170
|
+
if (parentObject !== undefined && fromTunedModelDisplayName != null) {
|
|
9171
|
+
setValueByPath(parentObject, ['displayName'], fromTunedModelDisplayName);
|
|
9172
|
+
}
|
|
9173
|
+
if (getValueByPath(fromObject, ['description']) !== undefined) {
|
|
9174
|
+
throw new Error('description parameter is not supported in Gemini API.');
|
|
9175
|
+
}
|
|
9176
|
+
const fromEpochCount = getValueByPath(fromObject, ['epochCount']);
|
|
9177
|
+
if (parentObject !== undefined && fromEpochCount != null) {
|
|
9178
|
+
setValueByPath(parentObject, ['tuningTask', 'hyperparameters', 'epochCount'], fromEpochCount);
|
|
9179
|
+
}
|
|
9180
|
+
const fromLearningRateMultiplier = getValueByPath(fromObject, [
|
|
9181
|
+
'learningRateMultiplier',
|
|
9182
|
+
]);
|
|
9183
|
+
if (fromLearningRateMultiplier != null) {
|
|
9184
|
+
setValueByPath(toObject, ['tuningTask', 'hyperparameters', 'learningRateMultiplier'], fromLearningRateMultiplier);
|
|
9185
|
+
}
|
|
9186
|
+
if (getValueByPath(fromObject, ['adapterSize']) !== undefined) {
|
|
9187
|
+
throw new Error('adapterSize parameter is not supported in Gemini API.');
|
|
9188
|
+
}
|
|
9189
|
+
const fromBatchSize = getValueByPath(fromObject, ['batchSize']);
|
|
9190
|
+
if (parentObject !== undefined && fromBatchSize != null) {
|
|
9191
|
+
setValueByPath(parentObject, ['tuningTask', 'hyperparameters', 'batchSize'], fromBatchSize);
|
|
9192
|
+
}
|
|
9193
|
+
const fromLearningRate = getValueByPath(fromObject, ['learningRate']);
|
|
9194
|
+
if (parentObject !== undefined && fromLearningRate != null) {
|
|
9195
|
+
setValueByPath(parentObject, ['tuningTask', 'hyperparameters', 'learningRate'], fromLearningRate);
|
|
9196
|
+
}
|
|
9197
|
+
return toObject;
|
|
9198
|
+
}
|
|
9199
|
+
function createTuningJobParametersToMldev(apiClient, fromObject) {
|
|
9200
|
+
const toObject = {};
|
|
9201
|
+
const fromBaseModel = getValueByPath(fromObject, ['baseModel']);
|
|
9202
|
+
if (fromBaseModel != null) {
|
|
9203
|
+
setValueByPath(toObject, ['baseModel'], fromBaseModel);
|
|
9204
|
+
}
|
|
9205
|
+
const fromTrainingDataset = getValueByPath(fromObject, [
|
|
9206
|
+
'trainingDataset',
|
|
9207
|
+
]);
|
|
9208
|
+
if (fromTrainingDataset != null) {
|
|
9209
|
+
setValueByPath(toObject, ['tuningTask', 'trainingData'], tuningDatasetToMldev(apiClient, fromTrainingDataset));
|
|
9210
|
+
}
|
|
9211
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
9212
|
+
if (fromConfig != null) {
|
|
9213
|
+
setValueByPath(toObject, ['config'], createTuningJobConfigToMldev(apiClient, fromConfig, toObject));
|
|
9214
|
+
}
|
|
9215
|
+
return toObject;
|
|
9216
|
+
}
|
|
9217
|
+
function getTuningJobParametersToVertex(apiClient, fromObject) {
|
|
9218
|
+
const toObject = {};
|
|
9219
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
9220
|
+
if (fromName != null) {
|
|
9221
|
+
setValueByPath(toObject, ['_url', 'name'], fromName);
|
|
9222
|
+
}
|
|
9223
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
9224
|
+
if (fromConfig != null) {
|
|
9225
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
9226
|
+
}
|
|
9227
|
+
return toObject;
|
|
9228
|
+
}
|
|
9229
|
+
function listTuningJobsConfigToVertex(apiClient, fromObject, parentObject) {
|
|
9230
|
+
const toObject = {};
|
|
9231
|
+
const fromPageSize = getValueByPath(fromObject, ['pageSize']);
|
|
9232
|
+
if (parentObject !== undefined && fromPageSize != null) {
|
|
9233
|
+
setValueByPath(parentObject, ['_query', 'pageSize'], fromPageSize);
|
|
9234
|
+
}
|
|
9235
|
+
const fromPageToken = getValueByPath(fromObject, ['pageToken']);
|
|
9236
|
+
if (parentObject !== undefined && fromPageToken != null) {
|
|
9237
|
+
setValueByPath(parentObject, ['_query', 'pageToken'], fromPageToken);
|
|
9238
|
+
}
|
|
9239
|
+
const fromFilter = getValueByPath(fromObject, ['filter']);
|
|
9240
|
+
if (parentObject !== undefined && fromFilter != null) {
|
|
9241
|
+
setValueByPath(parentObject, ['_query', 'filter'], fromFilter);
|
|
9242
|
+
}
|
|
9243
|
+
return toObject;
|
|
9244
|
+
}
|
|
9245
|
+
function listTuningJobsParametersToVertex(apiClient, fromObject) {
|
|
9246
|
+
const toObject = {};
|
|
9247
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
9248
|
+
if (fromConfig != null) {
|
|
9249
|
+
setValueByPath(toObject, ['config'], listTuningJobsConfigToVertex(apiClient, fromConfig, toObject));
|
|
9250
|
+
}
|
|
9251
|
+
return toObject;
|
|
9252
|
+
}
|
|
9253
|
+
function tuningDatasetToVertex(apiClient, fromObject, parentObject) {
|
|
9254
|
+
const toObject = {};
|
|
9255
|
+
const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
|
|
9256
|
+
if (parentObject !== undefined && fromGcsUri != null) {
|
|
9257
|
+
setValueByPath(parentObject, ['supervisedTuningSpec', 'trainingDatasetUri'], fromGcsUri);
|
|
9258
|
+
}
|
|
9259
|
+
if (getValueByPath(fromObject, ['examples']) !== undefined) {
|
|
9260
|
+
throw new Error('examples parameter is not supported in Vertex AI.');
|
|
9261
|
+
}
|
|
9262
|
+
return toObject;
|
|
9263
|
+
}
|
|
9264
|
+
function tuningValidationDatasetToVertex(apiClient, fromObject) {
|
|
9265
|
+
const toObject = {};
|
|
9266
|
+
const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
|
|
9267
|
+
if (fromGcsUri != null) {
|
|
9268
|
+
setValueByPath(toObject, ['validationDatasetUri'], fromGcsUri);
|
|
9269
|
+
}
|
|
9270
|
+
return toObject;
|
|
9271
|
+
}
|
|
9272
|
+
function createTuningJobConfigToVertex(apiClient, fromObject, parentObject) {
|
|
9273
|
+
const toObject = {};
|
|
9274
|
+
const fromValidationDataset = getValueByPath(fromObject, [
|
|
9275
|
+
'validationDataset',
|
|
9276
|
+
]);
|
|
9277
|
+
if (parentObject !== undefined && fromValidationDataset != null) {
|
|
9278
|
+
setValueByPath(parentObject, ['supervisedTuningSpec'], tuningValidationDatasetToVertex(apiClient, fromValidationDataset));
|
|
9279
|
+
}
|
|
9280
|
+
const fromTunedModelDisplayName = getValueByPath(fromObject, [
|
|
9281
|
+
'tunedModelDisplayName',
|
|
9282
|
+
]);
|
|
9283
|
+
if (parentObject !== undefined && fromTunedModelDisplayName != null) {
|
|
9284
|
+
setValueByPath(parentObject, ['tunedModelDisplayName'], fromTunedModelDisplayName);
|
|
9285
|
+
}
|
|
9286
|
+
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
9287
|
+
if (parentObject !== undefined && fromDescription != null) {
|
|
9288
|
+
setValueByPath(parentObject, ['description'], fromDescription);
|
|
9289
|
+
}
|
|
9290
|
+
const fromEpochCount = getValueByPath(fromObject, ['epochCount']);
|
|
9291
|
+
if (parentObject !== undefined && fromEpochCount != null) {
|
|
9292
|
+
setValueByPath(parentObject, ['supervisedTuningSpec', 'hyperParameters', 'epochCount'], fromEpochCount);
|
|
9293
|
+
}
|
|
9294
|
+
const fromLearningRateMultiplier = getValueByPath(fromObject, [
|
|
9295
|
+
'learningRateMultiplier',
|
|
9296
|
+
]);
|
|
9297
|
+
if (parentObject !== undefined && fromLearningRateMultiplier != null) {
|
|
9298
|
+
setValueByPath(parentObject, ['supervisedTuningSpec', 'hyperParameters', 'learningRateMultiplier'], fromLearningRateMultiplier);
|
|
9299
|
+
}
|
|
9300
|
+
const fromAdapterSize = getValueByPath(fromObject, ['adapterSize']);
|
|
9301
|
+
if (parentObject !== undefined && fromAdapterSize != null) {
|
|
9302
|
+
setValueByPath(parentObject, ['supervisedTuningSpec', 'hyperParameters', 'adapterSize'], fromAdapterSize);
|
|
9303
|
+
}
|
|
9304
|
+
if (getValueByPath(fromObject, ['batchSize']) !== undefined) {
|
|
9305
|
+
throw new Error('batchSize parameter is not supported in Vertex AI.');
|
|
9306
|
+
}
|
|
9307
|
+
if (getValueByPath(fromObject, ['learningRate']) !== undefined) {
|
|
9308
|
+
throw new Error('learningRate parameter is not supported in Vertex AI.');
|
|
9309
|
+
}
|
|
9310
|
+
return toObject;
|
|
9311
|
+
}
|
|
9312
|
+
function createTuningJobParametersToVertex(apiClient, fromObject) {
|
|
9313
|
+
const toObject = {};
|
|
9314
|
+
const fromBaseModel = getValueByPath(fromObject, ['baseModel']);
|
|
9315
|
+
if (fromBaseModel != null) {
|
|
9316
|
+
setValueByPath(toObject, ['baseModel'], fromBaseModel);
|
|
9317
|
+
}
|
|
9318
|
+
const fromTrainingDataset = getValueByPath(fromObject, [
|
|
9319
|
+
'trainingDataset',
|
|
9320
|
+
]);
|
|
9321
|
+
if (fromTrainingDataset != null) {
|
|
9322
|
+
setValueByPath(toObject, ['supervisedTuningSpec', 'trainingDatasetUri'], tuningDatasetToVertex(apiClient, fromTrainingDataset, toObject));
|
|
9323
|
+
}
|
|
9324
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
9325
|
+
if (fromConfig != null) {
|
|
9326
|
+
setValueByPath(toObject, ['config'], createTuningJobConfigToVertex(apiClient, fromConfig, toObject));
|
|
9327
|
+
}
|
|
9328
|
+
return toObject;
|
|
9329
|
+
}
|
|
9330
|
+
function tunedModelFromMldev(apiClient, fromObject) {
|
|
9331
|
+
const toObject = {};
|
|
9332
|
+
const fromModel = getValueByPath(fromObject, ['name']);
|
|
9333
|
+
if (fromModel != null) {
|
|
9334
|
+
setValueByPath(toObject, ['model'], fromModel);
|
|
9335
|
+
}
|
|
9336
|
+
const fromEndpoint = getValueByPath(fromObject, ['name']);
|
|
9337
|
+
if (fromEndpoint != null) {
|
|
9338
|
+
setValueByPath(toObject, ['endpoint'], fromEndpoint);
|
|
9339
|
+
}
|
|
9340
|
+
return toObject;
|
|
9341
|
+
}
|
|
9342
|
+
function tuningJobFromMldev(apiClient, fromObject) {
|
|
9343
|
+
const toObject = {};
|
|
9344
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
9345
|
+
if (fromName != null) {
|
|
9346
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
9347
|
+
}
|
|
9348
|
+
const fromState = getValueByPath(fromObject, ['state']);
|
|
9349
|
+
if (fromState != null) {
|
|
9350
|
+
setValueByPath(toObject, ['state'], tTuningJobStatus(apiClient, fromState));
|
|
9351
|
+
}
|
|
9352
|
+
const fromCreateTime = getValueByPath(fromObject, ['createTime']);
|
|
9353
|
+
if (fromCreateTime != null) {
|
|
9354
|
+
setValueByPath(toObject, ['createTime'], fromCreateTime);
|
|
9355
|
+
}
|
|
9356
|
+
const fromStartTime = getValueByPath(fromObject, [
|
|
9357
|
+
'tuningTask',
|
|
9358
|
+
'startTime',
|
|
9359
|
+
]);
|
|
9360
|
+
if (fromStartTime != null) {
|
|
9361
|
+
setValueByPath(toObject, ['startTime'], fromStartTime);
|
|
9362
|
+
}
|
|
9363
|
+
const fromEndTime = getValueByPath(fromObject, [
|
|
9364
|
+
'tuningTask',
|
|
9365
|
+
'completeTime',
|
|
9366
|
+
]);
|
|
9367
|
+
if (fromEndTime != null) {
|
|
9368
|
+
setValueByPath(toObject, ['endTime'], fromEndTime);
|
|
9369
|
+
}
|
|
9370
|
+
const fromUpdateTime = getValueByPath(fromObject, ['updateTime']);
|
|
9371
|
+
if (fromUpdateTime != null) {
|
|
9372
|
+
setValueByPath(toObject, ['updateTime'], fromUpdateTime);
|
|
9373
|
+
}
|
|
9374
|
+
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
9375
|
+
if (fromDescription != null) {
|
|
9376
|
+
setValueByPath(toObject, ['description'], fromDescription);
|
|
9377
|
+
}
|
|
9378
|
+
const fromBaseModel = getValueByPath(fromObject, ['baseModel']);
|
|
9379
|
+
if (fromBaseModel != null) {
|
|
9380
|
+
setValueByPath(toObject, ['baseModel'], fromBaseModel);
|
|
9381
|
+
}
|
|
9382
|
+
const fromTunedModel = getValueByPath(fromObject, ['_self']);
|
|
9383
|
+
if (fromTunedModel != null) {
|
|
9384
|
+
setValueByPath(toObject, ['tunedModel'], tunedModelFromMldev(apiClient, fromTunedModel));
|
|
9385
|
+
}
|
|
9386
|
+
const fromDistillationSpec = getValueByPath(fromObject, [
|
|
9387
|
+
'distillationSpec',
|
|
9388
|
+
]);
|
|
9389
|
+
if (fromDistillationSpec != null) {
|
|
9390
|
+
setValueByPath(toObject, ['distillationSpec'], fromDistillationSpec);
|
|
9391
|
+
}
|
|
9392
|
+
const fromExperiment = getValueByPath(fromObject, ['experiment']);
|
|
9393
|
+
if (fromExperiment != null) {
|
|
9394
|
+
setValueByPath(toObject, ['experiment'], fromExperiment);
|
|
9395
|
+
}
|
|
9396
|
+
const fromLabels = getValueByPath(fromObject, ['labels']);
|
|
9397
|
+
if (fromLabels != null) {
|
|
9398
|
+
setValueByPath(toObject, ['labels'], fromLabels);
|
|
9399
|
+
}
|
|
9400
|
+
const fromPipelineJob = getValueByPath(fromObject, ['pipelineJob']);
|
|
9401
|
+
if (fromPipelineJob != null) {
|
|
9402
|
+
setValueByPath(toObject, ['pipelineJob'], fromPipelineJob);
|
|
9403
|
+
}
|
|
9404
|
+
const fromTunedModelDisplayName = getValueByPath(fromObject, [
|
|
9405
|
+
'tunedModelDisplayName',
|
|
9406
|
+
]);
|
|
9407
|
+
if (fromTunedModelDisplayName != null) {
|
|
9408
|
+
setValueByPath(toObject, ['tunedModelDisplayName'], fromTunedModelDisplayName);
|
|
9409
|
+
}
|
|
9410
|
+
return toObject;
|
|
9411
|
+
}
|
|
9412
|
+
function listTuningJobsResponseFromMldev(apiClient, fromObject) {
|
|
9413
|
+
const toObject = {};
|
|
9414
|
+
const fromNextPageToken = getValueByPath(fromObject, [
|
|
9415
|
+
'nextPageToken',
|
|
9416
|
+
]);
|
|
9417
|
+
if (fromNextPageToken != null) {
|
|
9418
|
+
setValueByPath(toObject, ['nextPageToken'], fromNextPageToken);
|
|
9419
|
+
}
|
|
9420
|
+
const fromTuningJobs = getValueByPath(fromObject, ['tunedModels']);
|
|
9421
|
+
if (fromTuningJobs != null) {
|
|
9422
|
+
let transformedList = fromTuningJobs;
|
|
9423
|
+
if (Array.isArray(transformedList)) {
|
|
9424
|
+
transformedList = transformedList.map((item) => {
|
|
9425
|
+
return tuningJobFromMldev(apiClient, item);
|
|
9426
|
+
});
|
|
9427
|
+
}
|
|
9428
|
+
setValueByPath(toObject, ['tuningJobs'], transformedList);
|
|
9429
|
+
}
|
|
9430
|
+
return toObject;
|
|
9431
|
+
}
|
|
9432
|
+
function operationFromMldev(apiClient, fromObject) {
|
|
9433
|
+
const toObject = {};
|
|
9434
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
9435
|
+
if (fromName != null) {
|
|
9436
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
9437
|
+
}
|
|
9438
|
+
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
9439
|
+
if (fromMetadata != null) {
|
|
9440
|
+
setValueByPath(toObject, ['metadata'], fromMetadata);
|
|
9441
|
+
}
|
|
9442
|
+
const fromDone = getValueByPath(fromObject, ['done']);
|
|
9443
|
+
if (fromDone != null) {
|
|
9444
|
+
setValueByPath(toObject, ['done'], fromDone);
|
|
9445
|
+
}
|
|
9446
|
+
const fromError = getValueByPath(fromObject, ['error']);
|
|
9447
|
+
if (fromError != null) {
|
|
9448
|
+
setValueByPath(toObject, ['error'], fromError);
|
|
9449
|
+
}
|
|
9450
|
+
return toObject;
|
|
9451
|
+
}
|
|
9452
|
+
function tunedModelFromVertex(apiClient, fromObject) {
|
|
9453
|
+
const toObject = {};
|
|
9454
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
9455
|
+
if (fromModel != null) {
|
|
9456
|
+
setValueByPath(toObject, ['model'], fromModel);
|
|
9457
|
+
}
|
|
9458
|
+
const fromEndpoint = getValueByPath(fromObject, ['endpoint']);
|
|
9459
|
+
if (fromEndpoint != null) {
|
|
9460
|
+
setValueByPath(toObject, ['endpoint'], fromEndpoint);
|
|
9461
|
+
}
|
|
9462
|
+
return toObject;
|
|
9463
|
+
}
|
|
9464
|
+
function tuningJobFromVertex(apiClient, fromObject) {
|
|
9465
|
+
const toObject = {};
|
|
9466
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
9467
|
+
if (fromName != null) {
|
|
9468
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
9469
|
+
}
|
|
9470
|
+
const fromState = getValueByPath(fromObject, ['state']);
|
|
9471
|
+
if (fromState != null) {
|
|
9472
|
+
setValueByPath(toObject, ['state'], tTuningJobStatus(apiClient, fromState));
|
|
9473
|
+
}
|
|
9474
|
+
const fromCreateTime = getValueByPath(fromObject, ['createTime']);
|
|
9475
|
+
if (fromCreateTime != null) {
|
|
9476
|
+
setValueByPath(toObject, ['createTime'], fromCreateTime);
|
|
9477
|
+
}
|
|
9478
|
+
const fromStartTime = getValueByPath(fromObject, ['startTime']);
|
|
9479
|
+
if (fromStartTime != null) {
|
|
9480
|
+
setValueByPath(toObject, ['startTime'], fromStartTime);
|
|
9481
|
+
}
|
|
9482
|
+
const fromEndTime = getValueByPath(fromObject, ['endTime']);
|
|
9483
|
+
if (fromEndTime != null) {
|
|
9484
|
+
setValueByPath(toObject, ['endTime'], fromEndTime);
|
|
9485
|
+
}
|
|
9486
|
+
const fromUpdateTime = getValueByPath(fromObject, ['updateTime']);
|
|
9487
|
+
if (fromUpdateTime != null) {
|
|
9488
|
+
setValueByPath(toObject, ['updateTime'], fromUpdateTime);
|
|
9489
|
+
}
|
|
9490
|
+
const fromError = getValueByPath(fromObject, ['error']);
|
|
9491
|
+
if (fromError != null) {
|
|
9492
|
+
setValueByPath(toObject, ['error'], fromError);
|
|
9493
|
+
}
|
|
9494
|
+
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
9495
|
+
if (fromDescription != null) {
|
|
9496
|
+
setValueByPath(toObject, ['description'], fromDescription);
|
|
9497
|
+
}
|
|
9498
|
+
const fromBaseModel = getValueByPath(fromObject, ['baseModel']);
|
|
9499
|
+
if (fromBaseModel != null) {
|
|
9500
|
+
setValueByPath(toObject, ['baseModel'], fromBaseModel);
|
|
9501
|
+
}
|
|
9502
|
+
const fromTunedModel = getValueByPath(fromObject, ['tunedModel']);
|
|
9503
|
+
if (fromTunedModel != null) {
|
|
9504
|
+
setValueByPath(toObject, ['tunedModel'], tunedModelFromVertex(apiClient, fromTunedModel));
|
|
9505
|
+
}
|
|
9506
|
+
const fromSupervisedTuningSpec = getValueByPath(fromObject, [
|
|
9507
|
+
'supervisedTuningSpec',
|
|
9508
|
+
]);
|
|
9509
|
+
if (fromSupervisedTuningSpec != null) {
|
|
9510
|
+
setValueByPath(toObject, ['supervisedTuningSpec'], fromSupervisedTuningSpec);
|
|
9511
|
+
}
|
|
9512
|
+
const fromTuningDataStats = getValueByPath(fromObject, [
|
|
9513
|
+
'tuningDataStats',
|
|
9514
|
+
]);
|
|
9515
|
+
if (fromTuningDataStats != null) {
|
|
9516
|
+
setValueByPath(toObject, ['tuningDataStats'], fromTuningDataStats);
|
|
9517
|
+
}
|
|
9518
|
+
const fromEncryptionSpec = getValueByPath(fromObject, [
|
|
9519
|
+
'encryptionSpec',
|
|
9520
|
+
]);
|
|
9521
|
+
if (fromEncryptionSpec != null) {
|
|
9522
|
+
setValueByPath(toObject, ['encryptionSpec'], fromEncryptionSpec);
|
|
9523
|
+
}
|
|
9524
|
+
const fromPartnerModelTuningSpec = getValueByPath(fromObject, [
|
|
9525
|
+
'partnerModelTuningSpec',
|
|
9526
|
+
]);
|
|
9527
|
+
if (fromPartnerModelTuningSpec != null) {
|
|
9528
|
+
setValueByPath(toObject, ['partnerModelTuningSpec'], fromPartnerModelTuningSpec);
|
|
9529
|
+
}
|
|
9530
|
+
const fromDistillationSpec = getValueByPath(fromObject, [
|
|
9531
|
+
'distillationSpec',
|
|
9532
|
+
]);
|
|
9533
|
+
if (fromDistillationSpec != null) {
|
|
9534
|
+
setValueByPath(toObject, ['distillationSpec'], fromDistillationSpec);
|
|
9535
|
+
}
|
|
9536
|
+
const fromExperiment = getValueByPath(fromObject, ['experiment']);
|
|
9537
|
+
if (fromExperiment != null) {
|
|
9538
|
+
setValueByPath(toObject, ['experiment'], fromExperiment);
|
|
9539
|
+
}
|
|
9540
|
+
const fromLabels = getValueByPath(fromObject, ['labels']);
|
|
9541
|
+
if (fromLabels != null) {
|
|
9542
|
+
setValueByPath(toObject, ['labels'], fromLabels);
|
|
9543
|
+
}
|
|
9544
|
+
const fromPipelineJob = getValueByPath(fromObject, ['pipelineJob']);
|
|
9545
|
+
if (fromPipelineJob != null) {
|
|
9546
|
+
setValueByPath(toObject, ['pipelineJob'], fromPipelineJob);
|
|
9547
|
+
}
|
|
9548
|
+
const fromTunedModelDisplayName = getValueByPath(fromObject, [
|
|
9549
|
+
'tunedModelDisplayName',
|
|
9550
|
+
]);
|
|
9551
|
+
if (fromTunedModelDisplayName != null) {
|
|
9552
|
+
setValueByPath(toObject, ['tunedModelDisplayName'], fromTunedModelDisplayName);
|
|
9553
|
+
}
|
|
9554
|
+
return toObject;
|
|
9555
|
+
}
|
|
9556
|
+
function listTuningJobsResponseFromVertex(apiClient, fromObject) {
|
|
9557
|
+
const toObject = {};
|
|
9558
|
+
const fromNextPageToken = getValueByPath(fromObject, [
|
|
9559
|
+
'nextPageToken',
|
|
9560
|
+
]);
|
|
9561
|
+
if (fromNextPageToken != null) {
|
|
9562
|
+
setValueByPath(toObject, ['nextPageToken'], fromNextPageToken);
|
|
9563
|
+
}
|
|
9564
|
+
const fromTuningJobs = getValueByPath(fromObject, ['tuningJobs']);
|
|
9565
|
+
if (fromTuningJobs != null) {
|
|
9566
|
+
let transformedList = fromTuningJobs;
|
|
9567
|
+
if (Array.isArray(transformedList)) {
|
|
9568
|
+
transformedList = transformedList.map((item) => {
|
|
9569
|
+
return tuningJobFromVertex(apiClient, item);
|
|
9570
|
+
});
|
|
9571
|
+
}
|
|
9572
|
+
setValueByPath(toObject, ['tuningJobs'], transformedList);
|
|
9573
|
+
}
|
|
9574
|
+
return toObject;
|
|
9575
|
+
}
|
|
9576
|
+
|
|
9577
|
+
/**
|
|
9578
|
+
* @license
|
|
9579
|
+
* Copyright 2025 Google LLC
|
|
9580
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
9581
|
+
*/
|
|
9582
|
+
class Tunings extends BaseModule {
|
|
9583
|
+
constructor(apiClient) {
|
|
9584
|
+
super();
|
|
9585
|
+
this.apiClient = apiClient;
|
|
9586
|
+
/**
|
|
9587
|
+
* Gets a TuningJob.
|
|
9588
|
+
*
|
|
9589
|
+
* @param name - The resource name of the tuning job.
|
|
9590
|
+
* @return - A TuningJob object.
|
|
9591
|
+
*
|
|
9592
|
+
* @experimental - The SDK's tuning implementation is experimental, and may
|
|
9593
|
+
* change in future versions.
|
|
9594
|
+
*/
|
|
9595
|
+
this.get = async (params) => {
|
|
9596
|
+
return await this.getInternal(params);
|
|
9597
|
+
};
|
|
9598
|
+
/**
|
|
9599
|
+
* Lists tuning jobs.
|
|
9600
|
+
*
|
|
9601
|
+
* @param config - The configuration for the list request.
|
|
9602
|
+
* @return - A list of tuning jobs.
|
|
9603
|
+
*
|
|
9604
|
+
* @experimental - The SDK's tuning implementation is experimental, and may
|
|
9605
|
+
* change in future versions.
|
|
9606
|
+
*/
|
|
9607
|
+
this.list = async (params = {}) => {
|
|
9608
|
+
return new Pager(PagedItem.PAGED_ITEM_TUNING_JOBS, (x) => this.listInternal(x), await this.listInternal(params), params);
|
|
9609
|
+
};
|
|
9610
|
+
/**
|
|
9611
|
+
* Creates a supervised fine-tuning job.
|
|
9612
|
+
*
|
|
9613
|
+
* @param params - The parameters for the tuning job.
|
|
9614
|
+
* @return - A TuningJob operation.
|
|
9615
|
+
*
|
|
9616
|
+
* @experimental - The SDK's tuning implementation is experimental, and may
|
|
9617
|
+
* change in future versions.
|
|
9618
|
+
*/
|
|
9619
|
+
this.tune = async (params) => {
|
|
9620
|
+
if (this.apiClient.isVertexAI()) {
|
|
9621
|
+
return await this.tuneInternal(params);
|
|
9622
|
+
}
|
|
9623
|
+
else {
|
|
9624
|
+
const operation = await this.tuneMldevInternal(params);
|
|
9625
|
+
let tunedModelName = '';
|
|
9626
|
+
if (operation['metadata'] !== undefined &&
|
|
9627
|
+
operation['metadata']['tunedModel'] !== undefined) {
|
|
9628
|
+
tunedModelName = operation['metadata']['tunedModel'];
|
|
9629
|
+
}
|
|
9630
|
+
else if (operation['name'] !== undefined &&
|
|
9631
|
+
operation['name'].includes('/operations/')) {
|
|
9632
|
+
tunedModelName = operation['name'].split('/operations/')[0];
|
|
9633
|
+
}
|
|
9634
|
+
const tuningJob = {
|
|
9635
|
+
name: tunedModelName,
|
|
9636
|
+
state: JobState.JOB_STATE_QUEUED,
|
|
9637
|
+
};
|
|
9638
|
+
return tuningJob;
|
|
9639
|
+
}
|
|
9640
|
+
};
|
|
9641
|
+
}
|
|
9642
|
+
async getInternal(params) {
|
|
9643
|
+
var _a, _b, _c, _d;
|
|
9644
|
+
let response;
|
|
9645
|
+
let path = '';
|
|
9646
|
+
let queryParams = {};
|
|
9647
|
+
if (this.apiClient.isVertexAI()) {
|
|
9648
|
+
const body = getTuningJobParametersToVertex(this.apiClient, params);
|
|
9649
|
+
path = formatMap('{name}', body['_url']);
|
|
9650
|
+
queryParams = body['_query'];
|
|
9651
|
+
delete body['config'];
|
|
9652
|
+
delete body['_url'];
|
|
9653
|
+
delete body['_query'];
|
|
9654
|
+
response = this.apiClient
|
|
9655
|
+
.request({
|
|
9656
|
+
path: path,
|
|
9657
|
+
queryParams: queryParams,
|
|
9658
|
+
body: JSON.stringify(body),
|
|
9659
|
+
httpMethod: 'GET',
|
|
9660
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
9661
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
9662
|
+
})
|
|
9663
|
+
.then((httpResponse) => {
|
|
9664
|
+
return httpResponse.json();
|
|
9665
|
+
});
|
|
9666
|
+
return response.then((apiResponse) => {
|
|
9667
|
+
const resp = tuningJobFromVertex(this.apiClient, apiResponse);
|
|
9668
|
+
return resp;
|
|
9669
|
+
});
|
|
9670
|
+
}
|
|
9671
|
+
else {
|
|
9672
|
+
const body = getTuningJobParametersToMldev(this.apiClient, params);
|
|
9673
|
+
path = formatMap('{name}', body['_url']);
|
|
9674
|
+
queryParams = body['_query'];
|
|
9675
|
+
delete body['config'];
|
|
9676
|
+
delete body['_url'];
|
|
9677
|
+
delete body['_query'];
|
|
9678
|
+
response = this.apiClient
|
|
9679
|
+
.request({
|
|
9680
|
+
path: path,
|
|
9681
|
+
queryParams: queryParams,
|
|
9682
|
+
body: JSON.stringify(body),
|
|
9683
|
+
httpMethod: 'GET',
|
|
9684
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
9685
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
9686
|
+
})
|
|
9687
|
+
.then((httpResponse) => {
|
|
9688
|
+
return httpResponse.json();
|
|
9689
|
+
});
|
|
9690
|
+
return response.then((apiResponse) => {
|
|
9691
|
+
const resp = tuningJobFromMldev(this.apiClient, apiResponse);
|
|
9692
|
+
return resp;
|
|
9693
|
+
});
|
|
9694
|
+
}
|
|
9695
|
+
}
|
|
9696
|
+
async listInternal(params) {
|
|
9697
|
+
var _a, _b, _c, _d;
|
|
9698
|
+
let response;
|
|
9699
|
+
let path = '';
|
|
9700
|
+
let queryParams = {};
|
|
9701
|
+
if (this.apiClient.isVertexAI()) {
|
|
9702
|
+
const body = listTuningJobsParametersToVertex(this.apiClient, params);
|
|
9703
|
+
path = formatMap('tuningJobs', body['_url']);
|
|
9704
|
+
queryParams = body['_query'];
|
|
9705
|
+
delete body['config'];
|
|
9706
|
+
delete body['_url'];
|
|
9707
|
+
delete body['_query'];
|
|
9708
|
+
response = this.apiClient
|
|
9709
|
+
.request({
|
|
9710
|
+
path: path,
|
|
9711
|
+
queryParams: queryParams,
|
|
9712
|
+
body: JSON.stringify(body),
|
|
9713
|
+
httpMethod: 'GET',
|
|
9714
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
9715
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
9716
|
+
})
|
|
9717
|
+
.then((httpResponse) => {
|
|
9718
|
+
return httpResponse.json();
|
|
9719
|
+
});
|
|
9720
|
+
return response.then((apiResponse) => {
|
|
9721
|
+
const resp = listTuningJobsResponseFromVertex(this.apiClient, apiResponse);
|
|
9722
|
+
const typedResp = new ListTuningJobsResponse();
|
|
9723
|
+
Object.assign(typedResp, resp);
|
|
9724
|
+
return typedResp;
|
|
9725
|
+
});
|
|
9726
|
+
}
|
|
9727
|
+
else {
|
|
9728
|
+
const body = listTuningJobsParametersToMldev(this.apiClient, params);
|
|
9729
|
+
path = formatMap('tunedModels', body['_url']);
|
|
9730
|
+
queryParams = body['_query'];
|
|
9731
|
+
delete body['config'];
|
|
9732
|
+
delete body['_url'];
|
|
9733
|
+
delete body['_query'];
|
|
9734
|
+
response = this.apiClient
|
|
9735
|
+
.request({
|
|
9736
|
+
path: path,
|
|
9737
|
+
queryParams: queryParams,
|
|
9738
|
+
body: JSON.stringify(body),
|
|
9739
|
+
httpMethod: 'GET',
|
|
9740
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
9741
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
9742
|
+
})
|
|
9743
|
+
.then((httpResponse) => {
|
|
9744
|
+
return httpResponse.json();
|
|
9745
|
+
});
|
|
9746
|
+
return response.then((apiResponse) => {
|
|
9747
|
+
const resp = listTuningJobsResponseFromMldev(this.apiClient, apiResponse);
|
|
9748
|
+
const typedResp = new ListTuningJobsResponse();
|
|
9749
|
+
Object.assign(typedResp, resp);
|
|
9750
|
+
return typedResp;
|
|
9751
|
+
});
|
|
9752
|
+
}
|
|
9753
|
+
}
|
|
9754
|
+
async tuneInternal(params) {
|
|
9755
|
+
var _a, _b;
|
|
9756
|
+
let response;
|
|
9757
|
+
let path = '';
|
|
9758
|
+
let queryParams = {};
|
|
9759
|
+
if (this.apiClient.isVertexAI()) {
|
|
9760
|
+
const body = createTuningJobParametersToVertex(this.apiClient, params);
|
|
9761
|
+
path = formatMap('tuningJobs', body['_url']);
|
|
9762
|
+
queryParams = body['_query'];
|
|
9763
|
+
delete body['config'];
|
|
9764
|
+
delete body['_url'];
|
|
9765
|
+
delete body['_query'];
|
|
9766
|
+
response = this.apiClient
|
|
9767
|
+
.request({
|
|
9768
|
+
path: path,
|
|
9769
|
+
queryParams: queryParams,
|
|
9770
|
+
body: JSON.stringify(body),
|
|
9771
|
+
httpMethod: 'POST',
|
|
9772
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
9773
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
9774
|
+
})
|
|
9775
|
+
.then((httpResponse) => {
|
|
9776
|
+
return httpResponse.json();
|
|
9777
|
+
});
|
|
9778
|
+
return response.then((apiResponse) => {
|
|
9779
|
+
const resp = tuningJobFromVertex(this.apiClient, apiResponse);
|
|
9780
|
+
return resp;
|
|
9781
|
+
});
|
|
9782
|
+
}
|
|
9783
|
+
else {
|
|
9784
|
+
throw new Error('This method is only supported by the Vertex AI.');
|
|
9785
|
+
}
|
|
9786
|
+
}
|
|
9787
|
+
async tuneMldevInternal(params) {
|
|
9788
|
+
var _a, _b;
|
|
9789
|
+
let response;
|
|
9790
|
+
let path = '';
|
|
9791
|
+
let queryParams = {};
|
|
9792
|
+
if (this.apiClient.isVertexAI()) {
|
|
9793
|
+
throw new Error('This method is only supported by the Gemini Developer API.');
|
|
9794
|
+
}
|
|
9795
|
+
else {
|
|
9796
|
+
const body = createTuningJobParametersToMldev(this.apiClient, params);
|
|
9797
|
+
path = formatMap('tunedModels', body['_url']);
|
|
9798
|
+
queryParams = body['_query'];
|
|
9799
|
+
delete body['config'];
|
|
9800
|
+
delete body['_url'];
|
|
9801
|
+
delete body['_query'];
|
|
9802
|
+
response = this.apiClient
|
|
9803
|
+
.request({
|
|
9804
|
+
path: path,
|
|
9805
|
+
queryParams: queryParams,
|
|
9806
|
+
body: JSON.stringify(body),
|
|
9807
|
+
httpMethod: 'POST',
|
|
9808
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
9809
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
9810
|
+
})
|
|
9811
|
+
.then((httpResponse) => {
|
|
9812
|
+
return httpResponse.json();
|
|
9813
|
+
});
|
|
9814
|
+
return response.then((apiResponse) => {
|
|
9815
|
+
const resp = operationFromMldev(this.apiClient, apiResponse);
|
|
9816
|
+
return resp;
|
|
9817
|
+
});
|
|
9818
|
+
}
|
|
9819
|
+
}
|
|
9820
|
+
}
|
|
9821
|
+
|
|
9411
9822
|
const MAX_CHUNK_SIZE = 1024 * 1024 * 8; // bytes
|
|
9412
9823
|
async function uploadBlob(file, uploadUrl, apiClient) {
|
|
9413
9824
|
var _a, _b;
|
|
@@ -9617,8 +10028,9 @@ class GoogleGenAI {
|
|
|
9617
10028
|
this.caches = new Caches(this.apiClient);
|
|
9618
10029
|
this.files = new Files(this.apiClient);
|
|
9619
10030
|
this.operations = new Operations(this.apiClient);
|
|
10031
|
+
this.tunings = new Tunings(this.apiClient);
|
|
9620
10032
|
}
|
|
9621
10033
|
}
|
|
9622
10034
|
|
|
9623
|
-
export { ActivityHandling, BlockedReason, Caches, Chat, Chats, ComputeTokensResponse, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DynamicRetrievalConfigMode, EmbedContentResponse, EndSensitivity, FeatureSelectionPreference, FileSource, FileState, Files, FinishReason, FunctionCallingConfigMode, FunctionResponse, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GenerateVideosResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpResponse, ImagePromptLanguage, Language, ListCachedContentsResponse, ListFilesResponse, Live, LiveClientToolResponse, LiveSendToolResponseParameters, MaskReferenceMode, MediaModality, MediaResolution, Modality, Mode, Models, Operations, Outcome, PagedItem, Pager, PersonGeneration, ReplayResponse, SafetyFilterLevel, Session, StartSensitivity, SubjectReferenceType, TrafficType, TurnCoverage, Type, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent, setDefaultBaseUrls };
|
|
10035
|
+
export { ActivityHandling, AdapterSize, BlockedReason, Caches, Chat, Chats, ComputeTokensResponse, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DeleteModelResponse, DynamicRetrievalConfigMode, EmbedContentResponse, EndSensitivity, FeatureSelectionPreference, FileSource, FileState, Files, FinishReason, FunctionCallingConfigMode, FunctionResponse, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GenerateVideosResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpResponse, ImagePromptLanguage, JobState, Language, ListCachedContentsResponse, ListFilesResponse, ListTuningJobsResponse, Live, LiveClientToolResponse, LiveSendToolResponseParameters, MaskReferenceMode, MediaModality, MediaResolution, Modality, Mode, Models, Operations, Outcome, PagedItem, Pager, PersonGeneration, ReplayResponse, SafetyFilterLevel, Session, StartSensitivity, SubjectReferenceType, TrafficType, TurnCoverage, Type, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent, setDefaultBaseUrls };
|
|
9624
10036
|
//# sourceMappingURL=index.mjs.map
|