@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.
package/dist/index.mjs CHANGED
@@ -183,6 +183,216 @@ function tBytes$1(fromBytes) {
183
183
  * SPDX-License-Identifier: Apache-2.0
184
184
  */
185
185
  // Code generated by the Google Gen AI SDK generator DO NOT EDIT.
186
+ function getOperationParametersToMldev(fromObject) {
187
+ const toObject = {};
188
+ const fromOperationName = getValueByPath(fromObject, [
189
+ 'operationName',
190
+ ]);
191
+ if (fromOperationName != null) {
192
+ setValueByPath(toObject, ['_url', 'operationName'], fromOperationName);
193
+ }
194
+ const fromConfig = getValueByPath(fromObject, ['config']);
195
+ if (fromConfig != null) {
196
+ setValueByPath(toObject, ['config'], fromConfig);
197
+ }
198
+ return toObject;
199
+ }
200
+ function fetchPredictOperationParametersToVertex(fromObject) {
201
+ const toObject = {};
202
+ const fromOperationName = getValueByPath(fromObject, [
203
+ 'operationName',
204
+ ]);
205
+ if (fromOperationName != null) {
206
+ setValueByPath(toObject, ['operationName'], fromOperationName);
207
+ }
208
+ const fromResourceName = getValueByPath(fromObject, ['resourceName']);
209
+ if (fromResourceName != null) {
210
+ setValueByPath(toObject, ['_url', 'resourceName'], fromResourceName);
211
+ }
212
+ const fromConfig = getValueByPath(fromObject, ['config']);
213
+ if (fromConfig != null) {
214
+ setValueByPath(toObject, ['config'], fromConfig);
215
+ }
216
+ return toObject;
217
+ }
218
+ function getOperationParametersToVertex(fromObject) {
219
+ const toObject = {};
220
+ const fromOperationName = getValueByPath(fromObject, [
221
+ 'operationName',
222
+ ]);
223
+ if (fromOperationName != null) {
224
+ setValueByPath(toObject, ['_url', 'operationName'], fromOperationName);
225
+ }
226
+ const fromConfig = getValueByPath(fromObject, ['config']);
227
+ if (fromConfig != null) {
228
+ setValueByPath(toObject, ['config'], fromConfig);
229
+ }
230
+ return toObject;
231
+ }
232
+ function videoFromMldev$1(fromObject) {
233
+ const toObject = {};
234
+ const fromUri = getValueByPath(fromObject, ['video', 'uri']);
235
+ if (fromUri != null) {
236
+ setValueByPath(toObject, ['uri'], fromUri);
237
+ }
238
+ const fromVideoBytes = getValueByPath(fromObject, [
239
+ 'video',
240
+ 'encodedVideo',
241
+ ]);
242
+ if (fromVideoBytes != null) {
243
+ setValueByPath(toObject, ['videoBytes'], tBytes$1(fromVideoBytes));
244
+ }
245
+ const fromMimeType = getValueByPath(fromObject, ['encoding']);
246
+ if (fromMimeType != null) {
247
+ setValueByPath(toObject, ['mimeType'], fromMimeType);
248
+ }
249
+ return toObject;
250
+ }
251
+ function generatedVideoFromMldev$1(fromObject) {
252
+ const toObject = {};
253
+ const fromVideo = getValueByPath(fromObject, ['_self']);
254
+ if (fromVideo != null) {
255
+ setValueByPath(toObject, ['video'], videoFromMldev$1(fromVideo));
256
+ }
257
+ return toObject;
258
+ }
259
+ function generateVideosResponseFromMldev$1(fromObject) {
260
+ const toObject = {};
261
+ const fromGeneratedVideos = getValueByPath(fromObject, [
262
+ 'generatedSamples',
263
+ ]);
264
+ if (fromGeneratedVideos != null) {
265
+ let transformedList = fromGeneratedVideos;
266
+ if (Array.isArray(transformedList)) {
267
+ transformedList = transformedList.map((item) => {
268
+ return generatedVideoFromMldev$1(item);
269
+ });
270
+ }
271
+ setValueByPath(toObject, ['generatedVideos'], transformedList);
272
+ }
273
+ const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
274
+ 'raiMediaFilteredCount',
275
+ ]);
276
+ if (fromRaiMediaFilteredCount != null) {
277
+ setValueByPath(toObject, ['raiMediaFilteredCount'], fromRaiMediaFilteredCount);
278
+ }
279
+ const fromRaiMediaFilteredReasons = getValueByPath(fromObject, [
280
+ 'raiMediaFilteredReasons',
281
+ ]);
282
+ if (fromRaiMediaFilteredReasons != null) {
283
+ setValueByPath(toObject, ['raiMediaFilteredReasons'], fromRaiMediaFilteredReasons);
284
+ }
285
+ return toObject;
286
+ }
287
+ function generateVideosOperationFromMldev$1(fromObject) {
288
+ const toObject = {};
289
+ const fromName = getValueByPath(fromObject, ['name']);
290
+ if (fromName != null) {
291
+ setValueByPath(toObject, ['name'], fromName);
292
+ }
293
+ const fromMetadata = getValueByPath(fromObject, ['metadata']);
294
+ if (fromMetadata != null) {
295
+ setValueByPath(toObject, ['metadata'], fromMetadata);
296
+ }
297
+ const fromDone = getValueByPath(fromObject, ['done']);
298
+ if (fromDone != null) {
299
+ setValueByPath(toObject, ['done'], fromDone);
300
+ }
301
+ const fromError = getValueByPath(fromObject, ['error']);
302
+ if (fromError != null) {
303
+ setValueByPath(toObject, ['error'], fromError);
304
+ }
305
+ const fromResponse = getValueByPath(fromObject, [
306
+ 'response',
307
+ 'generateVideoResponse',
308
+ ]);
309
+ if (fromResponse != null) {
310
+ setValueByPath(toObject, ['response'], generateVideosResponseFromMldev$1(fromResponse));
311
+ }
312
+ return toObject;
313
+ }
314
+ function videoFromVertex$1(fromObject) {
315
+ const toObject = {};
316
+ const fromUri = getValueByPath(fromObject, ['gcsUri']);
317
+ if (fromUri != null) {
318
+ setValueByPath(toObject, ['uri'], fromUri);
319
+ }
320
+ const fromVideoBytes = getValueByPath(fromObject, [
321
+ 'bytesBase64Encoded',
322
+ ]);
323
+ if (fromVideoBytes != null) {
324
+ setValueByPath(toObject, ['videoBytes'], tBytes$1(fromVideoBytes));
325
+ }
326
+ const fromMimeType = getValueByPath(fromObject, ['mimeType']);
327
+ if (fromMimeType != null) {
328
+ setValueByPath(toObject, ['mimeType'], fromMimeType);
329
+ }
330
+ return toObject;
331
+ }
332
+ function generatedVideoFromVertex$1(fromObject) {
333
+ const toObject = {};
334
+ const fromVideo = getValueByPath(fromObject, ['_self']);
335
+ if (fromVideo != null) {
336
+ setValueByPath(toObject, ['video'], videoFromVertex$1(fromVideo));
337
+ }
338
+ return toObject;
339
+ }
340
+ function generateVideosResponseFromVertex$1(fromObject) {
341
+ const toObject = {};
342
+ const fromGeneratedVideos = getValueByPath(fromObject, ['videos']);
343
+ if (fromGeneratedVideos != null) {
344
+ let transformedList = fromGeneratedVideos;
345
+ if (Array.isArray(transformedList)) {
346
+ transformedList = transformedList.map((item) => {
347
+ return generatedVideoFromVertex$1(item);
348
+ });
349
+ }
350
+ setValueByPath(toObject, ['generatedVideos'], transformedList);
351
+ }
352
+ const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
353
+ 'raiMediaFilteredCount',
354
+ ]);
355
+ if (fromRaiMediaFilteredCount != null) {
356
+ setValueByPath(toObject, ['raiMediaFilteredCount'], fromRaiMediaFilteredCount);
357
+ }
358
+ const fromRaiMediaFilteredReasons = getValueByPath(fromObject, [
359
+ 'raiMediaFilteredReasons',
360
+ ]);
361
+ if (fromRaiMediaFilteredReasons != null) {
362
+ setValueByPath(toObject, ['raiMediaFilteredReasons'], fromRaiMediaFilteredReasons);
363
+ }
364
+ return toObject;
365
+ }
366
+ function generateVideosOperationFromVertex$1(fromObject) {
367
+ const toObject = {};
368
+ const fromName = getValueByPath(fromObject, ['name']);
369
+ if (fromName != null) {
370
+ setValueByPath(toObject, ['name'], fromName);
371
+ }
372
+ const fromMetadata = getValueByPath(fromObject, ['metadata']);
373
+ if (fromMetadata != null) {
374
+ setValueByPath(toObject, ['metadata'], fromMetadata);
375
+ }
376
+ const fromDone = getValueByPath(fromObject, ['done']);
377
+ if (fromDone != null) {
378
+ setValueByPath(toObject, ['done'], fromDone);
379
+ }
380
+ const fromError = getValueByPath(fromObject, ['error']);
381
+ if (fromError != null) {
382
+ setValueByPath(toObject, ['error'], fromError);
383
+ }
384
+ const fromResponse = getValueByPath(fromObject, ['response']);
385
+ if (fromResponse != null) {
386
+ setValueByPath(toObject, ['response'], generateVideosResponseFromVertex$1(fromResponse));
387
+ }
388
+ return toObject;
389
+ }
390
+
391
+ /**
392
+ * @license
393
+ * Copyright 2025 Google LLC
394
+ * SPDX-License-Identifier: Apache-2.0
395
+ */
186
396
  /** Required. Outcome of the code execution. */
187
397
  var Outcome;
188
398
  (function (Outcome) {
@@ -1574,54 +1784,15 @@ class GenerateVideosOperation {
1574
1784
  */
1575
1785
  _fromAPIResponse({ apiResponse, isVertexAI, }) {
1576
1786
  const operation = new GenerateVideosOperation();
1577
- operation.name = apiResponse['name'];
1578
- operation.metadata = apiResponse['metadata'];
1579
- operation.done = apiResponse['done'];
1580
- operation.error = apiResponse['error'];
1787
+ let response;
1788
+ const op = apiResponse;
1581
1789
  if (isVertexAI) {
1582
- const response = apiResponse['response'];
1583
- if (response) {
1584
- const operationResponse = new GenerateVideosResponse();
1585
- const responseVideos = response['videos'];
1586
- operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
1587
- return {
1588
- video: {
1589
- uri: generatedVideo['gcsUri'],
1590
- videoBytes: generatedVideo['bytesBase64Encoded']
1591
- ? tBytes$1(generatedVideo['bytesBase64Encoded'])
1592
- : undefined,
1593
- mimeType: generatedVideo['mimeType'],
1594
- },
1595
- };
1596
- });
1597
- operationResponse.raiMediaFilteredCount = response['raiMediaFilteredCount'];
1598
- operationResponse.raiMediaFilteredReasons = response['raiMediaFilteredReasons'];
1599
- operation.response = operationResponse;
1600
- }
1790
+ response = generateVideosOperationFromVertex$1(op);
1601
1791
  }
1602
1792
  else {
1603
- const response = apiResponse['response'];
1604
- if (response) {
1605
- const operationResponse = new GenerateVideosResponse();
1606
- const generatedVideoResponse = response['generateVideoResponse'];
1607
- const responseVideos = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['generatedSamples'];
1608
- operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
1609
- const video = generatedVideo['video'];
1610
- return {
1611
- video: {
1612
- uri: video === null || video === void 0 ? void 0 : video['uri'],
1613
- videoBytes: (video === null || video === void 0 ? void 0 : video['encodedVideo'])
1614
- ? tBytes$1(video === null || video === void 0 ? void 0 : video['encodedVideo'])
1615
- : undefined,
1616
- mimeType: generatedVideo['encoding'],
1617
- },
1618
- };
1619
- });
1620
- operationResponse.raiMediaFilteredCount = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredCount'];
1621
- operationResponse.raiMediaFilteredReasons = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredReasons'];
1622
- operation.response = operationResponse;
1623
- }
1793
+ response = generateVideosOperationFromMldev$1(op);
1624
1794
  }
1795
+ Object.assign(operation, response);
1625
1796
  return operation;
1626
1797
  }
1627
1798
  }
@@ -5598,8 +5769,9 @@ function fileDataToVertex$2(fromObject) {
5598
5769
  }
5599
5770
  function functionCallToVertex$2(fromObject) {
5600
5771
  const toObject = {};
5601
- if (getValueByPath(fromObject, ['id']) !== undefined) {
5602
- throw new Error('id parameter is not supported in Vertex AI.');
5772
+ const fromId = getValueByPath(fromObject, ['id']);
5773
+ if (fromId != null) {
5774
+ setValueByPath(toObject, ['id'], fromId);
5603
5775
  }
5604
5776
  const fromArgs = getValueByPath(fromObject, ['args']);
5605
5777
  if (fromArgs != null) {
@@ -7024,7 +7196,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
7024
7196
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
7025
7197
  const USER_AGENT_HEADER = 'User-Agent';
7026
7198
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
7027
- const SDK_VERSION = '1.18.0'; // x-release-please-version
7199
+ const SDK_VERSION = '1.19.0'; // x-release-please-version
7028
7200
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
7029
7201
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
7030
7202
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -9101,8 +9273,9 @@ function fileDataToVertex$1(fromObject) {
9101
9273
  }
9102
9274
  function functionCallToVertex$1(fromObject) {
9103
9275
  const toObject = {};
9104
- if (getValueByPath(fromObject, ['id']) !== undefined) {
9105
- throw new Error('id parameter is not supported in Vertex AI.');
9276
+ const fromId = getValueByPath(fromObject, ['id']);
9277
+ if (fromId != null) {
9278
+ setValueByPath(toObject, ['id'], fromId);
9106
9279
  }
9107
9280
  const fromArgs = getValueByPath(fromObject, ['args']);
9108
9281
  if (fromArgs != null) {
@@ -10299,6 +10472,10 @@ function fileDataFromVertex$1(fromObject) {
10299
10472
  }
10300
10473
  function functionCallFromVertex$1(fromObject) {
10301
10474
  const toObject = {};
10475
+ const fromId = getValueByPath(fromObject, ['id']);
10476
+ if (fromId != null) {
10477
+ setValueByPath(toObject, ['id'], fromId);
10478
+ }
10302
10479
  const fromArgs = getValueByPath(fromObject, ['args']);
10303
10480
  if (fromArgs != null) {
10304
10481
  setValueByPath(toObject, ['args'], fromArgs);
@@ -11681,6 +11858,9 @@ function generateVideosConfigToMldev(fromObject, parentObject) {
11681
11858
  if (getValueByPath(fromObject, ['referenceImages']) !== undefined) {
11682
11859
  throw new Error('referenceImages parameter is not supported in Gemini API.');
11683
11860
  }
11861
+ if (getValueByPath(fromObject, ['mask']) !== undefined) {
11862
+ throw new Error('mask parameter is not supported in Gemini API.');
11863
+ }
11684
11864
  if (getValueByPath(fromObject, ['compressionQuality']) !== undefined) {
11685
11865
  throw new Error('compressionQuality parameter is not supported in Gemini API.');
11686
11866
  }
@@ -11763,8 +11943,9 @@ function fileDataToVertex(fromObject) {
11763
11943
  }
11764
11944
  function functionCallToVertex(fromObject) {
11765
11945
  const toObject = {};
11766
- if (getValueByPath(fromObject, ['id']) !== undefined) {
11767
- throw new Error('id parameter is not supported in Vertex AI.');
11946
+ const fromId = getValueByPath(fromObject, ['id']);
11947
+ if (fromId != null) {
11948
+ setValueByPath(toObject, ['id'], fromId);
11768
11949
  }
11769
11950
  const fromArgs = getValueByPath(fromObject, ['args']);
11770
11951
  if (fromArgs != null) {
@@ -13288,6 +13469,18 @@ function videoGenerationReferenceImageToVertex(fromObject) {
13288
13469
  }
13289
13470
  return toObject;
13290
13471
  }
13472
+ function videoGenerationMaskToVertex(fromObject) {
13473
+ const toObject = {};
13474
+ const fromImage = getValueByPath(fromObject, ['image']);
13475
+ if (fromImage != null) {
13476
+ setValueByPath(toObject, ['_self'], imageToVertex(fromImage));
13477
+ }
13478
+ const fromMaskMode = getValueByPath(fromObject, ['maskMode']);
13479
+ if (fromMaskMode != null) {
13480
+ setValueByPath(toObject, ['maskMode'], fromMaskMode);
13481
+ }
13482
+ return toObject;
13483
+ }
13291
13484
  function generateVideosConfigToVertex(fromObject, parentObject) {
13292
13485
  const toObject = {};
13293
13486
  const fromNumberOfVideos = getValueByPath(fromObject, [
@@ -13366,6 +13559,10 @@ function generateVideosConfigToVertex(fromObject, parentObject) {
13366
13559
  }
13367
13560
  setValueByPath(parentObject, ['instances[0]', 'referenceImages'], transformedList);
13368
13561
  }
13562
+ const fromMask = getValueByPath(fromObject, ['mask']);
13563
+ if (parentObject !== undefined && fromMask != null) {
13564
+ setValueByPath(parentObject, ['instances[0]', 'mask'], videoGenerationMaskToVertex(fromMask));
13565
+ }
13369
13566
  const fromCompressionQuality = getValueByPath(fromObject, [
13370
13567
  'compressionQuality',
13371
13568
  ]);
@@ -14024,6 +14221,10 @@ function fileDataFromVertex(fromObject) {
14024
14221
  }
14025
14222
  function functionCallFromVertex(fromObject) {
14026
14223
  const toObject = {};
14224
+ const fromId = getValueByPath(fromObject, ['id']);
14225
+ if (fromId != null) {
14226
+ setValueByPath(toObject, ['id'], fromId);
14227
+ }
14027
14228
  const fromArgs = getValueByPath(fromObject, ['args']);
14028
14229
  if (fromArgs != null) {
14029
14230
  setValueByPath(toObject, ['args'], fromArgs);
@@ -17161,59 +17362,6 @@ class Models extends BaseModule {
17161
17362
  }
17162
17363
  }
17163
17364
 
17164
- /**
17165
- * @license
17166
- * Copyright 2025 Google LLC
17167
- * SPDX-License-Identifier: Apache-2.0
17168
- */
17169
- // Code generated by the Google Gen AI SDK generator DO NOT EDIT.
17170
- function getOperationParametersToMldev(fromObject) {
17171
- const toObject = {};
17172
- const fromOperationName = getValueByPath(fromObject, [
17173
- 'operationName',
17174
- ]);
17175
- if (fromOperationName != null) {
17176
- setValueByPath(toObject, ['_url', 'operationName'], fromOperationName);
17177
- }
17178
- const fromConfig = getValueByPath(fromObject, ['config']);
17179
- if (fromConfig != null) {
17180
- setValueByPath(toObject, ['config'], fromConfig);
17181
- }
17182
- return toObject;
17183
- }
17184
- function fetchPredictOperationParametersToVertex(fromObject) {
17185
- const toObject = {};
17186
- const fromOperationName = getValueByPath(fromObject, [
17187
- 'operationName',
17188
- ]);
17189
- if (fromOperationName != null) {
17190
- setValueByPath(toObject, ['operationName'], fromOperationName);
17191
- }
17192
- const fromResourceName = getValueByPath(fromObject, ['resourceName']);
17193
- if (fromResourceName != null) {
17194
- setValueByPath(toObject, ['_url', 'resourceName'], fromResourceName);
17195
- }
17196
- const fromConfig = getValueByPath(fromObject, ['config']);
17197
- if (fromConfig != null) {
17198
- setValueByPath(toObject, ['config'], fromConfig);
17199
- }
17200
- return toObject;
17201
- }
17202
- function getOperationParametersToVertex(fromObject) {
17203
- const toObject = {};
17204
- const fromOperationName = getValueByPath(fromObject, [
17205
- 'operationName',
17206
- ]);
17207
- if (fromOperationName != null) {
17208
- setValueByPath(toObject, ['_url', 'operationName'], fromOperationName);
17209
- }
17210
- const fromConfig = getValueByPath(fromObject, ['config']);
17211
- if (fromConfig != null) {
17212
- setValueByPath(toObject, ['config'], fromConfig);
17213
- }
17214
- return toObject;
17215
- }
17216
-
17217
17365
  /**
17218
17366
  * @license
17219
17367
  * Copyright 2025 Google LLC
@@ -18395,6 +18543,9 @@ function createTuningJobConfigToMldev(fromObject, parentObject) {
18395
18543
  if (parentObject !== undefined && fromLearningRate != null) {
18396
18544
  setValueByPath(parentObject, ['tuningTask', 'hyperparameters', 'learningRate'], fromLearningRate);
18397
18545
  }
18546
+ if (getValueByPath(fromObject, ['labels']) !== undefined) {
18547
+ throw new Error('labels parameter is not supported in Gemini API.');
18548
+ }
18398
18549
  return toObject;
18399
18550
  }
18400
18551
  function createTuningJobParametersPrivateToMldev(fromObject) {
@@ -18550,6 +18701,10 @@ function createTuningJobConfigToVertex(fromObject, parentObject) {
18550
18701
  if (getValueByPath(fromObject, ['learningRate']) !== undefined) {
18551
18702
  throw new Error('learningRate parameter is not supported in Vertex AI.');
18552
18703
  }
18704
+ const fromLabels = getValueByPath(fromObject, ['labels']);
18705
+ if (parentObject !== undefined && fromLabels != null) {
18706
+ setValueByPath(parentObject, ['labels'], fromLabels);
18707
+ }
18553
18708
  return toObject;
18554
18709
  }
18555
18710
  function createTuningJobParametersPrivateToVertex(fromObject) {