@google/genai 0.7.0 → 0.9.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/README.md +9 -34
- package/dist/genai.d.ts +530 -57
- package/dist/index.js +1984 -483
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1985 -484
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.js +2028 -526
- package/dist/node/index.js.map +1 -1
- package/dist/node/node.d.ts +530 -57
- package/dist/web/index.mjs +2024 -523
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +530 -57
- package/package.json +6 -2
package/dist/index.mjs
CHANGED
|
@@ -209,44 +209,25 @@ function _isFunctionCallPart(origin) {
|
|
|
209
209
|
typeof origin === 'object' &&
|
|
210
210
|
'functionCall' in origin);
|
|
211
211
|
}
|
|
212
|
-
function
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
return false;
|
|
218
|
-
}
|
|
219
|
-
return true;
|
|
220
|
-
}
|
|
221
|
-
function _areUserParts(origin) {
|
|
222
|
-
if (origin === null ||
|
|
223
|
-
origin === undefined ||
|
|
224
|
-
(Array.isArray(origin) && origin.length === 0)) {
|
|
225
|
-
return false;
|
|
226
|
-
}
|
|
227
|
-
return origin.every(_isUserPart);
|
|
212
|
+
function _isFunctionResponsePart(origin) {
|
|
213
|
+
return (origin !== null &&
|
|
214
|
+
origin !== undefined &&
|
|
215
|
+
typeof origin === 'object' &&
|
|
216
|
+
'functionResponse' in origin);
|
|
228
217
|
}
|
|
229
218
|
function tContent(apiClient, origin) {
|
|
230
219
|
if (origin === null || origin === undefined) {
|
|
231
220
|
throw new Error('ContentUnion is required');
|
|
232
221
|
}
|
|
233
222
|
if (_isContent(origin)) {
|
|
234
|
-
//
|
|
223
|
+
// _isContent is a utility function that checks if the
|
|
235
224
|
// origin is a Content.
|
|
236
225
|
return origin;
|
|
237
226
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
else {
|
|
245
|
-
return {
|
|
246
|
-
role: 'model',
|
|
247
|
-
parts: tParts(apiClient, origin),
|
|
248
|
-
};
|
|
249
|
-
}
|
|
227
|
+
return {
|
|
228
|
+
role: 'user',
|
|
229
|
+
parts: tParts(apiClient, origin),
|
|
230
|
+
};
|
|
250
231
|
}
|
|
251
232
|
function tContentsForEmbed(apiClient, origin) {
|
|
252
233
|
if (!origin) {
|
|
@@ -277,34 +258,6 @@ function tContentsForEmbed(apiClient, origin) {
|
|
|
277
258
|
}
|
|
278
259
|
return [tContent(apiClient, origin)];
|
|
279
260
|
}
|
|
280
|
-
function _appendAccumulatedPartsAsContent(apiClient, result, accumulatedParts) {
|
|
281
|
-
if (accumulatedParts.length === 0) {
|
|
282
|
-
return;
|
|
283
|
-
}
|
|
284
|
-
if (_areUserParts(accumulatedParts)) {
|
|
285
|
-
result.push({
|
|
286
|
-
role: 'user',
|
|
287
|
-
parts: tParts(apiClient, accumulatedParts),
|
|
288
|
-
});
|
|
289
|
-
}
|
|
290
|
-
else {
|
|
291
|
-
result.push({
|
|
292
|
-
role: 'model',
|
|
293
|
-
parts: tParts(apiClient, accumulatedParts),
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
accumulatedParts.length = 0; // clear the array inplace
|
|
297
|
-
}
|
|
298
|
-
function _handleCurrentPart(apiClient, result, accumulatedParts, currentPart) {
|
|
299
|
-
if (_isUserPart(currentPart) === _areUserParts(accumulatedParts)) {
|
|
300
|
-
accumulatedParts.push(currentPart);
|
|
301
|
-
}
|
|
302
|
-
else {
|
|
303
|
-
_appendAccumulatedPartsAsContent(apiClient, result, accumulatedParts);
|
|
304
|
-
accumulatedParts.length = 0;
|
|
305
|
-
accumulatedParts.push(currentPart);
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
261
|
function tContents(apiClient, origin) {
|
|
309
262
|
if (origin === null ||
|
|
310
263
|
origin === undefined ||
|
|
@@ -312,35 +265,35 @@ function tContents(apiClient, origin) {
|
|
|
312
265
|
throw new Error('contents are required');
|
|
313
266
|
}
|
|
314
267
|
if (!Array.isArray(origin)) {
|
|
268
|
+
// If it's not an array, it's a single content or a single PartUnion.
|
|
269
|
+
if (_isFunctionCallPart(origin) || _isFunctionResponsePart(origin)) {
|
|
270
|
+
throw new Error('To specify functionCall or functionResponse parts, please wrap them in a Content object, specifying the role for them');
|
|
271
|
+
}
|
|
315
272
|
return [tContent(apiClient, origin)];
|
|
316
273
|
}
|
|
317
274
|
const result = [];
|
|
318
275
|
const accumulatedParts = [];
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
//
|
|
328
|
-
|
|
329
|
-
}
|
|
330
|
-
else if (
|
|
331
|
-
|
|
332
|
-
// convert to UserContent and append to result
|
|
333
|
-
_appendAccumulatedPartsAsContent(apiClient, result, accumulatedParts);
|
|
334
|
-
result.push({
|
|
335
|
-
role: 'user',
|
|
336
|
-
parts: tParts(apiClient, content),
|
|
337
|
-
});
|
|
276
|
+
const isContentArray = _isContent(origin[0]);
|
|
277
|
+
for (const item of origin) {
|
|
278
|
+
const isContent = _isContent(item);
|
|
279
|
+
if (isContent != isContentArray) {
|
|
280
|
+
throw new Error('Mixing Content and Parts is not supported, please group the parts into a the appropriate Content objects and specify the roles for them');
|
|
281
|
+
}
|
|
282
|
+
if (isContent) {
|
|
283
|
+
// `isContent` contains the result of _isContent, which is a utility
|
|
284
|
+
// function that checks if the item is a Content.
|
|
285
|
+
result.push(item);
|
|
286
|
+
}
|
|
287
|
+
else if (_isFunctionCallPart(item) || _isFunctionResponsePart(item)) {
|
|
288
|
+
throw new Error('To specify functionCall or functionResponse parts, please wrap them, and any other parts, in Content objects as appropriate, specifying the role for them');
|
|
338
289
|
}
|
|
339
290
|
else {
|
|
340
|
-
|
|
291
|
+
accumulatedParts.push(item);
|
|
341
292
|
}
|
|
342
293
|
}
|
|
343
|
-
|
|
294
|
+
if (!isContentArray) {
|
|
295
|
+
result.push({ role: 'user', parts: tParts(apiClient, accumulatedParts) });
|
|
296
|
+
}
|
|
344
297
|
return result;
|
|
345
298
|
}
|
|
346
299
|
function processSchema(apiClient, schema) {
|
|
@@ -505,7 +458,7 @@ function tFileName(apiClient, fromName) {
|
|
|
505
458
|
* Copyright 2025 Google LLC
|
|
506
459
|
* SPDX-License-Identifier: Apache-2.0
|
|
507
460
|
*/
|
|
508
|
-
function partToMldev$
|
|
461
|
+
function partToMldev$2(apiClient, fromObject) {
|
|
509
462
|
const toObject = {};
|
|
510
463
|
if (getValueByPath(fromObject, ['videoMetadata']) !== undefined) {
|
|
511
464
|
throw new Error('videoMetadata parameter is not supported in Gemini API.');
|
|
@@ -550,13 +503,13 @@ function partToMldev$1(apiClient, fromObject) {
|
|
|
550
503
|
}
|
|
551
504
|
return toObject;
|
|
552
505
|
}
|
|
553
|
-
function contentToMldev$
|
|
506
|
+
function contentToMldev$2(apiClient, fromObject) {
|
|
554
507
|
const toObject = {};
|
|
555
508
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
556
509
|
if (fromParts != null) {
|
|
557
510
|
if (Array.isArray(fromParts)) {
|
|
558
511
|
setValueByPath(toObject, ['parts'], fromParts.map((item) => {
|
|
559
|
-
return partToMldev$
|
|
512
|
+
return partToMldev$2(apiClient, item);
|
|
560
513
|
}));
|
|
561
514
|
}
|
|
562
515
|
else {
|
|
@@ -569,7 +522,7 @@ function contentToMldev$1(apiClient, fromObject) {
|
|
|
569
522
|
}
|
|
570
523
|
return toObject;
|
|
571
524
|
}
|
|
572
|
-
function functionDeclarationToMldev$
|
|
525
|
+
function functionDeclarationToMldev$2(apiClient, fromObject) {
|
|
573
526
|
const toObject = {};
|
|
574
527
|
if (getValueByPath(fromObject, ['response']) !== undefined) {
|
|
575
528
|
throw new Error('response parameter is not supported in Gemini API.');
|
|
@@ -588,11 +541,11 @@ function functionDeclarationToMldev$1(apiClient, fromObject) {
|
|
|
588
541
|
}
|
|
589
542
|
return toObject;
|
|
590
543
|
}
|
|
591
|
-
function googleSearchToMldev$
|
|
544
|
+
function googleSearchToMldev$2() {
|
|
592
545
|
const toObject = {};
|
|
593
546
|
return toObject;
|
|
594
547
|
}
|
|
595
|
-
function dynamicRetrievalConfigToMldev$
|
|
548
|
+
function dynamicRetrievalConfigToMldev$2(apiClient, fromObject) {
|
|
596
549
|
const toObject = {};
|
|
597
550
|
const fromMode = getValueByPath(fromObject, ['mode']);
|
|
598
551
|
if (fromMode != null) {
|
|
@@ -606,17 +559,17 @@ function dynamicRetrievalConfigToMldev$1(apiClient, fromObject) {
|
|
|
606
559
|
}
|
|
607
560
|
return toObject;
|
|
608
561
|
}
|
|
609
|
-
function googleSearchRetrievalToMldev$
|
|
562
|
+
function googleSearchRetrievalToMldev$2(apiClient, fromObject) {
|
|
610
563
|
const toObject = {};
|
|
611
564
|
const fromDynamicRetrievalConfig = getValueByPath(fromObject, [
|
|
612
565
|
'dynamicRetrievalConfig',
|
|
613
566
|
]);
|
|
614
567
|
if (fromDynamicRetrievalConfig != null) {
|
|
615
|
-
setValueByPath(toObject, ['dynamicRetrievalConfig'], dynamicRetrievalConfigToMldev$
|
|
568
|
+
setValueByPath(toObject, ['dynamicRetrievalConfig'], dynamicRetrievalConfigToMldev$2(apiClient, fromDynamicRetrievalConfig));
|
|
616
569
|
}
|
|
617
570
|
return toObject;
|
|
618
571
|
}
|
|
619
|
-
function toolToMldev$
|
|
572
|
+
function toolToMldev$2(apiClient, fromObject) {
|
|
620
573
|
const toObject = {};
|
|
621
574
|
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
622
575
|
'functionDeclarations',
|
|
@@ -624,7 +577,7 @@ function toolToMldev$1(apiClient, fromObject) {
|
|
|
624
577
|
if (fromFunctionDeclarations != null) {
|
|
625
578
|
if (Array.isArray(fromFunctionDeclarations)) {
|
|
626
579
|
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations.map((item) => {
|
|
627
|
-
return functionDeclarationToMldev$
|
|
580
|
+
return functionDeclarationToMldev$2(apiClient, item);
|
|
628
581
|
}));
|
|
629
582
|
}
|
|
630
583
|
else {
|
|
@@ -636,13 +589,13 @@ function toolToMldev$1(apiClient, fromObject) {
|
|
|
636
589
|
}
|
|
637
590
|
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
638
591
|
if (fromGoogleSearch != null) {
|
|
639
|
-
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$
|
|
592
|
+
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$2());
|
|
640
593
|
}
|
|
641
594
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
642
595
|
'googleSearchRetrieval',
|
|
643
596
|
]);
|
|
644
597
|
if (fromGoogleSearchRetrieval != null) {
|
|
645
|
-
setValueByPath(toObject, ['googleSearchRetrieval'], googleSearchRetrievalToMldev$
|
|
598
|
+
setValueByPath(toObject, ['googleSearchRetrieval'], googleSearchRetrievalToMldev$2(apiClient, fromGoogleSearchRetrieval));
|
|
646
599
|
}
|
|
647
600
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
648
601
|
'codeExecution',
|
|
@@ -694,7 +647,7 @@ function createCachedContentConfigToMldev(apiClient, fromObject, parentObject) {
|
|
|
694
647
|
if (parentObject !== undefined && fromContents != null) {
|
|
695
648
|
if (Array.isArray(fromContents)) {
|
|
696
649
|
setValueByPath(parentObject, ['contents'], tContents(apiClient, tContents(apiClient, fromContents).map((item) => {
|
|
697
|
-
return contentToMldev$
|
|
650
|
+
return contentToMldev$2(apiClient, item);
|
|
698
651
|
})));
|
|
699
652
|
}
|
|
700
653
|
else {
|
|
@@ -705,13 +658,13 @@ function createCachedContentConfigToMldev(apiClient, fromObject, parentObject) {
|
|
|
705
658
|
'systemInstruction',
|
|
706
659
|
]);
|
|
707
660
|
if (parentObject !== undefined && fromSystemInstruction != null) {
|
|
708
|
-
setValueByPath(parentObject, ['systemInstruction'], contentToMldev$
|
|
661
|
+
setValueByPath(parentObject, ['systemInstruction'], contentToMldev$2(apiClient, tContent(apiClient, fromSystemInstruction)));
|
|
709
662
|
}
|
|
710
663
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
711
664
|
if (parentObject !== undefined && fromTools != null) {
|
|
712
665
|
if (Array.isArray(fromTools)) {
|
|
713
666
|
setValueByPath(parentObject, ['tools'], fromTools.map((item) => {
|
|
714
|
-
return toolToMldev$
|
|
667
|
+
return toolToMldev$2(apiClient, item);
|
|
715
668
|
}));
|
|
716
669
|
}
|
|
717
670
|
else {
|
|
@@ -804,7 +757,7 @@ function listCachedContentsParametersToMldev(apiClient, fromObject) {
|
|
|
804
757
|
}
|
|
805
758
|
return toObject;
|
|
806
759
|
}
|
|
807
|
-
function partToVertex$
|
|
760
|
+
function partToVertex$2(apiClient, fromObject) {
|
|
808
761
|
const toObject = {};
|
|
809
762
|
const fromVideoMetadata = getValueByPath(fromObject, [
|
|
810
763
|
'videoMetadata',
|
|
@@ -852,13 +805,13 @@ function partToVertex$1(apiClient, fromObject) {
|
|
|
852
805
|
}
|
|
853
806
|
return toObject;
|
|
854
807
|
}
|
|
855
|
-
function contentToVertex$
|
|
808
|
+
function contentToVertex$2(apiClient, fromObject) {
|
|
856
809
|
const toObject = {};
|
|
857
810
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
858
811
|
if (fromParts != null) {
|
|
859
812
|
if (Array.isArray(fromParts)) {
|
|
860
813
|
setValueByPath(toObject, ['parts'], fromParts.map((item) => {
|
|
861
|
-
return partToVertex$
|
|
814
|
+
return partToVertex$2(apiClient, item);
|
|
862
815
|
}));
|
|
863
816
|
}
|
|
864
817
|
else {
|
|
@@ -871,7 +824,7 @@ function contentToVertex$1(apiClient, fromObject) {
|
|
|
871
824
|
}
|
|
872
825
|
return toObject;
|
|
873
826
|
}
|
|
874
|
-
function schemaToVertex$
|
|
827
|
+
function schemaToVertex$2(apiClient, fromObject) {
|
|
875
828
|
const toObject = {};
|
|
876
829
|
const fromExample = getValueByPath(fromObject, ['example']);
|
|
877
830
|
if (fromExample != null) {
|
|
@@ -969,11 +922,11 @@ function schemaToVertex$1(apiClient, fromObject) {
|
|
|
969
922
|
}
|
|
970
923
|
return toObject;
|
|
971
924
|
}
|
|
972
|
-
function functionDeclarationToVertex$
|
|
925
|
+
function functionDeclarationToVertex$2(apiClient, fromObject) {
|
|
973
926
|
const toObject = {};
|
|
974
927
|
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
975
928
|
if (fromResponse != null) {
|
|
976
|
-
setValueByPath(toObject, ['response'], schemaToVertex$
|
|
929
|
+
setValueByPath(toObject, ['response'], schemaToVertex$2(apiClient, fromResponse));
|
|
977
930
|
}
|
|
978
931
|
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
979
932
|
if (fromDescription != null) {
|
|
@@ -989,11 +942,11 @@ function functionDeclarationToVertex$1(apiClient, fromObject) {
|
|
|
989
942
|
}
|
|
990
943
|
return toObject;
|
|
991
944
|
}
|
|
992
|
-
function googleSearchToVertex$
|
|
945
|
+
function googleSearchToVertex$2() {
|
|
993
946
|
const toObject = {};
|
|
994
947
|
return toObject;
|
|
995
948
|
}
|
|
996
|
-
function dynamicRetrievalConfigToVertex$
|
|
949
|
+
function dynamicRetrievalConfigToVertex$2(apiClient, fromObject) {
|
|
997
950
|
const toObject = {};
|
|
998
951
|
const fromMode = getValueByPath(fromObject, ['mode']);
|
|
999
952
|
if (fromMode != null) {
|
|
@@ -1007,17 +960,17 @@ function dynamicRetrievalConfigToVertex$1(apiClient, fromObject) {
|
|
|
1007
960
|
}
|
|
1008
961
|
return toObject;
|
|
1009
962
|
}
|
|
1010
|
-
function googleSearchRetrievalToVertex$
|
|
963
|
+
function googleSearchRetrievalToVertex$2(apiClient, fromObject) {
|
|
1011
964
|
const toObject = {};
|
|
1012
965
|
const fromDynamicRetrievalConfig = getValueByPath(fromObject, [
|
|
1013
966
|
'dynamicRetrievalConfig',
|
|
1014
967
|
]);
|
|
1015
968
|
if (fromDynamicRetrievalConfig != null) {
|
|
1016
|
-
setValueByPath(toObject, ['dynamicRetrievalConfig'], dynamicRetrievalConfigToVertex$
|
|
969
|
+
setValueByPath(toObject, ['dynamicRetrievalConfig'], dynamicRetrievalConfigToVertex$2(apiClient, fromDynamicRetrievalConfig));
|
|
1017
970
|
}
|
|
1018
971
|
return toObject;
|
|
1019
972
|
}
|
|
1020
|
-
function toolToVertex$
|
|
973
|
+
function toolToVertex$2(apiClient, fromObject) {
|
|
1021
974
|
const toObject = {};
|
|
1022
975
|
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
1023
976
|
'functionDeclarations',
|
|
@@ -1025,7 +978,7 @@ function toolToVertex$1(apiClient, fromObject) {
|
|
|
1025
978
|
if (fromFunctionDeclarations != null) {
|
|
1026
979
|
if (Array.isArray(fromFunctionDeclarations)) {
|
|
1027
980
|
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations.map((item) => {
|
|
1028
|
-
return functionDeclarationToVertex$
|
|
981
|
+
return functionDeclarationToVertex$2(apiClient, item);
|
|
1029
982
|
}));
|
|
1030
983
|
}
|
|
1031
984
|
else {
|
|
@@ -1038,13 +991,13 @@ function toolToVertex$1(apiClient, fromObject) {
|
|
|
1038
991
|
}
|
|
1039
992
|
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
1040
993
|
if (fromGoogleSearch != null) {
|
|
1041
|
-
setValueByPath(toObject, ['googleSearch'], googleSearchToVertex$
|
|
994
|
+
setValueByPath(toObject, ['googleSearch'], googleSearchToVertex$2());
|
|
1042
995
|
}
|
|
1043
996
|
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
1044
997
|
'googleSearchRetrieval',
|
|
1045
998
|
]);
|
|
1046
999
|
if (fromGoogleSearchRetrieval != null) {
|
|
1047
|
-
setValueByPath(toObject, ['googleSearchRetrieval'], googleSearchRetrievalToVertex$
|
|
1000
|
+
setValueByPath(toObject, ['googleSearchRetrieval'], googleSearchRetrievalToVertex$2(apiClient, fromGoogleSearchRetrieval));
|
|
1048
1001
|
}
|
|
1049
1002
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
1050
1003
|
'codeExecution',
|
|
@@ -1096,7 +1049,7 @@ function createCachedContentConfigToVertex(apiClient, fromObject, parentObject)
|
|
|
1096
1049
|
if (parentObject !== undefined && fromContents != null) {
|
|
1097
1050
|
if (Array.isArray(fromContents)) {
|
|
1098
1051
|
setValueByPath(parentObject, ['contents'], tContents(apiClient, tContents(apiClient, fromContents).map((item) => {
|
|
1099
|
-
return contentToVertex$
|
|
1052
|
+
return contentToVertex$2(apiClient, item);
|
|
1100
1053
|
})));
|
|
1101
1054
|
}
|
|
1102
1055
|
else {
|
|
@@ -1107,13 +1060,13 @@ function createCachedContentConfigToVertex(apiClient, fromObject, parentObject)
|
|
|
1107
1060
|
'systemInstruction',
|
|
1108
1061
|
]);
|
|
1109
1062
|
if (parentObject !== undefined && fromSystemInstruction != null) {
|
|
1110
|
-
setValueByPath(parentObject, ['systemInstruction'], contentToVertex$
|
|
1063
|
+
setValueByPath(parentObject, ['systemInstruction'], contentToVertex$2(apiClient, tContent(apiClient, fromSystemInstruction)));
|
|
1111
1064
|
}
|
|
1112
1065
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
1113
1066
|
if (parentObject !== undefined && fromTools != null) {
|
|
1114
1067
|
if (Array.isArray(fromTools)) {
|
|
1115
1068
|
setValueByPath(parentObject, ['tools'], fromTools.map((item) => {
|
|
1116
|
-
return toolToVertex$
|
|
1069
|
+
return toolToVertex$2(apiClient, item);
|
|
1117
1070
|
}));
|
|
1118
1071
|
}
|
|
1119
1072
|
else {
|
|
@@ -1512,6 +1465,7 @@ class Pager {
|
|
|
1512
1465
|
* SPDX-License-Identifier: Apache-2.0
|
|
1513
1466
|
*/
|
|
1514
1467
|
// Code generated by the Google Gen AI SDK generator DO NOT EDIT.
|
|
1468
|
+
/** Required. Outcome of the code execution. */
|
|
1515
1469
|
var Outcome;
|
|
1516
1470
|
(function (Outcome) {
|
|
1517
1471
|
Outcome["OUTCOME_UNSPECIFIED"] = "OUTCOME_UNSPECIFIED";
|
|
@@ -1519,11 +1473,13 @@ var Outcome;
|
|
|
1519
1473
|
Outcome["OUTCOME_FAILED"] = "OUTCOME_FAILED";
|
|
1520
1474
|
Outcome["OUTCOME_DEADLINE_EXCEEDED"] = "OUTCOME_DEADLINE_EXCEEDED";
|
|
1521
1475
|
})(Outcome || (Outcome = {}));
|
|
1476
|
+
/** Required. Programming language of the `code`. */
|
|
1522
1477
|
var Language;
|
|
1523
1478
|
(function (Language) {
|
|
1524
1479
|
Language["LANGUAGE_UNSPECIFIED"] = "LANGUAGE_UNSPECIFIED";
|
|
1525
1480
|
Language["PYTHON"] = "PYTHON";
|
|
1526
1481
|
})(Language || (Language = {}));
|
|
1482
|
+
/** Optional. The type of the data. */
|
|
1527
1483
|
var Type;
|
|
1528
1484
|
(function (Type) {
|
|
1529
1485
|
Type["TYPE_UNSPECIFIED"] = "TYPE_UNSPECIFIED";
|
|
@@ -1534,6 +1490,7 @@ var Type;
|
|
|
1534
1490
|
Type["ARRAY"] = "ARRAY";
|
|
1535
1491
|
Type["OBJECT"] = "OBJECT";
|
|
1536
1492
|
})(Type || (Type = {}));
|
|
1493
|
+
/** Required. Harm category. */
|
|
1537
1494
|
var HarmCategory;
|
|
1538
1495
|
(function (HarmCategory) {
|
|
1539
1496
|
HarmCategory["HARM_CATEGORY_UNSPECIFIED"] = "HARM_CATEGORY_UNSPECIFIED";
|
|
@@ -1543,12 +1500,14 @@ var HarmCategory;
|
|
|
1543
1500
|
HarmCategory["HARM_CATEGORY_SEXUALLY_EXPLICIT"] = "HARM_CATEGORY_SEXUALLY_EXPLICIT";
|
|
1544
1501
|
HarmCategory["HARM_CATEGORY_CIVIC_INTEGRITY"] = "HARM_CATEGORY_CIVIC_INTEGRITY";
|
|
1545
1502
|
})(HarmCategory || (HarmCategory = {}));
|
|
1503
|
+
/** Optional. Specify if the threshold is used for probability or severity score. If not specified, the threshold is used for probability score. */
|
|
1546
1504
|
var HarmBlockMethod;
|
|
1547
1505
|
(function (HarmBlockMethod) {
|
|
1548
1506
|
HarmBlockMethod["HARM_BLOCK_METHOD_UNSPECIFIED"] = "HARM_BLOCK_METHOD_UNSPECIFIED";
|
|
1549
1507
|
HarmBlockMethod["SEVERITY"] = "SEVERITY";
|
|
1550
1508
|
HarmBlockMethod["PROBABILITY"] = "PROBABILITY";
|
|
1551
1509
|
})(HarmBlockMethod || (HarmBlockMethod = {}));
|
|
1510
|
+
/** Required. The harm block threshold. */
|
|
1552
1511
|
var HarmBlockThreshold;
|
|
1553
1512
|
(function (HarmBlockThreshold) {
|
|
1554
1513
|
HarmBlockThreshold["HARM_BLOCK_THRESHOLD_UNSPECIFIED"] = "HARM_BLOCK_THRESHOLD_UNSPECIFIED";
|
|
@@ -1558,11 +1517,16 @@ var HarmBlockThreshold;
|
|
|
1558
1517
|
HarmBlockThreshold["BLOCK_NONE"] = "BLOCK_NONE";
|
|
1559
1518
|
HarmBlockThreshold["OFF"] = "OFF";
|
|
1560
1519
|
})(HarmBlockThreshold || (HarmBlockThreshold = {}));
|
|
1520
|
+
/** The mode of the predictor to be used in dynamic retrieval. */
|
|
1561
1521
|
var Mode;
|
|
1562
1522
|
(function (Mode) {
|
|
1563
1523
|
Mode["MODE_UNSPECIFIED"] = "MODE_UNSPECIFIED";
|
|
1564
1524
|
Mode["MODE_DYNAMIC"] = "MODE_DYNAMIC";
|
|
1565
1525
|
})(Mode || (Mode = {}));
|
|
1526
|
+
/** Output only. The reason why the model stopped generating tokens.
|
|
1527
|
+
|
|
1528
|
+
If empty, the model has not stopped generating the tokens.
|
|
1529
|
+
*/
|
|
1566
1530
|
var FinishReason;
|
|
1567
1531
|
(function (FinishReason) {
|
|
1568
1532
|
FinishReason["FINISH_REASON_UNSPECIFIED"] = "FINISH_REASON_UNSPECIFIED";
|
|
@@ -1577,6 +1541,7 @@ var FinishReason;
|
|
|
1577
1541
|
FinishReason["MALFORMED_FUNCTION_CALL"] = "MALFORMED_FUNCTION_CALL";
|
|
1578
1542
|
FinishReason["IMAGE_SAFETY"] = "IMAGE_SAFETY";
|
|
1579
1543
|
})(FinishReason || (FinishReason = {}));
|
|
1544
|
+
/** Output only. Harm probability levels in the content. */
|
|
1580
1545
|
var HarmProbability;
|
|
1581
1546
|
(function (HarmProbability) {
|
|
1582
1547
|
HarmProbability["HARM_PROBABILITY_UNSPECIFIED"] = "HARM_PROBABILITY_UNSPECIFIED";
|
|
@@ -1585,6 +1550,7 @@ var HarmProbability;
|
|
|
1585
1550
|
HarmProbability["MEDIUM"] = "MEDIUM";
|
|
1586
1551
|
HarmProbability["HIGH"] = "HIGH";
|
|
1587
1552
|
})(HarmProbability || (HarmProbability = {}));
|
|
1553
|
+
/** Output only. Harm severity levels in the content. */
|
|
1588
1554
|
var HarmSeverity;
|
|
1589
1555
|
(function (HarmSeverity) {
|
|
1590
1556
|
HarmSeverity["HARM_SEVERITY_UNSPECIFIED"] = "HARM_SEVERITY_UNSPECIFIED";
|
|
@@ -1593,6 +1559,7 @@ var HarmSeverity;
|
|
|
1593
1559
|
HarmSeverity["HARM_SEVERITY_MEDIUM"] = "HARM_SEVERITY_MEDIUM";
|
|
1594
1560
|
HarmSeverity["HARM_SEVERITY_HIGH"] = "HARM_SEVERITY_HIGH";
|
|
1595
1561
|
})(HarmSeverity || (HarmSeverity = {}));
|
|
1562
|
+
/** Output only. Blocked reason. */
|
|
1596
1563
|
var BlockedReason;
|
|
1597
1564
|
(function (BlockedReason) {
|
|
1598
1565
|
BlockedReason["BLOCKED_REASON_UNSPECIFIED"] = "BLOCKED_REASON_UNSPECIFIED";
|
|
@@ -1601,6 +1568,14 @@ var BlockedReason;
|
|
|
1601
1568
|
BlockedReason["BLOCKLIST"] = "BLOCKLIST";
|
|
1602
1569
|
BlockedReason["PROHIBITED_CONTENT"] = "PROHIBITED_CONTENT";
|
|
1603
1570
|
})(BlockedReason || (BlockedReason = {}));
|
|
1571
|
+
/** Output only. Traffic type. This shows whether a request consumes Pay-As-You-Go or Provisioned Throughput quota. */
|
|
1572
|
+
var TrafficType;
|
|
1573
|
+
(function (TrafficType) {
|
|
1574
|
+
TrafficType["TRAFFIC_TYPE_UNSPECIFIED"] = "TRAFFIC_TYPE_UNSPECIFIED";
|
|
1575
|
+
TrafficType["ON_DEMAND"] = "ON_DEMAND";
|
|
1576
|
+
TrafficType["PROVISIONED_THROUGHPUT"] = "PROVISIONED_THROUGHPUT";
|
|
1577
|
+
})(TrafficType || (TrafficType = {}));
|
|
1578
|
+
/** Server content modalities. */
|
|
1604
1579
|
var Modality;
|
|
1605
1580
|
(function (Modality) {
|
|
1606
1581
|
Modality["MODALITY_UNSPECIFIED"] = "MODALITY_UNSPECIFIED";
|
|
@@ -1608,17 +1583,29 @@ var Modality;
|
|
|
1608
1583
|
Modality["IMAGE"] = "IMAGE";
|
|
1609
1584
|
Modality["AUDIO"] = "AUDIO";
|
|
1610
1585
|
})(Modality || (Modality = {}));
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1586
|
+
/** The media resolution to use. */
|
|
1587
|
+
var MediaResolution;
|
|
1588
|
+
(function (MediaResolution) {
|
|
1589
|
+
MediaResolution["MEDIA_RESOLUTION_UNSPECIFIED"] = "MEDIA_RESOLUTION_UNSPECIFIED";
|
|
1590
|
+
MediaResolution["MEDIA_RESOLUTION_LOW"] = "MEDIA_RESOLUTION_LOW";
|
|
1591
|
+
MediaResolution["MEDIA_RESOLUTION_MEDIUM"] = "MEDIA_RESOLUTION_MEDIUM";
|
|
1592
|
+
MediaResolution["MEDIA_RESOLUTION_HIGH"] = "MEDIA_RESOLUTION_HIGH";
|
|
1593
|
+
})(MediaResolution || (MediaResolution = {}));
|
|
1594
|
+
/** Options for feature selection preference. */
|
|
1595
|
+
var FeatureSelectionPreference;
|
|
1596
|
+
(function (FeatureSelectionPreference) {
|
|
1597
|
+
FeatureSelectionPreference["FEATURE_SELECTION_PREFERENCE_UNSPECIFIED"] = "FEATURE_SELECTION_PREFERENCE_UNSPECIFIED";
|
|
1598
|
+
FeatureSelectionPreference["PRIORITIZE_QUALITY"] = "PRIORITIZE_QUALITY";
|
|
1599
|
+
FeatureSelectionPreference["BALANCED"] = "BALANCED";
|
|
1600
|
+
FeatureSelectionPreference["PRIORITIZE_COST"] = "PRIORITIZE_COST";
|
|
1601
|
+
})(FeatureSelectionPreference || (FeatureSelectionPreference = {}));
|
|
1602
|
+
/** Config for the dynamic retrieval config mode. */
|
|
1617
1603
|
var DynamicRetrievalConfigMode;
|
|
1618
1604
|
(function (DynamicRetrievalConfigMode) {
|
|
1619
1605
|
DynamicRetrievalConfigMode["MODE_UNSPECIFIED"] = "MODE_UNSPECIFIED";
|
|
1620
1606
|
DynamicRetrievalConfigMode["MODE_DYNAMIC"] = "MODE_DYNAMIC";
|
|
1621
1607
|
})(DynamicRetrievalConfigMode || (DynamicRetrievalConfigMode = {}));
|
|
1608
|
+
/** Config for the function calling config mode. */
|
|
1622
1609
|
var FunctionCallingConfigMode;
|
|
1623
1610
|
(function (FunctionCallingConfigMode) {
|
|
1624
1611
|
FunctionCallingConfigMode["MODE_UNSPECIFIED"] = "MODE_UNSPECIFIED";
|
|
@@ -1626,13 +1613,7 @@ var FunctionCallingConfigMode;
|
|
|
1626
1613
|
FunctionCallingConfigMode["ANY"] = "ANY";
|
|
1627
1614
|
FunctionCallingConfigMode["NONE"] = "NONE";
|
|
1628
1615
|
})(FunctionCallingConfigMode || (FunctionCallingConfigMode = {}));
|
|
1629
|
-
|
|
1630
|
-
(function (MediaResolution) {
|
|
1631
|
-
MediaResolution["MEDIA_RESOLUTION_UNSPECIFIED"] = "MEDIA_RESOLUTION_UNSPECIFIED";
|
|
1632
|
-
MediaResolution["MEDIA_RESOLUTION_LOW"] = "MEDIA_RESOLUTION_LOW";
|
|
1633
|
-
MediaResolution["MEDIA_RESOLUTION_MEDIUM"] = "MEDIA_RESOLUTION_MEDIUM";
|
|
1634
|
-
MediaResolution["MEDIA_RESOLUTION_HIGH"] = "MEDIA_RESOLUTION_HIGH";
|
|
1635
|
-
})(MediaResolution || (MediaResolution = {}));
|
|
1616
|
+
/** Enum that controls the safety filter level for objectionable content. */
|
|
1636
1617
|
var SafetyFilterLevel;
|
|
1637
1618
|
(function (SafetyFilterLevel) {
|
|
1638
1619
|
SafetyFilterLevel["BLOCK_LOW_AND_ABOVE"] = "BLOCK_LOW_AND_ABOVE";
|
|
@@ -1640,12 +1621,14 @@ var SafetyFilterLevel;
|
|
|
1640
1621
|
SafetyFilterLevel["BLOCK_ONLY_HIGH"] = "BLOCK_ONLY_HIGH";
|
|
1641
1622
|
SafetyFilterLevel["BLOCK_NONE"] = "BLOCK_NONE";
|
|
1642
1623
|
})(SafetyFilterLevel || (SafetyFilterLevel = {}));
|
|
1624
|
+
/** Enum that controls the generation of people. */
|
|
1643
1625
|
var PersonGeneration;
|
|
1644
1626
|
(function (PersonGeneration) {
|
|
1645
1627
|
PersonGeneration["DONT_ALLOW"] = "DONT_ALLOW";
|
|
1646
1628
|
PersonGeneration["ALLOW_ADULT"] = "ALLOW_ADULT";
|
|
1647
1629
|
PersonGeneration["ALLOW_ALL"] = "ALLOW_ALL";
|
|
1648
1630
|
})(PersonGeneration || (PersonGeneration = {}));
|
|
1631
|
+
/** Enum that specifies the language of the text in the prompt. */
|
|
1649
1632
|
var ImagePromptLanguage;
|
|
1650
1633
|
(function (ImagePromptLanguage) {
|
|
1651
1634
|
ImagePromptLanguage["auto"] = "auto";
|
|
@@ -1654,6 +1637,7 @@ var ImagePromptLanguage;
|
|
|
1654
1637
|
ImagePromptLanguage["ko"] = "ko";
|
|
1655
1638
|
ImagePromptLanguage["hi"] = "hi";
|
|
1656
1639
|
})(ImagePromptLanguage || (ImagePromptLanguage = {}));
|
|
1640
|
+
/** State for the lifecycle of a File. */
|
|
1657
1641
|
var FileState;
|
|
1658
1642
|
(function (FileState) {
|
|
1659
1643
|
FileState["STATE_UNSPECIFIED"] = "STATE_UNSPECIFIED";
|
|
@@ -1661,12 +1645,14 @@ var FileState;
|
|
|
1661
1645
|
FileState["ACTIVE"] = "ACTIVE";
|
|
1662
1646
|
FileState["FAILED"] = "FAILED";
|
|
1663
1647
|
})(FileState || (FileState = {}));
|
|
1648
|
+
/** Source of the File. */
|
|
1664
1649
|
var FileSource;
|
|
1665
1650
|
(function (FileSource) {
|
|
1666
1651
|
FileSource["SOURCE_UNSPECIFIED"] = "SOURCE_UNSPECIFIED";
|
|
1667
1652
|
FileSource["UPLOADED"] = "UPLOADED";
|
|
1668
1653
|
FileSource["GENERATED"] = "GENERATED";
|
|
1669
1654
|
})(FileSource || (FileSource = {}));
|
|
1655
|
+
/** Enum representing the mask mode of a mask reference image. */
|
|
1670
1656
|
var MaskReferenceMode;
|
|
1671
1657
|
(function (MaskReferenceMode) {
|
|
1672
1658
|
MaskReferenceMode["MASK_MODE_DEFAULT"] = "MASK_MODE_DEFAULT";
|
|
@@ -1675,6 +1661,7 @@ var MaskReferenceMode;
|
|
|
1675
1661
|
MaskReferenceMode["MASK_MODE_FOREGROUND"] = "MASK_MODE_FOREGROUND";
|
|
1676
1662
|
MaskReferenceMode["MASK_MODE_SEMANTIC"] = "MASK_MODE_SEMANTIC";
|
|
1677
1663
|
})(MaskReferenceMode || (MaskReferenceMode = {}));
|
|
1664
|
+
/** Enum representing the control type of a control reference image. */
|
|
1678
1665
|
var ControlReferenceType;
|
|
1679
1666
|
(function (ControlReferenceType) {
|
|
1680
1667
|
ControlReferenceType["CONTROL_TYPE_DEFAULT"] = "CONTROL_TYPE_DEFAULT";
|
|
@@ -1682,6 +1669,7 @@ var ControlReferenceType;
|
|
|
1682
1669
|
ControlReferenceType["CONTROL_TYPE_SCRIBBLE"] = "CONTROL_TYPE_SCRIBBLE";
|
|
1683
1670
|
ControlReferenceType["CONTROL_TYPE_FACE_MESH"] = "CONTROL_TYPE_FACE_MESH";
|
|
1684
1671
|
})(ControlReferenceType || (ControlReferenceType = {}));
|
|
1672
|
+
/** Enum representing the subject type of a subject reference image. */
|
|
1685
1673
|
var SubjectReferenceType;
|
|
1686
1674
|
(function (SubjectReferenceType) {
|
|
1687
1675
|
SubjectReferenceType["SUBJECT_TYPE_DEFAULT"] = "SUBJECT_TYPE_DEFAULT";
|
|
@@ -1689,6 +1677,7 @@ var SubjectReferenceType;
|
|
|
1689
1677
|
SubjectReferenceType["SUBJECT_TYPE_ANIMAL"] = "SUBJECT_TYPE_ANIMAL";
|
|
1690
1678
|
SubjectReferenceType["SUBJECT_TYPE_PRODUCT"] = "SUBJECT_TYPE_PRODUCT";
|
|
1691
1679
|
})(SubjectReferenceType || (SubjectReferenceType = {}));
|
|
1680
|
+
/** Server content modalities. */
|
|
1692
1681
|
var MediaModality;
|
|
1693
1682
|
(function (MediaModality) {
|
|
1694
1683
|
MediaModality["MODALITY_UNSPECIFIED"] = "MODALITY_UNSPECIFIED";
|
|
@@ -1698,6 +1687,34 @@ var MediaModality;
|
|
|
1698
1687
|
MediaModality["AUDIO"] = "AUDIO";
|
|
1699
1688
|
MediaModality["DOCUMENT"] = "DOCUMENT";
|
|
1700
1689
|
})(MediaModality || (MediaModality = {}));
|
|
1690
|
+
/** Start of speech sensitivity. */
|
|
1691
|
+
var StartSensitivity;
|
|
1692
|
+
(function (StartSensitivity) {
|
|
1693
|
+
StartSensitivity["START_SENSITIVITY_UNSPECIFIED"] = "START_SENSITIVITY_UNSPECIFIED";
|
|
1694
|
+
StartSensitivity["START_SENSITIVITY_HIGH"] = "START_SENSITIVITY_HIGH";
|
|
1695
|
+
StartSensitivity["START_SENSITIVITY_LOW"] = "START_SENSITIVITY_LOW";
|
|
1696
|
+
})(StartSensitivity || (StartSensitivity = {}));
|
|
1697
|
+
/** End of speech sensitivity. */
|
|
1698
|
+
var EndSensitivity;
|
|
1699
|
+
(function (EndSensitivity) {
|
|
1700
|
+
EndSensitivity["END_SENSITIVITY_UNSPECIFIED"] = "END_SENSITIVITY_UNSPECIFIED";
|
|
1701
|
+
EndSensitivity["END_SENSITIVITY_HIGH"] = "END_SENSITIVITY_HIGH";
|
|
1702
|
+
EndSensitivity["END_SENSITIVITY_LOW"] = "END_SENSITIVITY_LOW";
|
|
1703
|
+
})(EndSensitivity || (EndSensitivity = {}));
|
|
1704
|
+
/** The different ways of handling user activity. */
|
|
1705
|
+
var ActivityHandling;
|
|
1706
|
+
(function (ActivityHandling) {
|
|
1707
|
+
ActivityHandling["ACTIVITY_HANDLING_UNSPECIFIED"] = "ACTIVITY_HANDLING_UNSPECIFIED";
|
|
1708
|
+
ActivityHandling["START_OF_ACTIVITY_INTERRUPTS"] = "START_OF_ACTIVITY_INTERRUPTS";
|
|
1709
|
+
ActivityHandling["NO_INTERRUPTION"] = "NO_INTERRUPTION";
|
|
1710
|
+
})(ActivityHandling || (ActivityHandling = {}));
|
|
1711
|
+
/** Options about which input is included in the user's turn. */
|
|
1712
|
+
var TurnCoverage;
|
|
1713
|
+
(function (TurnCoverage) {
|
|
1714
|
+
TurnCoverage["TURN_COVERAGE_UNSPECIFIED"] = "TURN_COVERAGE_UNSPECIFIED";
|
|
1715
|
+
TurnCoverage["TURN_INCLUDES_ONLY_ACTIVITY"] = "TURN_INCLUDES_ONLY_ACTIVITY";
|
|
1716
|
+
TurnCoverage["TURN_INCLUDES_ALL_INPUT"] = "TURN_INCLUDES_ALL_INPUT";
|
|
1717
|
+
})(TurnCoverage || (TurnCoverage = {}));
|
|
1701
1718
|
/** A function response. */
|
|
1702
1719
|
class FunctionResponse {
|
|
1703
1720
|
}
|
|
@@ -1744,7 +1761,7 @@ function createPartFromFunctionResponse(id, name, response) {
|
|
|
1744
1761
|
};
|
|
1745
1762
|
}
|
|
1746
1763
|
/**
|
|
1747
|
-
* Creates a `Part` object from a `base64` `string`.
|
|
1764
|
+
* Creates a `Part` object from a `base64` encoded `string`.
|
|
1748
1765
|
*/
|
|
1749
1766
|
function createPartFromBase64(data, mimeType) {
|
|
1750
1767
|
return {
|
|
@@ -2132,8 +2149,8 @@ class Caches extends BaseModule {
|
|
|
2132
2149
|
*
|
|
2133
2150
|
* @remarks
|
|
2134
2151
|
* Context caching is only supported for specific models. See [Gemini
|
|
2135
|
-
* Developer API reference]
|
|
2136
|
-
* and [Vertex AI reference]
|
|
2152
|
+
* Developer API reference](https://ai.google.dev/gemini-api/docs/caching?lang=node/context-cac)
|
|
2153
|
+
* and [Vertex AI reference](https://cloud.google.com/vertex-ai/generative-ai/docs/context-cache/context-cache-overview#supported_models)
|
|
2137
2154
|
* for more information.
|
|
2138
2155
|
*
|
|
2139
2156
|
* @param params - The parameters for the create request.
|
|
@@ -2823,9 +2840,10 @@ class Chat {
|
|
|
2823
2840
|
* SPDX-License-Identifier: Apache-2.0
|
|
2824
2841
|
*/
|
|
2825
2842
|
const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
2843
|
+
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
2826
2844
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
2827
2845
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
2828
|
-
const SDK_VERSION = '0.
|
|
2846
|
+
const SDK_VERSION = '0.9.0'; // x-release-please-version
|
|
2829
2847
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
2830
2848
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
2831
2849
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -2965,11 +2983,9 @@ class ApiClient {
|
|
|
2965
2983
|
throw new Error('HTTP options are not correctly set.');
|
|
2966
2984
|
}
|
|
2967
2985
|
}
|
|
2968
|
-
constructUrl(path, httpOptions) {
|
|
2986
|
+
constructUrl(path, httpOptions, prependProjectLocation) {
|
|
2969
2987
|
const urlElement = [this.getRequestUrlInternal(httpOptions)];
|
|
2970
|
-
if (
|
|
2971
|
-
!this.clientOptions.apiKey &&
|
|
2972
|
-
!path.startsWith('projects/')) {
|
|
2988
|
+
if (prependProjectLocation) {
|
|
2973
2989
|
urlElement.push(this.getBaseResourcePath());
|
|
2974
2990
|
}
|
|
2975
2991
|
if (path !== '') {
|
|
@@ -2978,12 +2994,34 @@ class ApiClient {
|
|
|
2978
2994
|
const url = new URL(`${urlElement.join('/')}`);
|
|
2979
2995
|
return url;
|
|
2980
2996
|
}
|
|
2997
|
+
shouldPrependVertexProjectPath(request) {
|
|
2998
|
+
if (this.clientOptions.apiKey) {
|
|
2999
|
+
return false;
|
|
3000
|
+
}
|
|
3001
|
+
if (!this.clientOptions.vertexai) {
|
|
3002
|
+
return false;
|
|
3003
|
+
}
|
|
3004
|
+
if (request.path.startsWith('projects/')) {
|
|
3005
|
+
// Assume the path already starts with
|
|
3006
|
+
// `projects/<project>/location/<location>`.
|
|
3007
|
+
return false;
|
|
3008
|
+
}
|
|
3009
|
+
if (request.httpMethod === 'GET' &&
|
|
3010
|
+
request.path.startsWith('publishers/google/models')) {
|
|
3011
|
+
// These paths are used by Vertex's models.get and models.list
|
|
3012
|
+
// calls. For base models Vertex does not accept a project/location
|
|
3013
|
+
// prefix (for tuned model the prefix is required).
|
|
3014
|
+
return false;
|
|
3015
|
+
}
|
|
3016
|
+
return true;
|
|
3017
|
+
}
|
|
2981
3018
|
async request(request) {
|
|
2982
3019
|
let patchedHttpOptions = this.clientOptions.httpOptions;
|
|
2983
3020
|
if (request.httpOptions) {
|
|
2984
3021
|
patchedHttpOptions = this.patchHttpOptions(this.clientOptions.httpOptions, request.httpOptions);
|
|
2985
3022
|
}
|
|
2986
|
-
const
|
|
3023
|
+
const prependProjectLocation = this.shouldPrependVertexProjectPath(request);
|
|
3024
|
+
const url = this.constructUrl(request.path, patchedHttpOptions, prependProjectLocation);
|
|
2987
3025
|
if (request.queryParams) {
|
|
2988
3026
|
for (const [key, value] of Object.entries(request.queryParams)) {
|
|
2989
3027
|
url.searchParams.append(key, String(value));
|
|
@@ -3025,7 +3063,8 @@ class ApiClient {
|
|
|
3025
3063
|
if (request.httpOptions) {
|
|
3026
3064
|
patchedHttpOptions = this.patchHttpOptions(this.clientOptions.httpOptions, request.httpOptions);
|
|
3027
3065
|
}
|
|
3028
|
-
const
|
|
3066
|
+
const prependProjectLocation = this.shouldPrependVertexProjectPath(request);
|
|
3067
|
+
const url = this.constructUrl(request.path, patchedHttpOptions, prependProjectLocation);
|
|
3029
3068
|
if (!url.searchParams.has('alt') || url.searchParams.get('alt') !== 'sse') {
|
|
3030
3069
|
url.searchParams.set('alt', 'sse');
|
|
3031
3070
|
}
|
|
@@ -3098,8 +3137,12 @@ class ApiClient {
|
|
|
3098
3137
|
while (match) {
|
|
3099
3138
|
const processedChunkString = match[1];
|
|
3100
3139
|
try {
|
|
3101
|
-
const
|
|
3102
|
-
|
|
3140
|
+
const partialResponse = new Response(processedChunkString, {
|
|
3141
|
+
headers: response === null || response === void 0 ? void 0 : response.headers,
|
|
3142
|
+
status: response === null || response === void 0 ? void 0 : response.status,
|
|
3143
|
+
statusText: response === null || response === void 0 ? void 0 : response.statusText,
|
|
3144
|
+
});
|
|
3145
|
+
yield yield __await(new HttpResponse(partialResponse));
|
|
3103
3146
|
buffer = buffer.slice(match[0].length);
|
|
3104
3147
|
match = buffer.match(responseLineRE);
|
|
3105
3148
|
}
|
|
@@ -3133,6 +3176,11 @@ class ApiClient {
|
|
|
3133
3176
|
for (const [key, value] of Object.entries(httpOptions.headers)) {
|
|
3134
3177
|
headers.append(key, value);
|
|
3135
3178
|
}
|
|
3179
|
+
// Append a timeout header if it is set, note that the timeout option is
|
|
3180
|
+
// in milliseconds but the header is in seconds.
|
|
3181
|
+
if (httpOptions.timeout && httpOptions.timeout > 0) {
|
|
3182
|
+
headers.append(SERVER_TIMEOUT_HEADER, String(Math.ceil(httpOptions.timeout / 1000)));
|
|
3183
|
+
}
|
|
3136
3184
|
}
|
|
3137
3185
|
await this.clientOptions.auth.addAuthHeaders(headers);
|
|
3138
3186
|
return headers;
|
|
@@ -3580,12 +3628,8 @@ function listFilesResponseFromMldev(apiClient, fromObject) {
|
|
|
3580
3628
|
}
|
|
3581
3629
|
return toObject;
|
|
3582
3630
|
}
|
|
3583
|
-
function createFileResponseFromMldev(
|
|
3631
|
+
function createFileResponseFromMldev() {
|
|
3584
3632
|
const toObject = {};
|
|
3585
|
-
const fromHttpHeaders = getValueByPath(fromObject, ['httpHeaders']);
|
|
3586
|
-
if (fromHttpHeaders != null) {
|
|
3587
|
-
setValueByPath(toObject, ['httpHeaders'], fromHttpHeaders);
|
|
3588
|
-
}
|
|
3589
3633
|
return toObject;
|
|
3590
3634
|
}
|
|
3591
3635
|
function deleteFileResponseFromMldev() {
|
|
@@ -3647,7 +3691,9 @@ class Files extends BaseModule {
|
|
|
3647
3691
|
* This section can contain multiple paragraphs and code examples.
|
|
3648
3692
|
*
|
|
3649
3693
|
* @param params - Optional parameters specified in the
|
|
3650
|
-
* `
|
|
3694
|
+
* `types.UploadFileParameters` interface.
|
|
3695
|
+
* @see {@link types.UploadFileParameters#config} for the optional
|
|
3696
|
+
* config in the parameters.
|
|
3651
3697
|
* @return A promise that resolves to a `types.File` object.
|
|
3652
3698
|
* @throws An error if called on a Vertex AI client.
|
|
3653
3699
|
* @throws An error if the `mimeType` is not provided and can not be inferred,
|
|
@@ -3735,8 +3781,8 @@ class Files extends BaseModule {
|
|
|
3735
3781
|
.then((httpResponse) => {
|
|
3736
3782
|
return httpResponse.json();
|
|
3737
3783
|
});
|
|
3738
|
-
return response.then((
|
|
3739
|
-
const resp = createFileResponseFromMldev(
|
|
3784
|
+
return response.then(() => {
|
|
3785
|
+
const resp = createFileResponseFromMldev();
|
|
3740
3786
|
const typedResp = new CreateFileResponse();
|
|
3741
3787
|
Object.assign(typedResp, resp);
|
|
3742
3788
|
return typedResp;
|
|
@@ -3844,7 +3890,7 @@ class Files extends BaseModule {
|
|
|
3844
3890
|
* Copyright 2025 Google LLC
|
|
3845
3891
|
* SPDX-License-Identifier: Apache-2.0
|
|
3846
3892
|
*/
|
|
3847
|
-
function partToMldev(apiClient, fromObject) {
|
|
3893
|
+
function partToMldev$1(apiClient, fromObject) {
|
|
3848
3894
|
const toObject = {};
|
|
3849
3895
|
if (getValueByPath(fromObject, ['videoMetadata']) !== undefined) {
|
|
3850
3896
|
throw new Error('videoMetadata parameter is not supported in Gemini API.');
|
|
@@ -3889,13 +3935,61 @@ function partToMldev(apiClient, fromObject) {
|
|
|
3889
3935
|
}
|
|
3890
3936
|
return toObject;
|
|
3891
3937
|
}
|
|
3892
|
-
function
|
|
3938
|
+
function partToVertex$1(apiClient, fromObject) {
|
|
3939
|
+
const toObject = {};
|
|
3940
|
+
const fromVideoMetadata = getValueByPath(fromObject, [
|
|
3941
|
+
'videoMetadata',
|
|
3942
|
+
]);
|
|
3943
|
+
if (fromVideoMetadata != null) {
|
|
3944
|
+
setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
|
|
3945
|
+
}
|
|
3946
|
+
const fromThought = getValueByPath(fromObject, ['thought']);
|
|
3947
|
+
if (fromThought != null) {
|
|
3948
|
+
setValueByPath(toObject, ['thought'], fromThought);
|
|
3949
|
+
}
|
|
3950
|
+
const fromCodeExecutionResult = getValueByPath(fromObject, [
|
|
3951
|
+
'codeExecutionResult',
|
|
3952
|
+
]);
|
|
3953
|
+
if (fromCodeExecutionResult != null) {
|
|
3954
|
+
setValueByPath(toObject, ['codeExecutionResult'], fromCodeExecutionResult);
|
|
3955
|
+
}
|
|
3956
|
+
const fromExecutableCode = getValueByPath(fromObject, [
|
|
3957
|
+
'executableCode',
|
|
3958
|
+
]);
|
|
3959
|
+
if (fromExecutableCode != null) {
|
|
3960
|
+
setValueByPath(toObject, ['executableCode'], fromExecutableCode);
|
|
3961
|
+
}
|
|
3962
|
+
const fromFileData = getValueByPath(fromObject, ['fileData']);
|
|
3963
|
+
if (fromFileData != null) {
|
|
3964
|
+
setValueByPath(toObject, ['fileData'], fromFileData);
|
|
3965
|
+
}
|
|
3966
|
+
const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
|
|
3967
|
+
if (fromFunctionCall != null) {
|
|
3968
|
+
setValueByPath(toObject, ['functionCall'], fromFunctionCall);
|
|
3969
|
+
}
|
|
3970
|
+
const fromFunctionResponse = getValueByPath(fromObject, [
|
|
3971
|
+
'functionResponse',
|
|
3972
|
+
]);
|
|
3973
|
+
if (fromFunctionResponse != null) {
|
|
3974
|
+
setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
|
|
3975
|
+
}
|
|
3976
|
+
const fromInlineData = getValueByPath(fromObject, ['inlineData']);
|
|
3977
|
+
if (fromInlineData != null) {
|
|
3978
|
+
setValueByPath(toObject, ['inlineData'], fromInlineData);
|
|
3979
|
+
}
|
|
3980
|
+
const fromText = getValueByPath(fromObject, ['text']);
|
|
3981
|
+
if (fromText != null) {
|
|
3982
|
+
setValueByPath(toObject, ['text'], fromText);
|
|
3983
|
+
}
|
|
3984
|
+
return toObject;
|
|
3985
|
+
}
|
|
3986
|
+
function contentToMldev$1(apiClient, fromObject) {
|
|
3893
3987
|
const toObject = {};
|
|
3894
3988
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
3895
3989
|
if (fromParts != null) {
|
|
3896
3990
|
if (Array.isArray(fromParts)) {
|
|
3897
3991
|
setValueByPath(toObject, ['parts'], fromParts.map((item) => {
|
|
3898
|
-
return partToMldev(apiClient, item);
|
|
3992
|
+
return partToMldev$1(apiClient, item);
|
|
3899
3993
|
}));
|
|
3900
3994
|
}
|
|
3901
3995
|
else {
|
|
@@ -3908,28 +4002,58 @@ function contentToMldev(apiClient, fromObject) {
|
|
|
3908
4002
|
}
|
|
3909
4003
|
return toObject;
|
|
3910
4004
|
}
|
|
3911
|
-
function
|
|
4005
|
+
function contentToVertex$1(apiClient, fromObject) {
|
|
3912
4006
|
const toObject = {};
|
|
3913
|
-
|
|
3914
|
-
|
|
4007
|
+
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
4008
|
+
if (fromParts != null) {
|
|
4009
|
+
if (Array.isArray(fromParts)) {
|
|
4010
|
+
setValueByPath(toObject, ['parts'], fromParts.map((item) => {
|
|
4011
|
+
return partToVertex$1(apiClient, item);
|
|
4012
|
+
}));
|
|
4013
|
+
}
|
|
4014
|
+
else {
|
|
4015
|
+
setValueByPath(toObject, ['parts'], fromParts);
|
|
4016
|
+
}
|
|
3915
4017
|
}
|
|
3916
|
-
|
|
3917
|
-
|
|
4018
|
+
const fromRole = getValueByPath(fromObject, ['role']);
|
|
4019
|
+
if (fromRole != null) {
|
|
4020
|
+
setValueByPath(toObject, ['role'], fromRole);
|
|
3918
4021
|
}
|
|
3919
|
-
|
|
3920
|
-
|
|
4022
|
+
return toObject;
|
|
4023
|
+
}
|
|
4024
|
+
function schemaToVertex$1(apiClient, fromObject) {
|
|
4025
|
+
const toObject = {};
|
|
4026
|
+
const fromExample = getValueByPath(fromObject, ['example']);
|
|
4027
|
+
if (fromExample != null) {
|
|
4028
|
+
setValueByPath(toObject, ['example'], fromExample);
|
|
3921
4029
|
}
|
|
3922
|
-
|
|
3923
|
-
|
|
4030
|
+
const fromPattern = getValueByPath(fromObject, ['pattern']);
|
|
4031
|
+
if (fromPattern != null) {
|
|
4032
|
+
setValueByPath(toObject, ['pattern'], fromPattern);
|
|
3924
4033
|
}
|
|
3925
|
-
|
|
3926
|
-
|
|
4034
|
+
const fromDefault = getValueByPath(fromObject, ['default']);
|
|
4035
|
+
if (fromDefault != null) {
|
|
4036
|
+
setValueByPath(toObject, ['default'], fromDefault);
|
|
3927
4037
|
}
|
|
3928
|
-
|
|
3929
|
-
|
|
4038
|
+
const fromMaxLength = getValueByPath(fromObject, ['maxLength']);
|
|
4039
|
+
if (fromMaxLength != null) {
|
|
4040
|
+
setValueByPath(toObject, ['maxLength'], fromMaxLength);
|
|
3930
4041
|
}
|
|
3931
|
-
|
|
3932
|
-
|
|
4042
|
+
const fromMinLength = getValueByPath(fromObject, ['minLength']);
|
|
4043
|
+
if (fromMinLength != null) {
|
|
4044
|
+
setValueByPath(toObject, ['minLength'], fromMinLength);
|
|
4045
|
+
}
|
|
4046
|
+
const fromMinProperties = getValueByPath(fromObject, [
|
|
4047
|
+
'minProperties',
|
|
4048
|
+
]);
|
|
4049
|
+
if (fromMinProperties != null) {
|
|
4050
|
+
setValueByPath(toObject, ['minProperties'], fromMinProperties);
|
|
4051
|
+
}
|
|
4052
|
+
const fromMaxProperties = getValueByPath(fromObject, [
|
|
4053
|
+
'maxProperties',
|
|
4054
|
+
]);
|
|
4055
|
+
if (fromMaxProperties != null) {
|
|
4056
|
+
setValueByPath(toObject, ['maxProperties'], fromMaxProperties);
|
|
3933
4057
|
}
|
|
3934
4058
|
const fromAnyOf = getValueByPath(fromObject, ['anyOf']);
|
|
3935
4059
|
if (fromAnyOf != null) {
|
|
@@ -3995,25 +4119,30 @@ function schemaToMldev(apiClient, fromObject) {
|
|
|
3995
4119
|
}
|
|
3996
4120
|
return toObject;
|
|
3997
4121
|
}
|
|
3998
|
-
function
|
|
4122
|
+
function functionDeclarationToMldev$1(apiClient, fromObject) {
|
|
3999
4123
|
const toObject = {};
|
|
4000
|
-
if (getValueByPath(fromObject, ['
|
|
4001
|
-
throw new Error('
|
|
4124
|
+
if (getValueByPath(fromObject, ['response']) !== undefined) {
|
|
4125
|
+
throw new Error('response parameter is not supported in Gemini API.');
|
|
4002
4126
|
}
|
|
4003
|
-
const
|
|
4004
|
-
if (
|
|
4005
|
-
setValueByPath(toObject, ['
|
|
4127
|
+
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
4128
|
+
if (fromDescription != null) {
|
|
4129
|
+
setValueByPath(toObject, ['description'], fromDescription);
|
|
4006
4130
|
}
|
|
4007
|
-
const
|
|
4008
|
-
if (
|
|
4009
|
-
setValueByPath(toObject, ['
|
|
4131
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
4132
|
+
if (fromName != null) {
|
|
4133
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
4134
|
+
}
|
|
4135
|
+
const fromParameters = getValueByPath(fromObject, ['parameters']);
|
|
4136
|
+
if (fromParameters != null) {
|
|
4137
|
+
setValueByPath(toObject, ['parameters'], fromParameters);
|
|
4010
4138
|
}
|
|
4011
4139
|
return toObject;
|
|
4012
4140
|
}
|
|
4013
|
-
function
|
|
4141
|
+
function functionDeclarationToVertex$1(apiClient, fromObject) {
|
|
4014
4142
|
const toObject = {};
|
|
4015
|
-
|
|
4016
|
-
|
|
4143
|
+
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
4144
|
+
if (fromResponse != null) {
|
|
4145
|
+
setValueByPath(toObject, ['response'], schemaToVertex$1(apiClient, fromResponse));
|
|
4017
4146
|
}
|
|
4018
4147
|
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
4019
4148
|
if (fromDescription != null) {
|
|
@@ -4029,11 +4158,15 @@ function functionDeclarationToMldev(apiClient, fromObject) {
|
|
|
4029
4158
|
}
|
|
4030
4159
|
return toObject;
|
|
4031
4160
|
}
|
|
4032
|
-
function googleSearchToMldev() {
|
|
4161
|
+
function googleSearchToMldev$1() {
|
|
4033
4162
|
const toObject = {};
|
|
4034
4163
|
return toObject;
|
|
4035
4164
|
}
|
|
4036
|
-
function
|
|
4165
|
+
function googleSearchToVertex$1() {
|
|
4166
|
+
const toObject = {};
|
|
4167
|
+
return toObject;
|
|
4168
|
+
}
|
|
4169
|
+
function dynamicRetrievalConfigToMldev$1(apiClient, fromObject) {
|
|
4037
4170
|
const toObject = {};
|
|
4038
4171
|
const fromMode = getValueByPath(fromObject, ['mode']);
|
|
4039
4172
|
if (fromMode != null) {
|
|
@@ -4047,14 +4180,1378 @@ function dynamicRetrievalConfigToMldev(apiClient, fromObject) {
|
|
|
4047
4180
|
}
|
|
4048
4181
|
return toObject;
|
|
4049
4182
|
}
|
|
4050
|
-
function
|
|
4183
|
+
function dynamicRetrievalConfigToVertex$1(apiClient, fromObject) {
|
|
4051
4184
|
const toObject = {};
|
|
4052
|
-
const
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4185
|
+
const fromMode = getValueByPath(fromObject, ['mode']);
|
|
4186
|
+
if (fromMode != null) {
|
|
4187
|
+
setValueByPath(toObject, ['mode'], fromMode);
|
|
4188
|
+
}
|
|
4189
|
+
const fromDynamicThreshold = getValueByPath(fromObject, [
|
|
4190
|
+
'dynamicThreshold',
|
|
4191
|
+
]);
|
|
4192
|
+
if (fromDynamicThreshold != null) {
|
|
4193
|
+
setValueByPath(toObject, ['dynamicThreshold'], fromDynamicThreshold);
|
|
4194
|
+
}
|
|
4195
|
+
return toObject;
|
|
4196
|
+
}
|
|
4197
|
+
function googleSearchRetrievalToMldev$1(apiClient, fromObject) {
|
|
4198
|
+
const toObject = {};
|
|
4199
|
+
const fromDynamicRetrievalConfig = getValueByPath(fromObject, [
|
|
4200
|
+
'dynamicRetrievalConfig',
|
|
4201
|
+
]);
|
|
4202
|
+
if (fromDynamicRetrievalConfig != null) {
|
|
4203
|
+
setValueByPath(toObject, ['dynamicRetrievalConfig'], dynamicRetrievalConfigToMldev$1(apiClient, fromDynamicRetrievalConfig));
|
|
4204
|
+
}
|
|
4205
|
+
return toObject;
|
|
4206
|
+
}
|
|
4207
|
+
function googleSearchRetrievalToVertex$1(apiClient, fromObject) {
|
|
4208
|
+
const toObject = {};
|
|
4209
|
+
const fromDynamicRetrievalConfig = getValueByPath(fromObject, [
|
|
4210
|
+
'dynamicRetrievalConfig',
|
|
4211
|
+
]);
|
|
4212
|
+
if (fromDynamicRetrievalConfig != null) {
|
|
4213
|
+
setValueByPath(toObject, ['dynamicRetrievalConfig'], dynamicRetrievalConfigToVertex$1(apiClient, fromDynamicRetrievalConfig));
|
|
4214
|
+
}
|
|
4215
|
+
return toObject;
|
|
4216
|
+
}
|
|
4217
|
+
function toolToMldev$1(apiClient, fromObject) {
|
|
4218
|
+
const toObject = {};
|
|
4219
|
+
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
4220
|
+
'functionDeclarations',
|
|
4221
|
+
]);
|
|
4222
|
+
if (fromFunctionDeclarations != null) {
|
|
4223
|
+
if (Array.isArray(fromFunctionDeclarations)) {
|
|
4224
|
+
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations.map((item) => {
|
|
4225
|
+
return functionDeclarationToMldev$1(apiClient, item);
|
|
4226
|
+
}));
|
|
4227
|
+
}
|
|
4228
|
+
else {
|
|
4229
|
+
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
4230
|
+
}
|
|
4231
|
+
}
|
|
4232
|
+
if (getValueByPath(fromObject, ['retrieval']) !== undefined) {
|
|
4233
|
+
throw new Error('retrieval parameter is not supported in Gemini API.');
|
|
4234
|
+
}
|
|
4235
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
4236
|
+
if (fromGoogleSearch != null) {
|
|
4237
|
+
setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$1());
|
|
4238
|
+
}
|
|
4239
|
+
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
4240
|
+
'googleSearchRetrieval',
|
|
4241
|
+
]);
|
|
4242
|
+
if (fromGoogleSearchRetrieval != null) {
|
|
4243
|
+
setValueByPath(toObject, ['googleSearchRetrieval'], googleSearchRetrievalToMldev$1(apiClient, fromGoogleSearchRetrieval));
|
|
4244
|
+
}
|
|
4245
|
+
const fromCodeExecution = getValueByPath(fromObject, [
|
|
4246
|
+
'codeExecution',
|
|
4247
|
+
]);
|
|
4248
|
+
if (fromCodeExecution != null) {
|
|
4249
|
+
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
4250
|
+
}
|
|
4251
|
+
return toObject;
|
|
4252
|
+
}
|
|
4253
|
+
function toolToVertex$1(apiClient, fromObject) {
|
|
4254
|
+
const toObject = {};
|
|
4255
|
+
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
4256
|
+
'functionDeclarations',
|
|
4257
|
+
]);
|
|
4258
|
+
if (fromFunctionDeclarations != null) {
|
|
4259
|
+
if (Array.isArray(fromFunctionDeclarations)) {
|
|
4260
|
+
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations.map((item) => {
|
|
4261
|
+
return functionDeclarationToVertex$1(apiClient, item);
|
|
4262
|
+
}));
|
|
4263
|
+
}
|
|
4264
|
+
else {
|
|
4265
|
+
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
4266
|
+
}
|
|
4267
|
+
}
|
|
4268
|
+
const fromRetrieval = getValueByPath(fromObject, ['retrieval']);
|
|
4269
|
+
if (fromRetrieval != null) {
|
|
4270
|
+
setValueByPath(toObject, ['retrieval'], fromRetrieval);
|
|
4271
|
+
}
|
|
4272
|
+
const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
|
|
4273
|
+
if (fromGoogleSearch != null) {
|
|
4274
|
+
setValueByPath(toObject, ['googleSearch'], googleSearchToVertex$1());
|
|
4275
|
+
}
|
|
4276
|
+
const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
|
|
4277
|
+
'googleSearchRetrieval',
|
|
4278
|
+
]);
|
|
4279
|
+
if (fromGoogleSearchRetrieval != null) {
|
|
4280
|
+
setValueByPath(toObject, ['googleSearchRetrieval'], googleSearchRetrievalToVertex$1(apiClient, fromGoogleSearchRetrieval));
|
|
4281
|
+
}
|
|
4282
|
+
const fromCodeExecution = getValueByPath(fromObject, [
|
|
4283
|
+
'codeExecution',
|
|
4284
|
+
]);
|
|
4285
|
+
if (fromCodeExecution != null) {
|
|
4286
|
+
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
4287
|
+
}
|
|
4288
|
+
return toObject;
|
|
4289
|
+
}
|
|
4290
|
+
function sessionResumptionConfigToMldev(apiClient, fromObject) {
|
|
4291
|
+
const toObject = {};
|
|
4292
|
+
const fromHandle = getValueByPath(fromObject, ['handle']);
|
|
4293
|
+
if (fromHandle != null) {
|
|
4294
|
+
setValueByPath(toObject, ['handle'], fromHandle);
|
|
4295
|
+
}
|
|
4296
|
+
if (getValueByPath(fromObject, ['transparent']) !== undefined) {
|
|
4297
|
+
throw new Error('transparent parameter is not supported in Gemini API.');
|
|
4298
|
+
}
|
|
4299
|
+
return toObject;
|
|
4300
|
+
}
|
|
4301
|
+
function sessionResumptionConfigToVertex(apiClient, fromObject) {
|
|
4302
|
+
const toObject = {};
|
|
4303
|
+
const fromHandle = getValueByPath(fromObject, ['handle']);
|
|
4304
|
+
if (fromHandle != null) {
|
|
4305
|
+
setValueByPath(toObject, ['handle'], fromHandle);
|
|
4306
|
+
}
|
|
4307
|
+
const fromTransparent = getValueByPath(fromObject, ['transparent']);
|
|
4308
|
+
if (fromTransparent != null) {
|
|
4309
|
+
setValueByPath(toObject, ['transparent'], fromTransparent);
|
|
4310
|
+
}
|
|
4311
|
+
return toObject;
|
|
4312
|
+
}
|
|
4313
|
+
function audioTranscriptionConfigToMldev() {
|
|
4314
|
+
const toObject = {};
|
|
4315
|
+
return toObject;
|
|
4316
|
+
}
|
|
4317
|
+
function audioTranscriptionConfigToVertex() {
|
|
4318
|
+
const toObject = {};
|
|
4319
|
+
return toObject;
|
|
4320
|
+
}
|
|
4321
|
+
function automaticActivityDetectionToMldev(apiClient, fromObject) {
|
|
4322
|
+
const toObject = {};
|
|
4323
|
+
const fromDisabled = getValueByPath(fromObject, ['disabled']);
|
|
4324
|
+
if (fromDisabled != null) {
|
|
4325
|
+
setValueByPath(toObject, ['disabled'], fromDisabled);
|
|
4326
|
+
}
|
|
4327
|
+
const fromStartOfSpeechSensitivity = getValueByPath(fromObject, [
|
|
4328
|
+
'startOfSpeechSensitivity',
|
|
4329
|
+
]);
|
|
4330
|
+
if (fromStartOfSpeechSensitivity != null) {
|
|
4331
|
+
setValueByPath(toObject, ['startOfSpeechSensitivity'], fromStartOfSpeechSensitivity);
|
|
4332
|
+
}
|
|
4333
|
+
const fromEndOfSpeechSensitivity = getValueByPath(fromObject, [
|
|
4334
|
+
'endOfSpeechSensitivity',
|
|
4335
|
+
]);
|
|
4336
|
+
if (fromEndOfSpeechSensitivity != null) {
|
|
4337
|
+
setValueByPath(toObject, ['endOfSpeechSensitivity'], fromEndOfSpeechSensitivity);
|
|
4338
|
+
}
|
|
4339
|
+
const fromPrefixPaddingMs = getValueByPath(fromObject, [
|
|
4340
|
+
'prefixPaddingMs',
|
|
4341
|
+
]);
|
|
4342
|
+
if (fromPrefixPaddingMs != null) {
|
|
4343
|
+
setValueByPath(toObject, ['prefixPaddingMs'], fromPrefixPaddingMs);
|
|
4344
|
+
}
|
|
4345
|
+
const fromSilenceDurationMs = getValueByPath(fromObject, [
|
|
4346
|
+
'silenceDurationMs',
|
|
4347
|
+
]);
|
|
4348
|
+
if (fromSilenceDurationMs != null) {
|
|
4349
|
+
setValueByPath(toObject, ['silenceDurationMs'], fromSilenceDurationMs);
|
|
4350
|
+
}
|
|
4351
|
+
return toObject;
|
|
4352
|
+
}
|
|
4353
|
+
function automaticActivityDetectionToVertex(apiClient, fromObject) {
|
|
4354
|
+
const toObject = {};
|
|
4355
|
+
const fromDisabled = getValueByPath(fromObject, ['disabled']);
|
|
4356
|
+
if (fromDisabled != null) {
|
|
4357
|
+
setValueByPath(toObject, ['disabled'], fromDisabled);
|
|
4358
|
+
}
|
|
4359
|
+
const fromStartOfSpeechSensitivity = getValueByPath(fromObject, [
|
|
4360
|
+
'startOfSpeechSensitivity',
|
|
4361
|
+
]);
|
|
4362
|
+
if (fromStartOfSpeechSensitivity != null) {
|
|
4363
|
+
setValueByPath(toObject, ['startOfSpeechSensitivity'], fromStartOfSpeechSensitivity);
|
|
4364
|
+
}
|
|
4365
|
+
const fromEndOfSpeechSensitivity = getValueByPath(fromObject, [
|
|
4366
|
+
'endOfSpeechSensitivity',
|
|
4367
|
+
]);
|
|
4368
|
+
if (fromEndOfSpeechSensitivity != null) {
|
|
4369
|
+
setValueByPath(toObject, ['endOfSpeechSensitivity'], fromEndOfSpeechSensitivity);
|
|
4370
|
+
}
|
|
4371
|
+
const fromPrefixPaddingMs = getValueByPath(fromObject, [
|
|
4372
|
+
'prefixPaddingMs',
|
|
4373
|
+
]);
|
|
4374
|
+
if (fromPrefixPaddingMs != null) {
|
|
4375
|
+
setValueByPath(toObject, ['prefixPaddingMs'], fromPrefixPaddingMs);
|
|
4376
|
+
}
|
|
4377
|
+
const fromSilenceDurationMs = getValueByPath(fromObject, [
|
|
4378
|
+
'silenceDurationMs',
|
|
4379
|
+
]);
|
|
4380
|
+
if (fromSilenceDurationMs != null) {
|
|
4381
|
+
setValueByPath(toObject, ['silenceDurationMs'], fromSilenceDurationMs);
|
|
4382
|
+
}
|
|
4383
|
+
return toObject;
|
|
4384
|
+
}
|
|
4385
|
+
function realtimeInputConfigToMldev(apiClient, fromObject) {
|
|
4386
|
+
const toObject = {};
|
|
4387
|
+
const fromAutomaticActivityDetection = getValueByPath(fromObject, [
|
|
4388
|
+
'automaticActivityDetection',
|
|
4389
|
+
]);
|
|
4390
|
+
if (fromAutomaticActivityDetection != null) {
|
|
4391
|
+
setValueByPath(toObject, ['automaticActivityDetection'], automaticActivityDetectionToMldev(apiClient, fromAutomaticActivityDetection));
|
|
4392
|
+
}
|
|
4393
|
+
const fromActivityHandling = getValueByPath(fromObject, [
|
|
4394
|
+
'activityHandling',
|
|
4395
|
+
]);
|
|
4396
|
+
if (fromActivityHandling != null) {
|
|
4397
|
+
setValueByPath(toObject, ['activityHandling'], fromActivityHandling);
|
|
4398
|
+
}
|
|
4399
|
+
const fromTurnCoverage = getValueByPath(fromObject, ['turnCoverage']);
|
|
4400
|
+
if (fromTurnCoverage != null) {
|
|
4401
|
+
setValueByPath(toObject, ['turnCoverage'], fromTurnCoverage);
|
|
4402
|
+
}
|
|
4403
|
+
return toObject;
|
|
4404
|
+
}
|
|
4405
|
+
function realtimeInputConfigToVertex(apiClient, fromObject) {
|
|
4406
|
+
const toObject = {};
|
|
4407
|
+
const fromAutomaticActivityDetection = getValueByPath(fromObject, [
|
|
4408
|
+
'automaticActivityDetection',
|
|
4409
|
+
]);
|
|
4410
|
+
if (fromAutomaticActivityDetection != null) {
|
|
4411
|
+
setValueByPath(toObject, ['automaticActivityDetection'], automaticActivityDetectionToVertex(apiClient, fromAutomaticActivityDetection));
|
|
4412
|
+
}
|
|
4413
|
+
const fromActivityHandling = getValueByPath(fromObject, [
|
|
4414
|
+
'activityHandling',
|
|
4415
|
+
]);
|
|
4416
|
+
if (fromActivityHandling != null) {
|
|
4417
|
+
setValueByPath(toObject, ['activityHandling'], fromActivityHandling);
|
|
4418
|
+
}
|
|
4419
|
+
const fromTurnCoverage = getValueByPath(fromObject, ['turnCoverage']);
|
|
4420
|
+
if (fromTurnCoverage != null) {
|
|
4421
|
+
setValueByPath(toObject, ['turnCoverage'], fromTurnCoverage);
|
|
4422
|
+
}
|
|
4423
|
+
return toObject;
|
|
4424
|
+
}
|
|
4425
|
+
function slidingWindowToMldev(apiClient, fromObject) {
|
|
4426
|
+
const toObject = {};
|
|
4427
|
+
const fromTargetTokens = getValueByPath(fromObject, ['targetTokens']);
|
|
4428
|
+
if (fromTargetTokens != null) {
|
|
4429
|
+
setValueByPath(toObject, ['targetTokens'], fromTargetTokens);
|
|
4430
|
+
}
|
|
4431
|
+
return toObject;
|
|
4432
|
+
}
|
|
4433
|
+
function slidingWindowToVertex(apiClient, fromObject) {
|
|
4434
|
+
const toObject = {};
|
|
4435
|
+
const fromTargetTokens = getValueByPath(fromObject, ['targetTokens']);
|
|
4436
|
+
if (fromTargetTokens != null) {
|
|
4437
|
+
setValueByPath(toObject, ['targetTokens'], fromTargetTokens);
|
|
4438
|
+
}
|
|
4439
|
+
return toObject;
|
|
4440
|
+
}
|
|
4441
|
+
function contextWindowCompressionConfigToMldev(apiClient, fromObject) {
|
|
4442
|
+
const toObject = {};
|
|
4443
|
+
const fromTriggerTokens = getValueByPath(fromObject, [
|
|
4444
|
+
'triggerTokens',
|
|
4445
|
+
]);
|
|
4446
|
+
if (fromTriggerTokens != null) {
|
|
4447
|
+
setValueByPath(toObject, ['triggerTokens'], fromTriggerTokens);
|
|
4448
|
+
}
|
|
4449
|
+
const fromSlidingWindow = getValueByPath(fromObject, [
|
|
4450
|
+
'slidingWindow',
|
|
4451
|
+
]);
|
|
4452
|
+
if (fromSlidingWindow != null) {
|
|
4453
|
+
setValueByPath(toObject, ['slidingWindow'], slidingWindowToMldev(apiClient, fromSlidingWindow));
|
|
4454
|
+
}
|
|
4455
|
+
return toObject;
|
|
4456
|
+
}
|
|
4457
|
+
function contextWindowCompressionConfigToVertex(apiClient, fromObject) {
|
|
4458
|
+
const toObject = {};
|
|
4459
|
+
const fromTriggerTokens = getValueByPath(fromObject, [
|
|
4460
|
+
'triggerTokens',
|
|
4461
|
+
]);
|
|
4462
|
+
if (fromTriggerTokens != null) {
|
|
4463
|
+
setValueByPath(toObject, ['triggerTokens'], fromTriggerTokens);
|
|
4464
|
+
}
|
|
4465
|
+
const fromSlidingWindow = getValueByPath(fromObject, [
|
|
4466
|
+
'slidingWindow',
|
|
4467
|
+
]);
|
|
4468
|
+
if (fromSlidingWindow != null) {
|
|
4469
|
+
setValueByPath(toObject, ['slidingWindow'], slidingWindowToVertex(apiClient, fromSlidingWindow));
|
|
4470
|
+
}
|
|
4471
|
+
return toObject;
|
|
4472
|
+
}
|
|
4473
|
+
function liveConnectConfigToMldev(apiClient, fromObject, parentObject) {
|
|
4474
|
+
const toObject = {};
|
|
4475
|
+
const fromGenerationConfig = getValueByPath(fromObject, [
|
|
4476
|
+
'generationConfig',
|
|
4477
|
+
]);
|
|
4478
|
+
if (parentObject !== undefined && fromGenerationConfig != null) {
|
|
4479
|
+
setValueByPath(parentObject, ['setup', 'generationConfig'], fromGenerationConfig);
|
|
4480
|
+
}
|
|
4481
|
+
const fromResponseModalities = getValueByPath(fromObject, [
|
|
4482
|
+
'responseModalities',
|
|
4483
|
+
]);
|
|
4484
|
+
if (parentObject !== undefined && fromResponseModalities != null) {
|
|
4485
|
+
setValueByPath(parentObject, ['setup', 'generationConfig', 'responseModalities'], fromResponseModalities);
|
|
4486
|
+
}
|
|
4487
|
+
const fromTemperature = getValueByPath(fromObject, ['temperature']);
|
|
4488
|
+
if (parentObject !== undefined && fromTemperature != null) {
|
|
4489
|
+
setValueByPath(parentObject, ['setup', 'generationConfig', 'temperature'], fromTemperature);
|
|
4490
|
+
}
|
|
4491
|
+
const fromTopP = getValueByPath(fromObject, ['topP']);
|
|
4492
|
+
if (parentObject !== undefined && fromTopP != null) {
|
|
4493
|
+
setValueByPath(parentObject, ['setup', 'generationConfig', 'topP'], fromTopP);
|
|
4494
|
+
}
|
|
4495
|
+
const fromTopK = getValueByPath(fromObject, ['topK']);
|
|
4496
|
+
if (parentObject !== undefined && fromTopK != null) {
|
|
4497
|
+
setValueByPath(parentObject, ['setup', 'generationConfig', 'topK'], fromTopK);
|
|
4498
|
+
}
|
|
4499
|
+
const fromMaxOutputTokens = getValueByPath(fromObject, [
|
|
4500
|
+
'maxOutputTokens',
|
|
4501
|
+
]);
|
|
4502
|
+
if (parentObject !== undefined && fromMaxOutputTokens != null) {
|
|
4503
|
+
setValueByPath(parentObject, ['setup', 'generationConfig', 'maxOutputTokens'], fromMaxOutputTokens);
|
|
4504
|
+
}
|
|
4505
|
+
const fromMediaResolution = getValueByPath(fromObject, [
|
|
4506
|
+
'mediaResolution',
|
|
4507
|
+
]);
|
|
4508
|
+
if (parentObject !== undefined && fromMediaResolution != null) {
|
|
4509
|
+
setValueByPath(parentObject, ['setup', 'generationConfig', 'mediaResolution'], fromMediaResolution);
|
|
4510
|
+
}
|
|
4511
|
+
const fromSeed = getValueByPath(fromObject, ['seed']);
|
|
4512
|
+
if (parentObject !== undefined && fromSeed != null) {
|
|
4513
|
+
setValueByPath(parentObject, ['setup', 'generationConfig', 'seed'], fromSeed);
|
|
4514
|
+
}
|
|
4515
|
+
const fromSpeechConfig = getValueByPath(fromObject, ['speechConfig']);
|
|
4516
|
+
if (parentObject !== undefined && fromSpeechConfig != null) {
|
|
4517
|
+
setValueByPath(parentObject, ['setup', 'generationConfig', 'speechConfig'], fromSpeechConfig);
|
|
4518
|
+
}
|
|
4519
|
+
const fromSystemInstruction = getValueByPath(fromObject, [
|
|
4520
|
+
'systemInstruction',
|
|
4521
|
+
]);
|
|
4522
|
+
if (parentObject !== undefined && fromSystemInstruction != null) {
|
|
4523
|
+
setValueByPath(parentObject, ['setup', 'systemInstruction'], contentToMldev$1(apiClient, tContent(apiClient, fromSystemInstruction)));
|
|
4524
|
+
}
|
|
4525
|
+
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
4526
|
+
if (parentObject !== undefined && fromTools != null) {
|
|
4527
|
+
if (Array.isArray(fromTools)) {
|
|
4528
|
+
setValueByPath(parentObject, ['setup', 'tools'], tTools(apiClient, tTools(apiClient, fromTools).map((item) => {
|
|
4529
|
+
return toolToMldev$1(apiClient, tTool(apiClient, item));
|
|
4530
|
+
})));
|
|
4531
|
+
}
|
|
4532
|
+
else {
|
|
4533
|
+
setValueByPath(parentObject, ['setup', 'tools'], tTools(apiClient, fromTools));
|
|
4534
|
+
}
|
|
4535
|
+
}
|
|
4536
|
+
const fromSessionResumption = getValueByPath(fromObject, [
|
|
4537
|
+
'sessionResumption',
|
|
4538
|
+
]);
|
|
4539
|
+
if (parentObject !== undefined && fromSessionResumption != null) {
|
|
4540
|
+
setValueByPath(parentObject, ['setup', 'sessionResumption'], sessionResumptionConfigToMldev(apiClient, fromSessionResumption));
|
|
4541
|
+
}
|
|
4542
|
+
if (getValueByPath(fromObject, ['inputAudioTranscription']) !== undefined) {
|
|
4543
|
+
throw new Error('inputAudioTranscription parameter is not supported in Gemini API.');
|
|
4544
|
+
}
|
|
4545
|
+
const fromOutputAudioTranscription = getValueByPath(fromObject, [
|
|
4546
|
+
'outputAudioTranscription',
|
|
4547
|
+
]);
|
|
4548
|
+
if (parentObject !== undefined && fromOutputAudioTranscription != null) {
|
|
4549
|
+
setValueByPath(parentObject, ['setup', 'outputAudioTranscription'], audioTranscriptionConfigToMldev());
|
|
4550
|
+
}
|
|
4551
|
+
const fromRealtimeInputConfig = getValueByPath(fromObject, [
|
|
4552
|
+
'realtimeInputConfig',
|
|
4553
|
+
]);
|
|
4554
|
+
if (parentObject !== undefined && fromRealtimeInputConfig != null) {
|
|
4555
|
+
setValueByPath(parentObject, ['setup', 'realtimeInputConfig'], realtimeInputConfigToMldev(apiClient, fromRealtimeInputConfig));
|
|
4556
|
+
}
|
|
4557
|
+
const fromContextWindowCompression = getValueByPath(fromObject, [
|
|
4558
|
+
'contextWindowCompression',
|
|
4559
|
+
]);
|
|
4560
|
+
if (parentObject !== undefined && fromContextWindowCompression != null) {
|
|
4561
|
+
setValueByPath(parentObject, ['setup', 'contextWindowCompression'], contextWindowCompressionConfigToMldev(apiClient, fromContextWindowCompression));
|
|
4562
|
+
}
|
|
4563
|
+
return toObject;
|
|
4564
|
+
}
|
|
4565
|
+
function liveConnectConfigToVertex(apiClient, fromObject, parentObject) {
|
|
4566
|
+
const toObject = {};
|
|
4567
|
+
const fromGenerationConfig = getValueByPath(fromObject, [
|
|
4568
|
+
'generationConfig',
|
|
4569
|
+
]);
|
|
4570
|
+
if (parentObject !== undefined && fromGenerationConfig != null) {
|
|
4571
|
+
setValueByPath(parentObject, ['setup', 'generationConfig'], fromGenerationConfig);
|
|
4572
|
+
}
|
|
4573
|
+
const fromResponseModalities = getValueByPath(fromObject, [
|
|
4574
|
+
'responseModalities',
|
|
4575
|
+
]);
|
|
4576
|
+
if (parentObject !== undefined && fromResponseModalities != null) {
|
|
4577
|
+
setValueByPath(parentObject, ['setup', 'generationConfig', 'responseModalities'], fromResponseModalities);
|
|
4578
|
+
}
|
|
4579
|
+
const fromTemperature = getValueByPath(fromObject, ['temperature']);
|
|
4580
|
+
if (parentObject !== undefined && fromTemperature != null) {
|
|
4581
|
+
setValueByPath(parentObject, ['setup', 'generationConfig', 'temperature'], fromTemperature);
|
|
4582
|
+
}
|
|
4583
|
+
const fromTopP = getValueByPath(fromObject, ['topP']);
|
|
4584
|
+
if (parentObject !== undefined && fromTopP != null) {
|
|
4585
|
+
setValueByPath(parentObject, ['setup', 'generationConfig', 'topP'], fromTopP);
|
|
4586
|
+
}
|
|
4587
|
+
const fromTopK = getValueByPath(fromObject, ['topK']);
|
|
4588
|
+
if (parentObject !== undefined && fromTopK != null) {
|
|
4589
|
+
setValueByPath(parentObject, ['setup', 'generationConfig', 'topK'], fromTopK);
|
|
4590
|
+
}
|
|
4591
|
+
const fromMaxOutputTokens = getValueByPath(fromObject, [
|
|
4592
|
+
'maxOutputTokens',
|
|
4593
|
+
]);
|
|
4594
|
+
if (parentObject !== undefined && fromMaxOutputTokens != null) {
|
|
4595
|
+
setValueByPath(parentObject, ['setup', 'generationConfig', 'maxOutputTokens'], fromMaxOutputTokens);
|
|
4596
|
+
}
|
|
4597
|
+
const fromMediaResolution = getValueByPath(fromObject, [
|
|
4598
|
+
'mediaResolution',
|
|
4599
|
+
]);
|
|
4600
|
+
if (parentObject !== undefined && fromMediaResolution != null) {
|
|
4601
|
+
setValueByPath(parentObject, ['setup', 'generationConfig', 'mediaResolution'], fromMediaResolution);
|
|
4602
|
+
}
|
|
4603
|
+
const fromSeed = getValueByPath(fromObject, ['seed']);
|
|
4604
|
+
if (parentObject !== undefined && fromSeed != null) {
|
|
4605
|
+
setValueByPath(parentObject, ['setup', 'generationConfig', 'seed'], fromSeed);
|
|
4606
|
+
}
|
|
4607
|
+
const fromSpeechConfig = getValueByPath(fromObject, ['speechConfig']);
|
|
4608
|
+
if (parentObject !== undefined && fromSpeechConfig != null) {
|
|
4609
|
+
setValueByPath(parentObject, ['setup', 'generationConfig', 'speechConfig'], fromSpeechConfig);
|
|
4610
|
+
}
|
|
4611
|
+
const fromSystemInstruction = getValueByPath(fromObject, [
|
|
4612
|
+
'systemInstruction',
|
|
4613
|
+
]);
|
|
4614
|
+
if (parentObject !== undefined && fromSystemInstruction != null) {
|
|
4615
|
+
setValueByPath(parentObject, ['setup', 'systemInstruction'], contentToVertex$1(apiClient, tContent(apiClient, fromSystemInstruction)));
|
|
4616
|
+
}
|
|
4617
|
+
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
4618
|
+
if (parentObject !== undefined && fromTools != null) {
|
|
4619
|
+
if (Array.isArray(fromTools)) {
|
|
4620
|
+
setValueByPath(parentObject, ['setup', 'tools'], tTools(apiClient, tTools(apiClient, fromTools).map((item) => {
|
|
4621
|
+
return toolToVertex$1(apiClient, tTool(apiClient, item));
|
|
4622
|
+
})));
|
|
4623
|
+
}
|
|
4624
|
+
else {
|
|
4625
|
+
setValueByPath(parentObject, ['setup', 'tools'], tTools(apiClient, fromTools));
|
|
4626
|
+
}
|
|
4627
|
+
}
|
|
4628
|
+
const fromSessionResumption = getValueByPath(fromObject, [
|
|
4629
|
+
'sessionResumption',
|
|
4630
|
+
]);
|
|
4631
|
+
if (parentObject !== undefined && fromSessionResumption != null) {
|
|
4632
|
+
setValueByPath(parentObject, ['setup', 'sessionResumption'], sessionResumptionConfigToVertex(apiClient, fromSessionResumption));
|
|
4633
|
+
}
|
|
4634
|
+
const fromInputAudioTranscription = getValueByPath(fromObject, [
|
|
4635
|
+
'inputAudioTranscription',
|
|
4636
|
+
]);
|
|
4637
|
+
if (parentObject !== undefined && fromInputAudioTranscription != null) {
|
|
4638
|
+
setValueByPath(parentObject, ['setup', 'inputAudioTranscription'], audioTranscriptionConfigToVertex());
|
|
4639
|
+
}
|
|
4640
|
+
const fromOutputAudioTranscription = getValueByPath(fromObject, [
|
|
4641
|
+
'outputAudioTranscription',
|
|
4642
|
+
]);
|
|
4643
|
+
if (parentObject !== undefined && fromOutputAudioTranscription != null) {
|
|
4644
|
+
setValueByPath(parentObject, ['setup', 'outputAudioTranscription'], audioTranscriptionConfigToVertex());
|
|
4645
|
+
}
|
|
4646
|
+
const fromRealtimeInputConfig = getValueByPath(fromObject, [
|
|
4647
|
+
'realtimeInputConfig',
|
|
4648
|
+
]);
|
|
4649
|
+
if (parentObject !== undefined && fromRealtimeInputConfig != null) {
|
|
4650
|
+
setValueByPath(parentObject, ['setup', 'realtimeInputConfig'], realtimeInputConfigToVertex(apiClient, fromRealtimeInputConfig));
|
|
4651
|
+
}
|
|
4652
|
+
const fromContextWindowCompression = getValueByPath(fromObject, [
|
|
4653
|
+
'contextWindowCompression',
|
|
4654
|
+
]);
|
|
4655
|
+
if (parentObject !== undefined && fromContextWindowCompression != null) {
|
|
4656
|
+
setValueByPath(parentObject, ['setup', 'contextWindowCompression'], contextWindowCompressionConfigToVertex(apiClient, fromContextWindowCompression));
|
|
4657
|
+
}
|
|
4658
|
+
return toObject;
|
|
4659
|
+
}
|
|
4660
|
+
function liveConnectParametersToMldev(apiClient, fromObject) {
|
|
4661
|
+
const toObject = {};
|
|
4662
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
4663
|
+
if (fromModel != null) {
|
|
4664
|
+
setValueByPath(toObject, ['setup', 'model'], tModel(apiClient, fromModel));
|
|
4665
|
+
}
|
|
4666
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
4667
|
+
if (fromConfig != null) {
|
|
4668
|
+
setValueByPath(toObject, ['config'], liveConnectConfigToMldev(apiClient, fromConfig, toObject));
|
|
4669
|
+
}
|
|
4670
|
+
return toObject;
|
|
4671
|
+
}
|
|
4672
|
+
function liveConnectParametersToVertex(apiClient, fromObject) {
|
|
4673
|
+
const toObject = {};
|
|
4674
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
4675
|
+
if (fromModel != null) {
|
|
4676
|
+
setValueByPath(toObject, ['setup', 'model'], tModel(apiClient, fromModel));
|
|
4677
|
+
}
|
|
4678
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
4679
|
+
if (fromConfig != null) {
|
|
4680
|
+
setValueByPath(toObject, ['config'], liveConnectConfigToVertex(apiClient, fromConfig, toObject));
|
|
4681
|
+
}
|
|
4682
|
+
return toObject;
|
|
4683
|
+
}
|
|
4684
|
+
function liveServerSetupCompleteFromMldev() {
|
|
4685
|
+
const toObject = {};
|
|
4686
|
+
return toObject;
|
|
4687
|
+
}
|
|
4688
|
+
function liveServerSetupCompleteFromVertex() {
|
|
4689
|
+
const toObject = {};
|
|
4690
|
+
return toObject;
|
|
4691
|
+
}
|
|
4692
|
+
function partFromMldev$1(apiClient, fromObject) {
|
|
4693
|
+
const toObject = {};
|
|
4694
|
+
const fromThought = getValueByPath(fromObject, ['thought']);
|
|
4695
|
+
if (fromThought != null) {
|
|
4696
|
+
setValueByPath(toObject, ['thought'], fromThought);
|
|
4697
|
+
}
|
|
4698
|
+
const fromCodeExecutionResult = getValueByPath(fromObject, [
|
|
4699
|
+
'codeExecutionResult',
|
|
4700
|
+
]);
|
|
4701
|
+
if (fromCodeExecutionResult != null) {
|
|
4702
|
+
setValueByPath(toObject, ['codeExecutionResult'], fromCodeExecutionResult);
|
|
4703
|
+
}
|
|
4704
|
+
const fromExecutableCode = getValueByPath(fromObject, [
|
|
4705
|
+
'executableCode',
|
|
4706
|
+
]);
|
|
4707
|
+
if (fromExecutableCode != null) {
|
|
4708
|
+
setValueByPath(toObject, ['executableCode'], fromExecutableCode);
|
|
4709
|
+
}
|
|
4710
|
+
const fromFileData = getValueByPath(fromObject, ['fileData']);
|
|
4711
|
+
if (fromFileData != null) {
|
|
4712
|
+
setValueByPath(toObject, ['fileData'], fromFileData);
|
|
4713
|
+
}
|
|
4714
|
+
const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
|
|
4715
|
+
if (fromFunctionCall != null) {
|
|
4716
|
+
setValueByPath(toObject, ['functionCall'], fromFunctionCall);
|
|
4717
|
+
}
|
|
4718
|
+
const fromFunctionResponse = getValueByPath(fromObject, [
|
|
4719
|
+
'functionResponse',
|
|
4720
|
+
]);
|
|
4721
|
+
if (fromFunctionResponse != null) {
|
|
4722
|
+
setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
|
|
4723
|
+
}
|
|
4724
|
+
const fromInlineData = getValueByPath(fromObject, ['inlineData']);
|
|
4725
|
+
if (fromInlineData != null) {
|
|
4726
|
+
setValueByPath(toObject, ['inlineData'], fromInlineData);
|
|
4727
|
+
}
|
|
4728
|
+
const fromText = getValueByPath(fromObject, ['text']);
|
|
4729
|
+
if (fromText != null) {
|
|
4730
|
+
setValueByPath(toObject, ['text'], fromText);
|
|
4731
|
+
}
|
|
4732
|
+
return toObject;
|
|
4733
|
+
}
|
|
4734
|
+
function partFromVertex$1(apiClient, fromObject) {
|
|
4735
|
+
const toObject = {};
|
|
4736
|
+
const fromVideoMetadata = getValueByPath(fromObject, [
|
|
4737
|
+
'videoMetadata',
|
|
4738
|
+
]);
|
|
4739
|
+
if (fromVideoMetadata != null) {
|
|
4740
|
+
setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
|
|
4741
|
+
}
|
|
4742
|
+
const fromThought = getValueByPath(fromObject, ['thought']);
|
|
4743
|
+
if (fromThought != null) {
|
|
4744
|
+
setValueByPath(toObject, ['thought'], fromThought);
|
|
4745
|
+
}
|
|
4746
|
+
const fromCodeExecutionResult = getValueByPath(fromObject, [
|
|
4747
|
+
'codeExecutionResult',
|
|
4748
|
+
]);
|
|
4749
|
+
if (fromCodeExecutionResult != null) {
|
|
4750
|
+
setValueByPath(toObject, ['codeExecutionResult'], fromCodeExecutionResult);
|
|
4751
|
+
}
|
|
4752
|
+
const fromExecutableCode = getValueByPath(fromObject, [
|
|
4753
|
+
'executableCode',
|
|
4754
|
+
]);
|
|
4755
|
+
if (fromExecutableCode != null) {
|
|
4756
|
+
setValueByPath(toObject, ['executableCode'], fromExecutableCode);
|
|
4757
|
+
}
|
|
4758
|
+
const fromFileData = getValueByPath(fromObject, ['fileData']);
|
|
4759
|
+
if (fromFileData != null) {
|
|
4760
|
+
setValueByPath(toObject, ['fileData'], fromFileData);
|
|
4761
|
+
}
|
|
4762
|
+
const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
|
|
4763
|
+
if (fromFunctionCall != null) {
|
|
4764
|
+
setValueByPath(toObject, ['functionCall'], fromFunctionCall);
|
|
4765
|
+
}
|
|
4766
|
+
const fromFunctionResponse = getValueByPath(fromObject, [
|
|
4767
|
+
'functionResponse',
|
|
4768
|
+
]);
|
|
4769
|
+
if (fromFunctionResponse != null) {
|
|
4770
|
+
setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
|
|
4771
|
+
}
|
|
4772
|
+
const fromInlineData = getValueByPath(fromObject, ['inlineData']);
|
|
4773
|
+
if (fromInlineData != null) {
|
|
4774
|
+
setValueByPath(toObject, ['inlineData'], fromInlineData);
|
|
4775
|
+
}
|
|
4776
|
+
const fromText = getValueByPath(fromObject, ['text']);
|
|
4777
|
+
if (fromText != null) {
|
|
4778
|
+
setValueByPath(toObject, ['text'], fromText);
|
|
4779
|
+
}
|
|
4780
|
+
return toObject;
|
|
4781
|
+
}
|
|
4782
|
+
function contentFromMldev$1(apiClient, fromObject) {
|
|
4783
|
+
const toObject = {};
|
|
4784
|
+
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
4785
|
+
if (fromParts != null) {
|
|
4786
|
+
if (Array.isArray(fromParts)) {
|
|
4787
|
+
setValueByPath(toObject, ['parts'], fromParts.map((item) => {
|
|
4788
|
+
return partFromMldev$1(apiClient, item);
|
|
4789
|
+
}));
|
|
4790
|
+
}
|
|
4791
|
+
else {
|
|
4792
|
+
setValueByPath(toObject, ['parts'], fromParts);
|
|
4793
|
+
}
|
|
4794
|
+
}
|
|
4795
|
+
const fromRole = getValueByPath(fromObject, ['role']);
|
|
4796
|
+
if (fromRole != null) {
|
|
4797
|
+
setValueByPath(toObject, ['role'], fromRole);
|
|
4798
|
+
}
|
|
4799
|
+
return toObject;
|
|
4800
|
+
}
|
|
4801
|
+
function contentFromVertex$1(apiClient, fromObject) {
|
|
4802
|
+
const toObject = {};
|
|
4803
|
+
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
4804
|
+
if (fromParts != null) {
|
|
4805
|
+
if (Array.isArray(fromParts)) {
|
|
4806
|
+
setValueByPath(toObject, ['parts'], fromParts.map((item) => {
|
|
4807
|
+
return partFromVertex$1(apiClient, item);
|
|
4808
|
+
}));
|
|
4809
|
+
}
|
|
4810
|
+
else {
|
|
4811
|
+
setValueByPath(toObject, ['parts'], fromParts);
|
|
4812
|
+
}
|
|
4813
|
+
}
|
|
4814
|
+
const fromRole = getValueByPath(fromObject, ['role']);
|
|
4815
|
+
if (fromRole != null) {
|
|
4816
|
+
setValueByPath(toObject, ['role'], fromRole);
|
|
4817
|
+
}
|
|
4818
|
+
return toObject;
|
|
4819
|
+
}
|
|
4820
|
+
function transcriptionFromMldev(apiClient, fromObject) {
|
|
4821
|
+
const toObject = {};
|
|
4822
|
+
const fromText = getValueByPath(fromObject, ['text']);
|
|
4823
|
+
if (fromText != null) {
|
|
4824
|
+
setValueByPath(toObject, ['text'], fromText);
|
|
4825
|
+
}
|
|
4826
|
+
const fromFinished = getValueByPath(fromObject, ['finished']);
|
|
4827
|
+
if (fromFinished != null) {
|
|
4828
|
+
setValueByPath(toObject, ['finished'], fromFinished);
|
|
4829
|
+
}
|
|
4830
|
+
return toObject;
|
|
4831
|
+
}
|
|
4832
|
+
function transcriptionFromVertex(apiClient, fromObject) {
|
|
4833
|
+
const toObject = {};
|
|
4834
|
+
const fromText = getValueByPath(fromObject, ['text']);
|
|
4835
|
+
if (fromText != null) {
|
|
4836
|
+
setValueByPath(toObject, ['text'], fromText);
|
|
4837
|
+
}
|
|
4838
|
+
const fromFinished = getValueByPath(fromObject, ['finished']);
|
|
4839
|
+
if (fromFinished != null) {
|
|
4840
|
+
setValueByPath(toObject, ['finished'], fromFinished);
|
|
4841
|
+
}
|
|
4842
|
+
return toObject;
|
|
4843
|
+
}
|
|
4844
|
+
function liveServerContentFromMldev(apiClient, fromObject) {
|
|
4845
|
+
const toObject = {};
|
|
4846
|
+
const fromModelTurn = getValueByPath(fromObject, ['modelTurn']);
|
|
4847
|
+
if (fromModelTurn != null) {
|
|
4848
|
+
setValueByPath(toObject, ['modelTurn'], contentFromMldev$1(apiClient, fromModelTurn));
|
|
4849
|
+
}
|
|
4850
|
+
const fromTurnComplete = getValueByPath(fromObject, ['turnComplete']);
|
|
4851
|
+
if (fromTurnComplete != null) {
|
|
4852
|
+
setValueByPath(toObject, ['turnComplete'], fromTurnComplete);
|
|
4853
|
+
}
|
|
4854
|
+
const fromInterrupted = getValueByPath(fromObject, ['interrupted']);
|
|
4855
|
+
if (fromInterrupted != null) {
|
|
4856
|
+
setValueByPath(toObject, ['interrupted'], fromInterrupted);
|
|
4857
|
+
}
|
|
4858
|
+
const fromGenerationComplete = getValueByPath(fromObject, [
|
|
4859
|
+
'generationComplete',
|
|
4860
|
+
]);
|
|
4861
|
+
if (fromGenerationComplete != null) {
|
|
4862
|
+
setValueByPath(toObject, ['generationComplete'], fromGenerationComplete);
|
|
4863
|
+
}
|
|
4864
|
+
const fromInputTranscription = getValueByPath(fromObject, [
|
|
4865
|
+
'inputTranscription',
|
|
4866
|
+
]);
|
|
4867
|
+
if (fromInputTranscription != null) {
|
|
4868
|
+
setValueByPath(toObject, ['inputTranscription'], transcriptionFromMldev(apiClient, fromInputTranscription));
|
|
4869
|
+
}
|
|
4870
|
+
const fromOutputTranscription = getValueByPath(fromObject, [
|
|
4871
|
+
'outputTranscription',
|
|
4872
|
+
]);
|
|
4873
|
+
if (fromOutputTranscription != null) {
|
|
4874
|
+
setValueByPath(toObject, ['outputTranscription'], transcriptionFromMldev(apiClient, fromOutputTranscription));
|
|
4875
|
+
}
|
|
4876
|
+
return toObject;
|
|
4877
|
+
}
|
|
4878
|
+
function liveServerContentFromVertex(apiClient, fromObject) {
|
|
4879
|
+
const toObject = {};
|
|
4880
|
+
const fromModelTurn = getValueByPath(fromObject, ['modelTurn']);
|
|
4881
|
+
if (fromModelTurn != null) {
|
|
4882
|
+
setValueByPath(toObject, ['modelTurn'], contentFromVertex$1(apiClient, fromModelTurn));
|
|
4883
|
+
}
|
|
4884
|
+
const fromTurnComplete = getValueByPath(fromObject, ['turnComplete']);
|
|
4885
|
+
if (fromTurnComplete != null) {
|
|
4886
|
+
setValueByPath(toObject, ['turnComplete'], fromTurnComplete);
|
|
4887
|
+
}
|
|
4888
|
+
const fromInterrupted = getValueByPath(fromObject, ['interrupted']);
|
|
4889
|
+
if (fromInterrupted != null) {
|
|
4890
|
+
setValueByPath(toObject, ['interrupted'], fromInterrupted);
|
|
4891
|
+
}
|
|
4892
|
+
const fromGenerationComplete = getValueByPath(fromObject, [
|
|
4893
|
+
'generationComplete',
|
|
4894
|
+
]);
|
|
4895
|
+
if (fromGenerationComplete != null) {
|
|
4896
|
+
setValueByPath(toObject, ['generationComplete'], fromGenerationComplete);
|
|
4897
|
+
}
|
|
4898
|
+
const fromInputTranscription = getValueByPath(fromObject, [
|
|
4899
|
+
'inputTranscription',
|
|
4900
|
+
]);
|
|
4901
|
+
if (fromInputTranscription != null) {
|
|
4902
|
+
setValueByPath(toObject, ['inputTranscription'], transcriptionFromVertex(apiClient, fromInputTranscription));
|
|
4903
|
+
}
|
|
4904
|
+
const fromOutputTranscription = getValueByPath(fromObject, [
|
|
4905
|
+
'outputTranscription',
|
|
4906
|
+
]);
|
|
4907
|
+
if (fromOutputTranscription != null) {
|
|
4908
|
+
setValueByPath(toObject, ['outputTranscription'], transcriptionFromVertex(apiClient, fromOutputTranscription));
|
|
4909
|
+
}
|
|
4910
|
+
return toObject;
|
|
4911
|
+
}
|
|
4912
|
+
function functionCallFromMldev(apiClient, fromObject) {
|
|
4913
|
+
const toObject = {};
|
|
4914
|
+
const fromId = getValueByPath(fromObject, ['id']);
|
|
4915
|
+
if (fromId != null) {
|
|
4916
|
+
setValueByPath(toObject, ['id'], fromId);
|
|
4917
|
+
}
|
|
4918
|
+
const fromArgs = getValueByPath(fromObject, ['args']);
|
|
4919
|
+
if (fromArgs != null) {
|
|
4920
|
+
setValueByPath(toObject, ['args'], fromArgs);
|
|
4921
|
+
}
|
|
4922
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
4923
|
+
if (fromName != null) {
|
|
4924
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
4925
|
+
}
|
|
4926
|
+
return toObject;
|
|
4927
|
+
}
|
|
4928
|
+
function functionCallFromVertex(apiClient, fromObject) {
|
|
4929
|
+
const toObject = {};
|
|
4930
|
+
const fromArgs = getValueByPath(fromObject, ['args']);
|
|
4931
|
+
if (fromArgs != null) {
|
|
4932
|
+
setValueByPath(toObject, ['args'], fromArgs);
|
|
4933
|
+
}
|
|
4934
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
4935
|
+
if (fromName != null) {
|
|
4936
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
4937
|
+
}
|
|
4938
|
+
return toObject;
|
|
4939
|
+
}
|
|
4940
|
+
function liveServerToolCallFromMldev(apiClient, fromObject) {
|
|
4941
|
+
const toObject = {};
|
|
4942
|
+
const fromFunctionCalls = getValueByPath(fromObject, [
|
|
4943
|
+
'functionCalls',
|
|
4944
|
+
]);
|
|
4945
|
+
if (fromFunctionCalls != null) {
|
|
4946
|
+
if (Array.isArray(fromFunctionCalls)) {
|
|
4947
|
+
setValueByPath(toObject, ['functionCalls'], fromFunctionCalls.map((item) => {
|
|
4948
|
+
return functionCallFromMldev(apiClient, item);
|
|
4949
|
+
}));
|
|
4950
|
+
}
|
|
4951
|
+
else {
|
|
4952
|
+
setValueByPath(toObject, ['functionCalls'], fromFunctionCalls);
|
|
4953
|
+
}
|
|
4954
|
+
}
|
|
4955
|
+
return toObject;
|
|
4956
|
+
}
|
|
4957
|
+
function liveServerToolCallFromVertex(apiClient, fromObject) {
|
|
4958
|
+
const toObject = {};
|
|
4959
|
+
const fromFunctionCalls = getValueByPath(fromObject, [
|
|
4960
|
+
'functionCalls',
|
|
4961
|
+
]);
|
|
4962
|
+
if (fromFunctionCalls != null) {
|
|
4963
|
+
if (Array.isArray(fromFunctionCalls)) {
|
|
4964
|
+
setValueByPath(toObject, ['functionCalls'], fromFunctionCalls.map((item) => {
|
|
4965
|
+
return functionCallFromVertex(apiClient, item);
|
|
4966
|
+
}));
|
|
4967
|
+
}
|
|
4968
|
+
else {
|
|
4969
|
+
setValueByPath(toObject, ['functionCalls'], fromFunctionCalls);
|
|
4970
|
+
}
|
|
4971
|
+
}
|
|
4972
|
+
return toObject;
|
|
4973
|
+
}
|
|
4974
|
+
function liveServerToolCallCancellationFromMldev(apiClient, fromObject) {
|
|
4975
|
+
const toObject = {};
|
|
4976
|
+
const fromIds = getValueByPath(fromObject, ['ids']);
|
|
4977
|
+
if (fromIds != null) {
|
|
4978
|
+
setValueByPath(toObject, ['ids'], fromIds);
|
|
4979
|
+
}
|
|
4980
|
+
return toObject;
|
|
4981
|
+
}
|
|
4982
|
+
function liveServerToolCallCancellationFromVertex(apiClient, fromObject) {
|
|
4983
|
+
const toObject = {};
|
|
4984
|
+
const fromIds = getValueByPath(fromObject, ['ids']);
|
|
4985
|
+
if (fromIds != null) {
|
|
4986
|
+
setValueByPath(toObject, ['ids'], fromIds);
|
|
4987
|
+
}
|
|
4988
|
+
return toObject;
|
|
4989
|
+
}
|
|
4990
|
+
function modalityTokenCountFromMldev(apiClient, fromObject) {
|
|
4991
|
+
const toObject = {};
|
|
4992
|
+
const fromModality = getValueByPath(fromObject, ['modality']);
|
|
4993
|
+
if (fromModality != null) {
|
|
4994
|
+
setValueByPath(toObject, ['modality'], fromModality);
|
|
4995
|
+
}
|
|
4996
|
+
const fromTokenCount = getValueByPath(fromObject, ['tokenCount']);
|
|
4997
|
+
if (fromTokenCount != null) {
|
|
4998
|
+
setValueByPath(toObject, ['tokenCount'], fromTokenCount);
|
|
4999
|
+
}
|
|
5000
|
+
return toObject;
|
|
5001
|
+
}
|
|
5002
|
+
function modalityTokenCountFromVertex(apiClient, fromObject) {
|
|
5003
|
+
const toObject = {};
|
|
5004
|
+
const fromModality = getValueByPath(fromObject, ['modality']);
|
|
5005
|
+
if (fromModality != null) {
|
|
5006
|
+
setValueByPath(toObject, ['modality'], fromModality);
|
|
5007
|
+
}
|
|
5008
|
+
const fromTokenCount = getValueByPath(fromObject, ['tokenCount']);
|
|
5009
|
+
if (fromTokenCount != null) {
|
|
5010
|
+
setValueByPath(toObject, ['tokenCount'], fromTokenCount);
|
|
5011
|
+
}
|
|
5012
|
+
return toObject;
|
|
5013
|
+
}
|
|
5014
|
+
function usageMetadataFromMldev(apiClient, fromObject) {
|
|
5015
|
+
const toObject = {};
|
|
5016
|
+
const fromPromptTokenCount = getValueByPath(fromObject, [
|
|
5017
|
+
'promptTokenCount',
|
|
5018
|
+
]);
|
|
5019
|
+
if (fromPromptTokenCount != null) {
|
|
5020
|
+
setValueByPath(toObject, ['promptTokenCount'], fromPromptTokenCount);
|
|
5021
|
+
}
|
|
5022
|
+
const fromCachedContentTokenCount = getValueByPath(fromObject, [
|
|
5023
|
+
'cachedContentTokenCount',
|
|
5024
|
+
]);
|
|
5025
|
+
if (fromCachedContentTokenCount != null) {
|
|
5026
|
+
setValueByPath(toObject, ['cachedContentTokenCount'], fromCachedContentTokenCount);
|
|
5027
|
+
}
|
|
5028
|
+
const fromResponseTokenCount = getValueByPath(fromObject, [
|
|
5029
|
+
'responseTokenCount',
|
|
5030
|
+
]);
|
|
5031
|
+
if (fromResponseTokenCount != null) {
|
|
5032
|
+
setValueByPath(toObject, ['responseTokenCount'], fromResponseTokenCount);
|
|
5033
|
+
}
|
|
5034
|
+
const fromToolUsePromptTokenCount = getValueByPath(fromObject, [
|
|
5035
|
+
'toolUsePromptTokenCount',
|
|
5036
|
+
]);
|
|
5037
|
+
if (fromToolUsePromptTokenCount != null) {
|
|
5038
|
+
setValueByPath(toObject, ['toolUsePromptTokenCount'], fromToolUsePromptTokenCount);
|
|
5039
|
+
}
|
|
5040
|
+
const fromThoughtsTokenCount = getValueByPath(fromObject, [
|
|
5041
|
+
'thoughtsTokenCount',
|
|
5042
|
+
]);
|
|
5043
|
+
if (fromThoughtsTokenCount != null) {
|
|
5044
|
+
setValueByPath(toObject, ['thoughtsTokenCount'], fromThoughtsTokenCount);
|
|
5045
|
+
}
|
|
5046
|
+
const fromTotalTokenCount = getValueByPath(fromObject, [
|
|
5047
|
+
'totalTokenCount',
|
|
5048
|
+
]);
|
|
5049
|
+
if (fromTotalTokenCount != null) {
|
|
5050
|
+
setValueByPath(toObject, ['totalTokenCount'], fromTotalTokenCount);
|
|
5051
|
+
}
|
|
5052
|
+
const fromPromptTokensDetails = getValueByPath(fromObject, [
|
|
5053
|
+
'promptTokensDetails',
|
|
5054
|
+
]);
|
|
5055
|
+
if (fromPromptTokensDetails != null) {
|
|
5056
|
+
if (Array.isArray(fromPromptTokensDetails)) {
|
|
5057
|
+
setValueByPath(toObject, ['promptTokensDetails'], fromPromptTokensDetails.map((item) => {
|
|
5058
|
+
return modalityTokenCountFromMldev(apiClient, item);
|
|
5059
|
+
}));
|
|
5060
|
+
}
|
|
5061
|
+
else {
|
|
5062
|
+
setValueByPath(toObject, ['promptTokensDetails'], fromPromptTokensDetails);
|
|
5063
|
+
}
|
|
5064
|
+
}
|
|
5065
|
+
const fromCacheTokensDetails = getValueByPath(fromObject, [
|
|
5066
|
+
'cacheTokensDetails',
|
|
5067
|
+
]);
|
|
5068
|
+
if (fromCacheTokensDetails != null) {
|
|
5069
|
+
if (Array.isArray(fromCacheTokensDetails)) {
|
|
5070
|
+
setValueByPath(toObject, ['cacheTokensDetails'], fromCacheTokensDetails.map((item) => {
|
|
5071
|
+
return modalityTokenCountFromMldev(apiClient, item);
|
|
5072
|
+
}));
|
|
5073
|
+
}
|
|
5074
|
+
else {
|
|
5075
|
+
setValueByPath(toObject, ['cacheTokensDetails'], fromCacheTokensDetails);
|
|
5076
|
+
}
|
|
5077
|
+
}
|
|
5078
|
+
const fromResponseTokensDetails = getValueByPath(fromObject, [
|
|
5079
|
+
'responseTokensDetails',
|
|
5080
|
+
]);
|
|
5081
|
+
if (fromResponseTokensDetails != null) {
|
|
5082
|
+
if (Array.isArray(fromResponseTokensDetails)) {
|
|
5083
|
+
setValueByPath(toObject, ['responseTokensDetails'], fromResponseTokensDetails.map((item) => {
|
|
5084
|
+
return modalityTokenCountFromMldev(apiClient, item);
|
|
5085
|
+
}));
|
|
5086
|
+
}
|
|
5087
|
+
else {
|
|
5088
|
+
setValueByPath(toObject, ['responseTokensDetails'], fromResponseTokensDetails);
|
|
5089
|
+
}
|
|
5090
|
+
}
|
|
5091
|
+
const fromToolUsePromptTokensDetails = getValueByPath(fromObject, [
|
|
5092
|
+
'toolUsePromptTokensDetails',
|
|
5093
|
+
]);
|
|
5094
|
+
if (fromToolUsePromptTokensDetails != null) {
|
|
5095
|
+
if (Array.isArray(fromToolUsePromptTokensDetails)) {
|
|
5096
|
+
setValueByPath(toObject, ['toolUsePromptTokensDetails'], fromToolUsePromptTokensDetails.map((item) => {
|
|
5097
|
+
return modalityTokenCountFromMldev(apiClient, item);
|
|
5098
|
+
}));
|
|
5099
|
+
}
|
|
5100
|
+
else {
|
|
5101
|
+
setValueByPath(toObject, ['toolUsePromptTokensDetails'], fromToolUsePromptTokensDetails);
|
|
5102
|
+
}
|
|
5103
|
+
}
|
|
5104
|
+
return toObject;
|
|
5105
|
+
}
|
|
5106
|
+
function usageMetadataFromVertex(apiClient, fromObject) {
|
|
5107
|
+
const toObject = {};
|
|
5108
|
+
const fromPromptTokenCount = getValueByPath(fromObject, [
|
|
5109
|
+
'promptTokenCount',
|
|
5110
|
+
]);
|
|
5111
|
+
if (fromPromptTokenCount != null) {
|
|
5112
|
+
setValueByPath(toObject, ['promptTokenCount'], fromPromptTokenCount);
|
|
5113
|
+
}
|
|
5114
|
+
const fromCachedContentTokenCount = getValueByPath(fromObject, [
|
|
5115
|
+
'cachedContentTokenCount',
|
|
5116
|
+
]);
|
|
5117
|
+
if (fromCachedContentTokenCount != null) {
|
|
5118
|
+
setValueByPath(toObject, ['cachedContentTokenCount'], fromCachedContentTokenCount);
|
|
5119
|
+
}
|
|
5120
|
+
const fromResponseTokenCount = getValueByPath(fromObject, [
|
|
5121
|
+
'candidatesTokenCount',
|
|
5122
|
+
]);
|
|
5123
|
+
if (fromResponseTokenCount != null) {
|
|
5124
|
+
setValueByPath(toObject, ['responseTokenCount'], fromResponseTokenCount);
|
|
5125
|
+
}
|
|
5126
|
+
const fromToolUsePromptTokenCount = getValueByPath(fromObject, [
|
|
5127
|
+
'toolUsePromptTokenCount',
|
|
5128
|
+
]);
|
|
5129
|
+
if (fromToolUsePromptTokenCount != null) {
|
|
5130
|
+
setValueByPath(toObject, ['toolUsePromptTokenCount'], fromToolUsePromptTokenCount);
|
|
5131
|
+
}
|
|
5132
|
+
const fromThoughtsTokenCount = getValueByPath(fromObject, [
|
|
5133
|
+
'thoughtsTokenCount',
|
|
5134
|
+
]);
|
|
5135
|
+
if (fromThoughtsTokenCount != null) {
|
|
5136
|
+
setValueByPath(toObject, ['thoughtsTokenCount'], fromThoughtsTokenCount);
|
|
5137
|
+
}
|
|
5138
|
+
const fromTotalTokenCount = getValueByPath(fromObject, [
|
|
5139
|
+
'totalTokenCount',
|
|
5140
|
+
]);
|
|
5141
|
+
if (fromTotalTokenCount != null) {
|
|
5142
|
+
setValueByPath(toObject, ['totalTokenCount'], fromTotalTokenCount);
|
|
5143
|
+
}
|
|
5144
|
+
const fromPromptTokensDetails = getValueByPath(fromObject, [
|
|
5145
|
+
'promptTokensDetails',
|
|
5146
|
+
]);
|
|
5147
|
+
if (fromPromptTokensDetails != null) {
|
|
5148
|
+
if (Array.isArray(fromPromptTokensDetails)) {
|
|
5149
|
+
setValueByPath(toObject, ['promptTokensDetails'], fromPromptTokensDetails.map((item) => {
|
|
5150
|
+
return modalityTokenCountFromVertex(apiClient, item);
|
|
5151
|
+
}));
|
|
5152
|
+
}
|
|
5153
|
+
else {
|
|
5154
|
+
setValueByPath(toObject, ['promptTokensDetails'], fromPromptTokensDetails);
|
|
5155
|
+
}
|
|
5156
|
+
}
|
|
5157
|
+
const fromCacheTokensDetails = getValueByPath(fromObject, [
|
|
5158
|
+
'cacheTokensDetails',
|
|
5159
|
+
]);
|
|
5160
|
+
if (fromCacheTokensDetails != null) {
|
|
5161
|
+
if (Array.isArray(fromCacheTokensDetails)) {
|
|
5162
|
+
setValueByPath(toObject, ['cacheTokensDetails'], fromCacheTokensDetails.map((item) => {
|
|
5163
|
+
return modalityTokenCountFromVertex(apiClient, item);
|
|
5164
|
+
}));
|
|
5165
|
+
}
|
|
5166
|
+
else {
|
|
5167
|
+
setValueByPath(toObject, ['cacheTokensDetails'], fromCacheTokensDetails);
|
|
5168
|
+
}
|
|
5169
|
+
}
|
|
5170
|
+
const fromResponseTokensDetails = getValueByPath(fromObject, [
|
|
5171
|
+
'candidatesTokensDetails',
|
|
5172
|
+
]);
|
|
5173
|
+
if (fromResponseTokensDetails != null) {
|
|
5174
|
+
if (Array.isArray(fromResponseTokensDetails)) {
|
|
5175
|
+
setValueByPath(toObject, ['responseTokensDetails'], fromResponseTokensDetails.map((item) => {
|
|
5176
|
+
return modalityTokenCountFromVertex(apiClient, item);
|
|
5177
|
+
}));
|
|
5178
|
+
}
|
|
5179
|
+
else {
|
|
5180
|
+
setValueByPath(toObject, ['responseTokensDetails'], fromResponseTokensDetails);
|
|
5181
|
+
}
|
|
5182
|
+
}
|
|
5183
|
+
const fromToolUsePromptTokensDetails = getValueByPath(fromObject, [
|
|
5184
|
+
'toolUsePromptTokensDetails',
|
|
5185
|
+
]);
|
|
5186
|
+
if (fromToolUsePromptTokensDetails != null) {
|
|
5187
|
+
if (Array.isArray(fromToolUsePromptTokensDetails)) {
|
|
5188
|
+
setValueByPath(toObject, ['toolUsePromptTokensDetails'], fromToolUsePromptTokensDetails.map((item) => {
|
|
5189
|
+
return modalityTokenCountFromVertex(apiClient, item);
|
|
5190
|
+
}));
|
|
5191
|
+
}
|
|
5192
|
+
else {
|
|
5193
|
+
setValueByPath(toObject, ['toolUsePromptTokensDetails'], fromToolUsePromptTokensDetails);
|
|
5194
|
+
}
|
|
5195
|
+
}
|
|
5196
|
+
const fromTrafficType = getValueByPath(fromObject, ['trafficType']);
|
|
5197
|
+
if (fromTrafficType != null) {
|
|
5198
|
+
setValueByPath(toObject, ['trafficType'], fromTrafficType);
|
|
5199
|
+
}
|
|
5200
|
+
return toObject;
|
|
5201
|
+
}
|
|
5202
|
+
function liveServerGoAwayFromMldev(apiClient, fromObject) {
|
|
5203
|
+
const toObject = {};
|
|
5204
|
+
const fromTimeLeft = getValueByPath(fromObject, ['timeLeft']);
|
|
5205
|
+
if (fromTimeLeft != null) {
|
|
5206
|
+
setValueByPath(toObject, ['timeLeft'], fromTimeLeft);
|
|
5207
|
+
}
|
|
5208
|
+
return toObject;
|
|
5209
|
+
}
|
|
5210
|
+
function liveServerGoAwayFromVertex(apiClient, fromObject) {
|
|
5211
|
+
const toObject = {};
|
|
5212
|
+
const fromTimeLeft = getValueByPath(fromObject, ['timeLeft']);
|
|
5213
|
+
if (fromTimeLeft != null) {
|
|
5214
|
+
setValueByPath(toObject, ['timeLeft'], fromTimeLeft);
|
|
5215
|
+
}
|
|
5216
|
+
return toObject;
|
|
5217
|
+
}
|
|
5218
|
+
function liveServerSessionResumptionUpdateFromMldev(apiClient, fromObject) {
|
|
5219
|
+
const toObject = {};
|
|
5220
|
+
const fromNewHandle = getValueByPath(fromObject, ['newHandle']);
|
|
5221
|
+
if (fromNewHandle != null) {
|
|
5222
|
+
setValueByPath(toObject, ['newHandle'], fromNewHandle);
|
|
5223
|
+
}
|
|
5224
|
+
const fromResumable = getValueByPath(fromObject, ['resumable']);
|
|
5225
|
+
if (fromResumable != null) {
|
|
5226
|
+
setValueByPath(toObject, ['resumable'], fromResumable);
|
|
5227
|
+
}
|
|
5228
|
+
const fromLastConsumedClientMessageIndex = getValueByPath(fromObject, [
|
|
5229
|
+
'lastConsumedClientMessageIndex',
|
|
5230
|
+
]);
|
|
5231
|
+
if (fromLastConsumedClientMessageIndex != null) {
|
|
5232
|
+
setValueByPath(toObject, ['lastConsumedClientMessageIndex'], fromLastConsumedClientMessageIndex);
|
|
5233
|
+
}
|
|
5234
|
+
return toObject;
|
|
5235
|
+
}
|
|
5236
|
+
function liveServerSessionResumptionUpdateFromVertex(apiClient, fromObject) {
|
|
5237
|
+
const toObject = {};
|
|
5238
|
+
const fromNewHandle = getValueByPath(fromObject, ['newHandle']);
|
|
5239
|
+
if (fromNewHandle != null) {
|
|
5240
|
+
setValueByPath(toObject, ['newHandle'], fromNewHandle);
|
|
5241
|
+
}
|
|
5242
|
+
const fromResumable = getValueByPath(fromObject, ['resumable']);
|
|
5243
|
+
if (fromResumable != null) {
|
|
5244
|
+
setValueByPath(toObject, ['resumable'], fromResumable);
|
|
5245
|
+
}
|
|
5246
|
+
const fromLastConsumedClientMessageIndex = getValueByPath(fromObject, [
|
|
5247
|
+
'lastConsumedClientMessageIndex',
|
|
5248
|
+
]);
|
|
5249
|
+
if (fromLastConsumedClientMessageIndex != null) {
|
|
5250
|
+
setValueByPath(toObject, ['lastConsumedClientMessageIndex'], fromLastConsumedClientMessageIndex);
|
|
5251
|
+
}
|
|
5252
|
+
return toObject;
|
|
5253
|
+
}
|
|
5254
|
+
function liveServerMessageFromMldev(apiClient, fromObject) {
|
|
5255
|
+
const toObject = {};
|
|
5256
|
+
const fromSetupComplete = getValueByPath(fromObject, [
|
|
5257
|
+
'setupComplete',
|
|
5258
|
+
]);
|
|
5259
|
+
if (fromSetupComplete != null) {
|
|
5260
|
+
setValueByPath(toObject, ['setupComplete'], liveServerSetupCompleteFromMldev());
|
|
5261
|
+
}
|
|
5262
|
+
const fromServerContent = getValueByPath(fromObject, [
|
|
5263
|
+
'serverContent',
|
|
5264
|
+
]);
|
|
5265
|
+
if (fromServerContent != null) {
|
|
5266
|
+
setValueByPath(toObject, ['serverContent'], liveServerContentFromMldev(apiClient, fromServerContent));
|
|
5267
|
+
}
|
|
5268
|
+
const fromToolCall = getValueByPath(fromObject, ['toolCall']);
|
|
5269
|
+
if (fromToolCall != null) {
|
|
5270
|
+
setValueByPath(toObject, ['toolCall'], liveServerToolCallFromMldev(apiClient, fromToolCall));
|
|
5271
|
+
}
|
|
5272
|
+
const fromToolCallCancellation = getValueByPath(fromObject, [
|
|
5273
|
+
'toolCallCancellation',
|
|
5274
|
+
]);
|
|
5275
|
+
if (fromToolCallCancellation != null) {
|
|
5276
|
+
setValueByPath(toObject, ['toolCallCancellation'], liveServerToolCallCancellationFromMldev(apiClient, fromToolCallCancellation));
|
|
5277
|
+
}
|
|
5278
|
+
const fromUsageMetadata = getValueByPath(fromObject, [
|
|
5279
|
+
'usageMetadata',
|
|
5280
|
+
]);
|
|
5281
|
+
if (fromUsageMetadata != null) {
|
|
5282
|
+
setValueByPath(toObject, ['usageMetadata'], usageMetadataFromMldev(apiClient, fromUsageMetadata));
|
|
5283
|
+
}
|
|
5284
|
+
const fromGoAway = getValueByPath(fromObject, ['goAway']);
|
|
5285
|
+
if (fromGoAway != null) {
|
|
5286
|
+
setValueByPath(toObject, ['goAway'], liveServerGoAwayFromMldev(apiClient, fromGoAway));
|
|
5287
|
+
}
|
|
5288
|
+
const fromSessionResumptionUpdate = getValueByPath(fromObject, [
|
|
5289
|
+
'sessionResumptionUpdate',
|
|
5290
|
+
]);
|
|
5291
|
+
if (fromSessionResumptionUpdate != null) {
|
|
5292
|
+
setValueByPath(toObject, ['sessionResumptionUpdate'], liveServerSessionResumptionUpdateFromMldev(apiClient, fromSessionResumptionUpdate));
|
|
5293
|
+
}
|
|
5294
|
+
return toObject;
|
|
5295
|
+
}
|
|
5296
|
+
function liveServerMessageFromVertex(apiClient, fromObject) {
|
|
5297
|
+
const toObject = {};
|
|
5298
|
+
const fromSetupComplete = getValueByPath(fromObject, [
|
|
5299
|
+
'setupComplete',
|
|
5300
|
+
]);
|
|
5301
|
+
if (fromSetupComplete != null) {
|
|
5302
|
+
setValueByPath(toObject, ['setupComplete'], liveServerSetupCompleteFromVertex());
|
|
5303
|
+
}
|
|
5304
|
+
const fromServerContent = getValueByPath(fromObject, [
|
|
5305
|
+
'serverContent',
|
|
5306
|
+
]);
|
|
5307
|
+
if (fromServerContent != null) {
|
|
5308
|
+
setValueByPath(toObject, ['serverContent'], liveServerContentFromVertex(apiClient, fromServerContent));
|
|
5309
|
+
}
|
|
5310
|
+
const fromToolCall = getValueByPath(fromObject, ['toolCall']);
|
|
5311
|
+
if (fromToolCall != null) {
|
|
5312
|
+
setValueByPath(toObject, ['toolCall'], liveServerToolCallFromVertex(apiClient, fromToolCall));
|
|
5313
|
+
}
|
|
5314
|
+
const fromToolCallCancellation = getValueByPath(fromObject, [
|
|
5315
|
+
'toolCallCancellation',
|
|
5316
|
+
]);
|
|
5317
|
+
if (fromToolCallCancellation != null) {
|
|
5318
|
+
setValueByPath(toObject, ['toolCallCancellation'], liveServerToolCallCancellationFromVertex(apiClient, fromToolCallCancellation));
|
|
5319
|
+
}
|
|
5320
|
+
const fromUsageMetadata = getValueByPath(fromObject, [
|
|
5321
|
+
'usageMetadata',
|
|
5322
|
+
]);
|
|
5323
|
+
if (fromUsageMetadata != null) {
|
|
5324
|
+
setValueByPath(toObject, ['usageMetadata'], usageMetadataFromVertex(apiClient, fromUsageMetadata));
|
|
5325
|
+
}
|
|
5326
|
+
const fromGoAway = getValueByPath(fromObject, ['goAway']);
|
|
5327
|
+
if (fromGoAway != null) {
|
|
5328
|
+
setValueByPath(toObject, ['goAway'], liveServerGoAwayFromVertex(apiClient, fromGoAway));
|
|
5329
|
+
}
|
|
5330
|
+
const fromSessionResumptionUpdate = getValueByPath(fromObject, [
|
|
5331
|
+
'sessionResumptionUpdate',
|
|
5332
|
+
]);
|
|
5333
|
+
if (fromSessionResumptionUpdate != null) {
|
|
5334
|
+
setValueByPath(toObject, ['sessionResumptionUpdate'], liveServerSessionResumptionUpdateFromVertex(apiClient, fromSessionResumptionUpdate));
|
|
5335
|
+
}
|
|
5336
|
+
return toObject;
|
|
5337
|
+
}
|
|
5338
|
+
|
|
5339
|
+
/**
|
|
5340
|
+
* @license
|
|
5341
|
+
* Copyright 2025 Google LLC
|
|
5342
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5343
|
+
*/
|
|
5344
|
+
function partToMldev(apiClient, fromObject) {
|
|
5345
|
+
const toObject = {};
|
|
5346
|
+
if (getValueByPath(fromObject, ['videoMetadata']) !== undefined) {
|
|
5347
|
+
throw new Error('videoMetadata parameter is not supported in Gemini API.');
|
|
5348
|
+
}
|
|
5349
|
+
const fromThought = getValueByPath(fromObject, ['thought']);
|
|
5350
|
+
if (fromThought != null) {
|
|
5351
|
+
setValueByPath(toObject, ['thought'], fromThought);
|
|
5352
|
+
}
|
|
5353
|
+
const fromCodeExecutionResult = getValueByPath(fromObject, [
|
|
5354
|
+
'codeExecutionResult',
|
|
5355
|
+
]);
|
|
5356
|
+
if (fromCodeExecutionResult != null) {
|
|
5357
|
+
setValueByPath(toObject, ['codeExecutionResult'], fromCodeExecutionResult);
|
|
5358
|
+
}
|
|
5359
|
+
const fromExecutableCode = getValueByPath(fromObject, [
|
|
5360
|
+
'executableCode',
|
|
5361
|
+
]);
|
|
5362
|
+
if (fromExecutableCode != null) {
|
|
5363
|
+
setValueByPath(toObject, ['executableCode'], fromExecutableCode);
|
|
5364
|
+
}
|
|
5365
|
+
const fromFileData = getValueByPath(fromObject, ['fileData']);
|
|
5366
|
+
if (fromFileData != null) {
|
|
5367
|
+
setValueByPath(toObject, ['fileData'], fromFileData);
|
|
5368
|
+
}
|
|
5369
|
+
const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
|
|
5370
|
+
if (fromFunctionCall != null) {
|
|
5371
|
+
setValueByPath(toObject, ['functionCall'], fromFunctionCall);
|
|
5372
|
+
}
|
|
5373
|
+
const fromFunctionResponse = getValueByPath(fromObject, [
|
|
5374
|
+
'functionResponse',
|
|
5375
|
+
]);
|
|
5376
|
+
if (fromFunctionResponse != null) {
|
|
5377
|
+
setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
|
|
5378
|
+
}
|
|
5379
|
+
const fromInlineData = getValueByPath(fromObject, ['inlineData']);
|
|
5380
|
+
if (fromInlineData != null) {
|
|
5381
|
+
setValueByPath(toObject, ['inlineData'], fromInlineData);
|
|
5382
|
+
}
|
|
5383
|
+
const fromText = getValueByPath(fromObject, ['text']);
|
|
5384
|
+
if (fromText != null) {
|
|
5385
|
+
setValueByPath(toObject, ['text'], fromText);
|
|
5386
|
+
}
|
|
5387
|
+
return toObject;
|
|
5388
|
+
}
|
|
5389
|
+
function contentToMldev(apiClient, fromObject) {
|
|
5390
|
+
const toObject = {};
|
|
5391
|
+
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
5392
|
+
if (fromParts != null) {
|
|
5393
|
+
if (Array.isArray(fromParts)) {
|
|
5394
|
+
setValueByPath(toObject, ['parts'], fromParts.map((item) => {
|
|
5395
|
+
return partToMldev(apiClient, item);
|
|
5396
|
+
}));
|
|
5397
|
+
}
|
|
5398
|
+
else {
|
|
5399
|
+
setValueByPath(toObject, ['parts'], fromParts);
|
|
5400
|
+
}
|
|
5401
|
+
}
|
|
5402
|
+
const fromRole = getValueByPath(fromObject, ['role']);
|
|
5403
|
+
if (fromRole != null) {
|
|
5404
|
+
setValueByPath(toObject, ['role'], fromRole);
|
|
5405
|
+
}
|
|
5406
|
+
return toObject;
|
|
5407
|
+
}
|
|
5408
|
+
function schemaToMldev(apiClient, fromObject) {
|
|
5409
|
+
const toObject = {};
|
|
5410
|
+
if (getValueByPath(fromObject, ['example']) !== undefined) {
|
|
5411
|
+
throw new Error('example parameter is not supported in Gemini API.');
|
|
5412
|
+
}
|
|
5413
|
+
if (getValueByPath(fromObject, ['pattern']) !== undefined) {
|
|
5414
|
+
throw new Error('pattern parameter is not supported in Gemini API.');
|
|
5415
|
+
}
|
|
5416
|
+
if (getValueByPath(fromObject, ['default']) !== undefined) {
|
|
5417
|
+
throw new Error('default parameter is not supported in Gemini API.');
|
|
5418
|
+
}
|
|
5419
|
+
if (getValueByPath(fromObject, ['maxLength']) !== undefined) {
|
|
5420
|
+
throw new Error('maxLength parameter is not supported in Gemini API.');
|
|
5421
|
+
}
|
|
5422
|
+
if (getValueByPath(fromObject, ['minLength']) !== undefined) {
|
|
5423
|
+
throw new Error('minLength parameter is not supported in Gemini API.');
|
|
5424
|
+
}
|
|
5425
|
+
if (getValueByPath(fromObject, ['minProperties']) !== undefined) {
|
|
5426
|
+
throw new Error('minProperties parameter is not supported in Gemini API.');
|
|
5427
|
+
}
|
|
5428
|
+
if (getValueByPath(fromObject, ['maxProperties']) !== undefined) {
|
|
5429
|
+
throw new Error('maxProperties parameter is not supported in Gemini API.');
|
|
5430
|
+
}
|
|
5431
|
+
const fromAnyOf = getValueByPath(fromObject, ['anyOf']);
|
|
5432
|
+
if (fromAnyOf != null) {
|
|
5433
|
+
setValueByPath(toObject, ['anyOf'], fromAnyOf);
|
|
5434
|
+
}
|
|
5435
|
+
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
5436
|
+
if (fromDescription != null) {
|
|
5437
|
+
setValueByPath(toObject, ['description'], fromDescription);
|
|
5438
|
+
}
|
|
5439
|
+
const fromEnum = getValueByPath(fromObject, ['enum']);
|
|
5440
|
+
if (fromEnum != null) {
|
|
5441
|
+
setValueByPath(toObject, ['enum'], fromEnum);
|
|
5442
|
+
}
|
|
5443
|
+
const fromFormat = getValueByPath(fromObject, ['format']);
|
|
5444
|
+
if (fromFormat != null) {
|
|
5445
|
+
setValueByPath(toObject, ['format'], fromFormat);
|
|
5446
|
+
}
|
|
5447
|
+
const fromItems = getValueByPath(fromObject, ['items']);
|
|
5448
|
+
if (fromItems != null) {
|
|
5449
|
+
setValueByPath(toObject, ['items'], fromItems);
|
|
5450
|
+
}
|
|
5451
|
+
const fromMaxItems = getValueByPath(fromObject, ['maxItems']);
|
|
5452
|
+
if (fromMaxItems != null) {
|
|
5453
|
+
setValueByPath(toObject, ['maxItems'], fromMaxItems);
|
|
5454
|
+
}
|
|
5455
|
+
const fromMaximum = getValueByPath(fromObject, ['maximum']);
|
|
5456
|
+
if (fromMaximum != null) {
|
|
5457
|
+
setValueByPath(toObject, ['maximum'], fromMaximum);
|
|
5458
|
+
}
|
|
5459
|
+
const fromMinItems = getValueByPath(fromObject, ['minItems']);
|
|
5460
|
+
if (fromMinItems != null) {
|
|
5461
|
+
setValueByPath(toObject, ['minItems'], fromMinItems);
|
|
5462
|
+
}
|
|
5463
|
+
const fromMinimum = getValueByPath(fromObject, ['minimum']);
|
|
5464
|
+
if (fromMinimum != null) {
|
|
5465
|
+
setValueByPath(toObject, ['minimum'], fromMinimum);
|
|
5466
|
+
}
|
|
5467
|
+
const fromNullable = getValueByPath(fromObject, ['nullable']);
|
|
5468
|
+
if (fromNullable != null) {
|
|
5469
|
+
setValueByPath(toObject, ['nullable'], fromNullable);
|
|
5470
|
+
}
|
|
5471
|
+
const fromProperties = getValueByPath(fromObject, ['properties']);
|
|
5472
|
+
if (fromProperties != null) {
|
|
5473
|
+
setValueByPath(toObject, ['properties'], fromProperties);
|
|
5474
|
+
}
|
|
5475
|
+
const fromPropertyOrdering = getValueByPath(fromObject, [
|
|
5476
|
+
'propertyOrdering',
|
|
5477
|
+
]);
|
|
5478
|
+
if (fromPropertyOrdering != null) {
|
|
5479
|
+
setValueByPath(toObject, ['propertyOrdering'], fromPropertyOrdering);
|
|
5480
|
+
}
|
|
5481
|
+
const fromRequired = getValueByPath(fromObject, ['required']);
|
|
5482
|
+
if (fromRequired != null) {
|
|
5483
|
+
setValueByPath(toObject, ['required'], fromRequired);
|
|
5484
|
+
}
|
|
5485
|
+
const fromTitle = getValueByPath(fromObject, ['title']);
|
|
5486
|
+
if (fromTitle != null) {
|
|
5487
|
+
setValueByPath(toObject, ['title'], fromTitle);
|
|
5488
|
+
}
|
|
5489
|
+
const fromType = getValueByPath(fromObject, ['type']);
|
|
5490
|
+
if (fromType != null) {
|
|
5491
|
+
setValueByPath(toObject, ['type'], fromType);
|
|
5492
|
+
}
|
|
5493
|
+
return toObject;
|
|
5494
|
+
}
|
|
5495
|
+
function safetySettingToMldev(apiClient, fromObject) {
|
|
5496
|
+
const toObject = {};
|
|
5497
|
+
if (getValueByPath(fromObject, ['method']) !== undefined) {
|
|
5498
|
+
throw new Error('method parameter is not supported in Gemini API.');
|
|
5499
|
+
}
|
|
5500
|
+
const fromCategory = getValueByPath(fromObject, ['category']);
|
|
5501
|
+
if (fromCategory != null) {
|
|
5502
|
+
setValueByPath(toObject, ['category'], fromCategory);
|
|
5503
|
+
}
|
|
5504
|
+
const fromThreshold = getValueByPath(fromObject, ['threshold']);
|
|
5505
|
+
if (fromThreshold != null) {
|
|
5506
|
+
setValueByPath(toObject, ['threshold'], fromThreshold);
|
|
5507
|
+
}
|
|
5508
|
+
return toObject;
|
|
5509
|
+
}
|
|
5510
|
+
function functionDeclarationToMldev(apiClient, fromObject) {
|
|
5511
|
+
const toObject = {};
|
|
5512
|
+
if (getValueByPath(fromObject, ['response']) !== undefined) {
|
|
5513
|
+
throw new Error('response parameter is not supported in Gemini API.');
|
|
5514
|
+
}
|
|
5515
|
+
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
5516
|
+
if (fromDescription != null) {
|
|
5517
|
+
setValueByPath(toObject, ['description'], fromDescription);
|
|
5518
|
+
}
|
|
5519
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
5520
|
+
if (fromName != null) {
|
|
5521
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
5522
|
+
}
|
|
5523
|
+
const fromParameters = getValueByPath(fromObject, ['parameters']);
|
|
5524
|
+
if (fromParameters != null) {
|
|
5525
|
+
setValueByPath(toObject, ['parameters'], fromParameters);
|
|
5526
|
+
}
|
|
5527
|
+
return toObject;
|
|
5528
|
+
}
|
|
5529
|
+
function googleSearchToMldev() {
|
|
5530
|
+
const toObject = {};
|
|
5531
|
+
return toObject;
|
|
5532
|
+
}
|
|
5533
|
+
function dynamicRetrievalConfigToMldev(apiClient, fromObject) {
|
|
5534
|
+
const toObject = {};
|
|
5535
|
+
const fromMode = getValueByPath(fromObject, ['mode']);
|
|
5536
|
+
if (fromMode != null) {
|
|
5537
|
+
setValueByPath(toObject, ['mode'], fromMode);
|
|
5538
|
+
}
|
|
5539
|
+
const fromDynamicThreshold = getValueByPath(fromObject, [
|
|
5540
|
+
'dynamicThreshold',
|
|
5541
|
+
]);
|
|
5542
|
+
if (fromDynamicThreshold != null) {
|
|
5543
|
+
setValueByPath(toObject, ['dynamicThreshold'], fromDynamicThreshold);
|
|
5544
|
+
}
|
|
5545
|
+
return toObject;
|
|
5546
|
+
}
|
|
5547
|
+
function googleSearchRetrievalToMldev(apiClient, fromObject) {
|
|
5548
|
+
const toObject = {};
|
|
5549
|
+
const fromDynamicRetrievalConfig = getValueByPath(fromObject, [
|
|
5550
|
+
'dynamicRetrievalConfig',
|
|
5551
|
+
]);
|
|
5552
|
+
if (fromDynamicRetrievalConfig != null) {
|
|
5553
|
+
setValueByPath(toObject, ['dynamicRetrievalConfig'], dynamicRetrievalConfigToMldev(apiClient, fromDynamicRetrievalConfig));
|
|
5554
|
+
}
|
|
4058
5555
|
return toObject;
|
|
4059
5556
|
}
|
|
4060
5557
|
function toolToMldev(apiClient, fromObject) {
|
|
@@ -4141,6 +5638,10 @@ function speechConfigToMldev(apiClient, fromObject) {
|
|
|
4141
5638
|
if (fromVoiceConfig != null) {
|
|
4142
5639
|
setValueByPath(toObject, ['voiceConfig'], voiceConfigToMldev(apiClient, fromVoiceConfig));
|
|
4143
5640
|
}
|
|
5641
|
+
const fromLanguageCode = getValueByPath(fromObject, ['languageCode']);
|
|
5642
|
+
if (fromLanguageCode != null) {
|
|
5643
|
+
setValueByPath(toObject, ['languageCode'], fromLanguageCode);
|
|
5644
|
+
}
|
|
4144
5645
|
return toObject;
|
|
4145
5646
|
}
|
|
4146
5647
|
function thinkingConfigToMldev(apiClient, fromObject) {
|
|
@@ -4151,6 +5652,12 @@ function thinkingConfigToMldev(apiClient, fromObject) {
|
|
|
4151
5652
|
if (fromIncludeThoughts != null) {
|
|
4152
5653
|
setValueByPath(toObject, ['includeThoughts'], fromIncludeThoughts);
|
|
4153
5654
|
}
|
|
5655
|
+
const fromThinkingBudget = getValueByPath(fromObject, [
|
|
5656
|
+
'thinkingBudget',
|
|
5657
|
+
]);
|
|
5658
|
+
if (fromThinkingBudget != null) {
|
|
5659
|
+
setValueByPath(toObject, ['thinkingBudget'], fromThinkingBudget);
|
|
5660
|
+
}
|
|
4154
5661
|
return toObject;
|
|
4155
5662
|
}
|
|
4156
5663
|
function generateContentConfigToMldev(apiClient, fromObject, parentObject) {
|
|
@@ -4232,6 +5739,9 @@ function generateContentConfigToMldev(apiClient, fromObject, parentObject) {
|
|
|
4232
5739
|
if (getValueByPath(fromObject, ['routingConfig']) !== undefined) {
|
|
4233
5740
|
throw new Error('routingConfig parameter is not supported in Gemini API.');
|
|
4234
5741
|
}
|
|
5742
|
+
if (getValueByPath(fromObject, ['modelSelectionConfig']) !== undefined) {
|
|
5743
|
+
throw new Error('modelSelectionConfig parameter is not supported in Gemini API.');
|
|
5744
|
+
}
|
|
4235
5745
|
const fromSafetySettings = getValueByPath(fromObject, [
|
|
4236
5746
|
'safetySettings',
|
|
4237
5747
|
]);
|
|
@@ -4454,6 +5964,18 @@ function generateImagesParametersToMldev(apiClient, fromObject) {
|
|
|
4454
5964
|
}
|
|
4455
5965
|
return toObject;
|
|
4456
5966
|
}
|
|
5967
|
+
function getModelParametersToMldev(apiClient, fromObject) {
|
|
5968
|
+
const toObject = {};
|
|
5969
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
5970
|
+
if (fromModel != null) {
|
|
5971
|
+
setValueByPath(toObject, ['_url', 'name'], tModel(apiClient, fromModel));
|
|
5972
|
+
}
|
|
5973
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
5974
|
+
if (fromConfig != null) {
|
|
5975
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
5976
|
+
}
|
|
5977
|
+
return toObject;
|
|
5978
|
+
}
|
|
4457
5979
|
function countTokensConfigToMldev(apiClient, fromObject) {
|
|
4458
5980
|
const toObject = {};
|
|
4459
5981
|
if (getValueByPath(fromObject, ['systemInstruction']) !== undefined) {
|
|
@@ -4740,6 +6262,16 @@ function schemaToVertex(apiClient, fromObject) {
|
|
|
4740
6262
|
}
|
|
4741
6263
|
return toObject;
|
|
4742
6264
|
}
|
|
6265
|
+
function modelSelectionConfigToVertex(apiClient, fromObject) {
|
|
6266
|
+
const toObject = {};
|
|
6267
|
+
const fromFeatureSelectionPreference = getValueByPath(fromObject, [
|
|
6268
|
+
'featureSelectionPreference',
|
|
6269
|
+
]);
|
|
6270
|
+
if (fromFeatureSelectionPreference != null) {
|
|
6271
|
+
setValueByPath(toObject, ['featureSelectionPreference'], fromFeatureSelectionPreference);
|
|
6272
|
+
}
|
|
6273
|
+
return toObject;
|
|
6274
|
+
}
|
|
4743
6275
|
function safetySettingToVertex(apiClient, fromObject) {
|
|
4744
6276
|
const toObject = {};
|
|
4745
6277
|
const fromMethod = getValueByPath(fromObject, ['method']);
|
|
@@ -4889,6 +6421,10 @@ function speechConfigToVertex(apiClient, fromObject) {
|
|
|
4889
6421
|
if (fromVoiceConfig != null) {
|
|
4890
6422
|
setValueByPath(toObject, ['voiceConfig'], voiceConfigToVertex(apiClient, fromVoiceConfig));
|
|
4891
6423
|
}
|
|
6424
|
+
const fromLanguageCode = getValueByPath(fromObject, ['languageCode']);
|
|
6425
|
+
if (fromLanguageCode != null) {
|
|
6426
|
+
setValueByPath(toObject, ['languageCode'], fromLanguageCode);
|
|
6427
|
+
}
|
|
4892
6428
|
return toObject;
|
|
4893
6429
|
}
|
|
4894
6430
|
function thinkingConfigToVertex(apiClient, fromObject) {
|
|
@@ -4899,6 +6435,12 @@ function thinkingConfigToVertex(apiClient, fromObject) {
|
|
|
4899
6435
|
if (fromIncludeThoughts != null) {
|
|
4900
6436
|
setValueByPath(toObject, ['includeThoughts'], fromIncludeThoughts);
|
|
4901
6437
|
}
|
|
6438
|
+
const fromThinkingBudget = getValueByPath(fromObject, [
|
|
6439
|
+
'thinkingBudget',
|
|
6440
|
+
]);
|
|
6441
|
+
if (fromThinkingBudget != null) {
|
|
6442
|
+
setValueByPath(toObject, ['thinkingBudget'], fromThinkingBudget);
|
|
6443
|
+
}
|
|
4902
6444
|
return toObject;
|
|
4903
6445
|
}
|
|
4904
6446
|
function generateContentConfigToVertex(apiClient, fromObject, parentObject) {
|
|
@@ -4983,6 +6525,12 @@ function generateContentConfigToVertex(apiClient, fromObject, parentObject) {
|
|
|
4983
6525
|
if (fromRoutingConfig != null) {
|
|
4984
6526
|
setValueByPath(toObject, ['routingConfig'], fromRoutingConfig);
|
|
4985
6527
|
}
|
|
6528
|
+
const fromModelSelectionConfig = getValueByPath(fromObject, [
|
|
6529
|
+
'modelSelectionConfig',
|
|
6530
|
+
]);
|
|
6531
|
+
if (fromModelSelectionConfig != null) {
|
|
6532
|
+
setValueByPath(toObject, ['modelConfig'], modelSelectionConfigToVertex(apiClient, fromModelSelectionConfig));
|
|
6533
|
+
}
|
|
4986
6534
|
const fromSafetySettings = getValueByPath(fromObject, [
|
|
4987
6535
|
'safetySettings',
|
|
4988
6536
|
]);
|
|
@@ -5216,6 +6764,18 @@ function generateImagesParametersToVertex(apiClient, fromObject) {
|
|
|
5216
6764
|
}
|
|
5217
6765
|
return toObject;
|
|
5218
6766
|
}
|
|
6767
|
+
function getModelParametersToVertex(apiClient, fromObject) {
|
|
6768
|
+
const toObject = {};
|
|
6769
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
6770
|
+
if (fromModel != null) {
|
|
6771
|
+
setValueByPath(toObject, ['_url', 'name'], tModel(apiClient, fromModel));
|
|
6772
|
+
}
|
|
6773
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
6774
|
+
if (fromConfig != null) {
|
|
6775
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
6776
|
+
}
|
|
6777
|
+
return toObject;
|
|
6778
|
+
}
|
|
5219
6779
|
function countTokensConfigToVertex(apiClient, fromObject, parentObject) {
|
|
5220
6780
|
const toObject = {};
|
|
5221
6781
|
const fromSystemInstruction = getValueByPath(fromObject, [
|
|
@@ -5639,6 +7199,64 @@ function generateImagesResponseFromMldev(apiClient, fromObject) {
|
|
|
5639
7199
|
}
|
|
5640
7200
|
return toObject;
|
|
5641
7201
|
}
|
|
7202
|
+
function tunedModelInfoFromMldev(apiClient, fromObject) {
|
|
7203
|
+
const toObject = {};
|
|
7204
|
+
const fromBaseModel = getValueByPath(fromObject, ['baseModel']);
|
|
7205
|
+
if (fromBaseModel != null) {
|
|
7206
|
+
setValueByPath(toObject, ['baseModel'], fromBaseModel);
|
|
7207
|
+
}
|
|
7208
|
+
const fromCreateTime = getValueByPath(fromObject, ['createTime']);
|
|
7209
|
+
if (fromCreateTime != null) {
|
|
7210
|
+
setValueByPath(toObject, ['createTime'], fromCreateTime);
|
|
7211
|
+
}
|
|
7212
|
+
const fromUpdateTime = getValueByPath(fromObject, ['updateTime']);
|
|
7213
|
+
if (fromUpdateTime != null) {
|
|
7214
|
+
setValueByPath(toObject, ['updateTime'], fromUpdateTime);
|
|
7215
|
+
}
|
|
7216
|
+
return toObject;
|
|
7217
|
+
}
|
|
7218
|
+
function modelFromMldev(apiClient, fromObject) {
|
|
7219
|
+
const toObject = {};
|
|
7220
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
7221
|
+
if (fromName != null) {
|
|
7222
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
7223
|
+
}
|
|
7224
|
+
const fromDisplayName = getValueByPath(fromObject, ['displayName']);
|
|
7225
|
+
if (fromDisplayName != null) {
|
|
7226
|
+
setValueByPath(toObject, ['displayName'], fromDisplayName);
|
|
7227
|
+
}
|
|
7228
|
+
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
7229
|
+
if (fromDescription != null) {
|
|
7230
|
+
setValueByPath(toObject, ['description'], fromDescription);
|
|
7231
|
+
}
|
|
7232
|
+
const fromVersion = getValueByPath(fromObject, ['version']);
|
|
7233
|
+
if (fromVersion != null) {
|
|
7234
|
+
setValueByPath(toObject, ['version'], fromVersion);
|
|
7235
|
+
}
|
|
7236
|
+
const fromTunedModelInfo = getValueByPath(fromObject, ['_self']);
|
|
7237
|
+
if (fromTunedModelInfo != null) {
|
|
7238
|
+
setValueByPath(toObject, ['tunedModelInfo'], tunedModelInfoFromMldev(apiClient, fromTunedModelInfo));
|
|
7239
|
+
}
|
|
7240
|
+
const fromInputTokenLimit = getValueByPath(fromObject, [
|
|
7241
|
+
'inputTokenLimit',
|
|
7242
|
+
]);
|
|
7243
|
+
if (fromInputTokenLimit != null) {
|
|
7244
|
+
setValueByPath(toObject, ['inputTokenLimit'], fromInputTokenLimit);
|
|
7245
|
+
}
|
|
7246
|
+
const fromOutputTokenLimit = getValueByPath(fromObject, [
|
|
7247
|
+
'outputTokenLimit',
|
|
7248
|
+
]);
|
|
7249
|
+
if (fromOutputTokenLimit != null) {
|
|
7250
|
+
setValueByPath(toObject, ['outputTokenLimit'], fromOutputTokenLimit);
|
|
7251
|
+
}
|
|
7252
|
+
const fromSupportedActions = getValueByPath(fromObject, [
|
|
7253
|
+
'supportedGenerationMethods',
|
|
7254
|
+
]);
|
|
7255
|
+
if (fromSupportedActions != null) {
|
|
7256
|
+
setValueByPath(toObject, ['supportedActions'], fromSupportedActions);
|
|
7257
|
+
}
|
|
7258
|
+
return toObject;
|
|
7259
|
+
}
|
|
5642
7260
|
function countTokensResponseFromMldev(apiClient, fromObject) {
|
|
5643
7261
|
const toObject = {};
|
|
5644
7262
|
const fromTotalTokens = getValueByPath(fromObject, ['totalTokens']);
|
|
@@ -5727,16 +7345,12 @@ function generateVideosOperationFromMldev$1(apiClient, fromObject) {
|
|
|
5727
7345
|
if (fromError != null) {
|
|
5728
7346
|
setValueByPath(toObject, ['error'], fromError);
|
|
5729
7347
|
}
|
|
5730
|
-
const fromResponse = getValueByPath(fromObject, [
|
|
5731
|
-
if (fromResponse != null) {
|
|
5732
|
-
setValueByPath(toObject, ['response'], fromResponse);
|
|
5733
|
-
}
|
|
5734
|
-
const fromResult = getValueByPath(fromObject, [
|
|
7348
|
+
const fromResponse = getValueByPath(fromObject, [
|
|
5735
7349
|
'response',
|
|
5736
7350
|
'generateVideoResponse',
|
|
5737
7351
|
]);
|
|
5738
|
-
if (
|
|
5739
|
-
setValueByPath(toObject, ['
|
|
7352
|
+
if (fromResponse != null) {
|
|
7353
|
+
setValueByPath(toObject, ['response'], generateVideosResponseFromMldev$1(apiClient, fromResponse));
|
|
5740
7354
|
}
|
|
5741
7355
|
return toObject;
|
|
5742
7356
|
}
|
|
@@ -6045,6 +7659,78 @@ function generateImagesResponseFromVertex(apiClient, fromObject) {
|
|
|
6045
7659
|
}
|
|
6046
7660
|
return toObject;
|
|
6047
7661
|
}
|
|
7662
|
+
function endpointFromVertex(apiClient, fromObject) {
|
|
7663
|
+
const toObject = {};
|
|
7664
|
+
const fromName = getValueByPath(fromObject, ['endpoint']);
|
|
7665
|
+
if (fromName != null) {
|
|
7666
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
7667
|
+
}
|
|
7668
|
+
const fromDeployedModelId = getValueByPath(fromObject, [
|
|
7669
|
+
'deployedModelId',
|
|
7670
|
+
]);
|
|
7671
|
+
if (fromDeployedModelId != null) {
|
|
7672
|
+
setValueByPath(toObject, ['deployedModelId'], fromDeployedModelId);
|
|
7673
|
+
}
|
|
7674
|
+
return toObject;
|
|
7675
|
+
}
|
|
7676
|
+
function tunedModelInfoFromVertex(apiClient, fromObject) {
|
|
7677
|
+
const toObject = {};
|
|
7678
|
+
const fromBaseModel = getValueByPath(fromObject, [
|
|
7679
|
+
'labels',
|
|
7680
|
+
'google-vertex-llm-tuning-base-model-id',
|
|
7681
|
+
]);
|
|
7682
|
+
if (fromBaseModel != null) {
|
|
7683
|
+
setValueByPath(toObject, ['baseModel'], fromBaseModel);
|
|
7684
|
+
}
|
|
7685
|
+
const fromCreateTime = getValueByPath(fromObject, ['createTime']);
|
|
7686
|
+
if (fromCreateTime != null) {
|
|
7687
|
+
setValueByPath(toObject, ['createTime'], fromCreateTime);
|
|
7688
|
+
}
|
|
7689
|
+
const fromUpdateTime = getValueByPath(fromObject, ['updateTime']);
|
|
7690
|
+
if (fromUpdateTime != null) {
|
|
7691
|
+
setValueByPath(toObject, ['updateTime'], fromUpdateTime);
|
|
7692
|
+
}
|
|
7693
|
+
return toObject;
|
|
7694
|
+
}
|
|
7695
|
+
function modelFromVertex(apiClient, fromObject) {
|
|
7696
|
+
const toObject = {};
|
|
7697
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
7698
|
+
if (fromName != null) {
|
|
7699
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
7700
|
+
}
|
|
7701
|
+
const fromDisplayName = getValueByPath(fromObject, ['displayName']);
|
|
7702
|
+
if (fromDisplayName != null) {
|
|
7703
|
+
setValueByPath(toObject, ['displayName'], fromDisplayName);
|
|
7704
|
+
}
|
|
7705
|
+
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
7706
|
+
if (fromDescription != null) {
|
|
7707
|
+
setValueByPath(toObject, ['description'], fromDescription);
|
|
7708
|
+
}
|
|
7709
|
+
const fromVersion = getValueByPath(fromObject, ['versionId']);
|
|
7710
|
+
if (fromVersion != null) {
|
|
7711
|
+
setValueByPath(toObject, ['version'], fromVersion);
|
|
7712
|
+
}
|
|
7713
|
+
const fromEndpoints = getValueByPath(fromObject, ['deployedModels']);
|
|
7714
|
+
if (fromEndpoints != null) {
|
|
7715
|
+
if (Array.isArray(fromEndpoints)) {
|
|
7716
|
+
setValueByPath(toObject, ['endpoints'], fromEndpoints.map((item) => {
|
|
7717
|
+
return endpointFromVertex(apiClient, item);
|
|
7718
|
+
}));
|
|
7719
|
+
}
|
|
7720
|
+
else {
|
|
7721
|
+
setValueByPath(toObject, ['endpoints'], fromEndpoints);
|
|
7722
|
+
}
|
|
7723
|
+
}
|
|
7724
|
+
const fromLabels = getValueByPath(fromObject, ['labels']);
|
|
7725
|
+
if (fromLabels != null) {
|
|
7726
|
+
setValueByPath(toObject, ['labels'], fromLabels);
|
|
7727
|
+
}
|
|
7728
|
+
const fromTunedModelInfo = getValueByPath(fromObject, ['_self']);
|
|
7729
|
+
if (fromTunedModelInfo != null) {
|
|
7730
|
+
setValueByPath(toObject, ['tunedModelInfo'], tunedModelInfoFromVertex(apiClient, fromTunedModelInfo));
|
|
7731
|
+
}
|
|
7732
|
+
return toObject;
|
|
7733
|
+
}
|
|
6048
7734
|
function countTokensResponseFromVertex(apiClient, fromObject) {
|
|
6049
7735
|
const toObject = {};
|
|
6050
7736
|
const fromTotalTokens = getValueByPath(fromObject, ['totalTokens']);
|
|
@@ -6134,274 +7820,7 @@ function generateVideosOperationFromVertex$1(apiClient, fromObject) {
|
|
|
6134
7820
|
}
|
|
6135
7821
|
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
6136
7822
|
if (fromResponse != null) {
|
|
6137
|
-
setValueByPath(toObject, ['response'], fromResponse);
|
|
6138
|
-
}
|
|
6139
|
-
const fromResult = getValueByPath(fromObject, ['response']);
|
|
6140
|
-
if (fromResult != null) {
|
|
6141
|
-
setValueByPath(toObject, ['result'], generateVideosResponseFromVertex$1(apiClient, fromResult));
|
|
6142
|
-
}
|
|
6143
|
-
return toObject;
|
|
6144
|
-
}
|
|
6145
|
-
|
|
6146
|
-
/**
|
|
6147
|
-
* @license
|
|
6148
|
-
* Copyright 2025 Google LLC
|
|
6149
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
6150
|
-
*/
|
|
6151
|
-
/**
|
|
6152
|
-
* Converters for live client.
|
|
6153
|
-
*/
|
|
6154
|
-
function liveConnectParametersToMldev(apiClient, fromObject) {
|
|
6155
|
-
const toObject = {};
|
|
6156
|
-
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
6157
|
-
if (fromConfig !== undefined && fromConfig !== null) {
|
|
6158
|
-
setValueByPath(toObject, ['setup'], liveConnectConfigToMldev(apiClient, fromConfig));
|
|
6159
|
-
}
|
|
6160
|
-
const fromModel = getValueByPath(fromObject, ['model']);
|
|
6161
|
-
if (fromModel !== undefined) {
|
|
6162
|
-
setValueByPath(toObject, ['setup', 'model'], fromModel);
|
|
6163
|
-
}
|
|
6164
|
-
return toObject;
|
|
6165
|
-
}
|
|
6166
|
-
function liveConnectParametersToVertex(apiClient, fromObject) {
|
|
6167
|
-
const toObject = {};
|
|
6168
|
-
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
6169
|
-
if (fromConfig !== undefined && fromConfig !== null) {
|
|
6170
|
-
setValueByPath(toObject, ['setup'], liveConnectConfigToVertex(apiClient, fromConfig));
|
|
6171
|
-
}
|
|
6172
|
-
const fromModel = getValueByPath(fromObject, ['model']);
|
|
6173
|
-
if (fromModel !== undefined) {
|
|
6174
|
-
setValueByPath(toObject, ['setup', 'model'], fromModel);
|
|
6175
|
-
}
|
|
6176
|
-
return toObject;
|
|
6177
|
-
}
|
|
6178
|
-
function liveServerMessageFromMldev(apiClient, fromObject) {
|
|
6179
|
-
const toObject = {};
|
|
6180
|
-
const fromSetupComplete = getValueByPath(fromObject, [
|
|
6181
|
-
'setupComplete',
|
|
6182
|
-
]);
|
|
6183
|
-
if (fromSetupComplete !== undefined) {
|
|
6184
|
-
setValueByPath(toObject, ['setupComplete'], fromSetupComplete);
|
|
6185
|
-
}
|
|
6186
|
-
const fromServerContent = getValueByPath(fromObject, [
|
|
6187
|
-
'serverContent',
|
|
6188
|
-
]);
|
|
6189
|
-
if (fromServerContent !== undefined && fromServerContent !== null) {
|
|
6190
|
-
setValueByPath(toObject, ['serverContent'], liveServerContentFromMldev(apiClient, fromServerContent));
|
|
6191
|
-
}
|
|
6192
|
-
const fromToolCall = getValueByPath(fromObject, ['toolCall']);
|
|
6193
|
-
if (fromToolCall !== undefined && fromToolCall !== null) {
|
|
6194
|
-
setValueByPath(toObject, ['toolCall'], liveServerToolCallFromMldev(apiClient, fromToolCall));
|
|
6195
|
-
}
|
|
6196
|
-
const fromToolCallCancellation = getValueByPath(fromObject, [
|
|
6197
|
-
'toolCallCancellation',
|
|
6198
|
-
]);
|
|
6199
|
-
if (fromToolCallCancellation !== undefined &&
|
|
6200
|
-
fromToolCallCancellation !== null) {
|
|
6201
|
-
setValueByPath(toObject, ['toolCallCancellation'], liveServerToolCallCancellationFromMldev(apiClient, fromToolCallCancellation));
|
|
6202
|
-
}
|
|
6203
|
-
return toObject;
|
|
6204
|
-
}
|
|
6205
|
-
function liveServerMessageFromVertex(apiClient, fromObject) {
|
|
6206
|
-
const toObject = {};
|
|
6207
|
-
const fromSetupComplete = getValueByPath(fromObject, [
|
|
6208
|
-
'setupComplete',
|
|
6209
|
-
]);
|
|
6210
|
-
if (fromSetupComplete !== undefined) {
|
|
6211
|
-
setValueByPath(toObject, ['setupComplete'], fromSetupComplete);
|
|
6212
|
-
}
|
|
6213
|
-
const fromServerContent = getValueByPath(fromObject, [
|
|
6214
|
-
'serverContent',
|
|
6215
|
-
]);
|
|
6216
|
-
if (fromServerContent !== undefined && fromServerContent !== null) {
|
|
6217
|
-
setValueByPath(toObject, ['serverContent'], liveServerContentFromVertex(apiClient, fromServerContent));
|
|
6218
|
-
}
|
|
6219
|
-
const fromToolCall = getValueByPath(fromObject, ['toolCall']);
|
|
6220
|
-
if (fromToolCall !== undefined && fromToolCall !== null) {
|
|
6221
|
-
setValueByPath(toObject, ['toolCall'], liveServerToolCallFromVertex(apiClient, fromToolCall));
|
|
6222
|
-
}
|
|
6223
|
-
const fromToolCallCancellation = getValueByPath(fromObject, [
|
|
6224
|
-
'toolCallCancellation',
|
|
6225
|
-
]);
|
|
6226
|
-
if (fromToolCallCancellation !== undefined &&
|
|
6227
|
-
fromToolCallCancellation !== null) {
|
|
6228
|
-
setValueByPath(toObject, ['toolCallCancellation'], liveServerToolCallCancellationFromVertex(apiClient, fromToolCallCancellation));
|
|
6229
|
-
}
|
|
6230
|
-
return toObject;
|
|
6231
|
-
}
|
|
6232
|
-
function liveConnectConfigToMldev(apiClient, fromObject) {
|
|
6233
|
-
const toObject = {};
|
|
6234
|
-
const fromGenerationConfig = getValueByPath(fromObject, [
|
|
6235
|
-
'generationConfig',
|
|
6236
|
-
]);
|
|
6237
|
-
if (fromGenerationConfig !== undefined) {
|
|
6238
|
-
setValueByPath(toObject, ['generationConfig'], fromGenerationConfig);
|
|
6239
|
-
}
|
|
6240
|
-
const fromResponseModalities = getValueByPath(fromObject, [
|
|
6241
|
-
'responseModalities',
|
|
6242
|
-
]);
|
|
6243
|
-
if (fromResponseModalities !== undefined) {
|
|
6244
|
-
setValueByPath(toObject, ['generationConfig', 'responseModalities'], fromResponseModalities);
|
|
6245
|
-
}
|
|
6246
|
-
const fromSpeechConfig = getValueByPath(fromObject, ['speechConfig']);
|
|
6247
|
-
if (fromSpeechConfig !== undefined) {
|
|
6248
|
-
setValueByPath(toObject, ['generationConfig', 'speechConfig'], fromSpeechConfig);
|
|
6249
|
-
}
|
|
6250
|
-
const fromSystemInstruction = getValueByPath(fromObject, [
|
|
6251
|
-
'systemInstruction',
|
|
6252
|
-
]);
|
|
6253
|
-
if (fromSystemInstruction !== undefined && fromSystemInstruction !== null) {
|
|
6254
|
-
setValueByPath(toObject, ['systemInstruction'], contentToMldev(apiClient, fromSystemInstruction));
|
|
6255
|
-
}
|
|
6256
|
-
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
6257
|
-
if (fromTools !== undefined &&
|
|
6258
|
-
fromTools !== null &&
|
|
6259
|
-
Array.isArray(fromTools)) {
|
|
6260
|
-
setValueByPath(toObject, ['tools'], fromTools.map((item) => {
|
|
6261
|
-
return toolToMldev(apiClient, item);
|
|
6262
|
-
}));
|
|
6263
|
-
}
|
|
6264
|
-
return toObject;
|
|
6265
|
-
}
|
|
6266
|
-
function liveConnectConfigToVertex(apiClient, fromObject) {
|
|
6267
|
-
const toObject = {};
|
|
6268
|
-
const fromGenerationConfig = getValueByPath(fromObject, [
|
|
6269
|
-
'generationConfig',
|
|
6270
|
-
]);
|
|
6271
|
-
if (fromGenerationConfig !== undefined) {
|
|
6272
|
-
setValueByPath(toObject, ['generationConfig'], fromGenerationConfig);
|
|
6273
|
-
}
|
|
6274
|
-
const fromResponseModalities = getValueByPath(fromObject, [
|
|
6275
|
-
'responseModalities',
|
|
6276
|
-
]);
|
|
6277
|
-
if (fromResponseModalities !== undefined) {
|
|
6278
|
-
setValueByPath(toObject, ['generationConfig', 'responseModalities'], fromResponseModalities);
|
|
6279
|
-
}
|
|
6280
|
-
else {
|
|
6281
|
-
// Set default to AUDIO to align with MLDev API.
|
|
6282
|
-
setValueByPath(toObject, ['generationConfig', 'responseModalities'], ['AUDIO']);
|
|
6283
|
-
}
|
|
6284
|
-
const fromSpeechConfig = getValueByPath(fromObject, ['speechConfig']);
|
|
6285
|
-
if (fromSpeechConfig !== undefined) {
|
|
6286
|
-
setValueByPath(toObject, ['generationConfig', 'speechConfig'], fromSpeechConfig);
|
|
6287
|
-
}
|
|
6288
|
-
const fromSystemInstruction = getValueByPath(fromObject, [
|
|
6289
|
-
'systemInstruction',
|
|
6290
|
-
]);
|
|
6291
|
-
if (fromSystemInstruction !== undefined && fromSystemInstruction !== null) {
|
|
6292
|
-
setValueByPath(toObject, ['systemInstruction'], contentToVertex(apiClient, fromSystemInstruction));
|
|
6293
|
-
}
|
|
6294
|
-
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
6295
|
-
if (fromTools !== undefined &&
|
|
6296
|
-
fromTools !== null &&
|
|
6297
|
-
Array.isArray(fromTools)) {
|
|
6298
|
-
setValueByPath(toObject, ['tools'], fromTools.map((item) => {
|
|
6299
|
-
return toolToVertex(apiClient, item);
|
|
6300
|
-
}));
|
|
6301
|
-
}
|
|
6302
|
-
return toObject;
|
|
6303
|
-
}
|
|
6304
|
-
function liveServerContentFromMldev(apiClient, fromObject) {
|
|
6305
|
-
const toObject = {};
|
|
6306
|
-
const fromModelTurn = getValueByPath(fromObject, ['modelTurn']);
|
|
6307
|
-
if (fromModelTurn !== undefined && fromModelTurn !== null) {
|
|
6308
|
-
setValueByPath(toObject, ['modelTurn'], contentFromMldev(apiClient, fromModelTurn));
|
|
6309
|
-
}
|
|
6310
|
-
const fromTurnComplete = getValueByPath(fromObject, ['turnComplete']);
|
|
6311
|
-
if (fromTurnComplete !== undefined) {
|
|
6312
|
-
setValueByPath(toObject, ['turnComplete'], fromTurnComplete);
|
|
6313
|
-
}
|
|
6314
|
-
const fromInterrupted = getValueByPath(fromObject, ['interrupted']);
|
|
6315
|
-
if (fromInterrupted !== undefined) {
|
|
6316
|
-
setValueByPath(toObject, ['interrupted'], fromInterrupted);
|
|
6317
|
-
}
|
|
6318
|
-
return toObject;
|
|
6319
|
-
}
|
|
6320
|
-
function liveServerContentFromVertex(apiClient, fromObject) {
|
|
6321
|
-
const toObject = {};
|
|
6322
|
-
const fromModelTurn = getValueByPath(fromObject, ['modelTurn']);
|
|
6323
|
-
if (fromModelTurn !== undefined && fromModelTurn !== null) {
|
|
6324
|
-
setValueByPath(toObject, ['modelTurn'], contentFromVertex(apiClient, fromModelTurn));
|
|
6325
|
-
}
|
|
6326
|
-
const fromTurnComplete = getValueByPath(fromObject, ['turnComplete']);
|
|
6327
|
-
if (fromTurnComplete !== undefined) {
|
|
6328
|
-
setValueByPath(toObject, ['turnComplete'], fromTurnComplete);
|
|
6329
|
-
}
|
|
6330
|
-
const fromInterrupted = getValueByPath(fromObject, ['interrupted']);
|
|
6331
|
-
if (fromInterrupted !== undefined) {
|
|
6332
|
-
setValueByPath(toObject, ['interrupted'], fromInterrupted);
|
|
6333
|
-
}
|
|
6334
|
-
return toObject;
|
|
6335
|
-
}
|
|
6336
|
-
function functionCallFromMldev(apiClient, fromObject) {
|
|
6337
|
-
const toObject = {};
|
|
6338
|
-
const fromId = getValueByPath(fromObject, ['id']);
|
|
6339
|
-
if (fromId !== undefined) {
|
|
6340
|
-
setValueByPath(toObject, ['id'], fromId);
|
|
6341
|
-
}
|
|
6342
|
-
const fromArgs = getValueByPath(fromObject, ['args']);
|
|
6343
|
-
if (fromArgs !== undefined) {
|
|
6344
|
-
setValueByPath(toObject, ['args'], fromArgs);
|
|
6345
|
-
}
|
|
6346
|
-
const fromName = getValueByPath(fromObject, ['name']);
|
|
6347
|
-
if (fromName !== undefined) {
|
|
6348
|
-
setValueByPath(toObject, ['name'], fromName);
|
|
6349
|
-
}
|
|
6350
|
-
return toObject;
|
|
6351
|
-
}
|
|
6352
|
-
function functionCallFromVertex(apiClient, fromObject) {
|
|
6353
|
-
const toObject = {};
|
|
6354
|
-
const fromArgs = getValueByPath(fromObject, ['args']);
|
|
6355
|
-
if (fromArgs !== undefined) {
|
|
6356
|
-
setValueByPath(toObject, ['args'], fromArgs);
|
|
6357
|
-
}
|
|
6358
|
-
const fromName = getValueByPath(fromObject, ['name']);
|
|
6359
|
-
if (fromName !== undefined) {
|
|
6360
|
-
setValueByPath(toObject, ['name'], fromName);
|
|
6361
|
-
}
|
|
6362
|
-
return toObject;
|
|
6363
|
-
}
|
|
6364
|
-
function liveServerToolCallFromMldev(apiClient, fromObject) {
|
|
6365
|
-
const toObject = {};
|
|
6366
|
-
const fromFunctionCalls = getValueByPath(fromObject, [
|
|
6367
|
-
'functionCalls',
|
|
6368
|
-
]);
|
|
6369
|
-
if (fromFunctionCalls !== undefined &&
|
|
6370
|
-
fromFunctionCalls !== null &&
|
|
6371
|
-
Array.isArray(fromFunctionCalls)) {
|
|
6372
|
-
setValueByPath(toObject, ['functionCalls'], fromFunctionCalls.map((item) => {
|
|
6373
|
-
return functionCallFromMldev(apiClient, item);
|
|
6374
|
-
}));
|
|
6375
|
-
}
|
|
6376
|
-
return toObject;
|
|
6377
|
-
}
|
|
6378
|
-
function liveServerToolCallFromVertex(apiClient, fromObject) {
|
|
6379
|
-
const toObject = {};
|
|
6380
|
-
const fromFunctionCalls = getValueByPath(fromObject, [
|
|
6381
|
-
'functionCalls',
|
|
6382
|
-
]);
|
|
6383
|
-
if (fromFunctionCalls !== undefined &&
|
|
6384
|
-
fromFunctionCalls !== null &&
|
|
6385
|
-
Array.isArray(fromFunctionCalls)) {
|
|
6386
|
-
setValueByPath(toObject, ['functionCalls'], fromFunctionCalls.map((item) => {
|
|
6387
|
-
return functionCallFromVertex(apiClient, item);
|
|
6388
|
-
}));
|
|
6389
|
-
}
|
|
6390
|
-
return toObject;
|
|
6391
|
-
}
|
|
6392
|
-
function liveServerToolCallCancellationFromMldev(apiClient, fromObject) {
|
|
6393
|
-
const toObject = {};
|
|
6394
|
-
const fromIds = getValueByPath(fromObject, ['ids']);
|
|
6395
|
-
if (fromIds !== undefined) {
|
|
6396
|
-
setValueByPath(toObject, ['ids'], fromIds);
|
|
6397
|
-
}
|
|
6398
|
-
return toObject;
|
|
6399
|
-
}
|
|
6400
|
-
function liveServerToolCallCancellationFromVertex(apiClient, fromObject) {
|
|
6401
|
-
const toObject = {};
|
|
6402
|
-
const fromIds = getValueByPath(fromObject, ['ids']);
|
|
6403
|
-
if (fromIds !== undefined) {
|
|
6404
|
-
setValueByPath(toObject, ['ids'], fromIds);
|
|
7823
|
+
setValueByPath(toObject, ['response'], generateVideosResponseFromVertex$1(apiClient, fromResponse));
|
|
6405
7824
|
}
|
|
6406
7825
|
return toObject;
|
|
6407
7826
|
}
|
|
@@ -6461,17 +7880,20 @@ class Live {
|
|
|
6461
7880
|
@experimental
|
|
6462
7881
|
|
|
6463
7882
|
@remarks
|
|
6464
|
-
If using the Gemini API, Live is currently only supported behind API
|
|
6465
|
-
version `v1alpha`. Ensure that the API version is set to `v1alpha` when
|
|
6466
|
-
initializing the SDK if relying on the Gemini API.
|
|
6467
7883
|
|
|
6468
7884
|
@param params - The parameters for establishing a connection to the model.
|
|
6469
7885
|
@return A live session.
|
|
6470
7886
|
|
|
6471
7887
|
@example
|
|
6472
7888
|
```ts
|
|
7889
|
+
let model: string;
|
|
7890
|
+
if (GOOGLE_GENAI_USE_VERTEXAI) {
|
|
7891
|
+
model = 'gemini-2.0-flash-live-preview-04-09';
|
|
7892
|
+
} else {
|
|
7893
|
+
model = 'gemini-2.0-flash-live-001';
|
|
7894
|
+
}
|
|
6473
7895
|
const session = await ai.live.connect({
|
|
6474
|
-
model:
|
|
7896
|
+
model: model,
|
|
6475
7897
|
config: {
|
|
6476
7898
|
responseModalities: [Modality.AUDIO],
|
|
6477
7899
|
},
|
|
@@ -6493,7 +7915,7 @@ class Live {
|
|
|
6493
7915
|
```
|
|
6494
7916
|
*/
|
|
6495
7917
|
async connect(params) {
|
|
6496
|
-
var _a, _b;
|
|
7918
|
+
var _a, _b, _c, _d;
|
|
6497
7919
|
const websocketBaseUrl = this.apiClient.getWebsocketBaseUrl();
|
|
6498
7920
|
const apiVersion = this.apiClient.getApiVersion();
|
|
6499
7921
|
let url;
|
|
@@ -6540,6 +7962,20 @@ class Live {
|
|
|
6540
7962
|
`projects/${project}/locations/${location}/` + transformedModel;
|
|
6541
7963
|
}
|
|
6542
7964
|
let clientMessage = {};
|
|
7965
|
+
if (this.apiClient.isVertexAI() &&
|
|
7966
|
+
((_c = params.config) === null || _c === void 0 ? void 0 : _c.responseModalities) === undefined) {
|
|
7967
|
+
// Set default to AUDIO to align with MLDev API.
|
|
7968
|
+
if (params.config === undefined) {
|
|
7969
|
+
params.config = { responseModalities: [Modality.AUDIO] };
|
|
7970
|
+
}
|
|
7971
|
+
else {
|
|
7972
|
+
params.config.responseModalities = [Modality.AUDIO];
|
|
7973
|
+
}
|
|
7974
|
+
}
|
|
7975
|
+
if ((_d = params.config) === null || _d === void 0 ? void 0 : _d.generationConfig) {
|
|
7976
|
+
// Raise deprecation warning for generationConfig.
|
|
7977
|
+
console.warn('Setting `LiveConnectConfig.generation_config` is deprecated, please set the fields on `LiveConnectConfig` directly. This will become an error in a future version (not before Q3 2025).');
|
|
7978
|
+
}
|
|
6543
7979
|
const liveConnectParameters = {
|
|
6544
7980
|
model: transformedModel,
|
|
6545
7981
|
config: params.config,
|
|
@@ -6551,6 +7987,7 @@ class Live {
|
|
|
6551
7987
|
else {
|
|
6552
7988
|
clientMessage = liveConnectParametersToMldev(this.apiClient, liveConnectParameters);
|
|
6553
7989
|
}
|
|
7990
|
+
delete clientMessage['config'];
|
|
6554
7991
|
conn.send(JSON.stringify(clientMessage));
|
|
6555
7992
|
return new Session(conn, this.apiClient);
|
|
6556
7993
|
}
|
|
@@ -6597,7 +8034,13 @@ class Session {
|
|
|
6597
8034
|
throw new Error(`Failed to convert realtime input "media", type: '${typeof params.media}'`);
|
|
6598
8035
|
}
|
|
6599
8036
|
// LiveClientRealtimeInput
|
|
6600
|
-
clientMessage = {
|
|
8037
|
+
clientMessage = {
|
|
8038
|
+
realtimeInput: {
|
|
8039
|
+
mediaChunks: [params.media],
|
|
8040
|
+
activityStart: params.activityStart,
|
|
8041
|
+
activityEnd: params.activityEnd,
|
|
8042
|
+
},
|
|
8043
|
+
};
|
|
6601
8044
|
return clientMessage;
|
|
6602
8045
|
}
|
|
6603
8046
|
tLiveClienttToolResponse(apiClient, params) {
|
|
@@ -6741,8 +8184,14 @@ class Session {
|
|
|
6741
8184
|
|
|
6742
8185
|
@example
|
|
6743
8186
|
```ts
|
|
8187
|
+
let model: string;
|
|
8188
|
+
if (GOOGLE_GENAI_USE_VERTEXAI) {
|
|
8189
|
+
model = 'gemini-2.0-flash-live-preview-04-09';
|
|
8190
|
+
} else {
|
|
8191
|
+
model = 'gemini-2.0-flash-live-001';
|
|
8192
|
+
}
|
|
6744
8193
|
const session = await ai.live.connect({
|
|
6745
|
-
model:
|
|
8194
|
+
model: model,
|
|
6746
8195
|
config: {
|
|
6747
8196
|
responseModalities: [Modality.AUDIO],
|
|
6748
8197
|
}
|
|
@@ -7008,7 +8457,7 @@ class Models extends BaseModule {
|
|
|
7008
8457
|
_c = apiResponse_1_1.value;
|
|
7009
8458
|
_d = false;
|
|
7010
8459
|
const chunk = _c;
|
|
7011
|
-
const resp = generateContentResponseFromVertex(apiClient, chunk);
|
|
8460
|
+
const resp = generateContentResponseFromVertex(apiClient, (yield __await(chunk.json())));
|
|
7012
8461
|
const typedResp = new GenerateContentResponse();
|
|
7013
8462
|
Object.assign(typedResp, resp);
|
|
7014
8463
|
yield yield __await(typedResp);
|
|
@@ -7047,7 +8496,7 @@ class Models extends BaseModule {
|
|
|
7047
8496
|
_c = apiResponse_2_1.value;
|
|
7048
8497
|
_d = false;
|
|
7049
8498
|
const chunk = _c;
|
|
7050
|
-
const resp = generateContentResponseFromMldev(apiClient, chunk);
|
|
8499
|
+
const resp = generateContentResponseFromMldev(apiClient, (yield __await(chunk.json())));
|
|
7051
8500
|
const typedResp = new GenerateContentResponse();
|
|
7052
8501
|
Object.assign(typedResp, resp);
|
|
7053
8502
|
yield yield __await(typedResp);
|
|
@@ -7216,6 +8665,66 @@ class Models extends BaseModule {
|
|
|
7216
8665
|
});
|
|
7217
8666
|
}
|
|
7218
8667
|
}
|
|
8668
|
+
/**
|
|
8669
|
+
* Fetches information about a model by name.
|
|
8670
|
+
*
|
|
8671
|
+
* @example
|
|
8672
|
+
* ```ts
|
|
8673
|
+
* const modelInfo = await ai.models.get({model: 'gemini-2.0-flash'});
|
|
8674
|
+
* ```
|
|
8675
|
+
*/
|
|
8676
|
+
async get(params) {
|
|
8677
|
+
var _a, _b;
|
|
8678
|
+
let response;
|
|
8679
|
+
let path = '';
|
|
8680
|
+
let queryParams = {};
|
|
8681
|
+
if (this.apiClient.isVertexAI()) {
|
|
8682
|
+
const body = getModelParametersToVertex(this.apiClient, params);
|
|
8683
|
+
path = formatMap('{name}', body['_url']);
|
|
8684
|
+
queryParams = body['_query'];
|
|
8685
|
+
delete body['config'];
|
|
8686
|
+
delete body['_url'];
|
|
8687
|
+
delete body['_query'];
|
|
8688
|
+
response = this.apiClient
|
|
8689
|
+
.request({
|
|
8690
|
+
path: path,
|
|
8691
|
+
queryParams: queryParams,
|
|
8692
|
+
body: JSON.stringify(body),
|
|
8693
|
+
httpMethod: 'GET',
|
|
8694
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
8695
|
+
})
|
|
8696
|
+
.then((httpResponse) => {
|
|
8697
|
+
return httpResponse.json();
|
|
8698
|
+
});
|
|
8699
|
+
return response.then((apiResponse) => {
|
|
8700
|
+
const resp = modelFromVertex(this.apiClient, apiResponse);
|
|
8701
|
+
return resp;
|
|
8702
|
+
});
|
|
8703
|
+
}
|
|
8704
|
+
else {
|
|
8705
|
+
const body = getModelParametersToMldev(this.apiClient, params);
|
|
8706
|
+
path = formatMap('{name}', body['_url']);
|
|
8707
|
+
queryParams = body['_query'];
|
|
8708
|
+
delete body['config'];
|
|
8709
|
+
delete body['_url'];
|
|
8710
|
+
delete body['_query'];
|
|
8711
|
+
response = this.apiClient
|
|
8712
|
+
.request({
|
|
8713
|
+
path: path,
|
|
8714
|
+
queryParams: queryParams,
|
|
8715
|
+
body: JSON.stringify(body),
|
|
8716
|
+
httpMethod: 'GET',
|
|
8717
|
+
httpOptions: (_b = params.config) === null || _b === void 0 ? void 0 : _b.httpOptions,
|
|
8718
|
+
})
|
|
8719
|
+
.then((httpResponse) => {
|
|
8720
|
+
return httpResponse.json();
|
|
8721
|
+
});
|
|
8722
|
+
return response.then((apiResponse) => {
|
|
8723
|
+
const resp = modelFromMldev(this.apiClient, apiResponse);
|
|
8724
|
+
return resp;
|
|
8725
|
+
});
|
|
8726
|
+
}
|
|
8727
|
+
}
|
|
7219
8728
|
/**
|
|
7220
8729
|
* Counts the number of tokens in the given contents. Multimodal input is
|
|
7221
8730
|
* supported for Gemini models.
|
|
@@ -7357,10 +8866,10 @@ class Models extends BaseModule {
|
|
|
7357
8866
|
*
|
|
7358
8867
|
* while (!operation.done) {
|
|
7359
8868
|
* await new Promise(resolve => setTimeout(resolve, 10000));
|
|
7360
|
-
* operation = await ai.operations.
|
|
8869
|
+
* operation = await ai.operations.getVideosOperation({operation: operation});
|
|
7361
8870
|
* }
|
|
7362
8871
|
*
|
|
7363
|
-
* console.log(operation.
|
|
8872
|
+
* console.log(operation.response?.generatedVideos?.[0]?.video?.uri);
|
|
7364
8873
|
* ```
|
|
7365
8874
|
*/
|
|
7366
8875
|
async generateVideos(params) {
|
|
@@ -7542,16 +9051,12 @@ function generateVideosOperationFromMldev(apiClient, fromObject) {
|
|
|
7542
9051
|
if (fromError != null) {
|
|
7543
9052
|
setValueByPath(toObject, ['error'], fromError);
|
|
7544
9053
|
}
|
|
7545
|
-
const fromResponse = getValueByPath(fromObject, [
|
|
7546
|
-
if (fromResponse != null) {
|
|
7547
|
-
setValueByPath(toObject, ['response'], fromResponse);
|
|
7548
|
-
}
|
|
7549
|
-
const fromResult = getValueByPath(fromObject, [
|
|
9054
|
+
const fromResponse = getValueByPath(fromObject, [
|
|
7550
9055
|
'response',
|
|
7551
9056
|
'generateVideoResponse',
|
|
7552
9057
|
]);
|
|
7553
|
-
if (
|
|
7554
|
-
setValueByPath(toObject, ['
|
|
9058
|
+
if (fromResponse != null) {
|
|
9059
|
+
setValueByPath(toObject, ['response'], generateVideosResponseFromMldev(apiClient, fromResponse));
|
|
7555
9060
|
}
|
|
7556
9061
|
return toObject;
|
|
7557
9062
|
}
|
|
@@ -7628,11 +9133,7 @@ function generateVideosOperationFromVertex(apiClient, fromObject) {
|
|
|
7628
9133
|
}
|
|
7629
9134
|
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
7630
9135
|
if (fromResponse != null) {
|
|
7631
|
-
setValueByPath(toObject, ['response'], fromResponse);
|
|
7632
|
-
}
|
|
7633
|
-
const fromResult = getValueByPath(fromObject, ['response']);
|
|
7634
|
-
if (fromResult != null) {
|
|
7635
|
-
setValueByPath(toObject, ['result'], generateVideosResponseFromVertex(apiClient, fromResult));
|
|
9136
|
+
setValueByPath(toObject, ['response'], generateVideosResponseFromVertex(apiClient, fromResponse));
|
|
7636
9137
|
}
|
|
7637
9138
|
return toObject;
|
|
7638
9139
|
}
|
|
@@ -7650,10 +9151,10 @@ class Operations extends BaseModule {
|
|
|
7650
9151
|
/**
|
|
7651
9152
|
* Gets the status of a long-running operation.
|
|
7652
9153
|
*
|
|
7653
|
-
* @param
|
|
9154
|
+
* @param parameters The parameters for the get operation request.
|
|
7654
9155
|
* @return The updated Operation object, with the latest status or result.
|
|
7655
9156
|
*/
|
|
7656
|
-
async
|
|
9157
|
+
async getVideosOperation(parameters) {
|
|
7657
9158
|
const operation = parameters.operation;
|
|
7658
9159
|
const config = parameters.config;
|
|
7659
9160
|
if (operation.name === undefined || operation.name === '') {
|
|
@@ -7661,7 +9162,7 @@ class Operations extends BaseModule {
|
|
|
7661
9162
|
}
|
|
7662
9163
|
if (this.apiClient.isVertexAI()) {
|
|
7663
9164
|
const resourceName = operation.name.split('/operations/')[0];
|
|
7664
|
-
|
|
9165
|
+
let httpOptions = undefined;
|
|
7665
9166
|
if (config && 'httpOptions' in config) {
|
|
7666
9167
|
httpOptions = config.httpOptions;
|
|
7667
9168
|
}
|
|
@@ -7848,5 +9349,5 @@ class GoogleGenAI {
|
|
|
7848
9349
|
}
|
|
7849
9350
|
}
|
|
7850
9351
|
|
|
7851
|
-
export { BlockedReason, Caches, Chat, Chats, ComputeTokensResponse, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DynamicRetrievalConfigMode, EmbedContentResponse, 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,
|
|
9352
|
+
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 };
|
|
7852
9353
|
//# sourceMappingURL=index.mjs.map
|