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