@google/genai 0.9.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -5
- package/dist/genai.d.ts +803 -41
- package/dist/index.js +1664 -1039
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1662 -1040
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.js +1792 -1128
- package/dist/node/index.js.map +1 -1
- package/dist/node/node.d.ts +803 -41
- package/dist/web/index.mjs +1786 -1123
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +803 -41
- package/package.json +1 -1
package/dist/node/index.js
CHANGED
|
@@ -24,6 +24,66 @@ function _interopNamespaceDefault(e) {
|
|
|
24
24
|
var NodeWs__namespace = /*#__PURE__*/_interopNamespaceDefault(NodeWs);
|
|
25
25
|
var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
|
|
26
26
|
|
|
27
|
+
/**
|
|
28
|
+
* @license
|
|
29
|
+
* Copyright 2025 Google LLC
|
|
30
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
31
|
+
*/
|
|
32
|
+
let _defaultBaseGeminiUrl = undefined;
|
|
33
|
+
let _defaultBaseVertexUrl = undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Overrides the base URLs for the Gemini API and Vertex AI API.
|
|
36
|
+
*
|
|
37
|
+
* @remarks This function should be called before initializing the SDK. If the
|
|
38
|
+
* base URLs are set after initializing the SDK, the base URLs will not be
|
|
39
|
+
* updated. Base URLs provided in the HttpOptions will also take precedence over
|
|
40
|
+
* URLs set here.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* import {GoogleGenAI, setDefaultBaseUrls} from '@google/genai';
|
|
45
|
+
* // Override the base URL for the Gemini API.
|
|
46
|
+
* setDefaultBaseUrls({geminiUrl:'https://gemini.google.com'});
|
|
47
|
+
*
|
|
48
|
+
* // Override the base URL for the Vertex AI API.
|
|
49
|
+
* setDefaultBaseUrls({vertexUrl: 'https://vertexai.googleapis.com'});
|
|
50
|
+
*
|
|
51
|
+
* const ai = new GoogleGenAI({apiKey: 'GEMINI_API_KEY'});
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
function setDefaultBaseUrls(baseUrlParams) {
|
|
55
|
+
_defaultBaseGeminiUrl = baseUrlParams.geminiUrl;
|
|
56
|
+
_defaultBaseVertexUrl = baseUrlParams.vertexUrl;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Returns the default base URLs for the Gemini API and Vertex AI API.
|
|
60
|
+
*/
|
|
61
|
+
function getDefaultBaseUrls() {
|
|
62
|
+
return {
|
|
63
|
+
geminiUrl: _defaultBaseGeminiUrl,
|
|
64
|
+
vertexUrl: _defaultBaseVertexUrl,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Returns the default base URL based on the following priority:
|
|
69
|
+
* 1. Base URLs set via HttpOptions.
|
|
70
|
+
* 2. Base URLs set via the latest call to setDefaultBaseUrls.
|
|
71
|
+
* 3. Base URLs set via environment variables.
|
|
72
|
+
*/
|
|
73
|
+
function getBaseUrl(options, vertexBaseUrlFromEnv, geminiBaseUrlFromEnv) {
|
|
74
|
+
var _a, _b, _c;
|
|
75
|
+
if (!((_a = options.httpOptions) === null || _a === void 0 ? void 0 : _a.baseUrl)) {
|
|
76
|
+
const defaultBaseUrls = getDefaultBaseUrls();
|
|
77
|
+
if (options.vertexai) {
|
|
78
|
+
return (_b = defaultBaseUrls.vertexUrl) !== null && _b !== void 0 ? _b : vertexBaseUrlFromEnv;
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
return (_c = defaultBaseUrls.geminiUrl) !== null && _c !== void 0 ? _c : geminiBaseUrlFromEnv;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return options.httpOptions.baseUrl;
|
|
85
|
+
}
|
|
86
|
+
|
|
27
87
|
/**
|
|
28
88
|
* @license
|
|
29
89
|
* Copyright 2025 Google LLC
|
|
@@ -199,6 +259,36 @@ function tCachesModel(apiClient, model) {
|
|
|
199
259
|
return transformedModel;
|
|
200
260
|
}
|
|
201
261
|
}
|
|
262
|
+
function tBlobs(apiClient, blobs) {
|
|
263
|
+
if (Array.isArray(blobs)) {
|
|
264
|
+
return blobs.map((blob) => tBlob(apiClient, blob));
|
|
265
|
+
}
|
|
266
|
+
else {
|
|
267
|
+
return [tBlob(apiClient, blobs)];
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
function tBlob(apiClient, blob) {
|
|
271
|
+
if (typeof blob === 'object' && blob !== null) {
|
|
272
|
+
return blob;
|
|
273
|
+
}
|
|
274
|
+
throw new Error(`Could not parse input as Blob. Unsupported blob type: ${typeof blob}`);
|
|
275
|
+
}
|
|
276
|
+
function tImageBlob(apiClient, blob) {
|
|
277
|
+
const transformedBlob = tBlob(apiClient, blob);
|
|
278
|
+
if (transformedBlob.mimeType &&
|
|
279
|
+
transformedBlob.mimeType.startsWith('image/')) {
|
|
280
|
+
return transformedBlob;
|
|
281
|
+
}
|
|
282
|
+
throw new Error(`Unsupported mime type: ${transformedBlob.mimeType}`);
|
|
283
|
+
}
|
|
284
|
+
function tAudioBlob(apiClient, blob) {
|
|
285
|
+
const transformedBlob = tBlob(apiClient, blob);
|
|
286
|
+
if (transformedBlob.mimeType &&
|
|
287
|
+
transformedBlob.mimeType.startsWith('audio/')) {
|
|
288
|
+
return transformedBlob;
|
|
289
|
+
}
|
|
290
|
+
throw new Error(`Unsupported mime type: ${transformedBlob.mimeType}`);
|
|
291
|
+
}
|
|
202
292
|
function tPart(apiClient, origin) {
|
|
203
293
|
if (origin === null || origin === undefined) {
|
|
204
294
|
throw new Error('PartUnion is required');
|
|
@@ -322,38 +412,11 @@ function tContents(apiClient, origin) {
|
|
|
322
412
|
}
|
|
323
413
|
return result;
|
|
324
414
|
}
|
|
325
|
-
function processSchema(apiClient, schema) {
|
|
326
|
-
if (!apiClient.isVertexAI()) {
|
|
327
|
-
if ('default' in schema) {
|
|
328
|
-
throw new Error('Default value is not supported in the response schema for the Gemini API.');
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
if ('anyOf' in schema) {
|
|
332
|
-
if (schema['anyOf'] !== undefined) {
|
|
333
|
-
for (const subSchema of schema['anyOf']) {
|
|
334
|
-
processSchema(apiClient, subSchema);
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
if ('items' in schema) {
|
|
339
|
-
if (schema['items'] !== undefined) {
|
|
340
|
-
processSchema(apiClient, schema['items']);
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
if ('properties' in schema) {
|
|
344
|
-
if (schema['properties'] !== undefined) {
|
|
345
|
-
for (const subSchema of Object.values(schema['properties'])) {
|
|
346
|
-
processSchema(apiClient, subSchema);
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
415
|
function tSchema(apiClient, schema) {
|
|
352
|
-
processSchema(apiClient, schema);
|
|
353
416
|
return schema;
|
|
354
417
|
}
|
|
355
418
|
function tSpeechConfig(apiClient, speechConfig) {
|
|
356
|
-
if (typeof speechConfig === 'object'
|
|
419
|
+
if (typeof speechConfig === 'object') {
|
|
357
420
|
return speechConfig;
|
|
358
421
|
}
|
|
359
422
|
else if (typeof speechConfig === 'string') {
|
|
@@ -461,6 +524,20 @@ function tCachedContentName(apiClient, name) {
|
|
|
461
524
|
}
|
|
462
525
|
return resourceName(apiClient, name, 'cachedContents');
|
|
463
526
|
}
|
|
527
|
+
function tTuningJobStatus(apiClient, status) {
|
|
528
|
+
switch (status) {
|
|
529
|
+
case 'STATE_UNSPECIFIED':
|
|
530
|
+
return 'JOB_STATE_UNSPECIFIED';
|
|
531
|
+
case 'CREATING':
|
|
532
|
+
return 'JOB_STATE_RUNNING';
|
|
533
|
+
case 'ACTIVE':
|
|
534
|
+
return 'JOB_STATE_SUCCEEDED';
|
|
535
|
+
case 'FAILED':
|
|
536
|
+
return 'JOB_STATE_FAILED';
|
|
537
|
+
default:
|
|
538
|
+
return status;
|
|
539
|
+
}
|
|
540
|
+
}
|
|
464
541
|
function tBytes(apiClient, fromImageBytes) {
|
|
465
542
|
if (typeof fromImageBytes !== 'string') {
|
|
466
543
|
throw new Error('fromImageBytes must be a string');
|
|
@@ -533,14 +610,13 @@ function contentToMldev$2(apiClient, fromObject) {
|
|
|
533
610
|
const toObject = {};
|
|
534
611
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
535
612
|
if (fromParts != null) {
|
|
536
|
-
|
|
537
|
-
|
|
613
|
+
let transformedList = fromParts;
|
|
614
|
+
if (Array.isArray(transformedList)) {
|
|
615
|
+
transformedList = transformedList.map((item) => {
|
|
538
616
|
return partToMldev$2(apiClient, item);
|
|
539
|
-
})
|
|
540
|
-
}
|
|
541
|
-
else {
|
|
542
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
617
|
+
});
|
|
543
618
|
}
|
|
619
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
544
620
|
}
|
|
545
621
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
546
622
|
if (fromRole != null) {
|
|
@@ -548,25 +624,6 @@ function contentToMldev$2(apiClient, fromObject) {
|
|
|
548
624
|
}
|
|
549
625
|
return toObject;
|
|
550
626
|
}
|
|
551
|
-
function functionDeclarationToMldev$2(apiClient, fromObject) {
|
|
552
|
-
const toObject = {};
|
|
553
|
-
if (getValueByPath(fromObject, ['response']) !== undefined) {
|
|
554
|
-
throw new Error('response parameter is not supported in Gemini API.');
|
|
555
|
-
}
|
|
556
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
557
|
-
if (fromDescription != null) {
|
|
558
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
559
|
-
}
|
|
560
|
-
const fromName = getValueByPath(fromObject, ['name']);
|
|
561
|
-
if (fromName != null) {
|
|
562
|
-
setValueByPath(toObject, ['name'], fromName);
|
|
563
|
-
}
|
|
564
|
-
const fromParameters = getValueByPath(fromObject, ['parameters']);
|
|
565
|
-
if (fromParameters != null) {
|
|
566
|
-
setValueByPath(toObject, ['parameters'], fromParameters);
|
|
567
|
-
}
|
|
568
|
-
return toObject;
|
|
569
|
-
}
|
|
570
627
|
function googleSearchToMldev$2() {
|
|
571
628
|
const toObject = {};
|
|
572
629
|
return toObject;
|
|
@@ -597,19 +654,6 @@ function googleSearchRetrievalToMldev$2(apiClient, fromObject) {
|
|
|
597
654
|
}
|
|
598
655
|
function toolToMldev$2(apiClient, fromObject) {
|
|
599
656
|
const toObject = {};
|
|
600
|
-
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
601
|
-
'functionDeclarations',
|
|
602
|
-
]);
|
|
603
|
-
if (fromFunctionDeclarations != null) {
|
|
604
|
-
if (Array.isArray(fromFunctionDeclarations)) {
|
|
605
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations.map((item) => {
|
|
606
|
-
return functionDeclarationToMldev$2(apiClient, item);
|
|
607
|
-
}));
|
|
608
|
-
}
|
|
609
|
-
else {
|
|
610
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
657
|
if (getValueByPath(fromObject, ['retrieval']) !== undefined) {
|
|
614
658
|
throw new Error('retrieval parameter is not supported in Gemini API.');
|
|
615
659
|
}
|
|
@@ -629,6 +673,12 @@ function toolToMldev$2(apiClient, fromObject) {
|
|
|
629
673
|
if (fromCodeExecution != null) {
|
|
630
674
|
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
631
675
|
}
|
|
676
|
+
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
677
|
+
'functionDeclarations',
|
|
678
|
+
]);
|
|
679
|
+
if (fromFunctionDeclarations != null) {
|
|
680
|
+
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
681
|
+
}
|
|
632
682
|
return toObject;
|
|
633
683
|
}
|
|
634
684
|
function functionCallingConfigToMldev$1(apiClient, fromObject) {
|
|
@@ -671,14 +721,13 @@ function createCachedContentConfigToMldev(apiClient, fromObject, parentObject) {
|
|
|
671
721
|
}
|
|
672
722
|
const fromContents = getValueByPath(fromObject, ['contents']);
|
|
673
723
|
if (parentObject !== undefined && fromContents != null) {
|
|
674
|
-
|
|
675
|
-
|
|
724
|
+
let transformedList = tContents(apiClient, fromContents);
|
|
725
|
+
if (Array.isArray(transformedList)) {
|
|
726
|
+
transformedList = transformedList.map((item) => {
|
|
676
727
|
return contentToMldev$2(apiClient, item);
|
|
677
|
-
})
|
|
678
|
-
}
|
|
679
|
-
else {
|
|
680
|
-
setValueByPath(parentObject, ['contents'], tContents(apiClient, fromContents));
|
|
728
|
+
});
|
|
681
729
|
}
|
|
730
|
+
setValueByPath(parentObject, ['contents'], transformedList);
|
|
682
731
|
}
|
|
683
732
|
const fromSystemInstruction = getValueByPath(fromObject, [
|
|
684
733
|
'systemInstruction',
|
|
@@ -688,14 +737,13 @@ function createCachedContentConfigToMldev(apiClient, fromObject, parentObject) {
|
|
|
688
737
|
}
|
|
689
738
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
690
739
|
if (parentObject !== undefined && fromTools != null) {
|
|
691
|
-
|
|
692
|
-
|
|
740
|
+
let transformedList = fromTools;
|
|
741
|
+
if (Array.isArray(transformedList)) {
|
|
742
|
+
transformedList = transformedList.map((item) => {
|
|
693
743
|
return toolToMldev$2(apiClient, item);
|
|
694
|
-
})
|
|
695
|
-
}
|
|
696
|
-
else {
|
|
697
|
-
setValueByPath(parentObject, ['tools'], fromTools);
|
|
744
|
+
});
|
|
698
745
|
}
|
|
746
|
+
setValueByPath(parentObject, ['tools'], transformedList);
|
|
699
747
|
}
|
|
700
748
|
const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
|
|
701
749
|
if (parentObject !== undefined && fromToolConfig != null) {
|
|
@@ -835,14 +883,13 @@ function contentToVertex$2(apiClient, fromObject) {
|
|
|
835
883
|
const toObject = {};
|
|
836
884
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
837
885
|
if (fromParts != null) {
|
|
838
|
-
|
|
839
|
-
|
|
886
|
+
let transformedList = fromParts;
|
|
887
|
+
if (Array.isArray(transformedList)) {
|
|
888
|
+
transformedList = transformedList.map((item) => {
|
|
840
889
|
return partToVertex$2(apiClient, item);
|
|
841
|
-
})
|
|
842
|
-
}
|
|
843
|
-
else {
|
|
844
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
890
|
+
});
|
|
845
891
|
}
|
|
892
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
846
893
|
}
|
|
847
894
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
848
895
|
if (fromRole != null) {
|
|
@@ -850,124 +897,6 @@ function contentToVertex$2(apiClient, fromObject) {
|
|
|
850
897
|
}
|
|
851
898
|
return toObject;
|
|
852
899
|
}
|
|
853
|
-
function schemaToVertex$2(apiClient, fromObject) {
|
|
854
|
-
const toObject = {};
|
|
855
|
-
const fromExample = getValueByPath(fromObject, ['example']);
|
|
856
|
-
if (fromExample != null) {
|
|
857
|
-
setValueByPath(toObject, ['example'], fromExample);
|
|
858
|
-
}
|
|
859
|
-
const fromPattern = getValueByPath(fromObject, ['pattern']);
|
|
860
|
-
if (fromPattern != null) {
|
|
861
|
-
setValueByPath(toObject, ['pattern'], fromPattern);
|
|
862
|
-
}
|
|
863
|
-
const fromDefault = getValueByPath(fromObject, ['default']);
|
|
864
|
-
if (fromDefault != null) {
|
|
865
|
-
setValueByPath(toObject, ['default'], fromDefault);
|
|
866
|
-
}
|
|
867
|
-
const fromMaxLength = getValueByPath(fromObject, ['maxLength']);
|
|
868
|
-
if (fromMaxLength != null) {
|
|
869
|
-
setValueByPath(toObject, ['maxLength'], fromMaxLength);
|
|
870
|
-
}
|
|
871
|
-
const fromMinLength = getValueByPath(fromObject, ['minLength']);
|
|
872
|
-
if (fromMinLength != null) {
|
|
873
|
-
setValueByPath(toObject, ['minLength'], fromMinLength);
|
|
874
|
-
}
|
|
875
|
-
const fromMinProperties = getValueByPath(fromObject, [
|
|
876
|
-
'minProperties',
|
|
877
|
-
]);
|
|
878
|
-
if (fromMinProperties != null) {
|
|
879
|
-
setValueByPath(toObject, ['minProperties'], fromMinProperties);
|
|
880
|
-
}
|
|
881
|
-
const fromMaxProperties = getValueByPath(fromObject, [
|
|
882
|
-
'maxProperties',
|
|
883
|
-
]);
|
|
884
|
-
if (fromMaxProperties != null) {
|
|
885
|
-
setValueByPath(toObject, ['maxProperties'], fromMaxProperties);
|
|
886
|
-
}
|
|
887
|
-
const fromAnyOf = getValueByPath(fromObject, ['anyOf']);
|
|
888
|
-
if (fromAnyOf != null) {
|
|
889
|
-
setValueByPath(toObject, ['anyOf'], fromAnyOf);
|
|
890
|
-
}
|
|
891
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
892
|
-
if (fromDescription != null) {
|
|
893
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
894
|
-
}
|
|
895
|
-
const fromEnum = getValueByPath(fromObject, ['enum']);
|
|
896
|
-
if (fromEnum != null) {
|
|
897
|
-
setValueByPath(toObject, ['enum'], fromEnum);
|
|
898
|
-
}
|
|
899
|
-
const fromFormat = getValueByPath(fromObject, ['format']);
|
|
900
|
-
if (fromFormat != null) {
|
|
901
|
-
setValueByPath(toObject, ['format'], fromFormat);
|
|
902
|
-
}
|
|
903
|
-
const fromItems = getValueByPath(fromObject, ['items']);
|
|
904
|
-
if (fromItems != null) {
|
|
905
|
-
setValueByPath(toObject, ['items'], fromItems);
|
|
906
|
-
}
|
|
907
|
-
const fromMaxItems = getValueByPath(fromObject, ['maxItems']);
|
|
908
|
-
if (fromMaxItems != null) {
|
|
909
|
-
setValueByPath(toObject, ['maxItems'], fromMaxItems);
|
|
910
|
-
}
|
|
911
|
-
const fromMaximum = getValueByPath(fromObject, ['maximum']);
|
|
912
|
-
if (fromMaximum != null) {
|
|
913
|
-
setValueByPath(toObject, ['maximum'], fromMaximum);
|
|
914
|
-
}
|
|
915
|
-
const fromMinItems = getValueByPath(fromObject, ['minItems']);
|
|
916
|
-
if (fromMinItems != null) {
|
|
917
|
-
setValueByPath(toObject, ['minItems'], fromMinItems);
|
|
918
|
-
}
|
|
919
|
-
const fromMinimum = getValueByPath(fromObject, ['minimum']);
|
|
920
|
-
if (fromMinimum != null) {
|
|
921
|
-
setValueByPath(toObject, ['minimum'], fromMinimum);
|
|
922
|
-
}
|
|
923
|
-
const fromNullable = getValueByPath(fromObject, ['nullable']);
|
|
924
|
-
if (fromNullable != null) {
|
|
925
|
-
setValueByPath(toObject, ['nullable'], fromNullable);
|
|
926
|
-
}
|
|
927
|
-
const fromProperties = getValueByPath(fromObject, ['properties']);
|
|
928
|
-
if (fromProperties != null) {
|
|
929
|
-
setValueByPath(toObject, ['properties'], fromProperties);
|
|
930
|
-
}
|
|
931
|
-
const fromPropertyOrdering = getValueByPath(fromObject, [
|
|
932
|
-
'propertyOrdering',
|
|
933
|
-
]);
|
|
934
|
-
if (fromPropertyOrdering != null) {
|
|
935
|
-
setValueByPath(toObject, ['propertyOrdering'], fromPropertyOrdering);
|
|
936
|
-
}
|
|
937
|
-
const fromRequired = getValueByPath(fromObject, ['required']);
|
|
938
|
-
if (fromRequired != null) {
|
|
939
|
-
setValueByPath(toObject, ['required'], fromRequired);
|
|
940
|
-
}
|
|
941
|
-
const fromTitle = getValueByPath(fromObject, ['title']);
|
|
942
|
-
if (fromTitle != null) {
|
|
943
|
-
setValueByPath(toObject, ['title'], fromTitle);
|
|
944
|
-
}
|
|
945
|
-
const fromType = getValueByPath(fromObject, ['type']);
|
|
946
|
-
if (fromType != null) {
|
|
947
|
-
setValueByPath(toObject, ['type'], fromType);
|
|
948
|
-
}
|
|
949
|
-
return toObject;
|
|
950
|
-
}
|
|
951
|
-
function functionDeclarationToVertex$2(apiClient, fromObject) {
|
|
952
|
-
const toObject = {};
|
|
953
|
-
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
954
|
-
if (fromResponse != null) {
|
|
955
|
-
setValueByPath(toObject, ['response'], schemaToVertex$2(apiClient, fromResponse));
|
|
956
|
-
}
|
|
957
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
958
|
-
if (fromDescription != null) {
|
|
959
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
960
|
-
}
|
|
961
|
-
const fromName = getValueByPath(fromObject, ['name']);
|
|
962
|
-
if (fromName != null) {
|
|
963
|
-
setValueByPath(toObject, ['name'], fromName);
|
|
964
|
-
}
|
|
965
|
-
const fromParameters = getValueByPath(fromObject, ['parameters']);
|
|
966
|
-
if (fromParameters != null) {
|
|
967
|
-
setValueByPath(toObject, ['parameters'], fromParameters);
|
|
968
|
-
}
|
|
969
|
-
return toObject;
|
|
970
|
-
}
|
|
971
900
|
function googleSearchToVertex$2() {
|
|
972
901
|
const toObject = {};
|
|
973
902
|
return toObject;
|
|
@@ -998,19 +927,6 @@ function googleSearchRetrievalToVertex$2(apiClient, fromObject) {
|
|
|
998
927
|
}
|
|
999
928
|
function toolToVertex$2(apiClient, fromObject) {
|
|
1000
929
|
const toObject = {};
|
|
1001
|
-
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
1002
|
-
'functionDeclarations',
|
|
1003
|
-
]);
|
|
1004
|
-
if (fromFunctionDeclarations != null) {
|
|
1005
|
-
if (Array.isArray(fromFunctionDeclarations)) {
|
|
1006
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations.map((item) => {
|
|
1007
|
-
return functionDeclarationToVertex$2(apiClient, item);
|
|
1008
|
-
}));
|
|
1009
|
-
}
|
|
1010
|
-
else {
|
|
1011
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
1012
|
-
}
|
|
1013
|
-
}
|
|
1014
930
|
const fromRetrieval = getValueByPath(fromObject, ['retrieval']);
|
|
1015
931
|
if (fromRetrieval != null) {
|
|
1016
932
|
setValueByPath(toObject, ['retrieval'], fromRetrieval);
|
|
@@ -1031,6 +947,12 @@ function toolToVertex$2(apiClient, fromObject) {
|
|
|
1031
947
|
if (fromCodeExecution != null) {
|
|
1032
948
|
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
1033
949
|
}
|
|
950
|
+
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
951
|
+
'functionDeclarations',
|
|
952
|
+
]);
|
|
953
|
+
if (fromFunctionDeclarations != null) {
|
|
954
|
+
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
955
|
+
}
|
|
1034
956
|
return toObject;
|
|
1035
957
|
}
|
|
1036
958
|
function functionCallingConfigToVertex$1(apiClient, fromObject) {
|
|
@@ -1073,14 +995,13 @@ function createCachedContentConfigToVertex(apiClient, fromObject, parentObject)
|
|
|
1073
995
|
}
|
|
1074
996
|
const fromContents = getValueByPath(fromObject, ['contents']);
|
|
1075
997
|
if (parentObject !== undefined && fromContents != null) {
|
|
1076
|
-
|
|
1077
|
-
|
|
998
|
+
let transformedList = tContents(apiClient, fromContents);
|
|
999
|
+
if (Array.isArray(transformedList)) {
|
|
1000
|
+
transformedList = transformedList.map((item) => {
|
|
1078
1001
|
return contentToVertex$2(apiClient, item);
|
|
1079
|
-
})
|
|
1080
|
-
}
|
|
1081
|
-
else {
|
|
1082
|
-
setValueByPath(parentObject, ['contents'], tContents(apiClient, fromContents));
|
|
1002
|
+
});
|
|
1083
1003
|
}
|
|
1004
|
+
setValueByPath(parentObject, ['contents'], transformedList);
|
|
1084
1005
|
}
|
|
1085
1006
|
const fromSystemInstruction = getValueByPath(fromObject, [
|
|
1086
1007
|
'systemInstruction',
|
|
@@ -1090,14 +1011,13 @@ function createCachedContentConfigToVertex(apiClient, fromObject, parentObject)
|
|
|
1090
1011
|
}
|
|
1091
1012
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
1092
1013
|
if (parentObject !== undefined && fromTools != null) {
|
|
1093
|
-
|
|
1094
|
-
|
|
1014
|
+
let transformedList = fromTools;
|
|
1015
|
+
if (Array.isArray(transformedList)) {
|
|
1016
|
+
transformedList = transformedList.map((item) => {
|
|
1095
1017
|
return toolToVertex$2(apiClient, item);
|
|
1096
|
-
})
|
|
1097
|
-
}
|
|
1098
|
-
else {
|
|
1099
|
-
setValueByPath(parentObject, ['tools'], fromTools);
|
|
1018
|
+
});
|
|
1100
1019
|
}
|
|
1020
|
+
setValueByPath(parentObject, ['tools'], transformedList);
|
|
1101
1021
|
}
|
|
1102
1022
|
const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
|
|
1103
1023
|
if (parentObject !== undefined && fromToolConfig != null) {
|
|
@@ -1235,14 +1155,13 @@ function listCachedContentsResponseFromMldev(apiClient, fromObject) {
|
|
|
1235
1155
|
'cachedContents',
|
|
1236
1156
|
]);
|
|
1237
1157
|
if (fromCachedContents != null) {
|
|
1238
|
-
|
|
1239
|
-
|
|
1158
|
+
let transformedList = fromCachedContents;
|
|
1159
|
+
if (Array.isArray(transformedList)) {
|
|
1160
|
+
transformedList = transformedList.map((item) => {
|
|
1240
1161
|
return cachedContentFromMldev(apiClient, item);
|
|
1241
|
-
})
|
|
1242
|
-
}
|
|
1243
|
-
else {
|
|
1244
|
-
setValueByPath(toObject, ['cachedContents'], fromCachedContents);
|
|
1162
|
+
});
|
|
1245
1163
|
}
|
|
1164
|
+
setValueByPath(toObject, ['cachedContents'], transformedList);
|
|
1246
1165
|
}
|
|
1247
1166
|
return toObject;
|
|
1248
1167
|
}
|
|
@@ -1296,14 +1215,13 @@ function listCachedContentsResponseFromVertex(apiClient, fromObject) {
|
|
|
1296
1215
|
'cachedContents',
|
|
1297
1216
|
]);
|
|
1298
1217
|
if (fromCachedContents != null) {
|
|
1299
|
-
|
|
1300
|
-
|
|
1218
|
+
let transformedList = fromCachedContents;
|
|
1219
|
+
if (Array.isArray(transformedList)) {
|
|
1220
|
+
transformedList = transformedList.map((item) => {
|
|
1301
1221
|
return cachedContentFromVertex(apiClient, item);
|
|
1302
|
-
})
|
|
1303
|
-
}
|
|
1304
|
-
else {
|
|
1305
|
-
setValueByPath(toObject, ['cachedContents'], fromCachedContents);
|
|
1222
|
+
});
|
|
1306
1223
|
}
|
|
1224
|
+
setValueByPath(toObject, ['cachedContents'], transformedList);
|
|
1307
1225
|
}
|
|
1308
1226
|
return toObject;
|
|
1309
1227
|
}
|
|
@@ -1505,17 +1423,6 @@ exports.Language = void 0;
|
|
|
1505
1423
|
Language["LANGUAGE_UNSPECIFIED"] = "LANGUAGE_UNSPECIFIED";
|
|
1506
1424
|
Language["PYTHON"] = "PYTHON";
|
|
1507
1425
|
})(exports.Language || (exports.Language = {}));
|
|
1508
|
-
/** Optional. The type of the data. */
|
|
1509
|
-
exports.Type = void 0;
|
|
1510
|
-
(function (Type) {
|
|
1511
|
-
Type["TYPE_UNSPECIFIED"] = "TYPE_UNSPECIFIED";
|
|
1512
|
-
Type["STRING"] = "STRING";
|
|
1513
|
-
Type["NUMBER"] = "NUMBER";
|
|
1514
|
-
Type["INTEGER"] = "INTEGER";
|
|
1515
|
-
Type["BOOLEAN"] = "BOOLEAN";
|
|
1516
|
-
Type["ARRAY"] = "ARRAY";
|
|
1517
|
-
Type["OBJECT"] = "OBJECT";
|
|
1518
|
-
})(exports.Type || (exports.Type = {}));
|
|
1519
1426
|
/** Required. Harm category. */
|
|
1520
1427
|
exports.HarmCategory = void 0;
|
|
1521
1428
|
(function (HarmCategory) {
|
|
@@ -1549,6 +1456,17 @@ exports.Mode = void 0;
|
|
|
1549
1456
|
Mode["MODE_UNSPECIFIED"] = "MODE_UNSPECIFIED";
|
|
1550
1457
|
Mode["MODE_DYNAMIC"] = "MODE_DYNAMIC";
|
|
1551
1458
|
})(exports.Mode || (exports.Mode = {}));
|
|
1459
|
+
/** Optional. The type of the data. */
|
|
1460
|
+
exports.Type = void 0;
|
|
1461
|
+
(function (Type) {
|
|
1462
|
+
Type["TYPE_UNSPECIFIED"] = "TYPE_UNSPECIFIED";
|
|
1463
|
+
Type["STRING"] = "STRING";
|
|
1464
|
+
Type["NUMBER"] = "NUMBER";
|
|
1465
|
+
Type["INTEGER"] = "INTEGER";
|
|
1466
|
+
Type["BOOLEAN"] = "BOOLEAN";
|
|
1467
|
+
Type["ARRAY"] = "ARRAY";
|
|
1468
|
+
Type["OBJECT"] = "OBJECT";
|
|
1469
|
+
})(exports.Type || (exports.Type = {}));
|
|
1552
1470
|
/** Output only. The reason why the model stopped generating tokens.
|
|
1553
1471
|
|
|
1554
1472
|
If empty, the model has not stopped generating the tokens.
|
|
@@ -1560,6 +1478,7 @@ exports.FinishReason = void 0;
|
|
|
1560
1478
|
FinishReason["MAX_TOKENS"] = "MAX_TOKENS";
|
|
1561
1479
|
FinishReason["SAFETY"] = "SAFETY";
|
|
1562
1480
|
FinishReason["RECITATION"] = "RECITATION";
|
|
1481
|
+
FinishReason["LANGUAGE"] = "LANGUAGE";
|
|
1563
1482
|
FinishReason["OTHER"] = "OTHER";
|
|
1564
1483
|
FinishReason["BLOCKLIST"] = "BLOCKLIST";
|
|
1565
1484
|
FinishReason["PROHIBITED_CONTENT"] = "PROHIBITED_CONTENT";
|
|
@@ -1617,6 +1536,33 @@ exports.MediaResolution = void 0;
|
|
|
1617
1536
|
MediaResolution["MEDIA_RESOLUTION_MEDIUM"] = "MEDIA_RESOLUTION_MEDIUM";
|
|
1618
1537
|
MediaResolution["MEDIA_RESOLUTION_HIGH"] = "MEDIA_RESOLUTION_HIGH";
|
|
1619
1538
|
})(exports.MediaResolution || (exports.MediaResolution = {}));
|
|
1539
|
+
/** Output only. The detailed state of the job. */
|
|
1540
|
+
exports.JobState = void 0;
|
|
1541
|
+
(function (JobState) {
|
|
1542
|
+
JobState["JOB_STATE_UNSPECIFIED"] = "JOB_STATE_UNSPECIFIED";
|
|
1543
|
+
JobState["JOB_STATE_QUEUED"] = "JOB_STATE_QUEUED";
|
|
1544
|
+
JobState["JOB_STATE_PENDING"] = "JOB_STATE_PENDING";
|
|
1545
|
+
JobState["JOB_STATE_RUNNING"] = "JOB_STATE_RUNNING";
|
|
1546
|
+
JobState["JOB_STATE_SUCCEEDED"] = "JOB_STATE_SUCCEEDED";
|
|
1547
|
+
JobState["JOB_STATE_FAILED"] = "JOB_STATE_FAILED";
|
|
1548
|
+
JobState["JOB_STATE_CANCELLING"] = "JOB_STATE_CANCELLING";
|
|
1549
|
+
JobState["JOB_STATE_CANCELLED"] = "JOB_STATE_CANCELLED";
|
|
1550
|
+
JobState["JOB_STATE_PAUSED"] = "JOB_STATE_PAUSED";
|
|
1551
|
+
JobState["JOB_STATE_EXPIRED"] = "JOB_STATE_EXPIRED";
|
|
1552
|
+
JobState["JOB_STATE_UPDATING"] = "JOB_STATE_UPDATING";
|
|
1553
|
+
JobState["JOB_STATE_PARTIALLY_SUCCEEDED"] = "JOB_STATE_PARTIALLY_SUCCEEDED";
|
|
1554
|
+
})(exports.JobState || (exports.JobState = {}));
|
|
1555
|
+
/** Optional. Adapter size for tuning. */
|
|
1556
|
+
exports.AdapterSize = void 0;
|
|
1557
|
+
(function (AdapterSize) {
|
|
1558
|
+
AdapterSize["ADAPTER_SIZE_UNSPECIFIED"] = "ADAPTER_SIZE_UNSPECIFIED";
|
|
1559
|
+
AdapterSize["ADAPTER_SIZE_ONE"] = "ADAPTER_SIZE_ONE";
|
|
1560
|
+
AdapterSize["ADAPTER_SIZE_TWO"] = "ADAPTER_SIZE_TWO";
|
|
1561
|
+
AdapterSize["ADAPTER_SIZE_FOUR"] = "ADAPTER_SIZE_FOUR";
|
|
1562
|
+
AdapterSize["ADAPTER_SIZE_EIGHT"] = "ADAPTER_SIZE_EIGHT";
|
|
1563
|
+
AdapterSize["ADAPTER_SIZE_SIXTEEN"] = "ADAPTER_SIZE_SIXTEEN";
|
|
1564
|
+
AdapterSize["ADAPTER_SIZE_THIRTY_TWO"] = "ADAPTER_SIZE_THIRTY_TWO";
|
|
1565
|
+
})(exports.AdapterSize || (exports.AdapterSize = {}));
|
|
1620
1566
|
/** Options for feature selection preference. */
|
|
1621
1567
|
exports.FeatureSelectionPreference = void 0;
|
|
1622
1568
|
(function (FeatureSelectionPreference) {
|
|
@@ -1942,6 +1888,42 @@ class GenerateContentResponse {
|
|
|
1942
1888
|
// part.text === '' is different from part.text is null
|
|
1943
1889
|
return anyTextPartText ? text : undefined;
|
|
1944
1890
|
}
|
|
1891
|
+
/**
|
|
1892
|
+
* Returns the concatenation of all inline data parts from the first candidate
|
|
1893
|
+
* in the response.
|
|
1894
|
+
*
|
|
1895
|
+
* @remarks
|
|
1896
|
+
* If there are multiple candidates in the response, the inline data from the
|
|
1897
|
+
* first one will be returned. If there are non-inline data parts in the
|
|
1898
|
+
* response, the concatenation of all inline data parts will be returned, and
|
|
1899
|
+
* a warning will be logged.
|
|
1900
|
+
*/
|
|
1901
|
+
get data() {
|
|
1902
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1903
|
+
if (((_d = (_c = (_b = (_a = this.candidates) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.content) === null || _c === void 0 ? void 0 : _c.parts) === null || _d === void 0 ? void 0 : _d.length) === 0) {
|
|
1904
|
+
return undefined;
|
|
1905
|
+
}
|
|
1906
|
+
if (this.candidates && this.candidates.length > 1) {
|
|
1907
|
+
console.warn('there are multiple candidates in the response, returning data from the first one.');
|
|
1908
|
+
}
|
|
1909
|
+
let data = '';
|
|
1910
|
+
const nonDataParts = [];
|
|
1911
|
+
for (const part of (_h = (_g = (_f = (_e = this.candidates) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.content) === null || _g === void 0 ? void 0 : _g.parts) !== null && _h !== void 0 ? _h : []) {
|
|
1912
|
+
for (const [fieldName, fieldValue] of Object.entries(part)) {
|
|
1913
|
+
if (fieldName !== 'inlineData' &&
|
|
1914
|
+
(fieldValue !== null || fieldValue !== undefined)) {
|
|
1915
|
+
nonDataParts.push(fieldName);
|
|
1916
|
+
}
|
|
1917
|
+
}
|
|
1918
|
+
if (part.inlineData && typeof part.inlineData.data === 'string') {
|
|
1919
|
+
data += atob(part.inlineData.data);
|
|
1920
|
+
}
|
|
1921
|
+
}
|
|
1922
|
+
if (nonDataParts.length > 0) {
|
|
1923
|
+
console.warn(`there are non-data parts ${nonDataParts} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`);
|
|
1924
|
+
}
|
|
1925
|
+
return data.length > 0 ? btoa(data) : undefined;
|
|
1926
|
+
}
|
|
1945
1927
|
/**
|
|
1946
1928
|
* Returns the function calls from the first candidate in the response.
|
|
1947
1929
|
*
|
|
@@ -2081,6 +2063,8 @@ class EmbedContentResponse {
|
|
|
2081
2063
|
/** The output images response. */
|
|
2082
2064
|
class GenerateImagesResponse {
|
|
2083
2065
|
}
|
|
2066
|
+
class DeleteModelResponse {
|
|
2067
|
+
}
|
|
2084
2068
|
/** Response for counting tokens. */
|
|
2085
2069
|
class CountTokensResponse {
|
|
2086
2070
|
}
|
|
@@ -2090,6 +2074,9 @@ class ComputeTokensResponse {
|
|
|
2090
2074
|
/** Response with generated videos. */
|
|
2091
2075
|
class GenerateVideosResponse {
|
|
2092
2076
|
}
|
|
2077
|
+
/** Response for the list tuning jobs method. */
|
|
2078
|
+
class ListTuningJobsResponse {
|
|
2079
|
+
}
|
|
2093
2080
|
/** Empty response for caches.delete method. */
|
|
2094
2081
|
class DeleteCachedContentResponse {
|
|
2095
2082
|
}
|
|
@@ -2186,7 +2173,7 @@ class Caches extends BaseModule {
|
|
|
2186
2173
|
* ```ts
|
|
2187
2174
|
* const contents = ...; // Initialize the content to cache.
|
|
2188
2175
|
* const response = await ai.caches.create({
|
|
2189
|
-
* model: 'gemini-
|
|
2176
|
+
* model: 'gemini-2.0-flash-001',
|
|
2190
2177
|
* config: {
|
|
2191
2178
|
* 'contents': contents,
|
|
2192
2179
|
* 'displayName': 'test cache',
|
|
@@ -2197,7 +2184,7 @@ class Caches extends BaseModule {
|
|
|
2197
2184
|
* ```
|
|
2198
2185
|
*/
|
|
2199
2186
|
async create(params) {
|
|
2200
|
-
var _a, _b;
|
|
2187
|
+
var _a, _b, _c, _d;
|
|
2201
2188
|
let response;
|
|
2202
2189
|
let path = '';
|
|
2203
2190
|
let queryParams = {};
|
|
@@ -2215,6 +2202,7 @@ class Caches extends BaseModule {
|
|
|
2215
2202
|
body: JSON.stringify(body),
|
|
2216
2203
|
httpMethod: 'POST',
|
|
2217
2204
|
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
2205
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
2218
2206
|
})
|
|
2219
2207
|
.then((httpResponse) => {
|
|
2220
2208
|
return httpResponse.json();
|
|
@@ -2237,7 +2225,8 @@ class Caches extends BaseModule {
|
|
|
2237
2225
|
queryParams: queryParams,
|
|
2238
2226
|
body: JSON.stringify(body),
|
|
2239
2227
|
httpMethod: 'POST',
|
|
2240
|
-
httpOptions: (
|
|
2228
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
2229
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
2241
2230
|
})
|
|
2242
2231
|
.then((httpResponse) => {
|
|
2243
2232
|
return httpResponse.json();
|
|
@@ -2256,11 +2245,11 @@ class Caches extends BaseModule {
|
|
|
2256
2245
|
*
|
|
2257
2246
|
* @example
|
|
2258
2247
|
* ```ts
|
|
2259
|
-
* await ai.caches.get({name: '
|
|
2248
|
+
* await ai.caches.get({name: '...'}); // The server-generated resource name.
|
|
2260
2249
|
* ```
|
|
2261
2250
|
*/
|
|
2262
2251
|
async get(params) {
|
|
2263
|
-
var _a, _b;
|
|
2252
|
+
var _a, _b, _c, _d;
|
|
2264
2253
|
let response;
|
|
2265
2254
|
let path = '';
|
|
2266
2255
|
let queryParams = {};
|
|
@@ -2278,6 +2267,7 @@ class Caches extends BaseModule {
|
|
|
2278
2267
|
body: JSON.stringify(body),
|
|
2279
2268
|
httpMethod: 'GET',
|
|
2280
2269
|
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
2270
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
2281
2271
|
})
|
|
2282
2272
|
.then((httpResponse) => {
|
|
2283
2273
|
return httpResponse.json();
|
|
@@ -2300,7 +2290,8 @@ class Caches extends BaseModule {
|
|
|
2300
2290
|
queryParams: queryParams,
|
|
2301
2291
|
body: JSON.stringify(body),
|
|
2302
2292
|
httpMethod: 'GET',
|
|
2303
|
-
httpOptions: (
|
|
2293
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
2294
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
2304
2295
|
})
|
|
2305
2296
|
.then((httpResponse) => {
|
|
2306
2297
|
return httpResponse.json();
|
|
@@ -2319,11 +2310,11 @@ class Caches extends BaseModule {
|
|
|
2319
2310
|
*
|
|
2320
2311
|
* @example
|
|
2321
2312
|
* ```ts
|
|
2322
|
-
* await ai.caches.delete({name: '
|
|
2313
|
+
* await ai.caches.delete({name: '...'}); // The server-generated resource name.
|
|
2323
2314
|
* ```
|
|
2324
2315
|
*/
|
|
2325
2316
|
async delete(params) {
|
|
2326
|
-
var _a, _b;
|
|
2317
|
+
var _a, _b, _c, _d;
|
|
2327
2318
|
let response;
|
|
2328
2319
|
let path = '';
|
|
2329
2320
|
let queryParams = {};
|
|
@@ -2341,6 +2332,7 @@ class Caches extends BaseModule {
|
|
|
2341
2332
|
body: JSON.stringify(body),
|
|
2342
2333
|
httpMethod: 'DELETE',
|
|
2343
2334
|
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
2335
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
2344
2336
|
})
|
|
2345
2337
|
.then((httpResponse) => {
|
|
2346
2338
|
return httpResponse.json();
|
|
@@ -2365,7 +2357,8 @@ class Caches extends BaseModule {
|
|
|
2365
2357
|
queryParams: queryParams,
|
|
2366
2358
|
body: JSON.stringify(body),
|
|
2367
2359
|
httpMethod: 'DELETE',
|
|
2368
|
-
httpOptions: (
|
|
2360
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
2361
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
2369
2362
|
})
|
|
2370
2363
|
.then((httpResponse) => {
|
|
2371
2364
|
return httpResponse.json();
|
|
@@ -2387,13 +2380,13 @@ class Caches extends BaseModule {
|
|
|
2387
2380
|
* @example
|
|
2388
2381
|
* ```ts
|
|
2389
2382
|
* const response = await ai.caches.update({
|
|
2390
|
-
* name: '
|
|
2383
|
+
* name: '...', // The server-generated resource name.
|
|
2391
2384
|
* config: {'ttl': '7600s'}
|
|
2392
2385
|
* });
|
|
2393
2386
|
* ```
|
|
2394
2387
|
*/
|
|
2395
2388
|
async update(params) {
|
|
2396
|
-
var _a, _b;
|
|
2389
|
+
var _a, _b, _c, _d;
|
|
2397
2390
|
let response;
|
|
2398
2391
|
let path = '';
|
|
2399
2392
|
let queryParams = {};
|
|
@@ -2411,6 +2404,7 @@ class Caches extends BaseModule {
|
|
|
2411
2404
|
body: JSON.stringify(body),
|
|
2412
2405
|
httpMethod: 'PATCH',
|
|
2413
2406
|
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
2407
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
2414
2408
|
})
|
|
2415
2409
|
.then((httpResponse) => {
|
|
2416
2410
|
return httpResponse.json();
|
|
@@ -2433,7 +2427,8 @@ class Caches extends BaseModule {
|
|
|
2433
2427
|
queryParams: queryParams,
|
|
2434
2428
|
body: JSON.stringify(body),
|
|
2435
2429
|
httpMethod: 'PATCH',
|
|
2436
|
-
httpOptions: (
|
|
2430
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
2431
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
2437
2432
|
})
|
|
2438
2433
|
.then((httpResponse) => {
|
|
2439
2434
|
return httpResponse.json();
|
|
@@ -2445,7 +2440,7 @@ class Caches extends BaseModule {
|
|
|
2445
2440
|
}
|
|
2446
2441
|
}
|
|
2447
2442
|
async listInternal(params) {
|
|
2448
|
-
var _a, _b;
|
|
2443
|
+
var _a, _b, _c, _d;
|
|
2449
2444
|
let response;
|
|
2450
2445
|
let path = '';
|
|
2451
2446
|
let queryParams = {};
|
|
@@ -2463,6 +2458,7 @@ class Caches extends BaseModule {
|
|
|
2463
2458
|
body: JSON.stringify(body),
|
|
2464
2459
|
httpMethod: 'GET',
|
|
2465
2460
|
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
2461
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
2466
2462
|
})
|
|
2467
2463
|
.then((httpResponse) => {
|
|
2468
2464
|
return httpResponse.json();
|
|
@@ -2487,7 +2483,8 @@ class Caches extends BaseModule {
|
|
|
2487
2483
|
queryParams: queryParams,
|
|
2488
2484
|
body: JSON.stringify(body),
|
|
2489
2485
|
httpMethod: 'GET',
|
|
2490
|
-
httpOptions: (
|
|
2486
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
2487
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
2491
2488
|
})
|
|
2492
2489
|
.then((httpResponse) => {
|
|
2493
2490
|
return httpResponse.json();
|
|
@@ -2781,7 +2778,12 @@ class Chat {
|
|
|
2781
2778
|
contents: this.getHistory(true).concat(inputContent),
|
|
2782
2779
|
config: (_a = params.config) !== null && _a !== void 0 ? _a : this.config,
|
|
2783
2780
|
});
|
|
2784
|
-
|
|
2781
|
+
// Resolve the internal tracking of send completion promise - `sendPromise`
|
|
2782
|
+
// for both success and failure response. The actual failure is still
|
|
2783
|
+
// propagated by the `await streamResponse`.
|
|
2784
|
+
this.sendPromise = streamResponse
|
|
2785
|
+
.then(() => undefined)
|
|
2786
|
+
.catch(() => undefined);
|
|
2785
2787
|
const response = await streamResponse;
|
|
2786
2788
|
const result = this.processStreamResponse(response, inputContent);
|
|
2787
2789
|
return result;
|
|
@@ -3091,14 +3093,13 @@ function listFilesResponseFromMldev(apiClient, fromObject) {
|
|
|
3091
3093
|
}
|
|
3092
3094
|
const fromFiles = getValueByPath(fromObject, ['files']);
|
|
3093
3095
|
if (fromFiles != null) {
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
+
let transformedList = fromFiles;
|
|
3097
|
+
if (Array.isArray(transformedList)) {
|
|
3098
|
+
transformedList = transformedList.map((item) => {
|
|
3096
3099
|
return fileFromMldev(apiClient, item);
|
|
3097
|
-
})
|
|
3098
|
-
}
|
|
3099
|
-
else {
|
|
3100
|
-
setValueByPath(toObject, ['files'], fromFiles);
|
|
3100
|
+
});
|
|
3101
3101
|
}
|
|
3102
|
+
setValueByPath(toObject, ['files'], transformedList);
|
|
3102
3103
|
}
|
|
3103
3104
|
return toObject;
|
|
3104
3105
|
}
|
|
@@ -3196,7 +3197,7 @@ class Files extends BaseModule {
|
|
|
3196
3197
|
});
|
|
3197
3198
|
}
|
|
3198
3199
|
async listInternal(params) {
|
|
3199
|
-
var _a;
|
|
3200
|
+
var _a, _b;
|
|
3200
3201
|
let response;
|
|
3201
3202
|
let path = '';
|
|
3202
3203
|
let queryParams = {};
|
|
@@ -3217,6 +3218,7 @@ class Files extends BaseModule {
|
|
|
3217
3218
|
body: JSON.stringify(body),
|
|
3218
3219
|
httpMethod: 'GET',
|
|
3219
3220
|
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
3221
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
3220
3222
|
})
|
|
3221
3223
|
.then((httpResponse) => {
|
|
3222
3224
|
return httpResponse.json();
|
|
@@ -3230,7 +3232,7 @@ class Files extends BaseModule {
|
|
|
3230
3232
|
}
|
|
3231
3233
|
}
|
|
3232
3234
|
async createInternal(params) {
|
|
3233
|
-
var _a;
|
|
3235
|
+
var _a, _b;
|
|
3234
3236
|
let response;
|
|
3235
3237
|
let path = '';
|
|
3236
3238
|
let queryParams = {};
|
|
@@ -3251,6 +3253,7 @@ class Files extends BaseModule {
|
|
|
3251
3253
|
body: JSON.stringify(body),
|
|
3252
3254
|
httpMethod: 'POST',
|
|
3253
3255
|
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
3256
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
3254
3257
|
})
|
|
3255
3258
|
.then((httpResponse) => {
|
|
3256
3259
|
return httpResponse.json();
|
|
@@ -3279,7 +3282,7 @@ class Files extends BaseModule {
|
|
|
3279
3282
|
* ```
|
|
3280
3283
|
*/
|
|
3281
3284
|
async get(params) {
|
|
3282
|
-
var _a;
|
|
3285
|
+
var _a, _b;
|
|
3283
3286
|
let response;
|
|
3284
3287
|
let path = '';
|
|
3285
3288
|
let queryParams = {};
|
|
@@ -3300,6 +3303,7 @@ class Files extends BaseModule {
|
|
|
3300
3303
|
body: JSON.stringify(body),
|
|
3301
3304
|
httpMethod: 'GET',
|
|
3302
3305
|
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
3306
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
3303
3307
|
})
|
|
3304
3308
|
.then((httpResponse) => {
|
|
3305
3309
|
return httpResponse.json();
|
|
@@ -3324,7 +3328,7 @@ class Files extends BaseModule {
|
|
|
3324
3328
|
* ```
|
|
3325
3329
|
*/
|
|
3326
3330
|
async delete(params) {
|
|
3327
|
-
var _a;
|
|
3331
|
+
var _a, _b;
|
|
3328
3332
|
let response;
|
|
3329
3333
|
let path = '';
|
|
3330
3334
|
let queryParams = {};
|
|
@@ -3345,6 +3349,7 @@ class Files extends BaseModule {
|
|
|
3345
3349
|
body: JSON.stringify(body),
|
|
3346
3350
|
httpMethod: 'DELETE',
|
|
3347
3351
|
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
3352
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
3348
3353
|
})
|
|
3349
3354
|
.then((httpResponse) => {
|
|
3350
3355
|
return httpResponse.json();
|
|
@@ -3461,14 +3466,13 @@ function contentToMldev$1(apiClient, fromObject) {
|
|
|
3461
3466
|
const toObject = {};
|
|
3462
3467
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
3463
3468
|
if (fromParts != null) {
|
|
3464
|
-
|
|
3465
|
-
|
|
3469
|
+
let transformedList = fromParts;
|
|
3470
|
+
if (Array.isArray(transformedList)) {
|
|
3471
|
+
transformedList = transformedList.map((item) => {
|
|
3466
3472
|
return partToMldev$1(apiClient, item);
|
|
3467
|
-
})
|
|
3468
|
-
}
|
|
3469
|
-
else {
|
|
3470
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
3473
|
+
});
|
|
3471
3474
|
}
|
|
3475
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
3472
3476
|
}
|
|
3473
3477
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
3474
3478
|
if (fromRole != null) {
|
|
@@ -3480,14 +3484,13 @@ function contentToVertex$1(apiClient, fromObject) {
|
|
|
3480
3484
|
const toObject = {};
|
|
3481
3485
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
3482
3486
|
if (fromParts != null) {
|
|
3483
|
-
|
|
3484
|
-
|
|
3487
|
+
let transformedList = fromParts;
|
|
3488
|
+
if (Array.isArray(transformedList)) {
|
|
3489
|
+
transformedList = transformedList.map((item) => {
|
|
3485
3490
|
return partToVertex$1(apiClient, item);
|
|
3486
|
-
})
|
|
3487
|
-
}
|
|
3488
|
-
else {
|
|
3489
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
3491
|
+
});
|
|
3490
3492
|
}
|
|
3493
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
3491
3494
|
}
|
|
3492
3495
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
3493
3496
|
if (fromRole != null) {
|
|
@@ -3495,162 +3498,25 @@ function contentToVertex$1(apiClient, fromObject) {
|
|
|
3495
3498
|
}
|
|
3496
3499
|
return toObject;
|
|
3497
3500
|
}
|
|
3498
|
-
function
|
|
3501
|
+
function googleSearchToMldev$1() {
|
|
3499
3502
|
const toObject = {};
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
}
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
}
|
|
3508
|
-
const
|
|
3509
|
-
if (
|
|
3510
|
-
setValueByPath(toObject, ['
|
|
3511
|
-
}
|
|
3512
|
-
const fromMaxLength = getValueByPath(fromObject, ['maxLength']);
|
|
3513
|
-
if (fromMaxLength != null) {
|
|
3514
|
-
setValueByPath(toObject, ['maxLength'], fromMaxLength);
|
|
3515
|
-
}
|
|
3516
|
-
const fromMinLength = getValueByPath(fromObject, ['minLength']);
|
|
3517
|
-
if (fromMinLength != null) {
|
|
3518
|
-
setValueByPath(toObject, ['minLength'], fromMinLength);
|
|
3519
|
-
}
|
|
3520
|
-
const fromMinProperties = getValueByPath(fromObject, [
|
|
3521
|
-
'minProperties',
|
|
3522
|
-
]);
|
|
3523
|
-
if (fromMinProperties != null) {
|
|
3524
|
-
setValueByPath(toObject, ['minProperties'], fromMinProperties);
|
|
3503
|
+
return toObject;
|
|
3504
|
+
}
|
|
3505
|
+
function googleSearchToVertex$1() {
|
|
3506
|
+
const toObject = {};
|
|
3507
|
+
return toObject;
|
|
3508
|
+
}
|
|
3509
|
+
function dynamicRetrievalConfigToMldev$1(apiClient, fromObject) {
|
|
3510
|
+
const toObject = {};
|
|
3511
|
+
const fromMode = getValueByPath(fromObject, ['mode']);
|
|
3512
|
+
if (fromMode != null) {
|
|
3513
|
+
setValueByPath(toObject, ['mode'], fromMode);
|
|
3525
3514
|
}
|
|
3526
|
-
const
|
|
3527
|
-
'
|
|
3515
|
+
const fromDynamicThreshold = getValueByPath(fromObject, [
|
|
3516
|
+
'dynamicThreshold',
|
|
3528
3517
|
]);
|
|
3529
|
-
if (
|
|
3530
|
-
setValueByPath(toObject, ['
|
|
3531
|
-
}
|
|
3532
|
-
const fromAnyOf = getValueByPath(fromObject, ['anyOf']);
|
|
3533
|
-
if (fromAnyOf != null) {
|
|
3534
|
-
setValueByPath(toObject, ['anyOf'], fromAnyOf);
|
|
3535
|
-
}
|
|
3536
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
3537
|
-
if (fromDescription != null) {
|
|
3538
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
3539
|
-
}
|
|
3540
|
-
const fromEnum = getValueByPath(fromObject, ['enum']);
|
|
3541
|
-
if (fromEnum != null) {
|
|
3542
|
-
setValueByPath(toObject, ['enum'], fromEnum);
|
|
3543
|
-
}
|
|
3544
|
-
const fromFormat = getValueByPath(fromObject, ['format']);
|
|
3545
|
-
if (fromFormat != null) {
|
|
3546
|
-
setValueByPath(toObject, ['format'], fromFormat);
|
|
3547
|
-
}
|
|
3548
|
-
const fromItems = getValueByPath(fromObject, ['items']);
|
|
3549
|
-
if (fromItems != null) {
|
|
3550
|
-
setValueByPath(toObject, ['items'], fromItems);
|
|
3551
|
-
}
|
|
3552
|
-
const fromMaxItems = getValueByPath(fromObject, ['maxItems']);
|
|
3553
|
-
if (fromMaxItems != null) {
|
|
3554
|
-
setValueByPath(toObject, ['maxItems'], fromMaxItems);
|
|
3555
|
-
}
|
|
3556
|
-
const fromMaximum = getValueByPath(fromObject, ['maximum']);
|
|
3557
|
-
if (fromMaximum != null) {
|
|
3558
|
-
setValueByPath(toObject, ['maximum'], fromMaximum);
|
|
3559
|
-
}
|
|
3560
|
-
const fromMinItems = getValueByPath(fromObject, ['minItems']);
|
|
3561
|
-
if (fromMinItems != null) {
|
|
3562
|
-
setValueByPath(toObject, ['minItems'], fromMinItems);
|
|
3563
|
-
}
|
|
3564
|
-
const fromMinimum = getValueByPath(fromObject, ['minimum']);
|
|
3565
|
-
if (fromMinimum != null) {
|
|
3566
|
-
setValueByPath(toObject, ['minimum'], fromMinimum);
|
|
3567
|
-
}
|
|
3568
|
-
const fromNullable = getValueByPath(fromObject, ['nullable']);
|
|
3569
|
-
if (fromNullable != null) {
|
|
3570
|
-
setValueByPath(toObject, ['nullable'], fromNullable);
|
|
3571
|
-
}
|
|
3572
|
-
const fromProperties = getValueByPath(fromObject, ['properties']);
|
|
3573
|
-
if (fromProperties != null) {
|
|
3574
|
-
setValueByPath(toObject, ['properties'], fromProperties);
|
|
3575
|
-
}
|
|
3576
|
-
const fromPropertyOrdering = getValueByPath(fromObject, [
|
|
3577
|
-
'propertyOrdering',
|
|
3578
|
-
]);
|
|
3579
|
-
if (fromPropertyOrdering != null) {
|
|
3580
|
-
setValueByPath(toObject, ['propertyOrdering'], fromPropertyOrdering);
|
|
3581
|
-
}
|
|
3582
|
-
const fromRequired = getValueByPath(fromObject, ['required']);
|
|
3583
|
-
if (fromRequired != null) {
|
|
3584
|
-
setValueByPath(toObject, ['required'], fromRequired);
|
|
3585
|
-
}
|
|
3586
|
-
const fromTitle = getValueByPath(fromObject, ['title']);
|
|
3587
|
-
if (fromTitle != null) {
|
|
3588
|
-
setValueByPath(toObject, ['title'], fromTitle);
|
|
3589
|
-
}
|
|
3590
|
-
const fromType = getValueByPath(fromObject, ['type']);
|
|
3591
|
-
if (fromType != null) {
|
|
3592
|
-
setValueByPath(toObject, ['type'], fromType);
|
|
3593
|
-
}
|
|
3594
|
-
return toObject;
|
|
3595
|
-
}
|
|
3596
|
-
function functionDeclarationToMldev$1(apiClient, fromObject) {
|
|
3597
|
-
const toObject = {};
|
|
3598
|
-
if (getValueByPath(fromObject, ['response']) !== undefined) {
|
|
3599
|
-
throw new Error('response parameter is not supported in Gemini API.');
|
|
3600
|
-
}
|
|
3601
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
3602
|
-
if (fromDescription != null) {
|
|
3603
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
3604
|
-
}
|
|
3605
|
-
const fromName = getValueByPath(fromObject, ['name']);
|
|
3606
|
-
if (fromName != null) {
|
|
3607
|
-
setValueByPath(toObject, ['name'], fromName);
|
|
3608
|
-
}
|
|
3609
|
-
const fromParameters = getValueByPath(fromObject, ['parameters']);
|
|
3610
|
-
if (fromParameters != null) {
|
|
3611
|
-
setValueByPath(toObject, ['parameters'], fromParameters);
|
|
3612
|
-
}
|
|
3613
|
-
return toObject;
|
|
3614
|
-
}
|
|
3615
|
-
function functionDeclarationToVertex$1(apiClient, fromObject) {
|
|
3616
|
-
const toObject = {};
|
|
3617
|
-
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
3618
|
-
if (fromResponse != null) {
|
|
3619
|
-
setValueByPath(toObject, ['response'], schemaToVertex$1(apiClient, fromResponse));
|
|
3620
|
-
}
|
|
3621
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
3622
|
-
if (fromDescription != null) {
|
|
3623
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
3624
|
-
}
|
|
3625
|
-
const fromName = getValueByPath(fromObject, ['name']);
|
|
3626
|
-
if (fromName != null) {
|
|
3627
|
-
setValueByPath(toObject, ['name'], fromName);
|
|
3628
|
-
}
|
|
3629
|
-
const fromParameters = getValueByPath(fromObject, ['parameters']);
|
|
3630
|
-
if (fromParameters != null) {
|
|
3631
|
-
setValueByPath(toObject, ['parameters'], fromParameters);
|
|
3632
|
-
}
|
|
3633
|
-
return toObject;
|
|
3634
|
-
}
|
|
3635
|
-
function googleSearchToMldev$1() {
|
|
3636
|
-
const toObject = {};
|
|
3637
|
-
return toObject;
|
|
3638
|
-
}
|
|
3639
|
-
function googleSearchToVertex$1() {
|
|
3640
|
-
const toObject = {};
|
|
3641
|
-
return toObject;
|
|
3642
|
-
}
|
|
3643
|
-
function dynamicRetrievalConfigToMldev$1(apiClient, fromObject) {
|
|
3644
|
-
const toObject = {};
|
|
3645
|
-
const fromMode = getValueByPath(fromObject, ['mode']);
|
|
3646
|
-
if (fromMode != null) {
|
|
3647
|
-
setValueByPath(toObject, ['mode'], fromMode);
|
|
3648
|
-
}
|
|
3649
|
-
const fromDynamicThreshold = getValueByPath(fromObject, [
|
|
3650
|
-
'dynamicThreshold',
|
|
3651
|
-
]);
|
|
3652
|
-
if (fromDynamicThreshold != null) {
|
|
3653
|
-
setValueByPath(toObject, ['dynamicThreshold'], fromDynamicThreshold);
|
|
3518
|
+
if (fromDynamicThreshold != null) {
|
|
3519
|
+
setValueByPath(toObject, ['dynamicThreshold'], fromDynamicThreshold);
|
|
3654
3520
|
}
|
|
3655
3521
|
return toObject;
|
|
3656
3522
|
}
|
|
@@ -3690,19 +3556,6 @@ function googleSearchRetrievalToVertex$1(apiClient, fromObject) {
|
|
|
3690
3556
|
}
|
|
3691
3557
|
function toolToMldev$1(apiClient, fromObject) {
|
|
3692
3558
|
const toObject = {};
|
|
3693
|
-
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
3694
|
-
'functionDeclarations',
|
|
3695
|
-
]);
|
|
3696
|
-
if (fromFunctionDeclarations != null) {
|
|
3697
|
-
if (Array.isArray(fromFunctionDeclarations)) {
|
|
3698
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations.map((item) => {
|
|
3699
|
-
return functionDeclarationToMldev$1(apiClient, item);
|
|
3700
|
-
}));
|
|
3701
|
-
}
|
|
3702
|
-
else {
|
|
3703
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
3704
|
-
}
|
|
3705
|
-
}
|
|
3706
3559
|
if (getValueByPath(fromObject, ['retrieval']) !== undefined) {
|
|
3707
3560
|
throw new Error('retrieval parameter is not supported in Gemini API.');
|
|
3708
3561
|
}
|
|
@@ -3722,23 +3575,16 @@ function toolToMldev$1(apiClient, fromObject) {
|
|
|
3722
3575
|
if (fromCodeExecution != null) {
|
|
3723
3576
|
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
3724
3577
|
}
|
|
3725
|
-
return toObject;
|
|
3726
|
-
}
|
|
3727
|
-
function toolToVertex$1(apiClient, fromObject) {
|
|
3728
|
-
const toObject = {};
|
|
3729
3578
|
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
3730
3579
|
'functionDeclarations',
|
|
3731
3580
|
]);
|
|
3732
3581
|
if (fromFunctionDeclarations != null) {
|
|
3733
|
-
|
|
3734
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations.map((item) => {
|
|
3735
|
-
return functionDeclarationToVertex$1(apiClient, item);
|
|
3736
|
-
}));
|
|
3737
|
-
}
|
|
3738
|
-
else {
|
|
3739
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
3740
|
-
}
|
|
3582
|
+
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
3741
3583
|
}
|
|
3584
|
+
return toObject;
|
|
3585
|
+
}
|
|
3586
|
+
function toolToVertex$1(apiClient, fromObject) {
|
|
3587
|
+
const toObject = {};
|
|
3742
3588
|
const fromRetrieval = getValueByPath(fromObject, ['retrieval']);
|
|
3743
3589
|
if (fromRetrieval != null) {
|
|
3744
3590
|
setValueByPath(toObject, ['retrieval'], fromRetrieval);
|
|
@@ -3759,6 +3605,12 @@ function toolToVertex$1(apiClient, fromObject) {
|
|
|
3759
3605
|
if (fromCodeExecution != null) {
|
|
3760
3606
|
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
3761
3607
|
}
|
|
3608
|
+
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
3609
|
+
'functionDeclarations',
|
|
3610
|
+
]);
|
|
3611
|
+
if (fromFunctionDeclarations != null) {
|
|
3612
|
+
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
3613
|
+
}
|
|
3762
3614
|
return toObject;
|
|
3763
3615
|
}
|
|
3764
3616
|
function sessionResumptionConfigToMldev(apiClient, fromObject) {
|
|
@@ -3998,14 +3850,13 @@ function liveConnectConfigToMldev(apiClient, fromObject, parentObject) {
|
|
|
3998
3850
|
}
|
|
3999
3851
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
4000
3852
|
if (parentObject !== undefined && fromTools != null) {
|
|
4001
|
-
|
|
4002
|
-
|
|
3853
|
+
let transformedList = tTools(apiClient, fromTools);
|
|
3854
|
+
if (Array.isArray(transformedList)) {
|
|
3855
|
+
transformedList = transformedList.map((item) => {
|
|
4003
3856
|
return toolToMldev$1(apiClient, tTool(apiClient, item));
|
|
4004
|
-
})
|
|
4005
|
-
}
|
|
4006
|
-
else {
|
|
4007
|
-
setValueByPath(parentObject, ['setup', 'tools'], tTools(apiClient, fromTools));
|
|
3857
|
+
});
|
|
4008
3858
|
}
|
|
3859
|
+
setValueByPath(parentObject, ['setup', 'tools'], transformedList);
|
|
4009
3860
|
}
|
|
4010
3861
|
const fromSessionResumption = getValueByPath(fromObject, [
|
|
4011
3862
|
'sessionResumption',
|
|
@@ -4090,14 +3941,13 @@ function liveConnectConfigToVertex(apiClient, fromObject, parentObject) {
|
|
|
4090
3941
|
}
|
|
4091
3942
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
4092
3943
|
if (parentObject !== undefined && fromTools != null) {
|
|
4093
|
-
|
|
4094
|
-
|
|
3944
|
+
let transformedList = tTools(apiClient, fromTools);
|
|
3945
|
+
if (Array.isArray(transformedList)) {
|
|
3946
|
+
transformedList = transformedList.map((item) => {
|
|
4095
3947
|
return toolToVertex$1(apiClient, tTool(apiClient, item));
|
|
4096
|
-
})
|
|
4097
|
-
}
|
|
4098
|
-
else {
|
|
4099
|
-
setValueByPath(parentObject, ['setup', 'tools'], tTools(apiClient, fromTools));
|
|
3948
|
+
});
|
|
4100
3949
|
}
|
|
3950
|
+
setValueByPath(parentObject, ['setup', 'tools'], transformedList);
|
|
4101
3951
|
}
|
|
4102
3952
|
const fromSessionResumption = getValueByPath(fromObject, [
|
|
4103
3953
|
'sessionResumption',
|
|
@@ -4155,6 +4005,91 @@ function liveConnectParametersToVertex(apiClient, fromObject) {
|
|
|
4155
4005
|
}
|
|
4156
4006
|
return toObject;
|
|
4157
4007
|
}
|
|
4008
|
+
function activityStartToMldev() {
|
|
4009
|
+
const toObject = {};
|
|
4010
|
+
return toObject;
|
|
4011
|
+
}
|
|
4012
|
+
function activityStartToVertex() {
|
|
4013
|
+
const toObject = {};
|
|
4014
|
+
return toObject;
|
|
4015
|
+
}
|
|
4016
|
+
function activityEndToMldev() {
|
|
4017
|
+
const toObject = {};
|
|
4018
|
+
return toObject;
|
|
4019
|
+
}
|
|
4020
|
+
function activityEndToVertex() {
|
|
4021
|
+
const toObject = {};
|
|
4022
|
+
return toObject;
|
|
4023
|
+
}
|
|
4024
|
+
function liveSendRealtimeInputParametersToMldev(apiClient, fromObject) {
|
|
4025
|
+
const toObject = {};
|
|
4026
|
+
const fromMedia = getValueByPath(fromObject, ['media']);
|
|
4027
|
+
if (fromMedia != null) {
|
|
4028
|
+
setValueByPath(toObject, ['mediaChunks'], tBlobs(apiClient, fromMedia));
|
|
4029
|
+
}
|
|
4030
|
+
const fromAudio = getValueByPath(fromObject, ['audio']);
|
|
4031
|
+
if (fromAudio != null) {
|
|
4032
|
+
setValueByPath(toObject, ['audio'], tAudioBlob(apiClient, fromAudio));
|
|
4033
|
+
}
|
|
4034
|
+
const fromAudioStreamEnd = getValueByPath(fromObject, [
|
|
4035
|
+
'audioStreamEnd',
|
|
4036
|
+
]);
|
|
4037
|
+
if (fromAudioStreamEnd != null) {
|
|
4038
|
+
setValueByPath(toObject, ['audioStreamEnd'], fromAudioStreamEnd);
|
|
4039
|
+
}
|
|
4040
|
+
const fromVideo = getValueByPath(fromObject, ['video']);
|
|
4041
|
+
if (fromVideo != null) {
|
|
4042
|
+
setValueByPath(toObject, ['video'], tImageBlob(apiClient, fromVideo));
|
|
4043
|
+
}
|
|
4044
|
+
const fromText = getValueByPath(fromObject, ['text']);
|
|
4045
|
+
if (fromText != null) {
|
|
4046
|
+
setValueByPath(toObject, ['text'], fromText);
|
|
4047
|
+
}
|
|
4048
|
+
const fromActivityStart = getValueByPath(fromObject, [
|
|
4049
|
+
'activityStart',
|
|
4050
|
+
]);
|
|
4051
|
+
if (fromActivityStart != null) {
|
|
4052
|
+
setValueByPath(toObject, ['activityStart'], activityStartToMldev());
|
|
4053
|
+
}
|
|
4054
|
+
const fromActivityEnd = getValueByPath(fromObject, ['activityEnd']);
|
|
4055
|
+
if (fromActivityEnd != null) {
|
|
4056
|
+
setValueByPath(toObject, ['activityEnd'], activityEndToMldev());
|
|
4057
|
+
}
|
|
4058
|
+
return toObject;
|
|
4059
|
+
}
|
|
4060
|
+
function liveSendRealtimeInputParametersToVertex(apiClient, fromObject) {
|
|
4061
|
+
const toObject = {};
|
|
4062
|
+
const fromMedia = getValueByPath(fromObject, ['media']);
|
|
4063
|
+
if (fromMedia != null) {
|
|
4064
|
+
setValueByPath(toObject, ['mediaChunks'], tBlobs(apiClient, fromMedia));
|
|
4065
|
+
}
|
|
4066
|
+
if (getValueByPath(fromObject, ['audio']) !== undefined) {
|
|
4067
|
+
throw new Error('audio parameter is not supported in Vertex AI.');
|
|
4068
|
+
}
|
|
4069
|
+
const fromAudioStreamEnd = getValueByPath(fromObject, [
|
|
4070
|
+
'audioStreamEnd',
|
|
4071
|
+
]);
|
|
4072
|
+
if (fromAudioStreamEnd != null) {
|
|
4073
|
+
setValueByPath(toObject, ['audioStreamEnd'], fromAudioStreamEnd);
|
|
4074
|
+
}
|
|
4075
|
+
if (getValueByPath(fromObject, ['video']) !== undefined) {
|
|
4076
|
+
throw new Error('video parameter is not supported in Vertex AI.');
|
|
4077
|
+
}
|
|
4078
|
+
if (getValueByPath(fromObject, ['text']) !== undefined) {
|
|
4079
|
+
throw new Error('text parameter is not supported in Vertex AI.');
|
|
4080
|
+
}
|
|
4081
|
+
const fromActivityStart = getValueByPath(fromObject, [
|
|
4082
|
+
'activityStart',
|
|
4083
|
+
]);
|
|
4084
|
+
if (fromActivityStart != null) {
|
|
4085
|
+
setValueByPath(toObject, ['activityStart'], activityStartToVertex());
|
|
4086
|
+
}
|
|
4087
|
+
const fromActivityEnd = getValueByPath(fromObject, ['activityEnd']);
|
|
4088
|
+
if (fromActivityEnd != null) {
|
|
4089
|
+
setValueByPath(toObject, ['activityEnd'], activityEndToVertex());
|
|
4090
|
+
}
|
|
4091
|
+
return toObject;
|
|
4092
|
+
}
|
|
4158
4093
|
function liveServerSetupCompleteFromMldev() {
|
|
4159
4094
|
const toObject = {};
|
|
4160
4095
|
return toObject;
|
|
@@ -4257,14 +4192,13 @@ function contentFromMldev$1(apiClient, fromObject) {
|
|
|
4257
4192
|
const toObject = {};
|
|
4258
4193
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
4259
4194
|
if (fromParts != null) {
|
|
4260
|
-
|
|
4261
|
-
|
|
4195
|
+
let transformedList = fromParts;
|
|
4196
|
+
if (Array.isArray(transformedList)) {
|
|
4197
|
+
transformedList = transformedList.map((item) => {
|
|
4262
4198
|
return partFromMldev$1(apiClient, item);
|
|
4263
|
-
})
|
|
4264
|
-
}
|
|
4265
|
-
else {
|
|
4266
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
4199
|
+
});
|
|
4267
4200
|
}
|
|
4201
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
4268
4202
|
}
|
|
4269
4203
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
4270
4204
|
if (fromRole != null) {
|
|
@@ -4276,14 +4210,13 @@ function contentFromVertex$1(apiClient, fromObject) {
|
|
|
4276
4210
|
const toObject = {};
|
|
4277
4211
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
4278
4212
|
if (fromParts != null) {
|
|
4279
|
-
|
|
4280
|
-
|
|
4213
|
+
let transformedList = fromParts;
|
|
4214
|
+
if (Array.isArray(transformedList)) {
|
|
4215
|
+
transformedList = transformedList.map((item) => {
|
|
4281
4216
|
return partFromVertex$1(apiClient, item);
|
|
4282
|
-
})
|
|
4283
|
-
}
|
|
4284
|
-
else {
|
|
4285
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
4217
|
+
});
|
|
4286
4218
|
}
|
|
4219
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
4287
4220
|
}
|
|
4288
4221
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
4289
4222
|
if (fromRole != null) {
|
|
@@ -4417,14 +4350,13 @@ function liveServerToolCallFromMldev(apiClient, fromObject) {
|
|
|
4417
4350
|
'functionCalls',
|
|
4418
4351
|
]);
|
|
4419
4352
|
if (fromFunctionCalls != null) {
|
|
4420
|
-
|
|
4421
|
-
|
|
4353
|
+
let transformedList = fromFunctionCalls;
|
|
4354
|
+
if (Array.isArray(transformedList)) {
|
|
4355
|
+
transformedList = transformedList.map((item) => {
|
|
4422
4356
|
return functionCallFromMldev(apiClient, item);
|
|
4423
|
-
})
|
|
4424
|
-
}
|
|
4425
|
-
else {
|
|
4426
|
-
setValueByPath(toObject, ['functionCalls'], fromFunctionCalls);
|
|
4357
|
+
});
|
|
4427
4358
|
}
|
|
4359
|
+
setValueByPath(toObject, ['functionCalls'], transformedList);
|
|
4428
4360
|
}
|
|
4429
4361
|
return toObject;
|
|
4430
4362
|
}
|
|
@@ -4434,14 +4366,13 @@ function liveServerToolCallFromVertex(apiClient, fromObject) {
|
|
|
4434
4366
|
'functionCalls',
|
|
4435
4367
|
]);
|
|
4436
4368
|
if (fromFunctionCalls != null) {
|
|
4437
|
-
|
|
4438
|
-
|
|
4369
|
+
let transformedList = fromFunctionCalls;
|
|
4370
|
+
if (Array.isArray(transformedList)) {
|
|
4371
|
+
transformedList = transformedList.map((item) => {
|
|
4439
4372
|
return functionCallFromVertex(apiClient, item);
|
|
4440
|
-
})
|
|
4441
|
-
}
|
|
4442
|
-
else {
|
|
4443
|
-
setValueByPath(toObject, ['functionCalls'], fromFunctionCalls);
|
|
4373
|
+
});
|
|
4444
4374
|
}
|
|
4375
|
+
setValueByPath(toObject, ['functionCalls'], transformedList);
|
|
4445
4376
|
}
|
|
4446
4377
|
return toObject;
|
|
4447
4378
|
}
|
|
@@ -4527,53 +4458,49 @@ function usageMetadataFromMldev(apiClient, fromObject) {
|
|
|
4527
4458
|
'promptTokensDetails',
|
|
4528
4459
|
]);
|
|
4529
4460
|
if (fromPromptTokensDetails != null) {
|
|
4530
|
-
|
|
4531
|
-
|
|
4461
|
+
let transformedList = fromPromptTokensDetails;
|
|
4462
|
+
if (Array.isArray(transformedList)) {
|
|
4463
|
+
transformedList = transformedList.map((item) => {
|
|
4532
4464
|
return modalityTokenCountFromMldev(apiClient, item);
|
|
4533
|
-
})
|
|
4534
|
-
}
|
|
4535
|
-
else {
|
|
4536
|
-
setValueByPath(toObject, ['promptTokensDetails'], fromPromptTokensDetails);
|
|
4465
|
+
});
|
|
4537
4466
|
}
|
|
4467
|
+
setValueByPath(toObject, ['promptTokensDetails'], transformedList);
|
|
4538
4468
|
}
|
|
4539
4469
|
const fromCacheTokensDetails = getValueByPath(fromObject, [
|
|
4540
4470
|
'cacheTokensDetails',
|
|
4541
4471
|
]);
|
|
4542
4472
|
if (fromCacheTokensDetails != null) {
|
|
4543
|
-
|
|
4544
|
-
|
|
4473
|
+
let transformedList = fromCacheTokensDetails;
|
|
4474
|
+
if (Array.isArray(transformedList)) {
|
|
4475
|
+
transformedList = transformedList.map((item) => {
|
|
4545
4476
|
return modalityTokenCountFromMldev(apiClient, item);
|
|
4546
|
-
})
|
|
4547
|
-
}
|
|
4548
|
-
else {
|
|
4549
|
-
setValueByPath(toObject, ['cacheTokensDetails'], fromCacheTokensDetails);
|
|
4477
|
+
});
|
|
4550
4478
|
}
|
|
4479
|
+
setValueByPath(toObject, ['cacheTokensDetails'], transformedList);
|
|
4551
4480
|
}
|
|
4552
4481
|
const fromResponseTokensDetails = getValueByPath(fromObject, [
|
|
4553
4482
|
'responseTokensDetails',
|
|
4554
4483
|
]);
|
|
4555
4484
|
if (fromResponseTokensDetails != null) {
|
|
4556
|
-
|
|
4557
|
-
|
|
4485
|
+
let transformedList = fromResponseTokensDetails;
|
|
4486
|
+
if (Array.isArray(transformedList)) {
|
|
4487
|
+
transformedList = transformedList.map((item) => {
|
|
4558
4488
|
return modalityTokenCountFromMldev(apiClient, item);
|
|
4559
|
-
})
|
|
4560
|
-
}
|
|
4561
|
-
else {
|
|
4562
|
-
setValueByPath(toObject, ['responseTokensDetails'], fromResponseTokensDetails);
|
|
4489
|
+
});
|
|
4563
4490
|
}
|
|
4491
|
+
setValueByPath(toObject, ['responseTokensDetails'], transformedList);
|
|
4564
4492
|
}
|
|
4565
4493
|
const fromToolUsePromptTokensDetails = getValueByPath(fromObject, [
|
|
4566
4494
|
'toolUsePromptTokensDetails',
|
|
4567
4495
|
]);
|
|
4568
4496
|
if (fromToolUsePromptTokensDetails != null) {
|
|
4569
|
-
|
|
4570
|
-
|
|
4497
|
+
let transformedList = fromToolUsePromptTokensDetails;
|
|
4498
|
+
if (Array.isArray(transformedList)) {
|
|
4499
|
+
transformedList = transformedList.map((item) => {
|
|
4571
4500
|
return modalityTokenCountFromMldev(apiClient, item);
|
|
4572
|
-
})
|
|
4573
|
-
}
|
|
4574
|
-
else {
|
|
4575
|
-
setValueByPath(toObject, ['toolUsePromptTokensDetails'], fromToolUsePromptTokensDetails);
|
|
4501
|
+
});
|
|
4576
4502
|
}
|
|
4503
|
+
setValueByPath(toObject, ['toolUsePromptTokensDetails'], transformedList);
|
|
4577
4504
|
}
|
|
4578
4505
|
return toObject;
|
|
4579
4506
|
}
|
|
@@ -4619,53 +4546,49 @@ function usageMetadataFromVertex(apiClient, fromObject) {
|
|
|
4619
4546
|
'promptTokensDetails',
|
|
4620
4547
|
]);
|
|
4621
4548
|
if (fromPromptTokensDetails != null) {
|
|
4622
|
-
|
|
4623
|
-
|
|
4549
|
+
let transformedList = fromPromptTokensDetails;
|
|
4550
|
+
if (Array.isArray(transformedList)) {
|
|
4551
|
+
transformedList = transformedList.map((item) => {
|
|
4624
4552
|
return modalityTokenCountFromVertex(apiClient, item);
|
|
4625
|
-
})
|
|
4626
|
-
}
|
|
4627
|
-
else {
|
|
4628
|
-
setValueByPath(toObject, ['promptTokensDetails'], fromPromptTokensDetails);
|
|
4553
|
+
});
|
|
4629
4554
|
}
|
|
4555
|
+
setValueByPath(toObject, ['promptTokensDetails'], transformedList);
|
|
4630
4556
|
}
|
|
4631
4557
|
const fromCacheTokensDetails = getValueByPath(fromObject, [
|
|
4632
4558
|
'cacheTokensDetails',
|
|
4633
4559
|
]);
|
|
4634
4560
|
if (fromCacheTokensDetails != null) {
|
|
4635
|
-
|
|
4636
|
-
|
|
4561
|
+
let transformedList = fromCacheTokensDetails;
|
|
4562
|
+
if (Array.isArray(transformedList)) {
|
|
4563
|
+
transformedList = transformedList.map((item) => {
|
|
4637
4564
|
return modalityTokenCountFromVertex(apiClient, item);
|
|
4638
|
-
})
|
|
4639
|
-
}
|
|
4640
|
-
else {
|
|
4641
|
-
setValueByPath(toObject, ['cacheTokensDetails'], fromCacheTokensDetails);
|
|
4565
|
+
});
|
|
4642
4566
|
}
|
|
4567
|
+
setValueByPath(toObject, ['cacheTokensDetails'], transformedList);
|
|
4643
4568
|
}
|
|
4644
4569
|
const fromResponseTokensDetails = getValueByPath(fromObject, [
|
|
4645
4570
|
'candidatesTokensDetails',
|
|
4646
4571
|
]);
|
|
4647
4572
|
if (fromResponseTokensDetails != null) {
|
|
4648
|
-
|
|
4649
|
-
|
|
4573
|
+
let transformedList = fromResponseTokensDetails;
|
|
4574
|
+
if (Array.isArray(transformedList)) {
|
|
4575
|
+
transformedList = transformedList.map((item) => {
|
|
4650
4576
|
return modalityTokenCountFromVertex(apiClient, item);
|
|
4651
|
-
})
|
|
4652
|
-
}
|
|
4653
|
-
else {
|
|
4654
|
-
setValueByPath(toObject, ['responseTokensDetails'], fromResponseTokensDetails);
|
|
4577
|
+
});
|
|
4655
4578
|
}
|
|
4579
|
+
setValueByPath(toObject, ['responseTokensDetails'], transformedList);
|
|
4656
4580
|
}
|
|
4657
4581
|
const fromToolUsePromptTokensDetails = getValueByPath(fromObject, [
|
|
4658
4582
|
'toolUsePromptTokensDetails',
|
|
4659
4583
|
]);
|
|
4660
4584
|
if (fromToolUsePromptTokensDetails != null) {
|
|
4661
|
-
|
|
4662
|
-
|
|
4585
|
+
let transformedList = fromToolUsePromptTokensDetails;
|
|
4586
|
+
if (Array.isArray(transformedList)) {
|
|
4587
|
+
transformedList = transformedList.map((item) => {
|
|
4663
4588
|
return modalityTokenCountFromVertex(apiClient, item);
|
|
4664
|
-
})
|
|
4665
|
-
}
|
|
4666
|
-
else {
|
|
4667
|
-
setValueByPath(toObject, ['toolUsePromptTokensDetails'], fromToolUsePromptTokensDetails);
|
|
4589
|
+
});
|
|
4668
4590
|
}
|
|
4591
|
+
setValueByPath(toObject, ['toolUsePromptTokensDetails'], transformedList);
|
|
4669
4592
|
}
|
|
4670
4593
|
const fromTrafficType = getValueByPath(fromObject, ['trafficType']);
|
|
4671
4594
|
if (fromTrafficType != null) {
|
|
@@ -4864,14 +4787,13 @@ function contentToMldev(apiClient, fromObject) {
|
|
|
4864
4787
|
const toObject = {};
|
|
4865
4788
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
4866
4789
|
if (fromParts != null) {
|
|
4867
|
-
|
|
4868
|
-
|
|
4790
|
+
let transformedList = fromParts;
|
|
4791
|
+
if (Array.isArray(transformedList)) {
|
|
4792
|
+
transformedList = transformedList.map((item) => {
|
|
4869
4793
|
return partToMldev(apiClient, item);
|
|
4870
|
-
})
|
|
4871
|
-
}
|
|
4872
|
-
else {
|
|
4873
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
4794
|
+
});
|
|
4874
4795
|
}
|
|
4796
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
4875
4797
|
}
|
|
4876
4798
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
4877
4799
|
if (fromRole != null) {
|
|
@@ -4879,93 +4801,6 @@ function contentToMldev(apiClient, fromObject) {
|
|
|
4879
4801
|
}
|
|
4880
4802
|
return toObject;
|
|
4881
4803
|
}
|
|
4882
|
-
function schemaToMldev(apiClient, fromObject) {
|
|
4883
|
-
const toObject = {};
|
|
4884
|
-
if (getValueByPath(fromObject, ['example']) !== undefined) {
|
|
4885
|
-
throw new Error('example parameter is not supported in Gemini API.');
|
|
4886
|
-
}
|
|
4887
|
-
if (getValueByPath(fromObject, ['pattern']) !== undefined) {
|
|
4888
|
-
throw new Error('pattern parameter is not supported in Gemini API.');
|
|
4889
|
-
}
|
|
4890
|
-
if (getValueByPath(fromObject, ['default']) !== undefined) {
|
|
4891
|
-
throw new Error('default parameter is not supported in Gemini API.');
|
|
4892
|
-
}
|
|
4893
|
-
if (getValueByPath(fromObject, ['maxLength']) !== undefined) {
|
|
4894
|
-
throw new Error('maxLength parameter is not supported in Gemini API.');
|
|
4895
|
-
}
|
|
4896
|
-
if (getValueByPath(fromObject, ['minLength']) !== undefined) {
|
|
4897
|
-
throw new Error('minLength parameter is not supported in Gemini API.');
|
|
4898
|
-
}
|
|
4899
|
-
if (getValueByPath(fromObject, ['minProperties']) !== undefined) {
|
|
4900
|
-
throw new Error('minProperties parameter is not supported in Gemini API.');
|
|
4901
|
-
}
|
|
4902
|
-
if (getValueByPath(fromObject, ['maxProperties']) !== undefined) {
|
|
4903
|
-
throw new Error('maxProperties parameter is not supported in Gemini API.');
|
|
4904
|
-
}
|
|
4905
|
-
const fromAnyOf = getValueByPath(fromObject, ['anyOf']);
|
|
4906
|
-
if (fromAnyOf != null) {
|
|
4907
|
-
setValueByPath(toObject, ['anyOf'], fromAnyOf);
|
|
4908
|
-
}
|
|
4909
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
4910
|
-
if (fromDescription != null) {
|
|
4911
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
4912
|
-
}
|
|
4913
|
-
const fromEnum = getValueByPath(fromObject, ['enum']);
|
|
4914
|
-
if (fromEnum != null) {
|
|
4915
|
-
setValueByPath(toObject, ['enum'], fromEnum);
|
|
4916
|
-
}
|
|
4917
|
-
const fromFormat = getValueByPath(fromObject, ['format']);
|
|
4918
|
-
if (fromFormat != null) {
|
|
4919
|
-
setValueByPath(toObject, ['format'], fromFormat);
|
|
4920
|
-
}
|
|
4921
|
-
const fromItems = getValueByPath(fromObject, ['items']);
|
|
4922
|
-
if (fromItems != null) {
|
|
4923
|
-
setValueByPath(toObject, ['items'], fromItems);
|
|
4924
|
-
}
|
|
4925
|
-
const fromMaxItems = getValueByPath(fromObject, ['maxItems']);
|
|
4926
|
-
if (fromMaxItems != null) {
|
|
4927
|
-
setValueByPath(toObject, ['maxItems'], fromMaxItems);
|
|
4928
|
-
}
|
|
4929
|
-
const fromMaximum = getValueByPath(fromObject, ['maximum']);
|
|
4930
|
-
if (fromMaximum != null) {
|
|
4931
|
-
setValueByPath(toObject, ['maximum'], fromMaximum);
|
|
4932
|
-
}
|
|
4933
|
-
const fromMinItems = getValueByPath(fromObject, ['minItems']);
|
|
4934
|
-
if (fromMinItems != null) {
|
|
4935
|
-
setValueByPath(toObject, ['minItems'], fromMinItems);
|
|
4936
|
-
}
|
|
4937
|
-
const fromMinimum = getValueByPath(fromObject, ['minimum']);
|
|
4938
|
-
if (fromMinimum != null) {
|
|
4939
|
-
setValueByPath(toObject, ['minimum'], fromMinimum);
|
|
4940
|
-
}
|
|
4941
|
-
const fromNullable = getValueByPath(fromObject, ['nullable']);
|
|
4942
|
-
if (fromNullable != null) {
|
|
4943
|
-
setValueByPath(toObject, ['nullable'], fromNullable);
|
|
4944
|
-
}
|
|
4945
|
-
const fromProperties = getValueByPath(fromObject, ['properties']);
|
|
4946
|
-
if (fromProperties != null) {
|
|
4947
|
-
setValueByPath(toObject, ['properties'], fromProperties);
|
|
4948
|
-
}
|
|
4949
|
-
const fromPropertyOrdering = getValueByPath(fromObject, [
|
|
4950
|
-
'propertyOrdering',
|
|
4951
|
-
]);
|
|
4952
|
-
if (fromPropertyOrdering != null) {
|
|
4953
|
-
setValueByPath(toObject, ['propertyOrdering'], fromPropertyOrdering);
|
|
4954
|
-
}
|
|
4955
|
-
const fromRequired = getValueByPath(fromObject, ['required']);
|
|
4956
|
-
if (fromRequired != null) {
|
|
4957
|
-
setValueByPath(toObject, ['required'], fromRequired);
|
|
4958
|
-
}
|
|
4959
|
-
const fromTitle = getValueByPath(fromObject, ['title']);
|
|
4960
|
-
if (fromTitle != null) {
|
|
4961
|
-
setValueByPath(toObject, ['title'], fromTitle);
|
|
4962
|
-
}
|
|
4963
|
-
const fromType = getValueByPath(fromObject, ['type']);
|
|
4964
|
-
if (fromType != null) {
|
|
4965
|
-
setValueByPath(toObject, ['type'], fromType);
|
|
4966
|
-
}
|
|
4967
|
-
return toObject;
|
|
4968
|
-
}
|
|
4969
4804
|
function safetySettingToMldev(apiClient, fromObject) {
|
|
4970
4805
|
const toObject = {};
|
|
4971
4806
|
if (getValueByPath(fromObject, ['method']) !== undefined) {
|
|
@@ -4981,25 +4816,6 @@ function safetySettingToMldev(apiClient, fromObject) {
|
|
|
4981
4816
|
}
|
|
4982
4817
|
return toObject;
|
|
4983
4818
|
}
|
|
4984
|
-
function functionDeclarationToMldev(apiClient, fromObject) {
|
|
4985
|
-
const toObject = {};
|
|
4986
|
-
if (getValueByPath(fromObject, ['response']) !== undefined) {
|
|
4987
|
-
throw new Error('response parameter is not supported in Gemini API.');
|
|
4988
|
-
}
|
|
4989
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
4990
|
-
if (fromDescription != null) {
|
|
4991
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
4992
|
-
}
|
|
4993
|
-
const fromName = getValueByPath(fromObject, ['name']);
|
|
4994
|
-
if (fromName != null) {
|
|
4995
|
-
setValueByPath(toObject, ['name'], fromName);
|
|
4996
|
-
}
|
|
4997
|
-
const fromParameters = getValueByPath(fromObject, ['parameters']);
|
|
4998
|
-
if (fromParameters != null) {
|
|
4999
|
-
setValueByPath(toObject, ['parameters'], fromParameters);
|
|
5000
|
-
}
|
|
5001
|
-
return toObject;
|
|
5002
|
-
}
|
|
5003
4819
|
function googleSearchToMldev() {
|
|
5004
4820
|
const toObject = {};
|
|
5005
4821
|
return toObject;
|
|
@@ -5030,19 +4846,6 @@ function googleSearchRetrievalToMldev(apiClient, fromObject) {
|
|
|
5030
4846
|
}
|
|
5031
4847
|
function toolToMldev(apiClient, fromObject) {
|
|
5032
4848
|
const toObject = {};
|
|
5033
|
-
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
5034
|
-
'functionDeclarations',
|
|
5035
|
-
]);
|
|
5036
|
-
if (fromFunctionDeclarations != null) {
|
|
5037
|
-
if (Array.isArray(fromFunctionDeclarations)) {
|
|
5038
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations.map((item) => {
|
|
5039
|
-
return functionDeclarationToMldev(apiClient, item);
|
|
5040
|
-
}));
|
|
5041
|
-
}
|
|
5042
|
-
else {
|
|
5043
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
5044
|
-
}
|
|
5045
|
-
}
|
|
5046
4849
|
if (getValueByPath(fromObject, ['retrieval']) !== undefined) {
|
|
5047
4850
|
throw new Error('retrieval parameter is not supported in Gemini API.');
|
|
5048
4851
|
}
|
|
@@ -5062,6 +4865,12 @@ function toolToMldev(apiClient, fromObject) {
|
|
|
5062
4865
|
if (fromCodeExecution != null) {
|
|
5063
4866
|
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
5064
4867
|
}
|
|
4868
|
+
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
4869
|
+
'functionDeclarations',
|
|
4870
|
+
]);
|
|
4871
|
+
if (fromFunctionDeclarations != null) {
|
|
4872
|
+
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
4873
|
+
}
|
|
5065
4874
|
return toObject;
|
|
5066
4875
|
}
|
|
5067
4876
|
function functionCallingConfigToMldev(apiClient, fromObject) {
|
|
@@ -5208,7 +5017,7 @@ function generateContentConfigToMldev(apiClient, fromObject, parentObject) {
|
|
|
5208
5017
|
'responseSchema',
|
|
5209
5018
|
]);
|
|
5210
5019
|
if (fromResponseSchema != null) {
|
|
5211
|
-
setValueByPath(toObject, ['responseSchema'],
|
|
5020
|
+
setValueByPath(toObject, ['responseSchema'], tSchema(apiClient, fromResponseSchema));
|
|
5212
5021
|
}
|
|
5213
5022
|
if (getValueByPath(fromObject, ['routingConfig']) !== undefined) {
|
|
5214
5023
|
throw new Error('routingConfig parameter is not supported in Gemini API.');
|
|
@@ -5220,25 +5029,23 @@ function generateContentConfigToMldev(apiClient, fromObject, parentObject) {
|
|
|
5220
5029
|
'safetySettings',
|
|
5221
5030
|
]);
|
|
5222
5031
|
if (parentObject !== undefined && fromSafetySettings != null) {
|
|
5223
|
-
|
|
5224
|
-
|
|
5032
|
+
let transformedList = fromSafetySettings;
|
|
5033
|
+
if (Array.isArray(transformedList)) {
|
|
5034
|
+
transformedList = transformedList.map((item) => {
|
|
5225
5035
|
return safetySettingToMldev(apiClient, item);
|
|
5226
|
-
})
|
|
5227
|
-
}
|
|
5228
|
-
else {
|
|
5229
|
-
setValueByPath(parentObject, ['safetySettings'], fromSafetySettings);
|
|
5036
|
+
});
|
|
5230
5037
|
}
|
|
5038
|
+
setValueByPath(parentObject, ['safetySettings'], transformedList);
|
|
5231
5039
|
}
|
|
5232
5040
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
5233
5041
|
if (parentObject !== undefined && fromTools != null) {
|
|
5234
|
-
|
|
5235
|
-
|
|
5042
|
+
let transformedList = tTools(apiClient, fromTools);
|
|
5043
|
+
if (Array.isArray(transformedList)) {
|
|
5044
|
+
transformedList = transformedList.map((item) => {
|
|
5236
5045
|
return toolToMldev(apiClient, tTool(apiClient, item));
|
|
5237
|
-
})
|
|
5238
|
-
}
|
|
5239
|
-
else {
|
|
5240
|
-
setValueByPath(parentObject, ['tools'], tTools(apiClient, fromTools));
|
|
5046
|
+
});
|
|
5241
5047
|
}
|
|
5048
|
+
setValueByPath(parentObject, ['tools'], transformedList);
|
|
5242
5049
|
}
|
|
5243
5050
|
const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
|
|
5244
5051
|
if (parentObject !== undefined && fromToolConfig != null) {
|
|
@@ -5288,14 +5095,13 @@ function generateContentParametersToMldev(apiClient, fromObject) {
|
|
|
5288
5095
|
}
|
|
5289
5096
|
const fromContents = getValueByPath(fromObject, ['contents']);
|
|
5290
5097
|
if (fromContents != null) {
|
|
5291
|
-
|
|
5292
|
-
|
|
5098
|
+
let transformedList = tContents(apiClient, fromContents);
|
|
5099
|
+
if (Array.isArray(transformedList)) {
|
|
5100
|
+
transformedList = transformedList.map((item) => {
|
|
5293
5101
|
return contentToMldev(apiClient, item);
|
|
5294
|
-
})
|
|
5295
|
-
}
|
|
5296
|
-
else {
|
|
5297
|
-
setValueByPath(toObject, ['contents'], tContents(apiClient, fromContents));
|
|
5102
|
+
});
|
|
5298
5103
|
}
|
|
5104
|
+
setValueByPath(toObject, ['contents'], transformedList);
|
|
5299
5105
|
}
|
|
5300
5106
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
5301
5107
|
if (fromConfig != null) {
|
|
@@ -5450,16 +5256,52 @@ function getModelParametersToMldev(apiClient, fromObject) {
|
|
|
5450
5256
|
}
|
|
5451
5257
|
return toObject;
|
|
5452
5258
|
}
|
|
5453
|
-
function
|
|
5259
|
+
function updateModelConfigToMldev(apiClient, fromObject, parentObject) {
|
|
5454
5260
|
const toObject = {};
|
|
5455
|
-
|
|
5456
|
-
|
|
5457
|
-
|
|
5458
|
-
if (getValueByPath(fromObject, ['tools']) !== undefined) {
|
|
5459
|
-
throw new Error('tools parameter is not supported in Gemini API.');
|
|
5261
|
+
const fromDisplayName = getValueByPath(fromObject, ['displayName']);
|
|
5262
|
+
if (parentObject !== undefined && fromDisplayName != null) {
|
|
5263
|
+
setValueByPath(parentObject, ['displayName'], fromDisplayName);
|
|
5460
5264
|
}
|
|
5461
|
-
|
|
5462
|
-
|
|
5265
|
+
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
5266
|
+
if (parentObject !== undefined && fromDescription != null) {
|
|
5267
|
+
setValueByPath(parentObject, ['description'], fromDescription);
|
|
5268
|
+
}
|
|
5269
|
+
return toObject;
|
|
5270
|
+
}
|
|
5271
|
+
function updateModelParametersToMldev(apiClient, fromObject) {
|
|
5272
|
+
const toObject = {};
|
|
5273
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
5274
|
+
if (fromModel != null) {
|
|
5275
|
+
setValueByPath(toObject, ['_url', 'name'], tModel(apiClient, fromModel));
|
|
5276
|
+
}
|
|
5277
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
5278
|
+
if (fromConfig != null) {
|
|
5279
|
+
setValueByPath(toObject, ['config'], updateModelConfigToMldev(apiClient, fromConfig, toObject));
|
|
5280
|
+
}
|
|
5281
|
+
return toObject;
|
|
5282
|
+
}
|
|
5283
|
+
function deleteModelParametersToMldev(apiClient, fromObject) {
|
|
5284
|
+
const toObject = {};
|
|
5285
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
5286
|
+
if (fromModel != null) {
|
|
5287
|
+
setValueByPath(toObject, ['_url', 'name'], tModel(apiClient, fromModel));
|
|
5288
|
+
}
|
|
5289
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
5290
|
+
if (fromConfig != null) {
|
|
5291
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
5292
|
+
}
|
|
5293
|
+
return toObject;
|
|
5294
|
+
}
|
|
5295
|
+
function countTokensConfigToMldev(apiClient, fromObject) {
|
|
5296
|
+
const toObject = {};
|
|
5297
|
+
if (getValueByPath(fromObject, ['systemInstruction']) !== undefined) {
|
|
5298
|
+
throw new Error('systemInstruction parameter is not supported in Gemini API.');
|
|
5299
|
+
}
|
|
5300
|
+
if (getValueByPath(fromObject, ['tools']) !== undefined) {
|
|
5301
|
+
throw new Error('tools parameter is not supported in Gemini API.');
|
|
5302
|
+
}
|
|
5303
|
+
if (getValueByPath(fromObject, ['generationConfig']) !== undefined) {
|
|
5304
|
+
throw new Error('generationConfig parameter is not supported in Gemini API.');
|
|
5463
5305
|
}
|
|
5464
5306
|
return toObject;
|
|
5465
5307
|
}
|
|
@@ -5471,14 +5313,13 @@ function countTokensParametersToMldev(apiClient, fromObject) {
|
|
|
5471
5313
|
}
|
|
5472
5314
|
const fromContents = getValueByPath(fromObject, ['contents']);
|
|
5473
5315
|
if (fromContents != null) {
|
|
5474
|
-
|
|
5475
|
-
|
|
5316
|
+
let transformedList = tContents(apiClient, fromContents);
|
|
5317
|
+
if (Array.isArray(transformedList)) {
|
|
5318
|
+
transformedList = transformedList.map((item) => {
|
|
5476
5319
|
return contentToMldev(apiClient, item);
|
|
5477
|
-
})
|
|
5478
|
-
}
|
|
5479
|
-
else {
|
|
5480
|
-
setValueByPath(toObject, ['contents'], tContents(apiClient, fromContents));
|
|
5320
|
+
});
|
|
5481
5321
|
}
|
|
5322
|
+
setValueByPath(toObject, ['contents'], transformedList);
|
|
5482
5323
|
}
|
|
5483
5324
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
5484
5325
|
if (fromConfig != null) {
|
|
@@ -5623,14 +5464,13 @@ function contentToVertex(apiClient, fromObject) {
|
|
|
5623
5464
|
const toObject = {};
|
|
5624
5465
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
5625
5466
|
if (fromParts != null) {
|
|
5626
|
-
|
|
5627
|
-
|
|
5467
|
+
let transformedList = fromParts;
|
|
5468
|
+
if (Array.isArray(transformedList)) {
|
|
5469
|
+
transformedList = transformedList.map((item) => {
|
|
5628
5470
|
return partToVertex(apiClient, item);
|
|
5629
|
-
})
|
|
5630
|
-
}
|
|
5631
|
-
else {
|
|
5632
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
5471
|
+
});
|
|
5633
5472
|
}
|
|
5473
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
5634
5474
|
}
|
|
5635
5475
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
5636
5476
|
if (fromRole != null) {
|
|
@@ -5638,104 +5478,6 @@ function contentToVertex(apiClient, fromObject) {
|
|
|
5638
5478
|
}
|
|
5639
5479
|
return toObject;
|
|
5640
5480
|
}
|
|
5641
|
-
function schemaToVertex(apiClient, fromObject) {
|
|
5642
|
-
const toObject = {};
|
|
5643
|
-
const fromExample = getValueByPath(fromObject, ['example']);
|
|
5644
|
-
if (fromExample != null) {
|
|
5645
|
-
setValueByPath(toObject, ['example'], fromExample);
|
|
5646
|
-
}
|
|
5647
|
-
const fromPattern = getValueByPath(fromObject, ['pattern']);
|
|
5648
|
-
if (fromPattern != null) {
|
|
5649
|
-
setValueByPath(toObject, ['pattern'], fromPattern);
|
|
5650
|
-
}
|
|
5651
|
-
const fromDefault = getValueByPath(fromObject, ['default']);
|
|
5652
|
-
if (fromDefault != null) {
|
|
5653
|
-
setValueByPath(toObject, ['default'], fromDefault);
|
|
5654
|
-
}
|
|
5655
|
-
const fromMaxLength = getValueByPath(fromObject, ['maxLength']);
|
|
5656
|
-
if (fromMaxLength != null) {
|
|
5657
|
-
setValueByPath(toObject, ['maxLength'], fromMaxLength);
|
|
5658
|
-
}
|
|
5659
|
-
const fromMinLength = getValueByPath(fromObject, ['minLength']);
|
|
5660
|
-
if (fromMinLength != null) {
|
|
5661
|
-
setValueByPath(toObject, ['minLength'], fromMinLength);
|
|
5662
|
-
}
|
|
5663
|
-
const fromMinProperties = getValueByPath(fromObject, [
|
|
5664
|
-
'minProperties',
|
|
5665
|
-
]);
|
|
5666
|
-
if (fromMinProperties != null) {
|
|
5667
|
-
setValueByPath(toObject, ['minProperties'], fromMinProperties);
|
|
5668
|
-
}
|
|
5669
|
-
const fromMaxProperties = getValueByPath(fromObject, [
|
|
5670
|
-
'maxProperties',
|
|
5671
|
-
]);
|
|
5672
|
-
if (fromMaxProperties != null) {
|
|
5673
|
-
setValueByPath(toObject, ['maxProperties'], fromMaxProperties);
|
|
5674
|
-
}
|
|
5675
|
-
const fromAnyOf = getValueByPath(fromObject, ['anyOf']);
|
|
5676
|
-
if (fromAnyOf != null) {
|
|
5677
|
-
setValueByPath(toObject, ['anyOf'], fromAnyOf);
|
|
5678
|
-
}
|
|
5679
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
5680
|
-
if (fromDescription != null) {
|
|
5681
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
5682
|
-
}
|
|
5683
|
-
const fromEnum = getValueByPath(fromObject, ['enum']);
|
|
5684
|
-
if (fromEnum != null) {
|
|
5685
|
-
setValueByPath(toObject, ['enum'], fromEnum);
|
|
5686
|
-
}
|
|
5687
|
-
const fromFormat = getValueByPath(fromObject, ['format']);
|
|
5688
|
-
if (fromFormat != null) {
|
|
5689
|
-
setValueByPath(toObject, ['format'], fromFormat);
|
|
5690
|
-
}
|
|
5691
|
-
const fromItems = getValueByPath(fromObject, ['items']);
|
|
5692
|
-
if (fromItems != null) {
|
|
5693
|
-
setValueByPath(toObject, ['items'], fromItems);
|
|
5694
|
-
}
|
|
5695
|
-
const fromMaxItems = getValueByPath(fromObject, ['maxItems']);
|
|
5696
|
-
if (fromMaxItems != null) {
|
|
5697
|
-
setValueByPath(toObject, ['maxItems'], fromMaxItems);
|
|
5698
|
-
}
|
|
5699
|
-
const fromMaximum = getValueByPath(fromObject, ['maximum']);
|
|
5700
|
-
if (fromMaximum != null) {
|
|
5701
|
-
setValueByPath(toObject, ['maximum'], fromMaximum);
|
|
5702
|
-
}
|
|
5703
|
-
const fromMinItems = getValueByPath(fromObject, ['minItems']);
|
|
5704
|
-
if (fromMinItems != null) {
|
|
5705
|
-
setValueByPath(toObject, ['minItems'], fromMinItems);
|
|
5706
|
-
}
|
|
5707
|
-
const fromMinimum = getValueByPath(fromObject, ['minimum']);
|
|
5708
|
-
if (fromMinimum != null) {
|
|
5709
|
-
setValueByPath(toObject, ['minimum'], fromMinimum);
|
|
5710
|
-
}
|
|
5711
|
-
const fromNullable = getValueByPath(fromObject, ['nullable']);
|
|
5712
|
-
if (fromNullable != null) {
|
|
5713
|
-
setValueByPath(toObject, ['nullable'], fromNullable);
|
|
5714
|
-
}
|
|
5715
|
-
const fromProperties = getValueByPath(fromObject, ['properties']);
|
|
5716
|
-
if (fromProperties != null) {
|
|
5717
|
-
setValueByPath(toObject, ['properties'], fromProperties);
|
|
5718
|
-
}
|
|
5719
|
-
const fromPropertyOrdering = getValueByPath(fromObject, [
|
|
5720
|
-
'propertyOrdering',
|
|
5721
|
-
]);
|
|
5722
|
-
if (fromPropertyOrdering != null) {
|
|
5723
|
-
setValueByPath(toObject, ['propertyOrdering'], fromPropertyOrdering);
|
|
5724
|
-
}
|
|
5725
|
-
const fromRequired = getValueByPath(fromObject, ['required']);
|
|
5726
|
-
if (fromRequired != null) {
|
|
5727
|
-
setValueByPath(toObject, ['required'], fromRequired);
|
|
5728
|
-
}
|
|
5729
|
-
const fromTitle = getValueByPath(fromObject, ['title']);
|
|
5730
|
-
if (fromTitle != null) {
|
|
5731
|
-
setValueByPath(toObject, ['title'], fromTitle);
|
|
5732
|
-
}
|
|
5733
|
-
const fromType = getValueByPath(fromObject, ['type']);
|
|
5734
|
-
if (fromType != null) {
|
|
5735
|
-
setValueByPath(toObject, ['type'], fromType);
|
|
5736
|
-
}
|
|
5737
|
-
return toObject;
|
|
5738
|
-
}
|
|
5739
5481
|
function modelSelectionConfigToVertex(apiClient, fromObject) {
|
|
5740
5482
|
const toObject = {};
|
|
5741
5483
|
const fromFeatureSelectionPreference = getValueByPath(fromObject, [
|
|
@@ -5762,26 +5504,6 @@ function safetySettingToVertex(apiClient, fromObject) {
|
|
|
5762
5504
|
}
|
|
5763
5505
|
return toObject;
|
|
5764
5506
|
}
|
|
5765
|
-
function functionDeclarationToVertex(apiClient, fromObject) {
|
|
5766
|
-
const toObject = {};
|
|
5767
|
-
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
5768
|
-
if (fromResponse != null) {
|
|
5769
|
-
setValueByPath(toObject, ['response'], schemaToVertex(apiClient, fromResponse));
|
|
5770
|
-
}
|
|
5771
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
5772
|
-
if (fromDescription != null) {
|
|
5773
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
5774
|
-
}
|
|
5775
|
-
const fromName = getValueByPath(fromObject, ['name']);
|
|
5776
|
-
if (fromName != null) {
|
|
5777
|
-
setValueByPath(toObject, ['name'], fromName);
|
|
5778
|
-
}
|
|
5779
|
-
const fromParameters = getValueByPath(fromObject, ['parameters']);
|
|
5780
|
-
if (fromParameters != null) {
|
|
5781
|
-
setValueByPath(toObject, ['parameters'], fromParameters);
|
|
5782
|
-
}
|
|
5783
|
-
return toObject;
|
|
5784
|
-
}
|
|
5785
5507
|
function googleSearchToVertex() {
|
|
5786
5508
|
const toObject = {};
|
|
5787
5509
|
return toObject;
|
|
@@ -5812,19 +5534,6 @@ function googleSearchRetrievalToVertex(apiClient, fromObject) {
|
|
|
5812
5534
|
}
|
|
5813
5535
|
function toolToVertex(apiClient, fromObject) {
|
|
5814
5536
|
const toObject = {};
|
|
5815
|
-
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
5816
|
-
'functionDeclarations',
|
|
5817
|
-
]);
|
|
5818
|
-
if (fromFunctionDeclarations != null) {
|
|
5819
|
-
if (Array.isArray(fromFunctionDeclarations)) {
|
|
5820
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations.map((item) => {
|
|
5821
|
-
return functionDeclarationToVertex(apiClient, item);
|
|
5822
|
-
}));
|
|
5823
|
-
}
|
|
5824
|
-
else {
|
|
5825
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
5826
|
-
}
|
|
5827
|
-
}
|
|
5828
5537
|
const fromRetrieval = getValueByPath(fromObject, ['retrieval']);
|
|
5829
5538
|
if (fromRetrieval != null) {
|
|
5830
5539
|
setValueByPath(toObject, ['retrieval'], fromRetrieval);
|
|
@@ -5845,6 +5554,12 @@ function toolToVertex(apiClient, fromObject) {
|
|
|
5845
5554
|
if (fromCodeExecution != null) {
|
|
5846
5555
|
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
5847
5556
|
}
|
|
5557
|
+
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
5558
|
+
'functionDeclarations',
|
|
5559
|
+
]);
|
|
5560
|
+
if (fromFunctionDeclarations != null) {
|
|
5561
|
+
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
5562
|
+
}
|
|
5848
5563
|
return toObject;
|
|
5849
5564
|
}
|
|
5850
5565
|
function functionCallingConfigToVertex(apiClient, fromObject) {
|
|
@@ -5991,7 +5706,7 @@ function generateContentConfigToVertex(apiClient, fromObject, parentObject) {
|
|
|
5991
5706
|
'responseSchema',
|
|
5992
5707
|
]);
|
|
5993
5708
|
if (fromResponseSchema != null) {
|
|
5994
|
-
setValueByPath(toObject, ['responseSchema'],
|
|
5709
|
+
setValueByPath(toObject, ['responseSchema'], tSchema(apiClient, fromResponseSchema));
|
|
5995
5710
|
}
|
|
5996
5711
|
const fromRoutingConfig = getValueByPath(fromObject, [
|
|
5997
5712
|
'routingConfig',
|
|
@@ -6009,25 +5724,23 @@ function generateContentConfigToVertex(apiClient, fromObject, parentObject) {
|
|
|
6009
5724
|
'safetySettings',
|
|
6010
5725
|
]);
|
|
6011
5726
|
if (parentObject !== undefined && fromSafetySettings != null) {
|
|
6012
|
-
|
|
6013
|
-
|
|
5727
|
+
let transformedList = fromSafetySettings;
|
|
5728
|
+
if (Array.isArray(transformedList)) {
|
|
5729
|
+
transformedList = transformedList.map((item) => {
|
|
6014
5730
|
return safetySettingToVertex(apiClient, item);
|
|
6015
|
-
})
|
|
6016
|
-
}
|
|
6017
|
-
else {
|
|
6018
|
-
setValueByPath(parentObject, ['safetySettings'], fromSafetySettings);
|
|
5731
|
+
});
|
|
6019
5732
|
}
|
|
5733
|
+
setValueByPath(parentObject, ['safetySettings'], transformedList);
|
|
6020
5734
|
}
|
|
6021
5735
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
6022
5736
|
if (parentObject !== undefined && fromTools != null) {
|
|
6023
|
-
|
|
6024
|
-
|
|
5737
|
+
let transformedList = tTools(apiClient, fromTools);
|
|
5738
|
+
if (Array.isArray(transformedList)) {
|
|
5739
|
+
transformedList = transformedList.map((item) => {
|
|
6025
5740
|
return toolToVertex(apiClient, tTool(apiClient, item));
|
|
6026
|
-
})
|
|
6027
|
-
}
|
|
6028
|
-
else {
|
|
6029
|
-
setValueByPath(parentObject, ['tools'], tTools(apiClient, fromTools));
|
|
5741
|
+
});
|
|
6030
5742
|
}
|
|
5743
|
+
setValueByPath(parentObject, ['tools'], transformedList);
|
|
6031
5744
|
}
|
|
6032
5745
|
const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
|
|
6033
5746
|
if (parentObject !== undefined && fromToolConfig != null) {
|
|
@@ -6081,14 +5794,13 @@ function generateContentParametersToVertex(apiClient, fromObject) {
|
|
|
6081
5794
|
}
|
|
6082
5795
|
const fromContents = getValueByPath(fromObject, ['contents']);
|
|
6083
5796
|
if (fromContents != null) {
|
|
6084
|
-
|
|
6085
|
-
|
|
5797
|
+
let transformedList = tContents(apiClient, fromContents);
|
|
5798
|
+
if (Array.isArray(transformedList)) {
|
|
5799
|
+
transformedList = transformedList.map((item) => {
|
|
6086
5800
|
return contentToVertex(apiClient, item);
|
|
6087
|
-
})
|
|
6088
|
-
}
|
|
6089
|
-
else {
|
|
6090
|
-
setValueByPath(toObject, ['contents'], tContents(apiClient, fromContents));
|
|
5801
|
+
});
|
|
6091
5802
|
}
|
|
5803
|
+
setValueByPath(toObject, ['contents'], transformedList);
|
|
6092
5804
|
}
|
|
6093
5805
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
6094
5806
|
if (fromConfig != null) {
|
|
@@ -6250,6 +5962,42 @@ function getModelParametersToVertex(apiClient, fromObject) {
|
|
|
6250
5962
|
}
|
|
6251
5963
|
return toObject;
|
|
6252
5964
|
}
|
|
5965
|
+
function updateModelConfigToVertex(apiClient, fromObject, parentObject) {
|
|
5966
|
+
const toObject = {};
|
|
5967
|
+
const fromDisplayName = getValueByPath(fromObject, ['displayName']);
|
|
5968
|
+
if (parentObject !== undefined && fromDisplayName != null) {
|
|
5969
|
+
setValueByPath(parentObject, ['displayName'], fromDisplayName);
|
|
5970
|
+
}
|
|
5971
|
+
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
5972
|
+
if (parentObject !== undefined && fromDescription != null) {
|
|
5973
|
+
setValueByPath(parentObject, ['description'], fromDescription);
|
|
5974
|
+
}
|
|
5975
|
+
return toObject;
|
|
5976
|
+
}
|
|
5977
|
+
function updateModelParametersToVertex(apiClient, fromObject) {
|
|
5978
|
+
const toObject = {};
|
|
5979
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
5980
|
+
if (fromModel != null) {
|
|
5981
|
+
setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
|
|
5982
|
+
}
|
|
5983
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
5984
|
+
if (fromConfig != null) {
|
|
5985
|
+
setValueByPath(toObject, ['config'], updateModelConfigToVertex(apiClient, fromConfig, toObject));
|
|
5986
|
+
}
|
|
5987
|
+
return toObject;
|
|
5988
|
+
}
|
|
5989
|
+
function deleteModelParametersToVertex(apiClient, fromObject) {
|
|
5990
|
+
const toObject = {};
|
|
5991
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
5992
|
+
if (fromModel != null) {
|
|
5993
|
+
setValueByPath(toObject, ['_url', 'name'], tModel(apiClient, fromModel));
|
|
5994
|
+
}
|
|
5995
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
5996
|
+
if (fromConfig != null) {
|
|
5997
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
5998
|
+
}
|
|
5999
|
+
return toObject;
|
|
6000
|
+
}
|
|
6253
6001
|
function countTokensConfigToVertex(apiClient, fromObject, parentObject) {
|
|
6254
6002
|
const toObject = {};
|
|
6255
6003
|
const fromSystemInstruction = getValueByPath(fromObject, [
|
|
@@ -6260,14 +6008,13 @@ function countTokensConfigToVertex(apiClient, fromObject, parentObject) {
|
|
|
6260
6008
|
}
|
|
6261
6009
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
6262
6010
|
if (parentObject !== undefined && fromTools != null) {
|
|
6263
|
-
|
|
6264
|
-
|
|
6011
|
+
let transformedList = fromTools;
|
|
6012
|
+
if (Array.isArray(transformedList)) {
|
|
6013
|
+
transformedList = transformedList.map((item) => {
|
|
6265
6014
|
return toolToVertex(apiClient, item);
|
|
6266
|
-
})
|
|
6267
|
-
}
|
|
6268
|
-
else {
|
|
6269
|
-
setValueByPath(parentObject, ['tools'], fromTools);
|
|
6015
|
+
});
|
|
6270
6016
|
}
|
|
6017
|
+
setValueByPath(parentObject, ['tools'], transformedList);
|
|
6271
6018
|
}
|
|
6272
6019
|
const fromGenerationConfig = getValueByPath(fromObject, [
|
|
6273
6020
|
'generationConfig',
|
|
@@ -6285,14 +6032,13 @@ function countTokensParametersToVertex(apiClient, fromObject) {
|
|
|
6285
6032
|
}
|
|
6286
6033
|
const fromContents = getValueByPath(fromObject, ['contents']);
|
|
6287
6034
|
if (fromContents != null) {
|
|
6288
|
-
|
|
6289
|
-
|
|
6035
|
+
let transformedList = tContents(apiClient, fromContents);
|
|
6036
|
+
if (Array.isArray(transformedList)) {
|
|
6037
|
+
transformedList = transformedList.map((item) => {
|
|
6290
6038
|
return contentToVertex(apiClient, item);
|
|
6291
|
-
})
|
|
6292
|
-
}
|
|
6293
|
-
else {
|
|
6294
|
-
setValueByPath(toObject, ['contents'], tContents(apiClient, fromContents));
|
|
6039
|
+
});
|
|
6295
6040
|
}
|
|
6041
|
+
setValueByPath(toObject, ['contents'], transformedList);
|
|
6296
6042
|
}
|
|
6297
6043
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
6298
6044
|
if (fromConfig != null) {
|
|
@@ -6308,14 +6054,13 @@ function computeTokensParametersToVertex(apiClient, fromObject) {
|
|
|
6308
6054
|
}
|
|
6309
6055
|
const fromContents = getValueByPath(fromObject, ['contents']);
|
|
6310
6056
|
if (fromContents != null) {
|
|
6311
|
-
|
|
6312
|
-
|
|
6057
|
+
let transformedList = tContents(apiClient, fromContents);
|
|
6058
|
+
if (Array.isArray(transformedList)) {
|
|
6059
|
+
transformedList = transformedList.map((item) => {
|
|
6313
6060
|
return contentToVertex(apiClient, item);
|
|
6314
|
-
})
|
|
6315
|
-
}
|
|
6316
|
-
else {
|
|
6317
|
-
setValueByPath(toObject, ['contents'], tContents(apiClient, fromContents));
|
|
6061
|
+
});
|
|
6318
6062
|
}
|
|
6063
|
+
setValueByPath(toObject, ['contents'], transformedList);
|
|
6319
6064
|
}
|
|
6320
6065
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
6321
6066
|
if (fromConfig != null) {
|
|
@@ -6463,14 +6208,13 @@ function contentFromMldev(apiClient, fromObject) {
|
|
|
6463
6208
|
const toObject = {};
|
|
6464
6209
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
6465
6210
|
if (fromParts != null) {
|
|
6466
|
-
|
|
6467
|
-
|
|
6211
|
+
let transformedList = fromParts;
|
|
6212
|
+
if (Array.isArray(transformedList)) {
|
|
6213
|
+
transformedList = transformedList.map((item) => {
|
|
6468
6214
|
return partFromMldev(apiClient, item);
|
|
6469
|
-
})
|
|
6470
|
-
}
|
|
6471
|
-
else {
|
|
6472
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
6215
|
+
});
|
|
6473
6216
|
}
|
|
6217
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
6474
6218
|
}
|
|
6475
6219
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
6476
6220
|
if (fromRole != null) {
|
|
@@ -6538,14 +6282,13 @@ function generateContentResponseFromMldev(apiClient, fromObject) {
|
|
|
6538
6282
|
const toObject = {};
|
|
6539
6283
|
const fromCandidates = getValueByPath(fromObject, ['candidates']);
|
|
6540
6284
|
if (fromCandidates != null) {
|
|
6541
|
-
|
|
6542
|
-
|
|
6285
|
+
let transformedList = fromCandidates;
|
|
6286
|
+
if (Array.isArray(transformedList)) {
|
|
6287
|
+
transformedList = transformedList.map((item) => {
|
|
6543
6288
|
return candidateFromMldev(apiClient, item);
|
|
6544
|
-
})
|
|
6545
|
-
}
|
|
6546
|
-
else {
|
|
6547
|
-
setValueByPath(toObject, ['candidates'], fromCandidates);
|
|
6289
|
+
});
|
|
6548
6290
|
}
|
|
6291
|
+
setValueByPath(toObject, ['candidates'], transformedList);
|
|
6549
6292
|
}
|
|
6550
6293
|
const fromModelVersion = getValueByPath(fromObject, ['modelVersion']);
|
|
6551
6294
|
if (fromModelVersion != null) {
|
|
@@ -6581,14 +6324,13 @@ function embedContentResponseFromMldev(apiClient, fromObject) {
|
|
|
6581
6324
|
const toObject = {};
|
|
6582
6325
|
const fromEmbeddings = getValueByPath(fromObject, ['embeddings']);
|
|
6583
6326
|
if (fromEmbeddings != null) {
|
|
6584
|
-
|
|
6585
|
-
|
|
6327
|
+
let transformedList = fromEmbeddings;
|
|
6328
|
+
if (Array.isArray(transformedList)) {
|
|
6329
|
+
transformedList = transformedList.map((item) => {
|
|
6586
6330
|
return contentEmbeddingFromMldev(apiClient, item);
|
|
6587
|
-
})
|
|
6588
|
-
}
|
|
6589
|
-
else {
|
|
6590
|
-
setValueByPath(toObject, ['embeddings'], fromEmbeddings);
|
|
6331
|
+
});
|
|
6591
6332
|
}
|
|
6333
|
+
setValueByPath(toObject, ['embeddings'], transformedList);
|
|
6592
6334
|
}
|
|
6593
6335
|
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
6594
6336
|
if (fromMetadata != null) {
|
|
@@ -6656,14 +6398,13 @@ function generateImagesResponseFromMldev(apiClient, fromObject) {
|
|
|
6656
6398
|
'predictions',
|
|
6657
6399
|
]);
|
|
6658
6400
|
if (fromGeneratedImages != null) {
|
|
6659
|
-
|
|
6660
|
-
|
|
6401
|
+
let transformedList = fromGeneratedImages;
|
|
6402
|
+
if (Array.isArray(transformedList)) {
|
|
6403
|
+
transformedList = transformedList.map((item) => {
|
|
6661
6404
|
return generatedImageFromMldev(apiClient, item);
|
|
6662
|
-
})
|
|
6663
|
-
}
|
|
6664
|
-
else {
|
|
6665
|
-
setValueByPath(toObject, ['generatedImages'], fromGeneratedImages);
|
|
6405
|
+
});
|
|
6666
6406
|
}
|
|
6407
|
+
setValueByPath(toObject, ['generatedImages'], transformedList);
|
|
6667
6408
|
}
|
|
6668
6409
|
const fromPositivePromptSafetyAttributes = getValueByPath(fromObject, [
|
|
6669
6410
|
'positivePromptSafetyAttributes',
|
|
@@ -6731,6 +6472,10 @@ function modelFromMldev(apiClient, fromObject) {
|
|
|
6731
6472
|
}
|
|
6732
6473
|
return toObject;
|
|
6733
6474
|
}
|
|
6475
|
+
function deleteModelResponseFromMldev() {
|
|
6476
|
+
const toObject = {};
|
|
6477
|
+
return toObject;
|
|
6478
|
+
}
|
|
6734
6479
|
function countTokensResponseFromMldev(apiClient, fromObject) {
|
|
6735
6480
|
const toObject = {};
|
|
6736
6481
|
const fromTotalTokens = getValueByPath(fromObject, ['totalTokens']);
|
|
@@ -6778,14 +6523,13 @@ function generateVideosResponseFromMldev$1(apiClient, fromObject) {
|
|
|
6778
6523
|
'generatedSamples',
|
|
6779
6524
|
]);
|
|
6780
6525
|
if (fromGeneratedVideos != null) {
|
|
6781
|
-
|
|
6782
|
-
|
|
6526
|
+
let transformedList = fromGeneratedVideos;
|
|
6527
|
+
if (Array.isArray(transformedList)) {
|
|
6528
|
+
transformedList = transformedList.map((item) => {
|
|
6783
6529
|
return generatedVideoFromMldev$1(apiClient, item);
|
|
6784
|
-
})
|
|
6785
|
-
}
|
|
6786
|
-
else {
|
|
6787
|
-
setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos);
|
|
6530
|
+
});
|
|
6788
6531
|
}
|
|
6532
|
+
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
6789
6533
|
}
|
|
6790
6534
|
const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
|
|
6791
6535
|
'raiMediaFilteredCount',
|
|
@@ -6880,14 +6624,13 @@ function contentFromVertex(apiClient, fromObject) {
|
|
|
6880
6624
|
const toObject = {};
|
|
6881
6625
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
6882
6626
|
if (fromParts != null) {
|
|
6883
|
-
|
|
6884
|
-
|
|
6627
|
+
let transformedList = fromParts;
|
|
6628
|
+
if (Array.isArray(transformedList)) {
|
|
6629
|
+
transformedList = transformedList.map((item) => {
|
|
6885
6630
|
return partFromVertex(apiClient, item);
|
|
6886
|
-
})
|
|
6887
|
-
}
|
|
6888
|
-
else {
|
|
6889
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
6631
|
+
});
|
|
6890
6632
|
}
|
|
6633
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
6891
6634
|
}
|
|
6892
6635
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
6893
6636
|
if (fromRole != null) {
|
|
@@ -6957,14 +6700,13 @@ function generateContentResponseFromVertex(apiClient, fromObject) {
|
|
|
6957
6700
|
const toObject = {};
|
|
6958
6701
|
const fromCandidates = getValueByPath(fromObject, ['candidates']);
|
|
6959
6702
|
if (fromCandidates != null) {
|
|
6960
|
-
|
|
6961
|
-
|
|
6703
|
+
let transformedList = fromCandidates;
|
|
6704
|
+
if (Array.isArray(transformedList)) {
|
|
6705
|
+
transformedList = transformedList.map((item) => {
|
|
6962
6706
|
return candidateFromVertex(apiClient, item);
|
|
6963
|
-
})
|
|
6964
|
-
}
|
|
6965
|
-
else {
|
|
6966
|
-
setValueByPath(toObject, ['candidates'], fromCandidates);
|
|
6707
|
+
});
|
|
6967
6708
|
}
|
|
6709
|
+
setValueByPath(toObject, ['candidates'], transformedList);
|
|
6968
6710
|
}
|
|
6969
6711
|
const fromCreateTime = getValueByPath(fromObject, ['createTime']);
|
|
6970
6712
|
if (fromCreateTime != null) {
|
|
@@ -7033,14 +6775,13 @@ function embedContentResponseFromVertex(apiClient, fromObject) {
|
|
|
7033
6775
|
'embeddings',
|
|
7034
6776
|
]);
|
|
7035
6777
|
if (fromEmbeddings != null) {
|
|
7036
|
-
|
|
7037
|
-
|
|
6778
|
+
let transformedList = fromEmbeddings;
|
|
6779
|
+
if (Array.isArray(transformedList)) {
|
|
6780
|
+
transformedList = transformedList.map((item) => {
|
|
7038
6781
|
return contentEmbeddingFromVertex(apiClient, item);
|
|
7039
|
-
})
|
|
7040
|
-
}
|
|
7041
|
-
else {
|
|
7042
|
-
setValueByPath(toObject, ['embeddings'], fromEmbeddings);
|
|
6782
|
+
});
|
|
7043
6783
|
}
|
|
6784
|
+
setValueByPath(toObject, ['embeddings'], transformedList);
|
|
7044
6785
|
}
|
|
7045
6786
|
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
7046
6787
|
if (fromMetadata != null) {
|
|
@@ -7116,14 +6857,13 @@ function generateImagesResponseFromVertex(apiClient, fromObject) {
|
|
|
7116
6857
|
'predictions',
|
|
7117
6858
|
]);
|
|
7118
6859
|
if (fromGeneratedImages != null) {
|
|
7119
|
-
|
|
7120
|
-
|
|
6860
|
+
let transformedList = fromGeneratedImages;
|
|
6861
|
+
if (Array.isArray(transformedList)) {
|
|
6862
|
+
transformedList = transformedList.map((item) => {
|
|
7121
6863
|
return generatedImageFromVertex(apiClient, item);
|
|
7122
|
-
})
|
|
7123
|
-
}
|
|
7124
|
-
else {
|
|
7125
|
-
setValueByPath(toObject, ['generatedImages'], fromGeneratedImages);
|
|
6864
|
+
});
|
|
7126
6865
|
}
|
|
6866
|
+
setValueByPath(toObject, ['generatedImages'], transformedList);
|
|
7127
6867
|
}
|
|
7128
6868
|
const fromPositivePromptSafetyAttributes = getValueByPath(fromObject, [
|
|
7129
6869
|
'positivePromptSafetyAttributes',
|
|
@@ -7186,14 +6926,13 @@ function modelFromVertex(apiClient, fromObject) {
|
|
|
7186
6926
|
}
|
|
7187
6927
|
const fromEndpoints = getValueByPath(fromObject, ['deployedModels']);
|
|
7188
6928
|
if (fromEndpoints != null) {
|
|
7189
|
-
|
|
7190
|
-
|
|
6929
|
+
let transformedList = fromEndpoints;
|
|
6930
|
+
if (Array.isArray(transformedList)) {
|
|
6931
|
+
transformedList = transformedList.map((item) => {
|
|
7191
6932
|
return endpointFromVertex(apiClient, item);
|
|
7192
|
-
})
|
|
7193
|
-
}
|
|
7194
|
-
else {
|
|
7195
|
-
setValueByPath(toObject, ['endpoints'], fromEndpoints);
|
|
6933
|
+
});
|
|
7196
6934
|
}
|
|
6935
|
+
setValueByPath(toObject, ['endpoints'], transformedList);
|
|
7197
6936
|
}
|
|
7198
6937
|
const fromLabels = getValueByPath(fromObject, ['labels']);
|
|
7199
6938
|
if (fromLabels != null) {
|
|
@@ -7205,6 +6944,10 @@ function modelFromVertex(apiClient, fromObject) {
|
|
|
7205
6944
|
}
|
|
7206
6945
|
return toObject;
|
|
7207
6946
|
}
|
|
6947
|
+
function deleteModelResponseFromVertex() {
|
|
6948
|
+
const toObject = {};
|
|
6949
|
+
return toObject;
|
|
6950
|
+
}
|
|
7208
6951
|
function countTokensResponseFromVertex(apiClient, fromObject) {
|
|
7209
6952
|
const toObject = {};
|
|
7210
6953
|
const fromTotalTokens = getValueByPath(fromObject, ['totalTokens']);
|
|
@@ -7251,14 +6994,13 @@ function generateVideosResponseFromVertex$1(apiClient, fromObject) {
|
|
|
7251
6994
|
const toObject = {};
|
|
7252
6995
|
const fromGeneratedVideos = getValueByPath(fromObject, ['videos']);
|
|
7253
6996
|
if (fromGeneratedVideos != null) {
|
|
7254
|
-
|
|
7255
|
-
|
|
6997
|
+
let transformedList = fromGeneratedVideos;
|
|
6998
|
+
if (Array.isArray(transformedList)) {
|
|
6999
|
+
transformedList = transformedList.map((item) => {
|
|
7256
7000
|
return generatedVideoFromVertex$1(apiClient, item);
|
|
7257
|
-
})
|
|
7258
|
-
}
|
|
7259
|
-
else {
|
|
7260
|
-
setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos);
|
|
7001
|
+
});
|
|
7261
7002
|
}
|
|
7003
|
+
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
7262
7004
|
}
|
|
7263
7005
|
const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
|
|
7264
7006
|
'raiMediaFilteredCount',
|
|
@@ -7502,21 +7244,6 @@ class Session {
|
|
|
7502
7244
|
clientContent: { turnComplete: params.turnComplete },
|
|
7503
7245
|
};
|
|
7504
7246
|
}
|
|
7505
|
-
tLiveClientRealtimeInput(apiClient, params) {
|
|
7506
|
-
let clientMessage = {};
|
|
7507
|
-
if (!('media' in params) || !params.media) {
|
|
7508
|
-
throw new Error(`Failed to convert realtime input "media", type: '${typeof params.media}'`);
|
|
7509
|
-
}
|
|
7510
|
-
// LiveClientRealtimeInput
|
|
7511
|
-
clientMessage = {
|
|
7512
|
-
realtimeInput: {
|
|
7513
|
-
mediaChunks: [params.media],
|
|
7514
|
-
activityStart: params.activityStart,
|
|
7515
|
-
activityEnd: params.activityEnd,
|
|
7516
|
-
},
|
|
7517
|
-
};
|
|
7518
|
-
return clientMessage;
|
|
7519
|
-
}
|
|
7520
7247
|
tLiveClienttToolResponse(apiClient, params) {
|
|
7521
7248
|
let functionResponses = [];
|
|
7522
7249
|
if (params.functionResponses == null) {
|
|
@@ -7624,10 +7351,17 @@ class Session {
|
|
|
7624
7351
|
of audio and image mimetypes are allowed.
|
|
7625
7352
|
*/
|
|
7626
7353
|
sendRealtimeInput(params) {
|
|
7627
|
-
|
|
7628
|
-
|
|
7354
|
+
let clientMessage = {};
|
|
7355
|
+
if (this.apiClient.isVertexAI()) {
|
|
7356
|
+
clientMessage = {
|
|
7357
|
+
'realtimeInput': liveSendRealtimeInputParametersToVertex(this.apiClient, params),
|
|
7358
|
+
};
|
|
7359
|
+
}
|
|
7360
|
+
else {
|
|
7361
|
+
clientMessage = {
|
|
7362
|
+
'realtimeInput': liveSendRealtimeInputParametersToMldev(this.apiClient, params),
|
|
7363
|
+
};
|
|
7629
7364
|
}
|
|
7630
|
-
const clientMessage = this.tLiveClientRealtimeInput(this.apiClient, params);
|
|
7631
7365
|
this.conn.send(JSON.stringify(clientMessage));
|
|
7632
7366
|
}
|
|
7633
7367
|
/**
|
|
@@ -7848,7 +7582,7 @@ class Models extends BaseModule {
|
|
|
7848
7582
|
};
|
|
7849
7583
|
}
|
|
7850
7584
|
async generateContentInternal(params) {
|
|
7851
|
-
var _a, _b;
|
|
7585
|
+
var _a, _b, _c, _d;
|
|
7852
7586
|
let response;
|
|
7853
7587
|
let path = '';
|
|
7854
7588
|
let queryParams = {};
|
|
@@ -7866,6 +7600,7 @@ class Models extends BaseModule {
|
|
|
7866
7600
|
body: JSON.stringify(body),
|
|
7867
7601
|
httpMethod: 'POST',
|
|
7868
7602
|
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
7603
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
7869
7604
|
})
|
|
7870
7605
|
.then((httpResponse) => {
|
|
7871
7606
|
return httpResponse.json();
|
|
@@ -7890,7 +7625,8 @@ class Models extends BaseModule {
|
|
|
7890
7625
|
queryParams: queryParams,
|
|
7891
7626
|
body: JSON.stringify(body),
|
|
7892
7627
|
httpMethod: 'POST',
|
|
7893
|
-
httpOptions: (
|
|
7628
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
7629
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
7894
7630
|
})
|
|
7895
7631
|
.then((httpResponse) => {
|
|
7896
7632
|
return httpResponse.json();
|
|
@@ -7904,7 +7640,7 @@ class Models extends BaseModule {
|
|
|
7904
7640
|
}
|
|
7905
7641
|
}
|
|
7906
7642
|
async generateContentStreamInternal(params) {
|
|
7907
|
-
var _a, _b;
|
|
7643
|
+
var _a, _b, _c, _d;
|
|
7908
7644
|
let response;
|
|
7909
7645
|
let path = '';
|
|
7910
7646
|
let queryParams = {};
|
|
@@ -7922,6 +7658,7 @@ class Models extends BaseModule {
|
|
|
7922
7658
|
body: JSON.stringify(body),
|
|
7923
7659
|
httpMethod: 'POST',
|
|
7924
7660
|
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
7661
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
7925
7662
|
});
|
|
7926
7663
|
return response.then(function (apiResponse) {
|
|
7927
7664
|
return __asyncGenerator(this, arguments, function* () {
|
|
@@ -7960,7 +7697,8 @@ class Models extends BaseModule {
|
|
|
7960
7697
|
queryParams: queryParams,
|
|
7961
7698
|
body: JSON.stringify(body),
|
|
7962
7699
|
httpMethod: 'POST',
|
|
7963
|
-
httpOptions: (
|
|
7700
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
7701
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
7964
7702
|
});
|
|
7965
7703
|
return response.then(function (apiResponse) {
|
|
7966
7704
|
return __asyncGenerator(this, arguments, function* () {
|
|
@@ -8009,7 +7747,7 @@ class Models extends BaseModule {
|
|
|
8009
7747
|
* ```
|
|
8010
7748
|
*/
|
|
8011
7749
|
async embedContent(params) {
|
|
8012
|
-
var _a, _b;
|
|
7750
|
+
var _a, _b, _c, _d;
|
|
8013
7751
|
let response;
|
|
8014
7752
|
let path = '';
|
|
8015
7753
|
let queryParams = {};
|
|
@@ -8027,6 +7765,7 @@ class Models extends BaseModule {
|
|
|
8027
7765
|
body: JSON.stringify(body),
|
|
8028
7766
|
httpMethod: 'POST',
|
|
8029
7767
|
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
7768
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
8030
7769
|
})
|
|
8031
7770
|
.then((httpResponse) => {
|
|
8032
7771
|
return httpResponse.json();
|
|
@@ -8051,7 +7790,8 @@ class Models extends BaseModule {
|
|
|
8051
7790
|
queryParams: queryParams,
|
|
8052
7791
|
body: JSON.stringify(body),
|
|
8053
7792
|
httpMethod: 'POST',
|
|
8054
|
-
httpOptions: (
|
|
7793
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
7794
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
8055
7795
|
})
|
|
8056
7796
|
.then((httpResponse) => {
|
|
8057
7797
|
return httpResponse.json();
|
|
@@ -8084,7 +7824,7 @@ class Models extends BaseModule {
|
|
|
8084
7824
|
* ```
|
|
8085
7825
|
*/
|
|
8086
7826
|
async generateImagesInternal(params) {
|
|
8087
|
-
var _a, _b;
|
|
7827
|
+
var _a, _b, _c, _d;
|
|
8088
7828
|
let response;
|
|
8089
7829
|
let path = '';
|
|
8090
7830
|
let queryParams = {};
|
|
@@ -8102,6 +7842,7 @@ class Models extends BaseModule {
|
|
|
8102
7842
|
body: JSON.stringify(body),
|
|
8103
7843
|
httpMethod: 'POST',
|
|
8104
7844
|
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
7845
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
8105
7846
|
})
|
|
8106
7847
|
.then((httpResponse) => {
|
|
8107
7848
|
return httpResponse.json();
|
|
@@ -8126,7 +7867,8 @@ class Models extends BaseModule {
|
|
|
8126
7867
|
queryParams: queryParams,
|
|
8127
7868
|
body: JSON.stringify(body),
|
|
8128
7869
|
httpMethod: 'POST',
|
|
8129
|
-
httpOptions: (
|
|
7870
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
7871
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
8130
7872
|
})
|
|
8131
7873
|
.then((httpResponse) => {
|
|
8132
7874
|
return httpResponse.json();
|
|
@@ -8148,7 +7890,7 @@ class Models extends BaseModule {
|
|
|
8148
7890
|
* ```
|
|
8149
7891
|
*/
|
|
8150
7892
|
async get(params) {
|
|
8151
|
-
var _a, _b;
|
|
7893
|
+
var _a, _b, _c, _d;
|
|
8152
7894
|
let response;
|
|
8153
7895
|
let path = '';
|
|
8154
7896
|
let queryParams = {};
|
|
@@ -8166,6 +7908,7 @@ class Models extends BaseModule {
|
|
|
8166
7908
|
body: JSON.stringify(body),
|
|
8167
7909
|
httpMethod: 'GET',
|
|
8168
7910
|
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
7911
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
8169
7912
|
})
|
|
8170
7913
|
.then((httpResponse) => {
|
|
8171
7914
|
return httpResponse.json();
|
|
@@ -8188,7 +7931,8 @@ class Models extends BaseModule {
|
|
|
8188
7931
|
queryParams: queryParams,
|
|
8189
7932
|
body: JSON.stringify(body),
|
|
8190
7933
|
httpMethod: 'GET',
|
|
8191
|
-
httpOptions: (
|
|
7934
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
7935
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
8192
7936
|
})
|
|
8193
7937
|
.then((httpResponse) => {
|
|
8194
7938
|
return httpResponse.json();
|
|
@@ -8200,29 +7944,30 @@ class Models extends BaseModule {
|
|
|
8200
7944
|
}
|
|
8201
7945
|
}
|
|
8202
7946
|
/**
|
|
8203
|
-
*
|
|
8204
|
-
* supported for Gemini models.
|
|
7947
|
+
* Updates a tuned model by its name.
|
|
8205
7948
|
*
|
|
8206
|
-
* @param params - The parameters for
|
|
7949
|
+
* @param params - The parameters for updating the model.
|
|
8207
7950
|
* @return The response from the API.
|
|
8208
7951
|
*
|
|
8209
7952
|
* @example
|
|
8210
7953
|
* ```ts
|
|
8211
|
-
* const response = await ai.models.
|
|
8212
|
-
*
|
|
8213
|
-
*
|
|
7954
|
+
* const response = await ai.models.update({
|
|
7955
|
+
* model: 'tuned-model-name',
|
|
7956
|
+
* config: {
|
|
7957
|
+
* displayName: 'New display name',
|
|
7958
|
+
* description: 'New description',
|
|
7959
|
+
* },
|
|
8214
7960
|
* });
|
|
8215
|
-
* console.log(response);
|
|
8216
7961
|
* ```
|
|
8217
7962
|
*/
|
|
8218
|
-
async
|
|
8219
|
-
var _a, _b;
|
|
7963
|
+
async update(params) {
|
|
7964
|
+
var _a, _b, _c, _d;
|
|
8220
7965
|
let response;
|
|
8221
7966
|
let path = '';
|
|
8222
7967
|
let queryParams = {};
|
|
8223
7968
|
if (this.apiClient.isVertexAI()) {
|
|
8224
|
-
const body =
|
|
8225
|
-
path = formatMap('{model}
|
|
7969
|
+
const body = updateModelParametersToVertex(this.apiClient, params);
|
|
7970
|
+
path = formatMap('{model}', body['_url']);
|
|
8226
7971
|
queryParams = body['_query'];
|
|
8227
7972
|
delete body['config'];
|
|
8228
7973
|
delete body['_url'];
|
|
@@ -8232,22 +7977,21 @@ class Models extends BaseModule {
|
|
|
8232
7977
|
path: path,
|
|
8233
7978
|
queryParams: queryParams,
|
|
8234
7979
|
body: JSON.stringify(body),
|
|
8235
|
-
httpMethod: '
|
|
7980
|
+
httpMethod: 'PATCH',
|
|
8236
7981
|
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
7982
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
8237
7983
|
})
|
|
8238
7984
|
.then((httpResponse) => {
|
|
8239
7985
|
return httpResponse.json();
|
|
8240
7986
|
});
|
|
8241
7987
|
return response.then((apiResponse) => {
|
|
8242
|
-
const resp =
|
|
8243
|
-
|
|
8244
|
-
Object.assign(typedResp, resp);
|
|
8245
|
-
return typedResp;
|
|
7988
|
+
const resp = modelFromVertex(this.apiClient, apiResponse);
|
|
7989
|
+
return resp;
|
|
8246
7990
|
});
|
|
8247
7991
|
}
|
|
8248
7992
|
else {
|
|
8249
|
-
const body =
|
|
8250
|
-
path = formatMap('{
|
|
7993
|
+
const body = updateModelParametersToMldev(this.apiClient, params);
|
|
7994
|
+
path = formatMap('{name}', body['_url']);
|
|
8251
7995
|
queryParams = body['_query'];
|
|
8252
7996
|
delete body['config'];
|
|
8253
7997
|
delete body['_url'];
|
|
@@ -8257,40 +8001,182 @@ class Models extends BaseModule {
|
|
|
8257
8001
|
path: path,
|
|
8258
8002
|
queryParams: queryParams,
|
|
8259
8003
|
body: JSON.stringify(body),
|
|
8260
|
-
httpMethod: '
|
|
8261
|
-
httpOptions: (
|
|
8004
|
+
httpMethod: 'PATCH',
|
|
8005
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
8006
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
8262
8007
|
})
|
|
8263
8008
|
.then((httpResponse) => {
|
|
8264
8009
|
return httpResponse.json();
|
|
8265
8010
|
});
|
|
8266
8011
|
return response.then((apiResponse) => {
|
|
8267
|
-
const resp =
|
|
8268
|
-
|
|
8269
|
-
Object.assign(typedResp, resp);
|
|
8270
|
-
return typedResp;
|
|
8012
|
+
const resp = modelFromMldev(this.apiClient, apiResponse);
|
|
8013
|
+
return resp;
|
|
8271
8014
|
});
|
|
8272
8015
|
}
|
|
8273
8016
|
}
|
|
8274
8017
|
/**
|
|
8275
|
-
*
|
|
8276
|
-
* the list of tokens and list of token ids.
|
|
8018
|
+
* Deletes a tuned model by its name.
|
|
8277
8019
|
*
|
|
8278
|
-
*
|
|
8279
|
-
*
|
|
8280
|
-
* @param params - The parameters for computing tokens.
|
|
8020
|
+
* @param params - The parameters for deleting the model.
|
|
8281
8021
|
* @return The response from the API.
|
|
8282
8022
|
*
|
|
8283
8023
|
* @example
|
|
8284
8024
|
* ```ts
|
|
8285
|
-
* const response = await ai.models.
|
|
8286
|
-
* model: 'gemini-2.0-flash',
|
|
8287
|
-
* contents: 'What is your name?'
|
|
8288
|
-
* });
|
|
8289
|
-
* console.log(response);
|
|
8025
|
+
* const response = await ai.models.delete({model: 'tuned-model-name'});
|
|
8290
8026
|
* ```
|
|
8291
8027
|
*/
|
|
8292
|
-
async
|
|
8293
|
-
var _a;
|
|
8028
|
+
async delete(params) {
|
|
8029
|
+
var _a, _b, _c, _d;
|
|
8030
|
+
let response;
|
|
8031
|
+
let path = '';
|
|
8032
|
+
let queryParams = {};
|
|
8033
|
+
if (this.apiClient.isVertexAI()) {
|
|
8034
|
+
const body = deleteModelParametersToVertex(this.apiClient, params);
|
|
8035
|
+
path = formatMap('{name}', body['_url']);
|
|
8036
|
+
queryParams = body['_query'];
|
|
8037
|
+
delete body['config'];
|
|
8038
|
+
delete body['_url'];
|
|
8039
|
+
delete body['_query'];
|
|
8040
|
+
response = this.apiClient
|
|
8041
|
+
.request({
|
|
8042
|
+
path: path,
|
|
8043
|
+
queryParams: queryParams,
|
|
8044
|
+
body: JSON.stringify(body),
|
|
8045
|
+
httpMethod: 'DELETE',
|
|
8046
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
8047
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
8048
|
+
})
|
|
8049
|
+
.then((httpResponse) => {
|
|
8050
|
+
return httpResponse.json();
|
|
8051
|
+
});
|
|
8052
|
+
return response.then(() => {
|
|
8053
|
+
const resp = deleteModelResponseFromVertex();
|
|
8054
|
+
const typedResp = new DeleteModelResponse();
|
|
8055
|
+
Object.assign(typedResp, resp);
|
|
8056
|
+
return typedResp;
|
|
8057
|
+
});
|
|
8058
|
+
}
|
|
8059
|
+
else {
|
|
8060
|
+
const body = deleteModelParametersToMldev(this.apiClient, params);
|
|
8061
|
+
path = formatMap('{name}', body['_url']);
|
|
8062
|
+
queryParams = body['_query'];
|
|
8063
|
+
delete body['config'];
|
|
8064
|
+
delete body['_url'];
|
|
8065
|
+
delete body['_query'];
|
|
8066
|
+
response = this.apiClient
|
|
8067
|
+
.request({
|
|
8068
|
+
path: path,
|
|
8069
|
+
queryParams: queryParams,
|
|
8070
|
+
body: JSON.stringify(body),
|
|
8071
|
+
httpMethod: 'DELETE',
|
|
8072
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
8073
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
8074
|
+
})
|
|
8075
|
+
.then((httpResponse) => {
|
|
8076
|
+
return httpResponse.json();
|
|
8077
|
+
});
|
|
8078
|
+
return response.then(() => {
|
|
8079
|
+
const resp = deleteModelResponseFromMldev();
|
|
8080
|
+
const typedResp = new DeleteModelResponse();
|
|
8081
|
+
Object.assign(typedResp, resp);
|
|
8082
|
+
return typedResp;
|
|
8083
|
+
});
|
|
8084
|
+
}
|
|
8085
|
+
}
|
|
8086
|
+
/**
|
|
8087
|
+
* Counts the number of tokens in the given contents. Multimodal input is
|
|
8088
|
+
* supported for Gemini models.
|
|
8089
|
+
*
|
|
8090
|
+
* @param params - The parameters for counting tokens.
|
|
8091
|
+
* @return The response from the API.
|
|
8092
|
+
*
|
|
8093
|
+
* @example
|
|
8094
|
+
* ```ts
|
|
8095
|
+
* const response = await ai.models.countTokens({
|
|
8096
|
+
* model: 'gemini-2.0-flash',
|
|
8097
|
+
* contents: 'The quick brown fox jumps over the lazy dog.'
|
|
8098
|
+
* });
|
|
8099
|
+
* console.log(response);
|
|
8100
|
+
* ```
|
|
8101
|
+
*/
|
|
8102
|
+
async countTokens(params) {
|
|
8103
|
+
var _a, _b, _c, _d;
|
|
8104
|
+
let response;
|
|
8105
|
+
let path = '';
|
|
8106
|
+
let queryParams = {};
|
|
8107
|
+
if (this.apiClient.isVertexAI()) {
|
|
8108
|
+
const body = countTokensParametersToVertex(this.apiClient, params);
|
|
8109
|
+
path = formatMap('{model}:countTokens', body['_url']);
|
|
8110
|
+
queryParams = body['_query'];
|
|
8111
|
+
delete body['config'];
|
|
8112
|
+
delete body['_url'];
|
|
8113
|
+
delete body['_query'];
|
|
8114
|
+
response = this.apiClient
|
|
8115
|
+
.request({
|
|
8116
|
+
path: path,
|
|
8117
|
+
queryParams: queryParams,
|
|
8118
|
+
body: JSON.stringify(body),
|
|
8119
|
+
httpMethod: 'POST',
|
|
8120
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
8121
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
8122
|
+
})
|
|
8123
|
+
.then((httpResponse) => {
|
|
8124
|
+
return httpResponse.json();
|
|
8125
|
+
});
|
|
8126
|
+
return response.then((apiResponse) => {
|
|
8127
|
+
const resp = countTokensResponseFromVertex(this.apiClient, apiResponse);
|
|
8128
|
+
const typedResp = new CountTokensResponse();
|
|
8129
|
+
Object.assign(typedResp, resp);
|
|
8130
|
+
return typedResp;
|
|
8131
|
+
});
|
|
8132
|
+
}
|
|
8133
|
+
else {
|
|
8134
|
+
const body = countTokensParametersToMldev(this.apiClient, params);
|
|
8135
|
+
path = formatMap('{model}:countTokens', body['_url']);
|
|
8136
|
+
queryParams = body['_query'];
|
|
8137
|
+
delete body['config'];
|
|
8138
|
+
delete body['_url'];
|
|
8139
|
+
delete body['_query'];
|
|
8140
|
+
response = this.apiClient
|
|
8141
|
+
.request({
|
|
8142
|
+
path: path,
|
|
8143
|
+
queryParams: queryParams,
|
|
8144
|
+
body: JSON.stringify(body),
|
|
8145
|
+
httpMethod: 'POST',
|
|
8146
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
8147
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
8148
|
+
})
|
|
8149
|
+
.then((httpResponse) => {
|
|
8150
|
+
return httpResponse.json();
|
|
8151
|
+
});
|
|
8152
|
+
return response.then((apiResponse) => {
|
|
8153
|
+
const resp = countTokensResponseFromMldev(this.apiClient, apiResponse);
|
|
8154
|
+
const typedResp = new CountTokensResponse();
|
|
8155
|
+
Object.assign(typedResp, resp);
|
|
8156
|
+
return typedResp;
|
|
8157
|
+
});
|
|
8158
|
+
}
|
|
8159
|
+
}
|
|
8160
|
+
/**
|
|
8161
|
+
* Given a list of contents, returns a corresponding TokensInfo containing
|
|
8162
|
+
* the list of tokens and list of token ids.
|
|
8163
|
+
*
|
|
8164
|
+
* This method is not supported by the Gemini Developer API.
|
|
8165
|
+
*
|
|
8166
|
+
* @param params - The parameters for computing tokens.
|
|
8167
|
+
* @return The response from the API.
|
|
8168
|
+
*
|
|
8169
|
+
* @example
|
|
8170
|
+
* ```ts
|
|
8171
|
+
* const response = await ai.models.computeTokens({
|
|
8172
|
+
* model: 'gemini-2.0-flash',
|
|
8173
|
+
* contents: 'What is your name?'
|
|
8174
|
+
* });
|
|
8175
|
+
* console.log(response);
|
|
8176
|
+
* ```
|
|
8177
|
+
*/
|
|
8178
|
+
async computeTokens(params) {
|
|
8179
|
+
var _a, _b;
|
|
8294
8180
|
let response;
|
|
8295
8181
|
let path = '';
|
|
8296
8182
|
let queryParams = {};
|
|
@@ -8308,6 +8194,7 @@ class Models extends BaseModule {
|
|
|
8308
8194
|
body: JSON.stringify(body),
|
|
8309
8195
|
httpMethod: 'POST',
|
|
8310
8196
|
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
8197
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
8311
8198
|
})
|
|
8312
8199
|
.then((httpResponse) => {
|
|
8313
8200
|
return httpResponse.json();
|
|
@@ -8347,7 +8234,7 @@ class Models extends BaseModule {
|
|
|
8347
8234
|
* ```
|
|
8348
8235
|
*/
|
|
8349
8236
|
async generateVideos(params) {
|
|
8350
|
-
var _a, _b;
|
|
8237
|
+
var _a, _b, _c, _d;
|
|
8351
8238
|
let response;
|
|
8352
8239
|
let path = '';
|
|
8353
8240
|
let queryParams = {};
|
|
@@ -8365,6 +8252,7 @@ class Models extends BaseModule {
|
|
|
8365
8252
|
body: JSON.stringify(body),
|
|
8366
8253
|
httpMethod: 'POST',
|
|
8367
8254
|
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
8255
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
8368
8256
|
})
|
|
8369
8257
|
.then((httpResponse) => {
|
|
8370
8258
|
return httpResponse.json();
|
|
@@ -8387,7 +8275,8 @@ class Models extends BaseModule {
|
|
|
8387
8275
|
queryParams: queryParams,
|
|
8388
8276
|
body: JSON.stringify(body),
|
|
8389
8277
|
httpMethod: 'POST',
|
|
8390
|
-
httpOptions: (
|
|
8278
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
8279
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
8391
8280
|
})
|
|
8392
8281
|
.then((httpResponse) => {
|
|
8393
8282
|
return httpResponse.json();
|
|
@@ -8484,14 +8373,13 @@ function generateVideosResponseFromMldev(apiClient, fromObject) {
|
|
|
8484
8373
|
'generatedSamples',
|
|
8485
8374
|
]);
|
|
8486
8375
|
if (fromGeneratedVideos != null) {
|
|
8487
|
-
|
|
8488
|
-
|
|
8376
|
+
let transformedList = fromGeneratedVideos;
|
|
8377
|
+
if (Array.isArray(transformedList)) {
|
|
8378
|
+
transformedList = transformedList.map((item) => {
|
|
8489
8379
|
return generatedVideoFromMldev(apiClient, item);
|
|
8490
|
-
})
|
|
8491
|
-
}
|
|
8492
|
-
else {
|
|
8493
|
-
setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos);
|
|
8380
|
+
});
|
|
8494
8381
|
}
|
|
8382
|
+
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
8495
8383
|
}
|
|
8496
8384
|
const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
|
|
8497
8385
|
'raiMediaFilteredCount',
|
|
@@ -8564,14 +8452,13 @@ function generateVideosResponseFromVertex(apiClient, fromObject) {
|
|
|
8564
8452
|
const toObject = {};
|
|
8565
8453
|
const fromGeneratedVideos = getValueByPath(fromObject, ['videos']);
|
|
8566
8454
|
if (fromGeneratedVideos != null) {
|
|
8567
|
-
|
|
8568
|
-
|
|
8455
|
+
let transformedList = fromGeneratedVideos;
|
|
8456
|
+
if (Array.isArray(transformedList)) {
|
|
8457
|
+
transformedList = transformedList.map((item) => {
|
|
8569
8458
|
return generatedVideoFromVertex(apiClient, item);
|
|
8570
|
-
})
|
|
8571
|
-
}
|
|
8572
|
-
else {
|
|
8573
|
-
setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos);
|
|
8459
|
+
});
|
|
8574
8460
|
}
|
|
8461
|
+
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
8575
8462
|
}
|
|
8576
8463
|
const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
|
|
8577
8464
|
'raiMediaFilteredCount',
|
|
@@ -8654,7 +8541,7 @@ class Operations extends BaseModule {
|
|
|
8654
8541
|
}
|
|
8655
8542
|
}
|
|
8656
8543
|
async getVideosOperationInternal(params) {
|
|
8657
|
-
var _a, _b;
|
|
8544
|
+
var _a, _b, _c, _d;
|
|
8658
8545
|
let response;
|
|
8659
8546
|
let path = '';
|
|
8660
8547
|
let queryParams = {};
|
|
@@ -8672,6 +8559,7 @@ class Operations extends BaseModule {
|
|
|
8672
8559
|
body: JSON.stringify(body),
|
|
8673
8560
|
httpMethod: 'GET',
|
|
8674
8561
|
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
8562
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
8675
8563
|
})
|
|
8676
8564
|
.then((httpResponse) => {
|
|
8677
8565
|
return httpResponse.json();
|
|
@@ -8694,7 +8582,8 @@ class Operations extends BaseModule {
|
|
|
8694
8582
|
queryParams: queryParams,
|
|
8695
8583
|
body: JSON.stringify(body),
|
|
8696
8584
|
httpMethod: 'GET',
|
|
8697
|
-
httpOptions: (
|
|
8585
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
8586
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
8698
8587
|
})
|
|
8699
8588
|
.then((httpResponse) => {
|
|
8700
8589
|
return httpResponse.json();
|
|
@@ -8706,7 +8595,7 @@ class Operations extends BaseModule {
|
|
|
8706
8595
|
}
|
|
8707
8596
|
}
|
|
8708
8597
|
async fetchPredictVideosOperationInternal(params) {
|
|
8709
|
-
var _a;
|
|
8598
|
+
var _a, _b;
|
|
8710
8599
|
let response;
|
|
8711
8600
|
let path = '';
|
|
8712
8601
|
let queryParams = {};
|
|
@@ -8724,6 +8613,7 @@ class Operations extends BaseModule {
|
|
|
8724
8613
|
body: JSON.stringify(body),
|
|
8725
8614
|
httpMethod: 'POST',
|
|
8726
8615
|
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
8616
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
8727
8617
|
})
|
|
8728
8618
|
.then((httpResponse) => {
|
|
8729
8619
|
return httpResponse.json();
|
|
@@ -8748,7 +8638,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
8748
8638
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
8749
8639
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
8750
8640
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
8751
|
-
const SDK_VERSION = '0.
|
|
8641
|
+
const SDK_VERSION = '0.11.0'; // x-release-please-version
|
|
8752
8642
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
8753
8643
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
8754
8644
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -8877,7 +8767,7 @@ class ApiClient {
|
|
|
8877
8767
|
getWebsocketBaseUrl() {
|
|
8878
8768
|
const baseUrl = this.getBaseUrl();
|
|
8879
8769
|
const urlParts = new URL(baseUrl);
|
|
8880
|
-
urlParts.protocol = 'wss';
|
|
8770
|
+
urlParts.protocol = urlParts.protocol == 'http:' ? 'ws' : 'wss';
|
|
8881
8771
|
return urlParts.toString();
|
|
8882
8772
|
}
|
|
8883
8773
|
setBaseUrl(url) {
|
|
@@ -8941,7 +8831,7 @@ class ApiClient {
|
|
|
8941
8831
|
else {
|
|
8942
8832
|
requestInit.body = request.body;
|
|
8943
8833
|
}
|
|
8944
|
-
requestInit = await this.includeExtraHttpOptionsToRequestInit(requestInit, patchedHttpOptions);
|
|
8834
|
+
requestInit = await this.includeExtraHttpOptionsToRequestInit(requestInit, patchedHttpOptions, request.abortSignal);
|
|
8945
8835
|
return this.unaryApiCall(url, requestInit, request.httpMethod);
|
|
8946
8836
|
}
|
|
8947
8837
|
patchHttpOptions(baseHttpOptions, requestHttpOptions) {
|
|
@@ -8975,14 +8865,21 @@ class ApiClient {
|
|
|
8975
8865
|
}
|
|
8976
8866
|
let requestInit = {};
|
|
8977
8867
|
requestInit.body = request.body;
|
|
8978
|
-
requestInit = await this.includeExtraHttpOptionsToRequestInit(requestInit, patchedHttpOptions);
|
|
8868
|
+
requestInit = await this.includeExtraHttpOptionsToRequestInit(requestInit, patchedHttpOptions, request.abortSignal);
|
|
8979
8869
|
return this.streamApiCall(url, requestInit, request.httpMethod);
|
|
8980
8870
|
}
|
|
8981
|
-
async includeExtraHttpOptionsToRequestInit(requestInit, httpOptions) {
|
|
8982
|
-
if (httpOptions && httpOptions.timeout
|
|
8871
|
+
async includeExtraHttpOptionsToRequestInit(requestInit, httpOptions, abortSignal) {
|
|
8872
|
+
if ((httpOptions && httpOptions.timeout) || abortSignal) {
|
|
8983
8873
|
const abortController = new AbortController();
|
|
8984
8874
|
const signal = abortController.signal;
|
|
8985
|
-
|
|
8875
|
+
if (httpOptions.timeout && (httpOptions === null || httpOptions === void 0 ? void 0 : httpOptions.timeout) > 0) {
|
|
8876
|
+
setTimeout(() => abortController.abort(), httpOptions.timeout);
|
|
8877
|
+
}
|
|
8878
|
+
if (abortSignal) {
|
|
8879
|
+
abortSignal.addEventListener('abort', () => {
|
|
8880
|
+
abortController.abort();
|
|
8881
|
+
});
|
|
8882
|
+
}
|
|
8986
8883
|
requestInit.signal = signal;
|
|
8987
8884
|
}
|
|
8988
8885
|
requestInit.headers = await this.getHeadersInternal(httpOptions);
|
|
@@ -9037,6 +8934,30 @@ class ApiClient {
|
|
|
9037
8934
|
break;
|
|
9038
8935
|
}
|
|
9039
8936
|
const chunkString = decoder.decode(value);
|
|
8937
|
+
// Parse and throw an error if the chunk contains an error.
|
|
8938
|
+
try {
|
|
8939
|
+
const chunkJson = JSON.parse(chunkString);
|
|
8940
|
+
if ('error' in chunkJson) {
|
|
8941
|
+
const errorJson = JSON.parse(JSON.stringify(chunkJson['error']));
|
|
8942
|
+
const status = errorJson['status'];
|
|
8943
|
+
const code = errorJson['code'];
|
|
8944
|
+
const errorMessage = `got status: ${status}. ${JSON.stringify(chunkJson)}`;
|
|
8945
|
+
if (code >= 400 && code < 500) {
|
|
8946
|
+
const clientError = new ClientError(errorMessage);
|
|
8947
|
+
throw clientError;
|
|
8948
|
+
}
|
|
8949
|
+
else if (code >= 500 && code < 600) {
|
|
8950
|
+
const serverError = new ServerError(errorMessage);
|
|
8951
|
+
throw serverError;
|
|
8952
|
+
}
|
|
8953
|
+
}
|
|
8954
|
+
}
|
|
8955
|
+
catch (e) {
|
|
8956
|
+
const error = e;
|
|
8957
|
+
if (error.name === 'ClientError' || error.name === 'ServerError') {
|
|
8958
|
+
throw e;
|
|
8959
|
+
}
|
|
8960
|
+
}
|
|
9040
8961
|
buffer += chunkString;
|
|
9041
8962
|
let match = buffer.match(responseLineRE);
|
|
9042
8963
|
while (match) {
|
|
@@ -9175,7 +9096,7 @@ async function throwErrorIfNotOK(response) {
|
|
|
9175
9096
|
else {
|
|
9176
9097
|
errorBody = {
|
|
9177
9098
|
error: {
|
|
9178
|
-
message:
|
|
9099
|
+
message: await response.text(),
|
|
9179
9100
|
code: response.status,
|
|
9180
9101
|
status: response.statusText,
|
|
9181
9102
|
},
|
|
@@ -9305,105 +9226,835 @@ class NodeWebSocket {
|
|
|
9305
9226
|
}
|
|
9306
9227
|
}
|
|
9307
9228
|
|
|
9308
|
-
const MAX_CHUNK_SIZE = 1024 * 1024 * 8; // bytes
|
|
9309
|
-
async function uploadBlob(file, uploadUrl, apiClient) {
|
|
9310
|
-
var _a, _b;
|
|
9311
|
-
let fileSize = 0;
|
|
9312
|
-
let offset = 0;
|
|
9313
|
-
let response = new HttpResponse(new Response());
|
|
9314
|
-
let uploadCommand = 'upload';
|
|
9315
|
-
fileSize = file.size;
|
|
9316
|
-
while (offset < fileSize) {
|
|
9317
|
-
const chunkSize = Math.min(MAX_CHUNK_SIZE, fileSize - offset);
|
|
9318
|
-
const chunk = file.slice(offset, offset + chunkSize);
|
|
9319
|
-
if (offset + chunkSize >= fileSize) {
|
|
9320
|
-
uploadCommand += ', finalize';
|
|
9321
|
-
}
|
|
9322
|
-
response = await apiClient.request({
|
|
9323
|
-
path: '',
|
|
9324
|
-
body: chunk,
|
|
9325
|
-
httpMethod: 'POST',
|
|
9326
|
-
httpOptions: {
|
|
9327
|
-
apiVersion: '',
|
|
9328
|
-
baseUrl: uploadUrl,
|
|
9329
|
-
headers: {
|
|
9330
|
-
'X-Goog-Upload-Command': uploadCommand,
|
|
9331
|
-
'X-Goog-Upload-Offset': String(offset),
|
|
9332
|
-
'Content-Length': String(chunkSize),
|
|
9333
|
-
},
|
|
9334
|
-
},
|
|
9335
|
-
});
|
|
9336
|
-
offset += chunkSize;
|
|
9337
|
-
// The `x-goog-upload-status` header field can be `active`, `final` and
|
|
9338
|
-
//`cancelled` in resposne.
|
|
9339
|
-
if (((_a = response === null || response === void 0 ? void 0 : response.headers) === null || _a === void 0 ? void 0 : _a['x-goog-upload-status']) !== 'active') {
|
|
9340
|
-
break;
|
|
9341
|
-
}
|
|
9342
|
-
// TODO(b/401391430) Investigate why the upload status is not finalized
|
|
9343
|
-
// even though all content has been uploaded.
|
|
9344
|
-
if (fileSize <= offset) {
|
|
9345
|
-
throw new Error('All content has been uploaded, but the upload status is not finalized.');
|
|
9346
|
-
}
|
|
9347
|
-
}
|
|
9348
|
-
const responseJson = (await (response === null || response === void 0 ? void 0 : response.json()));
|
|
9349
|
-
if (((_b = response === null || response === void 0 ? void 0 : response.headers) === null || _b === void 0 ? void 0 : _b['x-goog-upload-status']) !== 'final') {
|
|
9350
|
-
throw new Error('Failed to upload file: Upload status is not finalized.');
|
|
9351
|
-
}
|
|
9352
|
-
return responseJson['file'];
|
|
9353
|
-
}
|
|
9354
|
-
async function getBlobStat(file) {
|
|
9355
|
-
const fileStat = { size: file.size, type: file.type };
|
|
9356
|
-
return fileStat;
|
|
9357
|
-
}
|
|
9358
|
-
|
|
9359
9229
|
/**
|
|
9360
9230
|
* @license
|
|
9361
9231
|
* Copyright 2025 Google LLC
|
|
9362
9232
|
* SPDX-License-Identifier: Apache-2.0
|
|
9363
9233
|
*/
|
|
9364
|
-
|
|
9365
|
-
|
|
9366
|
-
|
|
9367
|
-
|
|
9368
|
-
|
|
9369
|
-
fileStat.size = originalStat.size;
|
|
9370
|
-
fileStat.type = this.inferMimeType(file);
|
|
9371
|
-
return fileStat;
|
|
9372
|
-
}
|
|
9373
|
-
else {
|
|
9374
|
-
return await getBlobStat(file);
|
|
9375
|
-
}
|
|
9234
|
+
function getTuningJobParametersToMldev(apiClient, fromObject) {
|
|
9235
|
+
const toObject = {};
|
|
9236
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
9237
|
+
if (fromName != null) {
|
|
9238
|
+
setValueByPath(toObject, ['_url', 'name'], fromName);
|
|
9376
9239
|
}
|
|
9377
|
-
|
|
9378
|
-
|
|
9379
|
-
|
|
9380
|
-
}
|
|
9381
|
-
else {
|
|
9382
|
-
return uploadBlob(file, uploadUrl, apiClient);
|
|
9383
|
-
}
|
|
9240
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
9241
|
+
if (fromConfig != null) {
|
|
9242
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
9384
9243
|
}
|
|
9385
|
-
|
|
9386
|
-
|
|
9387
|
-
|
|
9388
|
-
|
|
9389
|
-
|
|
9390
|
-
|
|
9391
|
-
|
|
9392
|
-
|
|
9393
|
-
|
|
9394
|
-
|
|
9395
|
-
|
|
9396
|
-
|
|
9397
|
-
|
|
9398
|
-
|
|
9399
|
-
|
|
9400
|
-
|
|
9401
|
-
|
|
9402
|
-
|
|
9403
|
-
|
|
9404
|
-
|
|
9405
|
-
|
|
9406
|
-
|
|
9244
|
+
return toObject;
|
|
9245
|
+
}
|
|
9246
|
+
function listTuningJobsConfigToMldev(apiClient, fromObject, parentObject) {
|
|
9247
|
+
const toObject = {};
|
|
9248
|
+
const fromPageSize = getValueByPath(fromObject, ['pageSize']);
|
|
9249
|
+
if (parentObject !== undefined && fromPageSize != null) {
|
|
9250
|
+
setValueByPath(parentObject, ['_query', 'pageSize'], fromPageSize);
|
|
9251
|
+
}
|
|
9252
|
+
const fromPageToken = getValueByPath(fromObject, ['pageToken']);
|
|
9253
|
+
if (parentObject !== undefined && fromPageToken != null) {
|
|
9254
|
+
setValueByPath(parentObject, ['_query', 'pageToken'], fromPageToken);
|
|
9255
|
+
}
|
|
9256
|
+
const fromFilter = getValueByPath(fromObject, ['filter']);
|
|
9257
|
+
if (parentObject !== undefined && fromFilter != null) {
|
|
9258
|
+
setValueByPath(parentObject, ['_query', 'filter'], fromFilter);
|
|
9259
|
+
}
|
|
9260
|
+
return toObject;
|
|
9261
|
+
}
|
|
9262
|
+
function listTuningJobsParametersToMldev(apiClient, fromObject) {
|
|
9263
|
+
const toObject = {};
|
|
9264
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
9265
|
+
if (fromConfig != null) {
|
|
9266
|
+
setValueByPath(toObject, ['config'], listTuningJobsConfigToMldev(apiClient, fromConfig, toObject));
|
|
9267
|
+
}
|
|
9268
|
+
return toObject;
|
|
9269
|
+
}
|
|
9270
|
+
function tuningExampleToMldev(apiClient, fromObject) {
|
|
9271
|
+
const toObject = {};
|
|
9272
|
+
const fromTextInput = getValueByPath(fromObject, ['textInput']);
|
|
9273
|
+
if (fromTextInput != null) {
|
|
9274
|
+
setValueByPath(toObject, ['textInput'], fromTextInput);
|
|
9275
|
+
}
|
|
9276
|
+
const fromOutput = getValueByPath(fromObject, ['output']);
|
|
9277
|
+
if (fromOutput != null) {
|
|
9278
|
+
setValueByPath(toObject, ['output'], fromOutput);
|
|
9279
|
+
}
|
|
9280
|
+
return toObject;
|
|
9281
|
+
}
|
|
9282
|
+
function tuningDatasetToMldev(apiClient, fromObject) {
|
|
9283
|
+
const toObject = {};
|
|
9284
|
+
if (getValueByPath(fromObject, ['gcsUri']) !== undefined) {
|
|
9285
|
+
throw new Error('gcsUri parameter is not supported in Gemini API.');
|
|
9286
|
+
}
|
|
9287
|
+
const fromExamples = getValueByPath(fromObject, ['examples']);
|
|
9288
|
+
if (fromExamples != null) {
|
|
9289
|
+
let transformedList = fromExamples;
|
|
9290
|
+
if (Array.isArray(transformedList)) {
|
|
9291
|
+
transformedList = transformedList.map((item) => {
|
|
9292
|
+
return tuningExampleToMldev(apiClient, item);
|
|
9293
|
+
});
|
|
9294
|
+
}
|
|
9295
|
+
setValueByPath(toObject, ['examples', 'examples'], transformedList);
|
|
9296
|
+
}
|
|
9297
|
+
return toObject;
|
|
9298
|
+
}
|
|
9299
|
+
function createTuningJobConfigToMldev(apiClient, fromObject, parentObject) {
|
|
9300
|
+
const toObject = {};
|
|
9301
|
+
if (getValueByPath(fromObject, ['validationDataset']) !== undefined) {
|
|
9302
|
+
throw new Error('validationDataset parameter is not supported in Gemini API.');
|
|
9303
|
+
}
|
|
9304
|
+
const fromTunedModelDisplayName = getValueByPath(fromObject, [
|
|
9305
|
+
'tunedModelDisplayName',
|
|
9306
|
+
]);
|
|
9307
|
+
if (parentObject !== undefined && fromTunedModelDisplayName != null) {
|
|
9308
|
+
setValueByPath(parentObject, ['displayName'], fromTunedModelDisplayName);
|
|
9309
|
+
}
|
|
9310
|
+
if (getValueByPath(fromObject, ['description']) !== undefined) {
|
|
9311
|
+
throw new Error('description parameter is not supported in Gemini API.');
|
|
9312
|
+
}
|
|
9313
|
+
const fromEpochCount = getValueByPath(fromObject, ['epochCount']);
|
|
9314
|
+
if (parentObject !== undefined && fromEpochCount != null) {
|
|
9315
|
+
setValueByPath(parentObject, ['tuningTask', 'hyperparameters', 'epochCount'], fromEpochCount);
|
|
9316
|
+
}
|
|
9317
|
+
const fromLearningRateMultiplier = getValueByPath(fromObject, [
|
|
9318
|
+
'learningRateMultiplier',
|
|
9319
|
+
]);
|
|
9320
|
+
if (fromLearningRateMultiplier != null) {
|
|
9321
|
+
setValueByPath(toObject, ['tuningTask', 'hyperparameters', 'learningRateMultiplier'], fromLearningRateMultiplier);
|
|
9322
|
+
}
|
|
9323
|
+
if (getValueByPath(fromObject, ['adapterSize']) !== undefined) {
|
|
9324
|
+
throw new Error('adapterSize parameter is not supported in Gemini API.');
|
|
9325
|
+
}
|
|
9326
|
+
const fromBatchSize = getValueByPath(fromObject, ['batchSize']);
|
|
9327
|
+
if (parentObject !== undefined && fromBatchSize != null) {
|
|
9328
|
+
setValueByPath(parentObject, ['tuningTask', 'hyperparameters', 'batchSize'], fromBatchSize);
|
|
9329
|
+
}
|
|
9330
|
+
const fromLearningRate = getValueByPath(fromObject, ['learningRate']);
|
|
9331
|
+
if (parentObject !== undefined && fromLearningRate != null) {
|
|
9332
|
+
setValueByPath(parentObject, ['tuningTask', 'hyperparameters', 'learningRate'], fromLearningRate);
|
|
9333
|
+
}
|
|
9334
|
+
return toObject;
|
|
9335
|
+
}
|
|
9336
|
+
function createTuningJobParametersToMldev(apiClient, fromObject) {
|
|
9337
|
+
const toObject = {};
|
|
9338
|
+
const fromBaseModel = getValueByPath(fromObject, ['baseModel']);
|
|
9339
|
+
if (fromBaseModel != null) {
|
|
9340
|
+
setValueByPath(toObject, ['baseModel'], fromBaseModel);
|
|
9341
|
+
}
|
|
9342
|
+
const fromTrainingDataset = getValueByPath(fromObject, [
|
|
9343
|
+
'trainingDataset',
|
|
9344
|
+
]);
|
|
9345
|
+
if (fromTrainingDataset != null) {
|
|
9346
|
+
setValueByPath(toObject, ['tuningTask', 'trainingData'], tuningDatasetToMldev(apiClient, fromTrainingDataset));
|
|
9347
|
+
}
|
|
9348
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
9349
|
+
if (fromConfig != null) {
|
|
9350
|
+
setValueByPath(toObject, ['config'], createTuningJobConfigToMldev(apiClient, fromConfig, toObject));
|
|
9351
|
+
}
|
|
9352
|
+
return toObject;
|
|
9353
|
+
}
|
|
9354
|
+
function getTuningJobParametersToVertex(apiClient, fromObject) {
|
|
9355
|
+
const toObject = {};
|
|
9356
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
9357
|
+
if (fromName != null) {
|
|
9358
|
+
setValueByPath(toObject, ['_url', 'name'], fromName);
|
|
9359
|
+
}
|
|
9360
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
9361
|
+
if (fromConfig != null) {
|
|
9362
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
9363
|
+
}
|
|
9364
|
+
return toObject;
|
|
9365
|
+
}
|
|
9366
|
+
function listTuningJobsConfigToVertex(apiClient, fromObject, parentObject) {
|
|
9367
|
+
const toObject = {};
|
|
9368
|
+
const fromPageSize = getValueByPath(fromObject, ['pageSize']);
|
|
9369
|
+
if (parentObject !== undefined && fromPageSize != null) {
|
|
9370
|
+
setValueByPath(parentObject, ['_query', 'pageSize'], fromPageSize);
|
|
9371
|
+
}
|
|
9372
|
+
const fromPageToken = getValueByPath(fromObject, ['pageToken']);
|
|
9373
|
+
if (parentObject !== undefined && fromPageToken != null) {
|
|
9374
|
+
setValueByPath(parentObject, ['_query', 'pageToken'], fromPageToken);
|
|
9375
|
+
}
|
|
9376
|
+
const fromFilter = getValueByPath(fromObject, ['filter']);
|
|
9377
|
+
if (parentObject !== undefined && fromFilter != null) {
|
|
9378
|
+
setValueByPath(parentObject, ['_query', 'filter'], fromFilter);
|
|
9379
|
+
}
|
|
9380
|
+
return toObject;
|
|
9381
|
+
}
|
|
9382
|
+
function listTuningJobsParametersToVertex(apiClient, fromObject) {
|
|
9383
|
+
const toObject = {};
|
|
9384
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
9385
|
+
if (fromConfig != null) {
|
|
9386
|
+
setValueByPath(toObject, ['config'], listTuningJobsConfigToVertex(apiClient, fromConfig, toObject));
|
|
9387
|
+
}
|
|
9388
|
+
return toObject;
|
|
9389
|
+
}
|
|
9390
|
+
function tuningDatasetToVertex(apiClient, fromObject, parentObject) {
|
|
9391
|
+
const toObject = {};
|
|
9392
|
+
const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
|
|
9393
|
+
if (parentObject !== undefined && fromGcsUri != null) {
|
|
9394
|
+
setValueByPath(parentObject, ['supervisedTuningSpec', 'trainingDatasetUri'], fromGcsUri);
|
|
9395
|
+
}
|
|
9396
|
+
if (getValueByPath(fromObject, ['examples']) !== undefined) {
|
|
9397
|
+
throw new Error('examples parameter is not supported in Vertex AI.');
|
|
9398
|
+
}
|
|
9399
|
+
return toObject;
|
|
9400
|
+
}
|
|
9401
|
+
function tuningValidationDatasetToVertex(apiClient, fromObject) {
|
|
9402
|
+
const toObject = {};
|
|
9403
|
+
const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
|
|
9404
|
+
if (fromGcsUri != null) {
|
|
9405
|
+
setValueByPath(toObject, ['validationDatasetUri'], fromGcsUri);
|
|
9406
|
+
}
|
|
9407
|
+
return toObject;
|
|
9408
|
+
}
|
|
9409
|
+
function createTuningJobConfigToVertex(apiClient, fromObject, parentObject) {
|
|
9410
|
+
const toObject = {};
|
|
9411
|
+
const fromValidationDataset = getValueByPath(fromObject, [
|
|
9412
|
+
'validationDataset',
|
|
9413
|
+
]);
|
|
9414
|
+
if (parentObject !== undefined && fromValidationDataset != null) {
|
|
9415
|
+
setValueByPath(parentObject, ['supervisedTuningSpec'], tuningValidationDatasetToVertex(apiClient, fromValidationDataset));
|
|
9416
|
+
}
|
|
9417
|
+
const fromTunedModelDisplayName = getValueByPath(fromObject, [
|
|
9418
|
+
'tunedModelDisplayName',
|
|
9419
|
+
]);
|
|
9420
|
+
if (parentObject !== undefined && fromTunedModelDisplayName != null) {
|
|
9421
|
+
setValueByPath(parentObject, ['tunedModelDisplayName'], fromTunedModelDisplayName);
|
|
9422
|
+
}
|
|
9423
|
+
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
9424
|
+
if (parentObject !== undefined && fromDescription != null) {
|
|
9425
|
+
setValueByPath(parentObject, ['description'], fromDescription);
|
|
9426
|
+
}
|
|
9427
|
+
const fromEpochCount = getValueByPath(fromObject, ['epochCount']);
|
|
9428
|
+
if (parentObject !== undefined && fromEpochCount != null) {
|
|
9429
|
+
setValueByPath(parentObject, ['supervisedTuningSpec', 'hyperParameters', 'epochCount'], fromEpochCount);
|
|
9430
|
+
}
|
|
9431
|
+
const fromLearningRateMultiplier = getValueByPath(fromObject, [
|
|
9432
|
+
'learningRateMultiplier',
|
|
9433
|
+
]);
|
|
9434
|
+
if (parentObject !== undefined && fromLearningRateMultiplier != null) {
|
|
9435
|
+
setValueByPath(parentObject, ['supervisedTuningSpec', 'hyperParameters', 'learningRateMultiplier'], fromLearningRateMultiplier);
|
|
9436
|
+
}
|
|
9437
|
+
const fromAdapterSize = getValueByPath(fromObject, ['adapterSize']);
|
|
9438
|
+
if (parentObject !== undefined && fromAdapterSize != null) {
|
|
9439
|
+
setValueByPath(parentObject, ['supervisedTuningSpec', 'hyperParameters', 'adapterSize'], fromAdapterSize);
|
|
9440
|
+
}
|
|
9441
|
+
if (getValueByPath(fromObject, ['batchSize']) !== undefined) {
|
|
9442
|
+
throw new Error('batchSize parameter is not supported in Vertex AI.');
|
|
9443
|
+
}
|
|
9444
|
+
if (getValueByPath(fromObject, ['learningRate']) !== undefined) {
|
|
9445
|
+
throw new Error('learningRate parameter is not supported in Vertex AI.');
|
|
9446
|
+
}
|
|
9447
|
+
return toObject;
|
|
9448
|
+
}
|
|
9449
|
+
function createTuningJobParametersToVertex(apiClient, fromObject) {
|
|
9450
|
+
const toObject = {};
|
|
9451
|
+
const fromBaseModel = getValueByPath(fromObject, ['baseModel']);
|
|
9452
|
+
if (fromBaseModel != null) {
|
|
9453
|
+
setValueByPath(toObject, ['baseModel'], fromBaseModel);
|
|
9454
|
+
}
|
|
9455
|
+
const fromTrainingDataset = getValueByPath(fromObject, [
|
|
9456
|
+
'trainingDataset',
|
|
9457
|
+
]);
|
|
9458
|
+
if (fromTrainingDataset != null) {
|
|
9459
|
+
setValueByPath(toObject, ['supervisedTuningSpec', 'trainingDatasetUri'], tuningDatasetToVertex(apiClient, fromTrainingDataset, toObject));
|
|
9460
|
+
}
|
|
9461
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
9462
|
+
if (fromConfig != null) {
|
|
9463
|
+
setValueByPath(toObject, ['config'], createTuningJobConfigToVertex(apiClient, fromConfig, toObject));
|
|
9464
|
+
}
|
|
9465
|
+
return toObject;
|
|
9466
|
+
}
|
|
9467
|
+
function tunedModelFromMldev(apiClient, fromObject) {
|
|
9468
|
+
const toObject = {};
|
|
9469
|
+
const fromModel = getValueByPath(fromObject, ['name']);
|
|
9470
|
+
if (fromModel != null) {
|
|
9471
|
+
setValueByPath(toObject, ['model'], fromModel);
|
|
9472
|
+
}
|
|
9473
|
+
const fromEndpoint = getValueByPath(fromObject, ['name']);
|
|
9474
|
+
if (fromEndpoint != null) {
|
|
9475
|
+
setValueByPath(toObject, ['endpoint'], fromEndpoint);
|
|
9476
|
+
}
|
|
9477
|
+
return toObject;
|
|
9478
|
+
}
|
|
9479
|
+
function tuningJobFromMldev(apiClient, fromObject) {
|
|
9480
|
+
const toObject = {};
|
|
9481
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
9482
|
+
if (fromName != null) {
|
|
9483
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
9484
|
+
}
|
|
9485
|
+
const fromState = getValueByPath(fromObject, ['state']);
|
|
9486
|
+
if (fromState != null) {
|
|
9487
|
+
setValueByPath(toObject, ['state'], tTuningJobStatus(apiClient, fromState));
|
|
9488
|
+
}
|
|
9489
|
+
const fromCreateTime = getValueByPath(fromObject, ['createTime']);
|
|
9490
|
+
if (fromCreateTime != null) {
|
|
9491
|
+
setValueByPath(toObject, ['createTime'], fromCreateTime);
|
|
9492
|
+
}
|
|
9493
|
+
const fromStartTime = getValueByPath(fromObject, [
|
|
9494
|
+
'tuningTask',
|
|
9495
|
+
'startTime',
|
|
9496
|
+
]);
|
|
9497
|
+
if (fromStartTime != null) {
|
|
9498
|
+
setValueByPath(toObject, ['startTime'], fromStartTime);
|
|
9499
|
+
}
|
|
9500
|
+
const fromEndTime = getValueByPath(fromObject, [
|
|
9501
|
+
'tuningTask',
|
|
9502
|
+
'completeTime',
|
|
9503
|
+
]);
|
|
9504
|
+
if (fromEndTime != null) {
|
|
9505
|
+
setValueByPath(toObject, ['endTime'], fromEndTime);
|
|
9506
|
+
}
|
|
9507
|
+
const fromUpdateTime = getValueByPath(fromObject, ['updateTime']);
|
|
9508
|
+
if (fromUpdateTime != null) {
|
|
9509
|
+
setValueByPath(toObject, ['updateTime'], fromUpdateTime);
|
|
9510
|
+
}
|
|
9511
|
+
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
9512
|
+
if (fromDescription != null) {
|
|
9513
|
+
setValueByPath(toObject, ['description'], fromDescription);
|
|
9514
|
+
}
|
|
9515
|
+
const fromBaseModel = getValueByPath(fromObject, ['baseModel']);
|
|
9516
|
+
if (fromBaseModel != null) {
|
|
9517
|
+
setValueByPath(toObject, ['baseModel'], fromBaseModel);
|
|
9518
|
+
}
|
|
9519
|
+
const fromTunedModel = getValueByPath(fromObject, ['_self']);
|
|
9520
|
+
if (fromTunedModel != null) {
|
|
9521
|
+
setValueByPath(toObject, ['tunedModel'], tunedModelFromMldev(apiClient, fromTunedModel));
|
|
9522
|
+
}
|
|
9523
|
+
const fromDistillationSpec = getValueByPath(fromObject, [
|
|
9524
|
+
'distillationSpec',
|
|
9525
|
+
]);
|
|
9526
|
+
if (fromDistillationSpec != null) {
|
|
9527
|
+
setValueByPath(toObject, ['distillationSpec'], fromDistillationSpec);
|
|
9528
|
+
}
|
|
9529
|
+
const fromExperiment = getValueByPath(fromObject, ['experiment']);
|
|
9530
|
+
if (fromExperiment != null) {
|
|
9531
|
+
setValueByPath(toObject, ['experiment'], fromExperiment);
|
|
9532
|
+
}
|
|
9533
|
+
const fromLabels = getValueByPath(fromObject, ['labels']);
|
|
9534
|
+
if (fromLabels != null) {
|
|
9535
|
+
setValueByPath(toObject, ['labels'], fromLabels);
|
|
9536
|
+
}
|
|
9537
|
+
const fromPipelineJob = getValueByPath(fromObject, ['pipelineJob']);
|
|
9538
|
+
if (fromPipelineJob != null) {
|
|
9539
|
+
setValueByPath(toObject, ['pipelineJob'], fromPipelineJob);
|
|
9540
|
+
}
|
|
9541
|
+
const fromTunedModelDisplayName = getValueByPath(fromObject, [
|
|
9542
|
+
'tunedModelDisplayName',
|
|
9543
|
+
]);
|
|
9544
|
+
if (fromTunedModelDisplayName != null) {
|
|
9545
|
+
setValueByPath(toObject, ['tunedModelDisplayName'], fromTunedModelDisplayName);
|
|
9546
|
+
}
|
|
9547
|
+
return toObject;
|
|
9548
|
+
}
|
|
9549
|
+
function listTuningJobsResponseFromMldev(apiClient, fromObject) {
|
|
9550
|
+
const toObject = {};
|
|
9551
|
+
const fromNextPageToken = getValueByPath(fromObject, [
|
|
9552
|
+
'nextPageToken',
|
|
9553
|
+
]);
|
|
9554
|
+
if (fromNextPageToken != null) {
|
|
9555
|
+
setValueByPath(toObject, ['nextPageToken'], fromNextPageToken);
|
|
9556
|
+
}
|
|
9557
|
+
const fromTuningJobs = getValueByPath(fromObject, ['tunedModels']);
|
|
9558
|
+
if (fromTuningJobs != null) {
|
|
9559
|
+
let transformedList = fromTuningJobs;
|
|
9560
|
+
if (Array.isArray(transformedList)) {
|
|
9561
|
+
transformedList = transformedList.map((item) => {
|
|
9562
|
+
return tuningJobFromMldev(apiClient, item);
|
|
9563
|
+
});
|
|
9564
|
+
}
|
|
9565
|
+
setValueByPath(toObject, ['tuningJobs'], transformedList);
|
|
9566
|
+
}
|
|
9567
|
+
return toObject;
|
|
9568
|
+
}
|
|
9569
|
+
function operationFromMldev(apiClient, fromObject) {
|
|
9570
|
+
const toObject = {};
|
|
9571
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
9572
|
+
if (fromName != null) {
|
|
9573
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
9574
|
+
}
|
|
9575
|
+
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
9576
|
+
if (fromMetadata != null) {
|
|
9577
|
+
setValueByPath(toObject, ['metadata'], fromMetadata);
|
|
9578
|
+
}
|
|
9579
|
+
const fromDone = getValueByPath(fromObject, ['done']);
|
|
9580
|
+
if (fromDone != null) {
|
|
9581
|
+
setValueByPath(toObject, ['done'], fromDone);
|
|
9582
|
+
}
|
|
9583
|
+
const fromError = getValueByPath(fromObject, ['error']);
|
|
9584
|
+
if (fromError != null) {
|
|
9585
|
+
setValueByPath(toObject, ['error'], fromError);
|
|
9586
|
+
}
|
|
9587
|
+
return toObject;
|
|
9588
|
+
}
|
|
9589
|
+
function tunedModelFromVertex(apiClient, fromObject) {
|
|
9590
|
+
const toObject = {};
|
|
9591
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
9592
|
+
if (fromModel != null) {
|
|
9593
|
+
setValueByPath(toObject, ['model'], fromModel);
|
|
9594
|
+
}
|
|
9595
|
+
const fromEndpoint = getValueByPath(fromObject, ['endpoint']);
|
|
9596
|
+
if (fromEndpoint != null) {
|
|
9597
|
+
setValueByPath(toObject, ['endpoint'], fromEndpoint);
|
|
9598
|
+
}
|
|
9599
|
+
return toObject;
|
|
9600
|
+
}
|
|
9601
|
+
function tuningJobFromVertex(apiClient, fromObject) {
|
|
9602
|
+
const toObject = {};
|
|
9603
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
9604
|
+
if (fromName != null) {
|
|
9605
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
9606
|
+
}
|
|
9607
|
+
const fromState = getValueByPath(fromObject, ['state']);
|
|
9608
|
+
if (fromState != null) {
|
|
9609
|
+
setValueByPath(toObject, ['state'], tTuningJobStatus(apiClient, fromState));
|
|
9610
|
+
}
|
|
9611
|
+
const fromCreateTime = getValueByPath(fromObject, ['createTime']);
|
|
9612
|
+
if (fromCreateTime != null) {
|
|
9613
|
+
setValueByPath(toObject, ['createTime'], fromCreateTime);
|
|
9614
|
+
}
|
|
9615
|
+
const fromStartTime = getValueByPath(fromObject, ['startTime']);
|
|
9616
|
+
if (fromStartTime != null) {
|
|
9617
|
+
setValueByPath(toObject, ['startTime'], fromStartTime);
|
|
9618
|
+
}
|
|
9619
|
+
const fromEndTime = getValueByPath(fromObject, ['endTime']);
|
|
9620
|
+
if (fromEndTime != null) {
|
|
9621
|
+
setValueByPath(toObject, ['endTime'], fromEndTime);
|
|
9622
|
+
}
|
|
9623
|
+
const fromUpdateTime = getValueByPath(fromObject, ['updateTime']);
|
|
9624
|
+
if (fromUpdateTime != null) {
|
|
9625
|
+
setValueByPath(toObject, ['updateTime'], fromUpdateTime);
|
|
9626
|
+
}
|
|
9627
|
+
const fromError = getValueByPath(fromObject, ['error']);
|
|
9628
|
+
if (fromError != null) {
|
|
9629
|
+
setValueByPath(toObject, ['error'], fromError);
|
|
9630
|
+
}
|
|
9631
|
+
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
9632
|
+
if (fromDescription != null) {
|
|
9633
|
+
setValueByPath(toObject, ['description'], fromDescription);
|
|
9634
|
+
}
|
|
9635
|
+
const fromBaseModel = getValueByPath(fromObject, ['baseModel']);
|
|
9636
|
+
if (fromBaseModel != null) {
|
|
9637
|
+
setValueByPath(toObject, ['baseModel'], fromBaseModel);
|
|
9638
|
+
}
|
|
9639
|
+
const fromTunedModel = getValueByPath(fromObject, ['tunedModel']);
|
|
9640
|
+
if (fromTunedModel != null) {
|
|
9641
|
+
setValueByPath(toObject, ['tunedModel'], tunedModelFromVertex(apiClient, fromTunedModel));
|
|
9642
|
+
}
|
|
9643
|
+
const fromSupervisedTuningSpec = getValueByPath(fromObject, [
|
|
9644
|
+
'supervisedTuningSpec',
|
|
9645
|
+
]);
|
|
9646
|
+
if (fromSupervisedTuningSpec != null) {
|
|
9647
|
+
setValueByPath(toObject, ['supervisedTuningSpec'], fromSupervisedTuningSpec);
|
|
9648
|
+
}
|
|
9649
|
+
const fromTuningDataStats = getValueByPath(fromObject, [
|
|
9650
|
+
'tuningDataStats',
|
|
9651
|
+
]);
|
|
9652
|
+
if (fromTuningDataStats != null) {
|
|
9653
|
+
setValueByPath(toObject, ['tuningDataStats'], fromTuningDataStats);
|
|
9654
|
+
}
|
|
9655
|
+
const fromEncryptionSpec = getValueByPath(fromObject, [
|
|
9656
|
+
'encryptionSpec',
|
|
9657
|
+
]);
|
|
9658
|
+
if (fromEncryptionSpec != null) {
|
|
9659
|
+
setValueByPath(toObject, ['encryptionSpec'], fromEncryptionSpec);
|
|
9660
|
+
}
|
|
9661
|
+
const fromPartnerModelTuningSpec = getValueByPath(fromObject, [
|
|
9662
|
+
'partnerModelTuningSpec',
|
|
9663
|
+
]);
|
|
9664
|
+
if (fromPartnerModelTuningSpec != null) {
|
|
9665
|
+
setValueByPath(toObject, ['partnerModelTuningSpec'], fromPartnerModelTuningSpec);
|
|
9666
|
+
}
|
|
9667
|
+
const fromDistillationSpec = getValueByPath(fromObject, [
|
|
9668
|
+
'distillationSpec',
|
|
9669
|
+
]);
|
|
9670
|
+
if (fromDistillationSpec != null) {
|
|
9671
|
+
setValueByPath(toObject, ['distillationSpec'], fromDistillationSpec);
|
|
9672
|
+
}
|
|
9673
|
+
const fromExperiment = getValueByPath(fromObject, ['experiment']);
|
|
9674
|
+
if (fromExperiment != null) {
|
|
9675
|
+
setValueByPath(toObject, ['experiment'], fromExperiment);
|
|
9676
|
+
}
|
|
9677
|
+
const fromLabels = getValueByPath(fromObject, ['labels']);
|
|
9678
|
+
if (fromLabels != null) {
|
|
9679
|
+
setValueByPath(toObject, ['labels'], fromLabels);
|
|
9680
|
+
}
|
|
9681
|
+
const fromPipelineJob = getValueByPath(fromObject, ['pipelineJob']);
|
|
9682
|
+
if (fromPipelineJob != null) {
|
|
9683
|
+
setValueByPath(toObject, ['pipelineJob'], fromPipelineJob);
|
|
9684
|
+
}
|
|
9685
|
+
const fromTunedModelDisplayName = getValueByPath(fromObject, [
|
|
9686
|
+
'tunedModelDisplayName',
|
|
9687
|
+
]);
|
|
9688
|
+
if (fromTunedModelDisplayName != null) {
|
|
9689
|
+
setValueByPath(toObject, ['tunedModelDisplayName'], fromTunedModelDisplayName);
|
|
9690
|
+
}
|
|
9691
|
+
return toObject;
|
|
9692
|
+
}
|
|
9693
|
+
function listTuningJobsResponseFromVertex(apiClient, fromObject) {
|
|
9694
|
+
const toObject = {};
|
|
9695
|
+
const fromNextPageToken = getValueByPath(fromObject, [
|
|
9696
|
+
'nextPageToken',
|
|
9697
|
+
]);
|
|
9698
|
+
if (fromNextPageToken != null) {
|
|
9699
|
+
setValueByPath(toObject, ['nextPageToken'], fromNextPageToken);
|
|
9700
|
+
}
|
|
9701
|
+
const fromTuningJobs = getValueByPath(fromObject, ['tuningJobs']);
|
|
9702
|
+
if (fromTuningJobs != null) {
|
|
9703
|
+
let transformedList = fromTuningJobs;
|
|
9704
|
+
if (Array.isArray(transformedList)) {
|
|
9705
|
+
transformedList = transformedList.map((item) => {
|
|
9706
|
+
return tuningJobFromVertex(apiClient, item);
|
|
9707
|
+
});
|
|
9708
|
+
}
|
|
9709
|
+
setValueByPath(toObject, ['tuningJobs'], transformedList);
|
|
9710
|
+
}
|
|
9711
|
+
return toObject;
|
|
9712
|
+
}
|
|
9713
|
+
|
|
9714
|
+
/**
|
|
9715
|
+
* @license
|
|
9716
|
+
* Copyright 2025 Google LLC
|
|
9717
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
9718
|
+
*/
|
|
9719
|
+
class Tunings extends BaseModule {
|
|
9720
|
+
constructor(apiClient) {
|
|
9721
|
+
super();
|
|
9722
|
+
this.apiClient = apiClient;
|
|
9723
|
+
/**
|
|
9724
|
+
* Gets a TuningJob.
|
|
9725
|
+
*
|
|
9726
|
+
* @param name - The resource name of the tuning job.
|
|
9727
|
+
* @return - A TuningJob object.
|
|
9728
|
+
*
|
|
9729
|
+
* @experimental - The SDK's tuning implementation is experimental, and may
|
|
9730
|
+
* change in future versions.
|
|
9731
|
+
*/
|
|
9732
|
+
this.get = async (params) => {
|
|
9733
|
+
return await this.getInternal(params);
|
|
9734
|
+
};
|
|
9735
|
+
/**
|
|
9736
|
+
* Lists tuning jobs.
|
|
9737
|
+
*
|
|
9738
|
+
* @param config - The configuration for the list request.
|
|
9739
|
+
* @return - A list of tuning jobs.
|
|
9740
|
+
*
|
|
9741
|
+
* @experimental - The SDK's tuning implementation is experimental, and may
|
|
9742
|
+
* change in future versions.
|
|
9743
|
+
*/
|
|
9744
|
+
this.list = async (params = {}) => {
|
|
9745
|
+
return new Pager(exports.PagedItem.PAGED_ITEM_TUNING_JOBS, (x) => this.listInternal(x), await this.listInternal(params), params);
|
|
9746
|
+
};
|
|
9747
|
+
/**
|
|
9748
|
+
* Creates a supervised fine-tuning job.
|
|
9749
|
+
*
|
|
9750
|
+
* @param params - The parameters for the tuning job.
|
|
9751
|
+
* @return - A TuningJob operation.
|
|
9752
|
+
*
|
|
9753
|
+
* @experimental - The SDK's tuning implementation is experimental, and may
|
|
9754
|
+
* change in future versions.
|
|
9755
|
+
*/
|
|
9756
|
+
this.tune = async (params) => {
|
|
9757
|
+
if (this.apiClient.isVertexAI()) {
|
|
9758
|
+
return await this.tuneInternal(params);
|
|
9759
|
+
}
|
|
9760
|
+
else {
|
|
9761
|
+
const operation = await this.tuneMldevInternal(params);
|
|
9762
|
+
let tunedModelName = '';
|
|
9763
|
+
if (operation['metadata'] !== undefined &&
|
|
9764
|
+
operation['metadata']['tunedModel'] !== undefined) {
|
|
9765
|
+
tunedModelName = operation['metadata']['tunedModel'];
|
|
9766
|
+
}
|
|
9767
|
+
else if (operation['name'] !== undefined &&
|
|
9768
|
+
operation['name'].includes('/operations/')) {
|
|
9769
|
+
tunedModelName = operation['name'].split('/operations/')[0];
|
|
9770
|
+
}
|
|
9771
|
+
const tuningJob = {
|
|
9772
|
+
name: tunedModelName,
|
|
9773
|
+
state: exports.JobState.JOB_STATE_QUEUED,
|
|
9774
|
+
};
|
|
9775
|
+
return tuningJob;
|
|
9776
|
+
}
|
|
9777
|
+
};
|
|
9778
|
+
}
|
|
9779
|
+
async getInternal(params) {
|
|
9780
|
+
var _a, _b, _c, _d;
|
|
9781
|
+
let response;
|
|
9782
|
+
let path = '';
|
|
9783
|
+
let queryParams = {};
|
|
9784
|
+
if (this.apiClient.isVertexAI()) {
|
|
9785
|
+
const body = getTuningJobParametersToVertex(this.apiClient, params);
|
|
9786
|
+
path = formatMap('{name}', body['_url']);
|
|
9787
|
+
queryParams = body['_query'];
|
|
9788
|
+
delete body['config'];
|
|
9789
|
+
delete body['_url'];
|
|
9790
|
+
delete body['_query'];
|
|
9791
|
+
response = this.apiClient
|
|
9792
|
+
.request({
|
|
9793
|
+
path: path,
|
|
9794
|
+
queryParams: queryParams,
|
|
9795
|
+
body: JSON.stringify(body),
|
|
9796
|
+
httpMethod: 'GET',
|
|
9797
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
9798
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
9799
|
+
})
|
|
9800
|
+
.then((httpResponse) => {
|
|
9801
|
+
return httpResponse.json();
|
|
9802
|
+
});
|
|
9803
|
+
return response.then((apiResponse) => {
|
|
9804
|
+
const resp = tuningJobFromVertex(this.apiClient, apiResponse);
|
|
9805
|
+
return resp;
|
|
9806
|
+
});
|
|
9807
|
+
}
|
|
9808
|
+
else {
|
|
9809
|
+
const body = getTuningJobParametersToMldev(this.apiClient, params);
|
|
9810
|
+
path = formatMap('{name}', body['_url']);
|
|
9811
|
+
queryParams = body['_query'];
|
|
9812
|
+
delete body['config'];
|
|
9813
|
+
delete body['_url'];
|
|
9814
|
+
delete body['_query'];
|
|
9815
|
+
response = this.apiClient
|
|
9816
|
+
.request({
|
|
9817
|
+
path: path,
|
|
9818
|
+
queryParams: queryParams,
|
|
9819
|
+
body: JSON.stringify(body),
|
|
9820
|
+
httpMethod: 'GET',
|
|
9821
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
9822
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
9823
|
+
})
|
|
9824
|
+
.then((httpResponse) => {
|
|
9825
|
+
return httpResponse.json();
|
|
9826
|
+
});
|
|
9827
|
+
return response.then((apiResponse) => {
|
|
9828
|
+
const resp = tuningJobFromMldev(this.apiClient, apiResponse);
|
|
9829
|
+
return resp;
|
|
9830
|
+
});
|
|
9831
|
+
}
|
|
9832
|
+
}
|
|
9833
|
+
async listInternal(params) {
|
|
9834
|
+
var _a, _b, _c, _d;
|
|
9835
|
+
let response;
|
|
9836
|
+
let path = '';
|
|
9837
|
+
let queryParams = {};
|
|
9838
|
+
if (this.apiClient.isVertexAI()) {
|
|
9839
|
+
const body = listTuningJobsParametersToVertex(this.apiClient, params);
|
|
9840
|
+
path = formatMap('tuningJobs', body['_url']);
|
|
9841
|
+
queryParams = body['_query'];
|
|
9842
|
+
delete body['config'];
|
|
9843
|
+
delete body['_url'];
|
|
9844
|
+
delete body['_query'];
|
|
9845
|
+
response = this.apiClient
|
|
9846
|
+
.request({
|
|
9847
|
+
path: path,
|
|
9848
|
+
queryParams: queryParams,
|
|
9849
|
+
body: JSON.stringify(body),
|
|
9850
|
+
httpMethod: 'GET',
|
|
9851
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
9852
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
9853
|
+
})
|
|
9854
|
+
.then((httpResponse) => {
|
|
9855
|
+
return httpResponse.json();
|
|
9856
|
+
});
|
|
9857
|
+
return response.then((apiResponse) => {
|
|
9858
|
+
const resp = listTuningJobsResponseFromVertex(this.apiClient, apiResponse);
|
|
9859
|
+
const typedResp = new ListTuningJobsResponse();
|
|
9860
|
+
Object.assign(typedResp, resp);
|
|
9861
|
+
return typedResp;
|
|
9862
|
+
});
|
|
9863
|
+
}
|
|
9864
|
+
else {
|
|
9865
|
+
const body = listTuningJobsParametersToMldev(this.apiClient, params);
|
|
9866
|
+
path = formatMap('tunedModels', body['_url']);
|
|
9867
|
+
queryParams = body['_query'];
|
|
9868
|
+
delete body['config'];
|
|
9869
|
+
delete body['_url'];
|
|
9870
|
+
delete body['_query'];
|
|
9871
|
+
response = this.apiClient
|
|
9872
|
+
.request({
|
|
9873
|
+
path: path,
|
|
9874
|
+
queryParams: queryParams,
|
|
9875
|
+
body: JSON.stringify(body),
|
|
9876
|
+
httpMethod: 'GET',
|
|
9877
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
9878
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
9879
|
+
})
|
|
9880
|
+
.then((httpResponse) => {
|
|
9881
|
+
return httpResponse.json();
|
|
9882
|
+
});
|
|
9883
|
+
return response.then((apiResponse) => {
|
|
9884
|
+
const resp = listTuningJobsResponseFromMldev(this.apiClient, apiResponse);
|
|
9885
|
+
const typedResp = new ListTuningJobsResponse();
|
|
9886
|
+
Object.assign(typedResp, resp);
|
|
9887
|
+
return typedResp;
|
|
9888
|
+
});
|
|
9889
|
+
}
|
|
9890
|
+
}
|
|
9891
|
+
async tuneInternal(params) {
|
|
9892
|
+
var _a, _b;
|
|
9893
|
+
let response;
|
|
9894
|
+
let path = '';
|
|
9895
|
+
let queryParams = {};
|
|
9896
|
+
if (this.apiClient.isVertexAI()) {
|
|
9897
|
+
const body = createTuningJobParametersToVertex(this.apiClient, params);
|
|
9898
|
+
path = formatMap('tuningJobs', body['_url']);
|
|
9899
|
+
queryParams = body['_query'];
|
|
9900
|
+
delete body['config'];
|
|
9901
|
+
delete body['_url'];
|
|
9902
|
+
delete body['_query'];
|
|
9903
|
+
response = this.apiClient
|
|
9904
|
+
.request({
|
|
9905
|
+
path: path,
|
|
9906
|
+
queryParams: queryParams,
|
|
9907
|
+
body: JSON.stringify(body),
|
|
9908
|
+
httpMethod: 'POST',
|
|
9909
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
9910
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
9911
|
+
})
|
|
9912
|
+
.then((httpResponse) => {
|
|
9913
|
+
return httpResponse.json();
|
|
9914
|
+
});
|
|
9915
|
+
return response.then((apiResponse) => {
|
|
9916
|
+
const resp = tuningJobFromVertex(this.apiClient, apiResponse);
|
|
9917
|
+
return resp;
|
|
9918
|
+
});
|
|
9919
|
+
}
|
|
9920
|
+
else {
|
|
9921
|
+
throw new Error('This method is only supported by the Vertex AI.');
|
|
9922
|
+
}
|
|
9923
|
+
}
|
|
9924
|
+
async tuneMldevInternal(params) {
|
|
9925
|
+
var _a, _b;
|
|
9926
|
+
let response;
|
|
9927
|
+
let path = '';
|
|
9928
|
+
let queryParams = {};
|
|
9929
|
+
if (this.apiClient.isVertexAI()) {
|
|
9930
|
+
throw new Error('This method is only supported by the Gemini Developer API.');
|
|
9931
|
+
}
|
|
9932
|
+
else {
|
|
9933
|
+
const body = createTuningJobParametersToMldev(this.apiClient, params);
|
|
9934
|
+
path = formatMap('tunedModels', body['_url']);
|
|
9935
|
+
queryParams = body['_query'];
|
|
9936
|
+
delete body['config'];
|
|
9937
|
+
delete body['_url'];
|
|
9938
|
+
delete body['_query'];
|
|
9939
|
+
response = this.apiClient
|
|
9940
|
+
.request({
|
|
9941
|
+
path: path,
|
|
9942
|
+
queryParams: queryParams,
|
|
9943
|
+
body: JSON.stringify(body),
|
|
9944
|
+
httpMethod: 'POST',
|
|
9945
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
9946
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
9947
|
+
})
|
|
9948
|
+
.then((httpResponse) => {
|
|
9949
|
+
return httpResponse.json();
|
|
9950
|
+
});
|
|
9951
|
+
return response.then((apiResponse) => {
|
|
9952
|
+
const resp = operationFromMldev(this.apiClient, apiResponse);
|
|
9953
|
+
return resp;
|
|
9954
|
+
});
|
|
9955
|
+
}
|
|
9956
|
+
}
|
|
9957
|
+
}
|
|
9958
|
+
|
|
9959
|
+
const MAX_CHUNK_SIZE = 1024 * 1024 * 8; // bytes
|
|
9960
|
+
async function uploadBlob(file, uploadUrl, apiClient) {
|
|
9961
|
+
var _a, _b;
|
|
9962
|
+
let fileSize = 0;
|
|
9963
|
+
let offset = 0;
|
|
9964
|
+
let response = new HttpResponse(new Response());
|
|
9965
|
+
let uploadCommand = 'upload';
|
|
9966
|
+
fileSize = file.size;
|
|
9967
|
+
while (offset < fileSize) {
|
|
9968
|
+
const chunkSize = Math.min(MAX_CHUNK_SIZE, fileSize - offset);
|
|
9969
|
+
const chunk = file.slice(offset, offset + chunkSize);
|
|
9970
|
+
if (offset + chunkSize >= fileSize) {
|
|
9971
|
+
uploadCommand += ', finalize';
|
|
9972
|
+
}
|
|
9973
|
+
response = await apiClient.request({
|
|
9974
|
+
path: '',
|
|
9975
|
+
body: chunk,
|
|
9976
|
+
httpMethod: 'POST',
|
|
9977
|
+
httpOptions: {
|
|
9978
|
+
apiVersion: '',
|
|
9979
|
+
baseUrl: uploadUrl,
|
|
9980
|
+
headers: {
|
|
9981
|
+
'X-Goog-Upload-Command': uploadCommand,
|
|
9982
|
+
'X-Goog-Upload-Offset': String(offset),
|
|
9983
|
+
'Content-Length': String(chunkSize),
|
|
9984
|
+
},
|
|
9985
|
+
},
|
|
9986
|
+
});
|
|
9987
|
+
offset += chunkSize;
|
|
9988
|
+
// The `x-goog-upload-status` header field can be `active`, `final` and
|
|
9989
|
+
//`cancelled` in resposne.
|
|
9990
|
+
if (((_a = response === null || response === void 0 ? void 0 : response.headers) === null || _a === void 0 ? void 0 : _a['x-goog-upload-status']) !== 'active') {
|
|
9991
|
+
break;
|
|
9992
|
+
}
|
|
9993
|
+
// TODO(b/401391430) Investigate why the upload status is not finalized
|
|
9994
|
+
// even though all content has been uploaded.
|
|
9995
|
+
if (fileSize <= offset) {
|
|
9996
|
+
throw new Error('All content has been uploaded, but the upload status is not finalized.');
|
|
9997
|
+
}
|
|
9998
|
+
}
|
|
9999
|
+
const responseJson = (await (response === null || response === void 0 ? void 0 : response.json()));
|
|
10000
|
+
if (((_b = response === null || response === void 0 ? void 0 : response.headers) === null || _b === void 0 ? void 0 : _b['x-goog-upload-status']) !== 'final') {
|
|
10001
|
+
throw new Error('Failed to upload file: Upload status is not finalized.');
|
|
10002
|
+
}
|
|
10003
|
+
return responseJson['file'];
|
|
10004
|
+
}
|
|
10005
|
+
async function getBlobStat(file) {
|
|
10006
|
+
const fileStat = { size: file.size, type: file.type };
|
|
10007
|
+
return fileStat;
|
|
10008
|
+
}
|
|
10009
|
+
|
|
10010
|
+
/**
|
|
10011
|
+
* @license
|
|
10012
|
+
* Copyright 2025 Google LLC
|
|
10013
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
10014
|
+
*/
|
|
10015
|
+
class NodeUploader {
|
|
10016
|
+
async stat(file) {
|
|
10017
|
+
const fileStat = { size: 0, type: undefined };
|
|
10018
|
+
if (typeof file === 'string') {
|
|
10019
|
+
const originalStat = await fs__namespace.stat(file);
|
|
10020
|
+
fileStat.size = originalStat.size;
|
|
10021
|
+
fileStat.type = this.inferMimeType(file);
|
|
10022
|
+
return fileStat;
|
|
10023
|
+
}
|
|
10024
|
+
else {
|
|
10025
|
+
return await getBlobStat(file);
|
|
10026
|
+
}
|
|
10027
|
+
}
|
|
10028
|
+
async upload(file, uploadUrl, apiClient) {
|
|
10029
|
+
if (typeof file === 'string') {
|
|
10030
|
+
return await this.uploadFileFromPath(file, uploadUrl, apiClient);
|
|
10031
|
+
}
|
|
10032
|
+
else {
|
|
10033
|
+
return uploadBlob(file, uploadUrl, apiClient);
|
|
10034
|
+
}
|
|
10035
|
+
}
|
|
10036
|
+
/**
|
|
10037
|
+
* Infers the MIME type of a file based on its extension.
|
|
10038
|
+
*
|
|
10039
|
+
* @param filePath The path to the file.
|
|
10040
|
+
* @returns The MIME type of the file, or undefined if it cannot be inferred.
|
|
10041
|
+
*/
|
|
10042
|
+
inferMimeType(filePath) {
|
|
10043
|
+
// Get the file extension.
|
|
10044
|
+
const fileExtension = filePath.slice(filePath.lastIndexOf('.') + 1);
|
|
10045
|
+
// Create a map of file extensions to MIME types.
|
|
10046
|
+
const mimeTypes = {
|
|
10047
|
+
'aac': 'audio/aac',
|
|
10048
|
+
'abw': 'application/x-abiword',
|
|
10049
|
+
'arc': 'application/x-freearc',
|
|
10050
|
+
'avi': 'video/x-msvideo',
|
|
10051
|
+
'azw': 'application/vnd.amazon.ebook',
|
|
10052
|
+
'bin': 'application/octet-stream',
|
|
10053
|
+
'bmp': 'image/bmp',
|
|
10054
|
+
'bz': 'application/x-bzip',
|
|
10055
|
+
'bz2': 'application/x-bzip2',
|
|
10056
|
+
'csh': 'application/x-csh',
|
|
10057
|
+
'css': 'text/css',
|
|
9407
10058
|
'csv': 'text/csv',
|
|
9408
10059
|
'doc': 'application/msword',
|
|
9409
10060
|
'docx': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
@@ -9619,6 +10270,15 @@ class GoogleGenAI {
|
|
|
9619
10270
|
this.apiKey = undefined;
|
|
9620
10271
|
}
|
|
9621
10272
|
}
|
|
10273
|
+
const baseUrl = getBaseUrl(options, getEnv('GOOGLE_VERTEX_BASE_URL'), getEnv('GOOGLE_GEMINI_BASE_URL'));
|
|
10274
|
+
if (baseUrl) {
|
|
10275
|
+
if (options.httpOptions) {
|
|
10276
|
+
options.httpOptions.baseUrl = baseUrl;
|
|
10277
|
+
}
|
|
10278
|
+
else {
|
|
10279
|
+
options.httpOptions = { baseUrl: baseUrl };
|
|
10280
|
+
}
|
|
10281
|
+
}
|
|
9622
10282
|
this.apiVersion = options.apiVersion;
|
|
9623
10283
|
const auth = new NodeAuth({
|
|
9624
10284
|
apiKey: this.apiKey,
|
|
@@ -9641,6 +10301,7 @@ class GoogleGenAI {
|
|
|
9641
10301
|
this.caches = new Caches(this.apiClient);
|
|
9642
10302
|
this.files = new Files(this.apiClient);
|
|
9643
10303
|
this.operations = new Operations(this.apiClient);
|
|
10304
|
+
this.tunings = new Tunings(this.apiClient);
|
|
9644
10305
|
}
|
|
9645
10306
|
}
|
|
9646
10307
|
function getEnv(env) {
|
|
@@ -9665,6 +10326,7 @@ exports.CountTokensResponse = CountTokensResponse;
|
|
|
9665
10326
|
exports.CreateFileResponse = CreateFileResponse;
|
|
9666
10327
|
exports.DeleteCachedContentResponse = DeleteCachedContentResponse;
|
|
9667
10328
|
exports.DeleteFileResponse = DeleteFileResponse;
|
|
10329
|
+
exports.DeleteModelResponse = DeleteModelResponse;
|
|
9668
10330
|
exports.EmbedContentResponse = EmbedContentResponse;
|
|
9669
10331
|
exports.Files = Files;
|
|
9670
10332
|
exports.FunctionResponse = FunctionResponse;
|
|
@@ -9677,6 +10339,7 @@ exports.GoogleGenAI = GoogleGenAI;
|
|
|
9677
10339
|
exports.HttpResponse = HttpResponse;
|
|
9678
10340
|
exports.ListCachedContentsResponse = ListCachedContentsResponse;
|
|
9679
10341
|
exports.ListFilesResponse = ListFilesResponse;
|
|
10342
|
+
exports.ListTuningJobsResponse = ListTuningJobsResponse;
|
|
9680
10343
|
exports.Live = Live;
|
|
9681
10344
|
exports.LiveClientToolResponse = LiveClientToolResponse;
|
|
9682
10345
|
exports.LiveSendToolResponseParameters = LiveSendToolResponseParameters;
|
|
@@ -9694,4 +10357,5 @@ exports.createPartFromFunctionResponse = createPartFromFunctionResponse;
|
|
|
9694
10357
|
exports.createPartFromText = createPartFromText;
|
|
9695
10358
|
exports.createPartFromUri = createPartFromUri;
|
|
9696
10359
|
exports.createUserContent = createUserContent;
|
|
10360
|
+
exports.setDefaultBaseUrls = setDefaultBaseUrls;
|
|
9697
10361
|
//# sourceMappingURL=index.js.map
|