@google/genai 1.24.0 → 1.25.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/genai.d.ts CHANGED
@@ -467,7 +467,6 @@ export declare class Batches extends BaseModule {
467
467
  */
468
468
  list: (params?: types.ListBatchJobsParameters) => Promise<Pager<types.BatchJob>>;
469
469
  private createInlinedGenerateContentRequest;
470
- private createInlinedEmbedContentRequest;
471
470
  private getGcsUri;
472
471
  private getBigqueryUri;
473
472
  private formatDestination;
package/dist/index.cjs CHANGED
@@ -165,6 +165,98 @@ function getValueByPath(data, keys, defaultValue = undefined) {
165
165
  throw error;
166
166
  }
167
167
  }
168
+ /**
169
+ * Moves values from source paths to destination paths.
170
+ *
171
+ * Examples:
172
+ * moveValueByPath(
173
+ * {'requests': [{'content': v1}, {'content': v2}]},
174
+ * {'requests[].*': 'requests[].request.*'}
175
+ * )
176
+ * -> {'requests': [{'request': {'content': v1}}, {'request': {'content': v2}}]}
177
+ */
178
+ function moveValueByPath(data, paths) {
179
+ for (const [sourcePath, destPath] of Object.entries(paths)) {
180
+ const sourceKeys = sourcePath.split('.');
181
+ const destKeys = destPath.split('.');
182
+ // Determine keys to exclude from wildcard to avoid cyclic references
183
+ const excludeKeys = new Set();
184
+ let wildcardIdx = -1;
185
+ for (let i = 0; i < sourceKeys.length; i++) {
186
+ if (sourceKeys[i] === '*') {
187
+ wildcardIdx = i;
188
+ break;
189
+ }
190
+ }
191
+ if (wildcardIdx !== -1 && destKeys.length > wildcardIdx) {
192
+ // Extract the intermediate key between source and dest paths
193
+ // Example: source=['requests[]', '*'], dest=['requests[]', 'request', '*']
194
+ // We want to exclude 'request'
195
+ for (let i = wildcardIdx; i < destKeys.length; i++) {
196
+ const key = destKeys[i];
197
+ if (key !== '*' && !key.endsWith('[]') && !key.endsWith('[0]')) {
198
+ excludeKeys.add(key);
199
+ }
200
+ }
201
+ }
202
+ _moveValueRecursive(data, sourceKeys, destKeys, 0, excludeKeys);
203
+ }
204
+ }
205
+ /**
206
+ * Recursively moves values from source path to destination path.
207
+ */
208
+ function _moveValueRecursive(data, sourceKeys, destKeys, keyIdx, excludeKeys) {
209
+ if (keyIdx >= sourceKeys.length) {
210
+ return;
211
+ }
212
+ if (typeof data !== 'object' || data === null) {
213
+ return;
214
+ }
215
+ const key = sourceKeys[keyIdx];
216
+ if (key.endsWith('[]')) {
217
+ const keyName = key.slice(0, -2);
218
+ const dataRecord = data;
219
+ if (keyName in dataRecord && Array.isArray(dataRecord[keyName])) {
220
+ for (const item of dataRecord[keyName]) {
221
+ _moveValueRecursive(item, sourceKeys, destKeys, keyIdx + 1, excludeKeys);
222
+ }
223
+ }
224
+ }
225
+ else if (key === '*') {
226
+ // wildcard - move all fields
227
+ if (typeof data === 'object' && data !== null && !Array.isArray(data)) {
228
+ const dataRecord = data;
229
+ const keysToMove = Object.keys(dataRecord).filter((k) => !k.startsWith('_') && !excludeKeys.has(k));
230
+ const valuesToMove = {};
231
+ for (const k of keysToMove) {
232
+ valuesToMove[k] = dataRecord[k];
233
+ }
234
+ // Set values at destination
235
+ for (const [k, v] of Object.entries(valuesToMove)) {
236
+ const newDestKeys = [];
237
+ for (const dk of destKeys.slice(keyIdx)) {
238
+ if (dk === '*') {
239
+ newDestKeys.push(k);
240
+ }
241
+ else {
242
+ newDestKeys.push(dk);
243
+ }
244
+ }
245
+ setValueByPath(dataRecord, newDestKeys, v);
246
+ }
247
+ for (const k of keysToMove) {
248
+ delete dataRecord[k];
249
+ }
250
+ }
251
+ }
252
+ else {
253
+ // Navigate to next level
254
+ const dataRecord = data;
255
+ if (key in dataRecord) {
256
+ _moveValueRecursive(dataRecord[key], sourceKeys, destKeys, keyIdx + 1, excludeKeys);
257
+ }
258
+ }
259
+ }
168
260
 
169
261
  /**
170
262
  * @license
@@ -306,7 +398,7 @@ function generateVideosResponseFromVertex$1(fromObject) {
306
398
  }
307
399
  function generatedVideoFromMldev$1(fromObject) {
308
400
  const toObject = {};
309
- const fromVideo = getValueByPath(fromObject, ['_self']);
401
+ const fromVideo = getValueByPath(fromObject, ['video']);
310
402
  if (fromVideo != null) {
311
403
  setValueByPath(toObject, ['video'], videoFromMldev$1(fromVideo));
312
404
  }
@@ -342,14 +434,11 @@ function getOperationParametersToVertex(fromObject) {
342
434
  }
343
435
  function videoFromMldev$1(fromObject) {
344
436
  const toObject = {};
345
- const fromUri = getValueByPath(fromObject, ['video', 'uri']);
437
+ const fromUri = getValueByPath(fromObject, ['uri']);
346
438
  if (fromUri != null) {
347
439
  setValueByPath(toObject, ['uri'], fromUri);
348
440
  }
349
- const fromVideoBytes = getValueByPath(fromObject, [
350
- 'video',
351
- 'encodedVideo',
352
- ]);
441
+ const fromVideoBytes = getValueByPath(fromObject, ['encodedVideo']);
353
442
  if (fromVideoBytes != null) {
354
443
  setValueByPath(toObject, ['videoBytes'], tBytes$1(fromVideoBytes));
355
444
  }
@@ -3482,6 +3571,7 @@ function embedContentBatchToMldev(apiClient, fromObject) {
3482
3571
  const fromConfig = getValueByPath(fromObject, ['config']);
3483
3572
  if (fromConfig != null) {
3484
3573
  setValueByPath(toObject, ['_self'], embedContentConfigToMldev$1(fromConfig, toObject));
3574
+ moveValueByPath(toObject, { 'requests[].*': 'requests[].request.*' });
3485
3575
  }
3486
3576
  return toObject;
3487
3577
  }
@@ -4263,38 +4353,11 @@ class Batches extends BaseModule {
4263
4353
  * ```
4264
4354
  */
4265
4355
  this.createEmbeddings = async (params) => {
4266
- var _a, _b;
4267
4356
  console.warn('batches.createEmbeddings() is experimental and may change without notice.');
4268
4357
  if (this.apiClient.isVertexAI()) {
4269
4358
  throw new Error('Vertex AI does not support batches.createEmbeddings.');
4270
4359
  }
4271
- // MLDEV
4272
- const src = params.src;
4273
- const is_inlined = src.inlinedRequests !== undefined;
4274
- if (!is_inlined) {
4275
- return this.createEmbeddingsInternal(params); // Fixed typo here
4276
- }
4277
- // Inlined embed content requests handling
4278
- const result = this.createInlinedEmbedContentRequest(params);
4279
- const path = result.path;
4280
- const requestBody = result.body;
4281
- const queryParams = createEmbeddingsBatchJobParametersToMldev(this.apiClient, params)['_query'] || {};
4282
- const response = this.apiClient
4283
- .request({
4284
- path: path,
4285
- queryParams: queryParams,
4286
- body: JSON.stringify(requestBody),
4287
- httpMethod: 'POST',
4288
- httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
4289
- abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
4290
- })
4291
- .then((httpResponse) => {
4292
- return httpResponse.json();
4293
- });
4294
- return response.then((apiResponse) => {
4295
- const resp = batchJobFromMldev(apiResponse);
4296
- return resp;
4297
- });
4360
+ return this.createEmbeddingsInternal(params);
4298
4361
  };
4299
4362
  /**
4300
4363
  * Lists batch job configurations.
@@ -4342,35 +4405,6 @@ class Batches extends BaseModule {
4342
4405
  delete body['_query'];
4343
4406
  return { path, body };
4344
4407
  }
4345
- // Helper function to handle inlined embedding requests
4346
- createInlinedEmbedContentRequest(params) {
4347
- const body = createEmbeddingsBatchJobParametersToMldev(this.apiClient, // Use instance apiClient
4348
- params);
4349
- const urlParams = body['_url'];
4350
- const path = formatMap('{model}:asyncBatchEmbedContent', urlParams);
4351
- const batch = body['batch'];
4352
- const inputConfig = batch['inputConfig'];
4353
- const requestsWrapper = inputConfig['requests'];
4354
- const requests = requestsWrapper['requests'];
4355
- const newRequests = [];
4356
- delete requestsWrapper['config']; // Remove top-level config
4357
- for (const request of requests) {
4358
- const requestDict = Object.assign({}, request); // Clone
4359
- const innerRequest = requestDict['request'];
4360
- for (const key in requestDict) {
4361
- if (key !== 'request') {
4362
- innerRequest[key] = requestDict[key];
4363
- delete requestDict[key];
4364
- }
4365
- }
4366
- newRequests.push(requestDict);
4367
- }
4368
- requestsWrapper['requests'] = newRequests;
4369
- delete body['config'];
4370
- delete body['_url'];
4371
- delete body['_query'];
4372
- return { path, body };
4373
- }
4374
4408
  // Helper function to get the first GCS URI
4375
4409
  getGcsUri(src) {
4376
4410
  if (typeof src === 'string') {
@@ -6147,7 +6181,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
6147
6181
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
6148
6182
  const USER_AGENT_HEADER = 'User-Agent';
6149
6183
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
6150
- const SDK_VERSION = '1.24.0'; // x-release-please-version
6184
+ const SDK_VERSION = '1.25.0'; // x-release-please-version
6151
6185
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
6152
6186
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
6153
6187
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -9942,7 +9976,7 @@ function generatedImageMaskFromVertex(fromObject) {
9942
9976
  }
9943
9977
  function generatedVideoFromMldev(fromObject) {
9944
9978
  const toObject = {};
9945
- const fromVideo = getValueByPath(fromObject, ['_self']);
9979
+ const fromVideo = getValueByPath(fromObject, ['video']);
9946
9980
  if (fromVideo != null) {
9947
9981
  setValueByPath(toObject, ['video'], videoFromMldev(fromVideo));
9948
9982
  }
@@ -11088,14 +11122,11 @@ function upscaleImageResponseFromVertex(fromObject) {
11088
11122
  }
11089
11123
  function videoFromMldev(fromObject) {
11090
11124
  const toObject = {};
11091
- const fromUri = getValueByPath(fromObject, ['video', 'uri']);
11125
+ const fromUri = getValueByPath(fromObject, ['uri']);
11092
11126
  if (fromUri != null) {
11093
11127
  setValueByPath(toObject, ['uri'], fromUri);
11094
11128
  }
11095
- const fromVideoBytes = getValueByPath(fromObject, [
11096
- 'video',
11097
- 'encodedVideo',
11098
- ]);
11129
+ const fromVideoBytes = getValueByPath(fromObject, ['encodedVideo']);
11099
11130
  if (fromVideoBytes != null) {
11100
11131
  setValueByPath(toObject, ['videoBytes'], tBytes(fromVideoBytes));
11101
11132
  }
@@ -11167,11 +11198,11 @@ function videoToMldev(fromObject) {
11167
11198
  const toObject = {};
11168
11199
  const fromUri = getValueByPath(fromObject, ['uri']);
11169
11200
  if (fromUri != null) {
11170
- setValueByPath(toObject, ['video', 'uri'], fromUri);
11201
+ setValueByPath(toObject, ['uri'], fromUri);
11171
11202
  }
11172
11203
  const fromVideoBytes = getValueByPath(fromObject, ['videoBytes']);
11173
11204
  if (fromVideoBytes != null) {
11174
- setValueByPath(toObject, ['video', 'encodedVideo'], tBytes(fromVideoBytes));
11205
+ setValueByPath(toObject, ['encodedVideo'], tBytes(fromVideoBytes));
11175
11206
  }
11176
11207
  const fromMimeType = getValueByPath(fromObject, ['mimeType']);
11177
11208
  if (fromMimeType != null) {
@@ -12409,9 +12440,26 @@ class Models extends BaseModule {
12409
12440
  * ```
12410
12441
  */
12411
12442
  this.generateVideos = async (params) => {
12443
+ var _a, _b, _c, _d, _e, _f;
12412
12444
  if ((params.prompt || params.image || params.video) && params.source) {
12413
12445
  throw new Error('Source and prompt/image/video are mutually exclusive. Please only use source.');
12414
12446
  }
12447
+ // Gemini API does not support video bytes.
12448
+ if (!this.apiClient.isVertexAI()) {
12449
+ if (((_a = params.video) === null || _a === void 0 ? void 0 : _a.uri) && ((_b = params.video) === null || _b === void 0 ? void 0 : _b.videoBytes)) {
12450
+ params.video = {
12451
+ uri: params.video.uri,
12452
+ mimeType: params.video.mimeType,
12453
+ };
12454
+ }
12455
+ else if (((_d = (_c = params.source) === null || _c === void 0 ? void 0 : _c.video) === null || _d === void 0 ? void 0 : _d.uri) &&
12456
+ ((_f = (_e = params.source) === null || _e === void 0 ? void 0 : _e.video) === null || _f === void 0 ? void 0 : _f.videoBytes)) {
12457
+ params.source.video = {
12458
+ uri: params.source.video.uri,
12459
+ mimeType: params.source.video.mimeType,
12460
+ };
12461
+ }
12462
+ }
12415
12463
  return await this.generateVideosInternal(params);
12416
12464
  };
12417
12465
  }
package/dist/index.mjs CHANGED
@@ -163,6 +163,98 @@ function getValueByPath(data, keys, defaultValue = undefined) {
163
163
  throw error;
164
164
  }
165
165
  }
166
+ /**
167
+ * Moves values from source paths to destination paths.
168
+ *
169
+ * Examples:
170
+ * moveValueByPath(
171
+ * {'requests': [{'content': v1}, {'content': v2}]},
172
+ * {'requests[].*': 'requests[].request.*'}
173
+ * )
174
+ * -> {'requests': [{'request': {'content': v1}}, {'request': {'content': v2}}]}
175
+ */
176
+ function moveValueByPath(data, paths) {
177
+ for (const [sourcePath, destPath] of Object.entries(paths)) {
178
+ const sourceKeys = sourcePath.split('.');
179
+ const destKeys = destPath.split('.');
180
+ // Determine keys to exclude from wildcard to avoid cyclic references
181
+ const excludeKeys = new Set();
182
+ let wildcardIdx = -1;
183
+ for (let i = 0; i < sourceKeys.length; i++) {
184
+ if (sourceKeys[i] === '*') {
185
+ wildcardIdx = i;
186
+ break;
187
+ }
188
+ }
189
+ if (wildcardIdx !== -1 && destKeys.length > wildcardIdx) {
190
+ // Extract the intermediate key between source and dest paths
191
+ // Example: source=['requests[]', '*'], dest=['requests[]', 'request', '*']
192
+ // We want to exclude 'request'
193
+ for (let i = wildcardIdx; i < destKeys.length; i++) {
194
+ const key = destKeys[i];
195
+ if (key !== '*' && !key.endsWith('[]') && !key.endsWith('[0]')) {
196
+ excludeKeys.add(key);
197
+ }
198
+ }
199
+ }
200
+ _moveValueRecursive(data, sourceKeys, destKeys, 0, excludeKeys);
201
+ }
202
+ }
203
+ /**
204
+ * Recursively moves values from source path to destination path.
205
+ */
206
+ function _moveValueRecursive(data, sourceKeys, destKeys, keyIdx, excludeKeys) {
207
+ if (keyIdx >= sourceKeys.length) {
208
+ return;
209
+ }
210
+ if (typeof data !== 'object' || data === null) {
211
+ return;
212
+ }
213
+ const key = sourceKeys[keyIdx];
214
+ if (key.endsWith('[]')) {
215
+ const keyName = key.slice(0, -2);
216
+ const dataRecord = data;
217
+ if (keyName in dataRecord && Array.isArray(dataRecord[keyName])) {
218
+ for (const item of dataRecord[keyName]) {
219
+ _moveValueRecursive(item, sourceKeys, destKeys, keyIdx + 1, excludeKeys);
220
+ }
221
+ }
222
+ }
223
+ else if (key === '*') {
224
+ // wildcard - move all fields
225
+ if (typeof data === 'object' && data !== null && !Array.isArray(data)) {
226
+ const dataRecord = data;
227
+ const keysToMove = Object.keys(dataRecord).filter((k) => !k.startsWith('_') && !excludeKeys.has(k));
228
+ const valuesToMove = {};
229
+ for (const k of keysToMove) {
230
+ valuesToMove[k] = dataRecord[k];
231
+ }
232
+ // Set values at destination
233
+ for (const [k, v] of Object.entries(valuesToMove)) {
234
+ const newDestKeys = [];
235
+ for (const dk of destKeys.slice(keyIdx)) {
236
+ if (dk === '*') {
237
+ newDestKeys.push(k);
238
+ }
239
+ else {
240
+ newDestKeys.push(dk);
241
+ }
242
+ }
243
+ setValueByPath(dataRecord, newDestKeys, v);
244
+ }
245
+ for (const k of keysToMove) {
246
+ delete dataRecord[k];
247
+ }
248
+ }
249
+ }
250
+ else {
251
+ // Navigate to next level
252
+ const dataRecord = data;
253
+ if (key in dataRecord) {
254
+ _moveValueRecursive(dataRecord[key], sourceKeys, destKeys, keyIdx + 1, excludeKeys);
255
+ }
256
+ }
257
+ }
166
258
 
167
259
  /**
168
260
  * @license
@@ -304,7 +396,7 @@ function generateVideosResponseFromVertex$1(fromObject) {
304
396
  }
305
397
  function generatedVideoFromMldev$1(fromObject) {
306
398
  const toObject = {};
307
- const fromVideo = getValueByPath(fromObject, ['_self']);
399
+ const fromVideo = getValueByPath(fromObject, ['video']);
308
400
  if (fromVideo != null) {
309
401
  setValueByPath(toObject, ['video'], videoFromMldev$1(fromVideo));
310
402
  }
@@ -340,14 +432,11 @@ function getOperationParametersToVertex(fromObject) {
340
432
  }
341
433
  function videoFromMldev$1(fromObject) {
342
434
  const toObject = {};
343
- const fromUri = getValueByPath(fromObject, ['video', 'uri']);
435
+ const fromUri = getValueByPath(fromObject, ['uri']);
344
436
  if (fromUri != null) {
345
437
  setValueByPath(toObject, ['uri'], fromUri);
346
438
  }
347
- const fromVideoBytes = getValueByPath(fromObject, [
348
- 'video',
349
- 'encodedVideo',
350
- ]);
439
+ const fromVideoBytes = getValueByPath(fromObject, ['encodedVideo']);
351
440
  if (fromVideoBytes != null) {
352
441
  setValueByPath(toObject, ['videoBytes'], tBytes$1(fromVideoBytes));
353
442
  }
@@ -3480,6 +3569,7 @@ function embedContentBatchToMldev(apiClient, fromObject) {
3480
3569
  const fromConfig = getValueByPath(fromObject, ['config']);
3481
3570
  if (fromConfig != null) {
3482
3571
  setValueByPath(toObject, ['_self'], embedContentConfigToMldev$1(fromConfig, toObject));
3572
+ moveValueByPath(toObject, { 'requests[].*': 'requests[].request.*' });
3483
3573
  }
3484
3574
  return toObject;
3485
3575
  }
@@ -4261,38 +4351,11 @@ class Batches extends BaseModule {
4261
4351
  * ```
4262
4352
  */
4263
4353
  this.createEmbeddings = async (params) => {
4264
- var _a, _b;
4265
4354
  console.warn('batches.createEmbeddings() is experimental and may change without notice.');
4266
4355
  if (this.apiClient.isVertexAI()) {
4267
4356
  throw new Error('Vertex AI does not support batches.createEmbeddings.');
4268
4357
  }
4269
- // MLDEV
4270
- const src = params.src;
4271
- const is_inlined = src.inlinedRequests !== undefined;
4272
- if (!is_inlined) {
4273
- return this.createEmbeddingsInternal(params); // Fixed typo here
4274
- }
4275
- // Inlined embed content requests handling
4276
- const result = this.createInlinedEmbedContentRequest(params);
4277
- const path = result.path;
4278
- const requestBody = result.body;
4279
- const queryParams = createEmbeddingsBatchJobParametersToMldev(this.apiClient, params)['_query'] || {};
4280
- const response = this.apiClient
4281
- .request({
4282
- path: path,
4283
- queryParams: queryParams,
4284
- body: JSON.stringify(requestBody),
4285
- httpMethod: 'POST',
4286
- httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
4287
- abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
4288
- })
4289
- .then((httpResponse) => {
4290
- return httpResponse.json();
4291
- });
4292
- return response.then((apiResponse) => {
4293
- const resp = batchJobFromMldev(apiResponse);
4294
- return resp;
4295
- });
4358
+ return this.createEmbeddingsInternal(params);
4296
4359
  };
4297
4360
  /**
4298
4361
  * Lists batch job configurations.
@@ -4340,35 +4403,6 @@ class Batches extends BaseModule {
4340
4403
  delete body['_query'];
4341
4404
  return { path, body };
4342
4405
  }
4343
- // Helper function to handle inlined embedding requests
4344
- createInlinedEmbedContentRequest(params) {
4345
- const body = createEmbeddingsBatchJobParametersToMldev(this.apiClient, // Use instance apiClient
4346
- params);
4347
- const urlParams = body['_url'];
4348
- const path = formatMap('{model}:asyncBatchEmbedContent', urlParams);
4349
- const batch = body['batch'];
4350
- const inputConfig = batch['inputConfig'];
4351
- const requestsWrapper = inputConfig['requests'];
4352
- const requests = requestsWrapper['requests'];
4353
- const newRequests = [];
4354
- delete requestsWrapper['config']; // Remove top-level config
4355
- for (const request of requests) {
4356
- const requestDict = Object.assign({}, request); // Clone
4357
- const innerRequest = requestDict['request'];
4358
- for (const key in requestDict) {
4359
- if (key !== 'request') {
4360
- innerRequest[key] = requestDict[key];
4361
- delete requestDict[key];
4362
- }
4363
- }
4364
- newRequests.push(requestDict);
4365
- }
4366
- requestsWrapper['requests'] = newRequests;
4367
- delete body['config'];
4368
- delete body['_url'];
4369
- delete body['_query'];
4370
- return { path, body };
4371
- }
4372
4406
  // Helper function to get the first GCS URI
4373
4407
  getGcsUri(src) {
4374
4408
  if (typeof src === 'string') {
@@ -6145,7 +6179,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
6145
6179
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
6146
6180
  const USER_AGENT_HEADER = 'User-Agent';
6147
6181
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
6148
- const SDK_VERSION = '1.24.0'; // x-release-please-version
6182
+ const SDK_VERSION = '1.25.0'; // x-release-please-version
6149
6183
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
6150
6184
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
6151
6185
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -9940,7 +9974,7 @@ function generatedImageMaskFromVertex(fromObject) {
9940
9974
  }
9941
9975
  function generatedVideoFromMldev(fromObject) {
9942
9976
  const toObject = {};
9943
- const fromVideo = getValueByPath(fromObject, ['_self']);
9977
+ const fromVideo = getValueByPath(fromObject, ['video']);
9944
9978
  if (fromVideo != null) {
9945
9979
  setValueByPath(toObject, ['video'], videoFromMldev(fromVideo));
9946
9980
  }
@@ -11086,14 +11120,11 @@ function upscaleImageResponseFromVertex(fromObject) {
11086
11120
  }
11087
11121
  function videoFromMldev(fromObject) {
11088
11122
  const toObject = {};
11089
- const fromUri = getValueByPath(fromObject, ['video', 'uri']);
11123
+ const fromUri = getValueByPath(fromObject, ['uri']);
11090
11124
  if (fromUri != null) {
11091
11125
  setValueByPath(toObject, ['uri'], fromUri);
11092
11126
  }
11093
- const fromVideoBytes = getValueByPath(fromObject, [
11094
- 'video',
11095
- 'encodedVideo',
11096
- ]);
11127
+ const fromVideoBytes = getValueByPath(fromObject, ['encodedVideo']);
11097
11128
  if (fromVideoBytes != null) {
11098
11129
  setValueByPath(toObject, ['videoBytes'], tBytes(fromVideoBytes));
11099
11130
  }
@@ -11165,11 +11196,11 @@ function videoToMldev(fromObject) {
11165
11196
  const toObject = {};
11166
11197
  const fromUri = getValueByPath(fromObject, ['uri']);
11167
11198
  if (fromUri != null) {
11168
- setValueByPath(toObject, ['video', 'uri'], fromUri);
11199
+ setValueByPath(toObject, ['uri'], fromUri);
11169
11200
  }
11170
11201
  const fromVideoBytes = getValueByPath(fromObject, ['videoBytes']);
11171
11202
  if (fromVideoBytes != null) {
11172
- setValueByPath(toObject, ['video', 'encodedVideo'], tBytes(fromVideoBytes));
11203
+ setValueByPath(toObject, ['encodedVideo'], tBytes(fromVideoBytes));
11173
11204
  }
11174
11205
  const fromMimeType = getValueByPath(fromObject, ['mimeType']);
11175
11206
  if (fromMimeType != null) {
@@ -12407,9 +12438,26 @@ class Models extends BaseModule {
12407
12438
  * ```
12408
12439
  */
12409
12440
  this.generateVideos = async (params) => {
12441
+ var _a, _b, _c, _d, _e, _f;
12410
12442
  if ((params.prompt || params.image || params.video) && params.source) {
12411
12443
  throw new Error('Source and prompt/image/video are mutually exclusive. Please only use source.');
12412
12444
  }
12445
+ // Gemini API does not support video bytes.
12446
+ if (!this.apiClient.isVertexAI()) {
12447
+ if (((_a = params.video) === null || _a === void 0 ? void 0 : _a.uri) && ((_b = params.video) === null || _b === void 0 ? void 0 : _b.videoBytes)) {
12448
+ params.video = {
12449
+ uri: params.video.uri,
12450
+ mimeType: params.video.mimeType,
12451
+ };
12452
+ }
12453
+ else if (((_d = (_c = params.source) === null || _c === void 0 ? void 0 : _c.video) === null || _d === void 0 ? void 0 : _d.uri) &&
12454
+ ((_f = (_e = params.source) === null || _e === void 0 ? void 0 : _e.video) === null || _f === void 0 ? void 0 : _f.videoBytes)) {
12455
+ params.source.video = {
12456
+ uri: params.source.video.uri,
12457
+ mimeType: params.source.video.mimeType,
12458
+ };
12459
+ }
12460
+ }
12413
12461
  return await this.generateVideosInternal(params);
12414
12462
  };
12415
12463
  }