@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/index.mjs
CHANGED
|
@@ -1,3 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Overrides the base URLs for the Gemini API and Vertex AI API.
|
|
8
|
+
*
|
|
9
|
+
* @remarks This function should be called before initializing the SDK. If the
|
|
10
|
+
* base URLs are set after initializing the SDK, the base URLs will not be
|
|
11
|
+
* updated. Base URLs provided in the HttpOptions will also take precedence over
|
|
12
|
+
* URLs set here.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* import {GoogleGenAI, setDefaultBaseUrls} from '@google/genai';
|
|
17
|
+
* // Override the base URL for the Gemini API.
|
|
18
|
+
* setDefaultBaseUrls({geminiUrl:'https://gemini.google.com'});
|
|
19
|
+
*
|
|
20
|
+
* // Override the base URL for the Vertex AI API.
|
|
21
|
+
* setDefaultBaseUrls({vertexUrl: 'https://vertexai.googleapis.com'});
|
|
22
|
+
*
|
|
23
|
+
* const ai = new GoogleGenAI({apiKey: 'GEMINI_API_KEY'});
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
function setDefaultBaseUrls(baseUrlParams) {
|
|
27
|
+
baseUrlParams.geminiUrl;
|
|
28
|
+
baseUrlParams.vertexUrl;
|
|
29
|
+
}
|
|
30
|
+
|
|
1
31
|
/**
|
|
2
32
|
* @license
|
|
3
33
|
* Copyright 2025 Google LLC
|
|
@@ -173,6 +203,36 @@ function tCachesModel(apiClient, model) {
|
|
|
173
203
|
return transformedModel;
|
|
174
204
|
}
|
|
175
205
|
}
|
|
206
|
+
function tBlobs(apiClient, blobs) {
|
|
207
|
+
if (Array.isArray(blobs)) {
|
|
208
|
+
return blobs.map((blob) => tBlob(apiClient, blob));
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
return [tBlob(apiClient, blobs)];
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
function tBlob(apiClient, blob) {
|
|
215
|
+
if (typeof blob === 'object' && blob !== null) {
|
|
216
|
+
return blob;
|
|
217
|
+
}
|
|
218
|
+
throw new Error(`Could not parse input as Blob. Unsupported blob type: ${typeof blob}`);
|
|
219
|
+
}
|
|
220
|
+
function tImageBlob(apiClient, blob) {
|
|
221
|
+
const transformedBlob = tBlob(apiClient, blob);
|
|
222
|
+
if (transformedBlob.mimeType &&
|
|
223
|
+
transformedBlob.mimeType.startsWith('image/')) {
|
|
224
|
+
return transformedBlob;
|
|
225
|
+
}
|
|
226
|
+
throw new Error(`Unsupported mime type: ${transformedBlob.mimeType}`);
|
|
227
|
+
}
|
|
228
|
+
function tAudioBlob(apiClient, blob) {
|
|
229
|
+
const transformedBlob = tBlob(apiClient, blob);
|
|
230
|
+
if (transformedBlob.mimeType &&
|
|
231
|
+
transformedBlob.mimeType.startsWith('audio/')) {
|
|
232
|
+
return transformedBlob;
|
|
233
|
+
}
|
|
234
|
+
throw new Error(`Unsupported mime type: ${transformedBlob.mimeType}`);
|
|
235
|
+
}
|
|
176
236
|
function tPart(apiClient, origin) {
|
|
177
237
|
if (origin === null || origin === undefined) {
|
|
178
238
|
throw new Error('PartUnion is required');
|
|
@@ -296,38 +356,11 @@ function tContents(apiClient, origin) {
|
|
|
296
356
|
}
|
|
297
357
|
return result;
|
|
298
358
|
}
|
|
299
|
-
function processSchema(apiClient, schema) {
|
|
300
|
-
if (!apiClient.isVertexAI()) {
|
|
301
|
-
if ('default' in schema) {
|
|
302
|
-
throw new Error('Default value is not supported in the response schema for the Gemini API.');
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
if ('anyOf' in schema) {
|
|
306
|
-
if (schema['anyOf'] !== undefined) {
|
|
307
|
-
for (const subSchema of schema['anyOf']) {
|
|
308
|
-
processSchema(apiClient, subSchema);
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
if ('items' in schema) {
|
|
313
|
-
if (schema['items'] !== undefined) {
|
|
314
|
-
processSchema(apiClient, schema['items']);
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
if ('properties' in schema) {
|
|
318
|
-
if (schema['properties'] !== undefined) {
|
|
319
|
-
for (const subSchema of Object.values(schema['properties'])) {
|
|
320
|
-
processSchema(apiClient, subSchema);
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
359
|
function tSchema(apiClient, schema) {
|
|
326
|
-
processSchema(apiClient, schema);
|
|
327
360
|
return schema;
|
|
328
361
|
}
|
|
329
362
|
function tSpeechConfig(apiClient, speechConfig) {
|
|
330
|
-
if (typeof speechConfig === 'object'
|
|
363
|
+
if (typeof speechConfig === 'object') {
|
|
331
364
|
return speechConfig;
|
|
332
365
|
}
|
|
333
366
|
else if (typeof speechConfig === 'string') {
|
|
@@ -435,6 +468,20 @@ function tCachedContentName(apiClient, name) {
|
|
|
435
468
|
}
|
|
436
469
|
return resourceName(apiClient, name, 'cachedContents');
|
|
437
470
|
}
|
|
471
|
+
function tTuningJobStatus(apiClient, status) {
|
|
472
|
+
switch (status) {
|
|
473
|
+
case 'STATE_UNSPECIFIED':
|
|
474
|
+
return 'JOB_STATE_UNSPECIFIED';
|
|
475
|
+
case 'CREATING':
|
|
476
|
+
return 'JOB_STATE_RUNNING';
|
|
477
|
+
case 'ACTIVE':
|
|
478
|
+
return 'JOB_STATE_SUCCEEDED';
|
|
479
|
+
case 'FAILED':
|
|
480
|
+
return 'JOB_STATE_FAILED';
|
|
481
|
+
default:
|
|
482
|
+
return status;
|
|
483
|
+
}
|
|
484
|
+
}
|
|
438
485
|
function tBytes(apiClient, fromImageBytes) {
|
|
439
486
|
if (typeof fromImageBytes !== 'string') {
|
|
440
487
|
throw new Error('fromImageBytes must be a string');
|
|
@@ -507,14 +554,13 @@ function contentToMldev$2(apiClient, fromObject) {
|
|
|
507
554
|
const toObject = {};
|
|
508
555
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
509
556
|
if (fromParts != null) {
|
|
510
|
-
|
|
511
|
-
|
|
557
|
+
let transformedList = fromParts;
|
|
558
|
+
if (Array.isArray(transformedList)) {
|
|
559
|
+
transformedList = transformedList.map((item) => {
|
|
512
560
|
return partToMldev$2(apiClient, item);
|
|
513
|
-
})
|
|
514
|
-
}
|
|
515
|
-
else {
|
|
516
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
561
|
+
});
|
|
517
562
|
}
|
|
563
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
518
564
|
}
|
|
519
565
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
520
566
|
if (fromRole != null) {
|
|
@@ -522,25 +568,6 @@ function contentToMldev$2(apiClient, fromObject) {
|
|
|
522
568
|
}
|
|
523
569
|
return toObject;
|
|
524
570
|
}
|
|
525
|
-
function functionDeclarationToMldev$2(apiClient, fromObject) {
|
|
526
|
-
const toObject = {};
|
|
527
|
-
if (getValueByPath(fromObject, ['response']) !== undefined) {
|
|
528
|
-
throw new Error('response parameter is not supported in Gemini API.');
|
|
529
|
-
}
|
|
530
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
531
|
-
if (fromDescription != null) {
|
|
532
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
533
|
-
}
|
|
534
|
-
const fromName = getValueByPath(fromObject, ['name']);
|
|
535
|
-
if (fromName != null) {
|
|
536
|
-
setValueByPath(toObject, ['name'], fromName);
|
|
537
|
-
}
|
|
538
|
-
const fromParameters = getValueByPath(fromObject, ['parameters']);
|
|
539
|
-
if (fromParameters != null) {
|
|
540
|
-
setValueByPath(toObject, ['parameters'], fromParameters);
|
|
541
|
-
}
|
|
542
|
-
return toObject;
|
|
543
|
-
}
|
|
544
571
|
function googleSearchToMldev$2() {
|
|
545
572
|
const toObject = {};
|
|
546
573
|
return toObject;
|
|
@@ -571,19 +598,6 @@ function googleSearchRetrievalToMldev$2(apiClient, fromObject) {
|
|
|
571
598
|
}
|
|
572
599
|
function toolToMldev$2(apiClient, fromObject) {
|
|
573
600
|
const toObject = {};
|
|
574
|
-
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
575
|
-
'functionDeclarations',
|
|
576
|
-
]);
|
|
577
|
-
if (fromFunctionDeclarations != null) {
|
|
578
|
-
if (Array.isArray(fromFunctionDeclarations)) {
|
|
579
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations.map((item) => {
|
|
580
|
-
return functionDeclarationToMldev$2(apiClient, item);
|
|
581
|
-
}));
|
|
582
|
-
}
|
|
583
|
-
else {
|
|
584
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
601
|
if (getValueByPath(fromObject, ['retrieval']) !== undefined) {
|
|
588
602
|
throw new Error('retrieval parameter is not supported in Gemini API.');
|
|
589
603
|
}
|
|
@@ -603,6 +617,12 @@ function toolToMldev$2(apiClient, fromObject) {
|
|
|
603
617
|
if (fromCodeExecution != null) {
|
|
604
618
|
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
605
619
|
}
|
|
620
|
+
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
621
|
+
'functionDeclarations',
|
|
622
|
+
]);
|
|
623
|
+
if (fromFunctionDeclarations != null) {
|
|
624
|
+
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
625
|
+
}
|
|
606
626
|
return toObject;
|
|
607
627
|
}
|
|
608
628
|
function functionCallingConfigToMldev$1(apiClient, fromObject) {
|
|
@@ -645,14 +665,13 @@ function createCachedContentConfigToMldev(apiClient, fromObject, parentObject) {
|
|
|
645
665
|
}
|
|
646
666
|
const fromContents = getValueByPath(fromObject, ['contents']);
|
|
647
667
|
if (parentObject !== undefined && fromContents != null) {
|
|
648
|
-
|
|
649
|
-
|
|
668
|
+
let transformedList = tContents(apiClient, fromContents);
|
|
669
|
+
if (Array.isArray(transformedList)) {
|
|
670
|
+
transformedList = transformedList.map((item) => {
|
|
650
671
|
return contentToMldev$2(apiClient, item);
|
|
651
|
-
})
|
|
652
|
-
}
|
|
653
|
-
else {
|
|
654
|
-
setValueByPath(parentObject, ['contents'], tContents(apiClient, fromContents));
|
|
672
|
+
});
|
|
655
673
|
}
|
|
674
|
+
setValueByPath(parentObject, ['contents'], transformedList);
|
|
656
675
|
}
|
|
657
676
|
const fromSystemInstruction = getValueByPath(fromObject, [
|
|
658
677
|
'systemInstruction',
|
|
@@ -662,14 +681,13 @@ function createCachedContentConfigToMldev(apiClient, fromObject, parentObject) {
|
|
|
662
681
|
}
|
|
663
682
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
664
683
|
if (parentObject !== undefined && fromTools != null) {
|
|
665
|
-
|
|
666
|
-
|
|
684
|
+
let transformedList = fromTools;
|
|
685
|
+
if (Array.isArray(transformedList)) {
|
|
686
|
+
transformedList = transformedList.map((item) => {
|
|
667
687
|
return toolToMldev$2(apiClient, item);
|
|
668
|
-
})
|
|
669
|
-
}
|
|
670
|
-
else {
|
|
671
|
-
setValueByPath(parentObject, ['tools'], fromTools);
|
|
688
|
+
});
|
|
672
689
|
}
|
|
690
|
+
setValueByPath(parentObject, ['tools'], transformedList);
|
|
673
691
|
}
|
|
674
692
|
const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
|
|
675
693
|
if (parentObject !== undefined && fromToolConfig != null) {
|
|
@@ -809,14 +827,13 @@ function contentToVertex$2(apiClient, fromObject) {
|
|
|
809
827
|
const toObject = {};
|
|
810
828
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
811
829
|
if (fromParts != null) {
|
|
812
|
-
|
|
813
|
-
|
|
830
|
+
let transformedList = fromParts;
|
|
831
|
+
if (Array.isArray(transformedList)) {
|
|
832
|
+
transformedList = transformedList.map((item) => {
|
|
814
833
|
return partToVertex$2(apiClient, item);
|
|
815
|
-
})
|
|
816
|
-
}
|
|
817
|
-
else {
|
|
818
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
834
|
+
});
|
|
819
835
|
}
|
|
836
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
820
837
|
}
|
|
821
838
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
822
839
|
if (fromRole != null) {
|
|
@@ -824,124 +841,6 @@ function contentToVertex$2(apiClient, fromObject) {
|
|
|
824
841
|
}
|
|
825
842
|
return toObject;
|
|
826
843
|
}
|
|
827
|
-
function schemaToVertex$2(apiClient, fromObject) {
|
|
828
|
-
const toObject = {};
|
|
829
|
-
const fromExample = getValueByPath(fromObject, ['example']);
|
|
830
|
-
if (fromExample != null) {
|
|
831
|
-
setValueByPath(toObject, ['example'], fromExample);
|
|
832
|
-
}
|
|
833
|
-
const fromPattern = getValueByPath(fromObject, ['pattern']);
|
|
834
|
-
if (fromPattern != null) {
|
|
835
|
-
setValueByPath(toObject, ['pattern'], fromPattern);
|
|
836
|
-
}
|
|
837
|
-
const fromDefault = getValueByPath(fromObject, ['default']);
|
|
838
|
-
if (fromDefault != null) {
|
|
839
|
-
setValueByPath(toObject, ['default'], fromDefault);
|
|
840
|
-
}
|
|
841
|
-
const fromMaxLength = getValueByPath(fromObject, ['maxLength']);
|
|
842
|
-
if (fromMaxLength != null) {
|
|
843
|
-
setValueByPath(toObject, ['maxLength'], fromMaxLength);
|
|
844
|
-
}
|
|
845
|
-
const fromMinLength = getValueByPath(fromObject, ['minLength']);
|
|
846
|
-
if (fromMinLength != null) {
|
|
847
|
-
setValueByPath(toObject, ['minLength'], fromMinLength);
|
|
848
|
-
}
|
|
849
|
-
const fromMinProperties = getValueByPath(fromObject, [
|
|
850
|
-
'minProperties',
|
|
851
|
-
]);
|
|
852
|
-
if (fromMinProperties != null) {
|
|
853
|
-
setValueByPath(toObject, ['minProperties'], fromMinProperties);
|
|
854
|
-
}
|
|
855
|
-
const fromMaxProperties = getValueByPath(fromObject, [
|
|
856
|
-
'maxProperties',
|
|
857
|
-
]);
|
|
858
|
-
if (fromMaxProperties != null) {
|
|
859
|
-
setValueByPath(toObject, ['maxProperties'], fromMaxProperties);
|
|
860
|
-
}
|
|
861
|
-
const fromAnyOf = getValueByPath(fromObject, ['anyOf']);
|
|
862
|
-
if (fromAnyOf != null) {
|
|
863
|
-
setValueByPath(toObject, ['anyOf'], fromAnyOf);
|
|
864
|
-
}
|
|
865
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
866
|
-
if (fromDescription != null) {
|
|
867
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
868
|
-
}
|
|
869
|
-
const fromEnum = getValueByPath(fromObject, ['enum']);
|
|
870
|
-
if (fromEnum != null) {
|
|
871
|
-
setValueByPath(toObject, ['enum'], fromEnum);
|
|
872
|
-
}
|
|
873
|
-
const fromFormat = getValueByPath(fromObject, ['format']);
|
|
874
|
-
if (fromFormat != null) {
|
|
875
|
-
setValueByPath(toObject, ['format'], fromFormat);
|
|
876
|
-
}
|
|
877
|
-
const fromItems = getValueByPath(fromObject, ['items']);
|
|
878
|
-
if (fromItems != null) {
|
|
879
|
-
setValueByPath(toObject, ['items'], fromItems);
|
|
880
|
-
}
|
|
881
|
-
const fromMaxItems = getValueByPath(fromObject, ['maxItems']);
|
|
882
|
-
if (fromMaxItems != null) {
|
|
883
|
-
setValueByPath(toObject, ['maxItems'], fromMaxItems);
|
|
884
|
-
}
|
|
885
|
-
const fromMaximum = getValueByPath(fromObject, ['maximum']);
|
|
886
|
-
if (fromMaximum != null) {
|
|
887
|
-
setValueByPath(toObject, ['maximum'], fromMaximum);
|
|
888
|
-
}
|
|
889
|
-
const fromMinItems = getValueByPath(fromObject, ['minItems']);
|
|
890
|
-
if (fromMinItems != null) {
|
|
891
|
-
setValueByPath(toObject, ['minItems'], fromMinItems);
|
|
892
|
-
}
|
|
893
|
-
const fromMinimum = getValueByPath(fromObject, ['minimum']);
|
|
894
|
-
if (fromMinimum != null) {
|
|
895
|
-
setValueByPath(toObject, ['minimum'], fromMinimum);
|
|
896
|
-
}
|
|
897
|
-
const fromNullable = getValueByPath(fromObject, ['nullable']);
|
|
898
|
-
if (fromNullable != null) {
|
|
899
|
-
setValueByPath(toObject, ['nullable'], fromNullable);
|
|
900
|
-
}
|
|
901
|
-
const fromProperties = getValueByPath(fromObject, ['properties']);
|
|
902
|
-
if (fromProperties != null) {
|
|
903
|
-
setValueByPath(toObject, ['properties'], fromProperties);
|
|
904
|
-
}
|
|
905
|
-
const fromPropertyOrdering = getValueByPath(fromObject, [
|
|
906
|
-
'propertyOrdering',
|
|
907
|
-
]);
|
|
908
|
-
if (fromPropertyOrdering != null) {
|
|
909
|
-
setValueByPath(toObject, ['propertyOrdering'], fromPropertyOrdering);
|
|
910
|
-
}
|
|
911
|
-
const fromRequired = getValueByPath(fromObject, ['required']);
|
|
912
|
-
if (fromRequired != null) {
|
|
913
|
-
setValueByPath(toObject, ['required'], fromRequired);
|
|
914
|
-
}
|
|
915
|
-
const fromTitle = getValueByPath(fromObject, ['title']);
|
|
916
|
-
if (fromTitle != null) {
|
|
917
|
-
setValueByPath(toObject, ['title'], fromTitle);
|
|
918
|
-
}
|
|
919
|
-
const fromType = getValueByPath(fromObject, ['type']);
|
|
920
|
-
if (fromType != null) {
|
|
921
|
-
setValueByPath(toObject, ['type'], fromType);
|
|
922
|
-
}
|
|
923
|
-
return toObject;
|
|
924
|
-
}
|
|
925
|
-
function functionDeclarationToVertex$2(apiClient, fromObject) {
|
|
926
|
-
const toObject = {};
|
|
927
|
-
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
928
|
-
if (fromResponse != null) {
|
|
929
|
-
setValueByPath(toObject, ['response'], schemaToVertex$2(apiClient, fromResponse));
|
|
930
|
-
}
|
|
931
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
932
|
-
if (fromDescription != null) {
|
|
933
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
934
|
-
}
|
|
935
|
-
const fromName = getValueByPath(fromObject, ['name']);
|
|
936
|
-
if (fromName != null) {
|
|
937
|
-
setValueByPath(toObject, ['name'], fromName);
|
|
938
|
-
}
|
|
939
|
-
const fromParameters = getValueByPath(fromObject, ['parameters']);
|
|
940
|
-
if (fromParameters != null) {
|
|
941
|
-
setValueByPath(toObject, ['parameters'], fromParameters);
|
|
942
|
-
}
|
|
943
|
-
return toObject;
|
|
944
|
-
}
|
|
945
844
|
function googleSearchToVertex$2() {
|
|
946
845
|
const toObject = {};
|
|
947
846
|
return toObject;
|
|
@@ -972,19 +871,6 @@ function googleSearchRetrievalToVertex$2(apiClient, fromObject) {
|
|
|
972
871
|
}
|
|
973
872
|
function toolToVertex$2(apiClient, fromObject) {
|
|
974
873
|
const toObject = {};
|
|
975
|
-
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
976
|
-
'functionDeclarations',
|
|
977
|
-
]);
|
|
978
|
-
if (fromFunctionDeclarations != null) {
|
|
979
|
-
if (Array.isArray(fromFunctionDeclarations)) {
|
|
980
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations.map((item) => {
|
|
981
|
-
return functionDeclarationToVertex$2(apiClient, item);
|
|
982
|
-
}));
|
|
983
|
-
}
|
|
984
|
-
else {
|
|
985
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
986
|
-
}
|
|
987
|
-
}
|
|
988
874
|
const fromRetrieval = getValueByPath(fromObject, ['retrieval']);
|
|
989
875
|
if (fromRetrieval != null) {
|
|
990
876
|
setValueByPath(toObject, ['retrieval'], fromRetrieval);
|
|
@@ -1005,6 +891,12 @@ function toolToVertex$2(apiClient, fromObject) {
|
|
|
1005
891
|
if (fromCodeExecution != null) {
|
|
1006
892
|
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
1007
893
|
}
|
|
894
|
+
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
895
|
+
'functionDeclarations',
|
|
896
|
+
]);
|
|
897
|
+
if (fromFunctionDeclarations != null) {
|
|
898
|
+
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
899
|
+
}
|
|
1008
900
|
return toObject;
|
|
1009
901
|
}
|
|
1010
902
|
function functionCallingConfigToVertex$1(apiClient, fromObject) {
|
|
@@ -1047,14 +939,13 @@ function createCachedContentConfigToVertex(apiClient, fromObject, parentObject)
|
|
|
1047
939
|
}
|
|
1048
940
|
const fromContents = getValueByPath(fromObject, ['contents']);
|
|
1049
941
|
if (parentObject !== undefined && fromContents != null) {
|
|
1050
|
-
|
|
1051
|
-
|
|
942
|
+
let transformedList = tContents(apiClient, fromContents);
|
|
943
|
+
if (Array.isArray(transformedList)) {
|
|
944
|
+
transformedList = transformedList.map((item) => {
|
|
1052
945
|
return contentToVertex$2(apiClient, item);
|
|
1053
|
-
})
|
|
1054
|
-
}
|
|
1055
|
-
else {
|
|
1056
|
-
setValueByPath(parentObject, ['contents'], tContents(apiClient, fromContents));
|
|
946
|
+
});
|
|
1057
947
|
}
|
|
948
|
+
setValueByPath(parentObject, ['contents'], transformedList);
|
|
1058
949
|
}
|
|
1059
950
|
const fromSystemInstruction = getValueByPath(fromObject, [
|
|
1060
951
|
'systemInstruction',
|
|
@@ -1064,14 +955,13 @@ function createCachedContentConfigToVertex(apiClient, fromObject, parentObject)
|
|
|
1064
955
|
}
|
|
1065
956
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
1066
957
|
if (parentObject !== undefined && fromTools != null) {
|
|
1067
|
-
|
|
1068
|
-
|
|
958
|
+
let transformedList = fromTools;
|
|
959
|
+
if (Array.isArray(transformedList)) {
|
|
960
|
+
transformedList = transformedList.map((item) => {
|
|
1069
961
|
return toolToVertex$2(apiClient, item);
|
|
1070
|
-
})
|
|
1071
|
-
}
|
|
1072
|
-
else {
|
|
1073
|
-
setValueByPath(parentObject, ['tools'], fromTools);
|
|
962
|
+
});
|
|
1074
963
|
}
|
|
964
|
+
setValueByPath(parentObject, ['tools'], transformedList);
|
|
1075
965
|
}
|
|
1076
966
|
const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
|
|
1077
967
|
if (parentObject !== undefined && fromToolConfig != null) {
|
|
@@ -1209,14 +1099,13 @@ function listCachedContentsResponseFromMldev(apiClient, fromObject) {
|
|
|
1209
1099
|
'cachedContents',
|
|
1210
1100
|
]);
|
|
1211
1101
|
if (fromCachedContents != null) {
|
|
1212
|
-
|
|
1213
|
-
|
|
1102
|
+
let transformedList = fromCachedContents;
|
|
1103
|
+
if (Array.isArray(transformedList)) {
|
|
1104
|
+
transformedList = transformedList.map((item) => {
|
|
1214
1105
|
return cachedContentFromMldev(apiClient, item);
|
|
1215
|
-
})
|
|
1216
|
-
}
|
|
1217
|
-
else {
|
|
1218
|
-
setValueByPath(toObject, ['cachedContents'], fromCachedContents);
|
|
1106
|
+
});
|
|
1219
1107
|
}
|
|
1108
|
+
setValueByPath(toObject, ['cachedContents'], transformedList);
|
|
1220
1109
|
}
|
|
1221
1110
|
return toObject;
|
|
1222
1111
|
}
|
|
@@ -1270,14 +1159,13 @@ function listCachedContentsResponseFromVertex(apiClient, fromObject) {
|
|
|
1270
1159
|
'cachedContents',
|
|
1271
1160
|
]);
|
|
1272
1161
|
if (fromCachedContents != null) {
|
|
1273
|
-
|
|
1274
|
-
|
|
1162
|
+
let transformedList = fromCachedContents;
|
|
1163
|
+
if (Array.isArray(transformedList)) {
|
|
1164
|
+
transformedList = transformedList.map((item) => {
|
|
1275
1165
|
return cachedContentFromVertex(apiClient, item);
|
|
1276
|
-
})
|
|
1277
|
-
}
|
|
1278
|
-
else {
|
|
1279
|
-
setValueByPath(toObject, ['cachedContents'], fromCachedContents);
|
|
1166
|
+
});
|
|
1280
1167
|
}
|
|
1168
|
+
setValueByPath(toObject, ['cachedContents'], transformedList);
|
|
1281
1169
|
}
|
|
1282
1170
|
return toObject;
|
|
1283
1171
|
}
|
|
@@ -1479,17 +1367,6 @@ var Language;
|
|
|
1479
1367
|
Language["LANGUAGE_UNSPECIFIED"] = "LANGUAGE_UNSPECIFIED";
|
|
1480
1368
|
Language["PYTHON"] = "PYTHON";
|
|
1481
1369
|
})(Language || (Language = {}));
|
|
1482
|
-
/** Optional. The type of the data. */
|
|
1483
|
-
var Type;
|
|
1484
|
-
(function (Type) {
|
|
1485
|
-
Type["TYPE_UNSPECIFIED"] = "TYPE_UNSPECIFIED";
|
|
1486
|
-
Type["STRING"] = "STRING";
|
|
1487
|
-
Type["NUMBER"] = "NUMBER";
|
|
1488
|
-
Type["INTEGER"] = "INTEGER";
|
|
1489
|
-
Type["BOOLEAN"] = "BOOLEAN";
|
|
1490
|
-
Type["ARRAY"] = "ARRAY";
|
|
1491
|
-
Type["OBJECT"] = "OBJECT";
|
|
1492
|
-
})(Type || (Type = {}));
|
|
1493
1370
|
/** Required. Harm category. */
|
|
1494
1371
|
var HarmCategory;
|
|
1495
1372
|
(function (HarmCategory) {
|
|
@@ -1523,6 +1400,17 @@ var Mode;
|
|
|
1523
1400
|
Mode["MODE_UNSPECIFIED"] = "MODE_UNSPECIFIED";
|
|
1524
1401
|
Mode["MODE_DYNAMIC"] = "MODE_DYNAMIC";
|
|
1525
1402
|
})(Mode || (Mode = {}));
|
|
1403
|
+
/** Optional. The type of the data. */
|
|
1404
|
+
var Type;
|
|
1405
|
+
(function (Type) {
|
|
1406
|
+
Type["TYPE_UNSPECIFIED"] = "TYPE_UNSPECIFIED";
|
|
1407
|
+
Type["STRING"] = "STRING";
|
|
1408
|
+
Type["NUMBER"] = "NUMBER";
|
|
1409
|
+
Type["INTEGER"] = "INTEGER";
|
|
1410
|
+
Type["BOOLEAN"] = "BOOLEAN";
|
|
1411
|
+
Type["ARRAY"] = "ARRAY";
|
|
1412
|
+
Type["OBJECT"] = "OBJECT";
|
|
1413
|
+
})(Type || (Type = {}));
|
|
1526
1414
|
/** Output only. The reason why the model stopped generating tokens.
|
|
1527
1415
|
|
|
1528
1416
|
If empty, the model has not stopped generating the tokens.
|
|
@@ -1534,6 +1422,7 @@ var FinishReason;
|
|
|
1534
1422
|
FinishReason["MAX_TOKENS"] = "MAX_TOKENS";
|
|
1535
1423
|
FinishReason["SAFETY"] = "SAFETY";
|
|
1536
1424
|
FinishReason["RECITATION"] = "RECITATION";
|
|
1425
|
+
FinishReason["LANGUAGE"] = "LANGUAGE";
|
|
1537
1426
|
FinishReason["OTHER"] = "OTHER";
|
|
1538
1427
|
FinishReason["BLOCKLIST"] = "BLOCKLIST";
|
|
1539
1428
|
FinishReason["PROHIBITED_CONTENT"] = "PROHIBITED_CONTENT";
|
|
@@ -1591,6 +1480,33 @@ var MediaResolution;
|
|
|
1591
1480
|
MediaResolution["MEDIA_RESOLUTION_MEDIUM"] = "MEDIA_RESOLUTION_MEDIUM";
|
|
1592
1481
|
MediaResolution["MEDIA_RESOLUTION_HIGH"] = "MEDIA_RESOLUTION_HIGH";
|
|
1593
1482
|
})(MediaResolution || (MediaResolution = {}));
|
|
1483
|
+
/** Output only. The detailed state of the job. */
|
|
1484
|
+
var JobState;
|
|
1485
|
+
(function (JobState) {
|
|
1486
|
+
JobState["JOB_STATE_UNSPECIFIED"] = "JOB_STATE_UNSPECIFIED";
|
|
1487
|
+
JobState["JOB_STATE_QUEUED"] = "JOB_STATE_QUEUED";
|
|
1488
|
+
JobState["JOB_STATE_PENDING"] = "JOB_STATE_PENDING";
|
|
1489
|
+
JobState["JOB_STATE_RUNNING"] = "JOB_STATE_RUNNING";
|
|
1490
|
+
JobState["JOB_STATE_SUCCEEDED"] = "JOB_STATE_SUCCEEDED";
|
|
1491
|
+
JobState["JOB_STATE_FAILED"] = "JOB_STATE_FAILED";
|
|
1492
|
+
JobState["JOB_STATE_CANCELLING"] = "JOB_STATE_CANCELLING";
|
|
1493
|
+
JobState["JOB_STATE_CANCELLED"] = "JOB_STATE_CANCELLED";
|
|
1494
|
+
JobState["JOB_STATE_PAUSED"] = "JOB_STATE_PAUSED";
|
|
1495
|
+
JobState["JOB_STATE_EXPIRED"] = "JOB_STATE_EXPIRED";
|
|
1496
|
+
JobState["JOB_STATE_UPDATING"] = "JOB_STATE_UPDATING";
|
|
1497
|
+
JobState["JOB_STATE_PARTIALLY_SUCCEEDED"] = "JOB_STATE_PARTIALLY_SUCCEEDED";
|
|
1498
|
+
})(JobState || (JobState = {}));
|
|
1499
|
+
/** Optional. Adapter size for tuning. */
|
|
1500
|
+
var AdapterSize;
|
|
1501
|
+
(function (AdapterSize) {
|
|
1502
|
+
AdapterSize["ADAPTER_SIZE_UNSPECIFIED"] = "ADAPTER_SIZE_UNSPECIFIED";
|
|
1503
|
+
AdapterSize["ADAPTER_SIZE_ONE"] = "ADAPTER_SIZE_ONE";
|
|
1504
|
+
AdapterSize["ADAPTER_SIZE_TWO"] = "ADAPTER_SIZE_TWO";
|
|
1505
|
+
AdapterSize["ADAPTER_SIZE_FOUR"] = "ADAPTER_SIZE_FOUR";
|
|
1506
|
+
AdapterSize["ADAPTER_SIZE_EIGHT"] = "ADAPTER_SIZE_EIGHT";
|
|
1507
|
+
AdapterSize["ADAPTER_SIZE_SIXTEEN"] = "ADAPTER_SIZE_SIXTEEN";
|
|
1508
|
+
AdapterSize["ADAPTER_SIZE_THIRTY_TWO"] = "ADAPTER_SIZE_THIRTY_TWO";
|
|
1509
|
+
})(AdapterSize || (AdapterSize = {}));
|
|
1594
1510
|
/** Options for feature selection preference. */
|
|
1595
1511
|
var FeatureSelectionPreference;
|
|
1596
1512
|
(function (FeatureSelectionPreference) {
|
|
@@ -1916,6 +1832,42 @@ class GenerateContentResponse {
|
|
|
1916
1832
|
// part.text === '' is different from part.text is null
|
|
1917
1833
|
return anyTextPartText ? text : undefined;
|
|
1918
1834
|
}
|
|
1835
|
+
/**
|
|
1836
|
+
* Returns the concatenation of all inline data parts from the first candidate
|
|
1837
|
+
* in the response.
|
|
1838
|
+
*
|
|
1839
|
+
* @remarks
|
|
1840
|
+
* If there are multiple candidates in the response, the inline data from the
|
|
1841
|
+
* first one will be returned. If there are non-inline data parts in the
|
|
1842
|
+
* response, the concatenation of all inline data parts will be returned, and
|
|
1843
|
+
* a warning will be logged.
|
|
1844
|
+
*/
|
|
1845
|
+
get data() {
|
|
1846
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1847
|
+
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) {
|
|
1848
|
+
return undefined;
|
|
1849
|
+
}
|
|
1850
|
+
if (this.candidates && this.candidates.length > 1) {
|
|
1851
|
+
console.warn('there are multiple candidates in the response, returning data from the first one.');
|
|
1852
|
+
}
|
|
1853
|
+
let data = '';
|
|
1854
|
+
const nonDataParts = [];
|
|
1855
|
+
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 : []) {
|
|
1856
|
+
for (const [fieldName, fieldValue] of Object.entries(part)) {
|
|
1857
|
+
if (fieldName !== 'inlineData' &&
|
|
1858
|
+
(fieldValue !== null || fieldValue !== undefined)) {
|
|
1859
|
+
nonDataParts.push(fieldName);
|
|
1860
|
+
}
|
|
1861
|
+
}
|
|
1862
|
+
if (part.inlineData && typeof part.inlineData.data === 'string') {
|
|
1863
|
+
data += atob(part.inlineData.data);
|
|
1864
|
+
}
|
|
1865
|
+
}
|
|
1866
|
+
if (nonDataParts.length > 0) {
|
|
1867
|
+
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.`);
|
|
1868
|
+
}
|
|
1869
|
+
return data.length > 0 ? btoa(data) : undefined;
|
|
1870
|
+
}
|
|
1919
1871
|
/**
|
|
1920
1872
|
* Returns the function calls from the first candidate in the response.
|
|
1921
1873
|
*
|
|
@@ -2055,6 +2007,8 @@ class EmbedContentResponse {
|
|
|
2055
2007
|
/** The output images response. */
|
|
2056
2008
|
class GenerateImagesResponse {
|
|
2057
2009
|
}
|
|
2010
|
+
class DeleteModelResponse {
|
|
2011
|
+
}
|
|
2058
2012
|
/** Response for counting tokens. */
|
|
2059
2013
|
class CountTokensResponse {
|
|
2060
2014
|
}
|
|
@@ -2064,6 +2018,9 @@ class ComputeTokensResponse {
|
|
|
2064
2018
|
/** Response with generated videos. */
|
|
2065
2019
|
class GenerateVideosResponse {
|
|
2066
2020
|
}
|
|
2021
|
+
/** Response for the list tuning jobs method. */
|
|
2022
|
+
class ListTuningJobsResponse {
|
|
2023
|
+
}
|
|
2067
2024
|
/** Empty response for caches.delete method. */
|
|
2068
2025
|
class DeleteCachedContentResponse {
|
|
2069
2026
|
}
|
|
@@ -2160,7 +2117,7 @@ class Caches extends BaseModule {
|
|
|
2160
2117
|
* ```ts
|
|
2161
2118
|
* const contents = ...; // Initialize the content to cache.
|
|
2162
2119
|
* const response = await ai.caches.create({
|
|
2163
|
-
* model: 'gemini-
|
|
2120
|
+
* model: 'gemini-2.0-flash-001',
|
|
2164
2121
|
* config: {
|
|
2165
2122
|
* 'contents': contents,
|
|
2166
2123
|
* 'displayName': 'test cache',
|
|
@@ -2171,7 +2128,7 @@ class Caches extends BaseModule {
|
|
|
2171
2128
|
* ```
|
|
2172
2129
|
*/
|
|
2173
2130
|
async create(params) {
|
|
2174
|
-
var _a, _b;
|
|
2131
|
+
var _a, _b, _c, _d;
|
|
2175
2132
|
let response;
|
|
2176
2133
|
let path = '';
|
|
2177
2134
|
let queryParams = {};
|
|
@@ -2189,6 +2146,7 @@ class Caches extends BaseModule {
|
|
|
2189
2146
|
body: JSON.stringify(body),
|
|
2190
2147
|
httpMethod: 'POST',
|
|
2191
2148
|
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
2149
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
2192
2150
|
})
|
|
2193
2151
|
.then((httpResponse) => {
|
|
2194
2152
|
return httpResponse.json();
|
|
@@ -2211,7 +2169,8 @@ class Caches extends BaseModule {
|
|
|
2211
2169
|
queryParams: queryParams,
|
|
2212
2170
|
body: JSON.stringify(body),
|
|
2213
2171
|
httpMethod: 'POST',
|
|
2214
|
-
httpOptions: (
|
|
2172
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
2173
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
2215
2174
|
})
|
|
2216
2175
|
.then((httpResponse) => {
|
|
2217
2176
|
return httpResponse.json();
|
|
@@ -2230,11 +2189,11 @@ class Caches extends BaseModule {
|
|
|
2230
2189
|
*
|
|
2231
2190
|
* @example
|
|
2232
2191
|
* ```ts
|
|
2233
|
-
* await ai.caches.get({name: '
|
|
2192
|
+
* await ai.caches.get({name: '...'}); // The server-generated resource name.
|
|
2234
2193
|
* ```
|
|
2235
2194
|
*/
|
|
2236
2195
|
async get(params) {
|
|
2237
|
-
var _a, _b;
|
|
2196
|
+
var _a, _b, _c, _d;
|
|
2238
2197
|
let response;
|
|
2239
2198
|
let path = '';
|
|
2240
2199
|
let queryParams = {};
|
|
@@ -2252,6 +2211,7 @@ class Caches extends BaseModule {
|
|
|
2252
2211
|
body: JSON.stringify(body),
|
|
2253
2212
|
httpMethod: 'GET',
|
|
2254
2213
|
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
2214
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
2255
2215
|
})
|
|
2256
2216
|
.then((httpResponse) => {
|
|
2257
2217
|
return httpResponse.json();
|
|
@@ -2274,7 +2234,8 @@ class Caches extends BaseModule {
|
|
|
2274
2234
|
queryParams: queryParams,
|
|
2275
2235
|
body: JSON.stringify(body),
|
|
2276
2236
|
httpMethod: 'GET',
|
|
2277
|
-
httpOptions: (
|
|
2237
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
2238
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
2278
2239
|
})
|
|
2279
2240
|
.then((httpResponse) => {
|
|
2280
2241
|
return httpResponse.json();
|
|
@@ -2293,11 +2254,11 @@ class Caches extends BaseModule {
|
|
|
2293
2254
|
*
|
|
2294
2255
|
* @example
|
|
2295
2256
|
* ```ts
|
|
2296
|
-
* await ai.caches.delete({name: '
|
|
2257
|
+
* await ai.caches.delete({name: '...'}); // The server-generated resource name.
|
|
2297
2258
|
* ```
|
|
2298
2259
|
*/
|
|
2299
2260
|
async delete(params) {
|
|
2300
|
-
var _a, _b;
|
|
2261
|
+
var _a, _b, _c, _d;
|
|
2301
2262
|
let response;
|
|
2302
2263
|
let path = '';
|
|
2303
2264
|
let queryParams = {};
|
|
@@ -2315,6 +2276,7 @@ class Caches extends BaseModule {
|
|
|
2315
2276
|
body: JSON.stringify(body),
|
|
2316
2277
|
httpMethod: 'DELETE',
|
|
2317
2278
|
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
2279
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
2318
2280
|
})
|
|
2319
2281
|
.then((httpResponse) => {
|
|
2320
2282
|
return httpResponse.json();
|
|
@@ -2339,7 +2301,8 @@ class Caches extends BaseModule {
|
|
|
2339
2301
|
queryParams: queryParams,
|
|
2340
2302
|
body: JSON.stringify(body),
|
|
2341
2303
|
httpMethod: 'DELETE',
|
|
2342
|
-
httpOptions: (
|
|
2304
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
2305
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
2343
2306
|
})
|
|
2344
2307
|
.then((httpResponse) => {
|
|
2345
2308
|
return httpResponse.json();
|
|
@@ -2361,13 +2324,13 @@ class Caches extends BaseModule {
|
|
|
2361
2324
|
* @example
|
|
2362
2325
|
* ```ts
|
|
2363
2326
|
* const response = await ai.caches.update({
|
|
2364
|
-
* name: '
|
|
2327
|
+
* name: '...', // The server-generated resource name.
|
|
2365
2328
|
* config: {'ttl': '7600s'}
|
|
2366
2329
|
* });
|
|
2367
2330
|
* ```
|
|
2368
2331
|
*/
|
|
2369
2332
|
async update(params) {
|
|
2370
|
-
var _a, _b;
|
|
2333
|
+
var _a, _b, _c, _d;
|
|
2371
2334
|
let response;
|
|
2372
2335
|
let path = '';
|
|
2373
2336
|
let queryParams = {};
|
|
@@ -2385,6 +2348,7 @@ class Caches extends BaseModule {
|
|
|
2385
2348
|
body: JSON.stringify(body),
|
|
2386
2349
|
httpMethod: 'PATCH',
|
|
2387
2350
|
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
2351
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
2388
2352
|
})
|
|
2389
2353
|
.then((httpResponse) => {
|
|
2390
2354
|
return httpResponse.json();
|
|
@@ -2407,7 +2371,8 @@ class Caches extends BaseModule {
|
|
|
2407
2371
|
queryParams: queryParams,
|
|
2408
2372
|
body: JSON.stringify(body),
|
|
2409
2373
|
httpMethod: 'PATCH',
|
|
2410
|
-
httpOptions: (
|
|
2374
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
2375
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
2411
2376
|
})
|
|
2412
2377
|
.then((httpResponse) => {
|
|
2413
2378
|
return httpResponse.json();
|
|
@@ -2419,7 +2384,7 @@ class Caches extends BaseModule {
|
|
|
2419
2384
|
}
|
|
2420
2385
|
}
|
|
2421
2386
|
async listInternal(params) {
|
|
2422
|
-
var _a, _b;
|
|
2387
|
+
var _a, _b, _c, _d;
|
|
2423
2388
|
let response;
|
|
2424
2389
|
let path = '';
|
|
2425
2390
|
let queryParams = {};
|
|
@@ -2437,6 +2402,7 @@ class Caches extends BaseModule {
|
|
|
2437
2402
|
body: JSON.stringify(body),
|
|
2438
2403
|
httpMethod: 'GET',
|
|
2439
2404
|
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
2405
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
2440
2406
|
})
|
|
2441
2407
|
.then((httpResponse) => {
|
|
2442
2408
|
return httpResponse.json();
|
|
@@ -2461,7 +2427,8 @@ class Caches extends BaseModule {
|
|
|
2461
2427
|
queryParams: queryParams,
|
|
2462
2428
|
body: JSON.stringify(body),
|
|
2463
2429
|
httpMethod: 'GET',
|
|
2464
|
-
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,
|
|
2465
2432
|
})
|
|
2466
2433
|
.then((httpResponse) => {
|
|
2467
2434
|
return httpResponse.json();
|
|
@@ -2755,7 +2722,12 @@ class Chat {
|
|
|
2755
2722
|
contents: this.getHistory(true).concat(inputContent),
|
|
2756
2723
|
config: (_a = params.config) !== null && _a !== void 0 ? _a : this.config,
|
|
2757
2724
|
});
|
|
2758
|
-
|
|
2725
|
+
// Resolve the internal tracking of send completion promise - `sendPromise`
|
|
2726
|
+
// for both success and failure response. The actual failure is still
|
|
2727
|
+
// propagated by the `await streamResponse`.
|
|
2728
|
+
this.sendPromise = streamResponse
|
|
2729
|
+
.then(() => undefined)
|
|
2730
|
+
.catch(() => undefined);
|
|
2759
2731
|
const response = await streamResponse;
|
|
2760
2732
|
const result = this.processStreamResponse(response, inputContent);
|
|
2761
2733
|
return result;
|
|
@@ -2843,7 +2815,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
2843
2815
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
2844
2816
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
2845
2817
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
2846
|
-
const SDK_VERSION = '0.
|
|
2818
|
+
const SDK_VERSION = '0.11.0'; // x-release-please-version
|
|
2847
2819
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
2848
2820
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
2849
2821
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -2972,7 +2944,7 @@ class ApiClient {
|
|
|
2972
2944
|
getWebsocketBaseUrl() {
|
|
2973
2945
|
const baseUrl = this.getBaseUrl();
|
|
2974
2946
|
const urlParts = new URL(baseUrl);
|
|
2975
|
-
urlParts.protocol = 'wss';
|
|
2947
|
+
urlParts.protocol = urlParts.protocol == 'http:' ? 'ws' : 'wss';
|
|
2976
2948
|
return urlParts.toString();
|
|
2977
2949
|
}
|
|
2978
2950
|
setBaseUrl(url) {
|
|
@@ -3036,7 +3008,7 @@ class ApiClient {
|
|
|
3036
3008
|
else {
|
|
3037
3009
|
requestInit.body = request.body;
|
|
3038
3010
|
}
|
|
3039
|
-
requestInit = await this.includeExtraHttpOptionsToRequestInit(requestInit, patchedHttpOptions);
|
|
3011
|
+
requestInit = await this.includeExtraHttpOptionsToRequestInit(requestInit, patchedHttpOptions, request.abortSignal);
|
|
3040
3012
|
return this.unaryApiCall(url, requestInit, request.httpMethod);
|
|
3041
3013
|
}
|
|
3042
3014
|
patchHttpOptions(baseHttpOptions, requestHttpOptions) {
|
|
@@ -3070,14 +3042,21 @@ class ApiClient {
|
|
|
3070
3042
|
}
|
|
3071
3043
|
let requestInit = {};
|
|
3072
3044
|
requestInit.body = request.body;
|
|
3073
|
-
requestInit = await this.includeExtraHttpOptionsToRequestInit(requestInit, patchedHttpOptions);
|
|
3045
|
+
requestInit = await this.includeExtraHttpOptionsToRequestInit(requestInit, patchedHttpOptions, request.abortSignal);
|
|
3074
3046
|
return this.streamApiCall(url, requestInit, request.httpMethod);
|
|
3075
3047
|
}
|
|
3076
|
-
async includeExtraHttpOptionsToRequestInit(requestInit, httpOptions) {
|
|
3077
|
-
if (httpOptions && httpOptions.timeout
|
|
3048
|
+
async includeExtraHttpOptionsToRequestInit(requestInit, httpOptions, abortSignal) {
|
|
3049
|
+
if ((httpOptions && httpOptions.timeout) || abortSignal) {
|
|
3078
3050
|
const abortController = new AbortController();
|
|
3079
3051
|
const signal = abortController.signal;
|
|
3080
|
-
|
|
3052
|
+
if (httpOptions.timeout && (httpOptions === null || httpOptions === void 0 ? void 0 : httpOptions.timeout) > 0) {
|
|
3053
|
+
setTimeout(() => abortController.abort(), httpOptions.timeout);
|
|
3054
|
+
}
|
|
3055
|
+
if (abortSignal) {
|
|
3056
|
+
abortSignal.addEventListener('abort', () => {
|
|
3057
|
+
abortController.abort();
|
|
3058
|
+
});
|
|
3059
|
+
}
|
|
3081
3060
|
requestInit.signal = signal;
|
|
3082
3061
|
}
|
|
3083
3062
|
requestInit.headers = await this.getHeadersInternal(httpOptions);
|
|
@@ -3132,6 +3111,30 @@ class ApiClient {
|
|
|
3132
3111
|
break;
|
|
3133
3112
|
}
|
|
3134
3113
|
const chunkString = decoder.decode(value);
|
|
3114
|
+
// Parse and throw an error if the chunk contains an error.
|
|
3115
|
+
try {
|
|
3116
|
+
const chunkJson = JSON.parse(chunkString);
|
|
3117
|
+
if ('error' in chunkJson) {
|
|
3118
|
+
const errorJson = JSON.parse(JSON.stringify(chunkJson['error']));
|
|
3119
|
+
const status = errorJson['status'];
|
|
3120
|
+
const code = errorJson['code'];
|
|
3121
|
+
const errorMessage = `got status: ${status}. ${JSON.stringify(chunkJson)}`;
|
|
3122
|
+
if (code >= 400 && code < 500) {
|
|
3123
|
+
const clientError = new ClientError(errorMessage);
|
|
3124
|
+
throw clientError;
|
|
3125
|
+
}
|
|
3126
|
+
else if (code >= 500 && code < 600) {
|
|
3127
|
+
const serverError = new ServerError(errorMessage);
|
|
3128
|
+
throw serverError;
|
|
3129
|
+
}
|
|
3130
|
+
}
|
|
3131
|
+
}
|
|
3132
|
+
catch (e) {
|
|
3133
|
+
const error = e;
|
|
3134
|
+
if (error.name === 'ClientError' || error.name === 'ServerError') {
|
|
3135
|
+
throw e;
|
|
3136
|
+
}
|
|
3137
|
+
}
|
|
3135
3138
|
buffer += chunkString;
|
|
3136
3139
|
let match = buffer.match(responseLineRE);
|
|
3137
3140
|
while (match) {
|
|
@@ -3270,7 +3273,7 @@ async function throwErrorIfNotOK(response) {
|
|
|
3270
3273
|
else {
|
|
3271
3274
|
errorBody = {
|
|
3272
3275
|
error: {
|
|
3273
|
-
message:
|
|
3276
|
+
message: await response.text(),
|
|
3274
3277
|
code: response.status,
|
|
3275
3278
|
status: response.statusText,
|
|
3276
3279
|
},
|
|
@@ -3617,14 +3620,13 @@ function listFilesResponseFromMldev(apiClient, fromObject) {
|
|
|
3617
3620
|
}
|
|
3618
3621
|
const fromFiles = getValueByPath(fromObject, ['files']);
|
|
3619
3622
|
if (fromFiles != null) {
|
|
3620
|
-
|
|
3621
|
-
|
|
3623
|
+
let transformedList = fromFiles;
|
|
3624
|
+
if (Array.isArray(transformedList)) {
|
|
3625
|
+
transformedList = transformedList.map((item) => {
|
|
3622
3626
|
return fileFromMldev(apiClient, item);
|
|
3623
|
-
})
|
|
3624
|
-
}
|
|
3625
|
-
else {
|
|
3626
|
-
setValueByPath(toObject, ['files'], fromFiles);
|
|
3627
|
+
});
|
|
3627
3628
|
}
|
|
3629
|
+
setValueByPath(toObject, ['files'], transformedList);
|
|
3628
3630
|
}
|
|
3629
3631
|
return toObject;
|
|
3630
3632
|
}
|
|
@@ -3722,7 +3724,7 @@ class Files extends BaseModule {
|
|
|
3722
3724
|
});
|
|
3723
3725
|
}
|
|
3724
3726
|
async listInternal(params) {
|
|
3725
|
-
var _a;
|
|
3727
|
+
var _a, _b;
|
|
3726
3728
|
let response;
|
|
3727
3729
|
let path = '';
|
|
3728
3730
|
let queryParams = {};
|
|
@@ -3743,6 +3745,7 @@ class Files extends BaseModule {
|
|
|
3743
3745
|
body: JSON.stringify(body),
|
|
3744
3746
|
httpMethod: 'GET',
|
|
3745
3747
|
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
3748
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
3746
3749
|
})
|
|
3747
3750
|
.then((httpResponse) => {
|
|
3748
3751
|
return httpResponse.json();
|
|
@@ -3756,7 +3759,7 @@ class Files extends BaseModule {
|
|
|
3756
3759
|
}
|
|
3757
3760
|
}
|
|
3758
3761
|
async createInternal(params) {
|
|
3759
|
-
var _a;
|
|
3762
|
+
var _a, _b;
|
|
3760
3763
|
let response;
|
|
3761
3764
|
let path = '';
|
|
3762
3765
|
let queryParams = {};
|
|
@@ -3777,6 +3780,7 @@ class Files extends BaseModule {
|
|
|
3777
3780
|
body: JSON.stringify(body),
|
|
3778
3781
|
httpMethod: 'POST',
|
|
3779
3782
|
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
3783
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
3780
3784
|
})
|
|
3781
3785
|
.then((httpResponse) => {
|
|
3782
3786
|
return httpResponse.json();
|
|
@@ -3805,7 +3809,7 @@ class Files extends BaseModule {
|
|
|
3805
3809
|
* ```
|
|
3806
3810
|
*/
|
|
3807
3811
|
async get(params) {
|
|
3808
|
-
var _a;
|
|
3812
|
+
var _a, _b;
|
|
3809
3813
|
let response;
|
|
3810
3814
|
let path = '';
|
|
3811
3815
|
let queryParams = {};
|
|
@@ -3826,6 +3830,7 @@ class Files extends BaseModule {
|
|
|
3826
3830
|
body: JSON.stringify(body),
|
|
3827
3831
|
httpMethod: 'GET',
|
|
3828
3832
|
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
3833
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
3829
3834
|
})
|
|
3830
3835
|
.then((httpResponse) => {
|
|
3831
3836
|
return httpResponse.json();
|
|
@@ -3850,7 +3855,7 @@ class Files extends BaseModule {
|
|
|
3850
3855
|
* ```
|
|
3851
3856
|
*/
|
|
3852
3857
|
async delete(params) {
|
|
3853
|
-
var _a;
|
|
3858
|
+
var _a, _b;
|
|
3854
3859
|
let response;
|
|
3855
3860
|
let path = '';
|
|
3856
3861
|
let queryParams = {};
|
|
@@ -3871,6 +3876,7 @@ class Files extends BaseModule {
|
|
|
3871
3876
|
body: JSON.stringify(body),
|
|
3872
3877
|
httpMethod: 'DELETE',
|
|
3873
3878
|
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
3879
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
3874
3880
|
})
|
|
3875
3881
|
.then((httpResponse) => {
|
|
3876
3882
|
return httpResponse.json();
|
|
@@ -3987,14 +3993,13 @@ function contentToMldev$1(apiClient, fromObject) {
|
|
|
3987
3993
|
const toObject = {};
|
|
3988
3994
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
3989
3995
|
if (fromParts != null) {
|
|
3990
|
-
|
|
3991
|
-
|
|
3996
|
+
let transformedList = fromParts;
|
|
3997
|
+
if (Array.isArray(transformedList)) {
|
|
3998
|
+
transformedList = transformedList.map((item) => {
|
|
3992
3999
|
return partToMldev$1(apiClient, item);
|
|
3993
|
-
})
|
|
3994
|
-
}
|
|
3995
|
-
else {
|
|
3996
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
4000
|
+
});
|
|
3997
4001
|
}
|
|
4002
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
3998
4003
|
}
|
|
3999
4004
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
4000
4005
|
if (fromRole != null) {
|
|
@@ -4006,14 +4011,13 @@ function contentToVertex$1(apiClient, fromObject) {
|
|
|
4006
4011
|
const toObject = {};
|
|
4007
4012
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
4008
4013
|
if (fromParts != null) {
|
|
4009
|
-
|
|
4010
|
-
|
|
4014
|
+
let transformedList = fromParts;
|
|
4015
|
+
if (Array.isArray(transformedList)) {
|
|
4016
|
+
transformedList = transformedList.map((item) => {
|
|
4011
4017
|
return partToVertex$1(apiClient, item);
|
|
4012
|
-
})
|
|
4013
|
-
}
|
|
4014
|
-
else {
|
|
4015
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
4018
|
+
});
|
|
4016
4019
|
}
|
|
4020
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
4017
4021
|
}
|
|
4018
4022
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
4019
4023
|
if (fromRole != null) {
|
|
@@ -4021,170 +4025,33 @@ function contentToVertex$1(apiClient, fromObject) {
|
|
|
4021
4025
|
}
|
|
4022
4026
|
return toObject;
|
|
4023
4027
|
}
|
|
4024
|
-
function
|
|
4028
|
+
function googleSearchToMldev$1() {
|
|
4025
4029
|
const toObject = {};
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
}
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
}
|
|
4034
|
-
const
|
|
4035
|
-
if (
|
|
4036
|
-
setValueByPath(toObject, ['
|
|
4037
|
-
}
|
|
4038
|
-
const fromMaxLength = getValueByPath(fromObject, ['maxLength']);
|
|
4039
|
-
if (fromMaxLength != null) {
|
|
4040
|
-
setValueByPath(toObject, ['maxLength'], fromMaxLength);
|
|
4041
|
-
}
|
|
4042
|
-
const fromMinLength = getValueByPath(fromObject, ['minLength']);
|
|
4043
|
-
if (fromMinLength != null) {
|
|
4044
|
-
setValueByPath(toObject, ['minLength'], fromMinLength);
|
|
4030
|
+
return toObject;
|
|
4031
|
+
}
|
|
4032
|
+
function googleSearchToVertex$1() {
|
|
4033
|
+
const toObject = {};
|
|
4034
|
+
return toObject;
|
|
4035
|
+
}
|
|
4036
|
+
function dynamicRetrievalConfigToMldev$1(apiClient, fromObject) {
|
|
4037
|
+
const toObject = {};
|
|
4038
|
+
const fromMode = getValueByPath(fromObject, ['mode']);
|
|
4039
|
+
if (fromMode != null) {
|
|
4040
|
+
setValueByPath(toObject, ['mode'], fromMode);
|
|
4045
4041
|
}
|
|
4046
|
-
const
|
|
4047
|
-
'
|
|
4042
|
+
const fromDynamicThreshold = getValueByPath(fromObject, [
|
|
4043
|
+
'dynamicThreshold',
|
|
4048
4044
|
]);
|
|
4049
|
-
if (
|
|
4050
|
-
setValueByPath(toObject, ['
|
|
4045
|
+
if (fromDynamicThreshold != null) {
|
|
4046
|
+
setValueByPath(toObject, ['dynamicThreshold'], fromDynamicThreshold);
|
|
4051
4047
|
}
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
if (fromAnyOf != null) {
|
|
4060
|
-
setValueByPath(toObject, ['anyOf'], fromAnyOf);
|
|
4061
|
-
}
|
|
4062
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
4063
|
-
if (fromDescription != null) {
|
|
4064
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
4065
|
-
}
|
|
4066
|
-
const fromEnum = getValueByPath(fromObject, ['enum']);
|
|
4067
|
-
if (fromEnum != null) {
|
|
4068
|
-
setValueByPath(toObject, ['enum'], fromEnum);
|
|
4069
|
-
}
|
|
4070
|
-
const fromFormat = getValueByPath(fromObject, ['format']);
|
|
4071
|
-
if (fromFormat != null) {
|
|
4072
|
-
setValueByPath(toObject, ['format'], fromFormat);
|
|
4073
|
-
}
|
|
4074
|
-
const fromItems = getValueByPath(fromObject, ['items']);
|
|
4075
|
-
if (fromItems != null) {
|
|
4076
|
-
setValueByPath(toObject, ['items'], fromItems);
|
|
4077
|
-
}
|
|
4078
|
-
const fromMaxItems = getValueByPath(fromObject, ['maxItems']);
|
|
4079
|
-
if (fromMaxItems != null) {
|
|
4080
|
-
setValueByPath(toObject, ['maxItems'], fromMaxItems);
|
|
4081
|
-
}
|
|
4082
|
-
const fromMaximum = getValueByPath(fromObject, ['maximum']);
|
|
4083
|
-
if (fromMaximum != null) {
|
|
4084
|
-
setValueByPath(toObject, ['maximum'], fromMaximum);
|
|
4085
|
-
}
|
|
4086
|
-
const fromMinItems = getValueByPath(fromObject, ['minItems']);
|
|
4087
|
-
if (fromMinItems != null) {
|
|
4088
|
-
setValueByPath(toObject, ['minItems'], fromMinItems);
|
|
4089
|
-
}
|
|
4090
|
-
const fromMinimum = getValueByPath(fromObject, ['minimum']);
|
|
4091
|
-
if (fromMinimum != null) {
|
|
4092
|
-
setValueByPath(toObject, ['minimum'], fromMinimum);
|
|
4093
|
-
}
|
|
4094
|
-
const fromNullable = getValueByPath(fromObject, ['nullable']);
|
|
4095
|
-
if (fromNullable != null) {
|
|
4096
|
-
setValueByPath(toObject, ['nullable'], fromNullable);
|
|
4097
|
-
}
|
|
4098
|
-
const fromProperties = getValueByPath(fromObject, ['properties']);
|
|
4099
|
-
if (fromProperties != null) {
|
|
4100
|
-
setValueByPath(toObject, ['properties'], fromProperties);
|
|
4101
|
-
}
|
|
4102
|
-
const fromPropertyOrdering = getValueByPath(fromObject, [
|
|
4103
|
-
'propertyOrdering',
|
|
4104
|
-
]);
|
|
4105
|
-
if (fromPropertyOrdering != null) {
|
|
4106
|
-
setValueByPath(toObject, ['propertyOrdering'], fromPropertyOrdering);
|
|
4107
|
-
}
|
|
4108
|
-
const fromRequired = getValueByPath(fromObject, ['required']);
|
|
4109
|
-
if (fromRequired != null) {
|
|
4110
|
-
setValueByPath(toObject, ['required'], fromRequired);
|
|
4111
|
-
}
|
|
4112
|
-
const fromTitle = getValueByPath(fromObject, ['title']);
|
|
4113
|
-
if (fromTitle != null) {
|
|
4114
|
-
setValueByPath(toObject, ['title'], fromTitle);
|
|
4115
|
-
}
|
|
4116
|
-
const fromType = getValueByPath(fromObject, ['type']);
|
|
4117
|
-
if (fromType != null) {
|
|
4118
|
-
setValueByPath(toObject, ['type'], fromType);
|
|
4119
|
-
}
|
|
4120
|
-
return toObject;
|
|
4121
|
-
}
|
|
4122
|
-
function functionDeclarationToMldev$1(apiClient, fromObject) {
|
|
4123
|
-
const toObject = {};
|
|
4124
|
-
if (getValueByPath(fromObject, ['response']) !== undefined) {
|
|
4125
|
-
throw new Error('response parameter is not supported in Gemini API.');
|
|
4126
|
-
}
|
|
4127
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
4128
|
-
if (fromDescription != null) {
|
|
4129
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
4130
|
-
}
|
|
4131
|
-
const fromName = getValueByPath(fromObject, ['name']);
|
|
4132
|
-
if (fromName != null) {
|
|
4133
|
-
setValueByPath(toObject, ['name'], fromName);
|
|
4134
|
-
}
|
|
4135
|
-
const fromParameters = getValueByPath(fromObject, ['parameters']);
|
|
4136
|
-
if (fromParameters != null) {
|
|
4137
|
-
setValueByPath(toObject, ['parameters'], fromParameters);
|
|
4138
|
-
}
|
|
4139
|
-
return toObject;
|
|
4140
|
-
}
|
|
4141
|
-
function functionDeclarationToVertex$1(apiClient, fromObject) {
|
|
4142
|
-
const toObject = {};
|
|
4143
|
-
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
4144
|
-
if (fromResponse != null) {
|
|
4145
|
-
setValueByPath(toObject, ['response'], schemaToVertex$1(apiClient, fromResponse));
|
|
4146
|
-
}
|
|
4147
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
4148
|
-
if (fromDescription != null) {
|
|
4149
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
4150
|
-
}
|
|
4151
|
-
const fromName = getValueByPath(fromObject, ['name']);
|
|
4152
|
-
if (fromName != null) {
|
|
4153
|
-
setValueByPath(toObject, ['name'], fromName);
|
|
4154
|
-
}
|
|
4155
|
-
const fromParameters = getValueByPath(fromObject, ['parameters']);
|
|
4156
|
-
if (fromParameters != null) {
|
|
4157
|
-
setValueByPath(toObject, ['parameters'], fromParameters);
|
|
4158
|
-
}
|
|
4159
|
-
return toObject;
|
|
4160
|
-
}
|
|
4161
|
-
function googleSearchToMldev$1() {
|
|
4162
|
-
const toObject = {};
|
|
4163
|
-
return toObject;
|
|
4164
|
-
}
|
|
4165
|
-
function googleSearchToVertex$1() {
|
|
4166
|
-
const toObject = {};
|
|
4167
|
-
return toObject;
|
|
4168
|
-
}
|
|
4169
|
-
function dynamicRetrievalConfigToMldev$1(apiClient, fromObject) {
|
|
4170
|
-
const toObject = {};
|
|
4171
|
-
const fromMode = getValueByPath(fromObject, ['mode']);
|
|
4172
|
-
if (fromMode != null) {
|
|
4173
|
-
setValueByPath(toObject, ['mode'], fromMode);
|
|
4174
|
-
}
|
|
4175
|
-
const fromDynamicThreshold = getValueByPath(fromObject, [
|
|
4176
|
-
'dynamicThreshold',
|
|
4177
|
-
]);
|
|
4178
|
-
if (fromDynamicThreshold != null) {
|
|
4179
|
-
setValueByPath(toObject, ['dynamicThreshold'], fromDynamicThreshold);
|
|
4180
|
-
}
|
|
4181
|
-
return toObject;
|
|
4182
|
-
}
|
|
4183
|
-
function dynamicRetrievalConfigToVertex$1(apiClient, fromObject) {
|
|
4184
|
-
const toObject = {};
|
|
4185
|
-
const fromMode = getValueByPath(fromObject, ['mode']);
|
|
4186
|
-
if (fromMode != null) {
|
|
4187
|
-
setValueByPath(toObject, ['mode'], fromMode);
|
|
4048
|
+
return toObject;
|
|
4049
|
+
}
|
|
4050
|
+
function dynamicRetrievalConfigToVertex$1(apiClient, fromObject) {
|
|
4051
|
+
const toObject = {};
|
|
4052
|
+
const fromMode = getValueByPath(fromObject, ['mode']);
|
|
4053
|
+
if (fromMode != null) {
|
|
4054
|
+
setValueByPath(toObject, ['mode'], fromMode);
|
|
4188
4055
|
}
|
|
4189
4056
|
const fromDynamicThreshold = getValueByPath(fromObject, [
|
|
4190
4057
|
'dynamicThreshold',
|
|
@@ -4216,19 +4083,6 @@ function googleSearchRetrievalToVertex$1(apiClient, fromObject) {
|
|
|
4216
4083
|
}
|
|
4217
4084
|
function toolToMldev$1(apiClient, fromObject) {
|
|
4218
4085
|
const toObject = {};
|
|
4219
|
-
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
4220
|
-
'functionDeclarations',
|
|
4221
|
-
]);
|
|
4222
|
-
if (fromFunctionDeclarations != null) {
|
|
4223
|
-
if (Array.isArray(fromFunctionDeclarations)) {
|
|
4224
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations.map((item) => {
|
|
4225
|
-
return functionDeclarationToMldev$1(apiClient, item);
|
|
4226
|
-
}));
|
|
4227
|
-
}
|
|
4228
|
-
else {
|
|
4229
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
4230
|
-
}
|
|
4231
|
-
}
|
|
4232
4086
|
if (getValueByPath(fromObject, ['retrieval']) !== undefined) {
|
|
4233
4087
|
throw new Error('retrieval parameter is not supported in Gemini API.');
|
|
4234
4088
|
}
|
|
@@ -4248,23 +4102,16 @@ function toolToMldev$1(apiClient, fromObject) {
|
|
|
4248
4102
|
if (fromCodeExecution != null) {
|
|
4249
4103
|
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
4250
4104
|
}
|
|
4251
|
-
return toObject;
|
|
4252
|
-
}
|
|
4253
|
-
function toolToVertex$1(apiClient, fromObject) {
|
|
4254
|
-
const toObject = {};
|
|
4255
4105
|
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
4256
4106
|
'functionDeclarations',
|
|
4257
4107
|
]);
|
|
4258
4108
|
if (fromFunctionDeclarations != null) {
|
|
4259
|
-
|
|
4260
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations.map((item) => {
|
|
4261
|
-
return functionDeclarationToVertex$1(apiClient, item);
|
|
4262
|
-
}));
|
|
4263
|
-
}
|
|
4264
|
-
else {
|
|
4265
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
4266
|
-
}
|
|
4109
|
+
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
4267
4110
|
}
|
|
4111
|
+
return toObject;
|
|
4112
|
+
}
|
|
4113
|
+
function toolToVertex$1(apiClient, fromObject) {
|
|
4114
|
+
const toObject = {};
|
|
4268
4115
|
const fromRetrieval = getValueByPath(fromObject, ['retrieval']);
|
|
4269
4116
|
if (fromRetrieval != null) {
|
|
4270
4117
|
setValueByPath(toObject, ['retrieval'], fromRetrieval);
|
|
@@ -4285,6 +4132,12 @@ function toolToVertex$1(apiClient, fromObject) {
|
|
|
4285
4132
|
if (fromCodeExecution != null) {
|
|
4286
4133
|
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
4287
4134
|
}
|
|
4135
|
+
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
4136
|
+
'functionDeclarations',
|
|
4137
|
+
]);
|
|
4138
|
+
if (fromFunctionDeclarations != null) {
|
|
4139
|
+
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
4140
|
+
}
|
|
4288
4141
|
return toObject;
|
|
4289
4142
|
}
|
|
4290
4143
|
function sessionResumptionConfigToMldev(apiClient, fromObject) {
|
|
@@ -4524,14 +4377,13 @@ function liveConnectConfigToMldev(apiClient, fromObject, parentObject) {
|
|
|
4524
4377
|
}
|
|
4525
4378
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
4526
4379
|
if (parentObject !== undefined && fromTools != null) {
|
|
4527
|
-
|
|
4528
|
-
|
|
4380
|
+
let transformedList = tTools(apiClient, fromTools);
|
|
4381
|
+
if (Array.isArray(transformedList)) {
|
|
4382
|
+
transformedList = transformedList.map((item) => {
|
|
4529
4383
|
return toolToMldev$1(apiClient, tTool(apiClient, item));
|
|
4530
|
-
})
|
|
4531
|
-
}
|
|
4532
|
-
else {
|
|
4533
|
-
setValueByPath(parentObject, ['setup', 'tools'], tTools(apiClient, fromTools));
|
|
4384
|
+
});
|
|
4534
4385
|
}
|
|
4386
|
+
setValueByPath(parentObject, ['setup', 'tools'], transformedList);
|
|
4535
4387
|
}
|
|
4536
4388
|
const fromSessionResumption = getValueByPath(fromObject, [
|
|
4537
4389
|
'sessionResumption',
|
|
@@ -4616,14 +4468,13 @@ function liveConnectConfigToVertex(apiClient, fromObject, parentObject) {
|
|
|
4616
4468
|
}
|
|
4617
4469
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
4618
4470
|
if (parentObject !== undefined && fromTools != null) {
|
|
4619
|
-
|
|
4620
|
-
|
|
4471
|
+
let transformedList = tTools(apiClient, fromTools);
|
|
4472
|
+
if (Array.isArray(transformedList)) {
|
|
4473
|
+
transformedList = transformedList.map((item) => {
|
|
4621
4474
|
return toolToVertex$1(apiClient, tTool(apiClient, item));
|
|
4622
|
-
})
|
|
4623
|
-
}
|
|
4624
|
-
else {
|
|
4625
|
-
setValueByPath(parentObject, ['setup', 'tools'], tTools(apiClient, fromTools));
|
|
4475
|
+
});
|
|
4626
4476
|
}
|
|
4477
|
+
setValueByPath(parentObject, ['setup', 'tools'], transformedList);
|
|
4627
4478
|
}
|
|
4628
4479
|
const fromSessionResumption = getValueByPath(fromObject, [
|
|
4629
4480
|
'sessionResumption',
|
|
@@ -4681,6 +4532,91 @@ function liveConnectParametersToVertex(apiClient, fromObject) {
|
|
|
4681
4532
|
}
|
|
4682
4533
|
return toObject;
|
|
4683
4534
|
}
|
|
4535
|
+
function activityStartToMldev() {
|
|
4536
|
+
const toObject = {};
|
|
4537
|
+
return toObject;
|
|
4538
|
+
}
|
|
4539
|
+
function activityStartToVertex() {
|
|
4540
|
+
const toObject = {};
|
|
4541
|
+
return toObject;
|
|
4542
|
+
}
|
|
4543
|
+
function activityEndToMldev() {
|
|
4544
|
+
const toObject = {};
|
|
4545
|
+
return toObject;
|
|
4546
|
+
}
|
|
4547
|
+
function activityEndToVertex() {
|
|
4548
|
+
const toObject = {};
|
|
4549
|
+
return toObject;
|
|
4550
|
+
}
|
|
4551
|
+
function liveSendRealtimeInputParametersToMldev(apiClient, fromObject) {
|
|
4552
|
+
const toObject = {};
|
|
4553
|
+
const fromMedia = getValueByPath(fromObject, ['media']);
|
|
4554
|
+
if (fromMedia != null) {
|
|
4555
|
+
setValueByPath(toObject, ['mediaChunks'], tBlobs(apiClient, fromMedia));
|
|
4556
|
+
}
|
|
4557
|
+
const fromAudio = getValueByPath(fromObject, ['audio']);
|
|
4558
|
+
if (fromAudio != null) {
|
|
4559
|
+
setValueByPath(toObject, ['audio'], tAudioBlob(apiClient, fromAudio));
|
|
4560
|
+
}
|
|
4561
|
+
const fromAudioStreamEnd = getValueByPath(fromObject, [
|
|
4562
|
+
'audioStreamEnd',
|
|
4563
|
+
]);
|
|
4564
|
+
if (fromAudioStreamEnd != null) {
|
|
4565
|
+
setValueByPath(toObject, ['audioStreamEnd'], fromAudioStreamEnd);
|
|
4566
|
+
}
|
|
4567
|
+
const fromVideo = getValueByPath(fromObject, ['video']);
|
|
4568
|
+
if (fromVideo != null) {
|
|
4569
|
+
setValueByPath(toObject, ['video'], tImageBlob(apiClient, fromVideo));
|
|
4570
|
+
}
|
|
4571
|
+
const fromText = getValueByPath(fromObject, ['text']);
|
|
4572
|
+
if (fromText != null) {
|
|
4573
|
+
setValueByPath(toObject, ['text'], fromText);
|
|
4574
|
+
}
|
|
4575
|
+
const fromActivityStart = getValueByPath(fromObject, [
|
|
4576
|
+
'activityStart',
|
|
4577
|
+
]);
|
|
4578
|
+
if (fromActivityStart != null) {
|
|
4579
|
+
setValueByPath(toObject, ['activityStart'], activityStartToMldev());
|
|
4580
|
+
}
|
|
4581
|
+
const fromActivityEnd = getValueByPath(fromObject, ['activityEnd']);
|
|
4582
|
+
if (fromActivityEnd != null) {
|
|
4583
|
+
setValueByPath(toObject, ['activityEnd'], activityEndToMldev());
|
|
4584
|
+
}
|
|
4585
|
+
return toObject;
|
|
4586
|
+
}
|
|
4587
|
+
function liveSendRealtimeInputParametersToVertex(apiClient, fromObject) {
|
|
4588
|
+
const toObject = {};
|
|
4589
|
+
const fromMedia = getValueByPath(fromObject, ['media']);
|
|
4590
|
+
if (fromMedia != null) {
|
|
4591
|
+
setValueByPath(toObject, ['mediaChunks'], tBlobs(apiClient, fromMedia));
|
|
4592
|
+
}
|
|
4593
|
+
if (getValueByPath(fromObject, ['audio']) !== undefined) {
|
|
4594
|
+
throw new Error('audio parameter is not supported in Vertex AI.');
|
|
4595
|
+
}
|
|
4596
|
+
const fromAudioStreamEnd = getValueByPath(fromObject, [
|
|
4597
|
+
'audioStreamEnd',
|
|
4598
|
+
]);
|
|
4599
|
+
if (fromAudioStreamEnd != null) {
|
|
4600
|
+
setValueByPath(toObject, ['audioStreamEnd'], fromAudioStreamEnd);
|
|
4601
|
+
}
|
|
4602
|
+
if (getValueByPath(fromObject, ['video']) !== undefined) {
|
|
4603
|
+
throw new Error('video parameter is not supported in Vertex AI.');
|
|
4604
|
+
}
|
|
4605
|
+
if (getValueByPath(fromObject, ['text']) !== undefined) {
|
|
4606
|
+
throw new Error('text parameter is not supported in Vertex AI.');
|
|
4607
|
+
}
|
|
4608
|
+
const fromActivityStart = getValueByPath(fromObject, [
|
|
4609
|
+
'activityStart',
|
|
4610
|
+
]);
|
|
4611
|
+
if (fromActivityStart != null) {
|
|
4612
|
+
setValueByPath(toObject, ['activityStart'], activityStartToVertex());
|
|
4613
|
+
}
|
|
4614
|
+
const fromActivityEnd = getValueByPath(fromObject, ['activityEnd']);
|
|
4615
|
+
if (fromActivityEnd != null) {
|
|
4616
|
+
setValueByPath(toObject, ['activityEnd'], activityEndToVertex());
|
|
4617
|
+
}
|
|
4618
|
+
return toObject;
|
|
4619
|
+
}
|
|
4684
4620
|
function liveServerSetupCompleteFromMldev() {
|
|
4685
4621
|
const toObject = {};
|
|
4686
4622
|
return toObject;
|
|
@@ -4783,14 +4719,13 @@ function contentFromMldev$1(apiClient, fromObject) {
|
|
|
4783
4719
|
const toObject = {};
|
|
4784
4720
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
4785
4721
|
if (fromParts != null) {
|
|
4786
|
-
|
|
4787
|
-
|
|
4722
|
+
let transformedList = fromParts;
|
|
4723
|
+
if (Array.isArray(transformedList)) {
|
|
4724
|
+
transformedList = transformedList.map((item) => {
|
|
4788
4725
|
return partFromMldev$1(apiClient, item);
|
|
4789
|
-
})
|
|
4790
|
-
}
|
|
4791
|
-
else {
|
|
4792
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
4726
|
+
});
|
|
4793
4727
|
}
|
|
4728
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
4794
4729
|
}
|
|
4795
4730
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
4796
4731
|
if (fromRole != null) {
|
|
@@ -4802,14 +4737,13 @@ function contentFromVertex$1(apiClient, fromObject) {
|
|
|
4802
4737
|
const toObject = {};
|
|
4803
4738
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
4804
4739
|
if (fromParts != null) {
|
|
4805
|
-
|
|
4806
|
-
|
|
4740
|
+
let transformedList = fromParts;
|
|
4741
|
+
if (Array.isArray(transformedList)) {
|
|
4742
|
+
transformedList = transformedList.map((item) => {
|
|
4807
4743
|
return partFromVertex$1(apiClient, item);
|
|
4808
|
-
})
|
|
4809
|
-
}
|
|
4810
|
-
else {
|
|
4811
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
4744
|
+
});
|
|
4812
4745
|
}
|
|
4746
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
4813
4747
|
}
|
|
4814
4748
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
4815
4749
|
if (fromRole != null) {
|
|
@@ -4943,14 +4877,13 @@ function liveServerToolCallFromMldev(apiClient, fromObject) {
|
|
|
4943
4877
|
'functionCalls',
|
|
4944
4878
|
]);
|
|
4945
4879
|
if (fromFunctionCalls != null) {
|
|
4946
|
-
|
|
4947
|
-
|
|
4880
|
+
let transformedList = fromFunctionCalls;
|
|
4881
|
+
if (Array.isArray(transformedList)) {
|
|
4882
|
+
transformedList = transformedList.map((item) => {
|
|
4948
4883
|
return functionCallFromMldev(apiClient, item);
|
|
4949
|
-
})
|
|
4950
|
-
}
|
|
4951
|
-
else {
|
|
4952
|
-
setValueByPath(toObject, ['functionCalls'], fromFunctionCalls);
|
|
4884
|
+
});
|
|
4953
4885
|
}
|
|
4886
|
+
setValueByPath(toObject, ['functionCalls'], transformedList);
|
|
4954
4887
|
}
|
|
4955
4888
|
return toObject;
|
|
4956
4889
|
}
|
|
@@ -4960,14 +4893,13 @@ function liveServerToolCallFromVertex(apiClient, fromObject) {
|
|
|
4960
4893
|
'functionCalls',
|
|
4961
4894
|
]);
|
|
4962
4895
|
if (fromFunctionCalls != null) {
|
|
4963
|
-
|
|
4964
|
-
|
|
4896
|
+
let transformedList = fromFunctionCalls;
|
|
4897
|
+
if (Array.isArray(transformedList)) {
|
|
4898
|
+
transformedList = transformedList.map((item) => {
|
|
4965
4899
|
return functionCallFromVertex(apiClient, item);
|
|
4966
|
-
})
|
|
4967
|
-
}
|
|
4968
|
-
else {
|
|
4969
|
-
setValueByPath(toObject, ['functionCalls'], fromFunctionCalls);
|
|
4900
|
+
});
|
|
4970
4901
|
}
|
|
4902
|
+
setValueByPath(toObject, ['functionCalls'], transformedList);
|
|
4971
4903
|
}
|
|
4972
4904
|
return toObject;
|
|
4973
4905
|
}
|
|
@@ -5053,53 +4985,49 @@ function usageMetadataFromMldev(apiClient, fromObject) {
|
|
|
5053
4985
|
'promptTokensDetails',
|
|
5054
4986
|
]);
|
|
5055
4987
|
if (fromPromptTokensDetails != null) {
|
|
5056
|
-
|
|
5057
|
-
|
|
4988
|
+
let transformedList = fromPromptTokensDetails;
|
|
4989
|
+
if (Array.isArray(transformedList)) {
|
|
4990
|
+
transformedList = transformedList.map((item) => {
|
|
5058
4991
|
return modalityTokenCountFromMldev(apiClient, item);
|
|
5059
|
-
})
|
|
5060
|
-
}
|
|
5061
|
-
else {
|
|
5062
|
-
setValueByPath(toObject, ['promptTokensDetails'], fromPromptTokensDetails);
|
|
4992
|
+
});
|
|
5063
4993
|
}
|
|
4994
|
+
setValueByPath(toObject, ['promptTokensDetails'], transformedList);
|
|
5064
4995
|
}
|
|
5065
4996
|
const fromCacheTokensDetails = getValueByPath(fromObject, [
|
|
5066
4997
|
'cacheTokensDetails',
|
|
5067
4998
|
]);
|
|
5068
4999
|
if (fromCacheTokensDetails != null) {
|
|
5069
|
-
|
|
5070
|
-
|
|
5000
|
+
let transformedList = fromCacheTokensDetails;
|
|
5001
|
+
if (Array.isArray(transformedList)) {
|
|
5002
|
+
transformedList = transformedList.map((item) => {
|
|
5071
5003
|
return modalityTokenCountFromMldev(apiClient, item);
|
|
5072
|
-
})
|
|
5073
|
-
}
|
|
5074
|
-
else {
|
|
5075
|
-
setValueByPath(toObject, ['cacheTokensDetails'], fromCacheTokensDetails);
|
|
5004
|
+
});
|
|
5076
5005
|
}
|
|
5006
|
+
setValueByPath(toObject, ['cacheTokensDetails'], transformedList);
|
|
5077
5007
|
}
|
|
5078
5008
|
const fromResponseTokensDetails = getValueByPath(fromObject, [
|
|
5079
5009
|
'responseTokensDetails',
|
|
5080
5010
|
]);
|
|
5081
5011
|
if (fromResponseTokensDetails != null) {
|
|
5082
|
-
|
|
5083
|
-
|
|
5012
|
+
let transformedList = fromResponseTokensDetails;
|
|
5013
|
+
if (Array.isArray(transformedList)) {
|
|
5014
|
+
transformedList = transformedList.map((item) => {
|
|
5084
5015
|
return modalityTokenCountFromMldev(apiClient, item);
|
|
5085
|
-
})
|
|
5086
|
-
}
|
|
5087
|
-
else {
|
|
5088
|
-
setValueByPath(toObject, ['responseTokensDetails'], fromResponseTokensDetails);
|
|
5016
|
+
});
|
|
5089
5017
|
}
|
|
5018
|
+
setValueByPath(toObject, ['responseTokensDetails'], transformedList);
|
|
5090
5019
|
}
|
|
5091
5020
|
const fromToolUsePromptTokensDetails = getValueByPath(fromObject, [
|
|
5092
5021
|
'toolUsePromptTokensDetails',
|
|
5093
5022
|
]);
|
|
5094
5023
|
if (fromToolUsePromptTokensDetails != null) {
|
|
5095
|
-
|
|
5096
|
-
|
|
5024
|
+
let transformedList = fromToolUsePromptTokensDetails;
|
|
5025
|
+
if (Array.isArray(transformedList)) {
|
|
5026
|
+
transformedList = transformedList.map((item) => {
|
|
5097
5027
|
return modalityTokenCountFromMldev(apiClient, item);
|
|
5098
|
-
})
|
|
5099
|
-
}
|
|
5100
|
-
else {
|
|
5101
|
-
setValueByPath(toObject, ['toolUsePromptTokensDetails'], fromToolUsePromptTokensDetails);
|
|
5028
|
+
});
|
|
5102
5029
|
}
|
|
5030
|
+
setValueByPath(toObject, ['toolUsePromptTokensDetails'], transformedList);
|
|
5103
5031
|
}
|
|
5104
5032
|
return toObject;
|
|
5105
5033
|
}
|
|
@@ -5145,53 +5073,49 @@ function usageMetadataFromVertex(apiClient, fromObject) {
|
|
|
5145
5073
|
'promptTokensDetails',
|
|
5146
5074
|
]);
|
|
5147
5075
|
if (fromPromptTokensDetails != null) {
|
|
5148
|
-
|
|
5149
|
-
|
|
5076
|
+
let transformedList = fromPromptTokensDetails;
|
|
5077
|
+
if (Array.isArray(transformedList)) {
|
|
5078
|
+
transformedList = transformedList.map((item) => {
|
|
5150
5079
|
return modalityTokenCountFromVertex(apiClient, item);
|
|
5151
|
-
})
|
|
5152
|
-
}
|
|
5153
|
-
else {
|
|
5154
|
-
setValueByPath(toObject, ['promptTokensDetails'], fromPromptTokensDetails);
|
|
5080
|
+
});
|
|
5155
5081
|
}
|
|
5082
|
+
setValueByPath(toObject, ['promptTokensDetails'], transformedList);
|
|
5156
5083
|
}
|
|
5157
5084
|
const fromCacheTokensDetails = getValueByPath(fromObject, [
|
|
5158
5085
|
'cacheTokensDetails',
|
|
5159
5086
|
]);
|
|
5160
5087
|
if (fromCacheTokensDetails != null) {
|
|
5161
|
-
|
|
5162
|
-
|
|
5088
|
+
let transformedList = fromCacheTokensDetails;
|
|
5089
|
+
if (Array.isArray(transformedList)) {
|
|
5090
|
+
transformedList = transformedList.map((item) => {
|
|
5163
5091
|
return modalityTokenCountFromVertex(apiClient, item);
|
|
5164
|
-
})
|
|
5165
|
-
}
|
|
5166
|
-
else {
|
|
5167
|
-
setValueByPath(toObject, ['cacheTokensDetails'], fromCacheTokensDetails);
|
|
5092
|
+
});
|
|
5168
5093
|
}
|
|
5094
|
+
setValueByPath(toObject, ['cacheTokensDetails'], transformedList);
|
|
5169
5095
|
}
|
|
5170
5096
|
const fromResponseTokensDetails = getValueByPath(fromObject, [
|
|
5171
5097
|
'candidatesTokensDetails',
|
|
5172
5098
|
]);
|
|
5173
5099
|
if (fromResponseTokensDetails != null) {
|
|
5174
|
-
|
|
5175
|
-
|
|
5100
|
+
let transformedList = fromResponseTokensDetails;
|
|
5101
|
+
if (Array.isArray(transformedList)) {
|
|
5102
|
+
transformedList = transformedList.map((item) => {
|
|
5176
5103
|
return modalityTokenCountFromVertex(apiClient, item);
|
|
5177
|
-
})
|
|
5178
|
-
}
|
|
5179
|
-
else {
|
|
5180
|
-
setValueByPath(toObject, ['responseTokensDetails'], fromResponseTokensDetails);
|
|
5104
|
+
});
|
|
5181
5105
|
}
|
|
5106
|
+
setValueByPath(toObject, ['responseTokensDetails'], transformedList);
|
|
5182
5107
|
}
|
|
5183
5108
|
const fromToolUsePromptTokensDetails = getValueByPath(fromObject, [
|
|
5184
5109
|
'toolUsePromptTokensDetails',
|
|
5185
5110
|
]);
|
|
5186
5111
|
if (fromToolUsePromptTokensDetails != null) {
|
|
5187
|
-
|
|
5188
|
-
|
|
5112
|
+
let transformedList = fromToolUsePromptTokensDetails;
|
|
5113
|
+
if (Array.isArray(transformedList)) {
|
|
5114
|
+
transformedList = transformedList.map((item) => {
|
|
5189
5115
|
return modalityTokenCountFromVertex(apiClient, item);
|
|
5190
|
-
})
|
|
5191
|
-
}
|
|
5192
|
-
else {
|
|
5193
|
-
setValueByPath(toObject, ['toolUsePromptTokensDetails'], fromToolUsePromptTokensDetails);
|
|
5116
|
+
});
|
|
5194
5117
|
}
|
|
5118
|
+
setValueByPath(toObject, ['toolUsePromptTokensDetails'], transformedList);
|
|
5195
5119
|
}
|
|
5196
5120
|
const fromTrafficType = getValueByPath(fromObject, ['trafficType']);
|
|
5197
5121
|
if (fromTrafficType != null) {
|
|
@@ -5390,14 +5314,13 @@ function contentToMldev(apiClient, fromObject) {
|
|
|
5390
5314
|
const toObject = {};
|
|
5391
5315
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
5392
5316
|
if (fromParts != null) {
|
|
5393
|
-
|
|
5394
|
-
|
|
5317
|
+
let transformedList = fromParts;
|
|
5318
|
+
if (Array.isArray(transformedList)) {
|
|
5319
|
+
transformedList = transformedList.map((item) => {
|
|
5395
5320
|
return partToMldev(apiClient, item);
|
|
5396
|
-
})
|
|
5397
|
-
}
|
|
5398
|
-
else {
|
|
5399
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
5321
|
+
});
|
|
5400
5322
|
}
|
|
5323
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
5401
5324
|
}
|
|
5402
5325
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
5403
5326
|
if (fromRole != null) {
|
|
@@ -5405,93 +5328,6 @@ function contentToMldev(apiClient, fromObject) {
|
|
|
5405
5328
|
}
|
|
5406
5329
|
return toObject;
|
|
5407
5330
|
}
|
|
5408
|
-
function schemaToMldev(apiClient, fromObject) {
|
|
5409
|
-
const toObject = {};
|
|
5410
|
-
if (getValueByPath(fromObject, ['example']) !== undefined) {
|
|
5411
|
-
throw new Error('example parameter is not supported in Gemini API.');
|
|
5412
|
-
}
|
|
5413
|
-
if (getValueByPath(fromObject, ['pattern']) !== undefined) {
|
|
5414
|
-
throw new Error('pattern parameter is not supported in Gemini API.');
|
|
5415
|
-
}
|
|
5416
|
-
if (getValueByPath(fromObject, ['default']) !== undefined) {
|
|
5417
|
-
throw new Error('default parameter is not supported in Gemini API.');
|
|
5418
|
-
}
|
|
5419
|
-
if (getValueByPath(fromObject, ['maxLength']) !== undefined) {
|
|
5420
|
-
throw new Error('maxLength parameter is not supported in Gemini API.');
|
|
5421
|
-
}
|
|
5422
|
-
if (getValueByPath(fromObject, ['minLength']) !== undefined) {
|
|
5423
|
-
throw new Error('minLength parameter is not supported in Gemini API.');
|
|
5424
|
-
}
|
|
5425
|
-
if (getValueByPath(fromObject, ['minProperties']) !== undefined) {
|
|
5426
|
-
throw new Error('minProperties parameter is not supported in Gemini API.');
|
|
5427
|
-
}
|
|
5428
|
-
if (getValueByPath(fromObject, ['maxProperties']) !== undefined) {
|
|
5429
|
-
throw new Error('maxProperties parameter is not supported in Gemini API.');
|
|
5430
|
-
}
|
|
5431
|
-
const fromAnyOf = getValueByPath(fromObject, ['anyOf']);
|
|
5432
|
-
if (fromAnyOf != null) {
|
|
5433
|
-
setValueByPath(toObject, ['anyOf'], fromAnyOf);
|
|
5434
|
-
}
|
|
5435
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
5436
|
-
if (fromDescription != null) {
|
|
5437
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
5438
|
-
}
|
|
5439
|
-
const fromEnum = getValueByPath(fromObject, ['enum']);
|
|
5440
|
-
if (fromEnum != null) {
|
|
5441
|
-
setValueByPath(toObject, ['enum'], fromEnum);
|
|
5442
|
-
}
|
|
5443
|
-
const fromFormat = getValueByPath(fromObject, ['format']);
|
|
5444
|
-
if (fromFormat != null) {
|
|
5445
|
-
setValueByPath(toObject, ['format'], fromFormat);
|
|
5446
|
-
}
|
|
5447
|
-
const fromItems = getValueByPath(fromObject, ['items']);
|
|
5448
|
-
if (fromItems != null) {
|
|
5449
|
-
setValueByPath(toObject, ['items'], fromItems);
|
|
5450
|
-
}
|
|
5451
|
-
const fromMaxItems = getValueByPath(fromObject, ['maxItems']);
|
|
5452
|
-
if (fromMaxItems != null) {
|
|
5453
|
-
setValueByPath(toObject, ['maxItems'], fromMaxItems);
|
|
5454
|
-
}
|
|
5455
|
-
const fromMaximum = getValueByPath(fromObject, ['maximum']);
|
|
5456
|
-
if (fromMaximum != null) {
|
|
5457
|
-
setValueByPath(toObject, ['maximum'], fromMaximum);
|
|
5458
|
-
}
|
|
5459
|
-
const fromMinItems = getValueByPath(fromObject, ['minItems']);
|
|
5460
|
-
if (fromMinItems != null) {
|
|
5461
|
-
setValueByPath(toObject, ['minItems'], fromMinItems);
|
|
5462
|
-
}
|
|
5463
|
-
const fromMinimum = getValueByPath(fromObject, ['minimum']);
|
|
5464
|
-
if (fromMinimum != null) {
|
|
5465
|
-
setValueByPath(toObject, ['minimum'], fromMinimum);
|
|
5466
|
-
}
|
|
5467
|
-
const fromNullable = getValueByPath(fromObject, ['nullable']);
|
|
5468
|
-
if (fromNullable != null) {
|
|
5469
|
-
setValueByPath(toObject, ['nullable'], fromNullable);
|
|
5470
|
-
}
|
|
5471
|
-
const fromProperties = getValueByPath(fromObject, ['properties']);
|
|
5472
|
-
if (fromProperties != null) {
|
|
5473
|
-
setValueByPath(toObject, ['properties'], fromProperties);
|
|
5474
|
-
}
|
|
5475
|
-
const fromPropertyOrdering = getValueByPath(fromObject, [
|
|
5476
|
-
'propertyOrdering',
|
|
5477
|
-
]);
|
|
5478
|
-
if (fromPropertyOrdering != null) {
|
|
5479
|
-
setValueByPath(toObject, ['propertyOrdering'], fromPropertyOrdering);
|
|
5480
|
-
}
|
|
5481
|
-
const fromRequired = getValueByPath(fromObject, ['required']);
|
|
5482
|
-
if (fromRequired != null) {
|
|
5483
|
-
setValueByPath(toObject, ['required'], fromRequired);
|
|
5484
|
-
}
|
|
5485
|
-
const fromTitle = getValueByPath(fromObject, ['title']);
|
|
5486
|
-
if (fromTitle != null) {
|
|
5487
|
-
setValueByPath(toObject, ['title'], fromTitle);
|
|
5488
|
-
}
|
|
5489
|
-
const fromType = getValueByPath(fromObject, ['type']);
|
|
5490
|
-
if (fromType != null) {
|
|
5491
|
-
setValueByPath(toObject, ['type'], fromType);
|
|
5492
|
-
}
|
|
5493
|
-
return toObject;
|
|
5494
|
-
}
|
|
5495
5331
|
function safetySettingToMldev(apiClient, fromObject) {
|
|
5496
5332
|
const toObject = {};
|
|
5497
5333
|
if (getValueByPath(fromObject, ['method']) !== undefined) {
|
|
@@ -5507,25 +5343,6 @@ function safetySettingToMldev(apiClient, fromObject) {
|
|
|
5507
5343
|
}
|
|
5508
5344
|
return toObject;
|
|
5509
5345
|
}
|
|
5510
|
-
function functionDeclarationToMldev(apiClient, fromObject) {
|
|
5511
|
-
const toObject = {};
|
|
5512
|
-
if (getValueByPath(fromObject, ['response']) !== undefined) {
|
|
5513
|
-
throw new Error('response parameter is not supported in Gemini API.');
|
|
5514
|
-
}
|
|
5515
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
5516
|
-
if (fromDescription != null) {
|
|
5517
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
5518
|
-
}
|
|
5519
|
-
const fromName = getValueByPath(fromObject, ['name']);
|
|
5520
|
-
if (fromName != null) {
|
|
5521
|
-
setValueByPath(toObject, ['name'], fromName);
|
|
5522
|
-
}
|
|
5523
|
-
const fromParameters = getValueByPath(fromObject, ['parameters']);
|
|
5524
|
-
if (fromParameters != null) {
|
|
5525
|
-
setValueByPath(toObject, ['parameters'], fromParameters);
|
|
5526
|
-
}
|
|
5527
|
-
return toObject;
|
|
5528
|
-
}
|
|
5529
5346
|
function googleSearchToMldev() {
|
|
5530
5347
|
const toObject = {};
|
|
5531
5348
|
return toObject;
|
|
@@ -5556,19 +5373,6 @@ function googleSearchRetrievalToMldev(apiClient, fromObject) {
|
|
|
5556
5373
|
}
|
|
5557
5374
|
function toolToMldev(apiClient, fromObject) {
|
|
5558
5375
|
const toObject = {};
|
|
5559
|
-
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
5560
|
-
'functionDeclarations',
|
|
5561
|
-
]);
|
|
5562
|
-
if (fromFunctionDeclarations != null) {
|
|
5563
|
-
if (Array.isArray(fromFunctionDeclarations)) {
|
|
5564
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations.map((item) => {
|
|
5565
|
-
return functionDeclarationToMldev(apiClient, item);
|
|
5566
|
-
}));
|
|
5567
|
-
}
|
|
5568
|
-
else {
|
|
5569
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
5570
|
-
}
|
|
5571
|
-
}
|
|
5572
5376
|
if (getValueByPath(fromObject, ['retrieval']) !== undefined) {
|
|
5573
5377
|
throw new Error('retrieval parameter is not supported in Gemini API.');
|
|
5574
5378
|
}
|
|
@@ -5588,6 +5392,12 @@ function toolToMldev(apiClient, fromObject) {
|
|
|
5588
5392
|
if (fromCodeExecution != null) {
|
|
5589
5393
|
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
5590
5394
|
}
|
|
5395
|
+
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
5396
|
+
'functionDeclarations',
|
|
5397
|
+
]);
|
|
5398
|
+
if (fromFunctionDeclarations != null) {
|
|
5399
|
+
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
5400
|
+
}
|
|
5591
5401
|
return toObject;
|
|
5592
5402
|
}
|
|
5593
5403
|
function functionCallingConfigToMldev(apiClient, fromObject) {
|
|
@@ -5734,7 +5544,7 @@ function generateContentConfigToMldev(apiClient, fromObject, parentObject) {
|
|
|
5734
5544
|
'responseSchema',
|
|
5735
5545
|
]);
|
|
5736
5546
|
if (fromResponseSchema != null) {
|
|
5737
|
-
setValueByPath(toObject, ['responseSchema'],
|
|
5547
|
+
setValueByPath(toObject, ['responseSchema'], tSchema(apiClient, fromResponseSchema));
|
|
5738
5548
|
}
|
|
5739
5549
|
if (getValueByPath(fromObject, ['routingConfig']) !== undefined) {
|
|
5740
5550
|
throw new Error('routingConfig parameter is not supported in Gemini API.');
|
|
@@ -5746,25 +5556,23 @@ function generateContentConfigToMldev(apiClient, fromObject, parentObject) {
|
|
|
5746
5556
|
'safetySettings',
|
|
5747
5557
|
]);
|
|
5748
5558
|
if (parentObject !== undefined && fromSafetySettings != null) {
|
|
5749
|
-
|
|
5750
|
-
|
|
5559
|
+
let transformedList = fromSafetySettings;
|
|
5560
|
+
if (Array.isArray(transformedList)) {
|
|
5561
|
+
transformedList = transformedList.map((item) => {
|
|
5751
5562
|
return safetySettingToMldev(apiClient, item);
|
|
5752
|
-
})
|
|
5753
|
-
}
|
|
5754
|
-
else {
|
|
5755
|
-
setValueByPath(parentObject, ['safetySettings'], fromSafetySettings);
|
|
5563
|
+
});
|
|
5756
5564
|
}
|
|
5565
|
+
setValueByPath(parentObject, ['safetySettings'], transformedList);
|
|
5757
5566
|
}
|
|
5758
5567
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
5759
5568
|
if (parentObject !== undefined && fromTools != null) {
|
|
5760
|
-
|
|
5761
|
-
|
|
5569
|
+
let transformedList = tTools(apiClient, fromTools);
|
|
5570
|
+
if (Array.isArray(transformedList)) {
|
|
5571
|
+
transformedList = transformedList.map((item) => {
|
|
5762
5572
|
return toolToMldev(apiClient, tTool(apiClient, item));
|
|
5763
|
-
})
|
|
5764
|
-
}
|
|
5765
|
-
else {
|
|
5766
|
-
setValueByPath(parentObject, ['tools'], tTools(apiClient, fromTools));
|
|
5573
|
+
});
|
|
5767
5574
|
}
|
|
5575
|
+
setValueByPath(parentObject, ['tools'], transformedList);
|
|
5768
5576
|
}
|
|
5769
5577
|
const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
|
|
5770
5578
|
if (parentObject !== undefined && fromToolConfig != null) {
|
|
@@ -5814,14 +5622,13 @@ function generateContentParametersToMldev(apiClient, fromObject) {
|
|
|
5814
5622
|
}
|
|
5815
5623
|
const fromContents = getValueByPath(fromObject, ['contents']);
|
|
5816
5624
|
if (fromContents != null) {
|
|
5817
|
-
|
|
5818
|
-
|
|
5625
|
+
let transformedList = tContents(apiClient, fromContents);
|
|
5626
|
+
if (Array.isArray(transformedList)) {
|
|
5627
|
+
transformedList = transformedList.map((item) => {
|
|
5819
5628
|
return contentToMldev(apiClient, item);
|
|
5820
|
-
})
|
|
5821
|
-
}
|
|
5822
|
-
else {
|
|
5823
|
-
setValueByPath(toObject, ['contents'], tContents(apiClient, fromContents));
|
|
5629
|
+
});
|
|
5824
5630
|
}
|
|
5631
|
+
setValueByPath(toObject, ['contents'], transformedList);
|
|
5825
5632
|
}
|
|
5826
5633
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
5827
5634
|
if (fromConfig != null) {
|
|
@@ -5976,11 +5783,47 @@ function getModelParametersToMldev(apiClient, fromObject) {
|
|
|
5976
5783
|
}
|
|
5977
5784
|
return toObject;
|
|
5978
5785
|
}
|
|
5979
|
-
function
|
|
5786
|
+
function updateModelConfigToMldev(apiClient, fromObject, parentObject) {
|
|
5980
5787
|
const toObject = {};
|
|
5981
|
-
|
|
5982
|
-
|
|
5983
|
-
|
|
5788
|
+
const fromDisplayName = getValueByPath(fromObject, ['displayName']);
|
|
5789
|
+
if (parentObject !== undefined && fromDisplayName != null) {
|
|
5790
|
+
setValueByPath(parentObject, ['displayName'], fromDisplayName);
|
|
5791
|
+
}
|
|
5792
|
+
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
5793
|
+
if (parentObject !== undefined && fromDescription != null) {
|
|
5794
|
+
setValueByPath(parentObject, ['description'], fromDescription);
|
|
5795
|
+
}
|
|
5796
|
+
return toObject;
|
|
5797
|
+
}
|
|
5798
|
+
function updateModelParametersToMldev(apiClient, fromObject) {
|
|
5799
|
+
const toObject = {};
|
|
5800
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
5801
|
+
if (fromModel != null) {
|
|
5802
|
+
setValueByPath(toObject, ['_url', 'name'], tModel(apiClient, fromModel));
|
|
5803
|
+
}
|
|
5804
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
5805
|
+
if (fromConfig != null) {
|
|
5806
|
+
setValueByPath(toObject, ['config'], updateModelConfigToMldev(apiClient, fromConfig, toObject));
|
|
5807
|
+
}
|
|
5808
|
+
return toObject;
|
|
5809
|
+
}
|
|
5810
|
+
function deleteModelParametersToMldev(apiClient, fromObject) {
|
|
5811
|
+
const toObject = {};
|
|
5812
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
5813
|
+
if (fromModel != null) {
|
|
5814
|
+
setValueByPath(toObject, ['_url', 'name'], tModel(apiClient, fromModel));
|
|
5815
|
+
}
|
|
5816
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
5817
|
+
if (fromConfig != null) {
|
|
5818
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
5819
|
+
}
|
|
5820
|
+
return toObject;
|
|
5821
|
+
}
|
|
5822
|
+
function countTokensConfigToMldev(apiClient, fromObject) {
|
|
5823
|
+
const toObject = {};
|
|
5824
|
+
if (getValueByPath(fromObject, ['systemInstruction']) !== undefined) {
|
|
5825
|
+
throw new Error('systemInstruction parameter is not supported in Gemini API.');
|
|
5826
|
+
}
|
|
5984
5827
|
if (getValueByPath(fromObject, ['tools']) !== undefined) {
|
|
5985
5828
|
throw new Error('tools parameter is not supported in Gemini API.');
|
|
5986
5829
|
}
|
|
@@ -5997,14 +5840,13 @@ function countTokensParametersToMldev(apiClient, fromObject) {
|
|
|
5997
5840
|
}
|
|
5998
5841
|
const fromContents = getValueByPath(fromObject, ['contents']);
|
|
5999
5842
|
if (fromContents != null) {
|
|
6000
|
-
|
|
6001
|
-
|
|
5843
|
+
let transformedList = tContents(apiClient, fromContents);
|
|
5844
|
+
if (Array.isArray(transformedList)) {
|
|
5845
|
+
transformedList = transformedList.map((item) => {
|
|
6002
5846
|
return contentToMldev(apiClient, item);
|
|
6003
|
-
})
|
|
6004
|
-
}
|
|
6005
|
-
else {
|
|
6006
|
-
setValueByPath(toObject, ['contents'], tContents(apiClient, fromContents));
|
|
5847
|
+
});
|
|
6007
5848
|
}
|
|
5849
|
+
setValueByPath(toObject, ['contents'], transformedList);
|
|
6008
5850
|
}
|
|
6009
5851
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
6010
5852
|
if (fromConfig != null) {
|
|
@@ -6149,14 +5991,13 @@ function contentToVertex(apiClient, fromObject) {
|
|
|
6149
5991
|
const toObject = {};
|
|
6150
5992
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
6151
5993
|
if (fromParts != null) {
|
|
6152
|
-
|
|
6153
|
-
|
|
5994
|
+
let transformedList = fromParts;
|
|
5995
|
+
if (Array.isArray(transformedList)) {
|
|
5996
|
+
transformedList = transformedList.map((item) => {
|
|
6154
5997
|
return partToVertex(apiClient, item);
|
|
6155
|
-
})
|
|
6156
|
-
}
|
|
6157
|
-
else {
|
|
6158
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
5998
|
+
});
|
|
6159
5999
|
}
|
|
6000
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
6160
6001
|
}
|
|
6161
6002
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
6162
6003
|
if (fromRole != null) {
|
|
@@ -6164,104 +6005,6 @@ function contentToVertex(apiClient, fromObject) {
|
|
|
6164
6005
|
}
|
|
6165
6006
|
return toObject;
|
|
6166
6007
|
}
|
|
6167
|
-
function schemaToVertex(apiClient, fromObject) {
|
|
6168
|
-
const toObject = {};
|
|
6169
|
-
const fromExample = getValueByPath(fromObject, ['example']);
|
|
6170
|
-
if (fromExample != null) {
|
|
6171
|
-
setValueByPath(toObject, ['example'], fromExample);
|
|
6172
|
-
}
|
|
6173
|
-
const fromPattern = getValueByPath(fromObject, ['pattern']);
|
|
6174
|
-
if (fromPattern != null) {
|
|
6175
|
-
setValueByPath(toObject, ['pattern'], fromPattern);
|
|
6176
|
-
}
|
|
6177
|
-
const fromDefault = getValueByPath(fromObject, ['default']);
|
|
6178
|
-
if (fromDefault != null) {
|
|
6179
|
-
setValueByPath(toObject, ['default'], fromDefault);
|
|
6180
|
-
}
|
|
6181
|
-
const fromMaxLength = getValueByPath(fromObject, ['maxLength']);
|
|
6182
|
-
if (fromMaxLength != null) {
|
|
6183
|
-
setValueByPath(toObject, ['maxLength'], fromMaxLength);
|
|
6184
|
-
}
|
|
6185
|
-
const fromMinLength = getValueByPath(fromObject, ['minLength']);
|
|
6186
|
-
if (fromMinLength != null) {
|
|
6187
|
-
setValueByPath(toObject, ['minLength'], fromMinLength);
|
|
6188
|
-
}
|
|
6189
|
-
const fromMinProperties = getValueByPath(fromObject, [
|
|
6190
|
-
'minProperties',
|
|
6191
|
-
]);
|
|
6192
|
-
if (fromMinProperties != null) {
|
|
6193
|
-
setValueByPath(toObject, ['minProperties'], fromMinProperties);
|
|
6194
|
-
}
|
|
6195
|
-
const fromMaxProperties = getValueByPath(fromObject, [
|
|
6196
|
-
'maxProperties',
|
|
6197
|
-
]);
|
|
6198
|
-
if (fromMaxProperties != null) {
|
|
6199
|
-
setValueByPath(toObject, ['maxProperties'], fromMaxProperties);
|
|
6200
|
-
}
|
|
6201
|
-
const fromAnyOf = getValueByPath(fromObject, ['anyOf']);
|
|
6202
|
-
if (fromAnyOf != null) {
|
|
6203
|
-
setValueByPath(toObject, ['anyOf'], fromAnyOf);
|
|
6204
|
-
}
|
|
6205
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
6206
|
-
if (fromDescription != null) {
|
|
6207
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
6208
|
-
}
|
|
6209
|
-
const fromEnum = getValueByPath(fromObject, ['enum']);
|
|
6210
|
-
if (fromEnum != null) {
|
|
6211
|
-
setValueByPath(toObject, ['enum'], fromEnum);
|
|
6212
|
-
}
|
|
6213
|
-
const fromFormat = getValueByPath(fromObject, ['format']);
|
|
6214
|
-
if (fromFormat != null) {
|
|
6215
|
-
setValueByPath(toObject, ['format'], fromFormat);
|
|
6216
|
-
}
|
|
6217
|
-
const fromItems = getValueByPath(fromObject, ['items']);
|
|
6218
|
-
if (fromItems != null) {
|
|
6219
|
-
setValueByPath(toObject, ['items'], fromItems);
|
|
6220
|
-
}
|
|
6221
|
-
const fromMaxItems = getValueByPath(fromObject, ['maxItems']);
|
|
6222
|
-
if (fromMaxItems != null) {
|
|
6223
|
-
setValueByPath(toObject, ['maxItems'], fromMaxItems);
|
|
6224
|
-
}
|
|
6225
|
-
const fromMaximum = getValueByPath(fromObject, ['maximum']);
|
|
6226
|
-
if (fromMaximum != null) {
|
|
6227
|
-
setValueByPath(toObject, ['maximum'], fromMaximum);
|
|
6228
|
-
}
|
|
6229
|
-
const fromMinItems = getValueByPath(fromObject, ['minItems']);
|
|
6230
|
-
if (fromMinItems != null) {
|
|
6231
|
-
setValueByPath(toObject, ['minItems'], fromMinItems);
|
|
6232
|
-
}
|
|
6233
|
-
const fromMinimum = getValueByPath(fromObject, ['minimum']);
|
|
6234
|
-
if (fromMinimum != null) {
|
|
6235
|
-
setValueByPath(toObject, ['minimum'], fromMinimum);
|
|
6236
|
-
}
|
|
6237
|
-
const fromNullable = getValueByPath(fromObject, ['nullable']);
|
|
6238
|
-
if (fromNullable != null) {
|
|
6239
|
-
setValueByPath(toObject, ['nullable'], fromNullable);
|
|
6240
|
-
}
|
|
6241
|
-
const fromProperties = getValueByPath(fromObject, ['properties']);
|
|
6242
|
-
if (fromProperties != null) {
|
|
6243
|
-
setValueByPath(toObject, ['properties'], fromProperties);
|
|
6244
|
-
}
|
|
6245
|
-
const fromPropertyOrdering = getValueByPath(fromObject, [
|
|
6246
|
-
'propertyOrdering',
|
|
6247
|
-
]);
|
|
6248
|
-
if (fromPropertyOrdering != null) {
|
|
6249
|
-
setValueByPath(toObject, ['propertyOrdering'], fromPropertyOrdering);
|
|
6250
|
-
}
|
|
6251
|
-
const fromRequired = getValueByPath(fromObject, ['required']);
|
|
6252
|
-
if (fromRequired != null) {
|
|
6253
|
-
setValueByPath(toObject, ['required'], fromRequired);
|
|
6254
|
-
}
|
|
6255
|
-
const fromTitle = getValueByPath(fromObject, ['title']);
|
|
6256
|
-
if (fromTitle != null) {
|
|
6257
|
-
setValueByPath(toObject, ['title'], fromTitle);
|
|
6258
|
-
}
|
|
6259
|
-
const fromType = getValueByPath(fromObject, ['type']);
|
|
6260
|
-
if (fromType != null) {
|
|
6261
|
-
setValueByPath(toObject, ['type'], fromType);
|
|
6262
|
-
}
|
|
6263
|
-
return toObject;
|
|
6264
|
-
}
|
|
6265
6008
|
function modelSelectionConfigToVertex(apiClient, fromObject) {
|
|
6266
6009
|
const toObject = {};
|
|
6267
6010
|
const fromFeatureSelectionPreference = getValueByPath(fromObject, [
|
|
@@ -6288,26 +6031,6 @@ function safetySettingToVertex(apiClient, fromObject) {
|
|
|
6288
6031
|
}
|
|
6289
6032
|
return toObject;
|
|
6290
6033
|
}
|
|
6291
|
-
function functionDeclarationToVertex(apiClient, fromObject) {
|
|
6292
|
-
const toObject = {};
|
|
6293
|
-
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
6294
|
-
if (fromResponse != null) {
|
|
6295
|
-
setValueByPath(toObject, ['response'], schemaToVertex(apiClient, fromResponse));
|
|
6296
|
-
}
|
|
6297
|
-
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
6298
|
-
if (fromDescription != null) {
|
|
6299
|
-
setValueByPath(toObject, ['description'], fromDescription);
|
|
6300
|
-
}
|
|
6301
|
-
const fromName = getValueByPath(fromObject, ['name']);
|
|
6302
|
-
if (fromName != null) {
|
|
6303
|
-
setValueByPath(toObject, ['name'], fromName);
|
|
6304
|
-
}
|
|
6305
|
-
const fromParameters = getValueByPath(fromObject, ['parameters']);
|
|
6306
|
-
if (fromParameters != null) {
|
|
6307
|
-
setValueByPath(toObject, ['parameters'], fromParameters);
|
|
6308
|
-
}
|
|
6309
|
-
return toObject;
|
|
6310
|
-
}
|
|
6311
6034
|
function googleSearchToVertex() {
|
|
6312
6035
|
const toObject = {};
|
|
6313
6036
|
return toObject;
|
|
@@ -6338,19 +6061,6 @@ function googleSearchRetrievalToVertex(apiClient, fromObject) {
|
|
|
6338
6061
|
}
|
|
6339
6062
|
function toolToVertex(apiClient, fromObject) {
|
|
6340
6063
|
const toObject = {};
|
|
6341
|
-
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
6342
|
-
'functionDeclarations',
|
|
6343
|
-
]);
|
|
6344
|
-
if (fromFunctionDeclarations != null) {
|
|
6345
|
-
if (Array.isArray(fromFunctionDeclarations)) {
|
|
6346
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations.map((item) => {
|
|
6347
|
-
return functionDeclarationToVertex(apiClient, item);
|
|
6348
|
-
}));
|
|
6349
|
-
}
|
|
6350
|
-
else {
|
|
6351
|
-
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
6352
|
-
}
|
|
6353
|
-
}
|
|
6354
6064
|
const fromRetrieval = getValueByPath(fromObject, ['retrieval']);
|
|
6355
6065
|
if (fromRetrieval != null) {
|
|
6356
6066
|
setValueByPath(toObject, ['retrieval'], fromRetrieval);
|
|
@@ -6371,6 +6081,12 @@ function toolToVertex(apiClient, fromObject) {
|
|
|
6371
6081
|
if (fromCodeExecution != null) {
|
|
6372
6082
|
setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
|
|
6373
6083
|
}
|
|
6084
|
+
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
6085
|
+
'functionDeclarations',
|
|
6086
|
+
]);
|
|
6087
|
+
if (fromFunctionDeclarations != null) {
|
|
6088
|
+
setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
|
|
6089
|
+
}
|
|
6374
6090
|
return toObject;
|
|
6375
6091
|
}
|
|
6376
6092
|
function functionCallingConfigToVertex(apiClient, fromObject) {
|
|
@@ -6517,7 +6233,7 @@ function generateContentConfigToVertex(apiClient, fromObject, parentObject) {
|
|
|
6517
6233
|
'responseSchema',
|
|
6518
6234
|
]);
|
|
6519
6235
|
if (fromResponseSchema != null) {
|
|
6520
|
-
setValueByPath(toObject, ['responseSchema'],
|
|
6236
|
+
setValueByPath(toObject, ['responseSchema'], tSchema(apiClient, fromResponseSchema));
|
|
6521
6237
|
}
|
|
6522
6238
|
const fromRoutingConfig = getValueByPath(fromObject, [
|
|
6523
6239
|
'routingConfig',
|
|
@@ -6535,25 +6251,23 @@ function generateContentConfigToVertex(apiClient, fromObject, parentObject) {
|
|
|
6535
6251
|
'safetySettings',
|
|
6536
6252
|
]);
|
|
6537
6253
|
if (parentObject !== undefined && fromSafetySettings != null) {
|
|
6538
|
-
|
|
6539
|
-
|
|
6254
|
+
let transformedList = fromSafetySettings;
|
|
6255
|
+
if (Array.isArray(transformedList)) {
|
|
6256
|
+
transformedList = transformedList.map((item) => {
|
|
6540
6257
|
return safetySettingToVertex(apiClient, item);
|
|
6541
|
-
})
|
|
6542
|
-
}
|
|
6543
|
-
else {
|
|
6544
|
-
setValueByPath(parentObject, ['safetySettings'], fromSafetySettings);
|
|
6258
|
+
});
|
|
6545
6259
|
}
|
|
6260
|
+
setValueByPath(parentObject, ['safetySettings'], transformedList);
|
|
6546
6261
|
}
|
|
6547
6262
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
6548
6263
|
if (parentObject !== undefined && fromTools != null) {
|
|
6549
|
-
|
|
6550
|
-
|
|
6264
|
+
let transformedList = tTools(apiClient, fromTools);
|
|
6265
|
+
if (Array.isArray(transformedList)) {
|
|
6266
|
+
transformedList = transformedList.map((item) => {
|
|
6551
6267
|
return toolToVertex(apiClient, tTool(apiClient, item));
|
|
6552
|
-
})
|
|
6553
|
-
}
|
|
6554
|
-
else {
|
|
6555
|
-
setValueByPath(parentObject, ['tools'], tTools(apiClient, fromTools));
|
|
6268
|
+
});
|
|
6556
6269
|
}
|
|
6270
|
+
setValueByPath(parentObject, ['tools'], transformedList);
|
|
6557
6271
|
}
|
|
6558
6272
|
const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
|
|
6559
6273
|
if (parentObject !== undefined && fromToolConfig != null) {
|
|
@@ -6607,14 +6321,13 @@ function generateContentParametersToVertex(apiClient, fromObject) {
|
|
|
6607
6321
|
}
|
|
6608
6322
|
const fromContents = getValueByPath(fromObject, ['contents']);
|
|
6609
6323
|
if (fromContents != null) {
|
|
6610
|
-
|
|
6611
|
-
|
|
6324
|
+
let transformedList = tContents(apiClient, fromContents);
|
|
6325
|
+
if (Array.isArray(transformedList)) {
|
|
6326
|
+
transformedList = transformedList.map((item) => {
|
|
6612
6327
|
return contentToVertex(apiClient, item);
|
|
6613
|
-
})
|
|
6614
|
-
}
|
|
6615
|
-
else {
|
|
6616
|
-
setValueByPath(toObject, ['contents'], tContents(apiClient, fromContents));
|
|
6328
|
+
});
|
|
6617
6329
|
}
|
|
6330
|
+
setValueByPath(toObject, ['contents'], transformedList);
|
|
6618
6331
|
}
|
|
6619
6332
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
6620
6333
|
if (fromConfig != null) {
|
|
@@ -6776,6 +6489,42 @@ function getModelParametersToVertex(apiClient, fromObject) {
|
|
|
6776
6489
|
}
|
|
6777
6490
|
return toObject;
|
|
6778
6491
|
}
|
|
6492
|
+
function updateModelConfigToVertex(apiClient, fromObject, parentObject) {
|
|
6493
|
+
const toObject = {};
|
|
6494
|
+
const fromDisplayName = getValueByPath(fromObject, ['displayName']);
|
|
6495
|
+
if (parentObject !== undefined && fromDisplayName != null) {
|
|
6496
|
+
setValueByPath(parentObject, ['displayName'], fromDisplayName);
|
|
6497
|
+
}
|
|
6498
|
+
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
6499
|
+
if (parentObject !== undefined && fromDescription != null) {
|
|
6500
|
+
setValueByPath(parentObject, ['description'], fromDescription);
|
|
6501
|
+
}
|
|
6502
|
+
return toObject;
|
|
6503
|
+
}
|
|
6504
|
+
function updateModelParametersToVertex(apiClient, fromObject) {
|
|
6505
|
+
const toObject = {};
|
|
6506
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
6507
|
+
if (fromModel != null) {
|
|
6508
|
+
setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
|
|
6509
|
+
}
|
|
6510
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
6511
|
+
if (fromConfig != null) {
|
|
6512
|
+
setValueByPath(toObject, ['config'], updateModelConfigToVertex(apiClient, fromConfig, toObject));
|
|
6513
|
+
}
|
|
6514
|
+
return toObject;
|
|
6515
|
+
}
|
|
6516
|
+
function deleteModelParametersToVertex(apiClient, fromObject) {
|
|
6517
|
+
const toObject = {};
|
|
6518
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
6519
|
+
if (fromModel != null) {
|
|
6520
|
+
setValueByPath(toObject, ['_url', 'name'], tModel(apiClient, fromModel));
|
|
6521
|
+
}
|
|
6522
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
6523
|
+
if (fromConfig != null) {
|
|
6524
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
6525
|
+
}
|
|
6526
|
+
return toObject;
|
|
6527
|
+
}
|
|
6779
6528
|
function countTokensConfigToVertex(apiClient, fromObject, parentObject) {
|
|
6780
6529
|
const toObject = {};
|
|
6781
6530
|
const fromSystemInstruction = getValueByPath(fromObject, [
|
|
@@ -6786,14 +6535,13 @@ function countTokensConfigToVertex(apiClient, fromObject, parentObject) {
|
|
|
6786
6535
|
}
|
|
6787
6536
|
const fromTools = getValueByPath(fromObject, ['tools']);
|
|
6788
6537
|
if (parentObject !== undefined && fromTools != null) {
|
|
6789
|
-
|
|
6790
|
-
|
|
6538
|
+
let transformedList = fromTools;
|
|
6539
|
+
if (Array.isArray(transformedList)) {
|
|
6540
|
+
transformedList = transformedList.map((item) => {
|
|
6791
6541
|
return toolToVertex(apiClient, item);
|
|
6792
|
-
})
|
|
6793
|
-
}
|
|
6794
|
-
else {
|
|
6795
|
-
setValueByPath(parentObject, ['tools'], fromTools);
|
|
6542
|
+
});
|
|
6796
6543
|
}
|
|
6544
|
+
setValueByPath(parentObject, ['tools'], transformedList);
|
|
6797
6545
|
}
|
|
6798
6546
|
const fromGenerationConfig = getValueByPath(fromObject, [
|
|
6799
6547
|
'generationConfig',
|
|
@@ -6811,14 +6559,13 @@ function countTokensParametersToVertex(apiClient, fromObject) {
|
|
|
6811
6559
|
}
|
|
6812
6560
|
const fromContents = getValueByPath(fromObject, ['contents']);
|
|
6813
6561
|
if (fromContents != null) {
|
|
6814
|
-
|
|
6815
|
-
|
|
6562
|
+
let transformedList = tContents(apiClient, fromContents);
|
|
6563
|
+
if (Array.isArray(transformedList)) {
|
|
6564
|
+
transformedList = transformedList.map((item) => {
|
|
6816
6565
|
return contentToVertex(apiClient, item);
|
|
6817
|
-
})
|
|
6818
|
-
}
|
|
6819
|
-
else {
|
|
6820
|
-
setValueByPath(toObject, ['contents'], tContents(apiClient, fromContents));
|
|
6566
|
+
});
|
|
6821
6567
|
}
|
|
6568
|
+
setValueByPath(toObject, ['contents'], transformedList);
|
|
6822
6569
|
}
|
|
6823
6570
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
6824
6571
|
if (fromConfig != null) {
|
|
@@ -6834,14 +6581,13 @@ function computeTokensParametersToVertex(apiClient, fromObject) {
|
|
|
6834
6581
|
}
|
|
6835
6582
|
const fromContents = getValueByPath(fromObject, ['contents']);
|
|
6836
6583
|
if (fromContents != null) {
|
|
6837
|
-
|
|
6838
|
-
|
|
6584
|
+
let transformedList = tContents(apiClient, fromContents);
|
|
6585
|
+
if (Array.isArray(transformedList)) {
|
|
6586
|
+
transformedList = transformedList.map((item) => {
|
|
6839
6587
|
return contentToVertex(apiClient, item);
|
|
6840
|
-
})
|
|
6841
|
-
}
|
|
6842
|
-
else {
|
|
6843
|
-
setValueByPath(toObject, ['contents'], tContents(apiClient, fromContents));
|
|
6588
|
+
});
|
|
6844
6589
|
}
|
|
6590
|
+
setValueByPath(toObject, ['contents'], transformedList);
|
|
6845
6591
|
}
|
|
6846
6592
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
6847
6593
|
if (fromConfig != null) {
|
|
@@ -6989,14 +6735,13 @@ function contentFromMldev(apiClient, fromObject) {
|
|
|
6989
6735
|
const toObject = {};
|
|
6990
6736
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
6991
6737
|
if (fromParts != null) {
|
|
6992
|
-
|
|
6993
|
-
|
|
6738
|
+
let transformedList = fromParts;
|
|
6739
|
+
if (Array.isArray(transformedList)) {
|
|
6740
|
+
transformedList = transformedList.map((item) => {
|
|
6994
6741
|
return partFromMldev(apiClient, item);
|
|
6995
|
-
})
|
|
6996
|
-
}
|
|
6997
|
-
else {
|
|
6998
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
6742
|
+
});
|
|
6999
6743
|
}
|
|
6744
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
7000
6745
|
}
|
|
7001
6746
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
7002
6747
|
if (fromRole != null) {
|
|
@@ -7064,14 +6809,13 @@ function generateContentResponseFromMldev(apiClient, fromObject) {
|
|
|
7064
6809
|
const toObject = {};
|
|
7065
6810
|
const fromCandidates = getValueByPath(fromObject, ['candidates']);
|
|
7066
6811
|
if (fromCandidates != null) {
|
|
7067
|
-
|
|
7068
|
-
|
|
6812
|
+
let transformedList = fromCandidates;
|
|
6813
|
+
if (Array.isArray(transformedList)) {
|
|
6814
|
+
transformedList = transformedList.map((item) => {
|
|
7069
6815
|
return candidateFromMldev(apiClient, item);
|
|
7070
|
-
})
|
|
7071
|
-
}
|
|
7072
|
-
else {
|
|
7073
|
-
setValueByPath(toObject, ['candidates'], fromCandidates);
|
|
6816
|
+
});
|
|
7074
6817
|
}
|
|
6818
|
+
setValueByPath(toObject, ['candidates'], transformedList);
|
|
7075
6819
|
}
|
|
7076
6820
|
const fromModelVersion = getValueByPath(fromObject, ['modelVersion']);
|
|
7077
6821
|
if (fromModelVersion != null) {
|
|
@@ -7107,14 +6851,13 @@ function embedContentResponseFromMldev(apiClient, fromObject) {
|
|
|
7107
6851
|
const toObject = {};
|
|
7108
6852
|
const fromEmbeddings = getValueByPath(fromObject, ['embeddings']);
|
|
7109
6853
|
if (fromEmbeddings != null) {
|
|
7110
|
-
|
|
7111
|
-
|
|
6854
|
+
let transformedList = fromEmbeddings;
|
|
6855
|
+
if (Array.isArray(transformedList)) {
|
|
6856
|
+
transformedList = transformedList.map((item) => {
|
|
7112
6857
|
return contentEmbeddingFromMldev(apiClient, item);
|
|
7113
|
-
})
|
|
7114
|
-
}
|
|
7115
|
-
else {
|
|
7116
|
-
setValueByPath(toObject, ['embeddings'], fromEmbeddings);
|
|
6858
|
+
});
|
|
7117
6859
|
}
|
|
6860
|
+
setValueByPath(toObject, ['embeddings'], transformedList);
|
|
7118
6861
|
}
|
|
7119
6862
|
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
7120
6863
|
if (fromMetadata != null) {
|
|
@@ -7182,14 +6925,13 @@ function generateImagesResponseFromMldev(apiClient, fromObject) {
|
|
|
7182
6925
|
'predictions',
|
|
7183
6926
|
]);
|
|
7184
6927
|
if (fromGeneratedImages != null) {
|
|
7185
|
-
|
|
7186
|
-
|
|
6928
|
+
let transformedList = fromGeneratedImages;
|
|
6929
|
+
if (Array.isArray(transformedList)) {
|
|
6930
|
+
transformedList = transformedList.map((item) => {
|
|
7187
6931
|
return generatedImageFromMldev(apiClient, item);
|
|
7188
|
-
})
|
|
7189
|
-
}
|
|
7190
|
-
else {
|
|
7191
|
-
setValueByPath(toObject, ['generatedImages'], fromGeneratedImages);
|
|
6932
|
+
});
|
|
7192
6933
|
}
|
|
6934
|
+
setValueByPath(toObject, ['generatedImages'], transformedList);
|
|
7193
6935
|
}
|
|
7194
6936
|
const fromPositivePromptSafetyAttributes = getValueByPath(fromObject, [
|
|
7195
6937
|
'positivePromptSafetyAttributes',
|
|
@@ -7257,6 +6999,10 @@ function modelFromMldev(apiClient, fromObject) {
|
|
|
7257
6999
|
}
|
|
7258
7000
|
return toObject;
|
|
7259
7001
|
}
|
|
7002
|
+
function deleteModelResponseFromMldev() {
|
|
7003
|
+
const toObject = {};
|
|
7004
|
+
return toObject;
|
|
7005
|
+
}
|
|
7260
7006
|
function countTokensResponseFromMldev(apiClient, fromObject) {
|
|
7261
7007
|
const toObject = {};
|
|
7262
7008
|
const fromTotalTokens = getValueByPath(fromObject, ['totalTokens']);
|
|
@@ -7304,14 +7050,13 @@ function generateVideosResponseFromMldev$1(apiClient, fromObject) {
|
|
|
7304
7050
|
'generatedSamples',
|
|
7305
7051
|
]);
|
|
7306
7052
|
if (fromGeneratedVideos != null) {
|
|
7307
|
-
|
|
7308
|
-
|
|
7053
|
+
let transformedList = fromGeneratedVideos;
|
|
7054
|
+
if (Array.isArray(transformedList)) {
|
|
7055
|
+
transformedList = transformedList.map((item) => {
|
|
7309
7056
|
return generatedVideoFromMldev$1(apiClient, item);
|
|
7310
|
-
})
|
|
7311
|
-
}
|
|
7312
|
-
else {
|
|
7313
|
-
setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos);
|
|
7057
|
+
});
|
|
7314
7058
|
}
|
|
7059
|
+
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
7315
7060
|
}
|
|
7316
7061
|
const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
|
|
7317
7062
|
'raiMediaFilteredCount',
|
|
@@ -7406,14 +7151,13 @@ function contentFromVertex(apiClient, fromObject) {
|
|
|
7406
7151
|
const toObject = {};
|
|
7407
7152
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
7408
7153
|
if (fromParts != null) {
|
|
7409
|
-
|
|
7410
|
-
|
|
7154
|
+
let transformedList = fromParts;
|
|
7155
|
+
if (Array.isArray(transformedList)) {
|
|
7156
|
+
transformedList = transformedList.map((item) => {
|
|
7411
7157
|
return partFromVertex(apiClient, item);
|
|
7412
|
-
})
|
|
7413
|
-
}
|
|
7414
|
-
else {
|
|
7415
|
-
setValueByPath(toObject, ['parts'], fromParts);
|
|
7158
|
+
});
|
|
7416
7159
|
}
|
|
7160
|
+
setValueByPath(toObject, ['parts'], transformedList);
|
|
7417
7161
|
}
|
|
7418
7162
|
const fromRole = getValueByPath(fromObject, ['role']);
|
|
7419
7163
|
if (fromRole != null) {
|
|
@@ -7483,14 +7227,13 @@ function generateContentResponseFromVertex(apiClient, fromObject) {
|
|
|
7483
7227
|
const toObject = {};
|
|
7484
7228
|
const fromCandidates = getValueByPath(fromObject, ['candidates']);
|
|
7485
7229
|
if (fromCandidates != null) {
|
|
7486
|
-
|
|
7487
|
-
|
|
7230
|
+
let transformedList = fromCandidates;
|
|
7231
|
+
if (Array.isArray(transformedList)) {
|
|
7232
|
+
transformedList = transformedList.map((item) => {
|
|
7488
7233
|
return candidateFromVertex(apiClient, item);
|
|
7489
|
-
})
|
|
7490
|
-
}
|
|
7491
|
-
else {
|
|
7492
|
-
setValueByPath(toObject, ['candidates'], fromCandidates);
|
|
7234
|
+
});
|
|
7493
7235
|
}
|
|
7236
|
+
setValueByPath(toObject, ['candidates'], transformedList);
|
|
7494
7237
|
}
|
|
7495
7238
|
const fromCreateTime = getValueByPath(fromObject, ['createTime']);
|
|
7496
7239
|
if (fromCreateTime != null) {
|
|
@@ -7559,14 +7302,13 @@ function embedContentResponseFromVertex(apiClient, fromObject) {
|
|
|
7559
7302
|
'embeddings',
|
|
7560
7303
|
]);
|
|
7561
7304
|
if (fromEmbeddings != null) {
|
|
7562
|
-
|
|
7563
|
-
|
|
7305
|
+
let transformedList = fromEmbeddings;
|
|
7306
|
+
if (Array.isArray(transformedList)) {
|
|
7307
|
+
transformedList = transformedList.map((item) => {
|
|
7564
7308
|
return contentEmbeddingFromVertex(apiClient, item);
|
|
7565
|
-
})
|
|
7566
|
-
}
|
|
7567
|
-
else {
|
|
7568
|
-
setValueByPath(toObject, ['embeddings'], fromEmbeddings);
|
|
7309
|
+
});
|
|
7569
7310
|
}
|
|
7311
|
+
setValueByPath(toObject, ['embeddings'], transformedList);
|
|
7570
7312
|
}
|
|
7571
7313
|
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
7572
7314
|
if (fromMetadata != null) {
|
|
@@ -7642,14 +7384,13 @@ function generateImagesResponseFromVertex(apiClient, fromObject) {
|
|
|
7642
7384
|
'predictions',
|
|
7643
7385
|
]);
|
|
7644
7386
|
if (fromGeneratedImages != null) {
|
|
7645
|
-
|
|
7646
|
-
|
|
7387
|
+
let transformedList = fromGeneratedImages;
|
|
7388
|
+
if (Array.isArray(transformedList)) {
|
|
7389
|
+
transformedList = transformedList.map((item) => {
|
|
7647
7390
|
return generatedImageFromVertex(apiClient, item);
|
|
7648
|
-
})
|
|
7649
|
-
}
|
|
7650
|
-
else {
|
|
7651
|
-
setValueByPath(toObject, ['generatedImages'], fromGeneratedImages);
|
|
7391
|
+
});
|
|
7652
7392
|
}
|
|
7393
|
+
setValueByPath(toObject, ['generatedImages'], transformedList);
|
|
7653
7394
|
}
|
|
7654
7395
|
const fromPositivePromptSafetyAttributes = getValueByPath(fromObject, [
|
|
7655
7396
|
'positivePromptSafetyAttributes',
|
|
@@ -7712,14 +7453,13 @@ function modelFromVertex(apiClient, fromObject) {
|
|
|
7712
7453
|
}
|
|
7713
7454
|
const fromEndpoints = getValueByPath(fromObject, ['deployedModels']);
|
|
7714
7455
|
if (fromEndpoints != null) {
|
|
7715
|
-
|
|
7716
|
-
|
|
7456
|
+
let transformedList = fromEndpoints;
|
|
7457
|
+
if (Array.isArray(transformedList)) {
|
|
7458
|
+
transformedList = transformedList.map((item) => {
|
|
7717
7459
|
return endpointFromVertex(apiClient, item);
|
|
7718
|
-
})
|
|
7719
|
-
}
|
|
7720
|
-
else {
|
|
7721
|
-
setValueByPath(toObject, ['endpoints'], fromEndpoints);
|
|
7460
|
+
});
|
|
7722
7461
|
}
|
|
7462
|
+
setValueByPath(toObject, ['endpoints'], transformedList);
|
|
7723
7463
|
}
|
|
7724
7464
|
const fromLabels = getValueByPath(fromObject, ['labels']);
|
|
7725
7465
|
if (fromLabels != null) {
|
|
@@ -7731,6 +7471,10 @@ function modelFromVertex(apiClient, fromObject) {
|
|
|
7731
7471
|
}
|
|
7732
7472
|
return toObject;
|
|
7733
7473
|
}
|
|
7474
|
+
function deleteModelResponseFromVertex() {
|
|
7475
|
+
const toObject = {};
|
|
7476
|
+
return toObject;
|
|
7477
|
+
}
|
|
7734
7478
|
function countTokensResponseFromVertex(apiClient, fromObject) {
|
|
7735
7479
|
const toObject = {};
|
|
7736
7480
|
const fromTotalTokens = getValueByPath(fromObject, ['totalTokens']);
|
|
@@ -7777,14 +7521,13 @@ function generateVideosResponseFromVertex$1(apiClient, fromObject) {
|
|
|
7777
7521
|
const toObject = {};
|
|
7778
7522
|
const fromGeneratedVideos = getValueByPath(fromObject, ['videos']);
|
|
7779
7523
|
if (fromGeneratedVideos != null) {
|
|
7780
|
-
|
|
7781
|
-
|
|
7524
|
+
let transformedList = fromGeneratedVideos;
|
|
7525
|
+
if (Array.isArray(transformedList)) {
|
|
7526
|
+
transformedList = transformedList.map((item) => {
|
|
7782
7527
|
return generatedVideoFromVertex$1(apiClient, item);
|
|
7783
|
-
})
|
|
7784
|
-
}
|
|
7785
|
-
else {
|
|
7786
|
-
setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos);
|
|
7528
|
+
});
|
|
7787
7529
|
}
|
|
7530
|
+
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
7788
7531
|
}
|
|
7789
7532
|
const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
|
|
7790
7533
|
'raiMediaFilteredCount',
|
|
@@ -8028,21 +7771,6 @@ class Session {
|
|
|
8028
7771
|
clientContent: { turnComplete: params.turnComplete },
|
|
8029
7772
|
};
|
|
8030
7773
|
}
|
|
8031
|
-
tLiveClientRealtimeInput(apiClient, params) {
|
|
8032
|
-
let clientMessage = {};
|
|
8033
|
-
if (!('media' in params) || !params.media) {
|
|
8034
|
-
throw new Error(`Failed to convert realtime input "media", type: '${typeof params.media}'`);
|
|
8035
|
-
}
|
|
8036
|
-
// LiveClientRealtimeInput
|
|
8037
|
-
clientMessage = {
|
|
8038
|
-
realtimeInput: {
|
|
8039
|
-
mediaChunks: [params.media],
|
|
8040
|
-
activityStart: params.activityStart,
|
|
8041
|
-
activityEnd: params.activityEnd,
|
|
8042
|
-
},
|
|
8043
|
-
};
|
|
8044
|
-
return clientMessage;
|
|
8045
|
-
}
|
|
8046
7774
|
tLiveClienttToolResponse(apiClient, params) {
|
|
8047
7775
|
let functionResponses = [];
|
|
8048
7776
|
if (params.functionResponses == null) {
|
|
@@ -8150,10 +7878,17 @@ class Session {
|
|
|
8150
7878
|
of audio and image mimetypes are allowed.
|
|
8151
7879
|
*/
|
|
8152
7880
|
sendRealtimeInput(params) {
|
|
8153
|
-
|
|
8154
|
-
|
|
7881
|
+
let clientMessage = {};
|
|
7882
|
+
if (this.apiClient.isVertexAI()) {
|
|
7883
|
+
clientMessage = {
|
|
7884
|
+
'realtimeInput': liveSendRealtimeInputParametersToVertex(this.apiClient, params),
|
|
7885
|
+
};
|
|
7886
|
+
}
|
|
7887
|
+
else {
|
|
7888
|
+
clientMessage = {
|
|
7889
|
+
'realtimeInput': liveSendRealtimeInputParametersToMldev(this.apiClient, params),
|
|
7890
|
+
};
|
|
8155
7891
|
}
|
|
8156
|
-
const clientMessage = this.tLiveClientRealtimeInput(this.apiClient, params);
|
|
8157
7892
|
this.conn.send(JSON.stringify(clientMessage));
|
|
8158
7893
|
}
|
|
8159
7894
|
/**
|
|
@@ -8374,7 +8109,7 @@ class Models extends BaseModule {
|
|
|
8374
8109
|
};
|
|
8375
8110
|
}
|
|
8376
8111
|
async generateContentInternal(params) {
|
|
8377
|
-
var _a, _b;
|
|
8112
|
+
var _a, _b, _c, _d;
|
|
8378
8113
|
let response;
|
|
8379
8114
|
let path = '';
|
|
8380
8115
|
let queryParams = {};
|
|
@@ -8392,6 +8127,7 @@ class Models extends BaseModule {
|
|
|
8392
8127
|
body: JSON.stringify(body),
|
|
8393
8128
|
httpMethod: 'POST',
|
|
8394
8129
|
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
8130
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
8395
8131
|
})
|
|
8396
8132
|
.then((httpResponse) => {
|
|
8397
8133
|
return httpResponse.json();
|
|
@@ -8416,7 +8152,8 @@ class Models extends BaseModule {
|
|
|
8416
8152
|
queryParams: queryParams,
|
|
8417
8153
|
body: JSON.stringify(body),
|
|
8418
8154
|
httpMethod: 'POST',
|
|
8419
|
-
httpOptions: (
|
|
8155
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
8156
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
8420
8157
|
})
|
|
8421
8158
|
.then((httpResponse) => {
|
|
8422
8159
|
return httpResponse.json();
|
|
@@ -8430,7 +8167,7 @@ class Models extends BaseModule {
|
|
|
8430
8167
|
}
|
|
8431
8168
|
}
|
|
8432
8169
|
async generateContentStreamInternal(params) {
|
|
8433
|
-
var _a, _b;
|
|
8170
|
+
var _a, _b, _c, _d;
|
|
8434
8171
|
let response;
|
|
8435
8172
|
let path = '';
|
|
8436
8173
|
let queryParams = {};
|
|
@@ -8448,6 +8185,7 @@ class Models extends BaseModule {
|
|
|
8448
8185
|
body: JSON.stringify(body),
|
|
8449
8186
|
httpMethod: 'POST',
|
|
8450
8187
|
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
8188
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
8451
8189
|
});
|
|
8452
8190
|
return response.then(function (apiResponse) {
|
|
8453
8191
|
return __asyncGenerator(this, arguments, function* () {
|
|
@@ -8486,7 +8224,8 @@ class Models extends BaseModule {
|
|
|
8486
8224
|
queryParams: queryParams,
|
|
8487
8225
|
body: JSON.stringify(body),
|
|
8488
8226
|
httpMethod: 'POST',
|
|
8489
|
-
httpOptions: (
|
|
8227
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
8228
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
8490
8229
|
});
|
|
8491
8230
|
return response.then(function (apiResponse) {
|
|
8492
8231
|
return __asyncGenerator(this, arguments, function* () {
|
|
@@ -8535,7 +8274,7 @@ class Models extends BaseModule {
|
|
|
8535
8274
|
* ```
|
|
8536
8275
|
*/
|
|
8537
8276
|
async embedContent(params) {
|
|
8538
|
-
var _a, _b;
|
|
8277
|
+
var _a, _b, _c, _d;
|
|
8539
8278
|
let response;
|
|
8540
8279
|
let path = '';
|
|
8541
8280
|
let queryParams = {};
|
|
@@ -8553,6 +8292,7 @@ class Models extends BaseModule {
|
|
|
8553
8292
|
body: JSON.stringify(body),
|
|
8554
8293
|
httpMethod: 'POST',
|
|
8555
8294
|
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
8295
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
8556
8296
|
})
|
|
8557
8297
|
.then((httpResponse) => {
|
|
8558
8298
|
return httpResponse.json();
|
|
@@ -8577,7 +8317,8 @@ class Models extends BaseModule {
|
|
|
8577
8317
|
queryParams: queryParams,
|
|
8578
8318
|
body: JSON.stringify(body),
|
|
8579
8319
|
httpMethod: 'POST',
|
|
8580
|
-
httpOptions: (
|
|
8320
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
8321
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
8581
8322
|
})
|
|
8582
8323
|
.then((httpResponse) => {
|
|
8583
8324
|
return httpResponse.json();
|
|
@@ -8610,7 +8351,7 @@ class Models extends BaseModule {
|
|
|
8610
8351
|
* ```
|
|
8611
8352
|
*/
|
|
8612
8353
|
async generateImagesInternal(params) {
|
|
8613
|
-
var _a, _b;
|
|
8354
|
+
var _a, _b, _c, _d;
|
|
8614
8355
|
let response;
|
|
8615
8356
|
let path = '';
|
|
8616
8357
|
let queryParams = {};
|
|
@@ -8628,6 +8369,7 @@ class Models extends BaseModule {
|
|
|
8628
8369
|
body: JSON.stringify(body),
|
|
8629
8370
|
httpMethod: 'POST',
|
|
8630
8371
|
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
8372
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
8631
8373
|
})
|
|
8632
8374
|
.then((httpResponse) => {
|
|
8633
8375
|
return httpResponse.json();
|
|
@@ -8652,7 +8394,8 @@ class Models extends BaseModule {
|
|
|
8652
8394
|
queryParams: queryParams,
|
|
8653
8395
|
body: JSON.stringify(body),
|
|
8654
8396
|
httpMethod: 'POST',
|
|
8655
|
-
httpOptions: (
|
|
8397
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
8398
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
8656
8399
|
})
|
|
8657
8400
|
.then((httpResponse) => {
|
|
8658
8401
|
return httpResponse.json();
|
|
@@ -8674,7 +8417,7 @@ class Models extends BaseModule {
|
|
|
8674
8417
|
* ```
|
|
8675
8418
|
*/
|
|
8676
8419
|
async get(params) {
|
|
8677
|
-
var _a, _b;
|
|
8420
|
+
var _a, _b, _c, _d;
|
|
8678
8421
|
let response;
|
|
8679
8422
|
let path = '';
|
|
8680
8423
|
let queryParams = {};
|
|
@@ -8692,6 +8435,7 @@ class Models extends BaseModule {
|
|
|
8692
8435
|
body: JSON.stringify(body),
|
|
8693
8436
|
httpMethod: 'GET',
|
|
8694
8437
|
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
8438
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
8695
8439
|
})
|
|
8696
8440
|
.then((httpResponse) => {
|
|
8697
8441
|
return httpResponse.json();
|
|
@@ -8714,7 +8458,8 @@ class Models extends BaseModule {
|
|
|
8714
8458
|
queryParams: queryParams,
|
|
8715
8459
|
body: JSON.stringify(body),
|
|
8716
8460
|
httpMethod: 'GET',
|
|
8717
|
-
httpOptions: (
|
|
8461
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
8462
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
8718
8463
|
})
|
|
8719
8464
|
.then((httpResponse) => {
|
|
8720
8465
|
return httpResponse.json();
|
|
@@ -8726,29 +8471,30 @@ class Models extends BaseModule {
|
|
|
8726
8471
|
}
|
|
8727
8472
|
}
|
|
8728
8473
|
/**
|
|
8729
|
-
*
|
|
8730
|
-
* supported for Gemini models.
|
|
8474
|
+
* Updates a tuned model by its name.
|
|
8731
8475
|
*
|
|
8732
|
-
* @param params - The parameters for
|
|
8476
|
+
* @param params - The parameters for updating the model.
|
|
8733
8477
|
* @return The response from the API.
|
|
8734
8478
|
*
|
|
8735
8479
|
* @example
|
|
8736
8480
|
* ```ts
|
|
8737
|
-
* const response = await ai.models.
|
|
8738
|
-
*
|
|
8739
|
-
*
|
|
8481
|
+
* const response = await ai.models.update({
|
|
8482
|
+
* model: 'tuned-model-name',
|
|
8483
|
+
* config: {
|
|
8484
|
+
* displayName: 'New display name',
|
|
8485
|
+
* description: 'New description',
|
|
8486
|
+
* },
|
|
8740
8487
|
* });
|
|
8741
|
-
* console.log(response);
|
|
8742
8488
|
* ```
|
|
8743
8489
|
*/
|
|
8744
|
-
async
|
|
8745
|
-
var _a, _b;
|
|
8490
|
+
async update(params) {
|
|
8491
|
+
var _a, _b, _c, _d;
|
|
8746
8492
|
let response;
|
|
8747
8493
|
let path = '';
|
|
8748
8494
|
let queryParams = {};
|
|
8749
8495
|
if (this.apiClient.isVertexAI()) {
|
|
8750
|
-
const body =
|
|
8751
|
-
path = formatMap('{model}
|
|
8496
|
+
const body = updateModelParametersToVertex(this.apiClient, params);
|
|
8497
|
+
path = formatMap('{model}', body['_url']);
|
|
8752
8498
|
queryParams = body['_query'];
|
|
8753
8499
|
delete body['config'];
|
|
8754
8500
|
delete body['_url'];
|
|
@@ -8758,22 +8504,21 @@ class Models extends BaseModule {
|
|
|
8758
8504
|
path: path,
|
|
8759
8505
|
queryParams: queryParams,
|
|
8760
8506
|
body: JSON.stringify(body),
|
|
8761
|
-
httpMethod: '
|
|
8507
|
+
httpMethod: 'PATCH',
|
|
8762
8508
|
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
8509
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
8763
8510
|
})
|
|
8764
8511
|
.then((httpResponse) => {
|
|
8765
8512
|
return httpResponse.json();
|
|
8766
8513
|
});
|
|
8767
8514
|
return response.then((apiResponse) => {
|
|
8768
|
-
const resp =
|
|
8769
|
-
|
|
8770
|
-
Object.assign(typedResp, resp);
|
|
8771
|
-
return typedResp;
|
|
8515
|
+
const resp = modelFromVertex(this.apiClient, apiResponse);
|
|
8516
|
+
return resp;
|
|
8772
8517
|
});
|
|
8773
8518
|
}
|
|
8774
8519
|
else {
|
|
8775
|
-
const body =
|
|
8776
|
-
path = formatMap('{
|
|
8520
|
+
const body = updateModelParametersToMldev(this.apiClient, params);
|
|
8521
|
+
path = formatMap('{name}', body['_url']);
|
|
8777
8522
|
queryParams = body['_query'];
|
|
8778
8523
|
delete body['config'];
|
|
8779
8524
|
delete body['_url'];
|
|
@@ -8783,40 +8528,182 @@ class Models extends BaseModule {
|
|
|
8783
8528
|
path: path,
|
|
8784
8529
|
queryParams: queryParams,
|
|
8785
8530
|
body: JSON.stringify(body),
|
|
8786
|
-
httpMethod: '
|
|
8787
|
-
httpOptions: (
|
|
8531
|
+
httpMethod: 'PATCH',
|
|
8532
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
8533
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
8788
8534
|
})
|
|
8789
8535
|
.then((httpResponse) => {
|
|
8790
8536
|
return httpResponse.json();
|
|
8791
8537
|
});
|
|
8792
8538
|
return response.then((apiResponse) => {
|
|
8793
|
-
const resp =
|
|
8794
|
-
|
|
8795
|
-
Object.assign(typedResp, resp);
|
|
8796
|
-
return typedResp;
|
|
8539
|
+
const resp = modelFromMldev(this.apiClient, apiResponse);
|
|
8540
|
+
return resp;
|
|
8797
8541
|
});
|
|
8798
8542
|
}
|
|
8799
8543
|
}
|
|
8800
8544
|
/**
|
|
8801
|
-
*
|
|
8802
|
-
* the list of tokens and list of token ids.
|
|
8545
|
+
* Deletes a tuned model by its name.
|
|
8803
8546
|
*
|
|
8804
|
-
*
|
|
8805
|
-
*
|
|
8806
|
-
* @param params - The parameters for computing tokens.
|
|
8547
|
+
* @param params - The parameters for deleting the model.
|
|
8807
8548
|
* @return The response from the API.
|
|
8808
8549
|
*
|
|
8809
8550
|
* @example
|
|
8810
8551
|
* ```ts
|
|
8811
|
-
* const response = await ai.models.
|
|
8812
|
-
* model: 'gemini-2.0-flash',
|
|
8813
|
-
* contents: 'What is your name?'
|
|
8814
|
-
* });
|
|
8815
|
-
* console.log(response);
|
|
8552
|
+
* const response = await ai.models.delete({model: 'tuned-model-name'});
|
|
8816
8553
|
* ```
|
|
8817
8554
|
*/
|
|
8818
|
-
async
|
|
8819
|
-
var _a;
|
|
8555
|
+
async delete(params) {
|
|
8556
|
+
var _a, _b, _c, _d;
|
|
8557
|
+
let response;
|
|
8558
|
+
let path = '';
|
|
8559
|
+
let queryParams = {};
|
|
8560
|
+
if (this.apiClient.isVertexAI()) {
|
|
8561
|
+
const body = deleteModelParametersToVertex(this.apiClient, params);
|
|
8562
|
+
path = formatMap('{name}', body['_url']);
|
|
8563
|
+
queryParams = body['_query'];
|
|
8564
|
+
delete body['config'];
|
|
8565
|
+
delete body['_url'];
|
|
8566
|
+
delete body['_query'];
|
|
8567
|
+
response = this.apiClient
|
|
8568
|
+
.request({
|
|
8569
|
+
path: path,
|
|
8570
|
+
queryParams: queryParams,
|
|
8571
|
+
body: JSON.stringify(body),
|
|
8572
|
+
httpMethod: 'DELETE',
|
|
8573
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
8574
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
8575
|
+
})
|
|
8576
|
+
.then((httpResponse) => {
|
|
8577
|
+
return httpResponse.json();
|
|
8578
|
+
});
|
|
8579
|
+
return response.then(() => {
|
|
8580
|
+
const resp = deleteModelResponseFromVertex();
|
|
8581
|
+
const typedResp = new DeleteModelResponse();
|
|
8582
|
+
Object.assign(typedResp, resp);
|
|
8583
|
+
return typedResp;
|
|
8584
|
+
});
|
|
8585
|
+
}
|
|
8586
|
+
else {
|
|
8587
|
+
const body = deleteModelParametersToMldev(this.apiClient, params);
|
|
8588
|
+
path = formatMap('{name}', body['_url']);
|
|
8589
|
+
queryParams = body['_query'];
|
|
8590
|
+
delete body['config'];
|
|
8591
|
+
delete body['_url'];
|
|
8592
|
+
delete body['_query'];
|
|
8593
|
+
response = this.apiClient
|
|
8594
|
+
.request({
|
|
8595
|
+
path: path,
|
|
8596
|
+
queryParams: queryParams,
|
|
8597
|
+
body: JSON.stringify(body),
|
|
8598
|
+
httpMethod: 'DELETE',
|
|
8599
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
8600
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
8601
|
+
})
|
|
8602
|
+
.then((httpResponse) => {
|
|
8603
|
+
return httpResponse.json();
|
|
8604
|
+
});
|
|
8605
|
+
return response.then(() => {
|
|
8606
|
+
const resp = deleteModelResponseFromMldev();
|
|
8607
|
+
const typedResp = new DeleteModelResponse();
|
|
8608
|
+
Object.assign(typedResp, resp);
|
|
8609
|
+
return typedResp;
|
|
8610
|
+
});
|
|
8611
|
+
}
|
|
8612
|
+
}
|
|
8613
|
+
/**
|
|
8614
|
+
* Counts the number of tokens in the given contents. Multimodal input is
|
|
8615
|
+
* supported for Gemini models.
|
|
8616
|
+
*
|
|
8617
|
+
* @param params - The parameters for counting tokens.
|
|
8618
|
+
* @return The response from the API.
|
|
8619
|
+
*
|
|
8620
|
+
* @example
|
|
8621
|
+
* ```ts
|
|
8622
|
+
* const response = await ai.models.countTokens({
|
|
8623
|
+
* model: 'gemini-2.0-flash',
|
|
8624
|
+
* contents: 'The quick brown fox jumps over the lazy dog.'
|
|
8625
|
+
* });
|
|
8626
|
+
* console.log(response);
|
|
8627
|
+
* ```
|
|
8628
|
+
*/
|
|
8629
|
+
async countTokens(params) {
|
|
8630
|
+
var _a, _b, _c, _d;
|
|
8631
|
+
let response;
|
|
8632
|
+
let path = '';
|
|
8633
|
+
let queryParams = {};
|
|
8634
|
+
if (this.apiClient.isVertexAI()) {
|
|
8635
|
+
const body = countTokensParametersToVertex(this.apiClient, params);
|
|
8636
|
+
path = formatMap('{model}:countTokens', body['_url']);
|
|
8637
|
+
queryParams = body['_query'];
|
|
8638
|
+
delete body['config'];
|
|
8639
|
+
delete body['_url'];
|
|
8640
|
+
delete body['_query'];
|
|
8641
|
+
response = this.apiClient
|
|
8642
|
+
.request({
|
|
8643
|
+
path: path,
|
|
8644
|
+
queryParams: queryParams,
|
|
8645
|
+
body: JSON.stringify(body),
|
|
8646
|
+
httpMethod: 'POST',
|
|
8647
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
8648
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
8649
|
+
})
|
|
8650
|
+
.then((httpResponse) => {
|
|
8651
|
+
return httpResponse.json();
|
|
8652
|
+
});
|
|
8653
|
+
return response.then((apiResponse) => {
|
|
8654
|
+
const resp = countTokensResponseFromVertex(this.apiClient, apiResponse);
|
|
8655
|
+
const typedResp = new CountTokensResponse();
|
|
8656
|
+
Object.assign(typedResp, resp);
|
|
8657
|
+
return typedResp;
|
|
8658
|
+
});
|
|
8659
|
+
}
|
|
8660
|
+
else {
|
|
8661
|
+
const body = countTokensParametersToMldev(this.apiClient, params);
|
|
8662
|
+
path = formatMap('{model}:countTokens', body['_url']);
|
|
8663
|
+
queryParams = body['_query'];
|
|
8664
|
+
delete body['config'];
|
|
8665
|
+
delete body['_url'];
|
|
8666
|
+
delete body['_query'];
|
|
8667
|
+
response = this.apiClient
|
|
8668
|
+
.request({
|
|
8669
|
+
path: path,
|
|
8670
|
+
queryParams: queryParams,
|
|
8671
|
+
body: JSON.stringify(body),
|
|
8672
|
+
httpMethod: 'POST',
|
|
8673
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
8674
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
8675
|
+
})
|
|
8676
|
+
.then((httpResponse) => {
|
|
8677
|
+
return httpResponse.json();
|
|
8678
|
+
});
|
|
8679
|
+
return response.then((apiResponse) => {
|
|
8680
|
+
const resp = countTokensResponseFromMldev(this.apiClient, apiResponse);
|
|
8681
|
+
const typedResp = new CountTokensResponse();
|
|
8682
|
+
Object.assign(typedResp, resp);
|
|
8683
|
+
return typedResp;
|
|
8684
|
+
});
|
|
8685
|
+
}
|
|
8686
|
+
}
|
|
8687
|
+
/**
|
|
8688
|
+
* Given a list of contents, returns a corresponding TokensInfo containing
|
|
8689
|
+
* the list of tokens and list of token ids.
|
|
8690
|
+
*
|
|
8691
|
+
* This method is not supported by the Gemini Developer API.
|
|
8692
|
+
*
|
|
8693
|
+
* @param params - The parameters for computing tokens.
|
|
8694
|
+
* @return The response from the API.
|
|
8695
|
+
*
|
|
8696
|
+
* @example
|
|
8697
|
+
* ```ts
|
|
8698
|
+
* const response = await ai.models.computeTokens({
|
|
8699
|
+
* model: 'gemini-2.0-flash',
|
|
8700
|
+
* contents: 'What is your name?'
|
|
8701
|
+
* });
|
|
8702
|
+
* console.log(response);
|
|
8703
|
+
* ```
|
|
8704
|
+
*/
|
|
8705
|
+
async computeTokens(params) {
|
|
8706
|
+
var _a, _b;
|
|
8820
8707
|
let response;
|
|
8821
8708
|
let path = '';
|
|
8822
8709
|
let queryParams = {};
|
|
@@ -8834,6 +8721,7 @@ class Models extends BaseModule {
|
|
|
8834
8721
|
body: JSON.stringify(body),
|
|
8835
8722
|
httpMethod: 'POST',
|
|
8836
8723
|
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
8724
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
8837
8725
|
})
|
|
8838
8726
|
.then((httpResponse) => {
|
|
8839
8727
|
return httpResponse.json();
|
|
@@ -8873,7 +8761,7 @@ class Models extends BaseModule {
|
|
|
8873
8761
|
* ```
|
|
8874
8762
|
*/
|
|
8875
8763
|
async generateVideos(params) {
|
|
8876
|
-
var _a, _b;
|
|
8764
|
+
var _a, _b, _c, _d;
|
|
8877
8765
|
let response;
|
|
8878
8766
|
let path = '';
|
|
8879
8767
|
let queryParams = {};
|
|
@@ -8891,6 +8779,7 @@ class Models extends BaseModule {
|
|
|
8891
8779
|
body: JSON.stringify(body),
|
|
8892
8780
|
httpMethod: 'POST',
|
|
8893
8781
|
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
8782
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
8894
8783
|
})
|
|
8895
8784
|
.then((httpResponse) => {
|
|
8896
8785
|
return httpResponse.json();
|
|
@@ -8913,7 +8802,8 @@ class Models extends BaseModule {
|
|
|
8913
8802
|
queryParams: queryParams,
|
|
8914
8803
|
body: JSON.stringify(body),
|
|
8915
8804
|
httpMethod: 'POST',
|
|
8916
|
-
httpOptions: (
|
|
8805
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
8806
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
8917
8807
|
})
|
|
8918
8808
|
.then((httpResponse) => {
|
|
8919
8809
|
return httpResponse.json();
|
|
@@ -9010,14 +8900,13 @@ function generateVideosResponseFromMldev(apiClient, fromObject) {
|
|
|
9010
8900
|
'generatedSamples',
|
|
9011
8901
|
]);
|
|
9012
8902
|
if (fromGeneratedVideos != null) {
|
|
9013
|
-
|
|
9014
|
-
|
|
8903
|
+
let transformedList = fromGeneratedVideos;
|
|
8904
|
+
if (Array.isArray(transformedList)) {
|
|
8905
|
+
transformedList = transformedList.map((item) => {
|
|
9015
8906
|
return generatedVideoFromMldev(apiClient, item);
|
|
9016
|
-
})
|
|
9017
|
-
}
|
|
9018
|
-
else {
|
|
9019
|
-
setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos);
|
|
8907
|
+
});
|
|
9020
8908
|
}
|
|
8909
|
+
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
9021
8910
|
}
|
|
9022
8911
|
const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
|
|
9023
8912
|
'raiMediaFilteredCount',
|
|
@@ -9090,14 +8979,13 @@ function generateVideosResponseFromVertex(apiClient, fromObject) {
|
|
|
9090
8979
|
const toObject = {};
|
|
9091
8980
|
const fromGeneratedVideos = getValueByPath(fromObject, ['videos']);
|
|
9092
8981
|
if (fromGeneratedVideos != null) {
|
|
9093
|
-
|
|
9094
|
-
|
|
8982
|
+
let transformedList = fromGeneratedVideos;
|
|
8983
|
+
if (Array.isArray(transformedList)) {
|
|
8984
|
+
transformedList = transformedList.map((item) => {
|
|
9095
8985
|
return generatedVideoFromVertex(apiClient, item);
|
|
9096
|
-
})
|
|
9097
|
-
}
|
|
9098
|
-
else {
|
|
9099
|
-
setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos);
|
|
8986
|
+
});
|
|
9100
8987
|
}
|
|
8988
|
+
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
9101
8989
|
}
|
|
9102
8990
|
const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
|
|
9103
8991
|
'raiMediaFilteredCount',
|
|
@@ -9180,7 +9068,7 @@ class Operations extends BaseModule {
|
|
|
9180
9068
|
}
|
|
9181
9069
|
}
|
|
9182
9070
|
async getVideosOperationInternal(params) {
|
|
9183
|
-
var _a, _b;
|
|
9071
|
+
var _a, _b, _c, _d;
|
|
9184
9072
|
let response;
|
|
9185
9073
|
let path = '';
|
|
9186
9074
|
let queryParams = {};
|
|
@@ -9198,6 +9086,7 @@ class Operations extends BaseModule {
|
|
|
9198
9086
|
body: JSON.stringify(body),
|
|
9199
9087
|
httpMethod: 'GET',
|
|
9200
9088
|
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
9089
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
9201
9090
|
})
|
|
9202
9091
|
.then((httpResponse) => {
|
|
9203
9092
|
return httpResponse.json();
|
|
@@ -9220,7 +9109,8 @@ class Operations extends BaseModule {
|
|
|
9220
9109
|
queryParams: queryParams,
|
|
9221
9110
|
body: JSON.stringify(body),
|
|
9222
9111
|
httpMethod: 'GET',
|
|
9223
|
-
httpOptions: (
|
|
9112
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
9113
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
9224
9114
|
})
|
|
9225
9115
|
.then((httpResponse) => {
|
|
9226
9116
|
return httpResponse.json();
|
|
@@ -9232,7 +9122,7 @@ class Operations extends BaseModule {
|
|
|
9232
9122
|
}
|
|
9233
9123
|
}
|
|
9234
9124
|
async fetchPredictVideosOperationInternal(params) {
|
|
9235
|
-
var _a;
|
|
9125
|
+
var _a, _b;
|
|
9236
9126
|
let response;
|
|
9237
9127
|
let path = '';
|
|
9238
9128
|
let queryParams = {};
|
|
@@ -9250,6 +9140,7 @@ class Operations extends BaseModule {
|
|
|
9250
9140
|
body: JSON.stringify(body),
|
|
9251
9141
|
httpMethod: 'POST',
|
|
9252
9142
|
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
9143
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
9253
9144
|
})
|
|
9254
9145
|
.then((httpResponse) => {
|
|
9255
9146
|
return httpResponse.json();
|
|
@@ -9265,6 +9156,736 @@ class Operations extends BaseModule {
|
|
|
9265
9156
|
}
|
|
9266
9157
|
}
|
|
9267
9158
|
|
|
9159
|
+
/**
|
|
9160
|
+
* @license
|
|
9161
|
+
* Copyright 2025 Google LLC
|
|
9162
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
9163
|
+
*/
|
|
9164
|
+
function getTuningJobParametersToMldev(apiClient, fromObject) {
|
|
9165
|
+
const toObject = {};
|
|
9166
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
9167
|
+
if (fromName != null) {
|
|
9168
|
+
setValueByPath(toObject, ['_url', 'name'], fromName);
|
|
9169
|
+
}
|
|
9170
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
9171
|
+
if (fromConfig != null) {
|
|
9172
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
9173
|
+
}
|
|
9174
|
+
return toObject;
|
|
9175
|
+
}
|
|
9176
|
+
function listTuningJobsConfigToMldev(apiClient, fromObject, parentObject) {
|
|
9177
|
+
const toObject = {};
|
|
9178
|
+
const fromPageSize = getValueByPath(fromObject, ['pageSize']);
|
|
9179
|
+
if (parentObject !== undefined && fromPageSize != null) {
|
|
9180
|
+
setValueByPath(parentObject, ['_query', 'pageSize'], fromPageSize);
|
|
9181
|
+
}
|
|
9182
|
+
const fromPageToken = getValueByPath(fromObject, ['pageToken']);
|
|
9183
|
+
if (parentObject !== undefined && fromPageToken != null) {
|
|
9184
|
+
setValueByPath(parentObject, ['_query', 'pageToken'], fromPageToken);
|
|
9185
|
+
}
|
|
9186
|
+
const fromFilter = getValueByPath(fromObject, ['filter']);
|
|
9187
|
+
if (parentObject !== undefined && fromFilter != null) {
|
|
9188
|
+
setValueByPath(parentObject, ['_query', 'filter'], fromFilter);
|
|
9189
|
+
}
|
|
9190
|
+
return toObject;
|
|
9191
|
+
}
|
|
9192
|
+
function listTuningJobsParametersToMldev(apiClient, fromObject) {
|
|
9193
|
+
const toObject = {};
|
|
9194
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
9195
|
+
if (fromConfig != null) {
|
|
9196
|
+
setValueByPath(toObject, ['config'], listTuningJobsConfigToMldev(apiClient, fromConfig, toObject));
|
|
9197
|
+
}
|
|
9198
|
+
return toObject;
|
|
9199
|
+
}
|
|
9200
|
+
function tuningExampleToMldev(apiClient, fromObject) {
|
|
9201
|
+
const toObject = {};
|
|
9202
|
+
const fromTextInput = getValueByPath(fromObject, ['textInput']);
|
|
9203
|
+
if (fromTextInput != null) {
|
|
9204
|
+
setValueByPath(toObject, ['textInput'], fromTextInput);
|
|
9205
|
+
}
|
|
9206
|
+
const fromOutput = getValueByPath(fromObject, ['output']);
|
|
9207
|
+
if (fromOutput != null) {
|
|
9208
|
+
setValueByPath(toObject, ['output'], fromOutput);
|
|
9209
|
+
}
|
|
9210
|
+
return toObject;
|
|
9211
|
+
}
|
|
9212
|
+
function tuningDatasetToMldev(apiClient, fromObject) {
|
|
9213
|
+
const toObject = {};
|
|
9214
|
+
if (getValueByPath(fromObject, ['gcsUri']) !== undefined) {
|
|
9215
|
+
throw new Error('gcsUri parameter is not supported in Gemini API.');
|
|
9216
|
+
}
|
|
9217
|
+
const fromExamples = getValueByPath(fromObject, ['examples']);
|
|
9218
|
+
if (fromExamples != null) {
|
|
9219
|
+
let transformedList = fromExamples;
|
|
9220
|
+
if (Array.isArray(transformedList)) {
|
|
9221
|
+
transformedList = transformedList.map((item) => {
|
|
9222
|
+
return tuningExampleToMldev(apiClient, item);
|
|
9223
|
+
});
|
|
9224
|
+
}
|
|
9225
|
+
setValueByPath(toObject, ['examples', 'examples'], transformedList);
|
|
9226
|
+
}
|
|
9227
|
+
return toObject;
|
|
9228
|
+
}
|
|
9229
|
+
function createTuningJobConfigToMldev(apiClient, fromObject, parentObject) {
|
|
9230
|
+
const toObject = {};
|
|
9231
|
+
if (getValueByPath(fromObject, ['validationDataset']) !== undefined) {
|
|
9232
|
+
throw new Error('validationDataset parameter is not supported in Gemini API.');
|
|
9233
|
+
}
|
|
9234
|
+
const fromTunedModelDisplayName = getValueByPath(fromObject, [
|
|
9235
|
+
'tunedModelDisplayName',
|
|
9236
|
+
]);
|
|
9237
|
+
if (parentObject !== undefined && fromTunedModelDisplayName != null) {
|
|
9238
|
+
setValueByPath(parentObject, ['displayName'], fromTunedModelDisplayName);
|
|
9239
|
+
}
|
|
9240
|
+
if (getValueByPath(fromObject, ['description']) !== undefined) {
|
|
9241
|
+
throw new Error('description parameter is not supported in Gemini API.');
|
|
9242
|
+
}
|
|
9243
|
+
const fromEpochCount = getValueByPath(fromObject, ['epochCount']);
|
|
9244
|
+
if (parentObject !== undefined && fromEpochCount != null) {
|
|
9245
|
+
setValueByPath(parentObject, ['tuningTask', 'hyperparameters', 'epochCount'], fromEpochCount);
|
|
9246
|
+
}
|
|
9247
|
+
const fromLearningRateMultiplier = getValueByPath(fromObject, [
|
|
9248
|
+
'learningRateMultiplier',
|
|
9249
|
+
]);
|
|
9250
|
+
if (fromLearningRateMultiplier != null) {
|
|
9251
|
+
setValueByPath(toObject, ['tuningTask', 'hyperparameters', 'learningRateMultiplier'], fromLearningRateMultiplier);
|
|
9252
|
+
}
|
|
9253
|
+
if (getValueByPath(fromObject, ['adapterSize']) !== undefined) {
|
|
9254
|
+
throw new Error('adapterSize parameter is not supported in Gemini API.');
|
|
9255
|
+
}
|
|
9256
|
+
const fromBatchSize = getValueByPath(fromObject, ['batchSize']);
|
|
9257
|
+
if (parentObject !== undefined && fromBatchSize != null) {
|
|
9258
|
+
setValueByPath(parentObject, ['tuningTask', 'hyperparameters', 'batchSize'], fromBatchSize);
|
|
9259
|
+
}
|
|
9260
|
+
const fromLearningRate = getValueByPath(fromObject, ['learningRate']);
|
|
9261
|
+
if (parentObject !== undefined && fromLearningRate != null) {
|
|
9262
|
+
setValueByPath(parentObject, ['tuningTask', 'hyperparameters', 'learningRate'], fromLearningRate);
|
|
9263
|
+
}
|
|
9264
|
+
return toObject;
|
|
9265
|
+
}
|
|
9266
|
+
function createTuningJobParametersToMldev(apiClient, fromObject) {
|
|
9267
|
+
const toObject = {};
|
|
9268
|
+
const fromBaseModel = getValueByPath(fromObject, ['baseModel']);
|
|
9269
|
+
if (fromBaseModel != null) {
|
|
9270
|
+
setValueByPath(toObject, ['baseModel'], fromBaseModel);
|
|
9271
|
+
}
|
|
9272
|
+
const fromTrainingDataset = getValueByPath(fromObject, [
|
|
9273
|
+
'trainingDataset',
|
|
9274
|
+
]);
|
|
9275
|
+
if (fromTrainingDataset != null) {
|
|
9276
|
+
setValueByPath(toObject, ['tuningTask', 'trainingData'], tuningDatasetToMldev(apiClient, fromTrainingDataset));
|
|
9277
|
+
}
|
|
9278
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
9279
|
+
if (fromConfig != null) {
|
|
9280
|
+
setValueByPath(toObject, ['config'], createTuningJobConfigToMldev(apiClient, fromConfig, toObject));
|
|
9281
|
+
}
|
|
9282
|
+
return toObject;
|
|
9283
|
+
}
|
|
9284
|
+
function getTuningJobParametersToVertex(apiClient, fromObject) {
|
|
9285
|
+
const toObject = {};
|
|
9286
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
9287
|
+
if (fromName != null) {
|
|
9288
|
+
setValueByPath(toObject, ['_url', 'name'], fromName);
|
|
9289
|
+
}
|
|
9290
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
9291
|
+
if (fromConfig != null) {
|
|
9292
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
9293
|
+
}
|
|
9294
|
+
return toObject;
|
|
9295
|
+
}
|
|
9296
|
+
function listTuningJobsConfigToVertex(apiClient, fromObject, parentObject) {
|
|
9297
|
+
const toObject = {};
|
|
9298
|
+
const fromPageSize = getValueByPath(fromObject, ['pageSize']);
|
|
9299
|
+
if (parentObject !== undefined && fromPageSize != null) {
|
|
9300
|
+
setValueByPath(parentObject, ['_query', 'pageSize'], fromPageSize);
|
|
9301
|
+
}
|
|
9302
|
+
const fromPageToken = getValueByPath(fromObject, ['pageToken']);
|
|
9303
|
+
if (parentObject !== undefined && fromPageToken != null) {
|
|
9304
|
+
setValueByPath(parentObject, ['_query', 'pageToken'], fromPageToken);
|
|
9305
|
+
}
|
|
9306
|
+
const fromFilter = getValueByPath(fromObject, ['filter']);
|
|
9307
|
+
if (parentObject !== undefined && fromFilter != null) {
|
|
9308
|
+
setValueByPath(parentObject, ['_query', 'filter'], fromFilter);
|
|
9309
|
+
}
|
|
9310
|
+
return toObject;
|
|
9311
|
+
}
|
|
9312
|
+
function listTuningJobsParametersToVertex(apiClient, fromObject) {
|
|
9313
|
+
const toObject = {};
|
|
9314
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
9315
|
+
if (fromConfig != null) {
|
|
9316
|
+
setValueByPath(toObject, ['config'], listTuningJobsConfigToVertex(apiClient, fromConfig, toObject));
|
|
9317
|
+
}
|
|
9318
|
+
return toObject;
|
|
9319
|
+
}
|
|
9320
|
+
function tuningDatasetToVertex(apiClient, fromObject, parentObject) {
|
|
9321
|
+
const toObject = {};
|
|
9322
|
+
const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
|
|
9323
|
+
if (parentObject !== undefined && fromGcsUri != null) {
|
|
9324
|
+
setValueByPath(parentObject, ['supervisedTuningSpec', 'trainingDatasetUri'], fromGcsUri);
|
|
9325
|
+
}
|
|
9326
|
+
if (getValueByPath(fromObject, ['examples']) !== undefined) {
|
|
9327
|
+
throw new Error('examples parameter is not supported in Vertex AI.');
|
|
9328
|
+
}
|
|
9329
|
+
return toObject;
|
|
9330
|
+
}
|
|
9331
|
+
function tuningValidationDatasetToVertex(apiClient, fromObject) {
|
|
9332
|
+
const toObject = {};
|
|
9333
|
+
const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
|
|
9334
|
+
if (fromGcsUri != null) {
|
|
9335
|
+
setValueByPath(toObject, ['validationDatasetUri'], fromGcsUri);
|
|
9336
|
+
}
|
|
9337
|
+
return toObject;
|
|
9338
|
+
}
|
|
9339
|
+
function createTuningJobConfigToVertex(apiClient, fromObject, parentObject) {
|
|
9340
|
+
const toObject = {};
|
|
9341
|
+
const fromValidationDataset = getValueByPath(fromObject, [
|
|
9342
|
+
'validationDataset',
|
|
9343
|
+
]);
|
|
9344
|
+
if (parentObject !== undefined && fromValidationDataset != null) {
|
|
9345
|
+
setValueByPath(parentObject, ['supervisedTuningSpec'], tuningValidationDatasetToVertex(apiClient, fromValidationDataset));
|
|
9346
|
+
}
|
|
9347
|
+
const fromTunedModelDisplayName = getValueByPath(fromObject, [
|
|
9348
|
+
'tunedModelDisplayName',
|
|
9349
|
+
]);
|
|
9350
|
+
if (parentObject !== undefined && fromTunedModelDisplayName != null) {
|
|
9351
|
+
setValueByPath(parentObject, ['tunedModelDisplayName'], fromTunedModelDisplayName);
|
|
9352
|
+
}
|
|
9353
|
+
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
9354
|
+
if (parentObject !== undefined && fromDescription != null) {
|
|
9355
|
+
setValueByPath(parentObject, ['description'], fromDescription);
|
|
9356
|
+
}
|
|
9357
|
+
const fromEpochCount = getValueByPath(fromObject, ['epochCount']);
|
|
9358
|
+
if (parentObject !== undefined && fromEpochCount != null) {
|
|
9359
|
+
setValueByPath(parentObject, ['supervisedTuningSpec', 'hyperParameters', 'epochCount'], fromEpochCount);
|
|
9360
|
+
}
|
|
9361
|
+
const fromLearningRateMultiplier = getValueByPath(fromObject, [
|
|
9362
|
+
'learningRateMultiplier',
|
|
9363
|
+
]);
|
|
9364
|
+
if (parentObject !== undefined && fromLearningRateMultiplier != null) {
|
|
9365
|
+
setValueByPath(parentObject, ['supervisedTuningSpec', 'hyperParameters', 'learningRateMultiplier'], fromLearningRateMultiplier);
|
|
9366
|
+
}
|
|
9367
|
+
const fromAdapterSize = getValueByPath(fromObject, ['adapterSize']);
|
|
9368
|
+
if (parentObject !== undefined && fromAdapterSize != null) {
|
|
9369
|
+
setValueByPath(parentObject, ['supervisedTuningSpec', 'hyperParameters', 'adapterSize'], fromAdapterSize);
|
|
9370
|
+
}
|
|
9371
|
+
if (getValueByPath(fromObject, ['batchSize']) !== undefined) {
|
|
9372
|
+
throw new Error('batchSize parameter is not supported in Vertex AI.');
|
|
9373
|
+
}
|
|
9374
|
+
if (getValueByPath(fromObject, ['learningRate']) !== undefined) {
|
|
9375
|
+
throw new Error('learningRate parameter is not supported in Vertex AI.');
|
|
9376
|
+
}
|
|
9377
|
+
return toObject;
|
|
9378
|
+
}
|
|
9379
|
+
function createTuningJobParametersToVertex(apiClient, fromObject) {
|
|
9380
|
+
const toObject = {};
|
|
9381
|
+
const fromBaseModel = getValueByPath(fromObject, ['baseModel']);
|
|
9382
|
+
if (fromBaseModel != null) {
|
|
9383
|
+
setValueByPath(toObject, ['baseModel'], fromBaseModel);
|
|
9384
|
+
}
|
|
9385
|
+
const fromTrainingDataset = getValueByPath(fromObject, [
|
|
9386
|
+
'trainingDataset',
|
|
9387
|
+
]);
|
|
9388
|
+
if (fromTrainingDataset != null) {
|
|
9389
|
+
setValueByPath(toObject, ['supervisedTuningSpec', 'trainingDatasetUri'], tuningDatasetToVertex(apiClient, fromTrainingDataset, toObject));
|
|
9390
|
+
}
|
|
9391
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
9392
|
+
if (fromConfig != null) {
|
|
9393
|
+
setValueByPath(toObject, ['config'], createTuningJobConfigToVertex(apiClient, fromConfig, toObject));
|
|
9394
|
+
}
|
|
9395
|
+
return toObject;
|
|
9396
|
+
}
|
|
9397
|
+
function tunedModelFromMldev(apiClient, fromObject) {
|
|
9398
|
+
const toObject = {};
|
|
9399
|
+
const fromModel = getValueByPath(fromObject, ['name']);
|
|
9400
|
+
if (fromModel != null) {
|
|
9401
|
+
setValueByPath(toObject, ['model'], fromModel);
|
|
9402
|
+
}
|
|
9403
|
+
const fromEndpoint = getValueByPath(fromObject, ['name']);
|
|
9404
|
+
if (fromEndpoint != null) {
|
|
9405
|
+
setValueByPath(toObject, ['endpoint'], fromEndpoint);
|
|
9406
|
+
}
|
|
9407
|
+
return toObject;
|
|
9408
|
+
}
|
|
9409
|
+
function tuningJobFromMldev(apiClient, fromObject) {
|
|
9410
|
+
const toObject = {};
|
|
9411
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
9412
|
+
if (fromName != null) {
|
|
9413
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
9414
|
+
}
|
|
9415
|
+
const fromState = getValueByPath(fromObject, ['state']);
|
|
9416
|
+
if (fromState != null) {
|
|
9417
|
+
setValueByPath(toObject, ['state'], tTuningJobStatus(apiClient, fromState));
|
|
9418
|
+
}
|
|
9419
|
+
const fromCreateTime = getValueByPath(fromObject, ['createTime']);
|
|
9420
|
+
if (fromCreateTime != null) {
|
|
9421
|
+
setValueByPath(toObject, ['createTime'], fromCreateTime);
|
|
9422
|
+
}
|
|
9423
|
+
const fromStartTime = getValueByPath(fromObject, [
|
|
9424
|
+
'tuningTask',
|
|
9425
|
+
'startTime',
|
|
9426
|
+
]);
|
|
9427
|
+
if (fromStartTime != null) {
|
|
9428
|
+
setValueByPath(toObject, ['startTime'], fromStartTime);
|
|
9429
|
+
}
|
|
9430
|
+
const fromEndTime = getValueByPath(fromObject, [
|
|
9431
|
+
'tuningTask',
|
|
9432
|
+
'completeTime',
|
|
9433
|
+
]);
|
|
9434
|
+
if (fromEndTime != null) {
|
|
9435
|
+
setValueByPath(toObject, ['endTime'], fromEndTime);
|
|
9436
|
+
}
|
|
9437
|
+
const fromUpdateTime = getValueByPath(fromObject, ['updateTime']);
|
|
9438
|
+
if (fromUpdateTime != null) {
|
|
9439
|
+
setValueByPath(toObject, ['updateTime'], fromUpdateTime);
|
|
9440
|
+
}
|
|
9441
|
+
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
9442
|
+
if (fromDescription != null) {
|
|
9443
|
+
setValueByPath(toObject, ['description'], fromDescription);
|
|
9444
|
+
}
|
|
9445
|
+
const fromBaseModel = getValueByPath(fromObject, ['baseModel']);
|
|
9446
|
+
if (fromBaseModel != null) {
|
|
9447
|
+
setValueByPath(toObject, ['baseModel'], fromBaseModel);
|
|
9448
|
+
}
|
|
9449
|
+
const fromTunedModel = getValueByPath(fromObject, ['_self']);
|
|
9450
|
+
if (fromTunedModel != null) {
|
|
9451
|
+
setValueByPath(toObject, ['tunedModel'], tunedModelFromMldev(apiClient, fromTunedModel));
|
|
9452
|
+
}
|
|
9453
|
+
const fromDistillationSpec = getValueByPath(fromObject, [
|
|
9454
|
+
'distillationSpec',
|
|
9455
|
+
]);
|
|
9456
|
+
if (fromDistillationSpec != null) {
|
|
9457
|
+
setValueByPath(toObject, ['distillationSpec'], fromDistillationSpec);
|
|
9458
|
+
}
|
|
9459
|
+
const fromExperiment = getValueByPath(fromObject, ['experiment']);
|
|
9460
|
+
if (fromExperiment != null) {
|
|
9461
|
+
setValueByPath(toObject, ['experiment'], fromExperiment);
|
|
9462
|
+
}
|
|
9463
|
+
const fromLabels = getValueByPath(fromObject, ['labels']);
|
|
9464
|
+
if (fromLabels != null) {
|
|
9465
|
+
setValueByPath(toObject, ['labels'], fromLabels);
|
|
9466
|
+
}
|
|
9467
|
+
const fromPipelineJob = getValueByPath(fromObject, ['pipelineJob']);
|
|
9468
|
+
if (fromPipelineJob != null) {
|
|
9469
|
+
setValueByPath(toObject, ['pipelineJob'], fromPipelineJob);
|
|
9470
|
+
}
|
|
9471
|
+
const fromTunedModelDisplayName = getValueByPath(fromObject, [
|
|
9472
|
+
'tunedModelDisplayName',
|
|
9473
|
+
]);
|
|
9474
|
+
if (fromTunedModelDisplayName != null) {
|
|
9475
|
+
setValueByPath(toObject, ['tunedModelDisplayName'], fromTunedModelDisplayName);
|
|
9476
|
+
}
|
|
9477
|
+
return toObject;
|
|
9478
|
+
}
|
|
9479
|
+
function listTuningJobsResponseFromMldev(apiClient, fromObject) {
|
|
9480
|
+
const toObject = {};
|
|
9481
|
+
const fromNextPageToken = getValueByPath(fromObject, [
|
|
9482
|
+
'nextPageToken',
|
|
9483
|
+
]);
|
|
9484
|
+
if (fromNextPageToken != null) {
|
|
9485
|
+
setValueByPath(toObject, ['nextPageToken'], fromNextPageToken);
|
|
9486
|
+
}
|
|
9487
|
+
const fromTuningJobs = getValueByPath(fromObject, ['tunedModels']);
|
|
9488
|
+
if (fromTuningJobs != null) {
|
|
9489
|
+
let transformedList = fromTuningJobs;
|
|
9490
|
+
if (Array.isArray(transformedList)) {
|
|
9491
|
+
transformedList = transformedList.map((item) => {
|
|
9492
|
+
return tuningJobFromMldev(apiClient, item);
|
|
9493
|
+
});
|
|
9494
|
+
}
|
|
9495
|
+
setValueByPath(toObject, ['tuningJobs'], transformedList);
|
|
9496
|
+
}
|
|
9497
|
+
return toObject;
|
|
9498
|
+
}
|
|
9499
|
+
function operationFromMldev(apiClient, fromObject) {
|
|
9500
|
+
const toObject = {};
|
|
9501
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
9502
|
+
if (fromName != null) {
|
|
9503
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
9504
|
+
}
|
|
9505
|
+
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
9506
|
+
if (fromMetadata != null) {
|
|
9507
|
+
setValueByPath(toObject, ['metadata'], fromMetadata);
|
|
9508
|
+
}
|
|
9509
|
+
const fromDone = getValueByPath(fromObject, ['done']);
|
|
9510
|
+
if (fromDone != null) {
|
|
9511
|
+
setValueByPath(toObject, ['done'], fromDone);
|
|
9512
|
+
}
|
|
9513
|
+
const fromError = getValueByPath(fromObject, ['error']);
|
|
9514
|
+
if (fromError != null) {
|
|
9515
|
+
setValueByPath(toObject, ['error'], fromError);
|
|
9516
|
+
}
|
|
9517
|
+
return toObject;
|
|
9518
|
+
}
|
|
9519
|
+
function tunedModelFromVertex(apiClient, fromObject) {
|
|
9520
|
+
const toObject = {};
|
|
9521
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
9522
|
+
if (fromModel != null) {
|
|
9523
|
+
setValueByPath(toObject, ['model'], fromModel);
|
|
9524
|
+
}
|
|
9525
|
+
const fromEndpoint = getValueByPath(fromObject, ['endpoint']);
|
|
9526
|
+
if (fromEndpoint != null) {
|
|
9527
|
+
setValueByPath(toObject, ['endpoint'], fromEndpoint);
|
|
9528
|
+
}
|
|
9529
|
+
return toObject;
|
|
9530
|
+
}
|
|
9531
|
+
function tuningJobFromVertex(apiClient, fromObject) {
|
|
9532
|
+
const toObject = {};
|
|
9533
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
9534
|
+
if (fromName != null) {
|
|
9535
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
9536
|
+
}
|
|
9537
|
+
const fromState = getValueByPath(fromObject, ['state']);
|
|
9538
|
+
if (fromState != null) {
|
|
9539
|
+
setValueByPath(toObject, ['state'], tTuningJobStatus(apiClient, fromState));
|
|
9540
|
+
}
|
|
9541
|
+
const fromCreateTime = getValueByPath(fromObject, ['createTime']);
|
|
9542
|
+
if (fromCreateTime != null) {
|
|
9543
|
+
setValueByPath(toObject, ['createTime'], fromCreateTime);
|
|
9544
|
+
}
|
|
9545
|
+
const fromStartTime = getValueByPath(fromObject, ['startTime']);
|
|
9546
|
+
if (fromStartTime != null) {
|
|
9547
|
+
setValueByPath(toObject, ['startTime'], fromStartTime);
|
|
9548
|
+
}
|
|
9549
|
+
const fromEndTime = getValueByPath(fromObject, ['endTime']);
|
|
9550
|
+
if (fromEndTime != null) {
|
|
9551
|
+
setValueByPath(toObject, ['endTime'], fromEndTime);
|
|
9552
|
+
}
|
|
9553
|
+
const fromUpdateTime = getValueByPath(fromObject, ['updateTime']);
|
|
9554
|
+
if (fromUpdateTime != null) {
|
|
9555
|
+
setValueByPath(toObject, ['updateTime'], fromUpdateTime);
|
|
9556
|
+
}
|
|
9557
|
+
const fromError = getValueByPath(fromObject, ['error']);
|
|
9558
|
+
if (fromError != null) {
|
|
9559
|
+
setValueByPath(toObject, ['error'], fromError);
|
|
9560
|
+
}
|
|
9561
|
+
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
9562
|
+
if (fromDescription != null) {
|
|
9563
|
+
setValueByPath(toObject, ['description'], fromDescription);
|
|
9564
|
+
}
|
|
9565
|
+
const fromBaseModel = getValueByPath(fromObject, ['baseModel']);
|
|
9566
|
+
if (fromBaseModel != null) {
|
|
9567
|
+
setValueByPath(toObject, ['baseModel'], fromBaseModel);
|
|
9568
|
+
}
|
|
9569
|
+
const fromTunedModel = getValueByPath(fromObject, ['tunedModel']);
|
|
9570
|
+
if (fromTunedModel != null) {
|
|
9571
|
+
setValueByPath(toObject, ['tunedModel'], tunedModelFromVertex(apiClient, fromTunedModel));
|
|
9572
|
+
}
|
|
9573
|
+
const fromSupervisedTuningSpec = getValueByPath(fromObject, [
|
|
9574
|
+
'supervisedTuningSpec',
|
|
9575
|
+
]);
|
|
9576
|
+
if (fromSupervisedTuningSpec != null) {
|
|
9577
|
+
setValueByPath(toObject, ['supervisedTuningSpec'], fromSupervisedTuningSpec);
|
|
9578
|
+
}
|
|
9579
|
+
const fromTuningDataStats = getValueByPath(fromObject, [
|
|
9580
|
+
'tuningDataStats',
|
|
9581
|
+
]);
|
|
9582
|
+
if (fromTuningDataStats != null) {
|
|
9583
|
+
setValueByPath(toObject, ['tuningDataStats'], fromTuningDataStats);
|
|
9584
|
+
}
|
|
9585
|
+
const fromEncryptionSpec = getValueByPath(fromObject, [
|
|
9586
|
+
'encryptionSpec',
|
|
9587
|
+
]);
|
|
9588
|
+
if (fromEncryptionSpec != null) {
|
|
9589
|
+
setValueByPath(toObject, ['encryptionSpec'], fromEncryptionSpec);
|
|
9590
|
+
}
|
|
9591
|
+
const fromPartnerModelTuningSpec = getValueByPath(fromObject, [
|
|
9592
|
+
'partnerModelTuningSpec',
|
|
9593
|
+
]);
|
|
9594
|
+
if (fromPartnerModelTuningSpec != null) {
|
|
9595
|
+
setValueByPath(toObject, ['partnerModelTuningSpec'], fromPartnerModelTuningSpec);
|
|
9596
|
+
}
|
|
9597
|
+
const fromDistillationSpec = getValueByPath(fromObject, [
|
|
9598
|
+
'distillationSpec',
|
|
9599
|
+
]);
|
|
9600
|
+
if (fromDistillationSpec != null) {
|
|
9601
|
+
setValueByPath(toObject, ['distillationSpec'], fromDistillationSpec);
|
|
9602
|
+
}
|
|
9603
|
+
const fromExperiment = getValueByPath(fromObject, ['experiment']);
|
|
9604
|
+
if (fromExperiment != null) {
|
|
9605
|
+
setValueByPath(toObject, ['experiment'], fromExperiment);
|
|
9606
|
+
}
|
|
9607
|
+
const fromLabels = getValueByPath(fromObject, ['labels']);
|
|
9608
|
+
if (fromLabels != null) {
|
|
9609
|
+
setValueByPath(toObject, ['labels'], fromLabels);
|
|
9610
|
+
}
|
|
9611
|
+
const fromPipelineJob = getValueByPath(fromObject, ['pipelineJob']);
|
|
9612
|
+
if (fromPipelineJob != null) {
|
|
9613
|
+
setValueByPath(toObject, ['pipelineJob'], fromPipelineJob);
|
|
9614
|
+
}
|
|
9615
|
+
const fromTunedModelDisplayName = getValueByPath(fromObject, [
|
|
9616
|
+
'tunedModelDisplayName',
|
|
9617
|
+
]);
|
|
9618
|
+
if (fromTunedModelDisplayName != null) {
|
|
9619
|
+
setValueByPath(toObject, ['tunedModelDisplayName'], fromTunedModelDisplayName);
|
|
9620
|
+
}
|
|
9621
|
+
return toObject;
|
|
9622
|
+
}
|
|
9623
|
+
function listTuningJobsResponseFromVertex(apiClient, fromObject) {
|
|
9624
|
+
const toObject = {};
|
|
9625
|
+
const fromNextPageToken = getValueByPath(fromObject, [
|
|
9626
|
+
'nextPageToken',
|
|
9627
|
+
]);
|
|
9628
|
+
if (fromNextPageToken != null) {
|
|
9629
|
+
setValueByPath(toObject, ['nextPageToken'], fromNextPageToken);
|
|
9630
|
+
}
|
|
9631
|
+
const fromTuningJobs = getValueByPath(fromObject, ['tuningJobs']);
|
|
9632
|
+
if (fromTuningJobs != null) {
|
|
9633
|
+
let transformedList = fromTuningJobs;
|
|
9634
|
+
if (Array.isArray(transformedList)) {
|
|
9635
|
+
transformedList = transformedList.map((item) => {
|
|
9636
|
+
return tuningJobFromVertex(apiClient, item);
|
|
9637
|
+
});
|
|
9638
|
+
}
|
|
9639
|
+
setValueByPath(toObject, ['tuningJobs'], transformedList);
|
|
9640
|
+
}
|
|
9641
|
+
return toObject;
|
|
9642
|
+
}
|
|
9643
|
+
|
|
9644
|
+
/**
|
|
9645
|
+
* @license
|
|
9646
|
+
* Copyright 2025 Google LLC
|
|
9647
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
9648
|
+
*/
|
|
9649
|
+
class Tunings extends BaseModule {
|
|
9650
|
+
constructor(apiClient) {
|
|
9651
|
+
super();
|
|
9652
|
+
this.apiClient = apiClient;
|
|
9653
|
+
/**
|
|
9654
|
+
* Gets a TuningJob.
|
|
9655
|
+
*
|
|
9656
|
+
* @param name - The resource name of the tuning job.
|
|
9657
|
+
* @return - A TuningJob object.
|
|
9658
|
+
*
|
|
9659
|
+
* @experimental - The SDK's tuning implementation is experimental, and may
|
|
9660
|
+
* change in future versions.
|
|
9661
|
+
*/
|
|
9662
|
+
this.get = async (params) => {
|
|
9663
|
+
return await this.getInternal(params);
|
|
9664
|
+
};
|
|
9665
|
+
/**
|
|
9666
|
+
* Lists tuning jobs.
|
|
9667
|
+
*
|
|
9668
|
+
* @param config - The configuration for the list request.
|
|
9669
|
+
* @return - A list of tuning jobs.
|
|
9670
|
+
*
|
|
9671
|
+
* @experimental - The SDK's tuning implementation is experimental, and may
|
|
9672
|
+
* change in future versions.
|
|
9673
|
+
*/
|
|
9674
|
+
this.list = async (params = {}) => {
|
|
9675
|
+
return new Pager(PagedItem.PAGED_ITEM_TUNING_JOBS, (x) => this.listInternal(x), await this.listInternal(params), params);
|
|
9676
|
+
};
|
|
9677
|
+
/**
|
|
9678
|
+
* Creates a supervised fine-tuning job.
|
|
9679
|
+
*
|
|
9680
|
+
* @param params - The parameters for the tuning job.
|
|
9681
|
+
* @return - A TuningJob operation.
|
|
9682
|
+
*
|
|
9683
|
+
* @experimental - The SDK's tuning implementation is experimental, and may
|
|
9684
|
+
* change in future versions.
|
|
9685
|
+
*/
|
|
9686
|
+
this.tune = async (params) => {
|
|
9687
|
+
if (this.apiClient.isVertexAI()) {
|
|
9688
|
+
return await this.tuneInternal(params);
|
|
9689
|
+
}
|
|
9690
|
+
else {
|
|
9691
|
+
const operation = await this.tuneMldevInternal(params);
|
|
9692
|
+
let tunedModelName = '';
|
|
9693
|
+
if (operation['metadata'] !== undefined &&
|
|
9694
|
+
operation['metadata']['tunedModel'] !== undefined) {
|
|
9695
|
+
tunedModelName = operation['metadata']['tunedModel'];
|
|
9696
|
+
}
|
|
9697
|
+
else if (operation['name'] !== undefined &&
|
|
9698
|
+
operation['name'].includes('/operations/')) {
|
|
9699
|
+
tunedModelName = operation['name'].split('/operations/')[0];
|
|
9700
|
+
}
|
|
9701
|
+
const tuningJob = {
|
|
9702
|
+
name: tunedModelName,
|
|
9703
|
+
state: JobState.JOB_STATE_QUEUED,
|
|
9704
|
+
};
|
|
9705
|
+
return tuningJob;
|
|
9706
|
+
}
|
|
9707
|
+
};
|
|
9708
|
+
}
|
|
9709
|
+
async getInternal(params) {
|
|
9710
|
+
var _a, _b, _c, _d;
|
|
9711
|
+
let response;
|
|
9712
|
+
let path = '';
|
|
9713
|
+
let queryParams = {};
|
|
9714
|
+
if (this.apiClient.isVertexAI()) {
|
|
9715
|
+
const body = getTuningJobParametersToVertex(this.apiClient, params);
|
|
9716
|
+
path = formatMap('{name}', body['_url']);
|
|
9717
|
+
queryParams = body['_query'];
|
|
9718
|
+
delete body['config'];
|
|
9719
|
+
delete body['_url'];
|
|
9720
|
+
delete body['_query'];
|
|
9721
|
+
response = this.apiClient
|
|
9722
|
+
.request({
|
|
9723
|
+
path: path,
|
|
9724
|
+
queryParams: queryParams,
|
|
9725
|
+
body: JSON.stringify(body),
|
|
9726
|
+
httpMethod: 'GET',
|
|
9727
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
9728
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
9729
|
+
})
|
|
9730
|
+
.then((httpResponse) => {
|
|
9731
|
+
return httpResponse.json();
|
|
9732
|
+
});
|
|
9733
|
+
return response.then((apiResponse) => {
|
|
9734
|
+
const resp = tuningJobFromVertex(this.apiClient, apiResponse);
|
|
9735
|
+
return resp;
|
|
9736
|
+
});
|
|
9737
|
+
}
|
|
9738
|
+
else {
|
|
9739
|
+
const body = getTuningJobParametersToMldev(this.apiClient, params);
|
|
9740
|
+
path = formatMap('{name}', body['_url']);
|
|
9741
|
+
queryParams = body['_query'];
|
|
9742
|
+
delete body['config'];
|
|
9743
|
+
delete body['_url'];
|
|
9744
|
+
delete body['_query'];
|
|
9745
|
+
response = this.apiClient
|
|
9746
|
+
.request({
|
|
9747
|
+
path: path,
|
|
9748
|
+
queryParams: queryParams,
|
|
9749
|
+
body: JSON.stringify(body),
|
|
9750
|
+
httpMethod: 'GET',
|
|
9751
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
9752
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
9753
|
+
})
|
|
9754
|
+
.then((httpResponse) => {
|
|
9755
|
+
return httpResponse.json();
|
|
9756
|
+
});
|
|
9757
|
+
return response.then((apiResponse) => {
|
|
9758
|
+
const resp = tuningJobFromMldev(this.apiClient, apiResponse);
|
|
9759
|
+
return resp;
|
|
9760
|
+
});
|
|
9761
|
+
}
|
|
9762
|
+
}
|
|
9763
|
+
async listInternal(params) {
|
|
9764
|
+
var _a, _b, _c, _d;
|
|
9765
|
+
let response;
|
|
9766
|
+
let path = '';
|
|
9767
|
+
let queryParams = {};
|
|
9768
|
+
if (this.apiClient.isVertexAI()) {
|
|
9769
|
+
const body = listTuningJobsParametersToVertex(this.apiClient, params);
|
|
9770
|
+
path = formatMap('tuningJobs', body['_url']);
|
|
9771
|
+
queryParams = body['_query'];
|
|
9772
|
+
delete body['config'];
|
|
9773
|
+
delete body['_url'];
|
|
9774
|
+
delete body['_query'];
|
|
9775
|
+
response = this.apiClient
|
|
9776
|
+
.request({
|
|
9777
|
+
path: path,
|
|
9778
|
+
queryParams: queryParams,
|
|
9779
|
+
body: JSON.stringify(body),
|
|
9780
|
+
httpMethod: 'GET',
|
|
9781
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
9782
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
9783
|
+
})
|
|
9784
|
+
.then((httpResponse) => {
|
|
9785
|
+
return httpResponse.json();
|
|
9786
|
+
});
|
|
9787
|
+
return response.then((apiResponse) => {
|
|
9788
|
+
const resp = listTuningJobsResponseFromVertex(this.apiClient, apiResponse);
|
|
9789
|
+
const typedResp = new ListTuningJobsResponse();
|
|
9790
|
+
Object.assign(typedResp, resp);
|
|
9791
|
+
return typedResp;
|
|
9792
|
+
});
|
|
9793
|
+
}
|
|
9794
|
+
else {
|
|
9795
|
+
const body = listTuningJobsParametersToMldev(this.apiClient, params);
|
|
9796
|
+
path = formatMap('tunedModels', body['_url']);
|
|
9797
|
+
queryParams = body['_query'];
|
|
9798
|
+
delete body['config'];
|
|
9799
|
+
delete body['_url'];
|
|
9800
|
+
delete body['_query'];
|
|
9801
|
+
response = this.apiClient
|
|
9802
|
+
.request({
|
|
9803
|
+
path: path,
|
|
9804
|
+
queryParams: queryParams,
|
|
9805
|
+
body: JSON.stringify(body),
|
|
9806
|
+
httpMethod: 'GET',
|
|
9807
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
9808
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
9809
|
+
})
|
|
9810
|
+
.then((httpResponse) => {
|
|
9811
|
+
return httpResponse.json();
|
|
9812
|
+
});
|
|
9813
|
+
return response.then((apiResponse) => {
|
|
9814
|
+
const resp = listTuningJobsResponseFromMldev(this.apiClient, apiResponse);
|
|
9815
|
+
const typedResp = new ListTuningJobsResponse();
|
|
9816
|
+
Object.assign(typedResp, resp);
|
|
9817
|
+
return typedResp;
|
|
9818
|
+
});
|
|
9819
|
+
}
|
|
9820
|
+
}
|
|
9821
|
+
async tuneInternal(params) {
|
|
9822
|
+
var _a, _b;
|
|
9823
|
+
let response;
|
|
9824
|
+
let path = '';
|
|
9825
|
+
let queryParams = {};
|
|
9826
|
+
if (this.apiClient.isVertexAI()) {
|
|
9827
|
+
const body = createTuningJobParametersToVertex(this.apiClient, params);
|
|
9828
|
+
path = formatMap('tuningJobs', body['_url']);
|
|
9829
|
+
queryParams = body['_query'];
|
|
9830
|
+
delete body['config'];
|
|
9831
|
+
delete body['_url'];
|
|
9832
|
+
delete body['_query'];
|
|
9833
|
+
response = this.apiClient
|
|
9834
|
+
.request({
|
|
9835
|
+
path: path,
|
|
9836
|
+
queryParams: queryParams,
|
|
9837
|
+
body: JSON.stringify(body),
|
|
9838
|
+
httpMethod: 'POST',
|
|
9839
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
9840
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
9841
|
+
})
|
|
9842
|
+
.then((httpResponse) => {
|
|
9843
|
+
return httpResponse.json();
|
|
9844
|
+
});
|
|
9845
|
+
return response.then((apiResponse) => {
|
|
9846
|
+
const resp = tuningJobFromVertex(this.apiClient, apiResponse);
|
|
9847
|
+
return resp;
|
|
9848
|
+
});
|
|
9849
|
+
}
|
|
9850
|
+
else {
|
|
9851
|
+
throw new Error('This method is only supported by the Vertex AI.');
|
|
9852
|
+
}
|
|
9853
|
+
}
|
|
9854
|
+
async tuneMldevInternal(params) {
|
|
9855
|
+
var _a, _b;
|
|
9856
|
+
let response;
|
|
9857
|
+
let path = '';
|
|
9858
|
+
let queryParams = {};
|
|
9859
|
+
if (this.apiClient.isVertexAI()) {
|
|
9860
|
+
throw new Error('This method is only supported by the Gemini Developer API.');
|
|
9861
|
+
}
|
|
9862
|
+
else {
|
|
9863
|
+
const body = createTuningJobParametersToMldev(this.apiClient, params);
|
|
9864
|
+
path = formatMap('tunedModels', body['_url']);
|
|
9865
|
+
queryParams = body['_query'];
|
|
9866
|
+
delete body['config'];
|
|
9867
|
+
delete body['_url'];
|
|
9868
|
+
delete body['_query'];
|
|
9869
|
+
response = this.apiClient
|
|
9870
|
+
.request({
|
|
9871
|
+
path: path,
|
|
9872
|
+
queryParams: queryParams,
|
|
9873
|
+
body: JSON.stringify(body),
|
|
9874
|
+
httpMethod: 'POST',
|
|
9875
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
9876
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
9877
|
+
})
|
|
9878
|
+
.then((httpResponse) => {
|
|
9879
|
+
return httpResponse.json();
|
|
9880
|
+
});
|
|
9881
|
+
return response.then((apiResponse) => {
|
|
9882
|
+
const resp = operationFromMldev(this.apiClient, apiResponse);
|
|
9883
|
+
return resp;
|
|
9884
|
+
});
|
|
9885
|
+
}
|
|
9886
|
+
}
|
|
9887
|
+
}
|
|
9888
|
+
|
|
9268
9889
|
/**
|
|
9269
9890
|
* @license
|
|
9270
9891
|
* Copyright 2025 Google LLC
|
|
@@ -9346,8 +9967,9 @@ class GoogleGenAI {
|
|
|
9346
9967
|
this.caches = new Caches(this.apiClient);
|
|
9347
9968
|
this.files = new Files(this.apiClient);
|
|
9348
9969
|
this.operations = new Operations(this.apiClient);
|
|
9970
|
+
this.tunings = new Tunings(this.apiClient);
|
|
9349
9971
|
}
|
|
9350
9972
|
}
|
|
9351
9973
|
|
|
9352
|
-
export { ActivityHandling, BlockedReason, Caches, Chat, Chats, ComputeTokensResponse, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DynamicRetrievalConfigMode, EmbedContentResponse, EndSensitivity, FeatureSelectionPreference, FileSource, FileState, Files, FinishReason, FunctionCallingConfigMode, FunctionResponse, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GenerateVideosResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpResponse, ImagePromptLanguage, Language, ListCachedContentsResponse, ListFilesResponse, Live, LiveClientToolResponse, LiveSendToolResponseParameters, MaskReferenceMode, MediaModality, MediaResolution, Modality, Mode, Models, Operations, Outcome, PagedItem, Pager, PersonGeneration, ReplayResponse, SafetyFilterLevel, Session, StartSensitivity, SubjectReferenceType, TrafficType, TurnCoverage, Type, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent };
|
|
9974
|
+
export { ActivityHandling, AdapterSize, BlockedReason, Caches, Chat, Chats, ComputeTokensResponse, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DeleteModelResponse, DynamicRetrievalConfigMode, EmbedContentResponse, EndSensitivity, FeatureSelectionPreference, FileSource, FileState, Files, FinishReason, FunctionCallingConfigMode, FunctionResponse, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GenerateVideosResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpResponse, ImagePromptLanguage, JobState, Language, ListCachedContentsResponse, ListFilesResponse, ListTuningJobsResponse, Live, LiveClientToolResponse, LiveSendToolResponseParameters, MaskReferenceMode, MediaModality, MediaResolution, Modality, Mode, Models, Operations, Outcome, PagedItem, Pager, PersonGeneration, ReplayResponse, SafetyFilterLevel, Session, StartSensitivity, SubjectReferenceType, TrafficType, TurnCoverage, Type, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent, setDefaultBaseUrls };
|
|
9353
9975
|
//# sourceMappingURL=index.mjs.map
|