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