@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.
@@ -1,3 +1,63 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ let _defaultBaseGeminiUrl = undefined;
7
+ let _defaultBaseVertexUrl = undefined;
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
+ _defaultBaseGeminiUrl = baseUrlParams.geminiUrl;
30
+ _defaultBaseVertexUrl = baseUrlParams.vertexUrl;
31
+ }
32
+ /**
33
+ * Returns the default base URLs for the Gemini API and Vertex AI API.
34
+ */
35
+ function getDefaultBaseUrls() {
36
+ return {
37
+ geminiUrl: _defaultBaseGeminiUrl,
38
+ vertexUrl: _defaultBaseVertexUrl,
39
+ };
40
+ }
41
+ /**
42
+ * Returns the default base URL based on the following priority:
43
+ * 1. Base URLs set via HttpOptions.
44
+ * 2. Base URLs set via the latest call to setDefaultBaseUrls.
45
+ * 3. Base URLs set via environment variables.
46
+ */
47
+ function getBaseUrl(options, vertexBaseUrlFromEnv, geminiBaseUrlFromEnv) {
48
+ var _a, _b, _c;
49
+ if (!((_a = options.httpOptions) === null || _a === void 0 ? void 0 : _a.baseUrl)) {
50
+ const defaultBaseUrls = getDefaultBaseUrls();
51
+ if (options.vertexai) {
52
+ return (_b = defaultBaseUrls.vertexUrl) !== null && _b !== void 0 ? _b : vertexBaseUrlFromEnv;
53
+ }
54
+ else {
55
+ return (_c = defaultBaseUrls.geminiUrl) !== null && _c !== void 0 ? _c : geminiBaseUrlFromEnv;
56
+ }
57
+ }
58
+ return options.httpOptions.baseUrl;
59
+ }
60
+
1
61
  /**
2
62
  * @license
3
63
  * Copyright 2025 Google LLC
@@ -173,6 +233,36 @@ function tCachesModel(apiClient, model) {
173
233
  return transformedModel;
174
234
  }
175
235
  }
236
+ function tBlobs(apiClient, blobs) {
237
+ if (Array.isArray(blobs)) {
238
+ return blobs.map((blob) => tBlob(apiClient, blob));
239
+ }
240
+ else {
241
+ return [tBlob(apiClient, blobs)];
242
+ }
243
+ }
244
+ function tBlob(apiClient, blob) {
245
+ if (typeof blob === 'object' && blob !== null) {
246
+ return blob;
247
+ }
248
+ throw new Error(`Could not parse input as Blob. Unsupported blob type: ${typeof blob}`);
249
+ }
250
+ function tImageBlob(apiClient, blob) {
251
+ const transformedBlob = tBlob(apiClient, blob);
252
+ if (transformedBlob.mimeType &&
253
+ transformedBlob.mimeType.startsWith('image/')) {
254
+ return transformedBlob;
255
+ }
256
+ throw new Error(`Unsupported mime type: ${transformedBlob.mimeType}`);
257
+ }
258
+ function tAudioBlob(apiClient, blob) {
259
+ const transformedBlob = tBlob(apiClient, blob);
260
+ if (transformedBlob.mimeType &&
261
+ transformedBlob.mimeType.startsWith('audio/')) {
262
+ return transformedBlob;
263
+ }
264
+ throw new Error(`Unsupported mime type: ${transformedBlob.mimeType}`);
265
+ }
176
266
  function tPart(apiClient, origin) {
177
267
  if (origin === null || origin === undefined) {
178
268
  throw new Error('PartUnion is required');
@@ -296,38 +386,11 @@ function tContents(apiClient, origin) {
296
386
  }
297
387
  return result;
298
388
  }
299
- function processSchema(apiClient, schema) {
300
- if (!apiClient.isVertexAI()) {
301
- if ('default' in schema) {
302
- throw new Error('Default value is not supported in the response schema for the Gemini API.');
303
- }
304
- }
305
- if ('anyOf' in schema) {
306
- if (schema['anyOf'] !== undefined) {
307
- for (const subSchema of schema['anyOf']) {
308
- processSchema(apiClient, subSchema);
309
- }
310
- }
311
- }
312
- if ('items' in schema) {
313
- if (schema['items'] !== undefined) {
314
- processSchema(apiClient, schema['items']);
315
- }
316
- }
317
- if ('properties' in schema) {
318
- if (schema['properties'] !== undefined) {
319
- for (const subSchema of Object.values(schema['properties'])) {
320
- processSchema(apiClient, subSchema);
321
- }
322
- }
323
- }
324
- }
325
389
  function tSchema(apiClient, schema) {
326
- processSchema(apiClient, schema);
327
390
  return schema;
328
391
  }
329
392
  function tSpeechConfig(apiClient, speechConfig) {
330
- if (typeof speechConfig === 'object' && 'voiceConfig' in speechConfig) {
393
+ if (typeof speechConfig === 'object') {
331
394
  return speechConfig;
332
395
  }
333
396
  else if (typeof speechConfig === 'string') {
@@ -435,6 +498,20 @@ function tCachedContentName(apiClient, name) {
435
498
  }
436
499
  return resourceName(apiClient, name, 'cachedContents');
437
500
  }
501
+ function tTuningJobStatus(apiClient, status) {
502
+ switch (status) {
503
+ case 'STATE_UNSPECIFIED':
504
+ return 'JOB_STATE_UNSPECIFIED';
505
+ case 'CREATING':
506
+ return 'JOB_STATE_RUNNING';
507
+ case 'ACTIVE':
508
+ return 'JOB_STATE_SUCCEEDED';
509
+ case 'FAILED':
510
+ return 'JOB_STATE_FAILED';
511
+ default:
512
+ return status;
513
+ }
514
+ }
438
515
  function tBytes(apiClient, fromImageBytes) {
439
516
  if (typeof fromImageBytes !== 'string') {
440
517
  throw new Error('fromImageBytes must be a string');
@@ -507,14 +584,13 @@ function contentToMldev$2(apiClient, fromObject) {
507
584
  const toObject = {};
508
585
  const fromParts = getValueByPath(fromObject, ['parts']);
509
586
  if (fromParts != null) {
510
- if (Array.isArray(fromParts)) {
511
- setValueByPath(toObject, ['parts'], fromParts.map((item) => {
587
+ let transformedList = fromParts;
588
+ if (Array.isArray(transformedList)) {
589
+ transformedList = transformedList.map((item) => {
512
590
  return partToMldev$2(apiClient, item);
513
- }));
514
- }
515
- else {
516
- setValueByPath(toObject, ['parts'], fromParts);
591
+ });
517
592
  }
593
+ setValueByPath(toObject, ['parts'], transformedList);
518
594
  }
519
595
  const fromRole = getValueByPath(fromObject, ['role']);
520
596
  if (fromRole != null) {
@@ -522,25 +598,6 @@ function contentToMldev$2(apiClient, fromObject) {
522
598
  }
523
599
  return toObject;
524
600
  }
525
- function functionDeclarationToMldev$2(apiClient, fromObject) {
526
- const toObject = {};
527
- if (getValueByPath(fromObject, ['response']) !== undefined) {
528
- throw new Error('response parameter is not supported in Gemini API.');
529
- }
530
- const fromDescription = getValueByPath(fromObject, ['description']);
531
- if (fromDescription != null) {
532
- setValueByPath(toObject, ['description'], fromDescription);
533
- }
534
- const fromName = getValueByPath(fromObject, ['name']);
535
- if (fromName != null) {
536
- setValueByPath(toObject, ['name'], fromName);
537
- }
538
- const fromParameters = getValueByPath(fromObject, ['parameters']);
539
- if (fromParameters != null) {
540
- setValueByPath(toObject, ['parameters'], fromParameters);
541
- }
542
- return toObject;
543
- }
544
601
  function googleSearchToMldev$2() {
545
602
  const toObject = {};
546
603
  return toObject;
@@ -571,19 +628,6 @@ function googleSearchRetrievalToMldev$2(apiClient, fromObject) {
571
628
  }
572
629
  function toolToMldev$2(apiClient, fromObject) {
573
630
  const toObject = {};
574
- const fromFunctionDeclarations = getValueByPath(fromObject, [
575
- 'functionDeclarations',
576
- ]);
577
- if (fromFunctionDeclarations != null) {
578
- if (Array.isArray(fromFunctionDeclarations)) {
579
- setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations.map((item) => {
580
- return functionDeclarationToMldev$2(apiClient, item);
581
- }));
582
- }
583
- else {
584
- setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
585
- }
586
- }
587
631
  if (getValueByPath(fromObject, ['retrieval']) !== undefined) {
588
632
  throw new Error('retrieval parameter is not supported in Gemini API.');
589
633
  }
@@ -603,6 +647,12 @@ function toolToMldev$2(apiClient, fromObject) {
603
647
  if (fromCodeExecution != null) {
604
648
  setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
605
649
  }
650
+ const fromFunctionDeclarations = getValueByPath(fromObject, [
651
+ 'functionDeclarations',
652
+ ]);
653
+ if (fromFunctionDeclarations != null) {
654
+ setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
655
+ }
606
656
  return toObject;
607
657
  }
608
658
  function functionCallingConfigToMldev$1(apiClient, fromObject) {
@@ -645,14 +695,13 @@ function createCachedContentConfigToMldev(apiClient, fromObject, parentObject) {
645
695
  }
646
696
  const fromContents = getValueByPath(fromObject, ['contents']);
647
697
  if (parentObject !== undefined && fromContents != null) {
648
- if (Array.isArray(fromContents)) {
649
- setValueByPath(parentObject, ['contents'], tContents(apiClient, tContents(apiClient, fromContents).map((item) => {
698
+ let transformedList = tContents(apiClient, fromContents);
699
+ if (Array.isArray(transformedList)) {
700
+ transformedList = transformedList.map((item) => {
650
701
  return contentToMldev$2(apiClient, item);
651
- })));
652
- }
653
- else {
654
- setValueByPath(parentObject, ['contents'], tContents(apiClient, fromContents));
702
+ });
655
703
  }
704
+ setValueByPath(parentObject, ['contents'], transformedList);
656
705
  }
657
706
  const fromSystemInstruction = getValueByPath(fromObject, [
658
707
  'systemInstruction',
@@ -662,14 +711,13 @@ function createCachedContentConfigToMldev(apiClient, fromObject, parentObject) {
662
711
  }
663
712
  const fromTools = getValueByPath(fromObject, ['tools']);
664
713
  if (parentObject !== undefined && fromTools != null) {
665
- if (Array.isArray(fromTools)) {
666
- setValueByPath(parentObject, ['tools'], fromTools.map((item) => {
714
+ let transformedList = fromTools;
715
+ if (Array.isArray(transformedList)) {
716
+ transformedList = transformedList.map((item) => {
667
717
  return toolToMldev$2(apiClient, item);
668
- }));
669
- }
670
- else {
671
- setValueByPath(parentObject, ['tools'], fromTools);
718
+ });
672
719
  }
720
+ setValueByPath(parentObject, ['tools'], transformedList);
673
721
  }
674
722
  const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
675
723
  if (parentObject !== undefined && fromToolConfig != null) {
@@ -809,14 +857,13 @@ function contentToVertex$2(apiClient, fromObject) {
809
857
  const toObject = {};
810
858
  const fromParts = getValueByPath(fromObject, ['parts']);
811
859
  if (fromParts != null) {
812
- if (Array.isArray(fromParts)) {
813
- setValueByPath(toObject, ['parts'], fromParts.map((item) => {
860
+ let transformedList = fromParts;
861
+ if (Array.isArray(transformedList)) {
862
+ transformedList = transformedList.map((item) => {
814
863
  return partToVertex$2(apiClient, item);
815
- }));
816
- }
817
- else {
818
- setValueByPath(toObject, ['parts'], fromParts);
864
+ });
819
865
  }
866
+ setValueByPath(toObject, ['parts'], transformedList);
820
867
  }
821
868
  const fromRole = getValueByPath(fromObject, ['role']);
822
869
  if (fromRole != null) {
@@ -824,124 +871,6 @@ function contentToVertex$2(apiClient, fromObject) {
824
871
  }
825
872
  return toObject;
826
873
  }
827
- function schemaToVertex$2(apiClient, fromObject) {
828
- const toObject = {};
829
- const fromExample = getValueByPath(fromObject, ['example']);
830
- if (fromExample != null) {
831
- setValueByPath(toObject, ['example'], fromExample);
832
- }
833
- const fromPattern = getValueByPath(fromObject, ['pattern']);
834
- if (fromPattern != null) {
835
- setValueByPath(toObject, ['pattern'], fromPattern);
836
- }
837
- const fromDefault = getValueByPath(fromObject, ['default']);
838
- if (fromDefault != null) {
839
- setValueByPath(toObject, ['default'], fromDefault);
840
- }
841
- const fromMaxLength = getValueByPath(fromObject, ['maxLength']);
842
- if (fromMaxLength != null) {
843
- setValueByPath(toObject, ['maxLength'], fromMaxLength);
844
- }
845
- const fromMinLength = getValueByPath(fromObject, ['minLength']);
846
- if (fromMinLength != null) {
847
- setValueByPath(toObject, ['minLength'], fromMinLength);
848
- }
849
- const fromMinProperties = getValueByPath(fromObject, [
850
- 'minProperties',
851
- ]);
852
- if (fromMinProperties != null) {
853
- setValueByPath(toObject, ['minProperties'], fromMinProperties);
854
- }
855
- const fromMaxProperties = getValueByPath(fromObject, [
856
- 'maxProperties',
857
- ]);
858
- if (fromMaxProperties != null) {
859
- setValueByPath(toObject, ['maxProperties'], fromMaxProperties);
860
- }
861
- const fromAnyOf = getValueByPath(fromObject, ['anyOf']);
862
- if (fromAnyOf != null) {
863
- setValueByPath(toObject, ['anyOf'], fromAnyOf);
864
- }
865
- const fromDescription = getValueByPath(fromObject, ['description']);
866
- if (fromDescription != null) {
867
- setValueByPath(toObject, ['description'], fromDescription);
868
- }
869
- const fromEnum = getValueByPath(fromObject, ['enum']);
870
- if (fromEnum != null) {
871
- setValueByPath(toObject, ['enum'], fromEnum);
872
- }
873
- const fromFormat = getValueByPath(fromObject, ['format']);
874
- if (fromFormat != null) {
875
- setValueByPath(toObject, ['format'], fromFormat);
876
- }
877
- const fromItems = getValueByPath(fromObject, ['items']);
878
- if (fromItems != null) {
879
- setValueByPath(toObject, ['items'], fromItems);
880
- }
881
- const fromMaxItems = getValueByPath(fromObject, ['maxItems']);
882
- if (fromMaxItems != null) {
883
- setValueByPath(toObject, ['maxItems'], fromMaxItems);
884
- }
885
- const fromMaximum = getValueByPath(fromObject, ['maximum']);
886
- if (fromMaximum != null) {
887
- setValueByPath(toObject, ['maximum'], fromMaximum);
888
- }
889
- const fromMinItems = getValueByPath(fromObject, ['minItems']);
890
- if (fromMinItems != null) {
891
- setValueByPath(toObject, ['minItems'], fromMinItems);
892
- }
893
- const fromMinimum = getValueByPath(fromObject, ['minimum']);
894
- if (fromMinimum != null) {
895
- setValueByPath(toObject, ['minimum'], fromMinimum);
896
- }
897
- const fromNullable = getValueByPath(fromObject, ['nullable']);
898
- if (fromNullable != null) {
899
- setValueByPath(toObject, ['nullable'], fromNullable);
900
- }
901
- const fromProperties = getValueByPath(fromObject, ['properties']);
902
- if (fromProperties != null) {
903
- setValueByPath(toObject, ['properties'], fromProperties);
904
- }
905
- const fromPropertyOrdering = getValueByPath(fromObject, [
906
- 'propertyOrdering',
907
- ]);
908
- if (fromPropertyOrdering != null) {
909
- setValueByPath(toObject, ['propertyOrdering'], fromPropertyOrdering);
910
- }
911
- const fromRequired = getValueByPath(fromObject, ['required']);
912
- if (fromRequired != null) {
913
- setValueByPath(toObject, ['required'], fromRequired);
914
- }
915
- const fromTitle = getValueByPath(fromObject, ['title']);
916
- if (fromTitle != null) {
917
- setValueByPath(toObject, ['title'], fromTitle);
918
- }
919
- const fromType = getValueByPath(fromObject, ['type']);
920
- if (fromType != null) {
921
- setValueByPath(toObject, ['type'], fromType);
922
- }
923
- return toObject;
924
- }
925
- function functionDeclarationToVertex$2(apiClient, fromObject) {
926
- const toObject = {};
927
- const fromResponse = getValueByPath(fromObject, ['response']);
928
- if (fromResponse != null) {
929
- setValueByPath(toObject, ['response'], schemaToVertex$2(apiClient, fromResponse));
930
- }
931
- const fromDescription = getValueByPath(fromObject, ['description']);
932
- if (fromDescription != null) {
933
- setValueByPath(toObject, ['description'], fromDescription);
934
- }
935
- const fromName = getValueByPath(fromObject, ['name']);
936
- if (fromName != null) {
937
- setValueByPath(toObject, ['name'], fromName);
938
- }
939
- const fromParameters = getValueByPath(fromObject, ['parameters']);
940
- if (fromParameters != null) {
941
- setValueByPath(toObject, ['parameters'], fromParameters);
942
- }
943
- return toObject;
944
- }
945
874
  function googleSearchToVertex$2() {
946
875
  const toObject = {};
947
876
  return toObject;
@@ -972,19 +901,6 @@ function googleSearchRetrievalToVertex$2(apiClient, fromObject) {
972
901
  }
973
902
  function toolToVertex$2(apiClient, fromObject) {
974
903
  const toObject = {};
975
- const fromFunctionDeclarations = getValueByPath(fromObject, [
976
- 'functionDeclarations',
977
- ]);
978
- if (fromFunctionDeclarations != null) {
979
- if (Array.isArray(fromFunctionDeclarations)) {
980
- setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations.map((item) => {
981
- return functionDeclarationToVertex$2(apiClient, item);
982
- }));
983
- }
984
- else {
985
- setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
986
- }
987
- }
988
904
  const fromRetrieval = getValueByPath(fromObject, ['retrieval']);
989
905
  if (fromRetrieval != null) {
990
906
  setValueByPath(toObject, ['retrieval'], fromRetrieval);
@@ -1005,6 +921,12 @@ function toolToVertex$2(apiClient, fromObject) {
1005
921
  if (fromCodeExecution != null) {
1006
922
  setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
1007
923
  }
924
+ const fromFunctionDeclarations = getValueByPath(fromObject, [
925
+ 'functionDeclarations',
926
+ ]);
927
+ if (fromFunctionDeclarations != null) {
928
+ setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
929
+ }
1008
930
  return toObject;
1009
931
  }
1010
932
  function functionCallingConfigToVertex$1(apiClient, fromObject) {
@@ -1047,14 +969,13 @@ function createCachedContentConfigToVertex(apiClient, fromObject, parentObject)
1047
969
  }
1048
970
  const fromContents = getValueByPath(fromObject, ['contents']);
1049
971
  if (parentObject !== undefined && fromContents != null) {
1050
- if (Array.isArray(fromContents)) {
1051
- setValueByPath(parentObject, ['contents'], tContents(apiClient, tContents(apiClient, fromContents).map((item) => {
972
+ let transformedList = tContents(apiClient, fromContents);
973
+ if (Array.isArray(transformedList)) {
974
+ transformedList = transformedList.map((item) => {
1052
975
  return contentToVertex$2(apiClient, item);
1053
- })));
1054
- }
1055
- else {
1056
- setValueByPath(parentObject, ['contents'], tContents(apiClient, fromContents));
976
+ });
1057
977
  }
978
+ setValueByPath(parentObject, ['contents'], transformedList);
1058
979
  }
1059
980
  const fromSystemInstruction = getValueByPath(fromObject, [
1060
981
  'systemInstruction',
@@ -1064,14 +985,13 @@ function createCachedContentConfigToVertex(apiClient, fromObject, parentObject)
1064
985
  }
1065
986
  const fromTools = getValueByPath(fromObject, ['tools']);
1066
987
  if (parentObject !== undefined && fromTools != null) {
1067
- if (Array.isArray(fromTools)) {
1068
- setValueByPath(parentObject, ['tools'], fromTools.map((item) => {
988
+ let transformedList = fromTools;
989
+ if (Array.isArray(transformedList)) {
990
+ transformedList = transformedList.map((item) => {
1069
991
  return toolToVertex$2(apiClient, item);
1070
- }));
1071
- }
1072
- else {
1073
- setValueByPath(parentObject, ['tools'], fromTools);
992
+ });
1074
993
  }
994
+ setValueByPath(parentObject, ['tools'], transformedList);
1075
995
  }
1076
996
  const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
1077
997
  if (parentObject !== undefined && fromToolConfig != null) {
@@ -1209,14 +1129,13 @@ function listCachedContentsResponseFromMldev(apiClient, fromObject) {
1209
1129
  'cachedContents',
1210
1130
  ]);
1211
1131
  if (fromCachedContents != null) {
1212
- if (Array.isArray(fromCachedContents)) {
1213
- setValueByPath(toObject, ['cachedContents'], fromCachedContents.map((item) => {
1132
+ let transformedList = fromCachedContents;
1133
+ if (Array.isArray(transformedList)) {
1134
+ transformedList = transformedList.map((item) => {
1214
1135
  return cachedContentFromMldev(apiClient, item);
1215
- }));
1216
- }
1217
- else {
1218
- setValueByPath(toObject, ['cachedContents'], fromCachedContents);
1136
+ });
1219
1137
  }
1138
+ setValueByPath(toObject, ['cachedContents'], transformedList);
1220
1139
  }
1221
1140
  return toObject;
1222
1141
  }
@@ -1270,14 +1189,13 @@ function listCachedContentsResponseFromVertex(apiClient, fromObject) {
1270
1189
  'cachedContents',
1271
1190
  ]);
1272
1191
  if (fromCachedContents != null) {
1273
- if (Array.isArray(fromCachedContents)) {
1274
- setValueByPath(toObject, ['cachedContents'], fromCachedContents.map((item) => {
1192
+ let transformedList = fromCachedContents;
1193
+ if (Array.isArray(transformedList)) {
1194
+ transformedList = transformedList.map((item) => {
1275
1195
  return cachedContentFromVertex(apiClient, item);
1276
- }));
1277
- }
1278
- else {
1279
- setValueByPath(toObject, ['cachedContents'], fromCachedContents);
1196
+ });
1280
1197
  }
1198
+ setValueByPath(toObject, ['cachedContents'], transformedList);
1281
1199
  }
1282
1200
  return toObject;
1283
1201
  }
@@ -1479,17 +1397,6 @@ var Language;
1479
1397
  Language["LANGUAGE_UNSPECIFIED"] = "LANGUAGE_UNSPECIFIED";
1480
1398
  Language["PYTHON"] = "PYTHON";
1481
1399
  })(Language || (Language = {}));
1482
- /** Optional. The type of the data. */
1483
- var Type;
1484
- (function (Type) {
1485
- Type["TYPE_UNSPECIFIED"] = "TYPE_UNSPECIFIED";
1486
- Type["STRING"] = "STRING";
1487
- Type["NUMBER"] = "NUMBER";
1488
- Type["INTEGER"] = "INTEGER";
1489
- Type["BOOLEAN"] = "BOOLEAN";
1490
- Type["ARRAY"] = "ARRAY";
1491
- Type["OBJECT"] = "OBJECT";
1492
- })(Type || (Type = {}));
1493
1400
  /** Required. Harm category. */
1494
1401
  var HarmCategory;
1495
1402
  (function (HarmCategory) {
@@ -1523,6 +1430,17 @@ var Mode;
1523
1430
  Mode["MODE_UNSPECIFIED"] = "MODE_UNSPECIFIED";
1524
1431
  Mode["MODE_DYNAMIC"] = "MODE_DYNAMIC";
1525
1432
  })(Mode || (Mode = {}));
1433
+ /** Optional. The type of the data. */
1434
+ var Type;
1435
+ (function (Type) {
1436
+ Type["TYPE_UNSPECIFIED"] = "TYPE_UNSPECIFIED";
1437
+ Type["STRING"] = "STRING";
1438
+ Type["NUMBER"] = "NUMBER";
1439
+ Type["INTEGER"] = "INTEGER";
1440
+ Type["BOOLEAN"] = "BOOLEAN";
1441
+ Type["ARRAY"] = "ARRAY";
1442
+ Type["OBJECT"] = "OBJECT";
1443
+ })(Type || (Type = {}));
1526
1444
  /** Output only. The reason why the model stopped generating tokens.
1527
1445
 
1528
1446
  If empty, the model has not stopped generating the tokens.
@@ -1534,6 +1452,7 @@ var FinishReason;
1534
1452
  FinishReason["MAX_TOKENS"] = "MAX_TOKENS";
1535
1453
  FinishReason["SAFETY"] = "SAFETY";
1536
1454
  FinishReason["RECITATION"] = "RECITATION";
1455
+ FinishReason["LANGUAGE"] = "LANGUAGE";
1537
1456
  FinishReason["OTHER"] = "OTHER";
1538
1457
  FinishReason["BLOCKLIST"] = "BLOCKLIST";
1539
1458
  FinishReason["PROHIBITED_CONTENT"] = "PROHIBITED_CONTENT";
@@ -1591,6 +1510,33 @@ var MediaResolution;
1591
1510
  MediaResolution["MEDIA_RESOLUTION_MEDIUM"] = "MEDIA_RESOLUTION_MEDIUM";
1592
1511
  MediaResolution["MEDIA_RESOLUTION_HIGH"] = "MEDIA_RESOLUTION_HIGH";
1593
1512
  })(MediaResolution || (MediaResolution = {}));
1513
+ /** Output only. The detailed state of the job. */
1514
+ var JobState;
1515
+ (function (JobState) {
1516
+ JobState["JOB_STATE_UNSPECIFIED"] = "JOB_STATE_UNSPECIFIED";
1517
+ JobState["JOB_STATE_QUEUED"] = "JOB_STATE_QUEUED";
1518
+ JobState["JOB_STATE_PENDING"] = "JOB_STATE_PENDING";
1519
+ JobState["JOB_STATE_RUNNING"] = "JOB_STATE_RUNNING";
1520
+ JobState["JOB_STATE_SUCCEEDED"] = "JOB_STATE_SUCCEEDED";
1521
+ JobState["JOB_STATE_FAILED"] = "JOB_STATE_FAILED";
1522
+ JobState["JOB_STATE_CANCELLING"] = "JOB_STATE_CANCELLING";
1523
+ JobState["JOB_STATE_CANCELLED"] = "JOB_STATE_CANCELLED";
1524
+ JobState["JOB_STATE_PAUSED"] = "JOB_STATE_PAUSED";
1525
+ JobState["JOB_STATE_EXPIRED"] = "JOB_STATE_EXPIRED";
1526
+ JobState["JOB_STATE_UPDATING"] = "JOB_STATE_UPDATING";
1527
+ JobState["JOB_STATE_PARTIALLY_SUCCEEDED"] = "JOB_STATE_PARTIALLY_SUCCEEDED";
1528
+ })(JobState || (JobState = {}));
1529
+ /** Optional. Adapter size for tuning. */
1530
+ var AdapterSize;
1531
+ (function (AdapterSize) {
1532
+ AdapterSize["ADAPTER_SIZE_UNSPECIFIED"] = "ADAPTER_SIZE_UNSPECIFIED";
1533
+ AdapterSize["ADAPTER_SIZE_ONE"] = "ADAPTER_SIZE_ONE";
1534
+ AdapterSize["ADAPTER_SIZE_TWO"] = "ADAPTER_SIZE_TWO";
1535
+ AdapterSize["ADAPTER_SIZE_FOUR"] = "ADAPTER_SIZE_FOUR";
1536
+ AdapterSize["ADAPTER_SIZE_EIGHT"] = "ADAPTER_SIZE_EIGHT";
1537
+ AdapterSize["ADAPTER_SIZE_SIXTEEN"] = "ADAPTER_SIZE_SIXTEEN";
1538
+ AdapterSize["ADAPTER_SIZE_THIRTY_TWO"] = "ADAPTER_SIZE_THIRTY_TWO";
1539
+ })(AdapterSize || (AdapterSize = {}));
1594
1540
  /** Options for feature selection preference. */
1595
1541
  var FeatureSelectionPreference;
1596
1542
  (function (FeatureSelectionPreference) {
@@ -1916,6 +1862,42 @@ class GenerateContentResponse {
1916
1862
  // part.text === '' is different from part.text is null
1917
1863
  return anyTextPartText ? text : undefined;
1918
1864
  }
1865
+ /**
1866
+ * Returns the concatenation of all inline data parts from the first candidate
1867
+ * in the response.
1868
+ *
1869
+ * @remarks
1870
+ * If there are multiple candidates in the response, the inline data from the
1871
+ * first one will be returned. If there are non-inline data parts in the
1872
+ * response, the concatenation of all inline data parts will be returned, and
1873
+ * a warning will be logged.
1874
+ */
1875
+ get data() {
1876
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1877
+ 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) {
1878
+ return undefined;
1879
+ }
1880
+ if (this.candidates && this.candidates.length > 1) {
1881
+ console.warn('there are multiple candidates in the response, returning data from the first one.');
1882
+ }
1883
+ let data = '';
1884
+ const nonDataParts = [];
1885
+ 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 : []) {
1886
+ for (const [fieldName, fieldValue] of Object.entries(part)) {
1887
+ if (fieldName !== 'inlineData' &&
1888
+ (fieldValue !== null || fieldValue !== undefined)) {
1889
+ nonDataParts.push(fieldName);
1890
+ }
1891
+ }
1892
+ if (part.inlineData && typeof part.inlineData.data === 'string') {
1893
+ data += atob(part.inlineData.data);
1894
+ }
1895
+ }
1896
+ if (nonDataParts.length > 0) {
1897
+ 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.`);
1898
+ }
1899
+ return data.length > 0 ? btoa(data) : undefined;
1900
+ }
1919
1901
  /**
1920
1902
  * Returns the function calls from the first candidate in the response.
1921
1903
  *
@@ -2055,6 +2037,8 @@ class EmbedContentResponse {
2055
2037
  /** The output images response. */
2056
2038
  class GenerateImagesResponse {
2057
2039
  }
2040
+ class DeleteModelResponse {
2041
+ }
2058
2042
  /** Response for counting tokens. */
2059
2043
  class CountTokensResponse {
2060
2044
  }
@@ -2064,6 +2048,9 @@ class ComputeTokensResponse {
2064
2048
  /** Response with generated videos. */
2065
2049
  class GenerateVideosResponse {
2066
2050
  }
2051
+ /** Response for the list tuning jobs method. */
2052
+ class ListTuningJobsResponse {
2053
+ }
2067
2054
  /** Empty response for caches.delete method. */
2068
2055
  class DeleteCachedContentResponse {
2069
2056
  }
@@ -2160,7 +2147,7 @@ class Caches extends BaseModule {
2160
2147
  * ```ts
2161
2148
  * const contents = ...; // Initialize the content to cache.
2162
2149
  * const response = await ai.caches.create({
2163
- * model: 'gemini-1.5-flash',
2150
+ * model: 'gemini-2.0-flash-001',
2164
2151
  * config: {
2165
2152
  * 'contents': contents,
2166
2153
  * 'displayName': 'test cache',
@@ -2171,7 +2158,7 @@ class Caches extends BaseModule {
2171
2158
  * ```
2172
2159
  */
2173
2160
  async create(params) {
2174
- var _a, _b;
2161
+ var _a, _b, _c, _d;
2175
2162
  let response;
2176
2163
  let path = '';
2177
2164
  let queryParams = {};
@@ -2189,6 +2176,7 @@ class Caches extends BaseModule {
2189
2176
  body: JSON.stringify(body),
2190
2177
  httpMethod: 'POST',
2191
2178
  httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
2179
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
2192
2180
  })
2193
2181
  .then((httpResponse) => {
2194
2182
  return httpResponse.json();
@@ -2211,7 +2199,8 @@ class Caches extends BaseModule {
2211
2199
  queryParams: queryParams,
2212
2200
  body: JSON.stringify(body),
2213
2201
  httpMethod: 'POST',
2214
- httpOptions: (_b = params.config) === null || _b === void 0 ? void 0 : _b.httpOptions,
2202
+ httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
2203
+ abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
2215
2204
  })
2216
2205
  .then((httpResponse) => {
2217
2206
  return httpResponse.json();
@@ -2230,11 +2219,11 @@ class Caches extends BaseModule {
2230
2219
  *
2231
2220
  * @example
2232
2221
  * ```ts
2233
- * await ai.caches.get({name: 'gemini-1.5-flash'});
2222
+ * await ai.caches.get({name: '...'}); // The server-generated resource name.
2234
2223
  * ```
2235
2224
  */
2236
2225
  async get(params) {
2237
- var _a, _b;
2226
+ var _a, _b, _c, _d;
2238
2227
  let response;
2239
2228
  let path = '';
2240
2229
  let queryParams = {};
@@ -2252,6 +2241,7 @@ class Caches extends BaseModule {
2252
2241
  body: JSON.stringify(body),
2253
2242
  httpMethod: 'GET',
2254
2243
  httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
2244
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
2255
2245
  })
2256
2246
  .then((httpResponse) => {
2257
2247
  return httpResponse.json();
@@ -2274,7 +2264,8 @@ class Caches extends BaseModule {
2274
2264
  queryParams: queryParams,
2275
2265
  body: JSON.stringify(body),
2276
2266
  httpMethod: 'GET',
2277
- httpOptions: (_b = params.config) === null || _b === void 0 ? void 0 : _b.httpOptions,
2267
+ httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
2268
+ abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
2278
2269
  })
2279
2270
  .then((httpResponse) => {
2280
2271
  return httpResponse.json();
@@ -2293,11 +2284,11 @@ class Caches extends BaseModule {
2293
2284
  *
2294
2285
  * @example
2295
2286
  * ```ts
2296
- * await ai.caches.delete({name: 'gemini-1.5-flash'});
2287
+ * await ai.caches.delete({name: '...'}); // The server-generated resource name.
2297
2288
  * ```
2298
2289
  */
2299
2290
  async delete(params) {
2300
- var _a, _b;
2291
+ var _a, _b, _c, _d;
2301
2292
  let response;
2302
2293
  let path = '';
2303
2294
  let queryParams = {};
@@ -2315,6 +2306,7 @@ class Caches extends BaseModule {
2315
2306
  body: JSON.stringify(body),
2316
2307
  httpMethod: 'DELETE',
2317
2308
  httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
2309
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
2318
2310
  })
2319
2311
  .then((httpResponse) => {
2320
2312
  return httpResponse.json();
@@ -2339,7 +2331,8 @@ class Caches extends BaseModule {
2339
2331
  queryParams: queryParams,
2340
2332
  body: JSON.stringify(body),
2341
2333
  httpMethod: 'DELETE',
2342
- httpOptions: (_b = params.config) === null || _b === void 0 ? void 0 : _b.httpOptions,
2334
+ httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
2335
+ abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
2343
2336
  })
2344
2337
  .then((httpResponse) => {
2345
2338
  return httpResponse.json();
@@ -2361,13 +2354,13 @@ class Caches extends BaseModule {
2361
2354
  * @example
2362
2355
  * ```ts
2363
2356
  * const response = await ai.caches.update({
2364
- * name: 'gemini-1.5-flash',
2357
+ * name: '...', // The server-generated resource name.
2365
2358
  * config: {'ttl': '7600s'}
2366
2359
  * });
2367
2360
  * ```
2368
2361
  */
2369
2362
  async update(params) {
2370
- var _a, _b;
2363
+ var _a, _b, _c, _d;
2371
2364
  let response;
2372
2365
  let path = '';
2373
2366
  let queryParams = {};
@@ -2385,6 +2378,7 @@ class Caches extends BaseModule {
2385
2378
  body: JSON.stringify(body),
2386
2379
  httpMethod: 'PATCH',
2387
2380
  httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
2381
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
2388
2382
  })
2389
2383
  .then((httpResponse) => {
2390
2384
  return httpResponse.json();
@@ -2407,7 +2401,8 @@ class Caches extends BaseModule {
2407
2401
  queryParams: queryParams,
2408
2402
  body: JSON.stringify(body),
2409
2403
  httpMethod: 'PATCH',
2410
- httpOptions: (_b = params.config) === null || _b === void 0 ? void 0 : _b.httpOptions,
2404
+ httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
2405
+ abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
2411
2406
  })
2412
2407
  .then((httpResponse) => {
2413
2408
  return httpResponse.json();
@@ -2419,7 +2414,7 @@ class Caches extends BaseModule {
2419
2414
  }
2420
2415
  }
2421
2416
  async listInternal(params) {
2422
- var _a, _b;
2417
+ var _a, _b, _c, _d;
2423
2418
  let response;
2424
2419
  let path = '';
2425
2420
  let queryParams = {};
@@ -2437,6 +2432,7 @@ class Caches extends BaseModule {
2437
2432
  body: JSON.stringify(body),
2438
2433
  httpMethod: 'GET',
2439
2434
  httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
2435
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
2440
2436
  })
2441
2437
  .then((httpResponse) => {
2442
2438
  return httpResponse.json();
@@ -2461,7 +2457,8 @@ class Caches extends BaseModule {
2461
2457
  queryParams: queryParams,
2462
2458
  body: JSON.stringify(body),
2463
2459
  httpMethod: 'GET',
2464
- httpOptions: (_b = params.config) === null || _b === void 0 ? void 0 : _b.httpOptions,
2460
+ httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
2461
+ abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
2465
2462
  })
2466
2463
  .then((httpResponse) => {
2467
2464
  return httpResponse.json();
@@ -2755,7 +2752,12 @@ class Chat {
2755
2752
  contents: this.getHistory(true).concat(inputContent),
2756
2753
  config: (_a = params.config) !== null && _a !== void 0 ? _a : this.config,
2757
2754
  });
2758
- this.sendPromise = streamResponse.then(() => undefined);
2755
+ // Resolve the internal tracking of send completion promise - `sendPromise`
2756
+ // for both success and failure response. The actual failure is still
2757
+ // propagated by the `await streamResponse`.
2758
+ this.sendPromise = streamResponse
2759
+ .then(() => undefined)
2760
+ .catch(() => undefined);
2759
2761
  const response = await streamResponse;
2760
2762
  const result = this.processStreamResponse(response, inputContent);
2761
2763
  return result;
@@ -3065,14 +3067,13 @@ function listFilesResponseFromMldev(apiClient, fromObject) {
3065
3067
  }
3066
3068
  const fromFiles = getValueByPath(fromObject, ['files']);
3067
3069
  if (fromFiles != null) {
3068
- if (Array.isArray(fromFiles)) {
3069
- setValueByPath(toObject, ['files'], fromFiles.map((item) => {
3070
+ let transformedList = fromFiles;
3071
+ if (Array.isArray(transformedList)) {
3072
+ transformedList = transformedList.map((item) => {
3070
3073
  return fileFromMldev(apiClient, item);
3071
- }));
3072
- }
3073
- else {
3074
- setValueByPath(toObject, ['files'], fromFiles);
3074
+ });
3075
3075
  }
3076
+ setValueByPath(toObject, ['files'], transformedList);
3076
3077
  }
3077
3078
  return toObject;
3078
3079
  }
@@ -3170,7 +3171,7 @@ class Files extends BaseModule {
3170
3171
  });
3171
3172
  }
3172
3173
  async listInternal(params) {
3173
- var _a;
3174
+ var _a, _b;
3174
3175
  let response;
3175
3176
  let path = '';
3176
3177
  let queryParams = {};
@@ -3191,6 +3192,7 @@ class Files extends BaseModule {
3191
3192
  body: JSON.stringify(body),
3192
3193
  httpMethod: 'GET',
3193
3194
  httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
3195
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
3194
3196
  })
3195
3197
  .then((httpResponse) => {
3196
3198
  return httpResponse.json();
@@ -3204,7 +3206,7 @@ class Files extends BaseModule {
3204
3206
  }
3205
3207
  }
3206
3208
  async createInternal(params) {
3207
- var _a;
3209
+ var _a, _b;
3208
3210
  let response;
3209
3211
  let path = '';
3210
3212
  let queryParams = {};
@@ -3225,6 +3227,7 @@ class Files extends BaseModule {
3225
3227
  body: JSON.stringify(body),
3226
3228
  httpMethod: 'POST',
3227
3229
  httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
3230
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
3228
3231
  })
3229
3232
  .then((httpResponse) => {
3230
3233
  return httpResponse.json();
@@ -3253,7 +3256,7 @@ class Files extends BaseModule {
3253
3256
  * ```
3254
3257
  */
3255
3258
  async get(params) {
3256
- var _a;
3259
+ var _a, _b;
3257
3260
  let response;
3258
3261
  let path = '';
3259
3262
  let queryParams = {};
@@ -3274,6 +3277,7 @@ class Files extends BaseModule {
3274
3277
  body: JSON.stringify(body),
3275
3278
  httpMethod: 'GET',
3276
3279
  httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
3280
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
3277
3281
  })
3278
3282
  .then((httpResponse) => {
3279
3283
  return httpResponse.json();
@@ -3298,7 +3302,7 @@ class Files extends BaseModule {
3298
3302
  * ```
3299
3303
  */
3300
3304
  async delete(params) {
3301
- var _a;
3305
+ var _a, _b;
3302
3306
  let response;
3303
3307
  let path = '';
3304
3308
  let queryParams = {};
@@ -3319,6 +3323,7 @@ class Files extends BaseModule {
3319
3323
  body: JSON.stringify(body),
3320
3324
  httpMethod: 'DELETE',
3321
3325
  httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
3326
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
3322
3327
  })
3323
3328
  .then((httpResponse) => {
3324
3329
  return httpResponse.json();
@@ -3435,14 +3440,13 @@ function contentToMldev$1(apiClient, fromObject) {
3435
3440
  const toObject = {};
3436
3441
  const fromParts = getValueByPath(fromObject, ['parts']);
3437
3442
  if (fromParts != null) {
3438
- if (Array.isArray(fromParts)) {
3439
- setValueByPath(toObject, ['parts'], fromParts.map((item) => {
3443
+ let transformedList = fromParts;
3444
+ if (Array.isArray(transformedList)) {
3445
+ transformedList = transformedList.map((item) => {
3440
3446
  return partToMldev$1(apiClient, item);
3441
- }));
3442
- }
3443
- else {
3444
- setValueByPath(toObject, ['parts'], fromParts);
3447
+ });
3445
3448
  }
3449
+ setValueByPath(toObject, ['parts'], transformedList);
3446
3450
  }
3447
3451
  const fromRole = getValueByPath(fromObject, ['role']);
3448
3452
  if (fromRole != null) {
@@ -3454,14 +3458,13 @@ function contentToVertex$1(apiClient, fromObject) {
3454
3458
  const toObject = {};
3455
3459
  const fromParts = getValueByPath(fromObject, ['parts']);
3456
3460
  if (fromParts != null) {
3457
- if (Array.isArray(fromParts)) {
3458
- setValueByPath(toObject, ['parts'], fromParts.map((item) => {
3461
+ let transformedList = fromParts;
3462
+ if (Array.isArray(transformedList)) {
3463
+ transformedList = transformedList.map((item) => {
3459
3464
  return partToVertex$1(apiClient, item);
3460
- }));
3461
- }
3462
- else {
3463
- setValueByPath(toObject, ['parts'], fromParts);
3465
+ });
3464
3466
  }
3467
+ setValueByPath(toObject, ['parts'], transformedList);
3465
3468
  }
3466
3469
  const fromRole = getValueByPath(fromObject, ['role']);
3467
3470
  if (fromRole != null) {
@@ -3469,162 +3472,25 @@ function contentToVertex$1(apiClient, fromObject) {
3469
3472
  }
3470
3473
  return toObject;
3471
3474
  }
3472
- function schemaToVertex$1(apiClient, fromObject) {
3475
+ function googleSearchToMldev$1() {
3473
3476
  const toObject = {};
3474
- const fromExample = getValueByPath(fromObject, ['example']);
3475
- if (fromExample != null) {
3476
- setValueByPath(toObject, ['example'], fromExample);
3477
- }
3478
- const fromPattern = getValueByPath(fromObject, ['pattern']);
3479
- if (fromPattern != null) {
3480
- setValueByPath(toObject, ['pattern'], fromPattern);
3481
- }
3482
- const fromDefault = getValueByPath(fromObject, ['default']);
3483
- if (fromDefault != null) {
3484
- setValueByPath(toObject, ['default'], fromDefault);
3485
- }
3486
- const fromMaxLength = getValueByPath(fromObject, ['maxLength']);
3487
- if (fromMaxLength != null) {
3488
- setValueByPath(toObject, ['maxLength'], fromMaxLength);
3489
- }
3490
- const fromMinLength = getValueByPath(fromObject, ['minLength']);
3491
- if (fromMinLength != null) {
3492
- setValueByPath(toObject, ['minLength'], fromMinLength);
3493
- }
3494
- const fromMinProperties = getValueByPath(fromObject, [
3495
- 'minProperties',
3496
- ]);
3497
- if (fromMinProperties != null) {
3498
- setValueByPath(toObject, ['minProperties'], fromMinProperties);
3477
+ return toObject;
3478
+ }
3479
+ function googleSearchToVertex$1() {
3480
+ const toObject = {};
3481
+ return toObject;
3482
+ }
3483
+ function dynamicRetrievalConfigToMldev$1(apiClient, fromObject) {
3484
+ const toObject = {};
3485
+ const fromMode = getValueByPath(fromObject, ['mode']);
3486
+ if (fromMode != null) {
3487
+ setValueByPath(toObject, ['mode'], fromMode);
3499
3488
  }
3500
- const fromMaxProperties = getValueByPath(fromObject, [
3501
- 'maxProperties',
3489
+ const fromDynamicThreshold = getValueByPath(fromObject, [
3490
+ 'dynamicThreshold',
3502
3491
  ]);
3503
- if (fromMaxProperties != null) {
3504
- setValueByPath(toObject, ['maxProperties'], fromMaxProperties);
3505
- }
3506
- const fromAnyOf = getValueByPath(fromObject, ['anyOf']);
3507
- if (fromAnyOf != null) {
3508
- setValueByPath(toObject, ['anyOf'], fromAnyOf);
3509
- }
3510
- const fromDescription = getValueByPath(fromObject, ['description']);
3511
- if (fromDescription != null) {
3512
- setValueByPath(toObject, ['description'], fromDescription);
3513
- }
3514
- const fromEnum = getValueByPath(fromObject, ['enum']);
3515
- if (fromEnum != null) {
3516
- setValueByPath(toObject, ['enum'], fromEnum);
3517
- }
3518
- const fromFormat = getValueByPath(fromObject, ['format']);
3519
- if (fromFormat != null) {
3520
- setValueByPath(toObject, ['format'], fromFormat);
3521
- }
3522
- const fromItems = getValueByPath(fromObject, ['items']);
3523
- if (fromItems != null) {
3524
- setValueByPath(toObject, ['items'], fromItems);
3525
- }
3526
- const fromMaxItems = getValueByPath(fromObject, ['maxItems']);
3527
- if (fromMaxItems != null) {
3528
- setValueByPath(toObject, ['maxItems'], fromMaxItems);
3529
- }
3530
- const fromMaximum = getValueByPath(fromObject, ['maximum']);
3531
- if (fromMaximum != null) {
3532
- setValueByPath(toObject, ['maximum'], fromMaximum);
3533
- }
3534
- const fromMinItems = getValueByPath(fromObject, ['minItems']);
3535
- if (fromMinItems != null) {
3536
- setValueByPath(toObject, ['minItems'], fromMinItems);
3537
- }
3538
- const fromMinimum = getValueByPath(fromObject, ['minimum']);
3539
- if (fromMinimum != null) {
3540
- setValueByPath(toObject, ['minimum'], fromMinimum);
3541
- }
3542
- const fromNullable = getValueByPath(fromObject, ['nullable']);
3543
- if (fromNullable != null) {
3544
- setValueByPath(toObject, ['nullable'], fromNullable);
3545
- }
3546
- const fromProperties = getValueByPath(fromObject, ['properties']);
3547
- if (fromProperties != null) {
3548
- setValueByPath(toObject, ['properties'], fromProperties);
3549
- }
3550
- const fromPropertyOrdering = getValueByPath(fromObject, [
3551
- 'propertyOrdering',
3552
- ]);
3553
- if (fromPropertyOrdering != null) {
3554
- setValueByPath(toObject, ['propertyOrdering'], fromPropertyOrdering);
3555
- }
3556
- const fromRequired = getValueByPath(fromObject, ['required']);
3557
- if (fromRequired != null) {
3558
- setValueByPath(toObject, ['required'], fromRequired);
3559
- }
3560
- const fromTitle = getValueByPath(fromObject, ['title']);
3561
- if (fromTitle != null) {
3562
- setValueByPath(toObject, ['title'], fromTitle);
3563
- }
3564
- const fromType = getValueByPath(fromObject, ['type']);
3565
- if (fromType != null) {
3566
- setValueByPath(toObject, ['type'], fromType);
3567
- }
3568
- return toObject;
3569
- }
3570
- function functionDeclarationToMldev$1(apiClient, fromObject) {
3571
- const toObject = {};
3572
- if (getValueByPath(fromObject, ['response']) !== undefined) {
3573
- throw new Error('response parameter is not supported in Gemini API.');
3574
- }
3575
- const fromDescription = getValueByPath(fromObject, ['description']);
3576
- if (fromDescription != null) {
3577
- setValueByPath(toObject, ['description'], fromDescription);
3578
- }
3579
- const fromName = getValueByPath(fromObject, ['name']);
3580
- if (fromName != null) {
3581
- setValueByPath(toObject, ['name'], fromName);
3582
- }
3583
- const fromParameters = getValueByPath(fromObject, ['parameters']);
3584
- if (fromParameters != null) {
3585
- setValueByPath(toObject, ['parameters'], fromParameters);
3586
- }
3587
- return toObject;
3588
- }
3589
- function functionDeclarationToVertex$1(apiClient, fromObject) {
3590
- const toObject = {};
3591
- const fromResponse = getValueByPath(fromObject, ['response']);
3592
- if (fromResponse != null) {
3593
- setValueByPath(toObject, ['response'], schemaToVertex$1(apiClient, fromResponse));
3594
- }
3595
- const fromDescription = getValueByPath(fromObject, ['description']);
3596
- if (fromDescription != null) {
3597
- setValueByPath(toObject, ['description'], fromDescription);
3598
- }
3599
- const fromName = getValueByPath(fromObject, ['name']);
3600
- if (fromName != null) {
3601
- setValueByPath(toObject, ['name'], fromName);
3602
- }
3603
- const fromParameters = getValueByPath(fromObject, ['parameters']);
3604
- if (fromParameters != null) {
3605
- setValueByPath(toObject, ['parameters'], fromParameters);
3606
- }
3607
- return toObject;
3608
- }
3609
- function googleSearchToMldev$1() {
3610
- const toObject = {};
3611
- return toObject;
3612
- }
3613
- function googleSearchToVertex$1() {
3614
- const toObject = {};
3615
- return toObject;
3616
- }
3617
- function dynamicRetrievalConfigToMldev$1(apiClient, fromObject) {
3618
- const toObject = {};
3619
- const fromMode = getValueByPath(fromObject, ['mode']);
3620
- if (fromMode != null) {
3621
- setValueByPath(toObject, ['mode'], fromMode);
3622
- }
3623
- const fromDynamicThreshold = getValueByPath(fromObject, [
3624
- 'dynamicThreshold',
3625
- ]);
3626
- if (fromDynamicThreshold != null) {
3627
- setValueByPath(toObject, ['dynamicThreshold'], fromDynamicThreshold);
3492
+ if (fromDynamicThreshold != null) {
3493
+ setValueByPath(toObject, ['dynamicThreshold'], fromDynamicThreshold);
3628
3494
  }
3629
3495
  return toObject;
3630
3496
  }
@@ -3664,19 +3530,6 @@ function googleSearchRetrievalToVertex$1(apiClient, fromObject) {
3664
3530
  }
3665
3531
  function toolToMldev$1(apiClient, fromObject) {
3666
3532
  const toObject = {};
3667
- const fromFunctionDeclarations = getValueByPath(fromObject, [
3668
- 'functionDeclarations',
3669
- ]);
3670
- if (fromFunctionDeclarations != null) {
3671
- if (Array.isArray(fromFunctionDeclarations)) {
3672
- setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations.map((item) => {
3673
- return functionDeclarationToMldev$1(apiClient, item);
3674
- }));
3675
- }
3676
- else {
3677
- setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
3678
- }
3679
- }
3680
3533
  if (getValueByPath(fromObject, ['retrieval']) !== undefined) {
3681
3534
  throw new Error('retrieval parameter is not supported in Gemini API.');
3682
3535
  }
@@ -3696,23 +3549,16 @@ function toolToMldev$1(apiClient, fromObject) {
3696
3549
  if (fromCodeExecution != null) {
3697
3550
  setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
3698
3551
  }
3699
- return toObject;
3700
- }
3701
- function toolToVertex$1(apiClient, fromObject) {
3702
- const toObject = {};
3703
3552
  const fromFunctionDeclarations = getValueByPath(fromObject, [
3704
3553
  'functionDeclarations',
3705
3554
  ]);
3706
3555
  if (fromFunctionDeclarations != null) {
3707
- if (Array.isArray(fromFunctionDeclarations)) {
3708
- setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations.map((item) => {
3709
- return functionDeclarationToVertex$1(apiClient, item);
3710
- }));
3711
- }
3712
- else {
3713
- setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
3714
- }
3556
+ setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
3715
3557
  }
3558
+ return toObject;
3559
+ }
3560
+ function toolToVertex$1(apiClient, fromObject) {
3561
+ const toObject = {};
3716
3562
  const fromRetrieval = getValueByPath(fromObject, ['retrieval']);
3717
3563
  if (fromRetrieval != null) {
3718
3564
  setValueByPath(toObject, ['retrieval'], fromRetrieval);
@@ -3733,6 +3579,12 @@ function toolToVertex$1(apiClient, fromObject) {
3733
3579
  if (fromCodeExecution != null) {
3734
3580
  setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
3735
3581
  }
3582
+ const fromFunctionDeclarations = getValueByPath(fromObject, [
3583
+ 'functionDeclarations',
3584
+ ]);
3585
+ if (fromFunctionDeclarations != null) {
3586
+ setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
3587
+ }
3736
3588
  return toObject;
3737
3589
  }
3738
3590
  function sessionResumptionConfigToMldev(apiClient, fromObject) {
@@ -3972,14 +3824,13 @@ function liveConnectConfigToMldev(apiClient, fromObject, parentObject) {
3972
3824
  }
3973
3825
  const fromTools = getValueByPath(fromObject, ['tools']);
3974
3826
  if (parentObject !== undefined && fromTools != null) {
3975
- if (Array.isArray(fromTools)) {
3976
- setValueByPath(parentObject, ['setup', 'tools'], tTools(apiClient, tTools(apiClient, fromTools).map((item) => {
3827
+ let transformedList = tTools(apiClient, fromTools);
3828
+ if (Array.isArray(transformedList)) {
3829
+ transformedList = transformedList.map((item) => {
3977
3830
  return toolToMldev$1(apiClient, tTool(apiClient, item));
3978
- })));
3979
- }
3980
- else {
3981
- setValueByPath(parentObject, ['setup', 'tools'], tTools(apiClient, fromTools));
3831
+ });
3982
3832
  }
3833
+ setValueByPath(parentObject, ['setup', 'tools'], transformedList);
3983
3834
  }
3984
3835
  const fromSessionResumption = getValueByPath(fromObject, [
3985
3836
  'sessionResumption',
@@ -4064,14 +3915,13 @@ function liveConnectConfigToVertex(apiClient, fromObject, parentObject) {
4064
3915
  }
4065
3916
  const fromTools = getValueByPath(fromObject, ['tools']);
4066
3917
  if (parentObject !== undefined && fromTools != null) {
4067
- if (Array.isArray(fromTools)) {
4068
- setValueByPath(parentObject, ['setup', 'tools'], tTools(apiClient, tTools(apiClient, fromTools).map((item) => {
3918
+ let transformedList = tTools(apiClient, fromTools);
3919
+ if (Array.isArray(transformedList)) {
3920
+ transformedList = transformedList.map((item) => {
4069
3921
  return toolToVertex$1(apiClient, tTool(apiClient, item));
4070
- })));
4071
- }
4072
- else {
4073
- setValueByPath(parentObject, ['setup', 'tools'], tTools(apiClient, fromTools));
3922
+ });
4074
3923
  }
3924
+ setValueByPath(parentObject, ['setup', 'tools'], transformedList);
4075
3925
  }
4076
3926
  const fromSessionResumption = getValueByPath(fromObject, [
4077
3927
  'sessionResumption',
@@ -4129,6 +3979,91 @@ function liveConnectParametersToVertex(apiClient, fromObject) {
4129
3979
  }
4130
3980
  return toObject;
4131
3981
  }
3982
+ function activityStartToMldev() {
3983
+ const toObject = {};
3984
+ return toObject;
3985
+ }
3986
+ function activityStartToVertex() {
3987
+ const toObject = {};
3988
+ return toObject;
3989
+ }
3990
+ function activityEndToMldev() {
3991
+ const toObject = {};
3992
+ return toObject;
3993
+ }
3994
+ function activityEndToVertex() {
3995
+ const toObject = {};
3996
+ return toObject;
3997
+ }
3998
+ function liveSendRealtimeInputParametersToMldev(apiClient, fromObject) {
3999
+ const toObject = {};
4000
+ const fromMedia = getValueByPath(fromObject, ['media']);
4001
+ if (fromMedia != null) {
4002
+ setValueByPath(toObject, ['mediaChunks'], tBlobs(apiClient, fromMedia));
4003
+ }
4004
+ const fromAudio = getValueByPath(fromObject, ['audio']);
4005
+ if (fromAudio != null) {
4006
+ setValueByPath(toObject, ['audio'], tAudioBlob(apiClient, fromAudio));
4007
+ }
4008
+ const fromAudioStreamEnd = getValueByPath(fromObject, [
4009
+ 'audioStreamEnd',
4010
+ ]);
4011
+ if (fromAudioStreamEnd != null) {
4012
+ setValueByPath(toObject, ['audioStreamEnd'], fromAudioStreamEnd);
4013
+ }
4014
+ const fromVideo = getValueByPath(fromObject, ['video']);
4015
+ if (fromVideo != null) {
4016
+ setValueByPath(toObject, ['video'], tImageBlob(apiClient, fromVideo));
4017
+ }
4018
+ const fromText = getValueByPath(fromObject, ['text']);
4019
+ if (fromText != null) {
4020
+ setValueByPath(toObject, ['text'], fromText);
4021
+ }
4022
+ const fromActivityStart = getValueByPath(fromObject, [
4023
+ 'activityStart',
4024
+ ]);
4025
+ if (fromActivityStart != null) {
4026
+ setValueByPath(toObject, ['activityStart'], activityStartToMldev());
4027
+ }
4028
+ const fromActivityEnd = getValueByPath(fromObject, ['activityEnd']);
4029
+ if (fromActivityEnd != null) {
4030
+ setValueByPath(toObject, ['activityEnd'], activityEndToMldev());
4031
+ }
4032
+ return toObject;
4033
+ }
4034
+ function liveSendRealtimeInputParametersToVertex(apiClient, fromObject) {
4035
+ const toObject = {};
4036
+ const fromMedia = getValueByPath(fromObject, ['media']);
4037
+ if (fromMedia != null) {
4038
+ setValueByPath(toObject, ['mediaChunks'], tBlobs(apiClient, fromMedia));
4039
+ }
4040
+ if (getValueByPath(fromObject, ['audio']) !== undefined) {
4041
+ throw new Error('audio parameter is not supported in Vertex AI.');
4042
+ }
4043
+ const fromAudioStreamEnd = getValueByPath(fromObject, [
4044
+ 'audioStreamEnd',
4045
+ ]);
4046
+ if (fromAudioStreamEnd != null) {
4047
+ setValueByPath(toObject, ['audioStreamEnd'], fromAudioStreamEnd);
4048
+ }
4049
+ if (getValueByPath(fromObject, ['video']) !== undefined) {
4050
+ throw new Error('video parameter is not supported in Vertex AI.');
4051
+ }
4052
+ if (getValueByPath(fromObject, ['text']) !== undefined) {
4053
+ throw new Error('text parameter is not supported in Vertex AI.');
4054
+ }
4055
+ const fromActivityStart = getValueByPath(fromObject, [
4056
+ 'activityStart',
4057
+ ]);
4058
+ if (fromActivityStart != null) {
4059
+ setValueByPath(toObject, ['activityStart'], activityStartToVertex());
4060
+ }
4061
+ const fromActivityEnd = getValueByPath(fromObject, ['activityEnd']);
4062
+ if (fromActivityEnd != null) {
4063
+ setValueByPath(toObject, ['activityEnd'], activityEndToVertex());
4064
+ }
4065
+ return toObject;
4066
+ }
4132
4067
  function liveServerSetupCompleteFromMldev() {
4133
4068
  const toObject = {};
4134
4069
  return toObject;
@@ -4231,14 +4166,13 @@ function contentFromMldev$1(apiClient, fromObject) {
4231
4166
  const toObject = {};
4232
4167
  const fromParts = getValueByPath(fromObject, ['parts']);
4233
4168
  if (fromParts != null) {
4234
- if (Array.isArray(fromParts)) {
4235
- setValueByPath(toObject, ['parts'], fromParts.map((item) => {
4169
+ let transformedList = fromParts;
4170
+ if (Array.isArray(transformedList)) {
4171
+ transformedList = transformedList.map((item) => {
4236
4172
  return partFromMldev$1(apiClient, item);
4237
- }));
4238
- }
4239
- else {
4240
- setValueByPath(toObject, ['parts'], fromParts);
4173
+ });
4241
4174
  }
4175
+ setValueByPath(toObject, ['parts'], transformedList);
4242
4176
  }
4243
4177
  const fromRole = getValueByPath(fromObject, ['role']);
4244
4178
  if (fromRole != null) {
@@ -4250,14 +4184,13 @@ function contentFromVertex$1(apiClient, fromObject) {
4250
4184
  const toObject = {};
4251
4185
  const fromParts = getValueByPath(fromObject, ['parts']);
4252
4186
  if (fromParts != null) {
4253
- if (Array.isArray(fromParts)) {
4254
- setValueByPath(toObject, ['parts'], fromParts.map((item) => {
4187
+ let transformedList = fromParts;
4188
+ if (Array.isArray(transformedList)) {
4189
+ transformedList = transformedList.map((item) => {
4255
4190
  return partFromVertex$1(apiClient, item);
4256
- }));
4257
- }
4258
- else {
4259
- setValueByPath(toObject, ['parts'], fromParts);
4191
+ });
4260
4192
  }
4193
+ setValueByPath(toObject, ['parts'], transformedList);
4261
4194
  }
4262
4195
  const fromRole = getValueByPath(fromObject, ['role']);
4263
4196
  if (fromRole != null) {
@@ -4391,14 +4324,13 @@ function liveServerToolCallFromMldev(apiClient, fromObject) {
4391
4324
  'functionCalls',
4392
4325
  ]);
4393
4326
  if (fromFunctionCalls != null) {
4394
- if (Array.isArray(fromFunctionCalls)) {
4395
- setValueByPath(toObject, ['functionCalls'], fromFunctionCalls.map((item) => {
4327
+ let transformedList = fromFunctionCalls;
4328
+ if (Array.isArray(transformedList)) {
4329
+ transformedList = transformedList.map((item) => {
4396
4330
  return functionCallFromMldev(apiClient, item);
4397
- }));
4398
- }
4399
- else {
4400
- setValueByPath(toObject, ['functionCalls'], fromFunctionCalls);
4331
+ });
4401
4332
  }
4333
+ setValueByPath(toObject, ['functionCalls'], transformedList);
4402
4334
  }
4403
4335
  return toObject;
4404
4336
  }
@@ -4408,14 +4340,13 @@ function liveServerToolCallFromVertex(apiClient, fromObject) {
4408
4340
  'functionCalls',
4409
4341
  ]);
4410
4342
  if (fromFunctionCalls != null) {
4411
- if (Array.isArray(fromFunctionCalls)) {
4412
- setValueByPath(toObject, ['functionCalls'], fromFunctionCalls.map((item) => {
4343
+ let transformedList = fromFunctionCalls;
4344
+ if (Array.isArray(transformedList)) {
4345
+ transformedList = transformedList.map((item) => {
4413
4346
  return functionCallFromVertex(apiClient, item);
4414
- }));
4415
- }
4416
- else {
4417
- setValueByPath(toObject, ['functionCalls'], fromFunctionCalls);
4347
+ });
4418
4348
  }
4349
+ setValueByPath(toObject, ['functionCalls'], transformedList);
4419
4350
  }
4420
4351
  return toObject;
4421
4352
  }
@@ -4501,53 +4432,49 @@ function usageMetadataFromMldev(apiClient, fromObject) {
4501
4432
  'promptTokensDetails',
4502
4433
  ]);
4503
4434
  if (fromPromptTokensDetails != null) {
4504
- if (Array.isArray(fromPromptTokensDetails)) {
4505
- setValueByPath(toObject, ['promptTokensDetails'], fromPromptTokensDetails.map((item) => {
4435
+ let transformedList = fromPromptTokensDetails;
4436
+ if (Array.isArray(transformedList)) {
4437
+ transformedList = transformedList.map((item) => {
4506
4438
  return modalityTokenCountFromMldev(apiClient, item);
4507
- }));
4508
- }
4509
- else {
4510
- setValueByPath(toObject, ['promptTokensDetails'], fromPromptTokensDetails);
4439
+ });
4511
4440
  }
4441
+ setValueByPath(toObject, ['promptTokensDetails'], transformedList);
4512
4442
  }
4513
4443
  const fromCacheTokensDetails = getValueByPath(fromObject, [
4514
4444
  'cacheTokensDetails',
4515
4445
  ]);
4516
4446
  if (fromCacheTokensDetails != null) {
4517
- if (Array.isArray(fromCacheTokensDetails)) {
4518
- setValueByPath(toObject, ['cacheTokensDetails'], fromCacheTokensDetails.map((item) => {
4447
+ let transformedList = fromCacheTokensDetails;
4448
+ if (Array.isArray(transformedList)) {
4449
+ transformedList = transformedList.map((item) => {
4519
4450
  return modalityTokenCountFromMldev(apiClient, item);
4520
- }));
4521
- }
4522
- else {
4523
- setValueByPath(toObject, ['cacheTokensDetails'], fromCacheTokensDetails);
4451
+ });
4524
4452
  }
4453
+ setValueByPath(toObject, ['cacheTokensDetails'], transformedList);
4525
4454
  }
4526
4455
  const fromResponseTokensDetails = getValueByPath(fromObject, [
4527
4456
  'responseTokensDetails',
4528
4457
  ]);
4529
4458
  if (fromResponseTokensDetails != null) {
4530
- if (Array.isArray(fromResponseTokensDetails)) {
4531
- setValueByPath(toObject, ['responseTokensDetails'], fromResponseTokensDetails.map((item) => {
4459
+ let transformedList = fromResponseTokensDetails;
4460
+ if (Array.isArray(transformedList)) {
4461
+ transformedList = transformedList.map((item) => {
4532
4462
  return modalityTokenCountFromMldev(apiClient, item);
4533
- }));
4534
- }
4535
- else {
4536
- setValueByPath(toObject, ['responseTokensDetails'], fromResponseTokensDetails);
4463
+ });
4537
4464
  }
4465
+ setValueByPath(toObject, ['responseTokensDetails'], transformedList);
4538
4466
  }
4539
4467
  const fromToolUsePromptTokensDetails = getValueByPath(fromObject, [
4540
4468
  'toolUsePromptTokensDetails',
4541
4469
  ]);
4542
4470
  if (fromToolUsePromptTokensDetails != null) {
4543
- if (Array.isArray(fromToolUsePromptTokensDetails)) {
4544
- setValueByPath(toObject, ['toolUsePromptTokensDetails'], fromToolUsePromptTokensDetails.map((item) => {
4471
+ let transformedList = fromToolUsePromptTokensDetails;
4472
+ if (Array.isArray(transformedList)) {
4473
+ transformedList = transformedList.map((item) => {
4545
4474
  return modalityTokenCountFromMldev(apiClient, item);
4546
- }));
4547
- }
4548
- else {
4549
- setValueByPath(toObject, ['toolUsePromptTokensDetails'], fromToolUsePromptTokensDetails);
4475
+ });
4550
4476
  }
4477
+ setValueByPath(toObject, ['toolUsePromptTokensDetails'], transformedList);
4551
4478
  }
4552
4479
  return toObject;
4553
4480
  }
@@ -4593,53 +4520,49 @@ function usageMetadataFromVertex(apiClient, fromObject) {
4593
4520
  'promptTokensDetails',
4594
4521
  ]);
4595
4522
  if (fromPromptTokensDetails != null) {
4596
- if (Array.isArray(fromPromptTokensDetails)) {
4597
- setValueByPath(toObject, ['promptTokensDetails'], fromPromptTokensDetails.map((item) => {
4523
+ let transformedList = fromPromptTokensDetails;
4524
+ if (Array.isArray(transformedList)) {
4525
+ transformedList = transformedList.map((item) => {
4598
4526
  return modalityTokenCountFromVertex(apiClient, item);
4599
- }));
4600
- }
4601
- else {
4602
- setValueByPath(toObject, ['promptTokensDetails'], fromPromptTokensDetails);
4527
+ });
4603
4528
  }
4529
+ setValueByPath(toObject, ['promptTokensDetails'], transformedList);
4604
4530
  }
4605
4531
  const fromCacheTokensDetails = getValueByPath(fromObject, [
4606
4532
  'cacheTokensDetails',
4607
4533
  ]);
4608
4534
  if (fromCacheTokensDetails != null) {
4609
- if (Array.isArray(fromCacheTokensDetails)) {
4610
- setValueByPath(toObject, ['cacheTokensDetails'], fromCacheTokensDetails.map((item) => {
4535
+ let transformedList = fromCacheTokensDetails;
4536
+ if (Array.isArray(transformedList)) {
4537
+ transformedList = transformedList.map((item) => {
4611
4538
  return modalityTokenCountFromVertex(apiClient, item);
4612
- }));
4613
- }
4614
- else {
4615
- setValueByPath(toObject, ['cacheTokensDetails'], fromCacheTokensDetails);
4539
+ });
4616
4540
  }
4541
+ setValueByPath(toObject, ['cacheTokensDetails'], transformedList);
4617
4542
  }
4618
4543
  const fromResponseTokensDetails = getValueByPath(fromObject, [
4619
4544
  'candidatesTokensDetails',
4620
4545
  ]);
4621
4546
  if (fromResponseTokensDetails != null) {
4622
- if (Array.isArray(fromResponseTokensDetails)) {
4623
- setValueByPath(toObject, ['responseTokensDetails'], fromResponseTokensDetails.map((item) => {
4547
+ let transformedList = fromResponseTokensDetails;
4548
+ if (Array.isArray(transformedList)) {
4549
+ transformedList = transformedList.map((item) => {
4624
4550
  return modalityTokenCountFromVertex(apiClient, item);
4625
- }));
4626
- }
4627
- else {
4628
- setValueByPath(toObject, ['responseTokensDetails'], fromResponseTokensDetails);
4551
+ });
4629
4552
  }
4553
+ setValueByPath(toObject, ['responseTokensDetails'], transformedList);
4630
4554
  }
4631
4555
  const fromToolUsePromptTokensDetails = getValueByPath(fromObject, [
4632
4556
  'toolUsePromptTokensDetails',
4633
4557
  ]);
4634
4558
  if (fromToolUsePromptTokensDetails != null) {
4635
- if (Array.isArray(fromToolUsePromptTokensDetails)) {
4636
- setValueByPath(toObject, ['toolUsePromptTokensDetails'], fromToolUsePromptTokensDetails.map((item) => {
4559
+ let transformedList = fromToolUsePromptTokensDetails;
4560
+ if (Array.isArray(transformedList)) {
4561
+ transformedList = transformedList.map((item) => {
4637
4562
  return modalityTokenCountFromVertex(apiClient, item);
4638
- }));
4639
- }
4640
- else {
4641
- setValueByPath(toObject, ['toolUsePromptTokensDetails'], fromToolUsePromptTokensDetails);
4563
+ });
4642
4564
  }
4565
+ setValueByPath(toObject, ['toolUsePromptTokensDetails'], transformedList);
4643
4566
  }
4644
4567
  const fromTrafficType = getValueByPath(fromObject, ['trafficType']);
4645
4568
  if (fromTrafficType != null) {
@@ -4838,14 +4761,13 @@ function contentToMldev(apiClient, fromObject) {
4838
4761
  const toObject = {};
4839
4762
  const fromParts = getValueByPath(fromObject, ['parts']);
4840
4763
  if (fromParts != null) {
4841
- if (Array.isArray(fromParts)) {
4842
- setValueByPath(toObject, ['parts'], fromParts.map((item) => {
4764
+ let transformedList = fromParts;
4765
+ if (Array.isArray(transformedList)) {
4766
+ transformedList = transformedList.map((item) => {
4843
4767
  return partToMldev(apiClient, item);
4844
- }));
4845
- }
4846
- else {
4847
- setValueByPath(toObject, ['parts'], fromParts);
4768
+ });
4848
4769
  }
4770
+ setValueByPath(toObject, ['parts'], transformedList);
4849
4771
  }
4850
4772
  const fromRole = getValueByPath(fromObject, ['role']);
4851
4773
  if (fromRole != null) {
@@ -4853,93 +4775,6 @@ function contentToMldev(apiClient, fromObject) {
4853
4775
  }
4854
4776
  return toObject;
4855
4777
  }
4856
- function schemaToMldev(apiClient, fromObject) {
4857
- const toObject = {};
4858
- if (getValueByPath(fromObject, ['example']) !== undefined) {
4859
- throw new Error('example parameter is not supported in Gemini API.');
4860
- }
4861
- if (getValueByPath(fromObject, ['pattern']) !== undefined) {
4862
- throw new Error('pattern parameter is not supported in Gemini API.');
4863
- }
4864
- if (getValueByPath(fromObject, ['default']) !== undefined) {
4865
- throw new Error('default parameter is not supported in Gemini API.');
4866
- }
4867
- if (getValueByPath(fromObject, ['maxLength']) !== undefined) {
4868
- throw new Error('maxLength parameter is not supported in Gemini API.');
4869
- }
4870
- if (getValueByPath(fromObject, ['minLength']) !== undefined) {
4871
- throw new Error('minLength parameter is not supported in Gemini API.');
4872
- }
4873
- if (getValueByPath(fromObject, ['minProperties']) !== undefined) {
4874
- throw new Error('minProperties parameter is not supported in Gemini API.');
4875
- }
4876
- if (getValueByPath(fromObject, ['maxProperties']) !== undefined) {
4877
- throw new Error('maxProperties parameter is not supported in Gemini API.');
4878
- }
4879
- const fromAnyOf = getValueByPath(fromObject, ['anyOf']);
4880
- if (fromAnyOf != null) {
4881
- setValueByPath(toObject, ['anyOf'], fromAnyOf);
4882
- }
4883
- const fromDescription = getValueByPath(fromObject, ['description']);
4884
- if (fromDescription != null) {
4885
- setValueByPath(toObject, ['description'], fromDescription);
4886
- }
4887
- const fromEnum = getValueByPath(fromObject, ['enum']);
4888
- if (fromEnum != null) {
4889
- setValueByPath(toObject, ['enum'], fromEnum);
4890
- }
4891
- const fromFormat = getValueByPath(fromObject, ['format']);
4892
- if (fromFormat != null) {
4893
- setValueByPath(toObject, ['format'], fromFormat);
4894
- }
4895
- const fromItems = getValueByPath(fromObject, ['items']);
4896
- if (fromItems != null) {
4897
- setValueByPath(toObject, ['items'], fromItems);
4898
- }
4899
- const fromMaxItems = getValueByPath(fromObject, ['maxItems']);
4900
- if (fromMaxItems != null) {
4901
- setValueByPath(toObject, ['maxItems'], fromMaxItems);
4902
- }
4903
- const fromMaximum = getValueByPath(fromObject, ['maximum']);
4904
- if (fromMaximum != null) {
4905
- setValueByPath(toObject, ['maximum'], fromMaximum);
4906
- }
4907
- const fromMinItems = getValueByPath(fromObject, ['minItems']);
4908
- if (fromMinItems != null) {
4909
- setValueByPath(toObject, ['minItems'], fromMinItems);
4910
- }
4911
- const fromMinimum = getValueByPath(fromObject, ['minimum']);
4912
- if (fromMinimum != null) {
4913
- setValueByPath(toObject, ['minimum'], fromMinimum);
4914
- }
4915
- const fromNullable = getValueByPath(fromObject, ['nullable']);
4916
- if (fromNullable != null) {
4917
- setValueByPath(toObject, ['nullable'], fromNullable);
4918
- }
4919
- const fromProperties = getValueByPath(fromObject, ['properties']);
4920
- if (fromProperties != null) {
4921
- setValueByPath(toObject, ['properties'], fromProperties);
4922
- }
4923
- const fromPropertyOrdering = getValueByPath(fromObject, [
4924
- 'propertyOrdering',
4925
- ]);
4926
- if (fromPropertyOrdering != null) {
4927
- setValueByPath(toObject, ['propertyOrdering'], fromPropertyOrdering);
4928
- }
4929
- const fromRequired = getValueByPath(fromObject, ['required']);
4930
- if (fromRequired != null) {
4931
- setValueByPath(toObject, ['required'], fromRequired);
4932
- }
4933
- const fromTitle = getValueByPath(fromObject, ['title']);
4934
- if (fromTitle != null) {
4935
- setValueByPath(toObject, ['title'], fromTitle);
4936
- }
4937
- const fromType = getValueByPath(fromObject, ['type']);
4938
- if (fromType != null) {
4939
- setValueByPath(toObject, ['type'], fromType);
4940
- }
4941
- return toObject;
4942
- }
4943
4778
  function safetySettingToMldev(apiClient, fromObject) {
4944
4779
  const toObject = {};
4945
4780
  if (getValueByPath(fromObject, ['method']) !== undefined) {
@@ -4955,25 +4790,6 @@ function safetySettingToMldev(apiClient, fromObject) {
4955
4790
  }
4956
4791
  return toObject;
4957
4792
  }
4958
- function functionDeclarationToMldev(apiClient, fromObject) {
4959
- const toObject = {};
4960
- if (getValueByPath(fromObject, ['response']) !== undefined) {
4961
- throw new Error('response parameter is not supported in Gemini API.');
4962
- }
4963
- const fromDescription = getValueByPath(fromObject, ['description']);
4964
- if (fromDescription != null) {
4965
- setValueByPath(toObject, ['description'], fromDescription);
4966
- }
4967
- const fromName = getValueByPath(fromObject, ['name']);
4968
- if (fromName != null) {
4969
- setValueByPath(toObject, ['name'], fromName);
4970
- }
4971
- const fromParameters = getValueByPath(fromObject, ['parameters']);
4972
- if (fromParameters != null) {
4973
- setValueByPath(toObject, ['parameters'], fromParameters);
4974
- }
4975
- return toObject;
4976
- }
4977
4793
  function googleSearchToMldev() {
4978
4794
  const toObject = {};
4979
4795
  return toObject;
@@ -5004,19 +4820,6 @@ function googleSearchRetrievalToMldev(apiClient, fromObject) {
5004
4820
  }
5005
4821
  function toolToMldev(apiClient, fromObject) {
5006
4822
  const toObject = {};
5007
- const fromFunctionDeclarations = getValueByPath(fromObject, [
5008
- 'functionDeclarations',
5009
- ]);
5010
- if (fromFunctionDeclarations != null) {
5011
- if (Array.isArray(fromFunctionDeclarations)) {
5012
- setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations.map((item) => {
5013
- return functionDeclarationToMldev(apiClient, item);
5014
- }));
5015
- }
5016
- else {
5017
- setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
5018
- }
5019
- }
5020
4823
  if (getValueByPath(fromObject, ['retrieval']) !== undefined) {
5021
4824
  throw new Error('retrieval parameter is not supported in Gemini API.');
5022
4825
  }
@@ -5036,6 +4839,12 @@ function toolToMldev(apiClient, fromObject) {
5036
4839
  if (fromCodeExecution != null) {
5037
4840
  setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
5038
4841
  }
4842
+ const fromFunctionDeclarations = getValueByPath(fromObject, [
4843
+ 'functionDeclarations',
4844
+ ]);
4845
+ if (fromFunctionDeclarations != null) {
4846
+ setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
4847
+ }
5039
4848
  return toObject;
5040
4849
  }
5041
4850
  function functionCallingConfigToMldev(apiClient, fromObject) {
@@ -5182,7 +4991,7 @@ function generateContentConfigToMldev(apiClient, fromObject, parentObject) {
5182
4991
  'responseSchema',
5183
4992
  ]);
5184
4993
  if (fromResponseSchema != null) {
5185
- setValueByPath(toObject, ['responseSchema'], schemaToMldev(apiClient, tSchema(apiClient, fromResponseSchema)));
4994
+ setValueByPath(toObject, ['responseSchema'], tSchema(apiClient, fromResponseSchema));
5186
4995
  }
5187
4996
  if (getValueByPath(fromObject, ['routingConfig']) !== undefined) {
5188
4997
  throw new Error('routingConfig parameter is not supported in Gemini API.');
@@ -5194,25 +5003,23 @@ function generateContentConfigToMldev(apiClient, fromObject, parentObject) {
5194
5003
  'safetySettings',
5195
5004
  ]);
5196
5005
  if (parentObject !== undefined && fromSafetySettings != null) {
5197
- if (Array.isArray(fromSafetySettings)) {
5198
- setValueByPath(parentObject, ['safetySettings'], fromSafetySettings.map((item) => {
5006
+ let transformedList = fromSafetySettings;
5007
+ if (Array.isArray(transformedList)) {
5008
+ transformedList = transformedList.map((item) => {
5199
5009
  return safetySettingToMldev(apiClient, item);
5200
- }));
5201
- }
5202
- else {
5203
- setValueByPath(parentObject, ['safetySettings'], fromSafetySettings);
5010
+ });
5204
5011
  }
5012
+ setValueByPath(parentObject, ['safetySettings'], transformedList);
5205
5013
  }
5206
5014
  const fromTools = getValueByPath(fromObject, ['tools']);
5207
5015
  if (parentObject !== undefined && fromTools != null) {
5208
- if (Array.isArray(fromTools)) {
5209
- setValueByPath(parentObject, ['tools'], tTools(apiClient, tTools(apiClient, fromTools).map((item) => {
5016
+ let transformedList = tTools(apiClient, fromTools);
5017
+ if (Array.isArray(transformedList)) {
5018
+ transformedList = transformedList.map((item) => {
5210
5019
  return toolToMldev(apiClient, tTool(apiClient, item));
5211
- })));
5212
- }
5213
- else {
5214
- setValueByPath(parentObject, ['tools'], tTools(apiClient, fromTools));
5020
+ });
5215
5021
  }
5022
+ setValueByPath(parentObject, ['tools'], transformedList);
5216
5023
  }
5217
5024
  const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
5218
5025
  if (parentObject !== undefined && fromToolConfig != null) {
@@ -5262,14 +5069,13 @@ function generateContentParametersToMldev(apiClient, fromObject) {
5262
5069
  }
5263
5070
  const fromContents = getValueByPath(fromObject, ['contents']);
5264
5071
  if (fromContents != null) {
5265
- if (Array.isArray(fromContents)) {
5266
- setValueByPath(toObject, ['contents'], tContents(apiClient, tContents(apiClient, fromContents).map((item) => {
5072
+ let transformedList = tContents(apiClient, fromContents);
5073
+ if (Array.isArray(transformedList)) {
5074
+ transformedList = transformedList.map((item) => {
5267
5075
  return contentToMldev(apiClient, item);
5268
- })));
5269
- }
5270
- else {
5271
- setValueByPath(toObject, ['contents'], tContents(apiClient, fromContents));
5076
+ });
5272
5077
  }
5078
+ setValueByPath(toObject, ['contents'], transformedList);
5273
5079
  }
5274
5080
  const fromConfig = getValueByPath(fromObject, ['config']);
5275
5081
  if (fromConfig != null) {
@@ -5424,35 +5230,70 @@ function getModelParametersToMldev(apiClient, fromObject) {
5424
5230
  }
5425
5231
  return toObject;
5426
5232
  }
5427
- function countTokensConfigToMldev(apiClient, fromObject) {
5233
+ function updateModelConfigToMldev(apiClient, fromObject, parentObject) {
5428
5234
  const toObject = {};
5429
- if (getValueByPath(fromObject, ['systemInstruction']) !== undefined) {
5430
- throw new Error('systemInstruction parameter is not supported in Gemini API.');
5431
- }
5432
- if (getValueByPath(fromObject, ['tools']) !== undefined) {
5433
- throw new Error('tools parameter is not supported in Gemini API.');
5235
+ const fromDisplayName = getValueByPath(fromObject, ['displayName']);
5236
+ if (parentObject !== undefined && fromDisplayName != null) {
5237
+ setValueByPath(parentObject, ['displayName'], fromDisplayName);
5434
5238
  }
5435
- if (getValueByPath(fromObject, ['generationConfig']) !== undefined) {
5436
- throw new Error('generationConfig parameter is not supported in Gemini API.');
5239
+ const fromDescription = getValueByPath(fromObject, ['description']);
5240
+ if (parentObject !== undefined && fromDescription != null) {
5241
+ setValueByPath(parentObject, ['description'], fromDescription);
5437
5242
  }
5438
5243
  return toObject;
5439
5244
  }
5440
- function countTokensParametersToMldev(apiClient, fromObject) {
5245
+ function updateModelParametersToMldev(apiClient, fromObject) {
5441
5246
  const toObject = {};
5442
5247
  const fromModel = getValueByPath(fromObject, ['model']);
5443
5248
  if (fromModel != null) {
5444
- setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
5249
+ setValueByPath(toObject, ['_url', 'name'], tModel(apiClient, fromModel));
5250
+ }
5251
+ const fromConfig = getValueByPath(fromObject, ['config']);
5252
+ if (fromConfig != null) {
5253
+ setValueByPath(toObject, ['config'], updateModelConfigToMldev(apiClient, fromConfig, toObject));
5254
+ }
5255
+ return toObject;
5256
+ }
5257
+ function deleteModelParametersToMldev(apiClient, fromObject) {
5258
+ const toObject = {};
5259
+ const fromModel = getValueByPath(fromObject, ['model']);
5260
+ if (fromModel != null) {
5261
+ setValueByPath(toObject, ['_url', 'name'], tModel(apiClient, fromModel));
5262
+ }
5263
+ const fromConfig = getValueByPath(fromObject, ['config']);
5264
+ if (fromConfig != null) {
5265
+ setValueByPath(toObject, ['config'], fromConfig);
5266
+ }
5267
+ return toObject;
5268
+ }
5269
+ function countTokensConfigToMldev(apiClient, fromObject) {
5270
+ const toObject = {};
5271
+ if (getValueByPath(fromObject, ['systemInstruction']) !== undefined) {
5272
+ throw new Error('systemInstruction parameter is not supported in Gemini API.');
5273
+ }
5274
+ if (getValueByPath(fromObject, ['tools']) !== undefined) {
5275
+ throw new Error('tools parameter is not supported in Gemini API.');
5276
+ }
5277
+ if (getValueByPath(fromObject, ['generationConfig']) !== undefined) {
5278
+ throw new Error('generationConfig parameter is not supported in Gemini API.');
5279
+ }
5280
+ return toObject;
5281
+ }
5282
+ function countTokensParametersToMldev(apiClient, fromObject) {
5283
+ const toObject = {};
5284
+ const fromModel = getValueByPath(fromObject, ['model']);
5285
+ if (fromModel != null) {
5286
+ setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
5445
5287
  }
5446
5288
  const fromContents = getValueByPath(fromObject, ['contents']);
5447
5289
  if (fromContents != null) {
5448
- if (Array.isArray(fromContents)) {
5449
- setValueByPath(toObject, ['contents'], tContents(apiClient, tContents(apiClient, fromContents).map((item) => {
5290
+ let transformedList = tContents(apiClient, fromContents);
5291
+ if (Array.isArray(transformedList)) {
5292
+ transformedList = transformedList.map((item) => {
5450
5293
  return contentToMldev(apiClient, item);
5451
- })));
5452
- }
5453
- else {
5454
- setValueByPath(toObject, ['contents'], tContents(apiClient, fromContents));
5294
+ });
5455
5295
  }
5296
+ setValueByPath(toObject, ['contents'], transformedList);
5456
5297
  }
5457
5298
  const fromConfig = getValueByPath(fromObject, ['config']);
5458
5299
  if (fromConfig != null) {
@@ -5597,14 +5438,13 @@ function contentToVertex(apiClient, fromObject) {
5597
5438
  const toObject = {};
5598
5439
  const fromParts = getValueByPath(fromObject, ['parts']);
5599
5440
  if (fromParts != null) {
5600
- if (Array.isArray(fromParts)) {
5601
- setValueByPath(toObject, ['parts'], fromParts.map((item) => {
5441
+ let transformedList = fromParts;
5442
+ if (Array.isArray(transformedList)) {
5443
+ transformedList = transformedList.map((item) => {
5602
5444
  return partToVertex(apiClient, item);
5603
- }));
5604
- }
5605
- else {
5606
- setValueByPath(toObject, ['parts'], fromParts);
5445
+ });
5607
5446
  }
5447
+ setValueByPath(toObject, ['parts'], transformedList);
5608
5448
  }
5609
5449
  const fromRole = getValueByPath(fromObject, ['role']);
5610
5450
  if (fromRole != null) {
@@ -5612,104 +5452,6 @@ function contentToVertex(apiClient, fromObject) {
5612
5452
  }
5613
5453
  return toObject;
5614
5454
  }
5615
- function schemaToVertex(apiClient, fromObject) {
5616
- const toObject = {};
5617
- const fromExample = getValueByPath(fromObject, ['example']);
5618
- if (fromExample != null) {
5619
- setValueByPath(toObject, ['example'], fromExample);
5620
- }
5621
- const fromPattern = getValueByPath(fromObject, ['pattern']);
5622
- if (fromPattern != null) {
5623
- setValueByPath(toObject, ['pattern'], fromPattern);
5624
- }
5625
- const fromDefault = getValueByPath(fromObject, ['default']);
5626
- if (fromDefault != null) {
5627
- setValueByPath(toObject, ['default'], fromDefault);
5628
- }
5629
- const fromMaxLength = getValueByPath(fromObject, ['maxLength']);
5630
- if (fromMaxLength != null) {
5631
- setValueByPath(toObject, ['maxLength'], fromMaxLength);
5632
- }
5633
- const fromMinLength = getValueByPath(fromObject, ['minLength']);
5634
- if (fromMinLength != null) {
5635
- setValueByPath(toObject, ['minLength'], fromMinLength);
5636
- }
5637
- const fromMinProperties = getValueByPath(fromObject, [
5638
- 'minProperties',
5639
- ]);
5640
- if (fromMinProperties != null) {
5641
- setValueByPath(toObject, ['minProperties'], fromMinProperties);
5642
- }
5643
- const fromMaxProperties = getValueByPath(fromObject, [
5644
- 'maxProperties',
5645
- ]);
5646
- if (fromMaxProperties != null) {
5647
- setValueByPath(toObject, ['maxProperties'], fromMaxProperties);
5648
- }
5649
- const fromAnyOf = getValueByPath(fromObject, ['anyOf']);
5650
- if (fromAnyOf != null) {
5651
- setValueByPath(toObject, ['anyOf'], fromAnyOf);
5652
- }
5653
- const fromDescription = getValueByPath(fromObject, ['description']);
5654
- if (fromDescription != null) {
5655
- setValueByPath(toObject, ['description'], fromDescription);
5656
- }
5657
- const fromEnum = getValueByPath(fromObject, ['enum']);
5658
- if (fromEnum != null) {
5659
- setValueByPath(toObject, ['enum'], fromEnum);
5660
- }
5661
- const fromFormat = getValueByPath(fromObject, ['format']);
5662
- if (fromFormat != null) {
5663
- setValueByPath(toObject, ['format'], fromFormat);
5664
- }
5665
- const fromItems = getValueByPath(fromObject, ['items']);
5666
- if (fromItems != null) {
5667
- setValueByPath(toObject, ['items'], fromItems);
5668
- }
5669
- const fromMaxItems = getValueByPath(fromObject, ['maxItems']);
5670
- if (fromMaxItems != null) {
5671
- setValueByPath(toObject, ['maxItems'], fromMaxItems);
5672
- }
5673
- const fromMaximum = getValueByPath(fromObject, ['maximum']);
5674
- if (fromMaximum != null) {
5675
- setValueByPath(toObject, ['maximum'], fromMaximum);
5676
- }
5677
- const fromMinItems = getValueByPath(fromObject, ['minItems']);
5678
- if (fromMinItems != null) {
5679
- setValueByPath(toObject, ['minItems'], fromMinItems);
5680
- }
5681
- const fromMinimum = getValueByPath(fromObject, ['minimum']);
5682
- if (fromMinimum != null) {
5683
- setValueByPath(toObject, ['minimum'], fromMinimum);
5684
- }
5685
- const fromNullable = getValueByPath(fromObject, ['nullable']);
5686
- if (fromNullable != null) {
5687
- setValueByPath(toObject, ['nullable'], fromNullable);
5688
- }
5689
- const fromProperties = getValueByPath(fromObject, ['properties']);
5690
- if (fromProperties != null) {
5691
- setValueByPath(toObject, ['properties'], fromProperties);
5692
- }
5693
- const fromPropertyOrdering = getValueByPath(fromObject, [
5694
- 'propertyOrdering',
5695
- ]);
5696
- if (fromPropertyOrdering != null) {
5697
- setValueByPath(toObject, ['propertyOrdering'], fromPropertyOrdering);
5698
- }
5699
- const fromRequired = getValueByPath(fromObject, ['required']);
5700
- if (fromRequired != null) {
5701
- setValueByPath(toObject, ['required'], fromRequired);
5702
- }
5703
- const fromTitle = getValueByPath(fromObject, ['title']);
5704
- if (fromTitle != null) {
5705
- setValueByPath(toObject, ['title'], fromTitle);
5706
- }
5707
- const fromType = getValueByPath(fromObject, ['type']);
5708
- if (fromType != null) {
5709
- setValueByPath(toObject, ['type'], fromType);
5710
- }
5711
- return toObject;
5712
- }
5713
5455
  function modelSelectionConfigToVertex(apiClient, fromObject) {
5714
5456
  const toObject = {};
5715
5457
  const fromFeatureSelectionPreference = getValueByPath(fromObject, [
@@ -5736,26 +5478,6 @@ function safetySettingToVertex(apiClient, fromObject) {
5736
5478
  }
5737
5479
  return toObject;
5738
5480
  }
5739
- function functionDeclarationToVertex(apiClient, fromObject) {
5740
- const toObject = {};
5741
- const fromResponse = getValueByPath(fromObject, ['response']);
5742
- if (fromResponse != null) {
5743
- setValueByPath(toObject, ['response'], schemaToVertex(apiClient, fromResponse));
5744
- }
5745
- const fromDescription = getValueByPath(fromObject, ['description']);
5746
- if (fromDescription != null) {
5747
- setValueByPath(toObject, ['description'], fromDescription);
5748
- }
5749
- const fromName = getValueByPath(fromObject, ['name']);
5750
- if (fromName != null) {
5751
- setValueByPath(toObject, ['name'], fromName);
5752
- }
5753
- const fromParameters = getValueByPath(fromObject, ['parameters']);
5754
- if (fromParameters != null) {
5755
- setValueByPath(toObject, ['parameters'], fromParameters);
5756
- }
5757
- return toObject;
5758
- }
5759
5481
  function googleSearchToVertex() {
5760
5482
  const toObject = {};
5761
5483
  return toObject;
@@ -5786,19 +5508,6 @@ function googleSearchRetrievalToVertex(apiClient, fromObject) {
5786
5508
  }
5787
5509
  function toolToVertex(apiClient, fromObject) {
5788
5510
  const toObject = {};
5789
- const fromFunctionDeclarations = getValueByPath(fromObject, [
5790
- 'functionDeclarations',
5791
- ]);
5792
- if (fromFunctionDeclarations != null) {
5793
- if (Array.isArray(fromFunctionDeclarations)) {
5794
- setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations.map((item) => {
5795
- return functionDeclarationToVertex(apiClient, item);
5796
- }));
5797
- }
5798
- else {
5799
- setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
5800
- }
5801
- }
5802
5511
  const fromRetrieval = getValueByPath(fromObject, ['retrieval']);
5803
5512
  if (fromRetrieval != null) {
5804
5513
  setValueByPath(toObject, ['retrieval'], fromRetrieval);
@@ -5819,6 +5528,12 @@ function toolToVertex(apiClient, fromObject) {
5819
5528
  if (fromCodeExecution != null) {
5820
5529
  setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
5821
5530
  }
5531
+ const fromFunctionDeclarations = getValueByPath(fromObject, [
5532
+ 'functionDeclarations',
5533
+ ]);
5534
+ if (fromFunctionDeclarations != null) {
5535
+ setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
5536
+ }
5822
5537
  return toObject;
5823
5538
  }
5824
5539
  function functionCallingConfigToVertex(apiClient, fromObject) {
@@ -5965,7 +5680,7 @@ function generateContentConfigToVertex(apiClient, fromObject, parentObject) {
5965
5680
  'responseSchema',
5966
5681
  ]);
5967
5682
  if (fromResponseSchema != null) {
5968
- setValueByPath(toObject, ['responseSchema'], schemaToVertex(apiClient, tSchema(apiClient, fromResponseSchema)));
5683
+ setValueByPath(toObject, ['responseSchema'], tSchema(apiClient, fromResponseSchema));
5969
5684
  }
5970
5685
  const fromRoutingConfig = getValueByPath(fromObject, [
5971
5686
  'routingConfig',
@@ -5983,25 +5698,23 @@ function generateContentConfigToVertex(apiClient, fromObject, parentObject) {
5983
5698
  'safetySettings',
5984
5699
  ]);
5985
5700
  if (parentObject !== undefined && fromSafetySettings != null) {
5986
- if (Array.isArray(fromSafetySettings)) {
5987
- setValueByPath(parentObject, ['safetySettings'], fromSafetySettings.map((item) => {
5701
+ let transformedList = fromSafetySettings;
5702
+ if (Array.isArray(transformedList)) {
5703
+ transformedList = transformedList.map((item) => {
5988
5704
  return safetySettingToVertex(apiClient, item);
5989
- }));
5990
- }
5991
- else {
5992
- setValueByPath(parentObject, ['safetySettings'], fromSafetySettings);
5705
+ });
5993
5706
  }
5707
+ setValueByPath(parentObject, ['safetySettings'], transformedList);
5994
5708
  }
5995
5709
  const fromTools = getValueByPath(fromObject, ['tools']);
5996
5710
  if (parentObject !== undefined && fromTools != null) {
5997
- if (Array.isArray(fromTools)) {
5998
- setValueByPath(parentObject, ['tools'], tTools(apiClient, tTools(apiClient, fromTools).map((item) => {
5711
+ let transformedList = tTools(apiClient, fromTools);
5712
+ if (Array.isArray(transformedList)) {
5713
+ transformedList = transformedList.map((item) => {
5999
5714
  return toolToVertex(apiClient, tTool(apiClient, item));
6000
- })));
6001
- }
6002
- else {
6003
- setValueByPath(parentObject, ['tools'], tTools(apiClient, fromTools));
5715
+ });
6004
5716
  }
5717
+ setValueByPath(parentObject, ['tools'], transformedList);
6005
5718
  }
6006
5719
  const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
6007
5720
  if (parentObject !== undefined && fromToolConfig != null) {
@@ -6055,14 +5768,13 @@ function generateContentParametersToVertex(apiClient, fromObject) {
6055
5768
  }
6056
5769
  const fromContents = getValueByPath(fromObject, ['contents']);
6057
5770
  if (fromContents != null) {
6058
- if (Array.isArray(fromContents)) {
6059
- setValueByPath(toObject, ['contents'], tContents(apiClient, tContents(apiClient, fromContents).map((item) => {
5771
+ let transformedList = tContents(apiClient, fromContents);
5772
+ if (Array.isArray(transformedList)) {
5773
+ transformedList = transformedList.map((item) => {
6060
5774
  return contentToVertex(apiClient, item);
6061
- })));
6062
- }
6063
- else {
6064
- setValueByPath(toObject, ['contents'], tContents(apiClient, fromContents));
5775
+ });
6065
5776
  }
5777
+ setValueByPath(toObject, ['contents'], transformedList);
6066
5778
  }
6067
5779
  const fromConfig = getValueByPath(fromObject, ['config']);
6068
5780
  if (fromConfig != null) {
@@ -6224,6 +5936,42 @@ function getModelParametersToVertex(apiClient, fromObject) {
6224
5936
  }
6225
5937
  return toObject;
6226
5938
  }
5939
+ function updateModelConfigToVertex(apiClient, fromObject, parentObject) {
5940
+ const toObject = {};
5941
+ const fromDisplayName = getValueByPath(fromObject, ['displayName']);
5942
+ if (parentObject !== undefined && fromDisplayName != null) {
5943
+ setValueByPath(parentObject, ['displayName'], fromDisplayName);
5944
+ }
5945
+ const fromDescription = getValueByPath(fromObject, ['description']);
5946
+ if (parentObject !== undefined && fromDescription != null) {
5947
+ setValueByPath(parentObject, ['description'], fromDescription);
5948
+ }
5949
+ return toObject;
5950
+ }
5951
+ function updateModelParametersToVertex(apiClient, fromObject) {
5952
+ const toObject = {};
5953
+ const fromModel = getValueByPath(fromObject, ['model']);
5954
+ if (fromModel != null) {
5955
+ setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
5956
+ }
5957
+ const fromConfig = getValueByPath(fromObject, ['config']);
5958
+ if (fromConfig != null) {
5959
+ setValueByPath(toObject, ['config'], updateModelConfigToVertex(apiClient, fromConfig, toObject));
5960
+ }
5961
+ return toObject;
5962
+ }
5963
+ function deleteModelParametersToVertex(apiClient, fromObject) {
5964
+ const toObject = {};
5965
+ const fromModel = getValueByPath(fromObject, ['model']);
5966
+ if (fromModel != null) {
5967
+ setValueByPath(toObject, ['_url', 'name'], tModel(apiClient, fromModel));
5968
+ }
5969
+ const fromConfig = getValueByPath(fromObject, ['config']);
5970
+ if (fromConfig != null) {
5971
+ setValueByPath(toObject, ['config'], fromConfig);
5972
+ }
5973
+ return toObject;
5974
+ }
6227
5975
  function countTokensConfigToVertex(apiClient, fromObject, parentObject) {
6228
5976
  const toObject = {};
6229
5977
  const fromSystemInstruction = getValueByPath(fromObject, [
@@ -6234,14 +5982,13 @@ function countTokensConfigToVertex(apiClient, fromObject, parentObject) {
6234
5982
  }
6235
5983
  const fromTools = getValueByPath(fromObject, ['tools']);
6236
5984
  if (parentObject !== undefined && fromTools != null) {
6237
- if (Array.isArray(fromTools)) {
6238
- setValueByPath(parentObject, ['tools'], fromTools.map((item) => {
5985
+ let transformedList = fromTools;
5986
+ if (Array.isArray(transformedList)) {
5987
+ transformedList = transformedList.map((item) => {
6239
5988
  return toolToVertex(apiClient, item);
6240
- }));
6241
- }
6242
- else {
6243
- setValueByPath(parentObject, ['tools'], fromTools);
5989
+ });
6244
5990
  }
5991
+ setValueByPath(parentObject, ['tools'], transformedList);
6245
5992
  }
6246
5993
  const fromGenerationConfig = getValueByPath(fromObject, [
6247
5994
  'generationConfig',
@@ -6259,14 +6006,13 @@ function countTokensParametersToVertex(apiClient, fromObject) {
6259
6006
  }
6260
6007
  const fromContents = getValueByPath(fromObject, ['contents']);
6261
6008
  if (fromContents != null) {
6262
- if (Array.isArray(fromContents)) {
6263
- setValueByPath(toObject, ['contents'], tContents(apiClient, tContents(apiClient, fromContents).map((item) => {
6009
+ let transformedList = tContents(apiClient, fromContents);
6010
+ if (Array.isArray(transformedList)) {
6011
+ transformedList = transformedList.map((item) => {
6264
6012
  return contentToVertex(apiClient, item);
6265
- })));
6266
- }
6267
- else {
6268
- setValueByPath(toObject, ['contents'], tContents(apiClient, fromContents));
6013
+ });
6269
6014
  }
6015
+ setValueByPath(toObject, ['contents'], transformedList);
6270
6016
  }
6271
6017
  const fromConfig = getValueByPath(fromObject, ['config']);
6272
6018
  if (fromConfig != null) {
@@ -6282,14 +6028,13 @@ function computeTokensParametersToVertex(apiClient, fromObject) {
6282
6028
  }
6283
6029
  const fromContents = getValueByPath(fromObject, ['contents']);
6284
6030
  if (fromContents != null) {
6285
- if (Array.isArray(fromContents)) {
6286
- setValueByPath(toObject, ['contents'], tContents(apiClient, tContents(apiClient, fromContents).map((item) => {
6031
+ let transformedList = tContents(apiClient, fromContents);
6032
+ if (Array.isArray(transformedList)) {
6033
+ transformedList = transformedList.map((item) => {
6287
6034
  return contentToVertex(apiClient, item);
6288
- })));
6289
- }
6290
- else {
6291
- setValueByPath(toObject, ['contents'], tContents(apiClient, fromContents));
6035
+ });
6292
6036
  }
6037
+ setValueByPath(toObject, ['contents'], transformedList);
6293
6038
  }
6294
6039
  const fromConfig = getValueByPath(fromObject, ['config']);
6295
6040
  if (fromConfig != null) {
@@ -6437,14 +6182,13 @@ function contentFromMldev(apiClient, fromObject) {
6437
6182
  const toObject = {};
6438
6183
  const fromParts = getValueByPath(fromObject, ['parts']);
6439
6184
  if (fromParts != null) {
6440
- if (Array.isArray(fromParts)) {
6441
- setValueByPath(toObject, ['parts'], fromParts.map((item) => {
6185
+ let transformedList = fromParts;
6186
+ if (Array.isArray(transformedList)) {
6187
+ transformedList = transformedList.map((item) => {
6442
6188
  return partFromMldev(apiClient, item);
6443
- }));
6444
- }
6445
- else {
6446
- setValueByPath(toObject, ['parts'], fromParts);
6189
+ });
6447
6190
  }
6191
+ setValueByPath(toObject, ['parts'], transformedList);
6448
6192
  }
6449
6193
  const fromRole = getValueByPath(fromObject, ['role']);
6450
6194
  if (fromRole != null) {
@@ -6512,14 +6256,13 @@ function generateContentResponseFromMldev(apiClient, fromObject) {
6512
6256
  const toObject = {};
6513
6257
  const fromCandidates = getValueByPath(fromObject, ['candidates']);
6514
6258
  if (fromCandidates != null) {
6515
- if (Array.isArray(fromCandidates)) {
6516
- setValueByPath(toObject, ['candidates'], fromCandidates.map((item) => {
6259
+ let transformedList = fromCandidates;
6260
+ if (Array.isArray(transformedList)) {
6261
+ transformedList = transformedList.map((item) => {
6517
6262
  return candidateFromMldev(apiClient, item);
6518
- }));
6519
- }
6520
- else {
6521
- setValueByPath(toObject, ['candidates'], fromCandidates);
6263
+ });
6522
6264
  }
6265
+ setValueByPath(toObject, ['candidates'], transformedList);
6523
6266
  }
6524
6267
  const fromModelVersion = getValueByPath(fromObject, ['modelVersion']);
6525
6268
  if (fromModelVersion != null) {
@@ -6555,14 +6298,13 @@ function embedContentResponseFromMldev(apiClient, fromObject) {
6555
6298
  const toObject = {};
6556
6299
  const fromEmbeddings = getValueByPath(fromObject, ['embeddings']);
6557
6300
  if (fromEmbeddings != null) {
6558
- if (Array.isArray(fromEmbeddings)) {
6559
- setValueByPath(toObject, ['embeddings'], fromEmbeddings.map((item) => {
6301
+ let transformedList = fromEmbeddings;
6302
+ if (Array.isArray(transformedList)) {
6303
+ transformedList = transformedList.map((item) => {
6560
6304
  return contentEmbeddingFromMldev(apiClient, item);
6561
- }));
6562
- }
6563
- else {
6564
- setValueByPath(toObject, ['embeddings'], fromEmbeddings);
6305
+ });
6565
6306
  }
6307
+ setValueByPath(toObject, ['embeddings'], transformedList);
6566
6308
  }
6567
6309
  const fromMetadata = getValueByPath(fromObject, ['metadata']);
6568
6310
  if (fromMetadata != null) {
@@ -6630,14 +6372,13 @@ function generateImagesResponseFromMldev(apiClient, fromObject) {
6630
6372
  'predictions',
6631
6373
  ]);
6632
6374
  if (fromGeneratedImages != null) {
6633
- if (Array.isArray(fromGeneratedImages)) {
6634
- setValueByPath(toObject, ['generatedImages'], fromGeneratedImages.map((item) => {
6375
+ let transformedList = fromGeneratedImages;
6376
+ if (Array.isArray(transformedList)) {
6377
+ transformedList = transformedList.map((item) => {
6635
6378
  return generatedImageFromMldev(apiClient, item);
6636
- }));
6637
- }
6638
- else {
6639
- setValueByPath(toObject, ['generatedImages'], fromGeneratedImages);
6379
+ });
6640
6380
  }
6381
+ setValueByPath(toObject, ['generatedImages'], transformedList);
6641
6382
  }
6642
6383
  const fromPositivePromptSafetyAttributes = getValueByPath(fromObject, [
6643
6384
  'positivePromptSafetyAttributes',
@@ -6705,6 +6446,10 @@ function modelFromMldev(apiClient, fromObject) {
6705
6446
  }
6706
6447
  return toObject;
6707
6448
  }
6449
+ function deleteModelResponseFromMldev() {
6450
+ const toObject = {};
6451
+ return toObject;
6452
+ }
6708
6453
  function countTokensResponseFromMldev(apiClient, fromObject) {
6709
6454
  const toObject = {};
6710
6455
  const fromTotalTokens = getValueByPath(fromObject, ['totalTokens']);
@@ -6752,14 +6497,13 @@ function generateVideosResponseFromMldev$1(apiClient, fromObject) {
6752
6497
  'generatedSamples',
6753
6498
  ]);
6754
6499
  if (fromGeneratedVideos != null) {
6755
- if (Array.isArray(fromGeneratedVideos)) {
6756
- setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos.map((item) => {
6500
+ let transformedList = fromGeneratedVideos;
6501
+ if (Array.isArray(transformedList)) {
6502
+ transformedList = transformedList.map((item) => {
6757
6503
  return generatedVideoFromMldev$1(apiClient, item);
6758
- }));
6759
- }
6760
- else {
6761
- setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos);
6504
+ });
6762
6505
  }
6506
+ setValueByPath(toObject, ['generatedVideos'], transformedList);
6763
6507
  }
6764
6508
  const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
6765
6509
  'raiMediaFilteredCount',
@@ -6854,14 +6598,13 @@ function contentFromVertex(apiClient, fromObject) {
6854
6598
  const toObject = {};
6855
6599
  const fromParts = getValueByPath(fromObject, ['parts']);
6856
6600
  if (fromParts != null) {
6857
- if (Array.isArray(fromParts)) {
6858
- setValueByPath(toObject, ['parts'], fromParts.map((item) => {
6601
+ let transformedList = fromParts;
6602
+ if (Array.isArray(transformedList)) {
6603
+ transformedList = transformedList.map((item) => {
6859
6604
  return partFromVertex(apiClient, item);
6860
- }));
6861
- }
6862
- else {
6863
- setValueByPath(toObject, ['parts'], fromParts);
6605
+ });
6864
6606
  }
6607
+ setValueByPath(toObject, ['parts'], transformedList);
6865
6608
  }
6866
6609
  const fromRole = getValueByPath(fromObject, ['role']);
6867
6610
  if (fromRole != null) {
@@ -6931,14 +6674,13 @@ function generateContentResponseFromVertex(apiClient, fromObject) {
6931
6674
  const toObject = {};
6932
6675
  const fromCandidates = getValueByPath(fromObject, ['candidates']);
6933
6676
  if (fromCandidates != null) {
6934
- if (Array.isArray(fromCandidates)) {
6935
- setValueByPath(toObject, ['candidates'], fromCandidates.map((item) => {
6677
+ let transformedList = fromCandidates;
6678
+ if (Array.isArray(transformedList)) {
6679
+ transformedList = transformedList.map((item) => {
6936
6680
  return candidateFromVertex(apiClient, item);
6937
- }));
6938
- }
6939
- else {
6940
- setValueByPath(toObject, ['candidates'], fromCandidates);
6681
+ });
6941
6682
  }
6683
+ setValueByPath(toObject, ['candidates'], transformedList);
6942
6684
  }
6943
6685
  const fromCreateTime = getValueByPath(fromObject, ['createTime']);
6944
6686
  if (fromCreateTime != null) {
@@ -7007,14 +6749,13 @@ function embedContentResponseFromVertex(apiClient, fromObject) {
7007
6749
  'embeddings',
7008
6750
  ]);
7009
6751
  if (fromEmbeddings != null) {
7010
- if (Array.isArray(fromEmbeddings)) {
7011
- setValueByPath(toObject, ['embeddings'], fromEmbeddings.map((item) => {
6752
+ let transformedList = fromEmbeddings;
6753
+ if (Array.isArray(transformedList)) {
6754
+ transformedList = transformedList.map((item) => {
7012
6755
  return contentEmbeddingFromVertex(apiClient, item);
7013
- }));
7014
- }
7015
- else {
7016
- setValueByPath(toObject, ['embeddings'], fromEmbeddings);
6756
+ });
7017
6757
  }
6758
+ setValueByPath(toObject, ['embeddings'], transformedList);
7018
6759
  }
7019
6760
  const fromMetadata = getValueByPath(fromObject, ['metadata']);
7020
6761
  if (fromMetadata != null) {
@@ -7090,14 +6831,13 @@ function generateImagesResponseFromVertex(apiClient, fromObject) {
7090
6831
  'predictions',
7091
6832
  ]);
7092
6833
  if (fromGeneratedImages != null) {
7093
- if (Array.isArray(fromGeneratedImages)) {
7094
- setValueByPath(toObject, ['generatedImages'], fromGeneratedImages.map((item) => {
6834
+ let transformedList = fromGeneratedImages;
6835
+ if (Array.isArray(transformedList)) {
6836
+ transformedList = transformedList.map((item) => {
7095
6837
  return generatedImageFromVertex(apiClient, item);
7096
- }));
7097
- }
7098
- else {
7099
- setValueByPath(toObject, ['generatedImages'], fromGeneratedImages);
6838
+ });
7100
6839
  }
6840
+ setValueByPath(toObject, ['generatedImages'], transformedList);
7101
6841
  }
7102
6842
  const fromPositivePromptSafetyAttributes = getValueByPath(fromObject, [
7103
6843
  'positivePromptSafetyAttributes',
@@ -7160,14 +6900,13 @@ function modelFromVertex(apiClient, fromObject) {
7160
6900
  }
7161
6901
  const fromEndpoints = getValueByPath(fromObject, ['deployedModels']);
7162
6902
  if (fromEndpoints != null) {
7163
- if (Array.isArray(fromEndpoints)) {
7164
- setValueByPath(toObject, ['endpoints'], fromEndpoints.map((item) => {
6903
+ let transformedList = fromEndpoints;
6904
+ if (Array.isArray(transformedList)) {
6905
+ transformedList = transformedList.map((item) => {
7165
6906
  return endpointFromVertex(apiClient, item);
7166
- }));
7167
- }
7168
- else {
7169
- setValueByPath(toObject, ['endpoints'], fromEndpoints);
6907
+ });
7170
6908
  }
6909
+ setValueByPath(toObject, ['endpoints'], transformedList);
7171
6910
  }
7172
6911
  const fromLabels = getValueByPath(fromObject, ['labels']);
7173
6912
  if (fromLabels != null) {
@@ -7179,6 +6918,10 @@ function modelFromVertex(apiClient, fromObject) {
7179
6918
  }
7180
6919
  return toObject;
7181
6920
  }
6921
+ function deleteModelResponseFromVertex() {
6922
+ const toObject = {};
6923
+ return toObject;
6924
+ }
7182
6925
  function countTokensResponseFromVertex(apiClient, fromObject) {
7183
6926
  const toObject = {};
7184
6927
  const fromTotalTokens = getValueByPath(fromObject, ['totalTokens']);
@@ -7225,14 +6968,13 @@ function generateVideosResponseFromVertex$1(apiClient, fromObject) {
7225
6968
  const toObject = {};
7226
6969
  const fromGeneratedVideos = getValueByPath(fromObject, ['videos']);
7227
6970
  if (fromGeneratedVideos != null) {
7228
- if (Array.isArray(fromGeneratedVideos)) {
7229
- setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos.map((item) => {
6971
+ let transformedList = fromGeneratedVideos;
6972
+ if (Array.isArray(transformedList)) {
6973
+ transformedList = transformedList.map((item) => {
7230
6974
  return generatedVideoFromVertex$1(apiClient, item);
7231
- }));
7232
- }
7233
- else {
7234
- setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos);
6975
+ });
7235
6976
  }
6977
+ setValueByPath(toObject, ['generatedVideos'], transformedList);
7236
6978
  }
7237
6979
  const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
7238
6980
  'raiMediaFilteredCount',
@@ -7476,21 +7218,6 @@ class Session {
7476
7218
  clientContent: { turnComplete: params.turnComplete },
7477
7219
  };
7478
7220
  }
7479
- tLiveClientRealtimeInput(apiClient, params) {
7480
- let clientMessage = {};
7481
- if (!('media' in params) || !params.media) {
7482
- throw new Error(`Failed to convert realtime input "media", type: '${typeof params.media}'`);
7483
- }
7484
- // LiveClientRealtimeInput
7485
- clientMessage = {
7486
- realtimeInput: {
7487
- mediaChunks: [params.media],
7488
- activityStart: params.activityStart,
7489
- activityEnd: params.activityEnd,
7490
- },
7491
- };
7492
- return clientMessage;
7493
- }
7494
7221
  tLiveClienttToolResponse(apiClient, params) {
7495
7222
  let functionResponses = [];
7496
7223
  if (params.functionResponses == null) {
@@ -7598,10 +7325,17 @@ class Session {
7598
7325
  of audio and image mimetypes are allowed.
7599
7326
  */
7600
7327
  sendRealtimeInput(params) {
7601
- if (params.media == null) {
7602
- throw new Error('Media is required.');
7328
+ let clientMessage = {};
7329
+ if (this.apiClient.isVertexAI()) {
7330
+ clientMessage = {
7331
+ 'realtimeInput': liveSendRealtimeInputParametersToVertex(this.apiClient, params),
7332
+ };
7333
+ }
7334
+ else {
7335
+ clientMessage = {
7336
+ 'realtimeInput': liveSendRealtimeInputParametersToMldev(this.apiClient, params),
7337
+ };
7603
7338
  }
7604
- const clientMessage = this.tLiveClientRealtimeInput(this.apiClient, params);
7605
7339
  this.conn.send(JSON.stringify(clientMessage));
7606
7340
  }
7607
7341
  /**
@@ -7822,7 +7556,7 @@ class Models extends BaseModule {
7822
7556
  };
7823
7557
  }
7824
7558
  async generateContentInternal(params) {
7825
- var _a, _b;
7559
+ var _a, _b, _c, _d;
7826
7560
  let response;
7827
7561
  let path = '';
7828
7562
  let queryParams = {};
@@ -7840,6 +7574,7 @@ class Models extends BaseModule {
7840
7574
  body: JSON.stringify(body),
7841
7575
  httpMethod: 'POST',
7842
7576
  httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
7577
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
7843
7578
  })
7844
7579
  .then((httpResponse) => {
7845
7580
  return httpResponse.json();
@@ -7864,7 +7599,8 @@ class Models extends BaseModule {
7864
7599
  queryParams: queryParams,
7865
7600
  body: JSON.stringify(body),
7866
7601
  httpMethod: 'POST',
7867
- httpOptions: (_b = params.config) === null || _b === void 0 ? void 0 : _b.httpOptions,
7602
+ httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
7603
+ abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
7868
7604
  })
7869
7605
  .then((httpResponse) => {
7870
7606
  return httpResponse.json();
@@ -7878,7 +7614,7 @@ class Models extends BaseModule {
7878
7614
  }
7879
7615
  }
7880
7616
  async generateContentStreamInternal(params) {
7881
- var _a, _b;
7617
+ var _a, _b, _c, _d;
7882
7618
  let response;
7883
7619
  let path = '';
7884
7620
  let queryParams = {};
@@ -7896,6 +7632,7 @@ class Models extends BaseModule {
7896
7632
  body: JSON.stringify(body),
7897
7633
  httpMethod: 'POST',
7898
7634
  httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
7635
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
7899
7636
  });
7900
7637
  return response.then(function (apiResponse) {
7901
7638
  return __asyncGenerator(this, arguments, function* () {
@@ -7934,7 +7671,8 @@ class Models extends BaseModule {
7934
7671
  queryParams: queryParams,
7935
7672
  body: JSON.stringify(body),
7936
7673
  httpMethod: 'POST',
7937
- httpOptions: (_b = params.config) === null || _b === void 0 ? void 0 : _b.httpOptions,
7674
+ httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
7675
+ abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
7938
7676
  });
7939
7677
  return response.then(function (apiResponse) {
7940
7678
  return __asyncGenerator(this, arguments, function* () {
@@ -7983,7 +7721,7 @@ class Models extends BaseModule {
7983
7721
  * ```
7984
7722
  */
7985
7723
  async embedContent(params) {
7986
- var _a, _b;
7724
+ var _a, _b, _c, _d;
7987
7725
  let response;
7988
7726
  let path = '';
7989
7727
  let queryParams = {};
@@ -8001,6 +7739,7 @@ class Models extends BaseModule {
8001
7739
  body: JSON.stringify(body),
8002
7740
  httpMethod: 'POST',
8003
7741
  httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
7742
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
8004
7743
  })
8005
7744
  .then((httpResponse) => {
8006
7745
  return httpResponse.json();
@@ -8025,7 +7764,8 @@ class Models extends BaseModule {
8025
7764
  queryParams: queryParams,
8026
7765
  body: JSON.stringify(body),
8027
7766
  httpMethod: 'POST',
8028
- httpOptions: (_b = params.config) === null || _b === void 0 ? void 0 : _b.httpOptions,
7767
+ httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
7768
+ abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
8029
7769
  })
8030
7770
  .then((httpResponse) => {
8031
7771
  return httpResponse.json();
@@ -8058,7 +7798,7 @@ class Models extends BaseModule {
8058
7798
  * ```
8059
7799
  */
8060
7800
  async generateImagesInternal(params) {
8061
- var _a, _b;
7801
+ var _a, _b, _c, _d;
8062
7802
  let response;
8063
7803
  let path = '';
8064
7804
  let queryParams = {};
@@ -8076,6 +7816,7 @@ class Models extends BaseModule {
8076
7816
  body: JSON.stringify(body),
8077
7817
  httpMethod: 'POST',
8078
7818
  httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
7819
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
8079
7820
  })
8080
7821
  .then((httpResponse) => {
8081
7822
  return httpResponse.json();
@@ -8100,7 +7841,8 @@ class Models extends BaseModule {
8100
7841
  queryParams: queryParams,
8101
7842
  body: JSON.stringify(body),
8102
7843
  httpMethod: 'POST',
8103
- httpOptions: (_b = params.config) === null || _b === void 0 ? void 0 : _b.httpOptions,
7844
+ httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
7845
+ abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
8104
7846
  })
8105
7847
  .then((httpResponse) => {
8106
7848
  return httpResponse.json();
@@ -8122,7 +7864,7 @@ class Models extends BaseModule {
8122
7864
  * ```
8123
7865
  */
8124
7866
  async get(params) {
8125
- var _a, _b;
7867
+ var _a, _b, _c, _d;
8126
7868
  let response;
8127
7869
  let path = '';
8128
7870
  let queryParams = {};
@@ -8140,6 +7882,7 @@ class Models extends BaseModule {
8140
7882
  body: JSON.stringify(body),
8141
7883
  httpMethod: 'GET',
8142
7884
  httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
7885
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
8143
7886
  })
8144
7887
  .then((httpResponse) => {
8145
7888
  return httpResponse.json();
@@ -8162,7 +7905,8 @@ class Models extends BaseModule {
8162
7905
  queryParams: queryParams,
8163
7906
  body: JSON.stringify(body),
8164
7907
  httpMethod: 'GET',
8165
- httpOptions: (_b = params.config) === null || _b === void 0 ? void 0 : _b.httpOptions,
7908
+ httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
7909
+ abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
8166
7910
  })
8167
7911
  .then((httpResponse) => {
8168
7912
  return httpResponse.json();
@@ -8174,29 +7918,30 @@ class Models extends BaseModule {
8174
7918
  }
8175
7919
  }
8176
7920
  /**
8177
- * Counts the number of tokens in the given contents. Multimodal input is
8178
- * supported for Gemini models.
7921
+ * Updates a tuned model by its name.
8179
7922
  *
8180
- * @param params - The parameters for counting tokens.
7923
+ * @param params - The parameters for updating the model.
8181
7924
  * @return The response from the API.
8182
7925
  *
8183
7926
  * @example
8184
7927
  * ```ts
8185
- * const response = await ai.models.countTokens({
8186
- * model: 'gemini-2.0-flash',
8187
- * contents: 'The quick brown fox jumps over the lazy dog.'
7928
+ * const response = await ai.models.update({
7929
+ * model: 'tuned-model-name',
7930
+ * config: {
7931
+ * displayName: 'New display name',
7932
+ * description: 'New description',
7933
+ * },
8188
7934
  * });
8189
- * console.log(response);
8190
7935
  * ```
8191
7936
  */
8192
- async countTokens(params) {
8193
- var _a, _b;
7937
+ async update(params) {
7938
+ var _a, _b, _c, _d;
8194
7939
  let response;
8195
7940
  let path = '';
8196
7941
  let queryParams = {};
8197
7942
  if (this.apiClient.isVertexAI()) {
8198
- const body = countTokensParametersToVertex(this.apiClient, params);
8199
- path = formatMap('{model}:countTokens', body['_url']);
7943
+ const body = updateModelParametersToVertex(this.apiClient, params);
7944
+ path = formatMap('{model}', body['_url']);
8200
7945
  queryParams = body['_query'];
8201
7946
  delete body['config'];
8202
7947
  delete body['_url'];
@@ -8206,22 +7951,21 @@ class Models extends BaseModule {
8206
7951
  path: path,
8207
7952
  queryParams: queryParams,
8208
7953
  body: JSON.stringify(body),
8209
- httpMethod: 'POST',
7954
+ httpMethod: 'PATCH',
8210
7955
  httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
7956
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
8211
7957
  })
8212
7958
  .then((httpResponse) => {
8213
7959
  return httpResponse.json();
8214
7960
  });
8215
7961
  return response.then((apiResponse) => {
8216
- const resp = countTokensResponseFromVertex(this.apiClient, apiResponse);
8217
- const typedResp = new CountTokensResponse();
8218
- Object.assign(typedResp, resp);
8219
- return typedResp;
7962
+ const resp = modelFromVertex(this.apiClient, apiResponse);
7963
+ return resp;
8220
7964
  });
8221
7965
  }
8222
7966
  else {
8223
- const body = countTokensParametersToMldev(this.apiClient, params);
8224
- path = formatMap('{model}:countTokens', body['_url']);
7967
+ const body = updateModelParametersToMldev(this.apiClient, params);
7968
+ path = formatMap('{name}', body['_url']);
8225
7969
  queryParams = body['_query'];
8226
7970
  delete body['config'];
8227
7971
  delete body['_url'];
@@ -8231,40 +7975,182 @@ class Models extends BaseModule {
8231
7975
  path: path,
8232
7976
  queryParams: queryParams,
8233
7977
  body: JSON.stringify(body),
8234
- httpMethod: 'POST',
8235
- httpOptions: (_b = params.config) === null || _b === void 0 ? void 0 : _b.httpOptions,
7978
+ httpMethod: 'PATCH',
7979
+ httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
7980
+ abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
8236
7981
  })
8237
7982
  .then((httpResponse) => {
8238
7983
  return httpResponse.json();
8239
7984
  });
8240
7985
  return response.then((apiResponse) => {
8241
- const resp = countTokensResponseFromMldev(this.apiClient, apiResponse);
8242
- const typedResp = new CountTokensResponse();
8243
- Object.assign(typedResp, resp);
8244
- return typedResp;
7986
+ const resp = modelFromMldev(this.apiClient, apiResponse);
7987
+ return resp;
8245
7988
  });
8246
7989
  }
8247
7990
  }
8248
7991
  /**
8249
- * Given a list of contents, returns a corresponding TokensInfo containing
8250
- * the list of tokens and list of token ids.
8251
- *
8252
- * This method is not supported by the Gemini Developer API.
7992
+ * Deletes a tuned model by its name.
8253
7993
  *
8254
- * @param params - The parameters for computing tokens.
7994
+ * @param params - The parameters for deleting the model.
8255
7995
  * @return The response from the API.
8256
7996
  *
8257
7997
  * @example
8258
7998
  * ```ts
8259
- * const response = await ai.models.computeTokens({
8260
- * model: 'gemini-2.0-flash',
8261
- * contents: 'What is your name?'
8262
- * });
8263
- * console.log(response);
7999
+ * const response = await ai.models.delete({model: 'tuned-model-name'});
8264
8000
  * ```
8265
8001
  */
8266
- async computeTokens(params) {
8267
- var _a;
8002
+ async delete(params) {
8003
+ var _a, _b, _c, _d;
8004
+ let response;
8005
+ let path = '';
8006
+ let queryParams = {};
8007
+ if (this.apiClient.isVertexAI()) {
8008
+ const body = deleteModelParametersToVertex(this.apiClient, params);
8009
+ path = formatMap('{name}', body['_url']);
8010
+ queryParams = body['_query'];
8011
+ delete body['config'];
8012
+ delete body['_url'];
8013
+ delete body['_query'];
8014
+ response = this.apiClient
8015
+ .request({
8016
+ path: path,
8017
+ queryParams: queryParams,
8018
+ body: JSON.stringify(body),
8019
+ httpMethod: 'DELETE',
8020
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
8021
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
8022
+ })
8023
+ .then((httpResponse) => {
8024
+ return httpResponse.json();
8025
+ });
8026
+ return response.then(() => {
8027
+ const resp = deleteModelResponseFromVertex();
8028
+ const typedResp = new DeleteModelResponse();
8029
+ Object.assign(typedResp, resp);
8030
+ return typedResp;
8031
+ });
8032
+ }
8033
+ else {
8034
+ const body = deleteModelParametersToMldev(this.apiClient, params);
8035
+ path = formatMap('{name}', body['_url']);
8036
+ queryParams = body['_query'];
8037
+ delete body['config'];
8038
+ delete body['_url'];
8039
+ delete body['_query'];
8040
+ response = this.apiClient
8041
+ .request({
8042
+ path: path,
8043
+ queryParams: queryParams,
8044
+ body: JSON.stringify(body),
8045
+ httpMethod: 'DELETE',
8046
+ httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
8047
+ abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
8048
+ })
8049
+ .then((httpResponse) => {
8050
+ return httpResponse.json();
8051
+ });
8052
+ return response.then(() => {
8053
+ const resp = deleteModelResponseFromMldev();
8054
+ const typedResp = new DeleteModelResponse();
8055
+ Object.assign(typedResp, resp);
8056
+ return typedResp;
8057
+ });
8058
+ }
8059
+ }
8060
+ /**
8061
+ * Counts the number of tokens in the given contents. Multimodal input is
8062
+ * supported for Gemini models.
8063
+ *
8064
+ * @param params - The parameters for counting tokens.
8065
+ * @return The response from the API.
8066
+ *
8067
+ * @example
8068
+ * ```ts
8069
+ * const response = await ai.models.countTokens({
8070
+ * model: 'gemini-2.0-flash',
8071
+ * contents: 'The quick brown fox jumps over the lazy dog.'
8072
+ * });
8073
+ * console.log(response);
8074
+ * ```
8075
+ */
8076
+ async countTokens(params) {
8077
+ var _a, _b, _c, _d;
8078
+ let response;
8079
+ let path = '';
8080
+ let queryParams = {};
8081
+ if (this.apiClient.isVertexAI()) {
8082
+ const body = countTokensParametersToVertex(this.apiClient, params);
8083
+ path = formatMap('{model}:countTokens', body['_url']);
8084
+ queryParams = body['_query'];
8085
+ delete body['config'];
8086
+ delete body['_url'];
8087
+ delete body['_query'];
8088
+ response = this.apiClient
8089
+ .request({
8090
+ path: path,
8091
+ queryParams: queryParams,
8092
+ body: JSON.stringify(body),
8093
+ httpMethod: 'POST',
8094
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
8095
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
8096
+ })
8097
+ .then((httpResponse) => {
8098
+ return httpResponse.json();
8099
+ });
8100
+ return response.then((apiResponse) => {
8101
+ const resp = countTokensResponseFromVertex(this.apiClient, apiResponse);
8102
+ const typedResp = new CountTokensResponse();
8103
+ Object.assign(typedResp, resp);
8104
+ return typedResp;
8105
+ });
8106
+ }
8107
+ else {
8108
+ const body = countTokensParametersToMldev(this.apiClient, params);
8109
+ path = formatMap('{model}:countTokens', body['_url']);
8110
+ queryParams = body['_query'];
8111
+ delete body['config'];
8112
+ delete body['_url'];
8113
+ delete body['_query'];
8114
+ response = this.apiClient
8115
+ .request({
8116
+ path: path,
8117
+ queryParams: queryParams,
8118
+ body: JSON.stringify(body),
8119
+ httpMethod: 'POST',
8120
+ httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
8121
+ abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
8122
+ })
8123
+ .then((httpResponse) => {
8124
+ return httpResponse.json();
8125
+ });
8126
+ return response.then((apiResponse) => {
8127
+ const resp = countTokensResponseFromMldev(this.apiClient, apiResponse);
8128
+ const typedResp = new CountTokensResponse();
8129
+ Object.assign(typedResp, resp);
8130
+ return typedResp;
8131
+ });
8132
+ }
8133
+ }
8134
+ /**
8135
+ * Given a list of contents, returns a corresponding TokensInfo containing
8136
+ * the list of tokens and list of token ids.
8137
+ *
8138
+ * This method is not supported by the Gemini Developer API.
8139
+ *
8140
+ * @param params - The parameters for computing tokens.
8141
+ * @return The response from the API.
8142
+ *
8143
+ * @example
8144
+ * ```ts
8145
+ * const response = await ai.models.computeTokens({
8146
+ * model: 'gemini-2.0-flash',
8147
+ * contents: 'What is your name?'
8148
+ * });
8149
+ * console.log(response);
8150
+ * ```
8151
+ */
8152
+ async computeTokens(params) {
8153
+ var _a, _b;
8268
8154
  let response;
8269
8155
  let path = '';
8270
8156
  let queryParams = {};
@@ -8282,6 +8168,7 @@ class Models extends BaseModule {
8282
8168
  body: JSON.stringify(body),
8283
8169
  httpMethod: 'POST',
8284
8170
  httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
8171
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
8285
8172
  })
8286
8173
  .then((httpResponse) => {
8287
8174
  return httpResponse.json();
@@ -8321,7 +8208,7 @@ class Models extends BaseModule {
8321
8208
  * ```
8322
8209
  */
8323
8210
  async generateVideos(params) {
8324
- var _a, _b;
8211
+ var _a, _b, _c, _d;
8325
8212
  let response;
8326
8213
  let path = '';
8327
8214
  let queryParams = {};
@@ -8339,6 +8226,7 @@ class Models extends BaseModule {
8339
8226
  body: JSON.stringify(body),
8340
8227
  httpMethod: 'POST',
8341
8228
  httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
8229
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
8342
8230
  })
8343
8231
  .then((httpResponse) => {
8344
8232
  return httpResponse.json();
@@ -8361,7 +8249,8 @@ class Models extends BaseModule {
8361
8249
  queryParams: queryParams,
8362
8250
  body: JSON.stringify(body),
8363
8251
  httpMethod: 'POST',
8364
- httpOptions: (_b = params.config) === null || _b === void 0 ? void 0 : _b.httpOptions,
8252
+ httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
8253
+ abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
8365
8254
  })
8366
8255
  .then((httpResponse) => {
8367
8256
  return httpResponse.json();
@@ -8458,14 +8347,13 @@ function generateVideosResponseFromMldev(apiClient, fromObject) {
8458
8347
  'generatedSamples',
8459
8348
  ]);
8460
8349
  if (fromGeneratedVideos != null) {
8461
- if (Array.isArray(fromGeneratedVideos)) {
8462
- setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos.map((item) => {
8350
+ let transformedList = fromGeneratedVideos;
8351
+ if (Array.isArray(transformedList)) {
8352
+ transformedList = transformedList.map((item) => {
8463
8353
  return generatedVideoFromMldev(apiClient, item);
8464
- }));
8465
- }
8466
- else {
8467
- setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos);
8354
+ });
8468
8355
  }
8356
+ setValueByPath(toObject, ['generatedVideos'], transformedList);
8469
8357
  }
8470
8358
  const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
8471
8359
  'raiMediaFilteredCount',
@@ -8538,14 +8426,13 @@ function generateVideosResponseFromVertex(apiClient, fromObject) {
8538
8426
  const toObject = {};
8539
8427
  const fromGeneratedVideos = getValueByPath(fromObject, ['videos']);
8540
8428
  if (fromGeneratedVideos != null) {
8541
- if (Array.isArray(fromGeneratedVideos)) {
8542
- setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos.map((item) => {
8429
+ let transformedList = fromGeneratedVideos;
8430
+ if (Array.isArray(transformedList)) {
8431
+ transformedList = transformedList.map((item) => {
8543
8432
  return generatedVideoFromVertex(apiClient, item);
8544
- }));
8545
- }
8546
- else {
8547
- setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos);
8433
+ });
8548
8434
  }
8435
+ setValueByPath(toObject, ['generatedVideos'], transformedList);
8549
8436
  }
8550
8437
  const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
8551
8438
  'raiMediaFilteredCount',
@@ -8628,7 +8515,7 @@ class Operations extends BaseModule {
8628
8515
  }
8629
8516
  }
8630
8517
  async getVideosOperationInternal(params) {
8631
- var _a, _b;
8518
+ var _a, _b, _c, _d;
8632
8519
  let response;
8633
8520
  let path = '';
8634
8521
  let queryParams = {};
@@ -8646,6 +8533,7 @@ class Operations extends BaseModule {
8646
8533
  body: JSON.stringify(body),
8647
8534
  httpMethod: 'GET',
8648
8535
  httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
8536
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
8649
8537
  })
8650
8538
  .then((httpResponse) => {
8651
8539
  return httpResponse.json();
@@ -8668,7 +8556,8 @@ class Operations extends BaseModule {
8668
8556
  queryParams: queryParams,
8669
8557
  body: JSON.stringify(body),
8670
8558
  httpMethod: 'GET',
8671
- httpOptions: (_b = params.config) === null || _b === void 0 ? void 0 : _b.httpOptions,
8559
+ httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
8560
+ abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
8672
8561
  })
8673
8562
  .then((httpResponse) => {
8674
8563
  return httpResponse.json();
@@ -8680,7 +8569,7 @@ class Operations extends BaseModule {
8680
8569
  }
8681
8570
  }
8682
8571
  async fetchPredictVideosOperationInternal(params) {
8683
- var _a;
8572
+ var _a, _b;
8684
8573
  let response;
8685
8574
  let path = '';
8686
8575
  let queryParams = {};
@@ -8698,6 +8587,7 @@ class Operations extends BaseModule {
8698
8587
  body: JSON.stringify(body),
8699
8588
  httpMethod: 'POST',
8700
8589
  httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
8590
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
8701
8591
  })
8702
8592
  .then((httpResponse) => {
8703
8593
  return httpResponse.json();
@@ -8722,7 +8612,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
8722
8612
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
8723
8613
  const USER_AGENT_HEADER = 'User-Agent';
8724
8614
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
8725
- const SDK_VERSION = '0.9.0'; // x-release-please-version
8615
+ const SDK_VERSION = '0.11.0'; // x-release-please-version
8726
8616
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
8727
8617
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
8728
8618
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -8851,7 +8741,7 @@ class ApiClient {
8851
8741
  getWebsocketBaseUrl() {
8852
8742
  const baseUrl = this.getBaseUrl();
8853
8743
  const urlParts = new URL(baseUrl);
8854
- urlParts.protocol = 'wss';
8744
+ urlParts.protocol = urlParts.protocol == 'http:' ? 'ws' : 'wss';
8855
8745
  return urlParts.toString();
8856
8746
  }
8857
8747
  setBaseUrl(url) {
@@ -8915,7 +8805,7 @@ class ApiClient {
8915
8805
  else {
8916
8806
  requestInit.body = request.body;
8917
8807
  }
8918
- requestInit = await this.includeExtraHttpOptionsToRequestInit(requestInit, patchedHttpOptions);
8808
+ requestInit = await this.includeExtraHttpOptionsToRequestInit(requestInit, patchedHttpOptions, request.abortSignal);
8919
8809
  return this.unaryApiCall(url, requestInit, request.httpMethod);
8920
8810
  }
8921
8811
  patchHttpOptions(baseHttpOptions, requestHttpOptions) {
@@ -8949,14 +8839,21 @@ class ApiClient {
8949
8839
  }
8950
8840
  let requestInit = {};
8951
8841
  requestInit.body = request.body;
8952
- requestInit = await this.includeExtraHttpOptionsToRequestInit(requestInit, patchedHttpOptions);
8842
+ requestInit = await this.includeExtraHttpOptionsToRequestInit(requestInit, patchedHttpOptions, request.abortSignal);
8953
8843
  return this.streamApiCall(url, requestInit, request.httpMethod);
8954
8844
  }
8955
- async includeExtraHttpOptionsToRequestInit(requestInit, httpOptions) {
8956
- if (httpOptions && httpOptions.timeout && httpOptions.timeout > 0) {
8845
+ async includeExtraHttpOptionsToRequestInit(requestInit, httpOptions, abortSignal) {
8846
+ if ((httpOptions && httpOptions.timeout) || abortSignal) {
8957
8847
  const abortController = new AbortController();
8958
8848
  const signal = abortController.signal;
8959
- setTimeout(() => abortController.abort(), httpOptions.timeout);
8849
+ if (httpOptions.timeout && (httpOptions === null || httpOptions === void 0 ? void 0 : httpOptions.timeout) > 0) {
8850
+ setTimeout(() => abortController.abort(), httpOptions.timeout);
8851
+ }
8852
+ if (abortSignal) {
8853
+ abortSignal.addEventListener('abort', () => {
8854
+ abortController.abort();
8855
+ });
8856
+ }
8960
8857
  requestInit.signal = signal;
8961
8858
  }
8962
8859
  requestInit.headers = await this.getHeadersInternal(httpOptions);
@@ -9011,6 +8908,30 @@ class ApiClient {
9011
8908
  break;
9012
8909
  }
9013
8910
  const chunkString = decoder.decode(value);
8911
+ // Parse and throw an error if the chunk contains an error.
8912
+ try {
8913
+ const chunkJson = JSON.parse(chunkString);
8914
+ if ('error' in chunkJson) {
8915
+ const errorJson = JSON.parse(JSON.stringify(chunkJson['error']));
8916
+ const status = errorJson['status'];
8917
+ const code = errorJson['code'];
8918
+ const errorMessage = `got status: ${status}. ${JSON.stringify(chunkJson)}`;
8919
+ if (code >= 400 && code < 500) {
8920
+ const clientError = new ClientError(errorMessage);
8921
+ throw clientError;
8922
+ }
8923
+ else if (code >= 500 && code < 600) {
8924
+ const serverError = new ServerError(errorMessage);
8925
+ throw serverError;
8926
+ }
8927
+ }
8928
+ }
8929
+ catch (e) {
8930
+ const error = e;
8931
+ if (error.name === 'ClientError' || error.name === 'ServerError') {
8932
+ throw e;
8933
+ }
8934
+ }
9014
8935
  buffer += chunkString;
9015
8936
  let match = buffer.match(responseLineRE);
9016
8937
  while (match) {
@@ -9149,7 +9070,7 @@ async function throwErrorIfNotOK(response) {
9149
9070
  else {
9150
9071
  errorBody = {
9151
9072
  error: {
9152
- message: 'exception parsing response',
9073
+ message: await response.text(),
9153
9074
  code: response.status,
9154
9075
  status: response.statusText,
9155
9076
  },
@@ -9168,98 +9089,828 @@ async function throwErrorIfNotOK(response) {
9168
9089
  }
9169
9090
  }
9170
9091
 
9171
- const MAX_CHUNK_SIZE = 1024 * 1024 * 8; // bytes
9172
- async function uploadBlob(file, uploadUrl, apiClient) {
9173
- var _a, _b;
9174
- let fileSize = 0;
9175
- let offset = 0;
9176
- let response = new HttpResponse(new Response());
9177
- let uploadCommand = 'upload';
9178
- fileSize = file.size;
9179
- while (offset < fileSize) {
9180
- const chunkSize = Math.min(MAX_CHUNK_SIZE, fileSize - offset);
9181
- const chunk = file.slice(offset, offset + chunkSize);
9182
- if (offset + chunkSize >= fileSize) {
9183
- uploadCommand += ', finalize';
9184
- }
9185
- response = await apiClient.request({
9186
- path: '',
9187
- body: chunk,
9188
- httpMethod: 'POST',
9189
- httpOptions: {
9190
- apiVersion: '',
9191
- baseUrl: uploadUrl,
9192
- headers: {
9193
- 'X-Goog-Upload-Command': uploadCommand,
9194
- 'X-Goog-Upload-Offset': String(offset),
9195
- 'Content-Length': String(chunkSize),
9196
- },
9197
- },
9198
- });
9199
- offset += chunkSize;
9200
- // The `x-goog-upload-status` header field can be `active`, `final` and
9201
- //`cancelled` in resposne.
9202
- if (((_a = response === null || response === void 0 ? void 0 : response.headers) === null || _a === void 0 ? void 0 : _a['x-goog-upload-status']) !== 'active') {
9203
- break;
9204
- }
9205
- // TODO(b/401391430) Investigate why the upload status is not finalized
9206
- // even though all content has been uploaded.
9207
- if (fileSize <= offset) {
9208
- throw new Error('All content has been uploaded, but the upload status is not finalized.');
9209
- }
9210
- }
9211
- const responseJson = (await (response === null || response === void 0 ? void 0 : response.json()));
9212
- if (((_b = response === null || response === void 0 ? void 0 : response.headers) === null || _b === void 0 ? void 0 : _b['x-goog-upload-status']) !== 'final') {
9213
- throw new Error('Failed to upload file: Upload status is not finalized.');
9214
- }
9215
- return responseJson['file'];
9216
- }
9217
- async function getBlobStat(file) {
9218
- const fileStat = { size: file.size, type: file.type };
9219
- return fileStat;
9220
- }
9221
-
9222
- class BrowserUploader {
9223
- async upload(file, uploadUrl, apiClient) {
9224
- if (typeof file === 'string') {
9225
- throw new Error('File path is not supported in browser uploader.');
9226
- }
9227
- return await uploadBlob(file, uploadUrl, apiClient);
9228
- }
9229
- async stat(file) {
9230
- if (typeof file === 'string') {
9231
- throw new Error('File path is not supported in browser uploader.');
9232
- }
9233
- else {
9234
- return await getBlobStat(file);
9235
- }
9236
- }
9237
- }
9238
-
9239
9092
  /**
9240
9093
  * @license
9241
9094
  * Copyright 2025 Google LLC
9242
9095
  * SPDX-License-Identifier: Apache-2.0
9243
9096
  */
9244
- // TODO((b/401271082): re-enable lint once BrowserWebSocketFactory is
9245
- // implemented.
9246
- /* eslint-disable @typescript-eslint/no-unused-vars */
9247
- class BrowserWebSocketFactory {
9248
- create(url, headers, callbacks) {
9249
- return new BrowserWebSocket(url, headers, callbacks);
9097
+ function getTuningJobParametersToMldev(apiClient, fromObject) {
9098
+ const toObject = {};
9099
+ const fromName = getValueByPath(fromObject, ['name']);
9100
+ if (fromName != null) {
9101
+ setValueByPath(toObject, ['_url', 'name'], fromName);
9102
+ }
9103
+ const fromConfig = getValueByPath(fromObject, ['config']);
9104
+ if (fromConfig != null) {
9105
+ setValueByPath(toObject, ['config'], fromConfig);
9250
9106
  }
9107
+ return toObject;
9251
9108
  }
9252
- class BrowserWebSocket {
9253
- constructor(url, headers, callbacks) {
9254
- this.url = url;
9255
- this.headers = headers;
9256
- this.callbacks = callbacks;
9109
+ function listTuningJobsConfigToMldev(apiClient, fromObject, parentObject) {
9110
+ const toObject = {};
9111
+ const fromPageSize = getValueByPath(fromObject, ['pageSize']);
9112
+ if (parentObject !== undefined && fromPageSize != null) {
9113
+ setValueByPath(parentObject, ['_query', 'pageSize'], fromPageSize);
9257
9114
  }
9258
- connect() {
9259
- this.ws = new WebSocket(this.url);
9260
- this.ws.onopen = this.callbacks.onopen;
9261
- this.ws.onerror = this.callbacks.onerror;
9262
- this.ws.onclose = this.callbacks.onclose;
9115
+ const fromPageToken = getValueByPath(fromObject, ['pageToken']);
9116
+ if (parentObject !== undefined && fromPageToken != null) {
9117
+ setValueByPath(parentObject, ['_query', 'pageToken'], fromPageToken);
9118
+ }
9119
+ const fromFilter = getValueByPath(fromObject, ['filter']);
9120
+ if (parentObject !== undefined && fromFilter != null) {
9121
+ setValueByPath(parentObject, ['_query', 'filter'], fromFilter);
9122
+ }
9123
+ return toObject;
9124
+ }
9125
+ function listTuningJobsParametersToMldev(apiClient, fromObject) {
9126
+ const toObject = {};
9127
+ const fromConfig = getValueByPath(fromObject, ['config']);
9128
+ if (fromConfig != null) {
9129
+ setValueByPath(toObject, ['config'], listTuningJobsConfigToMldev(apiClient, fromConfig, toObject));
9130
+ }
9131
+ return toObject;
9132
+ }
9133
+ function tuningExampleToMldev(apiClient, fromObject) {
9134
+ const toObject = {};
9135
+ const fromTextInput = getValueByPath(fromObject, ['textInput']);
9136
+ if (fromTextInput != null) {
9137
+ setValueByPath(toObject, ['textInput'], fromTextInput);
9138
+ }
9139
+ const fromOutput = getValueByPath(fromObject, ['output']);
9140
+ if (fromOutput != null) {
9141
+ setValueByPath(toObject, ['output'], fromOutput);
9142
+ }
9143
+ return toObject;
9144
+ }
9145
+ function tuningDatasetToMldev(apiClient, fromObject) {
9146
+ const toObject = {};
9147
+ if (getValueByPath(fromObject, ['gcsUri']) !== undefined) {
9148
+ throw new Error('gcsUri parameter is not supported in Gemini API.');
9149
+ }
9150
+ const fromExamples = getValueByPath(fromObject, ['examples']);
9151
+ if (fromExamples != null) {
9152
+ let transformedList = fromExamples;
9153
+ if (Array.isArray(transformedList)) {
9154
+ transformedList = transformedList.map((item) => {
9155
+ return tuningExampleToMldev(apiClient, item);
9156
+ });
9157
+ }
9158
+ setValueByPath(toObject, ['examples', 'examples'], transformedList);
9159
+ }
9160
+ return toObject;
9161
+ }
9162
+ function createTuningJobConfigToMldev(apiClient, fromObject, parentObject) {
9163
+ const toObject = {};
9164
+ if (getValueByPath(fromObject, ['validationDataset']) !== undefined) {
9165
+ throw new Error('validationDataset parameter is not supported in Gemini API.');
9166
+ }
9167
+ const fromTunedModelDisplayName = getValueByPath(fromObject, [
9168
+ 'tunedModelDisplayName',
9169
+ ]);
9170
+ if (parentObject !== undefined && fromTunedModelDisplayName != null) {
9171
+ setValueByPath(parentObject, ['displayName'], fromTunedModelDisplayName);
9172
+ }
9173
+ if (getValueByPath(fromObject, ['description']) !== undefined) {
9174
+ throw new Error('description parameter is not supported in Gemini API.');
9175
+ }
9176
+ const fromEpochCount = getValueByPath(fromObject, ['epochCount']);
9177
+ if (parentObject !== undefined && fromEpochCount != null) {
9178
+ setValueByPath(parentObject, ['tuningTask', 'hyperparameters', 'epochCount'], fromEpochCount);
9179
+ }
9180
+ const fromLearningRateMultiplier = getValueByPath(fromObject, [
9181
+ 'learningRateMultiplier',
9182
+ ]);
9183
+ if (fromLearningRateMultiplier != null) {
9184
+ setValueByPath(toObject, ['tuningTask', 'hyperparameters', 'learningRateMultiplier'], fromLearningRateMultiplier);
9185
+ }
9186
+ if (getValueByPath(fromObject, ['adapterSize']) !== undefined) {
9187
+ throw new Error('adapterSize parameter is not supported in Gemini API.');
9188
+ }
9189
+ const fromBatchSize = getValueByPath(fromObject, ['batchSize']);
9190
+ if (parentObject !== undefined && fromBatchSize != null) {
9191
+ setValueByPath(parentObject, ['tuningTask', 'hyperparameters', 'batchSize'], fromBatchSize);
9192
+ }
9193
+ const fromLearningRate = getValueByPath(fromObject, ['learningRate']);
9194
+ if (parentObject !== undefined && fromLearningRate != null) {
9195
+ setValueByPath(parentObject, ['tuningTask', 'hyperparameters', 'learningRate'], fromLearningRate);
9196
+ }
9197
+ return toObject;
9198
+ }
9199
+ function createTuningJobParametersToMldev(apiClient, fromObject) {
9200
+ const toObject = {};
9201
+ const fromBaseModel = getValueByPath(fromObject, ['baseModel']);
9202
+ if (fromBaseModel != null) {
9203
+ setValueByPath(toObject, ['baseModel'], fromBaseModel);
9204
+ }
9205
+ const fromTrainingDataset = getValueByPath(fromObject, [
9206
+ 'trainingDataset',
9207
+ ]);
9208
+ if (fromTrainingDataset != null) {
9209
+ setValueByPath(toObject, ['tuningTask', 'trainingData'], tuningDatasetToMldev(apiClient, fromTrainingDataset));
9210
+ }
9211
+ const fromConfig = getValueByPath(fromObject, ['config']);
9212
+ if (fromConfig != null) {
9213
+ setValueByPath(toObject, ['config'], createTuningJobConfigToMldev(apiClient, fromConfig, toObject));
9214
+ }
9215
+ return toObject;
9216
+ }
9217
+ function getTuningJobParametersToVertex(apiClient, fromObject) {
9218
+ const toObject = {};
9219
+ const fromName = getValueByPath(fromObject, ['name']);
9220
+ if (fromName != null) {
9221
+ setValueByPath(toObject, ['_url', 'name'], fromName);
9222
+ }
9223
+ const fromConfig = getValueByPath(fromObject, ['config']);
9224
+ if (fromConfig != null) {
9225
+ setValueByPath(toObject, ['config'], fromConfig);
9226
+ }
9227
+ return toObject;
9228
+ }
9229
+ function listTuningJobsConfigToVertex(apiClient, fromObject, parentObject) {
9230
+ const toObject = {};
9231
+ const fromPageSize = getValueByPath(fromObject, ['pageSize']);
9232
+ if (parentObject !== undefined && fromPageSize != null) {
9233
+ setValueByPath(parentObject, ['_query', 'pageSize'], fromPageSize);
9234
+ }
9235
+ const fromPageToken = getValueByPath(fromObject, ['pageToken']);
9236
+ if (parentObject !== undefined && fromPageToken != null) {
9237
+ setValueByPath(parentObject, ['_query', 'pageToken'], fromPageToken);
9238
+ }
9239
+ const fromFilter = getValueByPath(fromObject, ['filter']);
9240
+ if (parentObject !== undefined && fromFilter != null) {
9241
+ setValueByPath(parentObject, ['_query', 'filter'], fromFilter);
9242
+ }
9243
+ return toObject;
9244
+ }
9245
+ function listTuningJobsParametersToVertex(apiClient, fromObject) {
9246
+ const toObject = {};
9247
+ const fromConfig = getValueByPath(fromObject, ['config']);
9248
+ if (fromConfig != null) {
9249
+ setValueByPath(toObject, ['config'], listTuningJobsConfigToVertex(apiClient, fromConfig, toObject));
9250
+ }
9251
+ return toObject;
9252
+ }
9253
+ function tuningDatasetToVertex(apiClient, fromObject, parentObject) {
9254
+ const toObject = {};
9255
+ const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
9256
+ if (parentObject !== undefined && fromGcsUri != null) {
9257
+ setValueByPath(parentObject, ['supervisedTuningSpec', 'trainingDatasetUri'], fromGcsUri);
9258
+ }
9259
+ if (getValueByPath(fromObject, ['examples']) !== undefined) {
9260
+ throw new Error('examples parameter is not supported in Vertex AI.');
9261
+ }
9262
+ return toObject;
9263
+ }
9264
+ function tuningValidationDatasetToVertex(apiClient, fromObject) {
9265
+ const toObject = {};
9266
+ const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
9267
+ if (fromGcsUri != null) {
9268
+ setValueByPath(toObject, ['validationDatasetUri'], fromGcsUri);
9269
+ }
9270
+ return toObject;
9271
+ }
9272
+ function createTuningJobConfigToVertex(apiClient, fromObject, parentObject) {
9273
+ const toObject = {};
9274
+ const fromValidationDataset = getValueByPath(fromObject, [
9275
+ 'validationDataset',
9276
+ ]);
9277
+ if (parentObject !== undefined && fromValidationDataset != null) {
9278
+ setValueByPath(parentObject, ['supervisedTuningSpec'], tuningValidationDatasetToVertex(apiClient, fromValidationDataset));
9279
+ }
9280
+ const fromTunedModelDisplayName = getValueByPath(fromObject, [
9281
+ 'tunedModelDisplayName',
9282
+ ]);
9283
+ if (parentObject !== undefined && fromTunedModelDisplayName != null) {
9284
+ setValueByPath(parentObject, ['tunedModelDisplayName'], fromTunedModelDisplayName);
9285
+ }
9286
+ const fromDescription = getValueByPath(fromObject, ['description']);
9287
+ if (parentObject !== undefined && fromDescription != null) {
9288
+ setValueByPath(parentObject, ['description'], fromDescription);
9289
+ }
9290
+ const fromEpochCount = getValueByPath(fromObject, ['epochCount']);
9291
+ if (parentObject !== undefined && fromEpochCount != null) {
9292
+ setValueByPath(parentObject, ['supervisedTuningSpec', 'hyperParameters', 'epochCount'], fromEpochCount);
9293
+ }
9294
+ const fromLearningRateMultiplier = getValueByPath(fromObject, [
9295
+ 'learningRateMultiplier',
9296
+ ]);
9297
+ if (parentObject !== undefined && fromLearningRateMultiplier != null) {
9298
+ setValueByPath(parentObject, ['supervisedTuningSpec', 'hyperParameters', 'learningRateMultiplier'], fromLearningRateMultiplier);
9299
+ }
9300
+ const fromAdapterSize = getValueByPath(fromObject, ['adapterSize']);
9301
+ if (parentObject !== undefined && fromAdapterSize != null) {
9302
+ setValueByPath(parentObject, ['supervisedTuningSpec', 'hyperParameters', 'adapterSize'], fromAdapterSize);
9303
+ }
9304
+ if (getValueByPath(fromObject, ['batchSize']) !== undefined) {
9305
+ throw new Error('batchSize parameter is not supported in Vertex AI.');
9306
+ }
9307
+ if (getValueByPath(fromObject, ['learningRate']) !== undefined) {
9308
+ throw new Error('learningRate parameter is not supported in Vertex AI.');
9309
+ }
9310
+ return toObject;
9311
+ }
9312
+ function createTuningJobParametersToVertex(apiClient, fromObject) {
9313
+ const toObject = {};
9314
+ const fromBaseModel = getValueByPath(fromObject, ['baseModel']);
9315
+ if (fromBaseModel != null) {
9316
+ setValueByPath(toObject, ['baseModel'], fromBaseModel);
9317
+ }
9318
+ const fromTrainingDataset = getValueByPath(fromObject, [
9319
+ 'trainingDataset',
9320
+ ]);
9321
+ if (fromTrainingDataset != null) {
9322
+ setValueByPath(toObject, ['supervisedTuningSpec', 'trainingDatasetUri'], tuningDatasetToVertex(apiClient, fromTrainingDataset, toObject));
9323
+ }
9324
+ const fromConfig = getValueByPath(fromObject, ['config']);
9325
+ if (fromConfig != null) {
9326
+ setValueByPath(toObject, ['config'], createTuningJobConfigToVertex(apiClient, fromConfig, toObject));
9327
+ }
9328
+ return toObject;
9329
+ }
9330
+ function tunedModelFromMldev(apiClient, fromObject) {
9331
+ const toObject = {};
9332
+ const fromModel = getValueByPath(fromObject, ['name']);
9333
+ if (fromModel != null) {
9334
+ setValueByPath(toObject, ['model'], fromModel);
9335
+ }
9336
+ const fromEndpoint = getValueByPath(fromObject, ['name']);
9337
+ if (fromEndpoint != null) {
9338
+ setValueByPath(toObject, ['endpoint'], fromEndpoint);
9339
+ }
9340
+ return toObject;
9341
+ }
9342
+ function tuningJobFromMldev(apiClient, fromObject) {
9343
+ const toObject = {};
9344
+ const fromName = getValueByPath(fromObject, ['name']);
9345
+ if (fromName != null) {
9346
+ setValueByPath(toObject, ['name'], fromName);
9347
+ }
9348
+ const fromState = getValueByPath(fromObject, ['state']);
9349
+ if (fromState != null) {
9350
+ setValueByPath(toObject, ['state'], tTuningJobStatus(apiClient, fromState));
9351
+ }
9352
+ const fromCreateTime = getValueByPath(fromObject, ['createTime']);
9353
+ if (fromCreateTime != null) {
9354
+ setValueByPath(toObject, ['createTime'], fromCreateTime);
9355
+ }
9356
+ const fromStartTime = getValueByPath(fromObject, [
9357
+ 'tuningTask',
9358
+ 'startTime',
9359
+ ]);
9360
+ if (fromStartTime != null) {
9361
+ setValueByPath(toObject, ['startTime'], fromStartTime);
9362
+ }
9363
+ const fromEndTime = getValueByPath(fromObject, [
9364
+ 'tuningTask',
9365
+ 'completeTime',
9366
+ ]);
9367
+ if (fromEndTime != null) {
9368
+ setValueByPath(toObject, ['endTime'], fromEndTime);
9369
+ }
9370
+ const fromUpdateTime = getValueByPath(fromObject, ['updateTime']);
9371
+ if (fromUpdateTime != null) {
9372
+ setValueByPath(toObject, ['updateTime'], fromUpdateTime);
9373
+ }
9374
+ const fromDescription = getValueByPath(fromObject, ['description']);
9375
+ if (fromDescription != null) {
9376
+ setValueByPath(toObject, ['description'], fromDescription);
9377
+ }
9378
+ const fromBaseModel = getValueByPath(fromObject, ['baseModel']);
9379
+ if (fromBaseModel != null) {
9380
+ setValueByPath(toObject, ['baseModel'], fromBaseModel);
9381
+ }
9382
+ const fromTunedModel = getValueByPath(fromObject, ['_self']);
9383
+ if (fromTunedModel != null) {
9384
+ setValueByPath(toObject, ['tunedModel'], tunedModelFromMldev(apiClient, fromTunedModel));
9385
+ }
9386
+ const fromDistillationSpec = getValueByPath(fromObject, [
9387
+ 'distillationSpec',
9388
+ ]);
9389
+ if (fromDistillationSpec != null) {
9390
+ setValueByPath(toObject, ['distillationSpec'], fromDistillationSpec);
9391
+ }
9392
+ const fromExperiment = getValueByPath(fromObject, ['experiment']);
9393
+ if (fromExperiment != null) {
9394
+ setValueByPath(toObject, ['experiment'], fromExperiment);
9395
+ }
9396
+ const fromLabels = getValueByPath(fromObject, ['labels']);
9397
+ if (fromLabels != null) {
9398
+ setValueByPath(toObject, ['labels'], fromLabels);
9399
+ }
9400
+ const fromPipelineJob = getValueByPath(fromObject, ['pipelineJob']);
9401
+ if (fromPipelineJob != null) {
9402
+ setValueByPath(toObject, ['pipelineJob'], fromPipelineJob);
9403
+ }
9404
+ const fromTunedModelDisplayName = getValueByPath(fromObject, [
9405
+ 'tunedModelDisplayName',
9406
+ ]);
9407
+ if (fromTunedModelDisplayName != null) {
9408
+ setValueByPath(toObject, ['tunedModelDisplayName'], fromTunedModelDisplayName);
9409
+ }
9410
+ return toObject;
9411
+ }
9412
+ function listTuningJobsResponseFromMldev(apiClient, fromObject) {
9413
+ const toObject = {};
9414
+ const fromNextPageToken = getValueByPath(fromObject, [
9415
+ 'nextPageToken',
9416
+ ]);
9417
+ if (fromNextPageToken != null) {
9418
+ setValueByPath(toObject, ['nextPageToken'], fromNextPageToken);
9419
+ }
9420
+ const fromTuningJobs = getValueByPath(fromObject, ['tunedModels']);
9421
+ if (fromTuningJobs != null) {
9422
+ let transformedList = fromTuningJobs;
9423
+ if (Array.isArray(transformedList)) {
9424
+ transformedList = transformedList.map((item) => {
9425
+ return tuningJobFromMldev(apiClient, item);
9426
+ });
9427
+ }
9428
+ setValueByPath(toObject, ['tuningJobs'], transformedList);
9429
+ }
9430
+ return toObject;
9431
+ }
9432
+ function operationFromMldev(apiClient, fromObject) {
9433
+ const toObject = {};
9434
+ const fromName = getValueByPath(fromObject, ['name']);
9435
+ if (fromName != null) {
9436
+ setValueByPath(toObject, ['name'], fromName);
9437
+ }
9438
+ const fromMetadata = getValueByPath(fromObject, ['metadata']);
9439
+ if (fromMetadata != null) {
9440
+ setValueByPath(toObject, ['metadata'], fromMetadata);
9441
+ }
9442
+ const fromDone = getValueByPath(fromObject, ['done']);
9443
+ if (fromDone != null) {
9444
+ setValueByPath(toObject, ['done'], fromDone);
9445
+ }
9446
+ const fromError = getValueByPath(fromObject, ['error']);
9447
+ if (fromError != null) {
9448
+ setValueByPath(toObject, ['error'], fromError);
9449
+ }
9450
+ return toObject;
9451
+ }
9452
+ function tunedModelFromVertex(apiClient, fromObject) {
9453
+ const toObject = {};
9454
+ const fromModel = getValueByPath(fromObject, ['model']);
9455
+ if (fromModel != null) {
9456
+ setValueByPath(toObject, ['model'], fromModel);
9457
+ }
9458
+ const fromEndpoint = getValueByPath(fromObject, ['endpoint']);
9459
+ if (fromEndpoint != null) {
9460
+ setValueByPath(toObject, ['endpoint'], fromEndpoint);
9461
+ }
9462
+ return toObject;
9463
+ }
9464
+ function tuningJobFromVertex(apiClient, fromObject) {
9465
+ const toObject = {};
9466
+ const fromName = getValueByPath(fromObject, ['name']);
9467
+ if (fromName != null) {
9468
+ setValueByPath(toObject, ['name'], fromName);
9469
+ }
9470
+ const fromState = getValueByPath(fromObject, ['state']);
9471
+ if (fromState != null) {
9472
+ setValueByPath(toObject, ['state'], tTuningJobStatus(apiClient, fromState));
9473
+ }
9474
+ const fromCreateTime = getValueByPath(fromObject, ['createTime']);
9475
+ if (fromCreateTime != null) {
9476
+ setValueByPath(toObject, ['createTime'], fromCreateTime);
9477
+ }
9478
+ const fromStartTime = getValueByPath(fromObject, ['startTime']);
9479
+ if (fromStartTime != null) {
9480
+ setValueByPath(toObject, ['startTime'], fromStartTime);
9481
+ }
9482
+ const fromEndTime = getValueByPath(fromObject, ['endTime']);
9483
+ if (fromEndTime != null) {
9484
+ setValueByPath(toObject, ['endTime'], fromEndTime);
9485
+ }
9486
+ const fromUpdateTime = getValueByPath(fromObject, ['updateTime']);
9487
+ if (fromUpdateTime != null) {
9488
+ setValueByPath(toObject, ['updateTime'], fromUpdateTime);
9489
+ }
9490
+ const fromError = getValueByPath(fromObject, ['error']);
9491
+ if (fromError != null) {
9492
+ setValueByPath(toObject, ['error'], fromError);
9493
+ }
9494
+ const fromDescription = getValueByPath(fromObject, ['description']);
9495
+ if (fromDescription != null) {
9496
+ setValueByPath(toObject, ['description'], fromDescription);
9497
+ }
9498
+ const fromBaseModel = getValueByPath(fromObject, ['baseModel']);
9499
+ if (fromBaseModel != null) {
9500
+ setValueByPath(toObject, ['baseModel'], fromBaseModel);
9501
+ }
9502
+ const fromTunedModel = getValueByPath(fromObject, ['tunedModel']);
9503
+ if (fromTunedModel != null) {
9504
+ setValueByPath(toObject, ['tunedModel'], tunedModelFromVertex(apiClient, fromTunedModel));
9505
+ }
9506
+ const fromSupervisedTuningSpec = getValueByPath(fromObject, [
9507
+ 'supervisedTuningSpec',
9508
+ ]);
9509
+ if (fromSupervisedTuningSpec != null) {
9510
+ setValueByPath(toObject, ['supervisedTuningSpec'], fromSupervisedTuningSpec);
9511
+ }
9512
+ const fromTuningDataStats = getValueByPath(fromObject, [
9513
+ 'tuningDataStats',
9514
+ ]);
9515
+ if (fromTuningDataStats != null) {
9516
+ setValueByPath(toObject, ['tuningDataStats'], fromTuningDataStats);
9517
+ }
9518
+ const fromEncryptionSpec = getValueByPath(fromObject, [
9519
+ 'encryptionSpec',
9520
+ ]);
9521
+ if (fromEncryptionSpec != null) {
9522
+ setValueByPath(toObject, ['encryptionSpec'], fromEncryptionSpec);
9523
+ }
9524
+ const fromPartnerModelTuningSpec = getValueByPath(fromObject, [
9525
+ 'partnerModelTuningSpec',
9526
+ ]);
9527
+ if (fromPartnerModelTuningSpec != null) {
9528
+ setValueByPath(toObject, ['partnerModelTuningSpec'], fromPartnerModelTuningSpec);
9529
+ }
9530
+ const fromDistillationSpec = getValueByPath(fromObject, [
9531
+ 'distillationSpec',
9532
+ ]);
9533
+ if (fromDistillationSpec != null) {
9534
+ setValueByPath(toObject, ['distillationSpec'], fromDistillationSpec);
9535
+ }
9536
+ const fromExperiment = getValueByPath(fromObject, ['experiment']);
9537
+ if (fromExperiment != null) {
9538
+ setValueByPath(toObject, ['experiment'], fromExperiment);
9539
+ }
9540
+ const fromLabels = getValueByPath(fromObject, ['labels']);
9541
+ if (fromLabels != null) {
9542
+ setValueByPath(toObject, ['labels'], fromLabels);
9543
+ }
9544
+ const fromPipelineJob = getValueByPath(fromObject, ['pipelineJob']);
9545
+ if (fromPipelineJob != null) {
9546
+ setValueByPath(toObject, ['pipelineJob'], fromPipelineJob);
9547
+ }
9548
+ const fromTunedModelDisplayName = getValueByPath(fromObject, [
9549
+ 'tunedModelDisplayName',
9550
+ ]);
9551
+ if (fromTunedModelDisplayName != null) {
9552
+ setValueByPath(toObject, ['tunedModelDisplayName'], fromTunedModelDisplayName);
9553
+ }
9554
+ return toObject;
9555
+ }
9556
+ function listTuningJobsResponseFromVertex(apiClient, fromObject) {
9557
+ const toObject = {};
9558
+ const fromNextPageToken = getValueByPath(fromObject, [
9559
+ 'nextPageToken',
9560
+ ]);
9561
+ if (fromNextPageToken != null) {
9562
+ setValueByPath(toObject, ['nextPageToken'], fromNextPageToken);
9563
+ }
9564
+ const fromTuningJobs = getValueByPath(fromObject, ['tuningJobs']);
9565
+ if (fromTuningJobs != null) {
9566
+ let transformedList = fromTuningJobs;
9567
+ if (Array.isArray(transformedList)) {
9568
+ transformedList = transformedList.map((item) => {
9569
+ return tuningJobFromVertex(apiClient, item);
9570
+ });
9571
+ }
9572
+ setValueByPath(toObject, ['tuningJobs'], transformedList);
9573
+ }
9574
+ return toObject;
9575
+ }
9576
+
9577
+ /**
9578
+ * @license
9579
+ * Copyright 2025 Google LLC
9580
+ * SPDX-License-Identifier: Apache-2.0
9581
+ */
9582
+ class Tunings extends BaseModule {
9583
+ constructor(apiClient) {
9584
+ super();
9585
+ this.apiClient = apiClient;
9586
+ /**
9587
+ * Gets a TuningJob.
9588
+ *
9589
+ * @param name - The resource name of the tuning job.
9590
+ * @return - A TuningJob object.
9591
+ *
9592
+ * @experimental - The SDK's tuning implementation is experimental, and may
9593
+ * change in future versions.
9594
+ */
9595
+ this.get = async (params) => {
9596
+ return await this.getInternal(params);
9597
+ };
9598
+ /**
9599
+ * Lists tuning jobs.
9600
+ *
9601
+ * @param config - The configuration for the list request.
9602
+ * @return - A list of tuning jobs.
9603
+ *
9604
+ * @experimental - The SDK's tuning implementation is experimental, and may
9605
+ * change in future versions.
9606
+ */
9607
+ this.list = async (params = {}) => {
9608
+ return new Pager(PagedItem.PAGED_ITEM_TUNING_JOBS, (x) => this.listInternal(x), await this.listInternal(params), params);
9609
+ };
9610
+ /**
9611
+ * Creates a supervised fine-tuning job.
9612
+ *
9613
+ * @param params - The parameters for the tuning job.
9614
+ * @return - A TuningJob operation.
9615
+ *
9616
+ * @experimental - The SDK's tuning implementation is experimental, and may
9617
+ * change in future versions.
9618
+ */
9619
+ this.tune = async (params) => {
9620
+ if (this.apiClient.isVertexAI()) {
9621
+ return await this.tuneInternal(params);
9622
+ }
9623
+ else {
9624
+ const operation = await this.tuneMldevInternal(params);
9625
+ let tunedModelName = '';
9626
+ if (operation['metadata'] !== undefined &&
9627
+ operation['metadata']['tunedModel'] !== undefined) {
9628
+ tunedModelName = operation['metadata']['tunedModel'];
9629
+ }
9630
+ else if (operation['name'] !== undefined &&
9631
+ operation['name'].includes('/operations/')) {
9632
+ tunedModelName = operation['name'].split('/operations/')[0];
9633
+ }
9634
+ const tuningJob = {
9635
+ name: tunedModelName,
9636
+ state: JobState.JOB_STATE_QUEUED,
9637
+ };
9638
+ return tuningJob;
9639
+ }
9640
+ };
9641
+ }
9642
+ async getInternal(params) {
9643
+ var _a, _b, _c, _d;
9644
+ let response;
9645
+ let path = '';
9646
+ let queryParams = {};
9647
+ if (this.apiClient.isVertexAI()) {
9648
+ const body = getTuningJobParametersToVertex(this.apiClient, params);
9649
+ path = formatMap('{name}', body['_url']);
9650
+ queryParams = body['_query'];
9651
+ delete body['config'];
9652
+ delete body['_url'];
9653
+ delete body['_query'];
9654
+ response = this.apiClient
9655
+ .request({
9656
+ path: path,
9657
+ queryParams: queryParams,
9658
+ body: JSON.stringify(body),
9659
+ httpMethod: 'GET',
9660
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
9661
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
9662
+ })
9663
+ .then((httpResponse) => {
9664
+ return httpResponse.json();
9665
+ });
9666
+ return response.then((apiResponse) => {
9667
+ const resp = tuningJobFromVertex(this.apiClient, apiResponse);
9668
+ return resp;
9669
+ });
9670
+ }
9671
+ else {
9672
+ const body = getTuningJobParametersToMldev(this.apiClient, params);
9673
+ path = formatMap('{name}', body['_url']);
9674
+ queryParams = body['_query'];
9675
+ delete body['config'];
9676
+ delete body['_url'];
9677
+ delete body['_query'];
9678
+ response = this.apiClient
9679
+ .request({
9680
+ path: path,
9681
+ queryParams: queryParams,
9682
+ body: JSON.stringify(body),
9683
+ httpMethod: 'GET',
9684
+ httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
9685
+ abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
9686
+ })
9687
+ .then((httpResponse) => {
9688
+ return httpResponse.json();
9689
+ });
9690
+ return response.then((apiResponse) => {
9691
+ const resp = tuningJobFromMldev(this.apiClient, apiResponse);
9692
+ return resp;
9693
+ });
9694
+ }
9695
+ }
9696
+ async listInternal(params) {
9697
+ var _a, _b, _c, _d;
9698
+ let response;
9699
+ let path = '';
9700
+ let queryParams = {};
9701
+ if (this.apiClient.isVertexAI()) {
9702
+ const body = listTuningJobsParametersToVertex(this.apiClient, params);
9703
+ path = formatMap('tuningJobs', body['_url']);
9704
+ queryParams = body['_query'];
9705
+ delete body['config'];
9706
+ delete body['_url'];
9707
+ delete body['_query'];
9708
+ response = this.apiClient
9709
+ .request({
9710
+ path: path,
9711
+ queryParams: queryParams,
9712
+ body: JSON.stringify(body),
9713
+ httpMethod: 'GET',
9714
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
9715
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
9716
+ })
9717
+ .then((httpResponse) => {
9718
+ return httpResponse.json();
9719
+ });
9720
+ return response.then((apiResponse) => {
9721
+ const resp = listTuningJobsResponseFromVertex(this.apiClient, apiResponse);
9722
+ const typedResp = new ListTuningJobsResponse();
9723
+ Object.assign(typedResp, resp);
9724
+ return typedResp;
9725
+ });
9726
+ }
9727
+ else {
9728
+ const body = listTuningJobsParametersToMldev(this.apiClient, params);
9729
+ path = formatMap('tunedModels', body['_url']);
9730
+ queryParams = body['_query'];
9731
+ delete body['config'];
9732
+ delete body['_url'];
9733
+ delete body['_query'];
9734
+ response = this.apiClient
9735
+ .request({
9736
+ path: path,
9737
+ queryParams: queryParams,
9738
+ body: JSON.stringify(body),
9739
+ httpMethod: 'GET',
9740
+ httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
9741
+ abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
9742
+ })
9743
+ .then((httpResponse) => {
9744
+ return httpResponse.json();
9745
+ });
9746
+ return response.then((apiResponse) => {
9747
+ const resp = listTuningJobsResponseFromMldev(this.apiClient, apiResponse);
9748
+ const typedResp = new ListTuningJobsResponse();
9749
+ Object.assign(typedResp, resp);
9750
+ return typedResp;
9751
+ });
9752
+ }
9753
+ }
9754
+ async tuneInternal(params) {
9755
+ var _a, _b;
9756
+ let response;
9757
+ let path = '';
9758
+ let queryParams = {};
9759
+ if (this.apiClient.isVertexAI()) {
9760
+ const body = createTuningJobParametersToVertex(this.apiClient, params);
9761
+ path = formatMap('tuningJobs', body['_url']);
9762
+ queryParams = body['_query'];
9763
+ delete body['config'];
9764
+ delete body['_url'];
9765
+ delete body['_query'];
9766
+ response = this.apiClient
9767
+ .request({
9768
+ path: path,
9769
+ queryParams: queryParams,
9770
+ body: JSON.stringify(body),
9771
+ httpMethod: 'POST',
9772
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
9773
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
9774
+ })
9775
+ .then((httpResponse) => {
9776
+ return httpResponse.json();
9777
+ });
9778
+ return response.then((apiResponse) => {
9779
+ const resp = tuningJobFromVertex(this.apiClient, apiResponse);
9780
+ return resp;
9781
+ });
9782
+ }
9783
+ else {
9784
+ throw new Error('This method is only supported by the Vertex AI.');
9785
+ }
9786
+ }
9787
+ async tuneMldevInternal(params) {
9788
+ var _a, _b;
9789
+ let response;
9790
+ let path = '';
9791
+ let queryParams = {};
9792
+ if (this.apiClient.isVertexAI()) {
9793
+ throw new Error('This method is only supported by the Gemini Developer API.');
9794
+ }
9795
+ else {
9796
+ const body = createTuningJobParametersToMldev(this.apiClient, params);
9797
+ path = formatMap('tunedModels', body['_url']);
9798
+ queryParams = body['_query'];
9799
+ delete body['config'];
9800
+ delete body['_url'];
9801
+ delete body['_query'];
9802
+ response = this.apiClient
9803
+ .request({
9804
+ path: path,
9805
+ queryParams: queryParams,
9806
+ body: JSON.stringify(body),
9807
+ httpMethod: 'POST',
9808
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
9809
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
9810
+ })
9811
+ .then((httpResponse) => {
9812
+ return httpResponse.json();
9813
+ });
9814
+ return response.then((apiResponse) => {
9815
+ const resp = operationFromMldev(this.apiClient, apiResponse);
9816
+ return resp;
9817
+ });
9818
+ }
9819
+ }
9820
+ }
9821
+
9822
+ const MAX_CHUNK_SIZE = 1024 * 1024 * 8; // bytes
9823
+ async function uploadBlob(file, uploadUrl, apiClient) {
9824
+ var _a, _b;
9825
+ let fileSize = 0;
9826
+ let offset = 0;
9827
+ let response = new HttpResponse(new Response());
9828
+ let uploadCommand = 'upload';
9829
+ fileSize = file.size;
9830
+ while (offset < fileSize) {
9831
+ const chunkSize = Math.min(MAX_CHUNK_SIZE, fileSize - offset);
9832
+ const chunk = file.slice(offset, offset + chunkSize);
9833
+ if (offset + chunkSize >= fileSize) {
9834
+ uploadCommand += ', finalize';
9835
+ }
9836
+ response = await apiClient.request({
9837
+ path: '',
9838
+ body: chunk,
9839
+ httpMethod: 'POST',
9840
+ httpOptions: {
9841
+ apiVersion: '',
9842
+ baseUrl: uploadUrl,
9843
+ headers: {
9844
+ 'X-Goog-Upload-Command': uploadCommand,
9845
+ 'X-Goog-Upload-Offset': String(offset),
9846
+ 'Content-Length': String(chunkSize),
9847
+ },
9848
+ },
9849
+ });
9850
+ offset += chunkSize;
9851
+ // The `x-goog-upload-status` header field can be `active`, `final` and
9852
+ //`cancelled` in resposne.
9853
+ if (((_a = response === null || response === void 0 ? void 0 : response.headers) === null || _a === void 0 ? void 0 : _a['x-goog-upload-status']) !== 'active') {
9854
+ break;
9855
+ }
9856
+ // TODO(b/401391430) Investigate why the upload status is not finalized
9857
+ // even though all content has been uploaded.
9858
+ if (fileSize <= offset) {
9859
+ throw new Error('All content has been uploaded, but the upload status is not finalized.');
9860
+ }
9861
+ }
9862
+ const responseJson = (await (response === null || response === void 0 ? void 0 : response.json()));
9863
+ if (((_b = response === null || response === void 0 ? void 0 : response.headers) === null || _b === void 0 ? void 0 : _b['x-goog-upload-status']) !== 'final') {
9864
+ throw new Error('Failed to upload file: Upload status is not finalized.');
9865
+ }
9866
+ return responseJson['file'];
9867
+ }
9868
+ async function getBlobStat(file) {
9869
+ const fileStat = { size: file.size, type: file.type };
9870
+ return fileStat;
9871
+ }
9872
+
9873
+ class BrowserUploader {
9874
+ async upload(file, uploadUrl, apiClient) {
9875
+ if (typeof file === 'string') {
9876
+ throw new Error('File path is not supported in browser uploader.');
9877
+ }
9878
+ return await uploadBlob(file, uploadUrl, apiClient);
9879
+ }
9880
+ async stat(file) {
9881
+ if (typeof file === 'string') {
9882
+ throw new Error('File path is not supported in browser uploader.');
9883
+ }
9884
+ else {
9885
+ return await getBlobStat(file);
9886
+ }
9887
+ }
9888
+ }
9889
+
9890
+ /**
9891
+ * @license
9892
+ * Copyright 2025 Google LLC
9893
+ * SPDX-License-Identifier: Apache-2.0
9894
+ */
9895
+ // TODO((b/401271082): re-enable lint once BrowserWebSocketFactory is
9896
+ // implemented.
9897
+ /* eslint-disable @typescript-eslint/no-unused-vars */
9898
+ class BrowserWebSocketFactory {
9899
+ create(url, headers, callbacks) {
9900
+ return new BrowserWebSocket(url, headers, callbacks);
9901
+ }
9902
+ }
9903
+ class BrowserWebSocket {
9904
+ constructor(url, headers, callbacks) {
9905
+ this.url = url;
9906
+ this.headers = headers;
9907
+ this.callbacks = callbacks;
9908
+ }
9909
+ connect() {
9910
+ this.ws = new WebSocket(this.url);
9911
+ this.ws.onopen = this.callbacks.onopen;
9912
+ this.ws.onerror = this.callbacks.onerror;
9913
+ this.ws.onclose = this.callbacks.onclose;
9263
9914
  this.ws.onmessage = this.callbacks.onmessage;
9264
9915
  }
9265
9916
  send(message) {
@@ -9349,6 +10000,17 @@ class GoogleGenAI {
9349
10000
  }
9350
10001
  this.vertexai = (_a = options.vertexai) !== null && _a !== void 0 ? _a : false;
9351
10002
  this.apiKey = options.apiKey;
10003
+ const baseUrl = getBaseUrl(options,
10004
+ /*vertexBaseUrlFromEnv*/ undefined,
10005
+ /*geminiBaseUrlFromEnv*/ undefined);
10006
+ if (baseUrl) {
10007
+ if (options.httpOptions) {
10008
+ options.httpOptions.baseUrl = baseUrl;
10009
+ }
10010
+ else {
10011
+ options.httpOptions = { baseUrl: baseUrl };
10012
+ }
10013
+ }
9352
10014
  this.apiVersion = options.apiVersion;
9353
10015
  const auth = new WebAuth(this.apiKey);
9354
10016
  this.apiClient = new ApiClient({
@@ -9366,8 +10028,9 @@ class GoogleGenAI {
9366
10028
  this.caches = new Caches(this.apiClient);
9367
10029
  this.files = new Files(this.apiClient);
9368
10030
  this.operations = new Operations(this.apiClient);
10031
+ this.tunings = new Tunings(this.apiClient);
9369
10032
  }
9370
10033
  }
9371
10034
 
9372
- export { ActivityHandling, BlockedReason, Caches, Chat, Chats, ComputeTokensResponse, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DynamicRetrievalConfigMode, EmbedContentResponse, EndSensitivity, FeatureSelectionPreference, FileSource, FileState, Files, FinishReason, FunctionCallingConfigMode, FunctionResponse, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GenerateVideosResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpResponse, ImagePromptLanguage, Language, ListCachedContentsResponse, ListFilesResponse, Live, LiveClientToolResponse, LiveSendToolResponseParameters, MaskReferenceMode, MediaModality, MediaResolution, Modality, Mode, Models, Operations, Outcome, PagedItem, Pager, PersonGeneration, ReplayResponse, SafetyFilterLevel, Session, StartSensitivity, SubjectReferenceType, TrafficType, TurnCoverage, Type, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent };
10035
+ export { ActivityHandling, AdapterSize, BlockedReason, Caches, Chat, Chats, ComputeTokensResponse, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DeleteModelResponse, DynamicRetrievalConfigMode, EmbedContentResponse, EndSensitivity, FeatureSelectionPreference, FileSource, FileState, Files, FinishReason, FunctionCallingConfigMode, FunctionResponse, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GenerateVideosResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpResponse, ImagePromptLanguage, JobState, Language, ListCachedContentsResponse, ListFilesResponse, ListTuningJobsResponse, Live, LiveClientToolResponse, LiveSendToolResponseParameters, MaskReferenceMode, MediaModality, MediaResolution, Modality, Mode, Models, Operations, Outcome, PagedItem, Pager, PersonGeneration, ReplayResponse, SafetyFilterLevel, Session, StartSensitivity, SubjectReferenceType, TrafficType, TurnCoverage, Type, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent, setDefaultBaseUrls };
9373
10036
  //# sourceMappingURL=index.mjs.map