@google/genai 1.18.0 → 1.19.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.
@@ -219,6 +219,216 @@ function tBytes$1(fromBytes) {
219
219
  * SPDX-License-Identifier: Apache-2.0
220
220
  */
221
221
  // Code generated by the Google Gen AI SDK generator DO NOT EDIT.
222
+ function getOperationParametersToMldev(fromObject) {
223
+ const toObject = {};
224
+ const fromOperationName = getValueByPath(fromObject, [
225
+ 'operationName',
226
+ ]);
227
+ if (fromOperationName != null) {
228
+ setValueByPath(toObject, ['_url', 'operationName'], fromOperationName);
229
+ }
230
+ const fromConfig = getValueByPath(fromObject, ['config']);
231
+ if (fromConfig != null) {
232
+ setValueByPath(toObject, ['config'], fromConfig);
233
+ }
234
+ return toObject;
235
+ }
236
+ function fetchPredictOperationParametersToVertex(fromObject) {
237
+ const toObject = {};
238
+ const fromOperationName = getValueByPath(fromObject, [
239
+ 'operationName',
240
+ ]);
241
+ if (fromOperationName != null) {
242
+ setValueByPath(toObject, ['operationName'], fromOperationName);
243
+ }
244
+ const fromResourceName = getValueByPath(fromObject, ['resourceName']);
245
+ if (fromResourceName != null) {
246
+ setValueByPath(toObject, ['_url', 'resourceName'], fromResourceName);
247
+ }
248
+ const fromConfig = getValueByPath(fromObject, ['config']);
249
+ if (fromConfig != null) {
250
+ setValueByPath(toObject, ['config'], fromConfig);
251
+ }
252
+ return toObject;
253
+ }
254
+ function getOperationParametersToVertex(fromObject) {
255
+ const toObject = {};
256
+ const fromOperationName = getValueByPath(fromObject, [
257
+ 'operationName',
258
+ ]);
259
+ if (fromOperationName != null) {
260
+ setValueByPath(toObject, ['_url', 'operationName'], fromOperationName);
261
+ }
262
+ const fromConfig = getValueByPath(fromObject, ['config']);
263
+ if (fromConfig != null) {
264
+ setValueByPath(toObject, ['config'], fromConfig);
265
+ }
266
+ return toObject;
267
+ }
268
+ function videoFromMldev$1(fromObject) {
269
+ const toObject = {};
270
+ const fromUri = getValueByPath(fromObject, ['video', 'uri']);
271
+ if (fromUri != null) {
272
+ setValueByPath(toObject, ['uri'], fromUri);
273
+ }
274
+ const fromVideoBytes = getValueByPath(fromObject, [
275
+ 'video',
276
+ 'encodedVideo',
277
+ ]);
278
+ if (fromVideoBytes != null) {
279
+ setValueByPath(toObject, ['videoBytes'], tBytes$1(fromVideoBytes));
280
+ }
281
+ const fromMimeType = getValueByPath(fromObject, ['encoding']);
282
+ if (fromMimeType != null) {
283
+ setValueByPath(toObject, ['mimeType'], fromMimeType);
284
+ }
285
+ return toObject;
286
+ }
287
+ function generatedVideoFromMldev$1(fromObject) {
288
+ const toObject = {};
289
+ const fromVideo = getValueByPath(fromObject, ['_self']);
290
+ if (fromVideo != null) {
291
+ setValueByPath(toObject, ['video'], videoFromMldev$1(fromVideo));
292
+ }
293
+ return toObject;
294
+ }
295
+ function generateVideosResponseFromMldev$1(fromObject) {
296
+ const toObject = {};
297
+ const fromGeneratedVideos = getValueByPath(fromObject, [
298
+ 'generatedSamples',
299
+ ]);
300
+ if (fromGeneratedVideos != null) {
301
+ let transformedList = fromGeneratedVideos;
302
+ if (Array.isArray(transformedList)) {
303
+ transformedList = transformedList.map((item) => {
304
+ return generatedVideoFromMldev$1(item);
305
+ });
306
+ }
307
+ setValueByPath(toObject, ['generatedVideos'], transformedList);
308
+ }
309
+ const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
310
+ 'raiMediaFilteredCount',
311
+ ]);
312
+ if (fromRaiMediaFilteredCount != null) {
313
+ setValueByPath(toObject, ['raiMediaFilteredCount'], fromRaiMediaFilteredCount);
314
+ }
315
+ const fromRaiMediaFilteredReasons = getValueByPath(fromObject, [
316
+ 'raiMediaFilteredReasons',
317
+ ]);
318
+ if (fromRaiMediaFilteredReasons != null) {
319
+ setValueByPath(toObject, ['raiMediaFilteredReasons'], fromRaiMediaFilteredReasons);
320
+ }
321
+ return toObject;
322
+ }
323
+ function generateVideosOperationFromMldev$1(fromObject) {
324
+ const toObject = {};
325
+ const fromName = getValueByPath(fromObject, ['name']);
326
+ if (fromName != null) {
327
+ setValueByPath(toObject, ['name'], fromName);
328
+ }
329
+ const fromMetadata = getValueByPath(fromObject, ['metadata']);
330
+ if (fromMetadata != null) {
331
+ setValueByPath(toObject, ['metadata'], fromMetadata);
332
+ }
333
+ const fromDone = getValueByPath(fromObject, ['done']);
334
+ if (fromDone != null) {
335
+ setValueByPath(toObject, ['done'], fromDone);
336
+ }
337
+ const fromError = getValueByPath(fromObject, ['error']);
338
+ if (fromError != null) {
339
+ setValueByPath(toObject, ['error'], fromError);
340
+ }
341
+ const fromResponse = getValueByPath(fromObject, [
342
+ 'response',
343
+ 'generateVideoResponse',
344
+ ]);
345
+ if (fromResponse != null) {
346
+ setValueByPath(toObject, ['response'], generateVideosResponseFromMldev$1(fromResponse));
347
+ }
348
+ return toObject;
349
+ }
350
+ function videoFromVertex$1(fromObject) {
351
+ const toObject = {};
352
+ const fromUri = getValueByPath(fromObject, ['gcsUri']);
353
+ if (fromUri != null) {
354
+ setValueByPath(toObject, ['uri'], fromUri);
355
+ }
356
+ const fromVideoBytes = getValueByPath(fromObject, [
357
+ 'bytesBase64Encoded',
358
+ ]);
359
+ if (fromVideoBytes != null) {
360
+ setValueByPath(toObject, ['videoBytes'], tBytes$1(fromVideoBytes));
361
+ }
362
+ const fromMimeType = getValueByPath(fromObject, ['mimeType']);
363
+ if (fromMimeType != null) {
364
+ setValueByPath(toObject, ['mimeType'], fromMimeType);
365
+ }
366
+ return toObject;
367
+ }
368
+ function generatedVideoFromVertex$1(fromObject) {
369
+ const toObject = {};
370
+ const fromVideo = getValueByPath(fromObject, ['_self']);
371
+ if (fromVideo != null) {
372
+ setValueByPath(toObject, ['video'], videoFromVertex$1(fromVideo));
373
+ }
374
+ return toObject;
375
+ }
376
+ function generateVideosResponseFromVertex$1(fromObject) {
377
+ const toObject = {};
378
+ const fromGeneratedVideos = getValueByPath(fromObject, ['videos']);
379
+ if (fromGeneratedVideos != null) {
380
+ let transformedList = fromGeneratedVideos;
381
+ if (Array.isArray(transformedList)) {
382
+ transformedList = transformedList.map((item) => {
383
+ return generatedVideoFromVertex$1(item);
384
+ });
385
+ }
386
+ setValueByPath(toObject, ['generatedVideos'], transformedList);
387
+ }
388
+ const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
389
+ 'raiMediaFilteredCount',
390
+ ]);
391
+ if (fromRaiMediaFilteredCount != null) {
392
+ setValueByPath(toObject, ['raiMediaFilteredCount'], fromRaiMediaFilteredCount);
393
+ }
394
+ const fromRaiMediaFilteredReasons = getValueByPath(fromObject, [
395
+ 'raiMediaFilteredReasons',
396
+ ]);
397
+ if (fromRaiMediaFilteredReasons != null) {
398
+ setValueByPath(toObject, ['raiMediaFilteredReasons'], fromRaiMediaFilteredReasons);
399
+ }
400
+ return toObject;
401
+ }
402
+ function generateVideosOperationFromVertex$1(fromObject) {
403
+ const toObject = {};
404
+ const fromName = getValueByPath(fromObject, ['name']);
405
+ if (fromName != null) {
406
+ setValueByPath(toObject, ['name'], fromName);
407
+ }
408
+ const fromMetadata = getValueByPath(fromObject, ['metadata']);
409
+ if (fromMetadata != null) {
410
+ setValueByPath(toObject, ['metadata'], fromMetadata);
411
+ }
412
+ const fromDone = getValueByPath(fromObject, ['done']);
413
+ if (fromDone != null) {
414
+ setValueByPath(toObject, ['done'], fromDone);
415
+ }
416
+ const fromError = getValueByPath(fromObject, ['error']);
417
+ if (fromError != null) {
418
+ setValueByPath(toObject, ['error'], fromError);
419
+ }
420
+ const fromResponse = getValueByPath(fromObject, ['response']);
421
+ if (fromResponse != null) {
422
+ setValueByPath(toObject, ['response'], generateVideosResponseFromVertex$1(fromResponse));
423
+ }
424
+ return toObject;
425
+ }
426
+
427
+ /**
428
+ * @license
429
+ * Copyright 2025 Google LLC
430
+ * SPDX-License-Identifier: Apache-2.0
431
+ */
222
432
  /** Required. Outcome of the code execution. */
223
433
  var Outcome;
224
434
  (function (Outcome) {
@@ -1610,54 +1820,15 @@ class GenerateVideosOperation {
1610
1820
  */
1611
1821
  _fromAPIResponse({ apiResponse, isVertexAI, }) {
1612
1822
  const operation = new GenerateVideosOperation();
1613
- operation.name = apiResponse['name'];
1614
- operation.metadata = apiResponse['metadata'];
1615
- operation.done = apiResponse['done'];
1616
- operation.error = apiResponse['error'];
1823
+ let response;
1824
+ const op = apiResponse;
1617
1825
  if (isVertexAI) {
1618
- const response = apiResponse['response'];
1619
- if (response) {
1620
- const operationResponse = new GenerateVideosResponse();
1621
- const responseVideos = response['videos'];
1622
- operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
1623
- return {
1624
- video: {
1625
- uri: generatedVideo['gcsUri'],
1626
- videoBytes: generatedVideo['bytesBase64Encoded']
1627
- ? tBytes$1(generatedVideo['bytesBase64Encoded'])
1628
- : undefined,
1629
- mimeType: generatedVideo['mimeType'],
1630
- },
1631
- };
1632
- });
1633
- operationResponse.raiMediaFilteredCount = response['raiMediaFilteredCount'];
1634
- operationResponse.raiMediaFilteredReasons = response['raiMediaFilteredReasons'];
1635
- operation.response = operationResponse;
1636
- }
1826
+ response = generateVideosOperationFromVertex$1(op);
1637
1827
  }
1638
1828
  else {
1639
- const response = apiResponse['response'];
1640
- if (response) {
1641
- const operationResponse = new GenerateVideosResponse();
1642
- const generatedVideoResponse = response['generateVideoResponse'];
1643
- const responseVideos = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['generatedSamples'];
1644
- operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
1645
- const video = generatedVideo['video'];
1646
- return {
1647
- video: {
1648
- uri: video === null || video === void 0 ? void 0 : video['uri'],
1649
- videoBytes: (video === null || video === void 0 ? void 0 : video['encodedVideo'])
1650
- ? tBytes$1(video === null || video === void 0 ? void 0 : video['encodedVideo'])
1651
- : undefined,
1652
- mimeType: generatedVideo['encoding'],
1653
- },
1654
- };
1655
- });
1656
- operationResponse.raiMediaFilteredCount = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredCount'];
1657
- operationResponse.raiMediaFilteredReasons = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredReasons'];
1658
- operation.response = operationResponse;
1659
- }
1829
+ response = generateVideosOperationFromMldev$1(op);
1660
1830
  }
1831
+ Object.assign(operation, response);
1661
1832
  return operation;
1662
1833
  }
1663
1834
  }
@@ -5634,8 +5805,9 @@ function fileDataToVertex$2(fromObject) {
5634
5805
  }
5635
5806
  function functionCallToVertex$2(fromObject) {
5636
5807
  const toObject = {};
5637
- if (getValueByPath(fromObject, ['id']) !== undefined) {
5638
- throw new Error('id parameter is not supported in Vertex AI.');
5808
+ const fromId = getValueByPath(fromObject, ['id']);
5809
+ if (fromId != null) {
5810
+ setValueByPath(toObject, ['id'], fromId);
5639
5811
  }
5640
5812
  const fromArgs = getValueByPath(fromObject, ['args']);
5641
5813
  if (fromArgs != null) {
@@ -8440,8 +8612,9 @@ function fileDataToVertex$1(fromObject) {
8440
8612
  }
8441
8613
  function functionCallToVertex$1(fromObject) {
8442
8614
  const toObject = {};
8443
- if (getValueByPath(fromObject, ['id']) !== undefined) {
8444
- throw new Error('id parameter is not supported in Vertex AI.');
8615
+ const fromId = getValueByPath(fromObject, ['id']);
8616
+ if (fromId != null) {
8617
+ setValueByPath(toObject, ['id'], fromId);
8445
8618
  }
8446
8619
  const fromArgs = getValueByPath(fromObject, ['args']);
8447
8620
  if (fromArgs != null) {
@@ -9638,6 +9811,10 @@ function fileDataFromVertex$1(fromObject) {
9638
9811
  }
9639
9812
  function functionCallFromVertex$1(fromObject) {
9640
9813
  const toObject = {};
9814
+ const fromId = getValueByPath(fromObject, ['id']);
9815
+ if (fromId != null) {
9816
+ setValueByPath(toObject, ['id'], fromId);
9817
+ }
9641
9818
  const fromArgs = getValueByPath(fromObject, ['args']);
9642
9819
  if (fromArgs != null) {
9643
9820
  setValueByPath(toObject, ['args'], fromArgs);
@@ -11020,6 +11197,9 @@ function generateVideosConfigToMldev(fromObject, parentObject) {
11020
11197
  if (getValueByPath(fromObject, ['referenceImages']) !== undefined) {
11021
11198
  throw new Error('referenceImages parameter is not supported in Gemini API.');
11022
11199
  }
11200
+ if (getValueByPath(fromObject, ['mask']) !== undefined) {
11201
+ throw new Error('mask parameter is not supported in Gemini API.');
11202
+ }
11023
11203
  if (getValueByPath(fromObject, ['compressionQuality']) !== undefined) {
11024
11204
  throw new Error('compressionQuality parameter is not supported in Gemini API.');
11025
11205
  }
@@ -11102,8 +11282,9 @@ function fileDataToVertex(fromObject) {
11102
11282
  }
11103
11283
  function functionCallToVertex(fromObject) {
11104
11284
  const toObject = {};
11105
- if (getValueByPath(fromObject, ['id']) !== undefined) {
11106
- throw new Error('id parameter is not supported in Vertex AI.');
11285
+ const fromId = getValueByPath(fromObject, ['id']);
11286
+ if (fromId != null) {
11287
+ setValueByPath(toObject, ['id'], fromId);
11107
11288
  }
11108
11289
  const fromArgs = getValueByPath(fromObject, ['args']);
11109
11290
  if (fromArgs != null) {
@@ -12627,6 +12808,18 @@ function videoGenerationReferenceImageToVertex(fromObject) {
12627
12808
  }
12628
12809
  return toObject;
12629
12810
  }
12811
+ function videoGenerationMaskToVertex(fromObject) {
12812
+ const toObject = {};
12813
+ const fromImage = getValueByPath(fromObject, ['image']);
12814
+ if (fromImage != null) {
12815
+ setValueByPath(toObject, ['_self'], imageToVertex(fromImage));
12816
+ }
12817
+ const fromMaskMode = getValueByPath(fromObject, ['maskMode']);
12818
+ if (fromMaskMode != null) {
12819
+ setValueByPath(toObject, ['maskMode'], fromMaskMode);
12820
+ }
12821
+ return toObject;
12822
+ }
12630
12823
  function generateVideosConfigToVertex(fromObject, parentObject) {
12631
12824
  const toObject = {};
12632
12825
  const fromNumberOfVideos = getValueByPath(fromObject, [
@@ -12705,6 +12898,10 @@ function generateVideosConfigToVertex(fromObject, parentObject) {
12705
12898
  }
12706
12899
  setValueByPath(parentObject, ['instances[0]', 'referenceImages'], transformedList);
12707
12900
  }
12901
+ const fromMask = getValueByPath(fromObject, ['mask']);
12902
+ if (parentObject !== undefined && fromMask != null) {
12903
+ setValueByPath(parentObject, ['instances[0]', 'mask'], videoGenerationMaskToVertex(fromMask));
12904
+ }
12708
12905
  const fromCompressionQuality = getValueByPath(fromObject, [
12709
12906
  'compressionQuality',
12710
12907
  ]);
@@ -13363,6 +13560,10 @@ function fileDataFromVertex(fromObject) {
13363
13560
  }
13364
13561
  function functionCallFromVertex(fromObject) {
13365
13562
  const toObject = {};
13563
+ const fromId = getValueByPath(fromObject, ['id']);
13564
+ if (fromId != null) {
13565
+ setValueByPath(toObject, ['id'], fromId);
13566
+ }
13366
13567
  const fromArgs = getValueByPath(fromObject, ['args']);
13367
13568
  if (fromArgs != null) {
13368
13569
  setValueByPath(toObject, ['args'], fromArgs);
@@ -14089,7 +14290,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
14089
14290
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
14090
14291
  const USER_AGENT_HEADER = 'User-Agent';
14091
14292
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
14092
- const SDK_VERSION = '1.18.0'; // x-release-please-version
14293
+ const SDK_VERSION = '1.19.0'; // x-release-please-version
14093
14294
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
14094
14295
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
14095
14296
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -17074,59 +17275,6 @@ class Models extends BaseModule {
17074
17275
  }
17075
17276
  }
17076
17277
 
17077
- /**
17078
- * @license
17079
- * Copyright 2025 Google LLC
17080
- * SPDX-License-Identifier: Apache-2.0
17081
- */
17082
- // Code generated by the Google Gen AI SDK generator DO NOT EDIT.
17083
- function getOperationParametersToMldev(fromObject) {
17084
- const toObject = {};
17085
- const fromOperationName = getValueByPath(fromObject, [
17086
- 'operationName',
17087
- ]);
17088
- if (fromOperationName != null) {
17089
- setValueByPath(toObject, ['_url', 'operationName'], fromOperationName);
17090
- }
17091
- const fromConfig = getValueByPath(fromObject, ['config']);
17092
- if (fromConfig != null) {
17093
- setValueByPath(toObject, ['config'], fromConfig);
17094
- }
17095
- return toObject;
17096
- }
17097
- function fetchPredictOperationParametersToVertex(fromObject) {
17098
- const toObject = {};
17099
- const fromOperationName = getValueByPath(fromObject, [
17100
- 'operationName',
17101
- ]);
17102
- if (fromOperationName != null) {
17103
- setValueByPath(toObject, ['operationName'], fromOperationName);
17104
- }
17105
- const fromResourceName = getValueByPath(fromObject, ['resourceName']);
17106
- if (fromResourceName != null) {
17107
- setValueByPath(toObject, ['_url', 'resourceName'], fromResourceName);
17108
- }
17109
- const fromConfig = getValueByPath(fromObject, ['config']);
17110
- if (fromConfig != null) {
17111
- setValueByPath(toObject, ['config'], fromConfig);
17112
- }
17113
- return toObject;
17114
- }
17115
- function getOperationParametersToVertex(fromObject) {
17116
- const toObject = {};
17117
- const fromOperationName = getValueByPath(fromObject, [
17118
- 'operationName',
17119
- ]);
17120
- if (fromOperationName != null) {
17121
- setValueByPath(toObject, ['_url', 'operationName'], fromOperationName);
17122
- }
17123
- const fromConfig = getValueByPath(fromObject, ['config']);
17124
- if (fromConfig != null) {
17125
- setValueByPath(toObject, ['config'], fromConfig);
17126
- }
17127
- return toObject;
17128
- }
17129
-
17130
17278
  /**
17131
17279
  * @license
17132
17280
  * Copyright 2025 Google LLC
@@ -18482,6 +18630,9 @@ function createTuningJobConfigToMldev(fromObject, parentObject) {
18482
18630
  if (parentObject !== undefined && fromLearningRate != null) {
18483
18631
  setValueByPath(parentObject, ['tuningTask', 'hyperparameters', 'learningRate'], fromLearningRate);
18484
18632
  }
18633
+ if (getValueByPath(fromObject, ['labels']) !== undefined) {
18634
+ throw new Error('labels parameter is not supported in Gemini API.');
18635
+ }
18485
18636
  return toObject;
18486
18637
  }
18487
18638
  function createTuningJobParametersPrivateToMldev(fromObject) {
@@ -18637,6 +18788,10 @@ function createTuningJobConfigToVertex(fromObject, parentObject) {
18637
18788
  if (getValueByPath(fromObject, ['learningRate']) !== undefined) {
18638
18789
  throw new Error('learningRate parameter is not supported in Vertex AI.');
18639
18790
  }
18791
+ const fromLabels = getValueByPath(fromObject, ['labels']);
18792
+ if (parentObject !== undefined && fromLabels != null) {
18793
+ setValueByPath(parentObject, ['labels'], fromLabels);
18794
+ }
18640
18795
  return toObject;
18641
18796
  }
18642
18797
  function createTuningJobParametersPrivateToVertex(fromObject) {