@google/genai 0.6.1 → 0.7.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 +195 -11
- package/dist/index.js +802 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +795 -5
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.js +3848 -3054
- package/dist/node/index.js.map +1 -1
- package/dist/node/node.d.ts +195 -11
- package/dist/web/index.mjs +1809 -1019
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +195 -11
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1339,14 +1339,14 @@ function listCachedContentsResponseFromVertex(apiClient, fromObject) {
|
|
|
1339
1339
|
/**
|
|
1340
1340
|
* Pagers for the GenAI List APIs.
|
|
1341
1341
|
*/
|
|
1342
|
-
|
|
1342
|
+
exports.PagedItem = void 0;
|
|
1343
1343
|
(function (PagedItem) {
|
|
1344
1344
|
PagedItem["PAGED_ITEM_BATCH_JOBS"] = "batchJobs";
|
|
1345
1345
|
PagedItem["PAGED_ITEM_MODELS"] = "models";
|
|
1346
1346
|
PagedItem["PAGED_ITEM_TUNING_JOBS"] = "tuningJobs";
|
|
1347
1347
|
PagedItem["PAGED_ITEM_FILES"] = "files";
|
|
1348
1348
|
PagedItem["PAGED_ITEM_CACHED_CONTENTS"] = "cachedContents";
|
|
1349
|
-
})(PagedItem || (PagedItem = {}));
|
|
1349
|
+
})(exports.PagedItem || (exports.PagedItem = {}));
|
|
1350
1350
|
/**
|
|
1351
1351
|
* Pager class for iterating through paginated results.
|
|
1352
1352
|
*/
|
|
@@ -1691,6 +1691,15 @@ exports.SubjectReferenceType = void 0;
|
|
|
1691
1691
|
SubjectReferenceType["SUBJECT_TYPE_ANIMAL"] = "SUBJECT_TYPE_ANIMAL";
|
|
1692
1692
|
SubjectReferenceType["SUBJECT_TYPE_PRODUCT"] = "SUBJECT_TYPE_PRODUCT";
|
|
1693
1693
|
})(exports.SubjectReferenceType || (exports.SubjectReferenceType = {}));
|
|
1694
|
+
exports.MediaModality = void 0;
|
|
1695
|
+
(function (MediaModality) {
|
|
1696
|
+
MediaModality["MODALITY_UNSPECIFIED"] = "MODALITY_UNSPECIFIED";
|
|
1697
|
+
MediaModality["TEXT"] = "TEXT";
|
|
1698
|
+
MediaModality["IMAGE"] = "IMAGE";
|
|
1699
|
+
MediaModality["VIDEO"] = "VIDEO";
|
|
1700
|
+
MediaModality["AUDIO"] = "AUDIO";
|
|
1701
|
+
MediaModality["DOCUMENT"] = "DOCUMENT";
|
|
1702
|
+
})(exports.MediaModality || (exports.MediaModality = {}));
|
|
1694
1703
|
/** A function response. */
|
|
1695
1704
|
class FunctionResponse {
|
|
1696
1705
|
}
|
|
@@ -2037,6 +2046,9 @@ class CountTokensResponse {
|
|
|
2037
2046
|
/** Response for computing tokens. */
|
|
2038
2047
|
class ComputeTokensResponse {
|
|
2039
2048
|
}
|
|
2049
|
+
/** Response with generated videos. */
|
|
2050
|
+
class GenerateVideosResponse {
|
|
2051
|
+
}
|
|
2040
2052
|
/** Empty response for caches.delete method. */
|
|
2041
2053
|
class DeleteCachedContentResponse {
|
|
2042
2054
|
}
|
|
@@ -2114,12 +2126,18 @@ class Caches extends BaseModule {
|
|
|
2114
2126
|
* ```
|
|
2115
2127
|
*/
|
|
2116
2128
|
this.list = async (params = {}) => {
|
|
2117
|
-
return new Pager(PagedItem.PAGED_ITEM_CACHED_CONTENTS, (x) => this.listInternal(x), await this.listInternal(params), params);
|
|
2129
|
+
return new Pager(exports.PagedItem.PAGED_ITEM_CACHED_CONTENTS, (x) => this.listInternal(x), await this.listInternal(params), params);
|
|
2118
2130
|
};
|
|
2119
2131
|
}
|
|
2120
2132
|
/**
|
|
2121
2133
|
* Creates a cached contents resource.
|
|
2122
2134
|
*
|
|
2135
|
+
* @remarks
|
|
2136
|
+
* Context caching is only supported for specific models. See [Gemini
|
|
2137
|
+
* Developer API reference] (https://ai.google.dev/gemini-api/docs/caching?lang=node/context-cac)
|
|
2138
|
+
* and [Vertex AI reference] (https://cloud.google.com/vertex-ai/generative-ai/docs/context-cache/context-cache-overview#supported_models)
|
|
2139
|
+
* for more information.
|
|
2140
|
+
*
|
|
2123
2141
|
* @param params - The parameters for the create request.
|
|
2124
2142
|
* @return The created cached content.
|
|
2125
2143
|
*
|
|
@@ -2127,7 +2145,7 @@ class Caches extends BaseModule {
|
|
|
2127
2145
|
* ```ts
|
|
2128
2146
|
* const contents = ...; // Initialize the content to cache.
|
|
2129
2147
|
* const response = await ai.caches.create({
|
|
2130
|
-
* model: 'gemini-
|
|
2148
|
+
* model: 'gemini-1.5-flash',
|
|
2131
2149
|
* config: {
|
|
2132
2150
|
* 'contents': contents,
|
|
2133
2151
|
* 'displayName': 'test cache',
|
|
@@ -2809,7 +2827,7 @@ class Chat {
|
|
|
2809
2827
|
const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
2810
2828
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
2811
2829
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
2812
|
-
const SDK_VERSION = '0.
|
|
2830
|
+
const SDK_VERSION = '0.7.0'; // x-release-please-version
|
|
2813
2831
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
2814
2832
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
2815
2833
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -3145,7 +3163,7 @@ class ApiClient {
|
|
|
3145
3163
|
}
|
|
3146
3164
|
const uploader = this.clientOptions.uploader;
|
|
3147
3165
|
const fileStat = await uploader.stat(file);
|
|
3148
|
-
fileToUpload.sizeBytes = fileStat.size;
|
|
3166
|
+
fileToUpload.sizeBytes = String(fileStat.size);
|
|
3149
3167
|
const mimeType = (_a = config === null || config === void 0 ? void 0 : config.mimeType) !== null && _a !== void 0 ? _a : fileStat.type;
|
|
3150
3168
|
if (mimeType === undefined || mimeType === '') {
|
|
3151
3169
|
throw new Error('Can not determine mimeType. Please provide mimeType in the config.');
|
|
@@ -3604,7 +3622,7 @@ class Files extends BaseModule {
|
|
|
3604
3622
|
* ```
|
|
3605
3623
|
*/
|
|
3606
3624
|
this.list = async (params = {}) => {
|
|
3607
|
-
return new Pager(PagedItem.PAGED_ITEM_FILES, (x) => this.listInternal(x), await this.listInternal(params), params);
|
|
3625
|
+
return new Pager(exports.PagedItem.PAGED_ITEM_FILES, (x) => this.listInternal(x), await this.listInternal(params), params);
|
|
3608
3626
|
};
|
|
3609
3627
|
}
|
|
3610
3628
|
/**
|
|
@@ -3632,7 +3650,6 @@ class Files extends BaseModule {
|
|
|
3632
3650
|
*
|
|
3633
3651
|
* @param params - Optional parameters specified in the
|
|
3634
3652
|
* `common.UploadFileParameters` interface.
|
|
3635
|
-
* Optional @see {@link common.UploadFileParameters}
|
|
3636
3653
|
* @return A promise that resolves to a `types.File` object.
|
|
3637
3654
|
* @throws An error if called on a Vertex AI client.
|
|
3638
3655
|
* @throws An error if the `mimeType` is not provided and can not be inferred,
|
|
@@ -4475,6 +4492,91 @@ function countTokensParametersToMldev(apiClient, fromObject) {
|
|
|
4475
4492
|
}
|
|
4476
4493
|
return toObject;
|
|
4477
4494
|
}
|
|
4495
|
+
function imageToMldev(apiClient, fromObject) {
|
|
4496
|
+
const toObject = {};
|
|
4497
|
+
if (getValueByPath(fromObject, ['gcsUri']) !== undefined) {
|
|
4498
|
+
throw new Error('gcsUri parameter is not supported in Gemini API.');
|
|
4499
|
+
}
|
|
4500
|
+
const fromImageBytes = getValueByPath(fromObject, ['imageBytes']);
|
|
4501
|
+
if (fromImageBytes != null) {
|
|
4502
|
+
setValueByPath(toObject, ['bytesBase64Encoded'], tBytes(apiClient, fromImageBytes));
|
|
4503
|
+
}
|
|
4504
|
+
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
4505
|
+
if (fromMimeType != null) {
|
|
4506
|
+
setValueByPath(toObject, ['mimeType'], fromMimeType);
|
|
4507
|
+
}
|
|
4508
|
+
return toObject;
|
|
4509
|
+
}
|
|
4510
|
+
function generateVideosConfigToMldev(apiClient, fromObject, parentObject) {
|
|
4511
|
+
const toObject = {};
|
|
4512
|
+
const fromNumberOfVideos = getValueByPath(fromObject, [
|
|
4513
|
+
'numberOfVideos',
|
|
4514
|
+
]);
|
|
4515
|
+
if (parentObject !== undefined && fromNumberOfVideos != null) {
|
|
4516
|
+
setValueByPath(parentObject, ['parameters', 'sampleCount'], fromNumberOfVideos);
|
|
4517
|
+
}
|
|
4518
|
+
if (getValueByPath(fromObject, ['outputGcsUri']) !== undefined) {
|
|
4519
|
+
throw new Error('outputGcsUri parameter is not supported in Gemini API.');
|
|
4520
|
+
}
|
|
4521
|
+
if (getValueByPath(fromObject, ['fps']) !== undefined) {
|
|
4522
|
+
throw new Error('fps parameter is not supported in Gemini API.');
|
|
4523
|
+
}
|
|
4524
|
+
const fromDurationSeconds = getValueByPath(fromObject, [
|
|
4525
|
+
'durationSeconds',
|
|
4526
|
+
]);
|
|
4527
|
+
if (parentObject !== undefined && fromDurationSeconds != null) {
|
|
4528
|
+
setValueByPath(parentObject, ['parameters', 'durationSeconds'], fromDurationSeconds);
|
|
4529
|
+
}
|
|
4530
|
+
if (getValueByPath(fromObject, ['seed']) !== undefined) {
|
|
4531
|
+
throw new Error('seed parameter is not supported in Gemini API.');
|
|
4532
|
+
}
|
|
4533
|
+
const fromAspectRatio = getValueByPath(fromObject, ['aspectRatio']);
|
|
4534
|
+
if (parentObject !== undefined && fromAspectRatio != null) {
|
|
4535
|
+
setValueByPath(parentObject, ['parameters', 'aspectRatio'], fromAspectRatio);
|
|
4536
|
+
}
|
|
4537
|
+
if (getValueByPath(fromObject, ['resolution']) !== undefined) {
|
|
4538
|
+
throw new Error('resolution parameter is not supported in Gemini API.');
|
|
4539
|
+
}
|
|
4540
|
+
const fromPersonGeneration = getValueByPath(fromObject, [
|
|
4541
|
+
'personGeneration',
|
|
4542
|
+
]);
|
|
4543
|
+
if (parentObject !== undefined && fromPersonGeneration != null) {
|
|
4544
|
+
setValueByPath(parentObject, ['parameters', 'personGeneration'], fromPersonGeneration);
|
|
4545
|
+
}
|
|
4546
|
+
if (getValueByPath(fromObject, ['pubsubTopic']) !== undefined) {
|
|
4547
|
+
throw new Error('pubsubTopic parameter is not supported in Gemini API.');
|
|
4548
|
+
}
|
|
4549
|
+
const fromNegativePrompt = getValueByPath(fromObject, [
|
|
4550
|
+
'negativePrompt',
|
|
4551
|
+
]);
|
|
4552
|
+
if (parentObject !== undefined && fromNegativePrompt != null) {
|
|
4553
|
+
setValueByPath(parentObject, ['parameters', 'negativePrompt'], fromNegativePrompt);
|
|
4554
|
+
}
|
|
4555
|
+
if (getValueByPath(fromObject, ['enhancePrompt']) !== undefined) {
|
|
4556
|
+
throw new Error('enhancePrompt parameter is not supported in Gemini API.');
|
|
4557
|
+
}
|
|
4558
|
+
return toObject;
|
|
4559
|
+
}
|
|
4560
|
+
function generateVideosParametersToMldev(apiClient, fromObject) {
|
|
4561
|
+
const toObject = {};
|
|
4562
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
4563
|
+
if (fromModel != null) {
|
|
4564
|
+
setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
|
|
4565
|
+
}
|
|
4566
|
+
const fromPrompt = getValueByPath(fromObject, ['prompt']);
|
|
4567
|
+
if (fromPrompt != null) {
|
|
4568
|
+
setValueByPath(toObject, ['instances[0]', 'prompt'], fromPrompt);
|
|
4569
|
+
}
|
|
4570
|
+
const fromImage = getValueByPath(fromObject, ['image']);
|
|
4571
|
+
if (fromImage != null) {
|
|
4572
|
+
setValueByPath(toObject, ['instances[0]', 'image'], imageToMldev(apiClient, fromImage));
|
|
4573
|
+
}
|
|
4574
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
4575
|
+
if (fromConfig != null) {
|
|
4576
|
+
setValueByPath(toObject, ['config'], generateVideosConfigToMldev(apiClient, fromConfig, toObject));
|
|
4577
|
+
}
|
|
4578
|
+
return toObject;
|
|
4579
|
+
}
|
|
4478
4580
|
function partToVertex(apiClient, fromObject) {
|
|
4479
4581
|
const toObject = {};
|
|
4480
4582
|
const fromVideoMetadata = getValueByPath(fromObject, [
|
|
@@ -5189,6 +5291,100 @@ function computeTokensParametersToVertex(apiClient, fromObject) {
|
|
|
5189
5291
|
}
|
|
5190
5292
|
return toObject;
|
|
5191
5293
|
}
|
|
5294
|
+
function imageToVertex(apiClient, fromObject) {
|
|
5295
|
+
const toObject = {};
|
|
5296
|
+
const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
|
|
5297
|
+
if (fromGcsUri != null) {
|
|
5298
|
+
setValueByPath(toObject, ['gcsUri'], fromGcsUri);
|
|
5299
|
+
}
|
|
5300
|
+
const fromImageBytes = getValueByPath(fromObject, ['imageBytes']);
|
|
5301
|
+
if (fromImageBytes != null) {
|
|
5302
|
+
setValueByPath(toObject, ['bytesBase64Encoded'], tBytes(apiClient, fromImageBytes));
|
|
5303
|
+
}
|
|
5304
|
+
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
5305
|
+
if (fromMimeType != null) {
|
|
5306
|
+
setValueByPath(toObject, ['mimeType'], fromMimeType);
|
|
5307
|
+
}
|
|
5308
|
+
return toObject;
|
|
5309
|
+
}
|
|
5310
|
+
function generateVideosConfigToVertex(apiClient, fromObject, parentObject) {
|
|
5311
|
+
const toObject = {};
|
|
5312
|
+
const fromNumberOfVideos = getValueByPath(fromObject, [
|
|
5313
|
+
'numberOfVideos',
|
|
5314
|
+
]);
|
|
5315
|
+
if (parentObject !== undefined && fromNumberOfVideos != null) {
|
|
5316
|
+
setValueByPath(parentObject, ['parameters', 'sampleCount'], fromNumberOfVideos);
|
|
5317
|
+
}
|
|
5318
|
+
const fromOutputGcsUri = getValueByPath(fromObject, ['outputGcsUri']);
|
|
5319
|
+
if (parentObject !== undefined && fromOutputGcsUri != null) {
|
|
5320
|
+
setValueByPath(parentObject, ['parameters', 'storageUri'], fromOutputGcsUri);
|
|
5321
|
+
}
|
|
5322
|
+
const fromFps = getValueByPath(fromObject, ['fps']);
|
|
5323
|
+
if (parentObject !== undefined && fromFps != null) {
|
|
5324
|
+
setValueByPath(parentObject, ['parameters', 'fps'], fromFps);
|
|
5325
|
+
}
|
|
5326
|
+
const fromDurationSeconds = getValueByPath(fromObject, [
|
|
5327
|
+
'durationSeconds',
|
|
5328
|
+
]);
|
|
5329
|
+
if (parentObject !== undefined && fromDurationSeconds != null) {
|
|
5330
|
+
setValueByPath(parentObject, ['parameters', 'durationSeconds'], fromDurationSeconds);
|
|
5331
|
+
}
|
|
5332
|
+
const fromSeed = getValueByPath(fromObject, ['seed']);
|
|
5333
|
+
if (parentObject !== undefined && fromSeed != null) {
|
|
5334
|
+
setValueByPath(parentObject, ['parameters', 'seed'], fromSeed);
|
|
5335
|
+
}
|
|
5336
|
+
const fromAspectRatio = getValueByPath(fromObject, ['aspectRatio']);
|
|
5337
|
+
if (parentObject !== undefined && fromAspectRatio != null) {
|
|
5338
|
+
setValueByPath(parentObject, ['parameters', 'aspectRatio'], fromAspectRatio);
|
|
5339
|
+
}
|
|
5340
|
+
const fromResolution = getValueByPath(fromObject, ['resolution']);
|
|
5341
|
+
if (parentObject !== undefined && fromResolution != null) {
|
|
5342
|
+
setValueByPath(parentObject, ['parameters', 'resolution'], fromResolution);
|
|
5343
|
+
}
|
|
5344
|
+
const fromPersonGeneration = getValueByPath(fromObject, [
|
|
5345
|
+
'personGeneration',
|
|
5346
|
+
]);
|
|
5347
|
+
if (parentObject !== undefined && fromPersonGeneration != null) {
|
|
5348
|
+
setValueByPath(parentObject, ['parameters', 'personGeneration'], fromPersonGeneration);
|
|
5349
|
+
}
|
|
5350
|
+
const fromPubsubTopic = getValueByPath(fromObject, ['pubsubTopic']);
|
|
5351
|
+
if (parentObject !== undefined && fromPubsubTopic != null) {
|
|
5352
|
+
setValueByPath(parentObject, ['parameters', 'pubsubTopic'], fromPubsubTopic);
|
|
5353
|
+
}
|
|
5354
|
+
const fromNegativePrompt = getValueByPath(fromObject, [
|
|
5355
|
+
'negativePrompt',
|
|
5356
|
+
]);
|
|
5357
|
+
if (parentObject !== undefined && fromNegativePrompt != null) {
|
|
5358
|
+
setValueByPath(parentObject, ['parameters', 'negativePrompt'], fromNegativePrompt);
|
|
5359
|
+
}
|
|
5360
|
+
const fromEnhancePrompt = getValueByPath(fromObject, [
|
|
5361
|
+
'enhancePrompt',
|
|
5362
|
+
]);
|
|
5363
|
+
if (parentObject !== undefined && fromEnhancePrompt != null) {
|
|
5364
|
+
setValueByPath(parentObject, ['parameters', 'enhancePrompt'], fromEnhancePrompt);
|
|
5365
|
+
}
|
|
5366
|
+
return toObject;
|
|
5367
|
+
}
|
|
5368
|
+
function generateVideosParametersToVertex(apiClient, fromObject) {
|
|
5369
|
+
const toObject = {};
|
|
5370
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
5371
|
+
if (fromModel != null) {
|
|
5372
|
+
setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
|
|
5373
|
+
}
|
|
5374
|
+
const fromPrompt = getValueByPath(fromObject, ['prompt']);
|
|
5375
|
+
if (fromPrompt != null) {
|
|
5376
|
+
setValueByPath(toObject, ['instances[0]', 'prompt'], fromPrompt);
|
|
5377
|
+
}
|
|
5378
|
+
const fromImage = getValueByPath(fromObject, ['image']);
|
|
5379
|
+
if (fromImage != null) {
|
|
5380
|
+
setValueByPath(toObject, ['instances[0]', 'image'], imageToVertex(apiClient, fromImage));
|
|
5381
|
+
}
|
|
5382
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
5383
|
+
if (fromConfig != null) {
|
|
5384
|
+
setValueByPath(toObject, ['config'], generateVideosConfigToVertex(apiClient, fromConfig, toObject));
|
|
5385
|
+
}
|
|
5386
|
+
return toObject;
|
|
5387
|
+
}
|
|
5192
5388
|
function partFromMldev(apiClient, fromObject) {
|
|
5193
5389
|
const toObject = {};
|
|
5194
5390
|
const fromThought = getValueByPath(fromObject, ['thought']);
|
|
@@ -5459,6 +5655,93 @@ function countTokensResponseFromMldev(apiClient, fromObject) {
|
|
|
5459
5655
|
}
|
|
5460
5656
|
return toObject;
|
|
5461
5657
|
}
|
|
5658
|
+
function videoFromMldev$1(apiClient, fromObject) {
|
|
5659
|
+
const toObject = {};
|
|
5660
|
+
const fromUri = getValueByPath(fromObject, ['video', 'uri']);
|
|
5661
|
+
if (fromUri != null) {
|
|
5662
|
+
setValueByPath(toObject, ['uri'], fromUri);
|
|
5663
|
+
}
|
|
5664
|
+
const fromVideoBytes = getValueByPath(fromObject, [
|
|
5665
|
+
'video',
|
|
5666
|
+
'encodedVideo',
|
|
5667
|
+
]);
|
|
5668
|
+
if (fromVideoBytes != null) {
|
|
5669
|
+
setValueByPath(toObject, ['videoBytes'], tBytes(apiClient, fromVideoBytes));
|
|
5670
|
+
}
|
|
5671
|
+
const fromMimeType = getValueByPath(fromObject, ['encoding']);
|
|
5672
|
+
if (fromMimeType != null) {
|
|
5673
|
+
setValueByPath(toObject, ['mimeType'], fromMimeType);
|
|
5674
|
+
}
|
|
5675
|
+
return toObject;
|
|
5676
|
+
}
|
|
5677
|
+
function generatedVideoFromMldev$1(apiClient, fromObject) {
|
|
5678
|
+
const toObject = {};
|
|
5679
|
+
const fromVideo = getValueByPath(fromObject, ['_self']);
|
|
5680
|
+
if (fromVideo != null) {
|
|
5681
|
+
setValueByPath(toObject, ['video'], videoFromMldev$1(apiClient, fromVideo));
|
|
5682
|
+
}
|
|
5683
|
+
return toObject;
|
|
5684
|
+
}
|
|
5685
|
+
function generateVideosResponseFromMldev$1(apiClient, fromObject) {
|
|
5686
|
+
const toObject = {};
|
|
5687
|
+
const fromGeneratedVideos = getValueByPath(fromObject, [
|
|
5688
|
+
'generatedSamples',
|
|
5689
|
+
]);
|
|
5690
|
+
if (fromGeneratedVideos != null) {
|
|
5691
|
+
if (Array.isArray(fromGeneratedVideos)) {
|
|
5692
|
+
setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos.map((item) => {
|
|
5693
|
+
return generatedVideoFromMldev$1(apiClient, item);
|
|
5694
|
+
}));
|
|
5695
|
+
}
|
|
5696
|
+
else {
|
|
5697
|
+
setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos);
|
|
5698
|
+
}
|
|
5699
|
+
}
|
|
5700
|
+
const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
|
|
5701
|
+
'raiMediaFilteredCount',
|
|
5702
|
+
]);
|
|
5703
|
+
if (fromRaiMediaFilteredCount != null) {
|
|
5704
|
+
setValueByPath(toObject, ['raiMediaFilteredCount'], fromRaiMediaFilteredCount);
|
|
5705
|
+
}
|
|
5706
|
+
const fromRaiMediaFilteredReasons = getValueByPath(fromObject, [
|
|
5707
|
+
'raiMediaFilteredReasons',
|
|
5708
|
+
]);
|
|
5709
|
+
if (fromRaiMediaFilteredReasons != null) {
|
|
5710
|
+
setValueByPath(toObject, ['raiMediaFilteredReasons'], fromRaiMediaFilteredReasons);
|
|
5711
|
+
}
|
|
5712
|
+
return toObject;
|
|
5713
|
+
}
|
|
5714
|
+
function generateVideosOperationFromMldev$1(apiClient, fromObject) {
|
|
5715
|
+
const toObject = {};
|
|
5716
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
5717
|
+
if (fromName != null) {
|
|
5718
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
5719
|
+
}
|
|
5720
|
+
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
5721
|
+
if (fromMetadata != null) {
|
|
5722
|
+
setValueByPath(toObject, ['metadata'], fromMetadata);
|
|
5723
|
+
}
|
|
5724
|
+
const fromDone = getValueByPath(fromObject, ['done']);
|
|
5725
|
+
if (fromDone != null) {
|
|
5726
|
+
setValueByPath(toObject, ['done'], fromDone);
|
|
5727
|
+
}
|
|
5728
|
+
const fromError = getValueByPath(fromObject, ['error']);
|
|
5729
|
+
if (fromError != null) {
|
|
5730
|
+
setValueByPath(toObject, ['error'], fromError);
|
|
5731
|
+
}
|
|
5732
|
+
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
5733
|
+
if (fromResponse != null) {
|
|
5734
|
+
setValueByPath(toObject, ['response'], fromResponse);
|
|
5735
|
+
}
|
|
5736
|
+
const fromResult = getValueByPath(fromObject, [
|
|
5737
|
+
'response',
|
|
5738
|
+
'generateVideoResponse',
|
|
5739
|
+
]);
|
|
5740
|
+
if (fromResult != null) {
|
|
5741
|
+
setValueByPath(toObject, ['result'], generateVideosResponseFromMldev$1(apiClient, fromResult));
|
|
5742
|
+
}
|
|
5743
|
+
return toObject;
|
|
5744
|
+
}
|
|
5462
5745
|
function partFromVertex(apiClient, fromObject) {
|
|
5463
5746
|
const toObject = {};
|
|
5464
5747
|
const fromVideoMetadata = getValueByPath(fromObject, [
|
|
@@ -5780,6 +6063,87 @@ function computeTokensResponseFromVertex(apiClient, fromObject) {
|
|
|
5780
6063
|
}
|
|
5781
6064
|
return toObject;
|
|
5782
6065
|
}
|
|
6066
|
+
function videoFromVertex$1(apiClient, fromObject) {
|
|
6067
|
+
const toObject = {};
|
|
6068
|
+
const fromUri = getValueByPath(fromObject, ['gcsUri']);
|
|
6069
|
+
if (fromUri != null) {
|
|
6070
|
+
setValueByPath(toObject, ['uri'], fromUri);
|
|
6071
|
+
}
|
|
6072
|
+
const fromVideoBytes = getValueByPath(fromObject, [
|
|
6073
|
+
'bytesBase64Encoded',
|
|
6074
|
+
]);
|
|
6075
|
+
if (fromVideoBytes != null) {
|
|
6076
|
+
setValueByPath(toObject, ['videoBytes'], tBytes(apiClient, fromVideoBytes));
|
|
6077
|
+
}
|
|
6078
|
+
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
6079
|
+
if (fromMimeType != null) {
|
|
6080
|
+
setValueByPath(toObject, ['mimeType'], fromMimeType);
|
|
6081
|
+
}
|
|
6082
|
+
return toObject;
|
|
6083
|
+
}
|
|
6084
|
+
function generatedVideoFromVertex$1(apiClient, fromObject) {
|
|
6085
|
+
const toObject = {};
|
|
6086
|
+
const fromVideo = getValueByPath(fromObject, ['_self']);
|
|
6087
|
+
if (fromVideo != null) {
|
|
6088
|
+
setValueByPath(toObject, ['video'], videoFromVertex$1(apiClient, fromVideo));
|
|
6089
|
+
}
|
|
6090
|
+
return toObject;
|
|
6091
|
+
}
|
|
6092
|
+
function generateVideosResponseFromVertex$1(apiClient, fromObject) {
|
|
6093
|
+
const toObject = {};
|
|
6094
|
+
const fromGeneratedVideos = getValueByPath(fromObject, ['videos']);
|
|
6095
|
+
if (fromGeneratedVideos != null) {
|
|
6096
|
+
if (Array.isArray(fromGeneratedVideos)) {
|
|
6097
|
+
setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos.map((item) => {
|
|
6098
|
+
return generatedVideoFromVertex$1(apiClient, item);
|
|
6099
|
+
}));
|
|
6100
|
+
}
|
|
6101
|
+
else {
|
|
6102
|
+
setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos);
|
|
6103
|
+
}
|
|
6104
|
+
}
|
|
6105
|
+
const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
|
|
6106
|
+
'raiMediaFilteredCount',
|
|
6107
|
+
]);
|
|
6108
|
+
if (fromRaiMediaFilteredCount != null) {
|
|
6109
|
+
setValueByPath(toObject, ['raiMediaFilteredCount'], fromRaiMediaFilteredCount);
|
|
6110
|
+
}
|
|
6111
|
+
const fromRaiMediaFilteredReasons = getValueByPath(fromObject, [
|
|
6112
|
+
'raiMediaFilteredReasons',
|
|
6113
|
+
]);
|
|
6114
|
+
if (fromRaiMediaFilteredReasons != null) {
|
|
6115
|
+
setValueByPath(toObject, ['raiMediaFilteredReasons'], fromRaiMediaFilteredReasons);
|
|
6116
|
+
}
|
|
6117
|
+
return toObject;
|
|
6118
|
+
}
|
|
6119
|
+
function generateVideosOperationFromVertex$1(apiClient, fromObject) {
|
|
6120
|
+
const toObject = {};
|
|
6121
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
6122
|
+
if (fromName != null) {
|
|
6123
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
6124
|
+
}
|
|
6125
|
+
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
6126
|
+
if (fromMetadata != null) {
|
|
6127
|
+
setValueByPath(toObject, ['metadata'], fromMetadata);
|
|
6128
|
+
}
|
|
6129
|
+
const fromDone = getValueByPath(fromObject, ['done']);
|
|
6130
|
+
if (fromDone != null) {
|
|
6131
|
+
setValueByPath(toObject, ['done'], fromDone);
|
|
6132
|
+
}
|
|
6133
|
+
const fromError = getValueByPath(fromObject, ['error']);
|
|
6134
|
+
if (fromError != null) {
|
|
6135
|
+
setValueByPath(toObject, ['error'], fromError);
|
|
6136
|
+
}
|
|
6137
|
+
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
6138
|
+
if (fromResponse != null) {
|
|
6139
|
+
setValueByPath(toObject, ['response'], fromResponse);
|
|
6140
|
+
}
|
|
6141
|
+
const fromResult = getValueByPath(fromObject, ['response']);
|
|
6142
|
+
if (fromResult != null) {
|
|
6143
|
+
setValueByPath(toObject, ['result'], generateVideosResponseFromVertex$1(apiClient, fromResult));
|
|
6144
|
+
}
|
|
6145
|
+
return toObject;
|
|
6146
|
+
}
|
|
5783
6147
|
|
|
5784
6148
|
/**
|
|
5785
6149
|
* @license
|
|
@@ -6246,6 +6610,9 @@ class Session {
|
|
|
6246
6610
|
if (!Array.isArray(params.functionResponses)) {
|
|
6247
6611
|
functionResponses = [params.functionResponses];
|
|
6248
6612
|
}
|
|
6613
|
+
else {
|
|
6614
|
+
functionResponses = params.functionResponses;
|
|
6615
|
+
}
|
|
6249
6616
|
if (functionResponses.length === 0) {
|
|
6250
6617
|
throw new Error('functionResponses is required.');
|
|
6251
6618
|
}
|
|
@@ -6975,6 +7342,428 @@ class Models extends BaseModule {
|
|
|
6975
7342
|
throw new Error('This method is only supported by the Vertex AI.');
|
|
6976
7343
|
}
|
|
6977
7344
|
}
|
|
7345
|
+
/**
|
|
7346
|
+
* Generates videos based on a text description and configuration.
|
|
7347
|
+
*
|
|
7348
|
+
* @param params - The parameters for generating videos.
|
|
7349
|
+
* @return A Promise<GenerateVideosOperation> which allows you to track the progress and eventually retrieve the generated videos using the operations.get method.
|
|
7350
|
+
*
|
|
7351
|
+
* @example
|
|
7352
|
+
* ```ts
|
|
7353
|
+
* const operation = await ai.models.generateVideos({
|
|
7354
|
+
* model: 'veo-2.0-generate-001',
|
|
7355
|
+
* prompt: 'A neon hologram of a cat driving at top speed',
|
|
7356
|
+
* config: {
|
|
7357
|
+
* numberOfVideos: 1
|
|
7358
|
+
* });
|
|
7359
|
+
*
|
|
7360
|
+
* while (!operation.done) {
|
|
7361
|
+
* await new Promise(resolve => setTimeout(resolve, 10000));
|
|
7362
|
+
* operation = await ai.operations.get({operation: operation});
|
|
7363
|
+
* }
|
|
7364
|
+
*
|
|
7365
|
+
* console.log(operation.result?.generatedVideos?.[0]?.video?.uri);
|
|
7366
|
+
* ```
|
|
7367
|
+
*/
|
|
7368
|
+
async generateVideos(params) {
|
|
7369
|
+
var _a, _b;
|
|
7370
|
+
let response;
|
|
7371
|
+
let path = '';
|
|
7372
|
+
let queryParams = {};
|
|
7373
|
+
if (this.apiClient.isVertexAI()) {
|
|
7374
|
+
const body = generateVideosParametersToVertex(this.apiClient, params);
|
|
7375
|
+
path = formatMap('{model}:predictLongRunning', body['_url']);
|
|
7376
|
+
queryParams = body['_query'];
|
|
7377
|
+
delete body['config'];
|
|
7378
|
+
delete body['_url'];
|
|
7379
|
+
delete body['_query'];
|
|
7380
|
+
response = this.apiClient
|
|
7381
|
+
.request({
|
|
7382
|
+
path: path,
|
|
7383
|
+
queryParams: queryParams,
|
|
7384
|
+
body: JSON.stringify(body),
|
|
7385
|
+
httpMethod: 'POST',
|
|
7386
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
7387
|
+
})
|
|
7388
|
+
.then((httpResponse) => {
|
|
7389
|
+
return httpResponse.json();
|
|
7390
|
+
});
|
|
7391
|
+
return response.then((apiResponse) => {
|
|
7392
|
+
const resp = generateVideosOperationFromVertex$1(this.apiClient, apiResponse);
|
|
7393
|
+
return resp;
|
|
7394
|
+
});
|
|
7395
|
+
}
|
|
7396
|
+
else {
|
|
7397
|
+
const body = generateVideosParametersToMldev(this.apiClient, params);
|
|
7398
|
+
path = formatMap('{model}:predictLongRunning', body['_url']);
|
|
7399
|
+
queryParams = body['_query'];
|
|
7400
|
+
delete body['config'];
|
|
7401
|
+
delete body['_url'];
|
|
7402
|
+
delete body['_query'];
|
|
7403
|
+
response = this.apiClient
|
|
7404
|
+
.request({
|
|
7405
|
+
path: path,
|
|
7406
|
+
queryParams: queryParams,
|
|
7407
|
+
body: JSON.stringify(body),
|
|
7408
|
+
httpMethod: 'POST',
|
|
7409
|
+
httpOptions: (_b = params.config) === null || _b === void 0 ? void 0 : _b.httpOptions,
|
|
7410
|
+
})
|
|
7411
|
+
.then((httpResponse) => {
|
|
7412
|
+
return httpResponse.json();
|
|
7413
|
+
});
|
|
7414
|
+
return response.then((apiResponse) => {
|
|
7415
|
+
const resp = generateVideosOperationFromMldev$1(this.apiClient, apiResponse);
|
|
7416
|
+
return resp;
|
|
7417
|
+
});
|
|
7418
|
+
}
|
|
7419
|
+
}
|
|
7420
|
+
}
|
|
7421
|
+
|
|
7422
|
+
/**
|
|
7423
|
+
* @license
|
|
7424
|
+
* Copyright 2025 Google LLC
|
|
7425
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
7426
|
+
*/
|
|
7427
|
+
function getOperationParametersToMldev(apiClient, fromObject) {
|
|
7428
|
+
const toObject = {};
|
|
7429
|
+
const fromOperationName = getValueByPath(fromObject, [
|
|
7430
|
+
'operationName',
|
|
7431
|
+
]);
|
|
7432
|
+
if (fromOperationName != null) {
|
|
7433
|
+
setValueByPath(toObject, ['_url', 'operationName'], fromOperationName);
|
|
7434
|
+
}
|
|
7435
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
7436
|
+
if (fromConfig != null) {
|
|
7437
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
7438
|
+
}
|
|
7439
|
+
return toObject;
|
|
7440
|
+
}
|
|
7441
|
+
function getOperationParametersToVertex(apiClient, fromObject) {
|
|
7442
|
+
const toObject = {};
|
|
7443
|
+
const fromOperationName = getValueByPath(fromObject, [
|
|
7444
|
+
'operationName',
|
|
7445
|
+
]);
|
|
7446
|
+
if (fromOperationName != null) {
|
|
7447
|
+
setValueByPath(toObject, ['_url', 'operationName'], fromOperationName);
|
|
7448
|
+
}
|
|
7449
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
7450
|
+
if (fromConfig != null) {
|
|
7451
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
7452
|
+
}
|
|
7453
|
+
return toObject;
|
|
7454
|
+
}
|
|
7455
|
+
function fetchPredictOperationParametersToVertex(apiClient, fromObject) {
|
|
7456
|
+
const toObject = {};
|
|
7457
|
+
const fromOperationName = getValueByPath(fromObject, [
|
|
7458
|
+
'operationName',
|
|
7459
|
+
]);
|
|
7460
|
+
if (fromOperationName != null) {
|
|
7461
|
+
setValueByPath(toObject, ['operationName'], fromOperationName);
|
|
7462
|
+
}
|
|
7463
|
+
const fromResourceName = getValueByPath(fromObject, ['resourceName']);
|
|
7464
|
+
if (fromResourceName != null) {
|
|
7465
|
+
setValueByPath(toObject, ['_url', 'resourceName'], fromResourceName);
|
|
7466
|
+
}
|
|
7467
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
7468
|
+
if (fromConfig != null) {
|
|
7469
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
7470
|
+
}
|
|
7471
|
+
return toObject;
|
|
7472
|
+
}
|
|
7473
|
+
function videoFromMldev(apiClient, fromObject) {
|
|
7474
|
+
const toObject = {};
|
|
7475
|
+
const fromUri = getValueByPath(fromObject, ['video', 'uri']);
|
|
7476
|
+
if (fromUri != null) {
|
|
7477
|
+
setValueByPath(toObject, ['uri'], fromUri);
|
|
7478
|
+
}
|
|
7479
|
+
const fromVideoBytes = getValueByPath(fromObject, [
|
|
7480
|
+
'video',
|
|
7481
|
+
'encodedVideo',
|
|
7482
|
+
]);
|
|
7483
|
+
if (fromVideoBytes != null) {
|
|
7484
|
+
setValueByPath(toObject, ['videoBytes'], tBytes(apiClient, fromVideoBytes));
|
|
7485
|
+
}
|
|
7486
|
+
const fromMimeType = getValueByPath(fromObject, ['encoding']);
|
|
7487
|
+
if (fromMimeType != null) {
|
|
7488
|
+
setValueByPath(toObject, ['mimeType'], fromMimeType);
|
|
7489
|
+
}
|
|
7490
|
+
return toObject;
|
|
7491
|
+
}
|
|
7492
|
+
function generatedVideoFromMldev(apiClient, fromObject) {
|
|
7493
|
+
const toObject = {};
|
|
7494
|
+
const fromVideo = getValueByPath(fromObject, ['_self']);
|
|
7495
|
+
if (fromVideo != null) {
|
|
7496
|
+
setValueByPath(toObject, ['video'], videoFromMldev(apiClient, fromVideo));
|
|
7497
|
+
}
|
|
7498
|
+
return toObject;
|
|
7499
|
+
}
|
|
7500
|
+
function generateVideosResponseFromMldev(apiClient, fromObject) {
|
|
7501
|
+
const toObject = {};
|
|
7502
|
+
const fromGeneratedVideos = getValueByPath(fromObject, [
|
|
7503
|
+
'generatedSamples',
|
|
7504
|
+
]);
|
|
7505
|
+
if (fromGeneratedVideos != null) {
|
|
7506
|
+
if (Array.isArray(fromGeneratedVideos)) {
|
|
7507
|
+
setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos.map((item) => {
|
|
7508
|
+
return generatedVideoFromMldev(apiClient, item);
|
|
7509
|
+
}));
|
|
7510
|
+
}
|
|
7511
|
+
else {
|
|
7512
|
+
setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos);
|
|
7513
|
+
}
|
|
7514
|
+
}
|
|
7515
|
+
const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
|
|
7516
|
+
'raiMediaFilteredCount',
|
|
7517
|
+
]);
|
|
7518
|
+
if (fromRaiMediaFilteredCount != null) {
|
|
7519
|
+
setValueByPath(toObject, ['raiMediaFilteredCount'], fromRaiMediaFilteredCount);
|
|
7520
|
+
}
|
|
7521
|
+
const fromRaiMediaFilteredReasons = getValueByPath(fromObject, [
|
|
7522
|
+
'raiMediaFilteredReasons',
|
|
7523
|
+
]);
|
|
7524
|
+
if (fromRaiMediaFilteredReasons != null) {
|
|
7525
|
+
setValueByPath(toObject, ['raiMediaFilteredReasons'], fromRaiMediaFilteredReasons);
|
|
7526
|
+
}
|
|
7527
|
+
return toObject;
|
|
7528
|
+
}
|
|
7529
|
+
function generateVideosOperationFromMldev(apiClient, fromObject) {
|
|
7530
|
+
const toObject = {};
|
|
7531
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
7532
|
+
if (fromName != null) {
|
|
7533
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
7534
|
+
}
|
|
7535
|
+
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
7536
|
+
if (fromMetadata != null) {
|
|
7537
|
+
setValueByPath(toObject, ['metadata'], fromMetadata);
|
|
7538
|
+
}
|
|
7539
|
+
const fromDone = getValueByPath(fromObject, ['done']);
|
|
7540
|
+
if (fromDone != null) {
|
|
7541
|
+
setValueByPath(toObject, ['done'], fromDone);
|
|
7542
|
+
}
|
|
7543
|
+
const fromError = getValueByPath(fromObject, ['error']);
|
|
7544
|
+
if (fromError != null) {
|
|
7545
|
+
setValueByPath(toObject, ['error'], fromError);
|
|
7546
|
+
}
|
|
7547
|
+
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
7548
|
+
if (fromResponse != null) {
|
|
7549
|
+
setValueByPath(toObject, ['response'], fromResponse);
|
|
7550
|
+
}
|
|
7551
|
+
const fromResult = getValueByPath(fromObject, [
|
|
7552
|
+
'response',
|
|
7553
|
+
'generateVideoResponse',
|
|
7554
|
+
]);
|
|
7555
|
+
if (fromResult != null) {
|
|
7556
|
+
setValueByPath(toObject, ['result'], generateVideosResponseFromMldev(apiClient, fromResult));
|
|
7557
|
+
}
|
|
7558
|
+
return toObject;
|
|
7559
|
+
}
|
|
7560
|
+
function videoFromVertex(apiClient, fromObject) {
|
|
7561
|
+
const toObject = {};
|
|
7562
|
+
const fromUri = getValueByPath(fromObject, ['gcsUri']);
|
|
7563
|
+
if (fromUri != null) {
|
|
7564
|
+
setValueByPath(toObject, ['uri'], fromUri);
|
|
7565
|
+
}
|
|
7566
|
+
const fromVideoBytes = getValueByPath(fromObject, [
|
|
7567
|
+
'bytesBase64Encoded',
|
|
7568
|
+
]);
|
|
7569
|
+
if (fromVideoBytes != null) {
|
|
7570
|
+
setValueByPath(toObject, ['videoBytes'], tBytes(apiClient, fromVideoBytes));
|
|
7571
|
+
}
|
|
7572
|
+
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
7573
|
+
if (fromMimeType != null) {
|
|
7574
|
+
setValueByPath(toObject, ['mimeType'], fromMimeType);
|
|
7575
|
+
}
|
|
7576
|
+
return toObject;
|
|
7577
|
+
}
|
|
7578
|
+
function generatedVideoFromVertex(apiClient, fromObject) {
|
|
7579
|
+
const toObject = {};
|
|
7580
|
+
const fromVideo = getValueByPath(fromObject, ['_self']);
|
|
7581
|
+
if (fromVideo != null) {
|
|
7582
|
+
setValueByPath(toObject, ['video'], videoFromVertex(apiClient, fromVideo));
|
|
7583
|
+
}
|
|
7584
|
+
return toObject;
|
|
7585
|
+
}
|
|
7586
|
+
function generateVideosResponseFromVertex(apiClient, fromObject) {
|
|
7587
|
+
const toObject = {};
|
|
7588
|
+
const fromGeneratedVideos = getValueByPath(fromObject, ['videos']);
|
|
7589
|
+
if (fromGeneratedVideos != null) {
|
|
7590
|
+
if (Array.isArray(fromGeneratedVideos)) {
|
|
7591
|
+
setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos.map((item) => {
|
|
7592
|
+
return generatedVideoFromVertex(apiClient, item);
|
|
7593
|
+
}));
|
|
7594
|
+
}
|
|
7595
|
+
else {
|
|
7596
|
+
setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos);
|
|
7597
|
+
}
|
|
7598
|
+
}
|
|
7599
|
+
const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
|
|
7600
|
+
'raiMediaFilteredCount',
|
|
7601
|
+
]);
|
|
7602
|
+
if (fromRaiMediaFilteredCount != null) {
|
|
7603
|
+
setValueByPath(toObject, ['raiMediaFilteredCount'], fromRaiMediaFilteredCount);
|
|
7604
|
+
}
|
|
7605
|
+
const fromRaiMediaFilteredReasons = getValueByPath(fromObject, [
|
|
7606
|
+
'raiMediaFilteredReasons',
|
|
7607
|
+
]);
|
|
7608
|
+
if (fromRaiMediaFilteredReasons != null) {
|
|
7609
|
+
setValueByPath(toObject, ['raiMediaFilteredReasons'], fromRaiMediaFilteredReasons);
|
|
7610
|
+
}
|
|
7611
|
+
return toObject;
|
|
7612
|
+
}
|
|
7613
|
+
function generateVideosOperationFromVertex(apiClient, fromObject) {
|
|
7614
|
+
const toObject = {};
|
|
7615
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
7616
|
+
if (fromName != null) {
|
|
7617
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
7618
|
+
}
|
|
7619
|
+
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
7620
|
+
if (fromMetadata != null) {
|
|
7621
|
+
setValueByPath(toObject, ['metadata'], fromMetadata);
|
|
7622
|
+
}
|
|
7623
|
+
const fromDone = getValueByPath(fromObject, ['done']);
|
|
7624
|
+
if (fromDone != null) {
|
|
7625
|
+
setValueByPath(toObject, ['done'], fromDone);
|
|
7626
|
+
}
|
|
7627
|
+
const fromError = getValueByPath(fromObject, ['error']);
|
|
7628
|
+
if (fromError != null) {
|
|
7629
|
+
setValueByPath(toObject, ['error'], fromError);
|
|
7630
|
+
}
|
|
7631
|
+
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
7632
|
+
if (fromResponse != null) {
|
|
7633
|
+
setValueByPath(toObject, ['response'], fromResponse);
|
|
7634
|
+
}
|
|
7635
|
+
const fromResult = getValueByPath(fromObject, ['response']);
|
|
7636
|
+
if (fromResult != null) {
|
|
7637
|
+
setValueByPath(toObject, ['result'], generateVideosResponseFromVertex(apiClient, fromResult));
|
|
7638
|
+
}
|
|
7639
|
+
return toObject;
|
|
7640
|
+
}
|
|
7641
|
+
|
|
7642
|
+
/**
|
|
7643
|
+
* @license
|
|
7644
|
+
* Copyright 2025 Google LLC
|
|
7645
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
7646
|
+
*/
|
|
7647
|
+
class Operations extends BaseModule {
|
|
7648
|
+
constructor(apiClient) {
|
|
7649
|
+
super();
|
|
7650
|
+
this.apiClient = apiClient;
|
|
7651
|
+
}
|
|
7652
|
+
/**
|
|
7653
|
+
* Gets the status of a long-running operation.
|
|
7654
|
+
*
|
|
7655
|
+
* @param operation The Operation object returned by a previous API call.
|
|
7656
|
+
* @return The updated Operation object, with the latest status or result.
|
|
7657
|
+
*/
|
|
7658
|
+
async get(parameters) {
|
|
7659
|
+
const operation = parameters.operation;
|
|
7660
|
+
const config = parameters.config;
|
|
7661
|
+
if (operation.name === undefined || operation.name === '') {
|
|
7662
|
+
throw new Error('Operation name is required.');
|
|
7663
|
+
}
|
|
7664
|
+
if (this.apiClient.isVertexAI()) {
|
|
7665
|
+
const resourceName = operation.name.split('/operations/')[0];
|
|
7666
|
+
var httpOptions = undefined;
|
|
7667
|
+
if (config && 'httpOptions' in config) {
|
|
7668
|
+
httpOptions = config.httpOptions;
|
|
7669
|
+
}
|
|
7670
|
+
return this.fetchPredictVideosOperationInternal({
|
|
7671
|
+
operationName: operation.name,
|
|
7672
|
+
resourceName: resourceName,
|
|
7673
|
+
config: { httpOptions: httpOptions },
|
|
7674
|
+
});
|
|
7675
|
+
}
|
|
7676
|
+
else {
|
|
7677
|
+
return this.getVideosOperationInternal({
|
|
7678
|
+
operationName: operation.name,
|
|
7679
|
+
config: config,
|
|
7680
|
+
});
|
|
7681
|
+
}
|
|
7682
|
+
}
|
|
7683
|
+
async getVideosOperationInternal(params) {
|
|
7684
|
+
var _a, _b;
|
|
7685
|
+
let response;
|
|
7686
|
+
let path = '';
|
|
7687
|
+
let queryParams = {};
|
|
7688
|
+
if (this.apiClient.isVertexAI()) {
|
|
7689
|
+
const body = getOperationParametersToVertex(this.apiClient, params);
|
|
7690
|
+
path = formatMap('{operationName}', body['_url']);
|
|
7691
|
+
queryParams = body['_query'];
|
|
7692
|
+
delete body['config'];
|
|
7693
|
+
delete body['_url'];
|
|
7694
|
+
delete body['_query'];
|
|
7695
|
+
response = this.apiClient
|
|
7696
|
+
.request({
|
|
7697
|
+
path: path,
|
|
7698
|
+
queryParams: queryParams,
|
|
7699
|
+
body: JSON.stringify(body),
|
|
7700
|
+
httpMethod: 'GET',
|
|
7701
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
7702
|
+
})
|
|
7703
|
+
.then((httpResponse) => {
|
|
7704
|
+
return httpResponse.json();
|
|
7705
|
+
});
|
|
7706
|
+
return response.then((apiResponse) => {
|
|
7707
|
+
const resp = generateVideosOperationFromVertex(this.apiClient, apiResponse);
|
|
7708
|
+
return resp;
|
|
7709
|
+
});
|
|
7710
|
+
}
|
|
7711
|
+
else {
|
|
7712
|
+
const body = getOperationParametersToMldev(this.apiClient, params);
|
|
7713
|
+
path = formatMap('{operationName}', body['_url']);
|
|
7714
|
+
queryParams = body['_query'];
|
|
7715
|
+
delete body['config'];
|
|
7716
|
+
delete body['_url'];
|
|
7717
|
+
delete body['_query'];
|
|
7718
|
+
response = this.apiClient
|
|
7719
|
+
.request({
|
|
7720
|
+
path: path,
|
|
7721
|
+
queryParams: queryParams,
|
|
7722
|
+
body: JSON.stringify(body),
|
|
7723
|
+
httpMethod: 'GET',
|
|
7724
|
+
httpOptions: (_b = params.config) === null || _b === void 0 ? void 0 : _b.httpOptions,
|
|
7725
|
+
})
|
|
7726
|
+
.then((httpResponse) => {
|
|
7727
|
+
return httpResponse.json();
|
|
7728
|
+
});
|
|
7729
|
+
return response.then((apiResponse) => {
|
|
7730
|
+
const resp = generateVideosOperationFromMldev(this.apiClient, apiResponse);
|
|
7731
|
+
return resp;
|
|
7732
|
+
});
|
|
7733
|
+
}
|
|
7734
|
+
}
|
|
7735
|
+
async fetchPredictVideosOperationInternal(params) {
|
|
7736
|
+
var _a;
|
|
7737
|
+
let response;
|
|
7738
|
+
let path = '';
|
|
7739
|
+
let queryParams = {};
|
|
7740
|
+
if (this.apiClient.isVertexAI()) {
|
|
7741
|
+
const body = fetchPredictOperationParametersToVertex(this.apiClient, params);
|
|
7742
|
+
path = formatMap('{resourceName}:fetchPredictOperation', body['_url']);
|
|
7743
|
+
queryParams = body['_query'];
|
|
7744
|
+
delete body['config'];
|
|
7745
|
+
delete body['_url'];
|
|
7746
|
+
delete body['_query'];
|
|
7747
|
+
response = this.apiClient
|
|
7748
|
+
.request({
|
|
7749
|
+
path: path,
|
|
7750
|
+
queryParams: queryParams,
|
|
7751
|
+
body: JSON.stringify(body),
|
|
7752
|
+
httpMethod: 'POST',
|
|
7753
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
7754
|
+
})
|
|
7755
|
+
.then((httpResponse) => {
|
|
7756
|
+
return httpResponse.json();
|
|
7757
|
+
});
|
|
7758
|
+
return response.then((apiResponse) => {
|
|
7759
|
+
const resp = generateVideosOperationFromVertex(this.apiClient, apiResponse);
|
|
7760
|
+
return resp;
|
|
7761
|
+
});
|
|
7762
|
+
}
|
|
7763
|
+
else {
|
|
7764
|
+
throw new Error('This method is only supported by the Vertex AI.');
|
|
7765
|
+
}
|
|
7766
|
+
}
|
|
6978
7767
|
}
|
|
6979
7768
|
|
|
6980
7769
|
/**
|
|
@@ -7057,6 +7846,7 @@ class GoogleGenAI {
|
|
|
7057
7846
|
this.chats = new Chats(this.models, this.apiClient);
|
|
7058
7847
|
this.caches = new Caches(this.apiClient);
|
|
7059
7848
|
this.files = new Files(this.apiClient);
|
|
7849
|
+
this.operations = new Operations(this.apiClient);
|
|
7060
7850
|
}
|
|
7061
7851
|
}
|
|
7062
7852
|
|
|
@@ -7069,11 +7859,13 @@ exports.CreateFileResponse = CreateFileResponse;
|
|
|
7069
7859
|
exports.DeleteCachedContentResponse = DeleteCachedContentResponse;
|
|
7070
7860
|
exports.DeleteFileResponse = DeleteFileResponse;
|
|
7071
7861
|
exports.EmbedContentResponse = EmbedContentResponse;
|
|
7862
|
+
exports.Files = Files;
|
|
7072
7863
|
exports.FunctionResponse = FunctionResponse;
|
|
7073
7864
|
exports.GenerateContentResponse = GenerateContentResponse;
|
|
7074
7865
|
exports.GenerateContentResponsePromptFeedback = GenerateContentResponsePromptFeedback;
|
|
7075
7866
|
exports.GenerateContentResponseUsageMetadata = GenerateContentResponseUsageMetadata;
|
|
7076
7867
|
exports.GenerateImagesResponse = GenerateImagesResponse;
|
|
7868
|
+
exports.GenerateVideosResponse = GenerateVideosResponse;
|
|
7077
7869
|
exports.GoogleGenAI = GoogleGenAI;
|
|
7078
7870
|
exports.HttpResponse = HttpResponse;
|
|
7079
7871
|
exports.ListCachedContentsResponse = ListCachedContentsResponse;
|
|
@@ -7082,6 +7874,8 @@ exports.Live = Live;
|
|
|
7082
7874
|
exports.LiveClientToolResponse = LiveClientToolResponse;
|
|
7083
7875
|
exports.LiveSendToolResponseParameters = LiveSendToolResponseParameters;
|
|
7084
7876
|
exports.Models = Models;
|
|
7877
|
+
exports.Operations = Operations;
|
|
7878
|
+
exports.Pager = Pager;
|
|
7085
7879
|
exports.ReplayResponse = ReplayResponse;
|
|
7086
7880
|
exports.Session = Session;
|
|
7087
7881
|
exports.createModelContent = createModelContent;
|