@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.
@@ -241,6 +241,216 @@ function tBytes$1(fromBytes) {
241
241
  * SPDX-License-Identifier: Apache-2.0
242
242
  */
243
243
  // Code generated by the Google Gen AI SDK generator DO NOT EDIT.
244
+ function getOperationParametersToMldev(fromObject) {
245
+ const toObject = {};
246
+ const fromOperationName = getValueByPath(fromObject, [
247
+ 'operationName',
248
+ ]);
249
+ if (fromOperationName != null) {
250
+ setValueByPath(toObject, ['_url', 'operationName'], fromOperationName);
251
+ }
252
+ const fromConfig = getValueByPath(fromObject, ['config']);
253
+ if (fromConfig != null) {
254
+ setValueByPath(toObject, ['config'], fromConfig);
255
+ }
256
+ return toObject;
257
+ }
258
+ function fetchPredictOperationParametersToVertex(fromObject) {
259
+ const toObject = {};
260
+ const fromOperationName = getValueByPath(fromObject, [
261
+ 'operationName',
262
+ ]);
263
+ if (fromOperationName != null) {
264
+ setValueByPath(toObject, ['operationName'], fromOperationName);
265
+ }
266
+ const fromResourceName = getValueByPath(fromObject, ['resourceName']);
267
+ if (fromResourceName != null) {
268
+ setValueByPath(toObject, ['_url', 'resourceName'], fromResourceName);
269
+ }
270
+ const fromConfig = getValueByPath(fromObject, ['config']);
271
+ if (fromConfig != null) {
272
+ setValueByPath(toObject, ['config'], fromConfig);
273
+ }
274
+ return toObject;
275
+ }
276
+ function getOperationParametersToVertex(fromObject) {
277
+ const toObject = {};
278
+ const fromOperationName = getValueByPath(fromObject, [
279
+ 'operationName',
280
+ ]);
281
+ if (fromOperationName != null) {
282
+ setValueByPath(toObject, ['_url', 'operationName'], fromOperationName);
283
+ }
284
+ const fromConfig = getValueByPath(fromObject, ['config']);
285
+ if (fromConfig != null) {
286
+ setValueByPath(toObject, ['config'], fromConfig);
287
+ }
288
+ return toObject;
289
+ }
290
+ function videoFromMldev$1(fromObject) {
291
+ const toObject = {};
292
+ const fromUri = getValueByPath(fromObject, ['video', 'uri']);
293
+ if (fromUri != null) {
294
+ setValueByPath(toObject, ['uri'], fromUri);
295
+ }
296
+ const fromVideoBytes = getValueByPath(fromObject, [
297
+ 'video',
298
+ 'encodedVideo',
299
+ ]);
300
+ if (fromVideoBytes != null) {
301
+ setValueByPath(toObject, ['videoBytes'], tBytes$1(fromVideoBytes));
302
+ }
303
+ const fromMimeType = getValueByPath(fromObject, ['encoding']);
304
+ if (fromMimeType != null) {
305
+ setValueByPath(toObject, ['mimeType'], fromMimeType);
306
+ }
307
+ return toObject;
308
+ }
309
+ function generatedVideoFromMldev$1(fromObject) {
310
+ const toObject = {};
311
+ const fromVideo = getValueByPath(fromObject, ['_self']);
312
+ if (fromVideo != null) {
313
+ setValueByPath(toObject, ['video'], videoFromMldev$1(fromVideo));
314
+ }
315
+ return toObject;
316
+ }
317
+ function generateVideosResponseFromMldev$1(fromObject) {
318
+ const toObject = {};
319
+ const fromGeneratedVideos = getValueByPath(fromObject, [
320
+ 'generatedSamples',
321
+ ]);
322
+ if (fromGeneratedVideos != null) {
323
+ let transformedList = fromGeneratedVideos;
324
+ if (Array.isArray(transformedList)) {
325
+ transformedList = transformedList.map((item) => {
326
+ return generatedVideoFromMldev$1(item);
327
+ });
328
+ }
329
+ setValueByPath(toObject, ['generatedVideos'], transformedList);
330
+ }
331
+ const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
332
+ 'raiMediaFilteredCount',
333
+ ]);
334
+ if (fromRaiMediaFilteredCount != null) {
335
+ setValueByPath(toObject, ['raiMediaFilteredCount'], fromRaiMediaFilteredCount);
336
+ }
337
+ const fromRaiMediaFilteredReasons = getValueByPath(fromObject, [
338
+ 'raiMediaFilteredReasons',
339
+ ]);
340
+ if (fromRaiMediaFilteredReasons != null) {
341
+ setValueByPath(toObject, ['raiMediaFilteredReasons'], fromRaiMediaFilteredReasons);
342
+ }
343
+ return toObject;
344
+ }
345
+ function generateVideosOperationFromMldev$1(fromObject) {
346
+ const toObject = {};
347
+ const fromName = getValueByPath(fromObject, ['name']);
348
+ if (fromName != null) {
349
+ setValueByPath(toObject, ['name'], fromName);
350
+ }
351
+ const fromMetadata = getValueByPath(fromObject, ['metadata']);
352
+ if (fromMetadata != null) {
353
+ setValueByPath(toObject, ['metadata'], fromMetadata);
354
+ }
355
+ const fromDone = getValueByPath(fromObject, ['done']);
356
+ if (fromDone != null) {
357
+ setValueByPath(toObject, ['done'], fromDone);
358
+ }
359
+ const fromError = getValueByPath(fromObject, ['error']);
360
+ if (fromError != null) {
361
+ setValueByPath(toObject, ['error'], fromError);
362
+ }
363
+ const fromResponse = getValueByPath(fromObject, [
364
+ 'response',
365
+ 'generateVideoResponse',
366
+ ]);
367
+ if (fromResponse != null) {
368
+ setValueByPath(toObject, ['response'], generateVideosResponseFromMldev$1(fromResponse));
369
+ }
370
+ return toObject;
371
+ }
372
+ function videoFromVertex$1(fromObject) {
373
+ const toObject = {};
374
+ const fromUri = getValueByPath(fromObject, ['gcsUri']);
375
+ if (fromUri != null) {
376
+ setValueByPath(toObject, ['uri'], fromUri);
377
+ }
378
+ const fromVideoBytes = getValueByPath(fromObject, [
379
+ 'bytesBase64Encoded',
380
+ ]);
381
+ if (fromVideoBytes != null) {
382
+ setValueByPath(toObject, ['videoBytes'], tBytes$1(fromVideoBytes));
383
+ }
384
+ const fromMimeType = getValueByPath(fromObject, ['mimeType']);
385
+ if (fromMimeType != null) {
386
+ setValueByPath(toObject, ['mimeType'], fromMimeType);
387
+ }
388
+ return toObject;
389
+ }
390
+ function generatedVideoFromVertex$1(fromObject) {
391
+ const toObject = {};
392
+ const fromVideo = getValueByPath(fromObject, ['_self']);
393
+ if (fromVideo != null) {
394
+ setValueByPath(toObject, ['video'], videoFromVertex$1(fromVideo));
395
+ }
396
+ return toObject;
397
+ }
398
+ function generateVideosResponseFromVertex$1(fromObject) {
399
+ const toObject = {};
400
+ const fromGeneratedVideos = getValueByPath(fromObject, ['videos']);
401
+ if (fromGeneratedVideos != null) {
402
+ let transformedList = fromGeneratedVideos;
403
+ if (Array.isArray(transformedList)) {
404
+ transformedList = transformedList.map((item) => {
405
+ return generatedVideoFromVertex$1(item);
406
+ });
407
+ }
408
+ setValueByPath(toObject, ['generatedVideos'], transformedList);
409
+ }
410
+ const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
411
+ 'raiMediaFilteredCount',
412
+ ]);
413
+ if (fromRaiMediaFilteredCount != null) {
414
+ setValueByPath(toObject, ['raiMediaFilteredCount'], fromRaiMediaFilteredCount);
415
+ }
416
+ const fromRaiMediaFilteredReasons = getValueByPath(fromObject, [
417
+ 'raiMediaFilteredReasons',
418
+ ]);
419
+ if (fromRaiMediaFilteredReasons != null) {
420
+ setValueByPath(toObject, ['raiMediaFilteredReasons'], fromRaiMediaFilteredReasons);
421
+ }
422
+ return toObject;
423
+ }
424
+ function generateVideosOperationFromVertex$1(fromObject) {
425
+ const toObject = {};
426
+ const fromName = getValueByPath(fromObject, ['name']);
427
+ if (fromName != null) {
428
+ setValueByPath(toObject, ['name'], fromName);
429
+ }
430
+ const fromMetadata = getValueByPath(fromObject, ['metadata']);
431
+ if (fromMetadata != null) {
432
+ setValueByPath(toObject, ['metadata'], fromMetadata);
433
+ }
434
+ const fromDone = getValueByPath(fromObject, ['done']);
435
+ if (fromDone != null) {
436
+ setValueByPath(toObject, ['done'], fromDone);
437
+ }
438
+ const fromError = getValueByPath(fromObject, ['error']);
439
+ if (fromError != null) {
440
+ setValueByPath(toObject, ['error'], fromError);
441
+ }
442
+ const fromResponse = getValueByPath(fromObject, ['response']);
443
+ if (fromResponse != null) {
444
+ setValueByPath(toObject, ['response'], generateVideosResponseFromVertex$1(fromResponse));
445
+ }
446
+ return toObject;
447
+ }
448
+
449
+ /**
450
+ * @license
451
+ * Copyright 2025 Google LLC
452
+ * SPDX-License-Identifier: Apache-2.0
453
+ */
244
454
  /** Required. Outcome of the code execution. */
245
455
  exports.Outcome = void 0;
246
456
  (function (Outcome) {
@@ -1632,54 +1842,15 @@ class GenerateVideosOperation {
1632
1842
  */
1633
1843
  _fromAPIResponse({ apiResponse, isVertexAI, }) {
1634
1844
  const operation = new GenerateVideosOperation();
1635
- operation.name = apiResponse['name'];
1636
- operation.metadata = apiResponse['metadata'];
1637
- operation.done = apiResponse['done'];
1638
- operation.error = apiResponse['error'];
1845
+ let response;
1846
+ const op = apiResponse;
1639
1847
  if (isVertexAI) {
1640
- const response = apiResponse['response'];
1641
- if (response) {
1642
- const operationResponse = new GenerateVideosResponse();
1643
- const responseVideos = response['videos'];
1644
- operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
1645
- return {
1646
- video: {
1647
- uri: generatedVideo['gcsUri'],
1648
- videoBytes: generatedVideo['bytesBase64Encoded']
1649
- ? tBytes$1(generatedVideo['bytesBase64Encoded'])
1650
- : undefined,
1651
- mimeType: generatedVideo['mimeType'],
1652
- },
1653
- };
1654
- });
1655
- operationResponse.raiMediaFilteredCount = response['raiMediaFilteredCount'];
1656
- operationResponse.raiMediaFilteredReasons = response['raiMediaFilteredReasons'];
1657
- operation.response = operationResponse;
1658
- }
1848
+ response = generateVideosOperationFromVertex$1(op);
1659
1849
  }
1660
1850
  else {
1661
- const response = apiResponse['response'];
1662
- if (response) {
1663
- const operationResponse = new GenerateVideosResponse();
1664
- const generatedVideoResponse = response['generateVideoResponse'];
1665
- const responseVideos = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['generatedSamples'];
1666
- operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
1667
- const video = generatedVideo['video'];
1668
- return {
1669
- video: {
1670
- uri: video === null || video === void 0 ? void 0 : video['uri'],
1671
- videoBytes: (video === null || video === void 0 ? void 0 : video['encodedVideo'])
1672
- ? tBytes$1(video === null || video === void 0 ? void 0 : video['encodedVideo'])
1673
- : undefined,
1674
- mimeType: generatedVideo['encoding'],
1675
- },
1676
- };
1677
- });
1678
- operationResponse.raiMediaFilteredCount = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredCount'];
1679
- operationResponse.raiMediaFilteredReasons = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredReasons'];
1680
- operation.response = operationResponse;
1681
- }
1851
+ response = generateVideosOperationFromMldev$1(op);
1682
1852
  }
1853
+ Object.assign(operation, response);
1683
1854
  return operation;
1684
1855
  }
1685
1856
  }
@@ -5656,8 +5827,9 @@ function fileDataToVertex$2(fromObject) {
5656
5827
  }
5657
5828
  function functionCallToVertex$2(fromObject) {
5658
5829
  const toObject = {};
5659
- if (getValueByPath(fromObject, ['id']) !== undefined) {
5660
- throw new Error('id parameter is not supported in Vertex AI.');
5830
+ const fromId = getValueByPath(fromObject, ['id']);
5831
+ if (fromId != null) {
5832
+ setValueByPath(toObject, ['id'], fromId);
5661
5833
  }
5662
5834
  const fromArgs = getValueByPath(fromObject, ['args']);
5663
5835
  if (fromArgs != null) {
@@ -8462,8 +8634,9 @@ function fileDataToVertex$1(fromObject) {
8462
8634
  }
8463
8635
  function functionCallToVertex$1(fromObject) {
8464
8636
  const toObject = {};
8465
- if (getValueByPath(fromObject, ['id']) !== undefined) {
8466
- throw new Error('id parameter is not supported in Vertex AI.');
8637
+ const fromId = getValueByPath(fromObject, ['id']);
8638
+ if (fromId != null) {
8639
+ setValueByPath(toObject, ['id'], fromId);
8467
8640
  }
8468
8641
  const fromArgs = getValueByPath(fromObject, ['args']);
8469
8642
  if (fromArgs != null) {
@@ -9660,6 +9833,10 @@ function fileDataFromVertex$1(fromObject) {
9660
9833
  }
9661
9834
  function functionCallFromVertex$1(fromObject) {
9662
9835
  const toObject = {};
9836
+ const fromId = getValueByPath(fromObject, ['id']);
9837
+ if (fromId != null) {
9838
+ setValueByPath(toObject, ['id'], fromId);
9839
+ }
9663
9840
  const fromArgs = getValueByPath(fromObject, ['args']);
9664
9841
  if (fromArgs != null) {
9665
9842
  setValueByPath(toObject, ['args'], fromArgs);
@@ -11042,6 +11219,9 @@ function generateVideosConfigToMldev(fromObject, parentObject) {
11042
11219
  if (getValueByPath(fromObject, ['referenceImages']) !== undefined) {
11043
11220
  throw new Error('referenceImages parameter is not supported in Gemini API.');
11044
11221
  }
11222
+ if (getValueByPath(fromObject, ['mask']) !== undefined) {
11223
+ throw new Error('mask parameter is not supported in Gemini API.');
11224
+ }
11045
11225
  if (getValueByPath(fromObject, ['compressionQuality']) !== undefined) {
11046
11226
  throw new Error('compressionQuality parameter is not supported in Gemini API.');
11047
11227
  }
@@ -11124,8 +11304,9 @@ function fileDataToVertex(fromObject) {
11124
11304
  }
11125
11305
  function functionCallToVertex(fromObject) {
11126
11306
  const toObject = {};
11127
- if (getValueByPath(fromObject, ['id']) !== undefined) {
11128
- throw new Error('id parameter is not supported in Vertex AI.');
11307
+ const fromId = getValueByPath(fromObject, ['id']);
11308
+ if (fromId != null) {
11309
+ setValueByPath(toObject, ['id'], fromId);
11129
11310
  }
11130
11311
  const fromArgs = getValueByPath(fromObject, ['args']);
11131
11312
  if (fromArgs != null) {
@@ -12649,6 +12830,18 @@ function videoGenerationReferenceImageToVertex(fromObject) {
12649
12830
  }
12650
12831
  return toObject;
12651
12832
  }
12833
+ function videoGenerationMaskToVertex(fromObject) {
12834
+ const toObject = {};
12835
+ const fromImage = getValueByPath(fromObject, ['image']);
12836
+ if (fromImage != null) {
12837
+ setValueByPath(toObject, ['_self'], imageToVertex(fromImage));
12838
+ }
12839
+ const fromMaskMode = getValueByPath(fromObject, ['maskMode']);
12840
+ if (fromMaskMode != null) {
12841
+ setValueByPath(toObject, ['maskMode'], fromMaskMode);
12842
+ }
12843
+ return toObject;
12844
+ }
12652
12845
  function generateVideosConfigToVertex(fromObject, parentObject) {
12653
12846
  const toObject = {};
12654
12847
  const fromNumberOfVideos = getValueByPath(fromObject, [
@@ -12727,6 +12920,10 @@ function generateVideosConfigToVertex(fromObject, parentObject) {
12727
12920
  }
12728
12921
  setValueByPath(parentObject, ['instances[0]', 'referenceImages'], transformedList);
12729
12922
  }
12923
+ const fromMask = getValueByPath(fromObject, ['mask']);
12924
+ if (parentObject !== undefined && fromMask != null) {
12925
+ setValueByPath(parentObject, ['instances[0]', 'mask'], videoGenerationMaskToVertex(fromMask));
12926
+ }
12730
12927
  const fromCompressionQuality = getValueByPath(fromObject, [
12731
12928
  'compressionQuality',
12732
12929
  ]);
@@ -13385,6 +13582,10 @@ function fileDataFromVertex(fromObject) {
13385
13582
  }
13386
13583
  function functionCallFromVertex(fromObject) {
13387
13584
  const toObject = {};
13585
+ const fromId = getValueByPath(fromObject, ['id']);
13586
+ if (fromId != null) {
13587
+ setValueByPath(toObject, ['id'], fromId);
13588
+ }
13388
13589
  const fromArgs = getValueByPath(fromObject, ['args']);
13389
13590
  if (fromArgs != null) {
13390
13591
  setValueByPath(toObject, ['args'], fromArgs);
@@ -14111,7 +14312,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
14111
14312
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
14112
14313
  const USER_AGENT_HEADER = 'User-Agent';
14113
14314
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
14114
- const SDK_VERSION = '1.18.0'; // x-release-please-version
14315
+ const SDK_VERSION = '1.19.0'; // x-release-please-version
14115
14316
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
14116
14317
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
14117
14318
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -17096,59 +17297,6 @@ class Models extends BaseModule {
17096
17297
  }
17097
17298
  }
17098
17299
 
17099
- /**
17100
- * @license
17101
- * Copyright 2025 Google LLC
17102
- * SPDX-License-Identifier: Apache-2.0
17103
- */
17104
- // Code generated by the Google Gen AI SDK generator DO NOT EDIT.
17105
- function getOperationParametersToMldev(fromObject) {
17106
- const toObject = {};
17107
- const fromOperationName = getValueByPath(fromObject, [
17108
- 'operationName',
17109
- ]);
17110
- if (fromOperationName != null) {
17111
- setValueByPath(toObject, ['_url', 'operationName'], fromOperationName);
17112
- }
17113
- const fromConfig = getValueByPath(fromObject, ['config']);
17114
- if (fromConfig != null) {
17115
- setValueByPath(toObject, ['config'], fromConfig);
17116
- }
17117
- return toObject;
17118
- }
17119
- function fetchPredictOperationParametersToVertex(fromObject) {
17120
- const toObject = {};
17121
- const fromOperationName = getValueByPath(fromObject, [
17122
- 'operationName',
17123
- ]);
17124
- if (fromOperationName != null) {
17125
- setValueByPath(toObject, ['operationName'], fromOperationName);
17126
- }
17127
- const fromResourceName = getValueByPath(fromObject, ['resourceName']);
17128
- if (fromResourceName != null) {
17129
- setValueByPath(toObject, ['_url', 'resourceName'], fromResourceName);
17130
- }
17131
- const fromConfig = getValueByPath(fromObject, ['config']);
17132
- if (fromConfig != null) {
17133
- setValueByPath(toObject, ['config'], fromConfig);
17134
- }
17135
- return toObject;
17136
- }
17137
- function getOperationParametersToVertex(fromObject) {
17138
- const toObject = {};
17139
- const fromOperationName = getValueByPath(fromObject, [
17140
- 'operationName',
17141
- ]);
17142
- if (fromOperationName != null) {
17143
- setValueByPath(toObject, ['_url', 'operationName'], fromOperationName);
17144
- }
17145
- const fromConfig = getValueByPath(fromObject, ['config']);
17146
- if (fromConfig != null) {
17147
- setValueByPath(toObject, ['config'], fromConfig);
17148
- }
17149
- return toObject;
17150
- }
17151
-
17152
17300
  /**
17153
17301
  * @license
17154
17302
  * Copyright 2025 Google LLC
@@ -18504,6 +18652,9 @@ function createTuningJobConfigToMldev(fromObject, parentObject) {
18504
18652
  if (parentObject !== undefined && fromLearningRate != null) {
18505
18653
  setValueByPath(parentObject, ['tuningTask', 'hyperparameters', 'learningRate'], fromLearningRate);
18506
18654
  }
18655
+ if (getValueByPath(fromObject, ['labels']) !== undefined) {
18656
+ throw new Error('labels parameter is not supported in Gemini API.');
18657
+ }
18507
18658
  return toObject;
18508
18659
  }
18509
18660
  function createTuningJobParametersPrivateToMldev(fromObject) {
@@ -18659,6 +18810,10 @@ function createTuningJobConfigToVertex(fromObject, parentObject) {
18659
18810
  if (getValueByPath(fromObject, ['learningRate']) !== undefined) {
18660
18811
  throw new Error('learningRate parameter is not supported in Vertex AI.');
18661
18812
  }
18813
+ const fromLabels = getValueByPath(fromObject, ['labels']);
18814
+ if (parentObject !== undefined && fromLabels != null) {
18815
+ setValueByPath(parentObject, ['labels'], fromLabels);
18816
+ }
18662
18817
  return toObject;
18663
18818
  }
18664
18819
  function createTuningJobParametersPrivateToVertex(fromObject) {