@google/genai 0.10.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/genai.d.ts +576 -39
- package/dist/index.js +1320 -894
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1319 -895
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.js +1320 -894
- package/dist/node/index.js.map +1 -1
- package/dist/node/node.d.ts +576 -39
- package/dist/web/index.mjs +1319 -895
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +576 -39
- package/package.json +1 -1
package/dist/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) {
|
|
@@ -4502,6 +4236,12 @@ function liveServerContentFromMldev(apiClient, fromObject) {
|
|
|
4502
4236
|
if (fromInterrupted != null) {
|
|
4503
4237
|
setValueByPath(toObject, ['interrupted'], fromInterrupted);
|
|
4504
4238
|
}
|
|
4239
|
+
const fromGroundingMetadata = getValueByPath(fromObject, [
|
|
4240
|
+
'groundingMetadata',
|
|
4241
|
+
]);
|
|
4242
|
+
if (fromGroundingMetadata != null) {
|
|
4243
|
+
setValueByPath(toObject, ['groundingMetadata'], fromGroundingMetadata);
|
|
4244
|
+
}
|
|
4505
4245
|
const fromGenerationComplete = getValueByPath(fromObject, [
|
|
4506
4246
|
'generationComplete',
|
|
4507
4247
|
]);
|
|
@@ -4536,6 +4276,12 @@ function liveServerContentFromVertex(apiClient, fromObject) {
|
|
|
4536
4276
|
if (fromInterrupted != null) {
|
|
4537
4277
|
setValueByPath(toObject, ['interrupted'], fromInterrupted);
|
|
4538
4278
|
}
|
|
4279
|
+
const fromGroundingMetadata = getValueByPath(fromObject, [
|
|
4280
|
+
'groundingMetadata',
|
|
4281
|
+
]);
|
|
4282
|
+
if (fromGroundingMetadata != null) {
|
|
4283
|
+
setValueByPath(toObject, ['groundingMetadata'], fromGroundingMetadata);
|
|
4284
|
+
}
|
|
4539
4285
|
const fromGenerationComplete = getValueByPath(fromObject, [
|
|
4540
4286
|
'generationComplete',
|
|
4541
4287
|
]);
|
|
@@ -4590,14 +4336,13 @@ function liveServerToolCallFromMldev(apiClient, fromObject) {
|
|
|
4590
4336
|
'functionCalls',
|
|
4591
4337
|
]);
|
|
4592
4338
|
if (fromFunctionCalls != null) {
|
|
4593
|
-
|
|
4594
|
-
|
|
4339
|
+
let transformedList = fromFunctionCalls;
|
|
4340
|
+
if (Array.isArray(transformedList)) {
|
|
4341
|
+
transformedList = transformedList.map((item) => {
|
|
4595
4342
|
return functionCallFromMldev(apiClient, item);
|
|
4596
|
-
})
|
|
4597
|
-
}
|
|
4598
|
-
else {
|
|
4599
|
-
setValueByPath(toObject, ['functionCalls'], fromFunctionCalls);
|
|
4343
|
+
});
|
|
4600
4344
|
}
|
|
4345
|
+
setValueByPath(toObject, ['functionCalls'], transformedList);
|
|
4601
4346
|
}
|
|
4602
4347
|
return toObject;
|
|
4603
4348
|
}
|
|
@@ -4607,14 +4352,13 @@ function liveServerToolCallFromVertex(apiClient, fromObject) {
|
|
|
4607
4352
|
'functionCalls',
|
|
4608
4353
|
]);
|
|
4609
4354
|
if (fromFunctionCalls != null) {
|
|
4610
|
-
|
|
4611
|
-
|
|
4355
|
+
let transformedList = fromFunctionCalls;
|
|
4356
|
+
if (Array.isArray(transformedList)) {
|
|
4357
|
+
transformedList = transformedList.map((item) => {
|
|
4612
4358
|
return functionCallFromVertex(apiClient, item);
|
|
4613
|
-
})
|
|
4614
|
-
}
|
|
4615
|
-
else {
|
|
4616
|
-
setValueByPath(toObject, ['functionCalls'], fromFunctionCalls);
|
|
4359
|
+
});
|
|
4617
4360
|
}
|
|
4361
|
+
setValueByPath(toObject, ['functionCalls'], transformedList);
|
|
4618
4362
|
}
|
|
4619
4363
|
return toObject;
|
|
4620
4364
|
}
|
|
@@ -4700,53 +4444,49 @@ function usageMetadataFromMldev(apiClient, fromObject) {
|
|
|
4700
4444
|
'promptTokensDetails',
|
|
4701
4445
|
]);
|
|
4702
4446
|
if (fromPromptTokensDetails != null) {
|
|
4703
|
-
|
|
4704
|
-
|
|
4447
|
+
let transformedList = fromPromptTokensDetails;
|
|
4448
|
+
if (Array.isArray(transformedList)) {
|
|
4449
|
+
transformedList = transformedList.map((item) => {
|
|
4705
4450
|
return modalityTokenCountFromMldev(apiClient, item);
|
|
4706
|
-
})
|
|
4707
|
-
}
|
|
4708
|
-
else {
|
|
4709
|
-
setValueByPath(toObject, ['promptTokensDetails'], fromPromptTokensDetails);
|
|
4451
|
+
});
|
|
4710
4452
|
}
|
|
4453
|
+
setValueByPath(toObject, ['promptTokensDetails'], transformedList);
|
|
4711
4454
|
}
|
|
4712
4455
|
const fromCacheTokensDetails = getValueByPath(fromObject, [
|
|
4713
4456
|
'cacheTokensDetails',
|
|
4714
4457
|
]);
|
|
4715
4458
|
if (fromCacheTokensDetails != null) {
|
|
4716
|
-
|
|
4717
|
-
|
|
4459
|
+
let transformedList = fromCacheTokensDetails;
|
|
4460
|
+
if (Array.isArray(transformedList)) {
|
|
4461
|
+
transformedList = transformedList.map((item) => {
|
|
4718
4462
|
return modalityTokenCountFromMldev(apiClient, item);
|
|
4719
|
-
})
|
|
4720
|
-
}
|
|
4721
|
-
else {
|
|
4722
|
-
setValueByPath(toObject, ['cacheTokensDetails'], fromCacheTokensDetails);
|
|
4463
|
+
});
|
|
4723
4464
|
}
|
|
4465
|
+
setValueByPath(toObject, ['cacheTokensDetails'], transformedList);
|
|
4724
4466
|
}
|
|
4725
4467
|
const fromResponseTokensDetails = getValueByPath(fromObject, [
|
|
4726
4468
|
'responseTokensDetails',
|
|
4727
4469
|
]);
|
|
4728
4470
|
if (fromResponseTokensDetails != null) {
|
|
4729
|
-
|
|
4730
|
-
|
|
4471
|
+
let transformedList = fromResponseTokensDetails;
|
|
4472
|
+
if (Array.isArray(transformedList)) {
|
|
4473
|
+
transformedList = transformedList.map((item) => {
|
|
4731
4474
|
return modalityTokenCountFromMldev(apiClient, item);
|
|
4732
|
-
})
|
|
4733
|
-
}
|
|
4734
|
-
else {
|
|
4735
|
-
setValueByPath(toObject, ['responseTokensDetails'], fromResponseTokensDetails);
|
|
4475
|
+
});
|
|
4736
4476
|
}
|
|
4477
|
+
setValueByPath(toObject, ['responseTokensDetails'], transformedList);
|
|
4737
4478
|
}
|
|
4738
4479
|
const fromToolUsePromptTokensDetails = getValueByPath(fromObject, [
|
|
4739
4480
|
'toolUsePromptTokensDetails',
|
|
4740
4481
|
]);
|
|
4741
4482
|
if (fromToolUsePromptTokensDetails != null) {
|
|
4742
|
-
|
|
4743
|
-
|
|
4483
|
+
let transformedList = fromToolUsePromptTokensDetails;
|
|
4484
|
+
if (Array.isArray(transformedList)) {
|
|
4485
|
+
transformedList = transformedList.map((item) => {
|
|
4744
4486
|
return modalityTokenCountFromMldev(apiClient, item);
|
|
4745
|
-
})
|
|
4746
|
-
}
|
|
4747
|
-
else {
|
|
4748
|
-
setValueByPath(toObject, ['toolUsePromptTokensDetails'], fromToolUsePromptTokensDetails);
|
|
4487
|
+
});
|
|
4749
4488
|
}
|
|
4489
|
+
setValueByPath(toObject, ['toolUsePromptTokensDetails'], transformedList);
|
|
4750
4490
|
}
|
|
4751
4491
|
return toObject;
|
|
4752
4492
|
}
|
|
@@ -4792,53 +4532,49 @@ function usageMetadataFromVertex(apiClient, fromObject) {
|
|
|
4792
4532
|
'promptTokensDetails',
|
|
4793
4533
|
]);
|
|
4794
4534
|
if (fromPromptTokensDetails != null) {
|
|
4795
|
-
|
|
4796
|
-
|
|
4535
|
+
let transformedList = fromPromptTokensDetails;
|
|
4536
|
+
if (Array.isArray(transformedList)) {
|
|
4537
|
+
transformedList = transformedList.map((item) => {
|
|
4797
4538
|
return modalityTokenCountFromVertex(apiClient, item);
|
|
4798
|
-
})
|
|
4799
|
-
}
|
|
4800
|
-
else {
|
|
4801
|
-
setValueByPath(toObject, ['promptTokensDetails'], fromPromptTokensDetails);
|
|
4539
|
+
});
|
|
4802
4540
|
}
|
|
4541
|
+
setValueByPath(toObject, ['promptTokensDetails'], transformedList);
|
|
4803
4542
|
}
|
|
4804
4543
|
const fromCacheTokensDetails = getValueByPath(fromObject, [
|
|
4805
4544
|
'cacheTokensDetails',
|
|
4806
4545
|
]);
|
|
4807
4546
|
if (fromCacheTokensDetails != null) {
|
|
4808
|
-
|
|
4809
|
-
|
|
4547
|
+
let transformedList = fromCacheTokensDetails;
|
|
4548
|
+
if (Array.isArray(transformedList)) {
|
|
4549
|
+
transformedList = transformedList.map((item) => {
|
|
4810
4550
|
return modalityTokenCountFromVertex(apiClient, item);
|
|
4811
|
-
})
|
|
4812
|
-
}
|
|
4813
|
-
else {
|
|
4814
|
-
setValueByPath(toObject, ['cacheTokensDetails'], fromCacheTokensDetails);
|
|
4551
|
+
});
|
|
4815
4552
|
}
|
|
4553
|
+
setValueByPath(toObject, ['cacheTokensDetails'], transformedList);
|
|
4816
4554
|
}
|
|
4817
4555
|
const fromResponseTokensDetails = getValueByPath(fromObject, [
|
|
4818
4556
|
'candidatesTokensDetails',
|
|
4819
4557
|
]);
|
|
4820
4558
|
if (fromResponseTokensDetails != null) {
|
|
4821
|
-
|
|
4822
|
-
|
|
4559
|
+
let transformedList = fromResponseTokensDetails;
|
|
4560
|
+
if (Array.isArray(transformedList)) {
|
|
4561
|
+
transformedList = transformedList.map((item) => {
|
|
4823
4562
|
return modalityTokenCountFromVertex(apiClient, item);
|
|
4824
|
-
})
|
|
4825
|
-
}
|
|
4826
|
-
else {
|
|
4827
|
-
setValueByPath(toObject, ['responseTokensDetails'], fromResponseTokensDetails);
|
|
4563
|
+
});
|
|
4828
4564
|
}
|
|
4565
|
+
setValueByPath(toObject, ['responseTokensDetails'], transformedList);
|
|
4829
4566
|
}
|
|
4830
4567
|
const fromToolUsePromptTokensDetails = getValueByPath(fromObject, [
|
|
4831
4568
|
'toolUsePromptTokensDetails',
|
|
4832
4569
|
]);
|
|
4833
4570
|
if (fromToolUsePromptTokensDetails != null) {
|
|
4834
|
-
|
|
4835
|
-
|
|
4571
|
+
let transformedList = fromToolUsePromptTokensDetails;
|
|
4572
|
+
if (Array.isArray(transformedList)) {
|
|
4573
|
+
transformedList = transformedList.map((item) => {
|
|
4836
4574
|
return modalityTokenCountFromVertex(apiClient, item);
|
|
4837
|
-
})
|
|
4838
|
-
}
|
|
4839
|
-
else {
|
|
4840
|
-
setValueByPath(toObject, ['toolUsePromptTokensDetails'], fromToolUsePromptTokensDetails);
|
|
4575
|
+
});
|
|
4841
4576
|
}
|
|
4577
|
+
setValueByPath(toObject, ['toolUsePromptTokensDetails'], transformedList);
|
|
4842
4578
|
}
|
|
4843
4579
|
const fromTrafficType = getValueByPath(fromObject, ['trafficType']);
|
|
4844
4580
|
if (fromTrafficType != null) {
|
|
@@ -5037,14 +4773,13 @@ function contentToMldev(apiClient, fromObject) {
|
|
|
5037
4773
|
const toObject = {};
|
|
5038
4774
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
5039
4775
|
if (fromParts != null) {
|
|
5040
|
-
|
|
5041
|
-
|
|
4776
|
+
let transformedList = fromParts;
|
|
4777
|
+
if (Array.isArray(transformedList)) {
|
|
4778
|
+
transformedList = transformedList.map((item) => {
|
|
5042
4779
|
return partToMldev(apiClient, item);
|
|
5043
|
-
})
|
|
5044
|
-
}
|
|
5045
|
-
else {
|
|
5046
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
4780
|
+
});
|
|
5047
4781
|
}
|
|
4782
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
5048
4783
|
}
|
|
5049
4784
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
5050
4785
|
if (fromRole != null) {
|
|
@@ -5052,93 +4787,6 @@ function contentToMldev(apiClient, fromObject) {
|
|
|
5052
4787
|
}
|
|
5053
4788
|
return toObject;
|
|
5054
4789
|
}
|
|
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
4790
|
function safetySettingToMldev(apiClient, fromObject) {
|
|
5143
4791
|
const toObject = {};
|
|
5144
4792
|
if (getValueByPath(fromObject, ['method']) !== undefined) {
|
|
@@ -5154,25 +4802,6 @@ function safetySettingToMldev(apiClient, fromObject) {
|
|
|
5154
4802
|
}
|
|
5155
4803
|
return toObject;
|
|
5156
4804
|
}
|
|
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
4805
|
function googleSearchToMldev() {
|
|
5177
4806
|
const toObject = {};
|
|
5178
4807
|
return toObject;
|
|
@@ -5203,19 +4832,6 @@ function googleSearchRetrievalToMldev(apiClient, fromObject) {
|
|
|
5203
4832
|
}
|
|
5204
4833
|
function toolToMldev(apiClient, fromObject) {
|
|
5205
4834
|
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
4835
|
if (getValueByPath(fromObject, ['retrieval']) !== undefined) {
|
|
5220
4836
|
throw new Error('retrieval parameter is not supported in Gemini API.');
|
|
5221
4837
|
}
|
|
@@ -5235,6 +4851,12 @@ function toolToMldev(apiClient, fromObject) {
|
|
|
5235
4851
|
if (fromCodeExecution != null) {
|
|
5236
4852
|
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
5237
4853
|
}
|
|
4854
|
+
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
4855
|
+
'functionDeclarations',
|
|
4856
|
+
]);
|
|
4857
|
+
if (fromFunctionDeclarations != null) {
|
|
4858
|
+
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
4859
|
+
}
|
|
5238
4860
|
return toObject;
|
|
5239
4861
|
}
|
|
5240
4862
|
function functionCallingConfigToMldev(apiClient, fromObject) {
|
|
@@ -5381,7 +5003,7 @@ function generateContentConfigToMldev(apiClient, fromObject, parentObject) {
|
|
|
5381
5003
|
'responseSchema',
|
|
5382
5004
|
]);
|
|
5383
5005
|
if (fromResponseSchema != null) {
|
|
5384
|
-
setValueByPath(toObject, ['responseSchema'],
|
|
5006
|
+
setValueByPath(toObject, ['responseSchema'], tSchema(apiClient, fromResponseSchema));
|
|
5385
5007
|
}
|
|
5386
5008
|
if (getValueByPath(fromObject, ['routingConfig']) !== undefined) {
|
|
5387
5009
|
throw new Error('routingConfig parameter is not supported in Gemini API.');
|
|
@@ -5393,25 +5015,23 @@ function generateContentConfigToMldev(apiClient, fromObject, parentObject) {
|
|
|
5393
5015
|
'safetySettings',
|
|
5394
5016
|
]);
|
|
5395
5017
|
if (parentObject !== undefined && fromSafetySettings != null) {
|
|
5396
|
-
|
|
5397
|
-
|
|
5018
|
+
let transformedList = fromSafetySettings;
|
|
5019
|
+
if (Array.isArray(transformedList)) {
|
|
5020
|
+
transformedList = transformedList.map((item) => {
|
|
5398
5021
|
return safetySettingToMldev(apiClient, item);
|
|
5399
|
-
})
|
|
5400
|
-
}
|
|
5401
|
-
else {
|
|
5402
|
-
setValueByPath(parentObject, ['safetySettings'], fromSafetySettings);
|
|
5022
|
+
});
|
|
5403
5023
|
}
|
|
5024
|
+
setValueByPath(parentObject, ['safetySettings'], transformedList);
|
|
5404
5025
|
}
|
|
5405
5026
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
5406
5027
|
if (parentObject !== undefined && fromTools != null) {
|
|
5407
|
-
|
|
5408
|
-
|
|
5028
|
+
let transformedList = tTools(apiClient, fromTools);
|
|
5029
|
+
if (Array.isArray(transformedList)) {
|
|
5030
|
+
transformedList = transformedList.map((item) => {
|
|
5409
5031
|
return toolToMldev(apiClient, tTool(apiClient, item));
|
|
5410
|
-
})
|
|
5411
|
-
}
|
|
5412
|
-
else {
|
|
5413
|
-
setValueByPath(parentObject, ['tools'], tTools(apiClient, fromTools));
|
|
5032
|
+
});
|
|
5414
5033
|
}
|
|
5034
|
+
setValueByPath(parentObject, ['tools'], transformedList);
|
|
5415
5035
|
}
|
|
5416
5036
|
const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
|
|
5417
5037
|
if (parentObject !== undefined && fromToolConfig != null) {
|
|
@@ -5461,14 +5081,13 @@ function generateContentParametersToMldev(apiClient, fromObject) {
|
|
|
5461
5081
|
}
|
|
5462
5082
|
const fromContents = getValueByPath(fromObject, ['contents']);
|
|
5463
5083
|
if (fromContents != null) {
|
|
5464
|
-
|
|
5465
|
-
|
|
5084
|
+
let transformedList = tContents(apiClient, fromContents);
|
|
5085
|
+
if (Array.isArray(transformedList)) {
|
|
5086
|
+
transformedList = transformedList.map((item) => {
|
|
5466
5087
|
return contentToMldev(apiClient, item);
|
|
5467
|
-
})
|
|
5468
|
-
}
|
|
5469
|
-
else {
|
|
5470
|
-
setValueByPath(toObject, ['contents'], tContents(apiClient, fromContents));
|
|
5088
|
+
});
|
|
5471
5089
|
}
|
|
5090
|
+
setValueByPath(toObject, ['contents'], transformedList);
|
|
5472
5091
|
}
|
|
5473
5092
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
5474
5093
|
if (fromConfig != null) {
|
|
@@ -5623,6 +5242,42 @@ function getModelParametersToMldev(apiClient, fromObject) {
|
|
|
5623
5242
|
}
|
|
5624
5243
|
return toObject;
|
|
5625
5244
|
}
|
|
5245
|
+
function updateModelConfigToMldev(apiClient, fromObject, parentObject) {
|
|
5246
|
+
const toObject = {};
|
|
5247
|
+
const fromDisplayName = getValueByPath(fromObject, ['displayName']);
|
|
5248
|
+
if (parentObject !== undefined && fromDisplayName != null) {
|
|
5249
|
+
setValueByPath(parentObject, ['displayName'], fromDisplayName);
|
|
5250
|
+
}
|
|
5251
|
+
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
5252
|
+
if (parentObject !== undefined && fromDescription != null) {
|
|
5253
|
+
setValueByPath(parentObject, ['description'], fromDescription);
|
|
5254
|
+
}
|
|
5255
|
+
return toObject;
|
|
5256
|
+
}
|
|
5257
|
+
function updateModelParametersToMldev(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'], updateModelConfigToMldev(apiClient, fromConfig, toObject));
|
|
5266
|
+
}
|
|
5267
|
+
return toObject;
|
|
5268
|
+
}
|
|
5269
|
+
function deleteModelParametersToMldev(apiClient, fromObject) {
|
|
5270
|
+
const toObject = {};
|
|
5271
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
5272
|
+
if (fromModel != null) {
|
|
5273
|
+
setValueByPath(toObject, ['_url', 'name'], tModel(apiClient, fromModel));
|
|
5274
|
+
}
|
|
5275
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
5276
|
+
if (fromConfig != null) {
|
|
5277
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
5278
|
+
}
|
|
5279
|
+
return toObject;
|
|
5280
|
+
}
|
|
5626
5281
|
function countTokensConfigToMldev(apiClient, fromObject) {
|
|
5627
5282
|
const toObject = {};
|
|
5628
5283
|
if (getValueByPath(fromObject, ['systemInstruction']) !== undefined) {
|
|
@@ -5644,14 +5299,13 @@ function countTokensParametersToMldev(apiClient, fromObject) {
|
|
|
5644
5299
|
}
|
|
5645
5300
|
const fromContents = getValueByPath(fromObject, ['contents']);
|
|
5646
5301
|
if (fromContents != null) {
|
|
5647
|
-
|
|
5648
|
-
|
|
5302
|
+
let transformedList = tContents(apiClient, fromContents);
|
|
5303
|
+
if (Array.isArray(transformedList)) {
|
|
5304
|
+
transformedList = transformedList.map((item) => {
|
|
5649
5305
|
return contentToMldev(apiClient, item);
|
|
5650
|
-
})
|
|
5651
|
-
}
|
|
5652
|
-
else {
|
|
5653
|
-
setValueByPath(toObject, ['contents'], tContents(apiClient, fromContents));
|
|
5306
|
+
});
|
|
5654
5307
|
}
|
|
5308
|
+
setValueByPath(toObject, ['contents'], transformedList);
|
|
5655
5309
|
}
|
|
5656
5310
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
5657
5311
|
if (fromConfig != null) {
|
|
@@ -5796,14 +5450,13 @@ function contentToVertex(apiClient, fromObject) {
|
|
|
5796
5450
|
const toObject = {};
|
|
5797
5451
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
5798
5452
|
if (fromParts != null) {
|
|
5799
|
-
|
|
5800
|
-
|
|
5453
|
+
let transformedList = fromParts;
|
|
5454
|
+
if (Array.isArray(transformedList)) {
|
|
5455
|
+
transformedList = transformedList.map((item) => {
|
|
5801
5456
|
return partToVertex(apiClient, item);
|
|
5802
|
-
})
|
|
5803
|
-
}
|
|
5804
|
-
else {
|
|
5805
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
5457
|
+
});
|
|
5806
5458
|
}
|
|
5459
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
5807
5460
|
}
|
|
5808
5461
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
5809
5462
|
if (fromRole != null) {
|
|
@@ -5811,104 +5464,6 @@ function contentToVertex(apiClient, fromObject) {
|
|
|
5811
5464
|
}
|
|
5812
5465
|
return toObject;
|
|
5813
5466
|
}
|
|
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
5467
|
function modelSelectionConfigToVertex(apiClient, fromObject) {
|
|
5913
5468
|
const toObject = {};
|
|
5914
5469
|
const fromFeatureSelectionPreference = getValueByPath(fromObject, [
|
|
@@ -5935,26 +5490,6 @@ function safetySettingToVertex(apiClient, fromObject) {
|
|
|
5935
5490
|
}
|
|
5936
5491
|
return toObject;
|
|
5937
5492
|
}
|
|
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
5493
|
function googleSearchToVertex() {
|
|
5959
5494
|
const toObject = {};
|
|
5960
5495
|
return toObject;
|
|
@@ -5985,19 +5520,6 @@ function googleSearchRetrievalToVertex(apiClient, fromObject) {
|
|
|
5985
5520
|
}
|
|
5986
5521
|
function toolToVertex(apiClient, fromObject) {
|
|
5987
5522
|
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
5523
|
const fromRetrieval = getValueByPath(fromObject, ['retrieval']);
|
|
6002
5524
|
if (fromRetrieval != null) {
|
|
6003
5525
|
setValueByPath(toObject, ['retrieval'], fromRetrieval);
|
|
@@ -6018,6 +5540,12 @@ function toolToVertex(apiClient, fromObject) {
|
|
|
6018
5540
|
if (fromCodeExecution != null) {
|
|
6019
5541
|
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
6020
5542
|
}
|
|
5543
|
+
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
5544
|
+
'functionDeclarations',
|
|
5545
|
+
]);
|
|
5546
|
+
if (fromFunctionDeclarations != null) {
|
|
5547
|
+
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
5548
|
+
}
|
|
6021
5549
|
return toObject;
|
|
6022
5550
|
}
|
|
6023
5551
|
function functionCallingConfigToVertex(apiClient, fromObject) {
|
|
@@ -6164,7 +5692,7 @@ function generateContentConfigToVertex(apiClient, fromObject, parentObject) {
|
|
|
6164
5692
|
'responseSchema',
|
|
6165
5693
|
]);
|
|
6166
5694
|
if (fromResponseSchema != null) {
|
|
6167
|
-
setValueByPath(toObject, ['responseSchema'],
|
|
5695
|
+
setValueByPath(toObject, ['responseSchema'], tSchema(apiClient, fromResponseSchema));
|
|
6168
5696
|
}
|
|
6169
5697
|
const fromRoutingConfig = getValueByPath(fromObject, [
|
|
6170
5698
|
'routingConfig',
|
|
@@ -6182,25 +5710,23 @@ function generateContentConfigToVertex(apiClient, fromObject, parentObject) {
|
|
|
6182
5710
|
'safetySettings',
|
|
6183
5711
|
]);
|
|
6184
5712
|
if (parentObject !== undefined && fromSafetySettings != null) {
|
|
6185
|
-
|
|
6186
|
-
|
|
5713
|
+
let transformedList = fromSafetySettings;
|
|
5714
|
+
if (Array.isArray(transformedList)) {
|
|
5715
|
+
transformedList = transformedList.map((item) => {
|
|
6187
5716
|
return safetySettingToVertex(apiClient, item);
|
|
6188
|
-
})
|
|
6189
|
-
}
|
|
6190
|
-
else {
|
|
6191
|
-
setValueByPath(parentObject, ['safetySettings'], fromSafetySettings);
|
|
5717
|
+
});
|
|
6192
5718
|
}
|
|
5719
|
+
setValueByPath(parentObject, ['safetySettings'], transformedList);
|
|
6193
5720
|
}
|
|
6194
5721
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
6195
5722
|
if (parentObject !== undefined && fromTools != null) {
|
|
6196
|
-
|
|
6197
|
-
|
|
5723
|
+
let transformedList = tTools(apiClient, fromTools);
|
|
5724
|
+
if (Array.isArray(transformedList)) {
|
|
5725
|
+
transformedList = transformedList.map((item) => {
|
|
6198
5726
|
return toolToVertex(apiClient, tTool(apiClient, item));
|
|
6199
|
-
})
|
|
6200
|
-
}
|
|
6201
|
-
else {
|
|
6202
|
-
setValueByPath(parentObject, ['tools'], tTools(apiClient, fromTools));
|
|
5727
|
+
});
|
|
6203
5728
|
}
|
|
5729
|
+
setValueByPath(parentObject, ['tools'], transformedList);
|
|
6204
5730
|
}
|
|
6205
5731
|
const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
|
|
6206
5732
|
if (parentObject !== undefined && fromToolConfig != null) {
|
|
@@ -6254,14 +5780,13 @@ function generateContentParametersToVertex(apiClient, fromObject) {
|
|
|
6254
5780
|
}
|
|
6255
5781
|
const fromContents = getValueByPath(fromObject, ['contents']);
|
|
6256
5782
|
if (fromContents != null) {
|
|
6257
|
-
|
|
6258
|
-
|
|
5783
|
+
let transformedList = tContents(apiClient, fromContents);
|
|
5784
|
+
if (Array.isArray(transformedList)) {
|
|
5785
|
+
transformedList = transformedList.map((item) => {
|
|
6259
5786
|
return contentToVertex(apiClient, item);
|
|
6260
|
-
})
|
|
6261
|
-
}
|
|
6262
|
-
else {
|
|
6263
|
-
setValueByPath(toObject, ['contents'], tContents(apiClient, fromContents));
|
|
5787
|
+
});
|
|
6264
5788
|
}
|
|
5789
|
+
setValueByPath(toObject, ['contents'], transformedList);
|
|
6265
5790
|
}
|
|
6266
5791
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
6267
5792
|
if (fromConfig != null) {
|
|
@@ -6423,6 +5948,42 @@ function getModelParametersToVertex(apiClient, fromObject) {
|
|
|
6423
5948
|
}
|
|
6424
5949
|
return toObject;
|
|
6425
5950
|
}
|
|
5951
|
+
function updateModelConfigToVertex(apiClient, fromObject, parentObject) {
|
|
5952
|
+
const toObject = {};
|
|
5953
|
+
const fromDisplayName = getValueByPath(fromObject, ['displayName']);
|
|
5954
|
+
if (parentObject !== undefined && fromDisplayName != null) {
|
|
5955
|
+
setValueByPath(parentObject, ['displayName'], fromDisplayName);
|
|
5956
|
+
}
|
|
5957
|
+
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
5958
|
+
if (parentObject !== undefined && fromDescription != null) {
|
|
5959
|
+
setValueByPath(parentObject, ['description'], fromDescription);
|
|
5960
|
+
}
|
|
5961
|
+
return toObject;
|
|
5962
|
+
}
|
|
5963
|
+
function updateModelParametersToVertex(apiClient, fromObject) {
|
|
5964
|
+
const toObject = {};
|
|
5965
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
5966
|
+
if (fromModel != null) {
|
|
5967
|
+
setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
|
|
5968
|
+
}
|
|
5969
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
5970
|
+
if (fromConfig != null) {
|
|
5971
|
+
setValueByPath(toObject, ['config'], updateModelConfigToVertex(apiClient, fromConfig, toObject));
|
|
5972
|
+
}
|
|
5973
|
+
return toObject;
|
|
5974
|
+
}
|
|
5975
|
+
function deleteModelParametersToVertex(apiClient, fromObject) {
|
|
5976
|
+
const toObject = {};
|
|
5977
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
5978
|
+
if (fromModel != null) {
|
|
5979
|
+
setValueByPath(toObject, ['_url', 'name'], tModel(apiClient, fromModel));
|
|
5980
|
+
}
|
|
5981
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
5982
|
+
if (fromConfig != null) {
|
|
5983
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
5984
|
+
}
|
|
5985
|
+
return toObject;
|
|
5986
|
+
}
|
|
6426
5987
|
function countTokensConfigToVertex(apiClient, fromObject, parentObject) {
|
|
6427
5988
|
const toObject = {};
|
|
6428
5989
|
const fromSystemInstruction = getValueByPath(fromObject, [
|
|
@@ -6433,14 +5994,13 @@ function countTokensConfigToVertex(apiClient, fromObject, parentObject) {
|
|
|
6433
5994
|
}
|
|
6434
5995
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
6435
5996
|
if (parentObject !== undefined && fromTools != null) {
|
|
6436
|
-
|
|
6437
|
-
|
|
5997
|
+
let transformedList = fromTools;
|
|
5998
|
+
if (Array.isArray(transformedList)) {
|
|
5999
|
+
transformedList = transformedList.map((item) => {
|
|
6438
6000
|
return toolToVertex(apiClient, item);
|
|
6439
|
-
})
|
|
6440
|
-
}
|
|
6441
|
-
else {
|
|
6442
|
-
setValueByPath(parentObject, ['tools'], fromTools);
|
|
6001
|
+
});
|
|
6443
6002
|
}
|
|
6003
|
+
setValueByPath(parentObject, ['tools'], transformedList);
|
|
6444
6004
|
}
|
|
6445
6005
|
const fromGenerationConfig = getValueByPath(fromObject, [
|
|
6446
6006
|
'generationConfig',
|
|
@@ -6458,14 +6018,13 @@ function countTokensParametersToVertex(apiClient, fromObject) {
|
|
|
6458
6018
|
}
|
|
6459
6019
|
const fromContents = getValueByPath(fromObject, ['contents']);
|
|
6460
6020
|
if (fromContents != null) {
|
|
6461
|
-
|
|
6462
|
-
|
|
6021
|
+
let transformedList = tContents(apiClient, fromContents);
|
|
6022
|
+
if (Array.isArray(transformedList)) {
|
|
6023
|
+
transformedList = transformedList.map((item) => {
|
|
6463
6024
|
return contentToVertex(apiClient, item);
|
|
6464
|
-
})
|
|
6465
|
-
}
|
|
6466
|
-
else {
|
|
6467
|
-
setValueByPath(toObject, ['contents'], tContents(apiClient, fromContents));
|
|
6025
|
+
});
|
|
6468
6026
|
}
|
|
6027
|
+
setValueByPath(toObject, ['contents'], transformedList);
|
|
6469
6028
|
}
|
|
6470
6029
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
6471
6030
|
if (fromConfig != null) {
|
|
@@ -6481,14 +6040,13 @@ function computeTokensParametersToVertex(apiClient, fromObject) {
|
|
|
6481
6040
|
}
|
|
6482
6041
|
const fromContents = getValueByPath(fromObject, ['contents']);
|
|
6483
6042
|
if (fromContents != null) {
|
|
6484
|
-
|
|
6485
|
-
|
|
6043
|
+
let transformedList = tContents(apiClient, fromContents);
|
|
6044
|
+
if (Array.isArray(transformedList)) {
|
|
6045
|
+
transformedList = transformedList.map((item) => {
|
|
6486
6046
|
return contentToVertex(apiClient, item);
|
|
6487
|
-
})
|
|
6488
|
-
}
|
|
6489
|
-
else {
|
|
6490
|
-
setValueByPath(toObject, ['contents'], tContents(apiClient, fromContents));
|
|
6047
|
+
});
|
|
6491
6048
|
}
|
|
6049
|
+
setValueByPath(toObject, ['contents'], transformedList);
|
|
6492
6050
|
}
|
|
6493
6051
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
6494
6052
|
if (fromConfig != null) {
|
|
@@ -6636,14 +6194,13 @@ function contentFromMldev(apiClient, fromObject) {
|
|
|
6636
6194
|
const toObject = {};
|
|
6637
6195
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
6638
6196
|
if (fromParts != null) {
|
|
6639
|
-
|
|
6640
|
-
|
|
6197
|
+
let transformedList = fromParts;
|
|
6198
|
+
if (Array.isArray(transformedList)) {
|
|
6199
|
+
transformedList = transformedList.map((item) => {
|
|
6641
6200
|
return partFromMldev(apiClient, item);
|
|
6642
|
-
})
|
|
6643
|
-
}
|
|
6644
|
-
else {
|
|
6645
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
6201
|
+
});
|
|
6646
6202
|
}
|
|
6203
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
6647
6204
|
}
|
|
6648
6205
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
6649
6206
|
if (fromRole != null) {
|
|
@@ -6711,14 +6268,13 @@ function generateContentResponseFromMldev(apiClient, fromObject) {
|
|
|
6711
6268
|
const toObject = {};
|
|
6712
6269
|
const fromCandidates = getValueByPath(fromObject, ['candidates']);
|
|
6713
6270
|
if (fromCandidates != null) {
|
|
6714
|
-
|
|
6715
|
-
|
|
6271
|
+
let transformedList = fromCandidates;
|
|
6272
|
+
if (Array.isArray(transformedList)) {
|
|
6273
|
+
transformedList = transformedList.map((item) => {
|
|
6716
6274
|
return candidateFromMldev(apiClient, item);
|
|
6717
|
-
})
|
|
6718
|
-
}
|
|
6719
|
-
else {
|
|
6720
|
-
setValueByPath(toObject, ['candidates'], fromCandidates);
|
|
6275
|
+
});
|
|
6721
6276
|
}
|
|
6277
|
+
setValueByPath(toObject, ['candidates'], transformedList);
|
|
6722
6278
|
}
|
|
6723
6279
|
const fromModelVersion = getValueByPath(fromObject, ['modelVersion']);
|
|
6724
6280
|
if (fromModelVersion != null) {
|
|
@@ -6754,14 +6310,13 @@ function embedContentResponseFromMldev(apiClient, fromObject) {
|
|
|
6754
6310
|
const toObject = {};
|
|
6755
6311
|
const fromEmbeddings = getValueByPath(fromObject, ['embeddings']);
|
|
6756
6312
|
if (fromEmbeddings != null) {
|
|
6757
|
-
|
|
6758
|
-
|
|
6313
|
+
let transformedList = fromEmbeddings;
|
|
6314
|
+
if (Array.isArray(transformedList)) {
|
|
6315
|
+
transformedList = transformedList.map((item) => {
|
|
6759
6316
|
return contentEmbeddingFromMldev(apiClient, item);
|
|
6760
|
-
})
|
|
6761
|
-
}
|
|
6762
|
-
else {
|
|
6763
|
-
setValueByPath(toObject, ['embeddings'], fromEmbeddings);
|
|
6317
|
+
});
|
|
6764
6318
|
}
|
|
6319
|
+
setValueByPath(toObject, ['embeddings'], transformedList);
|
|
6765
6320
|
}
|
|
6766
6321
|
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
6767
6322
|
if (fromMetadata != null) {
|
|
@@ -6829,14 +6384,13 @@ function generateImagesResponseFromMldev(apiClient, fromObject) {
|
|
|
6829
6384
|
'predictions',
|
|
6830
6385
|
]);
|
|
6831
6386
|
if (fromGeneratedImages != null) {
|
|
6832
|
-
|
|
6833
|
-
|
|
6387
|
+
let transformedList = fromGeneratedImages;
|
|
6388
|
+
if (Array.isArray(transformedList)) {
|
|
6389
|
+
transformedList = transformedList.map((item) => {
|
|
6834
6390
|
return generatedImageFromMldev(apiClient, item);
|
|
6835
|
-
})
|
|
6836
|
-
}
|
|
6837
|
-
else {
|
|
6838
|
-
setValueByPath(toObject, ['generatedImages'], fromGeneratedImages);
|
|
6391
|
+
});
|
|
6839
6392
|
}
|
|
6393
|
+
setValueByPath(toObject, ['generatedImages'], transformedList);
|
|
6840
6394
|
}
|
|
6841
6395
|
const fromPositivePromptSafetyAttributes = getValueByPath(fromObject, [
|
|
6842
6396
|
'positivePromptSafetyAttributes',
|
|
@@ -6904,6 +6458,10 @@ function modelFromMldev(apiClient, fromObject) {
|
|
|
6904
6458
|
}
|
|
6905
6459
|
return toObject;
|
|
6906
6460
|
}
|
|
6461
|
+
function deleteModelResponseFromMldev() {
|
|
6462
|
+
const toObject = {};
|
|
6463
|
+
return toObject;
|
|
6464
|
+
}
|
|
6907
6465
|
function countTokensResponseFromMldev(apiClient, fromObject) {
|
|
6908
6466
|
const toObject = {};
|
|
6909
6467
|
const fromTotalTokens = getValueByPath(fromObject, ['totalTokens']);
|
|
@@ -6951,14 +6509,13 @@ function generateVideosResponseFromMldev$1(apiClient, fromObject) {
|
|
|
6951
6509
|
'generatedSamples',
|
|
6952
6510
|
]);
|
|
6953
6511
|
if (fromGeneratedVideos != null) {
|
|
6954
|
-
|
|
6955
|
-
|
|
6512
|
+
let transformedList = fromGeneratedVideos;
|
|
6513
|
+
if (Array.isArray(transformedList)) {
|
|
6514
|
+
transformedList = transformedList.map((item) => {
|
|
6956
6515
|
return generatedVideoFromMldev$1(apiClient, item);
|
|
6957
|
-
})
|
|
6958
|
-
}
|
|
6959
|
-
else {
|
|
6960
|
-
setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos);
|
|
6516
|
+
});
|
|
6961
6517
|
}
|
|
6518
|
+
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
6962
6519
|
}
|
|
6963
6520
|
const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
|
|
6964
6521
|
'raiMediaFilteredCount',
|
|
@@ -7053,14 +6610,13 @@ function contentFromVertex(apiClient, fromObject) {
|
|
|
7053
6610
|
const toObject = {};
|
|
7054
6611
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
7055
6612
|
if (fromParts != null) {
|
|
7056
|
-
|
|
7057
|
-
|
|
6613
|
+
let transformedList = fromParts;
|
|
6614
|
+
if (Array.isArray(transformedList)) {
|
|
6615
|
+
transformedList = transformedList.map((item) => {
|
|
7058
6616
|
return partFromVertex(apiClient, item);
|
|
7059
|
-
})
|
|
7060
|
-
}
|
|
7061
|
-
else {
|
|
7062
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
6617
|
+
});
|
|
7063
6618
|
}
|
|
6619
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
7064
6620
|
}
|
|
7065
6621
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
7066
6622
|
if (fromRole != null) {
|
|
@@ -7130,14 +6686,13 @@ function generateContentResponseFromVertex(apiClient, fromObject) {
|
|
|
7130
6686
|
const toObject = {};
|
|
7131
6687
|
const fromCandidates = getValueByPath(fromObject, ['candidates']);
|
|
7132
6688
|
if (fromCandidates != null) {
|
|
7133
|
-
|
|
7134
|
-
|
|
6689
|
+
let transformedList = fromCandidates;
|
|
6690
|
+
if (Array.isArray(transformedList)) {
|
|
6691
|
+
transformedList = transformedList.map((item) => {
|
|
7135
6692
|
return candidateFromVertex(apiClient, item);
|
|
7136
|
-
})
|
|
7137
|
-
}
|
|
7138
|
-
else {
|
|
7139
|
-
setValueByPath(toObject, ['candidates'], fromCandidates);
|
|
6693
|
+
});
|
|
7140
6694
|
}
|
|
6695
|
+
setValueByPath(toObject, ['candidates'], transformedList);
|
|
7141
6696
|
}
|
|
7142
6697
|
const fromCreateTime = getValueByPath(fromObject, ['createTime']);
|
|
7143
6698
|
if (fromCreateTime != null) {
|
|
@@ -7206,14 +6761,13 @@ function embedContentResponseFromVertex(apiClient, fromObject) {
|
|
|
7206
6761
|
'embeddings',
|
|
7207
6762
|
]);
|
|
7208
6763
|
if (fromEmbeddings != null) {
|
|
7209
|
-
|
|
7210
|
-
|
|
6764
|
+
let transformedList = fromEmbeddings;
|
|
6765
|
+
if (Array.isArray(transformedList)) {
|
|
6766
|
+
transformedList = transformedList.map((item) => {
|
|
7211
6767
|
return contentEmbeddingFromVertex(apiClient, item);
|
|
7212
|
-
})
|
|
7213
|
-
}
|
|
7214
|
-
else {
|
|
7215
|
-
setValueByPath(toObject, ['embeddings'], fromEmbeddings);
|
|
6768
|
+
});
|
|
7216
6769
|
}
|
|
6770
|
+
setValueByPath(toObject, ['embeddings'], transformedList);
|
|
7217
6771
|
}
|
|
7218
6772
|
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
7219
6773
|
if (fromMetadata != null) {
|
|
@@ -7289,14 +6843,13 @@ function generateImagesResponseFromVertex(apiClient, fromObject) {
|
|
|
7289
6843
|
'predictions',
|
|
7290
6844
|
]);
|
|
7291
6845
|
if (fromGeneratedImages != null) {
|
|
7292
|
-
|
|
7293
|
-
|
|
6846
|
+
let transformedList = fromGeneratedImages;
|
|
6847
|
+
if (Array.isArray(transformedList)) {
|
|
6848
|
+
transformedList = transformedList.map((item) => {
|
|
7294
6849
|
return generatedImageFromVertex(apiClient, item);
|
|
7295
|
-
})
|
|
7296
|
-
}
|
|
7297
|
-
else {
|
|
7298
|
-
setValueByPath(toObject, ['generatedImages'], fromGeneratedImages);
|
|
6850
|
+
});
|
|
7299
6851
|
}
|
|
6852
|
+
setValueByPath(toObject, ['generatedImages'], transformedList);
|
|
7300
6853
|
}
|
|
7301
6854
|
const fromPositivePromptSafetyAttributes = getValueByPath(fromObject, [
|
|
7302
6855
|
'positivePromptSafetyAttributes',
|
|
@@ -7359,14 +6912,13 @@ function modelFromVertex(apiClient, fromObject) {
|
|
|
7359
6912
|
}
|
|
7360
6913
|
const fromEndpoints = getValueByPath(fromObject, ['deployedModels']);
|
|
7361
6914
|
if (fromEndpoints != null) {
|
|
7362
|
-
|
|
7363
|
-
|
|
6915
|
+
let transformedList = fromEndpoints;
|
|
6916
|
+
if (Array.isArray(transformedList)) {
|
|
6917
|
+
transformedList = transformedList.map((item) => {
|
|
7364
6918
|
return endpointFromVertex(apiClient, item);
|
|
7365
|
-
})
|
|
7366
|
-
}
|
|
7367
|
-
else {
|
|
7368
|
-
setValueByPath(toObject, ['endpoints'], fromEndpoints);
|
|
6919
|
+
});
|
|
7369
6920
|
}
|
|
6921
|
+
setValueByPath(toObject, ['endpoints'], transformedList);
|
|
7370
6922
|
}
|
|
7371
6923
|
const fromLabels = getValueByPath(fromObject, ['labels']);
|
|
7372
6924
|
if (fromLabels != null) {
|
|
@@ -7378,6 +6930,10 @@ function modelFromVertex(apiClient, fromObject) {
|
|
|
7378
6930
|
}
|
|
7379
6931
|
return toObject;
|
|
7380
6932
|
}
|
|
6933
|
+
function deleteModelResponseFromVertex() {
|
|
6934
|
+
const toObject = {};
|
|
6935
|
+
return toObject;
|
|
6936
|
+
}
|
|
7381
6937
|
function countTokensResponseFromVertex(apiClient, fromObject) {
|
|
7382
6938
|
const toObject = {};
|
|
7383
6939
|
const fromTotalTokens = getValueByPath(fromObject, ['totalTokens']);
|
|
@@ -7424,14 +6980,13 @@ function generateVideosResponseFromVertex$1(apiClient, fromObject) {
|
|
|
7424
6980
|
const toObject = {};
|
|
7425
6981
|
const fromGeneratedVideos = getValueByPath(fromObject, ['videos']);
|
|
7426
6982
|
if (fromGeneratedVideos != null) {
|
|
7427
|
-
|
|
7428
|
-
|
|
6983
|
+
let transformedList = fromGeneratedVideos;
|
|
6984
|
+
if (Array.isArray(transformedList)) {
|
|
6985
|
+
transformedList = transformedList.map((item) => {
|
|
7429
6986
|
return generatedVideoFromVertex$1(apiClient, item);
|
|
7430
|
-
})
|
|
7431
|
-
}
|
|
7432
|
-
else {
|
|
7433
|
-
setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos);
|
|
6987
|
+
});
|
|
7434
6988
|
}
|
|
6989
|
+
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
7435
6990
|
}
|
|
7436
6991
|
const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
|
|
7437
6992
|
'raiMediaFilteredCount',
|
|
@@ -8374,6 +7929,146 @@ class Models extends BaseModule {
|
|
|
8374
7929
|
});
|
|
8375
7930
|
}
|
|
8376
7931
|
}
|
|
7932
|
+
/**
|
|
7933
|
+
* Updates a tuned model by its name.
|
|
7934
|
+
*
|
|
7935
|
+
* @param params - The parameters for updating the model.
|
|
7936
|
+
* @return The response from the API.
|
|
7937
|
+
*
|
|
7938
|
+
* @example
|
|
7939
|
+
* ```ts
|
|
7940
|
+
* const response = await ai.models.update({
|
|
7941
|
+
* model: 'tuned-model-name',
|
|
7942
|
+
* config: {
|
|
7943
|
+
* displayName: 'New display name',
|
|
7944
|
+
* description: 'New description',
|
|
7945
|
+
* },
|
|
7946
|
+
* });
|
|
7947
|
+
* ```
|
|
7948
|
+
*/
|
|
7949
|
+
async update(params) {
|
|
7950
|
+
var _a, _b, _c, _d;
|
|
7951
|
+
let response;
|
|
7952
|
+
let path = '';
|
|
7953
|
+
let queryParams = {};
|
|
7954
|
+
if (this.apiClient.isVertexAI()) {
|
|
7955
|
+
const body = updateModelParametersToVertex(this.apiClient, params);
|
|
7956
|
+
path = formatMap('{model}', body['_url']);
|
|
7957
|
+
queryParams = body['_query'];
|
|
7958
|
+
delete body['config'];
|
|
7959
|
+
delete body['_url'];
|
|
7960
|
+
delete body['_query'];
|
|
7961
|
+
response = this.apiClient
|
|
7962
|
+
.request({
|
|
7963
|
+
path: path,
|
|
7964
|
+
queryParams: queryParams,
|
|
7965
|
+
body: JSON.stringify(body),
|
|
7966
|
+
httpMethod: 'PATCH',
|
|
7967
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
7968
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
7969
|
+
})
|
|
7970
|
+
.then((httpResponse) => {
|
|
7971
|
+
return httpResponse.json();
|
|
7972
|
+
});
|
|
7973
|
+
return response.then((apiResponse) => {
|
|
7974
|
+
const resp = modelFromVertex(this.apiClient, apiResponse);
|
|
7975
|
+
return resp;
|
|
7976
|
+
});
|
|
7977
|
+
}
|
|
7978
|
+
else {
|
|
7979
|
+
const body = updateModelParametersToMldev(this.apiClient, params);
|
|
7980
|
+
path = formatMap('{name}', body['_url']);
|
|
7981
|
+
queryParams = body['_query'];
|
|
7982
|
+
delete body['config'];
|
|
7983
|
+
delete body['_url'];
|
|
7984
|
+
delete body['_query'];
|
|
7985
|
+
response = this.apiClient
|
|
7986
|
+
.request({
|
|
7987
|
+
path: path,
|
|
7988
|
+
queryParams: queryParams,
|
|
7989
|
+
body: JSON.stringify(body),
|
|
7990
|
+
httpMethod: 'PATCH',
|
|
7991
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
7992
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
7993
|
+
})
|
|
7994
|
+
.then((httpResponse) => {
|
|
7995
|
+
return httpResponse.json();
|
|
7996
|
+
});
|
|
7997
|
+
return response.then((apiResponse) => {
|
|
7998
|
+
const resp = modelFromMldev(this.apiClient, apiResponse);
|
|
7999
|
+
return resp;
|
|
8000
|
+
});
|
|
8001
|
+
}
|
|
8002
|
+
}
|
|
8003
|
+
/**
|
|
8004
|
+
* Deletes a tuned model by its name.
|
|
8005
|
+
*
|
|
8006
|
+
* @param params - The parameters for deleting the model.
|
|
8007
|
+
* @return The response from the API.
|
|
8008
|
+
*
|
|
8009
|
+
* @example
|
|
8010
|
+
* ```ts
|
|
8011
|
+
* const response = await ai.models.delete({model: 'tuned-model-name'});
|
|
8012
|
+
* ```
|
|
8013
|
+
*/
|
|
8014
|
+
async delete(params) {
|
|
8015
|
+
var _a, _b, _c, _d;
|
|
8016
|
+
let response;
|
|
8017
|
+
let path = '';
|
|
8018
|
+
let queryParams = {};
|
|
8019
|
+
if (this.apiClient.isVertexAI()) {
|
|
8020
|
+
const body = deleteModelParametersToVertex(this.apiClient, params);
|
|
8021
|
+
path = formatMap('{name}', body['_url']);
|
|
8022
|
+
queryParams = body['_query'];
|
|
8023
|
+
delete body['config'];
|
|
8024
|
+
delete body['_url'];
|
|
8025
|
+
delete body['_query'];
|
|
8026
|
+
response = this.apiClient
|
|
8027
|
+
.request({
|
|
8028
|
+
path: path,
|
|
8029
|
+
queryParams: queryParams,
|
|
8030
|
+
body: JSON.stringify(body),
|
|
8031
|
+
httpMethod: 'DELETE',
|
|
8032
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
8033
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
8034
|
+
})
|
|
8035
|
+
.then((httpResponse) => {
|
|
8036
|
+
return httpResponse.json();
|
|
8037
|
+
});
|
|
8038
|
+
return response.then(() => {
|
|
8039
|
+
const resp = deleteModelResponseFromVertex();
|
|
8040
|
+
const typedResp = new DeleteModelResponse();
|
|
8041
|
+
Object.assign(typedResp, resp);
|
|
8042
|
+
return typedResp;
|
|
8043
|
+
});
|
|
8044
|
+
}
|
|
8045
|
+
else {
|
|
8046
|
+
const body = deleteModelParametersToMldev(this.apiClient, params);
|
|
8047
|
+
path = formatMap('{name}', body['_url']);
|
|
8048
|
+
queryParams = body['_query'];
|
|
8049
|
+
delete body['config'];
|
|
8050
|
+
delete body['_url'];
|
|
8051
|
+
delete body['_query'];
|
|
8052
|
+
response = this.apiClient
|
|
8053
|
+
.request({
|
|
8054
|
+
path: path,
|
|
8055
|
+
queryParams: queryParams,
|
|
8056
|
+
body: JSON.stringify(body),
|
|
8057
|
+
httpMethod: 'DELETE',
|
|
8058
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
8059
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
8060
|
+
})
|
|
8061
|
+
.then((httpResponse) => {
|
|
8062
|
+
return httpResponse.json();
|
|
8063
|
+
});
|
|
8064
|
+
return response.then(() => {
|
|
8065
|
+
const resp = deleteModelResponseFromMldev();
|
|
8066
|
+
const typedResp = new DeleteModelResponse();
|
|
8067
|
+
Object.assign(typedResp, resp);
|
|
8068
|
+
return typedResp;
|
|
8069
|
+
});
|
|
8070
|
+
}
|
|
8071
|
+
}
|
|
8377
8072
|
/**
|
|
8378
8073
|
* Counts the number of tokens in the given contents. Multimodal input is
|
|
8379
8074
|
* supported for Gemini models.
|
|
@@ -8664,14 +8359,13 @@ function generateVideosResponseFromMldev(apiClient, fromObject) {
|
|
|
8664
8359
|
'generatedSamples',
|
|
8665
8360
|
]);
|
|
8666
8361
|
if (fromGeneratedVideos != null) {
|
|
8667
|
-
|
|
8668
|
-
|
|
8362
|
+
let transformedList = fromGeneratedVideos;
|
|
8363
|
+
if (Array.isArray(transformedList)) {
|
|
8364
|
+
transformedList = transformedList.map((item) => {
|
|
8669
8365
|
return generatedVideoFromMldev(apiClient, item);
|
|
8670
|
-
})
|
|
8671
|
-
}
|
|
8672
|
-
else {
|
|
8673
|
-
setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos);
|
|
8366
|
+
});
|
|
8674
8367
|
}
|
|
8368
|
+
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
8675
8369
|
}
|
|
8676
8370
|
const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
|
|
8677
8371
|
'raiMediaFilteredCount',
|
|
@@ -8744,14 +8438,13 @@ function generateVideosResponseFromVertex(apiClient, fromObject) {
|
|
|
8744
8438
|
const toObject = {};
|
|
8745
8439
|
const fromGeneratedVideos = getValueByPath(fromObject, ['videos']);
|
|
8746
8440
|
if (fromGeneratedVideos != null) {
|
|
8747
|
-
|
|
8748
|
-
|
|
8441
|
+
let transformedList = fromGeneratedVideos;
|
|
8442
|
+
if (Array.isArray(transformedList)) {
|
|
8443
|
+
transformedList = transformedList.map((item) => {
|
|
8749
8444
|
return generatedVideoFromVertex(apiClient, item);
|
|
8750
|
-
})
|
|
8751
|
-
}
|
|
8752
|
-
else {
|
|
8753
|
-
setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos);
|
|
8445
|
+
});
|
|
8754
8446
|
}
|
|
8447
|
+
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
8755
8448
|
}
|
|
8756
8449
|
const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
|
|
8757
8450
|
'raiMediaFilteredCount',
|
|
@@ -8931,7 +8624,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
8931
8624
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
8932
8625
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
8933
8626
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
8934
|
-
const SDK_VERSION = '0.
|
|
8627
|
+
const SDK_VERSION = '0.12.0'; // x-release-please-version
|
|
8935
8628
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
8936
8629
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
8937
8630
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -9408,6 +9101,736 @@ async function throwErrorIfNotOK(response) {
|
|
|
9408
9101
|
}
|
|
9409
9102
|
}
|
|
9410
9103
|
|
|
9104
|
+
/**
|
|
9105
|
+
* @license
|
|
9106
|
+
* Copyright 2025 Google LLC
|
|
9107
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
9108
|
+
*/
|
|
9109
|
+
function getTuningJobParametersToMldev(apiClient, fromObject) {
|
|
9110
|
+
const toObject = {};
|
|
9111
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
9112
|
+
if (fromName != null) {
|
|
9113
|
+
setValueByPath(toObject, ['_url', 'name'], fromName);
|
|
9114
|
+
}
|
|
9115
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
9116
|
+
if (fromConfig != null) {
|
|
9117
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
9118
|
+
}
|
|
9119
|
+
return toObject;
|
|
9120
|
+
}
|
|
9121
|
+
function listTuningJobsConfigToMldev(apiClient, fromObject, parentObject) {
|
|
9122
|
+
const toObject = {};
|
|
9123
|
+
const fromPageSize = getValueByPath(fromObject, ['pageSize']);
|
|
9124
|
+
if (parentObject !== undefined && fromPageSize != null) {
|
|
9125
|
+
setValueByPath(parentObject, ['_query', 'pageSize'], fromPageSize);
|
|
9126
|
+
}
|
|
9127
|
+
const fromPageToken = getValueByPath(fromObject, ['pageToken']);
|
|
9128
|
+
if (parentObject !== undefined && fromPageToken != null) {
|
|
9129
|
+
setValueByPath(parentObject, ['_query', 'pageToken'], fromPageToken);
|
|
9130
|
+
}
|
|
9131
|
+
const fromFilter = getValueByPath(fromObject, ['filter']);
|
|
9132
|
+
if (parentObject !== undefined && fromFilter != null) {
|
|
9133
|
+
setValueByPath(parentObject, ['_query', 'filter'], fromFilter);
|
|
9134
|
+
}
|
|
9135
|
+
return toObject;
|
|
9136
|
+
}
|
|
9137
|
+
function listTuningJobsParametersToMldev(apiClient, fromObject) {
|
|
9138
|
+
const toObject = {};
|
|
9139
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
9140
|
+
if (fromConfig != null) {
|
|
9141
|
+
setValueByPath(toObject, ['config'], listTuningJobsConfigToMldev(apiClient, fromConfig, toObject));
|
|
9142
|
+
}
|
|
9143
|
+
return toObject;
|
|
9144
|
+
}
|
|
9145
|
+
function tuningExampleToMldev(apiClient, fromObject) {
|
|
9146
|
+
const toObject = {};
|
|
9147
|
+
const fromTextInput = getValueByPath(fromObject, ['textInput']);
|
|
9148
|
+
if (fromTextInput != null) {
|
|
9149
|
+
setValueByPath(toObject, ['textInput'], fromTextInput);
|
|
9150
|
+
}
|
|
9151
|
+
const fromOutput = getValueByPath(fromObject, ['output']);
|
|
9152
|
+
if (fromOutput != null) {
|
|
9153
|
+
setValueByPath(toObject, ['output'], fromOutput);
|
|
9154
|
+
}
|
|
9155
|
+
return toObject;
|
|
9156
|
+
}
|
|
9157
|
+
function tuningDatasetToMldev(apiClient, fromObject) {
|
|
9158
|
+
const toObject = {};
|
|
9159
|
+
if (getValueByPath(fromObject, ['gcsUri']) !== undefined) {
|
|
9160
|
+
throw new Error('gcsUri parameter is not supported in Gemini API.');
|
|
9161
|
+
}
|
|
9162
|
+
const fromExamples = getValueByPath(fromObject, ['examples']);
|
|
9163
|
+
if (fromExamples != null) {
|
|
9164
|
+
let transformedList = fromExamples;
|
|
9165
|
+
if (Array.isArray(transformedList)) {
|
|
9166
|
+
transformedList = transformedList.map((item) => {
|
|
9167
|
+
return tuningExampleToMldev(apiClient, item);
|
|
9168
|
+
});
|
|
9169
|
+
}
|
|
9170
|
+
setValueByPath(toObject, ['examples', 'examples'], transformedList);
|
|
9171
|
+
}
|
|
9172
|
+
return toObject;
|
|
9173
|
+
}
|
|
9174
|
+
function createTuningJobConfigToMldev(apiClient, fromObject, parentObject) {
|
|
9175
|
+
const toObject = {};
|
|
9176
|
+
if (getValueByPath(fromObject, ['validationDataset']) !== undefined) {
|
|
9177
|
+
throw new Error('validationDataset parameter is not supported in Gemini API.');
|
|
9178
|
+
}
|
|
9179
|
+
const fromTunedModelDisplayName = getValueByPath(fromObject, [
|
|
9180
|
+
'tunedModelDisplayName',
|
|
9181
|
+
]);
|
|
9182
|
+
if (parentObject !== undefined && fromTunedModelDisplayName != null) {
|
|
9183
|
+
setValueByPath(parentObject, ['displayName'], fromTunedModelDisplayName);
|
|
9184
|
+
}
|
|
9185
|
+
if (getValueByPath(fromObject, ['description']) !== undefined) {
|
|
9186
|
+
throw new Error('description parameter is not supported in Gemini API.');
|
|
9187
|
+
}
|
|
9188
|
+
const fromEpochCount = getValueByPath(fromObject, ['epochCount']);
|
|
9189
|
+
if (parentObject !== undefined && fromEpochCount != null) {
|
|
9190
|
+
setValueByPath(parentObject, ['tuningTask', 'hyperparameters', 'epochCount'], fromEpochCount);
|
|
9191
|
+
}
|
|
9192
|
+
const fromLearningRateMultiplier = getValueByPath(fromObject, [
|
|
9193
|
+
'learningRateMultiplier',
|
|
9194
|
+
]);
|
|
9195
|
+
if (fromLearningRateMultiplier != null) {
|
|
9196
|
+
setValueByPath(toObject, ['tuningTask', 'hyperparameters', 'learningRateMultiplier'], fromLearningRateMultiplier);
|
|
9197
|
+
}
|
|
9198
|
+
if (getValueByPath(fromObject, ['adapterSize']) !== undefined) {
|
|
9199
|
+
throw new Error('adapterSize parameter is not supported in Gemini API.');
|
|
9200
|
+
}
|
|
9201
|
+
const fromBatchSize = getValueByPath(fromObject, ['batchSize']);
|
|
9202
|
+
if (parentObject !== undefined && fromBatchSize != null) {
|
|
9203
|
+
setValueByPath(parentObject, ['tuningTask', 'hyperparameters', 'batchSize'], fromBatchSize);
|
|
9204
|
+
}
|
|
9205
|
+
const fromLearningRate = getValueByPath(fromObject, ['learningRate']);
|
|
9206
|
+
if (parentObject !== undefined && fromLearningRate != null) {
|
|
9207
|
+
setValueByPath(parentObject, ['tuningTask', 'hyperparameters', 'learningRate'], fromLearningRate);
|
|
9208
|
+
}
|
|
9209
|
+
return toObject;
|
|
9210
|
+
}
|
|
9211
|
+
function createTuningJobParametersToMldev(apiClient, fromObject) {
|
|
9212
|
+
const toObject = {};
|
|
9213
|
+
const fromBaseModel = getValueByPath(fromObject, ['baseModel']);
|
|
9214
|
+
if (fromBaseModel != null) {
|
|
9215
|
+
setValueByPath(toObject, ['baseModel'], fromBaseModel);
|
|
9216
|
+
}
|
|
9217
|
+
const fromTrainingDataset = getValueByPath(fromObject, [
|
|
9218
|
+
'trainingDataset',
|
|
9219
|
+
]);
|
|
9220
|
+
if (fromTrainingDataset != null) {
|
|
9221
|
+
setValueByPath(toObject, ['tuningTask', 'trainingData'], tuningDatasetToMldev(apiClient, fromTrainingDataset));
|
|
9222
|
+
}
|
|
9223
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
9224
|
+
if (fromConfig != null) {
|
|
9225
|
+
setValueByPath(toObject, ['config'], createTuningJobConfigToMldev(apiClient, fromConfig, toObject));
|
|
9226
|
+
}
|
|
9227
|
+
return toObject;
|
|
9228
|
+
}
|
|
9229
|
+
function getTuningJobParametersToVertex(apiClient, fromObject) {
|
|
9230
|
+
const toObject = {};
|
|
9231
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
9232
|
+
if (fromName != null) {
|
|
9233
|
+
setValueByPath(toObject, ['_url', 'name'], fromName);
|
|
9234
|
+
}
|
|
9235
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
9236
|
+
if (fromConfig != null) {
|
|
9237
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
9238
|
+
}
|
|
9239
|
+
return toObject;
|
|
9240
|
+
}
|
|
9241
|
+
function listTuningJobsConfigToVertex(apiClient, fromObject, parentObject) {
|
|
9242
|
+
const toObject = {};
|
|
9243
|
+
const fromPageSize = getValueByPath(fromObject, ['pageSize']);
|
|
9244
|
+
if (parentObject !== undefined && fromPageSize != null) {
|
|
9245
|
+
setValueByPath(parentObject, ['_query', 'pageSize'], fromPageSize);
|
|
9246
|
+
}
|
|
9247
|
+
const fromPageToken = getValueByPath(fromObject, ['pageToken']);
|
|
9248
|
+
if (parentObject !== undefined && fromPageToken != null) {
|
|
9249
|
+
setValueByPath(parentObject, ['_query', 'pageToken'], fromPageToken);
|
|
9250
|
+
}
|
|
9251
|
+
const fromFilter = getValueByPath(fromObject, ['filter']);
|
|
9252
|
+
if (parentObject !== undefined && fromFilter != null) {
|
|
9253
|
+
setValueByPath(parentObject, ['_query', 'filter'], fromFilter);
|
|
9254
|
+
}
|
|
9255
|
+
return toObject;
|
|
9256
|
+
}
|
|
9257
|
+
function listTuningJobsParametersToVertex(apiClient, fromObject) {
|
|
9258
|
+
const toObject = {};
|
|
9259
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
9260
|
+
if (fromConfig != null) {
|
|
9261
|
+
setValueByPath(toObject, ['config'], listTuningJobsConfigToVertex(apiClient, fromConfig, toObject));
|
|
9262
|
+
}
|
|
9263
|
+
return toObject;
|
|
9264
|
+
}
|
|
9265
|
+
function tuningDatasetToVertex(apiClient, fromObject, parentObject) {
|
|
9266
|
+
const toObject = {};
|
|
9267
|
+
const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
|
|
9268
|
+
if (parentObject !== undefined && fromGcsUri != null) {
|
|
9269
|
+
setValueByPath(parentObject, ['supervisedTuningSpec', 'trainingDatasetUri'], fromGcsUri);
|
|
9270
|
+
}
|
|
9271
|
+
if (getValueByPath(fromObject, ['examples']) !== undefined) {
|
|
9272
|
+
throw new Error('examples parameter is not supported in Vertex AI.');
|
|
9273
|
+
}
|
|
9274
|
+
return toObject;
|
|
9275
|
+
}
|
|
9276
|
+
function tuningValidationDatasetToVertex(apiClient, fromObject) {
|
|
9277
|
+
const toObject = {};
|
|
9278
|
+
const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
|
|
9279
|
+
if (fromGcsUri != null) {
|
|
9280
|
+
setValueByPath(toObject, ['validationDatasetUri'], fromGcsUri);
|
|
9281
|
+
}
|
|
9282
|
+
return toObject;
|
|
9283
|
+
}
|
|
9284
|
+
function createTuningJobConfigToVertex(apiClient, fromObject, parentObject) {
|
|
9285
|
+
const toObject = {};
|
|
9286
|
+
const fromValidationDataset = getValueByPath(fromObject, [
|
|
9287
|
+
'validationDataset',
|
|
9288
|
+
]);
|
|
9289
|
+
if (parentObject !== undefined && fromValidationDataset != null) {
|
|
9290
|
+
setValueByPath(parentObject, ['supervisedTuningSpec'], tuningValidationDatasetToVertex(apiClient, fromValidationDataset));
|
|
9291
|
+
}
|
|
9292
|
+
const fromTunedModelDisplayName = getValueByPath(fromObject, [
|
|
9293
|
+
'tunedModelDisplayName',
|
|
9294
|
+
]);
|
|
9295
|
+
if (parentObject !== undefined && fromTunedModelDisplayName != null) {
|
|
9296
|
+
setValueByPath(parentObject, ['tunedModelDisplayName'], fromTunedModelDisplayName);
|
|
9297
|
+
}
|
|
9298
|
+
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
9299
|
+
if (parentObject !== undefined && fromDescription != null) {
|
|
9300
|
+
setValueByPath(parentObject, ['description'], fromDescription);
|
|
9301
|
+
}
|
|
9302
|
+
const fromEpochCount = getValueByPath(fromObject, ['epochCount']);
|
|
9303
|
+
if (parentObject !== undefined && fromEpochCount != null) {
|
|
9304
|
+
setValueByPath(parentObject, ['supervisedTuningSpec', 'hyperParameters', 'epochCount'], fromEpochCount);
|
|
9305
|
+
}
|
|
9306
|
+
const fromLearningRateMultiplier = getValueByPath(fromObject, [
|
|
9307
|
+
'learningRateMultiplier',
|
|
9308
|
+
]);
|
|
9309
|
+
if (parentObject !== undefined && fromLearningRateMultiplier != null) {
|
|
9310
|
+
setValueByPath(parentObject, ['supervisedTuningSpec', 'hyperParameters', 'learningRateMultiplier'], fromLearningRateMultiplier);
|
|
9311
|
+
}
|
|
9312
|
+
const fromAdapterSize = getValueByPath(fromObject, ['adapterSize']);
|
|
9313
|
+
if (parentObject !== undefined && fromAdapterSize != null) {
|
|
9314
|
+
setValueByPath(parentObject, ['supervisedTuningSpec', 'hyperParameters', 'adapterSize'], fromAdapterSize);
|
|
9315
|
+
}
|
|
9316
|
+
if (getValueByPath(fromObject, ['batchSize']) !== undefined) {
|
|
9317
|
+
throw new Error('batchSize parameter is not supported in Vertex AI.');
|
|
9318
|
+
}
|
|
9319
|
+
if (getValueByPath(fromObject, ['learningRate']) !== undefined) {
|
|
9320
|
+
throw new Error('learningRate parameter is not supported in Vertex AI.');
|
|
9321
|
+
}
|
|
9322
|
+
return toObject;
|
|
9323
|
+
}
|
|
9324
|
+
function createTuningJobParametersToVertex(apiClient, fromObject) {
|
|
9325
|
+
const toObject = {};
|
|
9326
|
+
const fromBaseModel = getValueByPath(fromObject, ['baseModel']);
|
|
9327
|
+
if (fromBaseModel != null) {
|
|
9328
|
+
setValueByPath(toObject, ['baseModel'], fromBaseModel);
|
|
9329
|
+
}
|
|
9330
|
+
const fromTrainingDataset = getValueByPath(fromObject, [
|
|
9331
|
+
'trainingDataset',
|
|
9332
|
+
]);
|
|
9333
|
+
if (fromTrainingDataset != null) {
|
|
9334
|
+
setValueByPath(toObject, ['supervisedTuningSpec', 'trainingDatasetUri'], tuningDatasetToVertex(apiClient, fromTrainingDataset, toObject));
|
|
9335
|
+
}
|
|
9336
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
9337
|
+
if (fromConfig != null) {
|
|
9338
|
+
setValueByPath(toObject, ['config'], createTuningJobConfigToVertex(apiClient, fromConfig, toObject));
|
|
9339
|
+
}
|
|
9340
|
+
return toObject;
|
|
9341
|
+
}
|
|
9342
|
+
function tunedModelFromMldev(apiClient, fromObject) {
|
|
9343
|
+
const toObject = {};
|
|
9344
|
+
const fromModel = getValueByPath(fromObject, ['name']);
|
|
9345
|
+
if (fromModel != null) {
|
|
9346
|
+
setValueByPath(toObject, ['model'], fromModel);
|
|
9347
|
+
}
|
|
9348
|
+
const fromEndpoint = getValueByPath(fromObject, ['name']);
|
|
9349
|
+
if (fromEndpoint != null) {
|
|
9350
|
+
setValueByPath(toObject, ['endpoint'], fromEndpoint);
|
|
9351
|
+
}
|
|
9352
|
+
return toObject;
|
|
9353
|
+
}
|
|
9354
|
+
function tuningJobFromMldev(apiClient, fromObject) {
|
|
9355
|
+
const toObject = {};
|
|
9356
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
9357
|
+
if (fromName != null) {
|
|
9358
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
9359
|
+
}
|
|
9360
|
+
const fromState = getValueByPath(fromObject, ['state']);
|
|
9361
|
+
if (fromState != null) {
|
|
9362
|
+
setValueByPath(toObject, ['state'], tTuningJobStatus(apiClient, fromState));
|
|
9363
|
+
}
|
|
9364
|
+
const fromCreateTime = getValueByPath(fromObject, ['createTime']);
|
|
9365
|
+
if (fromCreateTime != null) {
|
|
9366
|
+
setValueByPath(toObject, ['createTime'], fromCreateTime);
|
|
9367
|
+
}
|
|
9368
|
+
const fromStartTime = getValueByPath(fromObject, [
|
|
9369
|
+
'tuningTask',
|
|
9370
|
+
'startTime',
|
|
9371
|
+
]);
|
|
9372
|
+
if (fromStartTime != null) {
|
|
9373
|
+
setValueByPath(toObject, ['startTime'], fromStartTime);
|
|
9374
|
+
}
|
|
9375
|
+
const fromEndTime = getValueByPath(fromObject, [
|
|
9376
|
+
'tuningTask',
|
|
9377
|
+
'completeTime',
|
|
9378
|
+
]);
|
|
9379
|
+
if (fromEndTime != null) {
|
|
9380
|
+
setValueByPath(toObject, ['endTime'], fromEndTime);
|
|
9381
|
+
}
|
|
9382
|
+
const fromUpdateTime = getValueByPath(fromObject, ['updateTime']);
|
|
9383
|
+
if (fromUpdateTime != null) {
|
|
9384
|
+
setValueByPath(toObject, ['updateTime'], fromUpdateTime);
|
|
9385
|
+
}
|
|
9386
|
+
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
9387
|
+
if (fromDescription != null) {
|
|
9388
|
+
setValueByPath(toObject, ['description'], fromDescription);
|
|
9389
|
+
}
|
|
9390
|
+
const fromBaseModel = getValueByPath(fromObject, ['baseModel']);
|
|
9391
|
+
if (fromBaseModel != null) {
|
|
9392
|
+
setValueByPath(toObject, ['baseModel'], fromBaseModel);
|
|
9393
|
+
}
|
|
9394
|
+
const fromTunedModel = getValueByPath(fromObject, ['_self']);
|
|
9395
|
+
if (fromTunedModel != null) {
|
|
9396
|
+
setValueByPath(toObject, ['tunedModel'], tunedModelFromMldev(apiClient, fromTunedModel));
|
|
9397
|
+
}
|
|
9398
|
+
const fromDistillationSpec = getValueByPath(fromObject, [
|
|
9399
|
+
'distillationSpec',
|
|
9400
|
+
]);
|
|
9401
|
+
if (fromDistillationSpec != null) {
|
|
9402
|
+
setValueByPath(toObject, ['distillationSpec'], fromDistillationSpec);
|
|
9403
|
+
}
|
|
9404
|
+
const fromExperiment = getValueByPath(fromObject, ['experiment']);
|
|
9405
|
+
if (fromExperiment != null) {
|
|
9406
|
+
setValueByPath(toObject, ['experiment'], fromExperiment);
|
|
9407
|
+
}
|
|
9408
|
+
const fromLabels = getValueByPath(fromObject, ['labels']);
|
|
9409
|
+
if (fromLabels != null) {
|
|
9410
|
+
setValueByPath(toObject, ['labels'], fromLabels);
|
|
9411
|
+
}
|
|
9412
|
+
const fromPipelineJob = getValueByPath(fromObject, ['pipelineJob']);
|
|
9413
|
+
if (fromPipelineJob != null) {
|
|
9414
|
+
setValueByPath(toObject, ['pipelineJob'], fromPipelineJob);
|
|
9415
|
+
}
|
|
9416
|
+
const fromTunedModelDisplayName = getValueByPath(fromObject, [
|
|
9417
|
+
'tunedModelDisplayName',
|
|
9418
|
+
]);
|
|
9419
|
+
if (fromTunedModelDisplayName != null) {
|
|
9420
|
+
setValueByPath(toObject, ['tunedModelDisplayName'], fromTunedModelDisplayName);
|
|
9421
|
+
}
|
|
9422
|
+
return toObject;
|
|
9423
|
+
}
|
|
9424
|
+
function listTuningJobsResponseFromMldev(apiClient, fromObject) {
|
|
9425
|
+
const toObject = {};
|
|
9426
|
+
const fromNextPageToken = getValueByPath(fromObject, [
|
|
9427
|
+
'nextPageToken',
|
|
9428
|
+
]);
|
|
9429
|
+
if (fromNextPageToken != null) {
|
|
9430
|
+
setValueByPath(toObject, ['nextPageToken'], fromNextPageToken);
|
|
9431
|
+
}
|
|
9432
|
+
const fromTuningJobs = getValueByPath(fromObject, ['tunedModels']);
|
|
9433
|
+
if (fromTuningJobs != null) {
|
|
9434
|
+
let transformedList = fromTuningJobs;
|
|
9435
|
+
if (Array.isArray(transformedList)) {
|
|
9436
|
+
transformedList = transformedList.map((item) => {
|
|
9437
|
+
return tuningJobFromMldev(apiClient, item);
|
|
9438
|
+
});
|
|
9439
|
+
}
|
|
9440
|
+
setValueByPath(toObject, ['tuningJobs'], transformedList);
|
|
9441
|
+
}
|
|
9442
|
+
return toObject;
|
|
9443
|
+
}
|
|
9444
|
+
function operationFromMldev(apiClient, fromObject) {
|
|
9445
|
+
const toObject = {};
|
|
9446
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
9447
|
+
if (fromName != null) {
|
|
9448
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
9449
|
+
}
|
|
9450
|
+
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
9451
|
+
if (fromMetadata != null) {
|
|
9452
|
+
setValueByPath(toObject, ['metadata'], fromMetadata);
|
|
9453
|
+
}
|
|
9454
|
+
const fromDone = getValueByPath(fromObject, ['done']);
|
|
9455
|
+
if (fromDone != null) {
|
|
9456
|
+
setValueByPath(toObject, ['done'], fromDone);
|
|
9457
|
+
}
|
|
9458
|
+
const fromError = getValueByPath(fromObject, ['error']);
|
|
9459
|
+
if (fromError != null) {
|
|
9460
|
+
setValueByPath(toObject, ['error'], fromError);
|
|
9461
|
+
}
|
|
9462
|
+
return toObject;
|
|
9463
|
+
}
|
|
9464
|
+
function tunedModelFromVertex(apiClient, fromObject) {
|
|
9465
|
+
const toObject = {};
|
|
9466
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
9467
|
+
if (fromModel != null) {
|
|
9468
|
+
setValueByPath(toObject, ['model'], fromModel);
|
|
9469
|
+
}
|
|
9470
|
+
const fromEndpoint = getValueByPath(fromObject, ['endpoint']);
|
|
9471
|
+
if (fromEndpoint != null) {
|
|
9472
|
+
setValueByPath(toObject, ['endpoint'], fromEndpoint);
|
|
9473
|
+
}
|
|
9474
|
+
return toObject;
|
|
9475
|
+
}
|
|
9476
|
+
function tuningJobFromVertex(apiClient, fromObject) {
|
|
9477
|
+
const toObject = {};
|
|
9478
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
9479
|
+
if (fromName != null) {
|
|
9480
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
9481
|
+
}
|
|
9482
|
+
const fromState = getValueByPath(fromObject, ['state']);
|
|
9483
|
+
if (fromState != null) {
|
|
9484
|
+
setValueByPath(toObject, ['state'], tTuningJobStatus(apiClient, fromState));
|
|
9485
|
+
}
|
|
9486
|
+
const fromCreateTime = getValueByPath(fromObject, ['createTime']);
|
|
9487
|
+
if (fromCreateTime != null) {
|
|
9488
|
+
setValueByPath(toObject, ['createTime'], fromCreateTime);
|
|
9489
|
+
}
|
|
9490
|
+
const fromStartTime = getValueByPath(fromObject, ['startTime']);
|
|
9491
|
+
if (fromStartTime != null) {
|
|
9492
|
+
setValueByPath(toObject, ['startTime'], fromStartTime);
|
|
9493
|
+
}
|
|
9494
|
+
const fromEndTime = getValueByPath(fromObject, ['endTime']);
|
|
9495
|
+
if (fromEndTime != null) {
|
|
9496
|
+
setValueByPath(toObject, ['endTime'], fromEndTime);
|
|
9497
|
+
}
|
|
9498
|
+
const fromUpdateTime = getValueByPath(fromObject, ['updateTime']);
|
|
9499
|
+
if (fromUpdateTime != null) {
|
|
9500
|
+
setValueByPath(toObject, ['updateTime'], fromUpdateTime);
|
|
9501
|
+
}
|
|
9502
|
+
const fromError = getValueByPath(fromObject, ['error']);
|
|
9503
|
+
if (fromError != null) {
|
|
9504
|
+
setValueByPath(toObject, ['error'], fromError);
|
|
9505
|
+
}
|
|
9506
|
+
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
9507
|
+
if (fromDescription != null) {
|
|
9508
|
+
setValueByPath(toObject, ['description'], fromDescription);
|
|
9509
|
+
}
|
|
9510
|
+
const fromBaseModel = getValueByPath(fromObject, ['baseModel']);
|
|
9511
|
+
if (fromBaseModel != null) {
|
|
9512
|
+
setValueByPath(toObject, ['baseModel'], fromBaseModel);
|
|
9513
|
+
}
|
|
9514
|
+
const fromTunedModel = getValueByPath(fromObject, ['tunedModel']);
|
|
9515
|
+
if (fromTunedModel != null) {
|
|
9516
|
+
setValueByPath(toObject, ['tunedModel'], tunedModelFromVertex(apiClient, fromTunedModel));
|
|
9517
|
+
}
|
|
9518
|
+
const fromSupervisedTuningSpec = getValueByPath(fromObject, [
|
|
9519
|
+
'supervisedTuningSpec',
|
|
9520
|
+
]);
|
|
9521
|
+
if (fromSupervisedTuningSpec != null) {
|
|
9522
|
+
setValueByPath(toObject, ['supervisedTuningSpec'], fromSupervisedTuningSpec);
|
|
9523
|
+
}
|
|
9524
|
+
const fromTuningDataStats = getValueByPath(fromObject, [
|
|
9525
|
+
'tuningDataStats',
|
|
9526
|
+
]);
|
|
9527
|
+
if (fromTuningDataStats != null) {
|
|
9528
|
+
setValueByPath(toObject, ['tuningDataStats'], fromTuningDataStats);
|
|
9529
|
+
}
|
|
9530
|
+
const fromEncryptionSpec = getValueByPath(fromObject, [
|
|
9531
|
+
'encryptionSpec',
|
|
9532
|
+
]);
|
|
9533
|
+
if (fromEncryptionSpec != null) {
|
|
9534
|
+
setValueByPath(toObject, ['encryptionSpec'], fromEncryptionSpec);
|
|
9535
|
+
}
|
|
9536
|
+
const fromPartnerModelTuningSpec = getValueByPath(fromObject, [
|
|
9537
|
+
'partnerModelTuningSpec',
|
|
9538
|
+
]);
|
|
9539
|
+
if (fromPartnerModelTuningSpec != null) {
|
|
9540
|
+
setValueByPath(toObject, ['partnerModelTuningSpec'], fromPartnerModelTuningSpec);
|
|
9541
|
+
}
|
|
9542
|
+
const fromDistillationSpec = getValueByPath(fromObject, [
|
|
9543
|
+
'distillationSpec',
|
|
9544
|
+
]);
|
|
9545
|
+
if (fromDistillationSpec != null) {
|
|
9546
|
+
setValueByPath(toObject, ['distillationSpec'], fromDistillationSpec);
|
|
9547
|
+
}
|
|
9548
|
+
const fromExperiment = getValueByPath(fromObject, ['experiment']);
|
|
9549
|
+
if (fromExperiment != null) {
|
|
9550
|
+
setValueByPath(toObject, ['experiment'], fromExperiment);
|
|
9551
|
+
}
|
|
9552
|
+
const fromLabels = getValueByPath(fromObject, ['labels']);
|
|
9553
|
+
if (fromLabels != null) {
|
|
9554
|
+
setValueByPath(toObject, ['labels'], fromLabels);
|
|
9555
|
+
}
|
|
9556
|
+
const fromPipelineJob = getValueByPath(fromObject, ['pipelineJob']);
|
|
9557
|
+
if (fromPipelineJob != null) {
|
|
9558
|
+
setValueByPath(toObject, ['pipelineJob'], fromPipelineJob);
|
|
9559
|
+
}
|
|
9560
|
+
const fromTunedModelDisplayName = getValueByPath(fromObject, [
|
|
9561
|
+
'tunedModelDisplayName',
|
|
9562
|
+
]);
|
|
9563
|
+
if (fromTunedModelDisplayName != null) {
|
|
9564
|
+
setValueByPath(toObject, ['tunedModelDisplayName'], fromTunedModelDisplayName);
|
|
9565
|
+
}
|
|
9566
|
+
return toObject;
|
|
9567
|
+
}
|
|
9568
|
+
function listTuningJobsResponseFromVertex(apiClient, fromObject) {
|
|
9569
|
+
const toObject = {};
|
|
9570
|
+
const fromNextPageToken = getValueByPath(fromObject, [
|
|
9571
|
+
'nextPageToken',
|
|
9572
|
+
]);
|
|
9573
|
+
if (fromNextPageToken != null) {
|
|
9574
|
+
setValueByPath(toObject, ['nextPageToken'], fromNextPageToken);
|
|
9575
|
+
}
|
|
9576
|
+
const fromTuningJobs = getValueByPath(fromObject, ['tuningJobs']);
|
|
9577
|
+
if (fromTuningJobs != null) {
|
|
9578
|
+
let transformedList = fromTuningJobs;
|
|
9579
|
+
if (Array.isArray(transformedList)) {
|
|
9580
|
+
transformedList = transformedList.map((item) => {
|
|
9581
|
+
return tuningJobFromVertex(apiClient, item);
|
|
9582
|
+
});
|
|
9583
|
+
}
|
|
9584
|
+
setValueByPath(toObject, ['tuningJobs'], transformedList);
|
|
9585
|
+
}
|
|
9586
|
+
return toObject;
|
|
9587
|
+
}
|
|
9588
|
+
|
|
9589
|
+
/**
|
|
9590
|
+
* @license
|
|
9591
|
+
* Copyright 2025 Google LLC
|
|
9592
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
9593
|
+
*/
|
|
9594
|
+
class Tunings extends BaseModule {
|
|
9595
|
+
constructor(apiClient) {
|
|
9596
|
+
super();
|
|
9597
|
+
this.apiClient = apiClient;
|
|
9598
|
+
/**
|
|
9599
|
+
* Gets a TuningJob.
|
|
9600
|
+
*
|
|
9601
|
+
* @param name - The resource name of the tuning job.
|
|
9602
|
+
* @return - A TuningJob object.
|
|
9603
|
+
*
|
|
9604
|
+
* @experimental - The SDK's tuning implementation is experimental, and may
|
|
9605
|
+
* change in future versions.
|
|
9606
|
+
*/
|
|
9607
|
+
this.get = async (params) => {
|
|
9608
|
+
return await this.getInternal(params);
|
|
9609
|
+
};
|
|
9610
|
+
/**
|
|
9611
|
+
* Lists tuning jobs.
|
|
9612
|
+
*
|
|
9613
|
+
* @param config - The configuration for the list request.
|
|
9614
|
+
* @return - A list of tuning jobs.
|
|
9615
|
+
*
|
|
9616
|
+
* @experimental - The SDK's tuning implementation is experimental, and may
|
|
9617
|
+
* change in future versions.
|
|
9618
|
+
*/
|
|
9619
|
+
this.list = async (params = {}) => {
|
|
9620
|
+
return new Pager(PagedItem.PAGED_ITEM_TUNING_JOBS, (x) => this.listInternal(x), await this.listInternal(params), params);
|
|
9621
|
+
};
|
|
9622
|
+
/**
|
|
9623
|
+
* Creates a supervised fine-tuning job.
|
|
9624
|
+
*
|
|
9625
|
+
* @param params - The parameters for the tuning job.
|
|
9626
|
+
* @return - A TuningJob operation.
|
|
9627
|
+
*
|
|
9628
|
+
* @experimental - The SDK's tuning implementation is experimental, and may
|
|
9629
|
+
* change in future versions.
|
|
9630
|
+
*/
|
|
9631
|
+
this.tune = async (params) => {
|
|
9632
|
+
if (this.apiClient.isVertexAI()) {
|
|
9633
|
+
return await this.tuneInternal(params);
|
|
9634
|
+
}
|
|
9635
|
+
else {
|
|
9636
|
+
const operation = await this.tuneMldevInternal(params);
|
|
9637
|
+
let tunedModelName = '';
|
|
9638
|
+
if (operation['metadata'] !== undefined &&
|
|
9639
|
+
operation['metadata']['tunedModel'] !== undefined) {
|
|
9640
|
+
tunedModelName = operation['metadata']['tunedModel'];
|
|
9641
|
+
}
|
|
9642
|
+
else if (operation['name'] !== undefined &&
|
|
9643
|
+
operation['name'].includes('/operations/')) {
|
|
9644
|
+
tunedModelName = operation['name'].split('/operations/')[0];
|
|
9645
|
+
}
|
|
9646
|
+
const tuningJob = {
|
|
9647
|
+
name: tunedModelName,
|
|
9648
|
+
state: JobState.JOB_STATE_QUEUED,
|
|
9649
|
+
};
|
|
9650
|
+
return tuningJob;
|
|
9651
|
+
}
|
|
9652
|
+
};
|
|
9653
|
+
}
|
|
9654
|
+
async getInternal(params) {
|
|
9655
|
+
var _a, _b, _c, _d;
|
|
9656
|
+
let response;
|
|
9657
|
+
let path = '';
|
|
9658
|
+
let queryParams = {};
|
|
9659
|
+
if (this.apiClient.isVertexAI()) {
|
|
9660
|
+
const body = getTuningJobParametersToVertex(this.apiClient, params);
|
|
9661
|
+
path = formatMap('{name}', body['_url']);
|
|
9662
|
+
queryParams = body['_query'];
|
|
9663
|
+
delete body['config'];
|
|
9664
|
+
delete body['_url'];
|
|
9665
|
+
delete body['_query'];
|
|
9666
|
+
response = this.apiClient
|
|
9667
|
+
.request({
|
|
9668
|
+
path: path,
|
|
9669
|
+
queryParams: queryParams,
|
|
9670
|
+
body: JSON.stringify(body),
|
|
9671
|
+
httpMethod: 'GET',
|
|
9672
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
9673
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
9674
|
+
})
|
|
9675
|
+
.then((httpResponse) => {
|
|
9676
|
+
return httpResponse.json();
|
|
9677
|
+
});
|
|
9678
|
+
return response.then((apiResponse) => {
|
|
9679
|
+
const resp = tuningJobFromVertex(this.apiClient, apiResponse);
|
|
9680
|
+
return resp;
|
|
9681
|
+
});
|
|
9682
|
+
}
|
|
9683
|
+
else {
|
|
9684
|
+
const body = getTuningJobParametersToMldev(this.apiClient, params);
|
|
9685
|
+
path = formatMap('{name}', body['_url']);
|
|
9686
|
+
queryParams = body['_query'];
|
|
9687
|
+
delete body['config'];
|
|
9688
|
+
delete body['_url'];
|
|
9689
|
+
delete body['_query'];
|
|
9690
|
+
response = this.apiClient
|
|
9691
|
+
.request({
|
|
9692
|
+
path: path,
|
|
9693
|
+
queryParams: queryParams,
|
|
9694
|
+
body: JSON.stringify(body),
|
|
9695
|
+
httpMethod: 'GET',
|
|
9696
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
9697
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
9698
|
+
})
|
|
9699
|
+
.then((httpResponse) => {
|
|
9700
|
+
return httpResponse.json();
|
|
9701
|
+
});
|
|
9702
|
+
return response.then((apiResponse) => {
|
|
9703
|
+
const resp = tuningJobFromMldev(this.apiClient, apiResponse);
|
|
9704
|
+
return resp;
|
|
9705
|
+
});
|
|
9706
|
+
}
|
|
9707
|
+
}
|
|
9708
|
+
async listInternal(params) {
|
|
9709
|
+
var _a, _b, _c, _d;
|
|
9710
|
+
let response;
|
|
9711
|
+
let path = '';
|
|
9712
|
+
let queryParams = {};
|
|
9713
|
+
if (this.apiClient.isVertexAI()) {
|
|
9714
|
+
const body = listTuningJobsParametersToVertex(this.apiClient, params);
|
|
9715
|
+
path = formatMap('tuningJobs', body['_url']);
|
|
9716
|
+
queryParams = body['_query'];
|
|
9717
|
+
delete body['config'];
|
|
9718
|
+
delete body['_url'];
|
|
9719
|
+
delete body['_query'];
|
|
9720
|
+
response = this.apiClient
|
|
9721
|
+
.request({
|
|
9722
|
+
path: path,
|
|
9723
|
+
queryParams: queryParams,
|
|
9724
|
+
body: JSON.stringify(body),
|
|
9725
|
+
httpMethod: 'GET',
|
|
9726
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
9727
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
9728
|
+
})
|
|
9729
|
+
.then((httpResponse) => {
|
|
9730
|
+
return httpResponse.json();
|
|
9731
|
+
});
|
|
9732
|
+
return response.then((apiResponse) => {
|
|
9733
|
+
const resp = listTuningJobsResponseFromVertex(this.apiClient, apiResponse);
|
|
9734
|
+
const typedResp = new ListTuningJobsResponse();
|
|
9735
|
+
Object.assign(typedResp, resp);
|
|
9736
|
+
return typedResp;
|
|
9737
|
+
});
|
|
9738
|
+
}
|
|
9739
|
+
else {
|
|
9740
|
+
const body = listTuningJobsParametersToMldev(this.apiClient, params);
|
|
9741
|
+
path = formatMap('tunedModels', body['_url']);
|
|
9742
|
+
queryParams = body['_query'];
|
|
9743
|
+
delete body['config'];
|
|
9744
|
+
delete body['_url'];
|
|
9745
|
+
delete body['_query'];
|
|
9746
|
+
response = this.apiClient
|
|
9747
|
+
.request({
|
|
9748
|
+
path: path,
|
|
9749
|
+
queryParams: queryParams,
|
|
9750
|
+
body: JSON.stringify(body),
|
|
9751
|
+
httpMethod: 'GET',
|
|
9752
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
9753
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
9754
|
+
})
|
|
9755
|
+
.then((httpResponse) => {
|
|
9756
|
+
return httpResponse.json();
|
|
9757
|
+
});
|
|
9758
|
+
return response.then((apiResponse) => {
|
|
9759
|
+
const resp = listTuningJobsResponseFromMldev(this.apiClient, apiResponse);
|
|
9760
|
+
const typedResp = new ListTuningJobsResponse();
|
|
9761
|
+
Object.assign(typedResp, resp);
|
|
9762
|
+
return typedResp;
|
|
9763
|
+
});
|
|
9764
|
+
}
|
|
9765
|
+
}
|
|
9766
|
+
async tuneInternal(params) {
|
|
9767
|
+
var _a, _b;
|
|
9768
|
+
let response;
|
|
9769
|
+
let path = '';
|
|
9770
|
+
let queryParams = {};
|
|
9771
|
+
if (this.apiClient.isVertexAI()) {
|
|
9772
|
+
const body = createTuningJobParametersToVertex(this.apiClient, params);
|
|
9773
|
+
path = formatMap('tuningJobs', body['_url']);
|
|
9774
|
+
queryParams = body['_query'];
|
|
9775
|
+
delete body['config'];
|
|
9776
|
+
delete body['_url'];
|
|
9777
|
+
delete body['_query'];
|
|
9778
|
+
response = this.apiClient
|
|
9779
|
+
.request({
|
|
9780
|
+
path: path,
|
|
9781
|
+
queryParams: queryParams,
|
|
9782
|
+
body: JSON.stringify(body),
|
|
9783
|
+
httpMethod: 'POST',
|
|
9784
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
9785
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
9786
|
+
})
|
|
9787
|
+
.then((httpResponse) => {
|
|
9788
|
+
return httpResponse.json();
|
|
9789
|
+
});
|
|
9790
|
+
return response.then((apiResponse) => {
|
|
9791
|
+
const resp = tuningJobFromVertex(this.apiClient, apiResponse);
|
|
9792
|
+
return resp;
|
|
9793
|
+
});
|
|
9794
|
+
}
|
|
9795
|
+
else {
|
|
9796
|
+
throw new Error('This method is only supported by the Vertex AI.');
|
|
9797
|
+
}
|
|
9798
|
+
}
|
|
9799
|
+
async tuneMldevInternal(params) {
|
|
9800
|
+
var _a, _b;
|
|
9801
|
+
let response;
|
|
9802
|
+
let path = '';
|
|
9803
|
+
let queryParams = {};
|
|
9804
|
+
if (this.apiClient.isVertexAI()) {
|
|
9805
|
+
throw new Error('This method is only supported by the Gemini Developer API.');
|
|
9806
|
+
}
|
|
9807
|
+
else {
|
|
9808
|
+
const body = createTuningJobParametersToMldev(this.apiClient, params);
|
|
9809
|
+
path = formatMap('tunedModels', body['_url']);
|
|
9810
|
+
queryParams = body['_query'];
|
|
9811
|
+
delete body['config'];
|
|
9812
|
+
delete body['_url'];
|
|
9813
|
+
delete body['_query'];
|
|
9814
|
+
response = this.apiClient
|
|
9815
|
+
.request({
|
|
9816
|
+
path: path,
|
|
9817
|
+
queryParams: queryParams,
|
|
9818
|
+
body: JSON.stringify(body),
|
|
9819
|
+
httpMethod: 'POST',
|
|
9820
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
9821
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
9822
|
+
})
|
|
9823
|
+
.then((httpResponse) => {
|
|
9824
|
+
return httpResponse.json();
|
|
9825
|
+
});
|
|
9826
|
+
return response.then((apiResponse) => {
|
|
9827
|
+
const resp = operationFromMldev(this.apiClient, apiResponse);
|
|
9828
|
+
return resp;
|
|
9829
|
+
});
|
|
9830
|
+
}
|
|
9831
|
+
}
|
|
9832
|
+
}
|
|
9833
|
+
|
|
9411
9834
|
const MAX_CHUNK_SIZE = 1024 * 1024 * 8; // bytes
|
|
9412
9835
|
async function uploadBlob(file, uploadUrl, apiClient) {
|
|
9413
9836
|
var _a, _b;
|
|
@@ -9617,8 +10040,9 @@ class GoogleGenAI {
|
|
|
9617
10040
|
this.caches = new Caches(this.apiClient);
|
|
9618
10041
|
this.files = new Files(this.apiClient);
|
|
9619
10042
|
this.operations = new Operations(this.apiClient);
|
|
10043
|
+
this.tunings = new Tunings(this.apiClient);
|
|
9620
10044
|
}
|
|
9621
10045
|
}
|
|
9622
10046
|
|
|
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 };
|
|
10047
|
+
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
10048
|
//# sourceMappingURL=index.mjs.map
|