@google/genai 1.10.0 → 1.11.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 +95 -18
- package/dist/index.cjs +327 -228
- package/dist/index.mjs +327 -229
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.cjs +335 -236
- package/dist/node/index.mjs +335 -237
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/node.d.ts +95 -18
- package/dist/web/index.mjs +335 -237
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +95 -18
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -162,6 +162,20 @@ function getValueByPath(data, keys) {
|
|
|
162
162
|
* Copyright 2025 Google LLC
|
|
163
163
|
* SPDX-License-Identifier: Apache-2.0
|
|
164
164
|
*/
|
|
165
|
+
function tBytes$1(fromBytes) {
|
|
166
|
+
if (typeof fromBytes !== 'string') {
|
|
167
|
+
throw new Error('fromImageBytes must be a string');
|
|
168
|
+
}
|
|
169
|
+
// TODO(b/389133914): Remove dummy bytes converter.
|
|
170
|
+
return fromBytes;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* @license
|
|
175
|
+
* Copyright 2025 Google LLC
|
|
176
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
177
|
+
*/
|
|
178
|
+
// Code generated by the Google Gen AI SDK generator DO NOT EDIT.
|
|
165
179
|
/** Required. Outcome of the code execution. */
|
|
166
180
|
exports.Outcome = void 0;
|
|
167
181
|
(function (Outcome) {
|
|
@@ -1655,6 +1669,65 @@ class LiveServerMessage {
|
|
|
1655
1669
|
return data.length > 0 ? btoa(data) : undefined;
|
|
1656
1670
|
}
|
|
1657
1671
|
}
|
|
1672
|
+
/** A video generation long-running operation. */
|
|
1673
|
+
class GenerateVideosOperation {
|
|
1674
|
+
/**
|
|
1675
|
+
* Instantiates an Operation of the same type as the one being called with the fields set from the API response.
|
|
1676
|
+
* @internal
|
|
1677
|
+
*/
|
|
1678
|
+
_fromAPIResponse({ apiResponse, isVertexAI, }) {
|
|
1679
|
+
const operation = new GenerateVideosOperation();
|
|
1680
|
+
operation.name = apiResponse['name'];
|
|
1681
|
+
operation.metadata = apiResponse['metadata'];
|
|
1682
|
+
operation.done = apiResponse['done'];
|
|
1683
|
+
operation.error = apiResponse['error'];
|
|
1684
|
+
if (isVertexAI) {
|
|
1685
|
+
const response = apiResponse['response'];
|
|
1686
|
+
if (response) {
|
|
1687
|
+
const operationResponse = new GenerateVideosResponse();
|
|
1688
|
+
const responseVideos = response['videos'];
|
|
1689
|
+
operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
|
|
1690
|
+
return {
|
|
1691
|
+
video: {
|
|
1692
|
+
uri: generatedVideo['gcsUri'],
|
|
1693
|
+
videoBytes: generatedVideo['bytesBase64Encoded']
|
|
1694
|
+
? tBytes$1(generatedVideo['bytesBase64Encoded'])
|
|
1695
|
+
: undefined,
|
|
1696
|
+
mimeType: generatedVideo['mimeType'],
|
|
1697
|
+
},
|
|
1698
|
+
};
|
|
1699
|
+
});
|
|
1700
|
+
operationResponse.raiMediaFilteredCount = response['raiMediaFilteredCount'];
|
|
1701
|
+
operationResponse.raiMediaFilteredReasons = response['raiMediaFilteredReasons'];
|
|
1702
|
+
operation.response = operationResponse;
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1705
|
+
else {
|
|
1706
|
+
const response = apiResponse['response'];
|
|
1707
|
+
if (response) {
|
|
1708
|
+
const operationResponse = new GenerateVideosResponse();
|
|
1709
|
+
const generatedVideoResponse = response['generateVideoResponse'];
|
|
1710
|
+
const responseVideos = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['generatedSamples'];
|
|
1711
|
+
operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
|
|
1712
|
+
const video = generatedVideo['video'];
|
|
1713
|
+
return {
|
|
1714
|
+
video: {
|
|
1715
|
+
uri: video === null || video === void 0 ? void 0 : video['uri'],
|
|
1716
|
+
videoBytes: (video === null || video === void 0 ? void 0 : video['encodedVideo'])
|
|
1717
|
+
? tBytes$1(video === null || video === void 0 ? void 0 : video['encodedVideo'])
|
|
1718
|
+
: undefined,
|
|
1719
|
+
mimeType: generatedVideo['encoding'],
|
|
1720
|
+
},
|
|
1721
|
+
};
|
|
1722
|
+
});
|
|
1723
|
+
operationResponse.raiMediaFilteredCount = response['raiMediaFilteredCount'];
|
|
1724
|
+
operationResponse.raiMediaFilteredReasons = response['raiMediaFilteredReasons'];
|
|
1725
|
+
operation.response = operationResponse;
|
|
1726
|
+
}
|
|
1727
|
+
}
|
|
1728
|
+
return operation;
|
|
1729
|
+
}
|
|
1730
|
+
}
|
|
1658
1731
|
/** Client generated response to a `ToolCall` received from the server.
|
|
1659
1732
|
|
|
1660
1733
|
Individual `FunctionResponse` objects are matched to the respective
|
|
@@ -2216,11 +2289,7 @@ function tTuningJobStatus(status) {
|
|
|
2216
2289
|
}
|
|
2217
2290
|
}
|
|
2218
2291
|
function tBytes(fromImageBytes) {
|
|
2219
|
-
|
|
2220
|
-
throw new Error('fromImageBytes must be a string');
|
|
2221
|
-
}
|
|
2222
|
-
// TODO(b/389133914): Remove dummy bytes converter.
|
|
2223
|
-
return fromImageBytes;
|
|
2292
|
+
return tBytes$1(fromImageBytes);
|
|
2224
2293
|
}
|
|
2225
2294
|
function _isFile(origin) {
|
|
2226
2295
|
return (origin !== null &&
|
|
@@ -3708,6 +3777,12 @@ function batchJobFromMldev(fromObject) {
|
|
|
3708
3777
|
}
|
|
3709
3778
|
function listBatchJobsResponseFromMldev(fromObject) {
|
|
3710
3779
|
const toObject = {};
|
|
3780
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
3781
|
+
'sdkHttpResponse',
|
|
3782
|
+
]);
|
|
3783
|
+
if (fromSdkHttpResponse != null) {
|
|
3784
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
3785
|
+
}
|
|
3711
3786
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
3712
3787
|
'nextPageToken',
|
|
3713
3788
|
]);
|
|
@@ -3849,6 +3924,12 @@ function batchJobFromVertex(fromObject) {
|
|
|
3849
3924
|
}
|
|
3850
3925
|
function listBatchJobsResponseFromVertex(fromObject) {
|
|
3851
3926
|
const toObject = {};
|
|
3927
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
3928
|
+
'sdkHttpResponse',
|
|
3929
|
+
]);
|
|
3930
|
+
if (fromSdkHttpResponse != null) {
|
|
3931
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
3932
|
+
}
|
|
3852
3933
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
3853
3934
|
'nextPageToken',
|
|
3854
3935
|
]);
|
|
@@ -3891,9 +3972,6 @@ function deleteResourceJobFromVertex(fromObject) {
|
|
|
3891
3972
|
* Copyright 2025 Google LLC
|
|
3892
3973
|
* SPDX-License-Identifier: Apache-2.0
|
|
3893
3974
|
*/
|
|
3894
|
-
/**
|
|
3895
|
-
* Pagers for the GenAI List APIs.
|
|
3896
|
-
*/
|
|
3897
3975
|
exports.PagedItem = void 0;
|
|
3898
3976
|
(function (PagedItem) {
|
|
3899
3977
|
PagedItem["PAGED_ITEM_BATCH_JOBS"] = "batchJobs";
|
|
@@ -3916,9 +3994,10 @@ class Pager {
|
|
|
3916
3994
|
var _a, _b;
|
|
3917
3995
|
this.nameInternal = name;
|
|
3918
3996
|
this.pageInternal = response[this.nameInternal] || [];
|
|
3997
|
+
this.sdkHttpResponseInternal = response === null || response === void 0 ? void 0 : response.sdkHttpResponse;
|
|
3919
3998
|
this.idxInternal = 0;
|
|
3920
3999
|
let requestParams = { config: {} };
|
|
3921
|
-
if (!params) {
|
|
4000
|
+
if (!params || Object.keys(params).length === 0) {
|
|
3922
4001
|
requestParams = { config: {} };
|
|
3923
4002
|
}
|
|
3924
4003
|
else if (typeof params === 'object') {
|
|
@@ -3962,6 +4041,12 @@ class Pager {
|
|
|
3962
4041
|
get pageSize() {
|
|
3963
4042
|
return this.pageInternalSize;
|
|
3964
4043
|
}
|
|
4044
|
+
/**
|
|
4045
|
+
* Returns the headers of the API response.
|
|
4046
|
+
*/
|
|
4047
|
+
get sdkHttpResponse() {
|
|
4048
|
+
return this.sdkHttpResponseInternal;
|
|
4049
|
+
}
|
|
3965
4050
|
/**
|
|
3966
4051
|
* Returns the parameters when making the API request for the next page.
|
|
3967
4052
|
*
|
|
@@ -4331,7 +4416,13 @@ class Batches extends BaseModule {
|
|
|
4331
4416
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
4332
4417
|
})
|
|
4333
4418
|
.then((httpResponse) => {
|
|
4334
|
-
return httpResponse.json()
|
|
4419
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
4420
|
+
const response = jsonResponse;
|
|
4421
|
+
response.sdkHttpResponse = {
|
|
4422
|
+
headers: httpResponse.headers,
|
|
4423
|
+
};
|
|
4424
|
+
return response;
|
|
4425
|
+
});
|
|
4335
4426
|
});
|
|
4336
4427
|
return response.then((apiResponse) => {
|
|
4337
4428
|
const resp = listBatchJobsResponseFromVertex(apiResponse);
|
|
@@ -4357,7 +4448,13 @@ class Batches extends BaseModule {
|
|
|
4357
4448
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
4358
4449
|
})
|
|
4359
4450
|
.then((httpResponse) => {
|
|
4360
|
-
return httpResponse.json()
|
|
4451
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
4452
|
+
const response = jsonResponse;
|
|
4453
|
+
response.sdkHttpResponse = {
|
|
4454
|
+
headers: httpResponse.headers,
|
|
4455
|
+
};
|
|
4456
|
+
return response;
|
|
4457
|
+
});
|
|
4361
4458
|
});
|
|
4362
4459
|
return response.then((apiResponse) => {
|
|
4363
4460
|
const resp = listBatchJobsResponseFromMldev(apiResponse);
|
|
@@ -5410,6 +5507,12 @@ function deleteCachedContentResponseFromMldev() {
|
|
|
5410
5507
|
}
|
|
5411
5508
|
function listCachedContentsResponseFromMldev(fromObject) {
|
|
5412
5509
|
const toObject = {};
|
|
5510
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
5511
|
+
'sdkHttpResponse',
|
|
5512
|
+
]);
|
|
5513
|
+
if (fromSdkHttpResponse != null) {
|
|
5514
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
5515
|
+
}
|
|
5413
5516
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
5414
5517
|
'nextPageToken',
|
|
5415
5518
|
]);
|
|
@@ -5470,6 +5573,12 @@ function deleteCachedContentResponseFromVertex() {
|
|
|
5470
5573
|
}
|
|
5471
5574
|
function listCachedContentsResponseFromVertex(fromObject) {
|
|
5472
5575
|
const toObject = {};
|
|
5576
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
5577
|
+
'sdkHttpResponse',
|
|
5578
|
+
]);
|
|
5579
|
+
if (fromSdkHttpResponse != null) {
|
|
5580
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
5581
|
+
}
|
|
5473
5582
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
5474
5583
|
'nextPageToken',
|
|
5475
5584
|
]);
|
|
@@ -5822,7 +5931,13 @@ class Caches extends BaseModule {
|
|
|
5822
5931
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
5823
5932
|
})
|
|
5824
5933
|
.then((httpResponse) => {
|
|
5825
|
-
return httpResponse.json()
|
|
5934
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
5935
|
+
const response = jsonResponse;
|
|
5936
|
+
response.sdkHttpResponse = {
|
|
5937
|
+
headers: httpResponse.headers,
|
|
5938
|
+
};
|
|
5939
|
+
return response;
|
|
5940
|
+
});
|
|
5826
5941
|
});
|
|
5827
5942
|
return response.then((apiResponse) => {
|
|
5828
5943
|
const resp = listCachedContentsResponseFromVertex(apiResponse);
|
|
@@ -5848,7 +5963,13 @@ class Caches extends BaseModule {
|
|
|
5848
5963
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
5849
5964
|
})
|
|
5850
5965
|
.then((httpResponse) => {
|
|
5851
|
-
return httpResponse.json()
|
|
5966
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
5967
|
+
const response = jsonResponse;
|
|
5968
|
+
response.sdkHttpResponse = {
|
|
5969
|
+
headers: httpResponse.headers,
|
|
5970
|
+
};
|
|
5971
|
+
return response;
|
|
5972
|
+
});
|
|
5852
5973
|
});
|
|
5853
5974
|
return response.then((apiResponse) => {
|
|
5854
5975
|
const resp = listCachedContentsResponseFromMldev(apiResponse);
|
|
@@ -6271,7 +6392,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
6271
6392
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
6272
6393
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
6273
6394
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
6274
|
-
const SDK_VERSION = '1.
|
|
6395
|
+
const SDK_VERSION = '1.11.0'; // x-release-please-version
|
|
6275
6396
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
6276
6397
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
6277
6398
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -7183,6 +7304,12 @@ function fileFromMldev(fromObject) {
|
|
|
7183
7304
|
}
|
|
7184
7305
|
function listFilesResponseFromMldev(fromObject) {
|
|
7185
7306
|
const toObject = {};
|
|
7307
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
7308
|
+
'sdkHttpResponse',
|
|
7309
|
+
]);
|
|
7310
|
+
if (fromSdkHttpResponse != null) {
|
|
7311
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
7312
|
+
}
|
|
7186
7313
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
7187
7314
|
'nextPageToken',
|
|
7188
7315
|
]);
|
|
@@ -7344,7 +7471,13 @@ class Files extends BaseModule {
|
|
|
7344
7471
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
7345
7472
|
})
|
|
7346
7473
|
.then((httpResponse) => {
|
|
7347
|
-
return httpResponse.json()
|
|
7474
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
7475
|
+
const response = jsonResponse;
|
|
7476
|
+
response.sdkHttpResponse = {
|
|
7477
|
+
headers: httpResponse.headers,
|
|
7478
|
+
};
|
|
7479
|
+
return response;
|
|
7480
|
+
});
|
|
7348
7481
|
});
|
|
7349
7482
|
return response.then((apiResponse) => {
|
|
7350
7483
|
const resp = listFilesResponseFromMldev(apiResponse);
|
|
@@ -10570,6 +10703,9 @@ function generateImagesConfigToMldev(fromObject, parentObject) {
|
|
|
10570
10703
|
if (getValueByPath(fromObject, ['addWatermark']) !== undefined) {
|
|
10571
10704
|
throw new Error('addWatermark parameter is not supported in Gemini API.');
|
|
10572
10705
|
}
|
|
10706
|
+
if (getValueByPath(fromObject, ['imageSize']) !== undefined) {
|
|
10707
|
+
throw new Error('imageSize parameter is not supported in Gemini API.');
|
|
10708
|
+
}
|
|
10573
10709
|
if (getValueByPath(fromObject, ['enhancePrompt']) !== undefined) {
|
|
10574
10710
|
throw new Error('enhancePrompt parameter is not supported in Gemini API.');
|
|
10575
10711
|
}
|
|
@@ -11646,6 +11782,10 @@ function generateImagesConfigToVertex(fromObject, parentObject) {
|
|
|
11646
11782
|
if (parentObject !== undefined && fromAddWatermark != null) {
|
|
11647
11783
|
setValueByPath(parentObject, ['parameters', 'addWatermark'], fromAddWatermark);
|
|
11648
11784
|
}
|
|
11785
|
+
const fromImageSize = getValueByPath(fromObject, ['imageSize']);
|
|
11786
|
+
if (parentObject !== undefined && fromImageSize != null) {
|
|
11787
|
+
setValueByPath(parentObject, ['parameters', 'sampleImageSize'], fromImageSize);
|
|
11788
|
+
}
|
|
11649
11789
|
const fromEnhancePrompt = getValueByPath(fromObject, [
|
|
11650
11790
|
'enhancePrompt',
|
|
11651
11791
|
]);
|
|
@@ -12636,6 +12776,12 @@ function modelFromMldev(fromObject) {
|
|
|
12636
12776
|
}
|
|
12637
12777
|
function listModelsResponseFromMldev(fromObject) {
|
|
12638
12778
|
const toObject = {};
|
|
12779
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
12780
|
+
'sdkHttpResponse',
|
|
12781
|
+
]);
|
|
12782
|
+
if (fromSdkHttpResponse != null) {
|
|
12783
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
12784
|
+
}
|
|
12639
12785
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
12640
12786
|
'nextPageToken',
|
|
12641
12787
|
]);
|
|
@@ -12672,7 +12818,7 @@ function countTokensResponseFromMldev(fromObject) {
|
|
|
12672
12818
|
}
|
|
12673
12819
|
return toObject;
|
|
12674
12820
|
}
|
|
12675
|
-
function videoFromMldev
|
|
12821
|
+
function videoFromMldev(fromObject) {
|
|
12676
12822
|
const toObject = {};
|
|
12677
12823
|
const fromUri = getValueByPath(fromObject, ['video', 'uri']);
|
|
12678
12824
|
if (fromUri != null) {
|
|
@@ -12691,15 +12837,15 @@ function videoFromMldev$1(fromObject) {
|
|
|
12691
12837
|
}
|
|
12692
12838
|
return toObject;
|
|
12693
12839
|
}
|
|
12694
|
-
function generatedVideoFromMldev
|
|
12840
|
+
function generatedVideoFromMldev(fromObject) {
|
|
12695
12841
|
const toObject = {};
|
|
12696
12842
|
const fromVideo = getValueByPath(fromObject, ['_self']);
|
|
12697
12843
|
if (fromVideo != null) {
|
|
12698
|
-
setValueByPath(toObject, ['video'], videoFromMldev
|
|
12844
|
+
setValueByPath(toObject, ['video'], videoFromMldev(fromVideo));
|
|
12699
12845
|
}
|
|
12700
12846
|
return toObject;
|
|
12701
12847
|
}
|
|
12702
|
-
function generateVideosResponseFromMldev
|
|
12848
|
+
function generateVideosResponseFromMldev(fromObject) {
|
|
12703
12849
|
const toObject = {};
|
|
12704
12850
|
const fromGeneratedVideos = getValueByPath(fromObject, [
|
|
12705
12851
|
'generatedSamples',
|
|
@@ -12708,7 +12854,7 @@ function generateVideosResponseFromMldev$1(fromObject) {
|
|
|
12708
12854
|
let transformedList = fromGeneratedVideos;
|
|
12709
12855
|
if (Array.isArray(transformedList)) {
|
|
12710
12856
|
transformedList = transformedList.map((item) => {
|
|
12711
|
-
return generatedVideoFromMldev
|
|
12857
|
+
return generatedVideoFromMldev(item);
|
|
12712
12858
|
});
|
|
12713
12859
|
}
|
|
12714
12860
|
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
@@ -12727,7 +12873,7 @@ function generateVideosResponseFromMldev$1(fromObject) {
|
|
|
12727
12873
|
}
|
|
12728
12874
|
return toObject;
|
|
12729
12875
|
}
|
|
12730
|
-
function generateVideosOperationFromMldev
|
|
12876
|
+
function generateVideosOperationFromMldev(fromObject) {
|
|
12731
12877
|
const toObject = {};
|
|
12732
12878
|
const fromName = getValueByPath(fromObject, ['name']);
|
|
12733
12879
|
if (fromName != null) {
|
|
@@ -12750,7 +12896,7 @@ function generateVideosOperationFromMldev$1(fromObject) {
|
|
|
12750
12896
|
'generateVideoResponse',
|
|
12751
12897
|
]);
|
|
12752
12898
|
if (fromResponse != null) {
|
|
12753
|
-
setValueByPath(toObject, ['response'], generateVideosResponseFromMldev
|
|
12899
|
+
setValueByPath(toObject, ['response'], generateVideosResponseFromMldev(fromResponse));
|
|
12754
12900
|
}
|
|
12755
12901
|
return toObject;
|
|
12756
12902
|
}
|
|
@@ -13286,6 +13432,12 @@ function modelFromVertex(fromObject) {
|
|
|
13286
13432
|
}
|
|
13287
13433
|
function listModelsResponseFromVertex(fromObject) {
|
|
13288
13434
|
const toObject = {};
|
|
13435
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
13436
|
+
'sdkHttpResponse',
|
|
13437
|
+
]);
|
|
13438
|
+
if (fromSdkHttpResponse != null) {
|
|
13439
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
13440
|
+
}
|
|
13289
13441
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
13290
13442
|
'nextPageToken',
|
|
13291
13443
|
]);
|
|
@@ -13324,7 +13476,7 @@ function computeTokensResponseFromVertex(fromObject) {
|
|
|
13324
13476
|
}
|
|
13325
13477
|
return toObject;
|
|
13326
13478
|
}
|
|
13327
|
-
function videoFromVertex
|
|
13479
|
+
function videoFromVertex(fromObject) {
|
|
13328
13480
|
const toObject = {};
|
|
13329
13481
|
const fromUri = getValueByPath(fromObject, ['gcsUri']);
|
|
13330
13482
|
if (fromUri != null) {
|
|
@@ -13342,22 +13494,22 @@ function videoFromVertex$1(fromObject) {
|
|
|
13342
13494
|
}
|
|
13343
13495
|
return toObject;
|
|
13344
13496
|
}
|
|
13345
|
-
function generatedVideoFromVertex
|
|
13497
|
+
function generatedVideoFromVertex(fromObject) {
|
|
13346
13498
|
const toObject = {};
|
|
13347
13499
|
const fromVideo = getValueByPath(fromObject, ['_self']);
|
|
13348
13500
|
if (fromVideo != null) {
|
|
13349
|
-
setValueByPath(toObject, ['video'], videoFromVertex
|
|
13501
|
+
setValueByPath(toObject, ['video'], videoFromVertex(fromVideo));
|
|
13350
13502
|
}
|
|
13351
13503
|
return toObject;
|
|
13352
13504
|
}
|
|
13353
|
-
function generateVideosResponseFromVertex
|
|
13505
|
+
function generateVideosResponseFromVertex(fromObject) {
|
|
13354
13506
|
const toObject = {};
|
|
13355
13507
|
const fromGeneratedVideos = getValueByPath(fromObject, ['videos']);
|
|
13356
13508
|
if (fromGeneratedVideos != null) {
|
|
13357
13509
|
let transformedList = fromGeneratedVideos;
|
|
13358
13510
|
if (Array.isArray(transformedList)) {
|
|
13359
13511
|
transformedList = transformedList.map((item) => {
|
|
13360
|
-
return generatedVideoFromVertex
|
|
13512
|
+
return generatedVideoFromVertex(item);
|
|
13361
13513
|
});
|
|
13362
13514
|
}
|
|
13363
13515
|
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
@@ -13376,7 +13528,7 @@ function generateVideosResponseFromVertex$1(fromObject) {
|
|
|
13376
13528
|
}
|
|
13377
13529
|
return toObject;
|
|
13378
13530
|
}
|
|
13379
|
-
function generateVideosOperationFromVertex
|
|
13531
|
+
function generateVideosOperationFromVertex(fromObject) {
|
|
13380
13532
|
const toObject = {};
|
|
13381
13533
|
const fromName = getValueByPath(fromObject, ['name']);
|
|
13382
13534
|
if (fromName != null) {
|
|
@@ -13396,7 +13548,7 @@ function generateVideosOperationFromVertex$1(fromObject) {
|
|
|
13396
13548
|
}
|
|
13397
13549
|
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
13398
13550
|
if (fromResponse != null) {
|
|
13399
|
-
setValueByPath(toObject, ['response'], generateVideosResponseFromVertex
|
|
13551
|
+
setValueByPath(toObject, ['response'], generateVideosResponseFromVertex(fromResponse));
|
|
13400
13552
|
}
|
|
13401
13553
|
return toObject;
|
|
13402
13554
|
}
|
|
@@ -13429,18 +13581,6 @@ function setMcpUsageHeader(headers) {
|
|
|
13429
13581
|
const existingHeader = (_a = headers[GOOGLE_API_CLIENT_HEADER]) !== null && _a !== void 0 ? _a : '';
|
|
13430
13582
|
headers[GOOGLE_API_CLIENT_HEADER] = (existingHeader + ` ${MCP_LABEL}`).trimStart();
|
|
13431
13583
|
}
|
|
13432
|
-
// Checks whether the list of tools contains any MCP clients. Will return true
|
|
13433
|
-
// if there is at least one MCP client.
|
|
13434
|
-
function hasMcpClientTools(params) {
|
|
13435
|
-
var _a, _b, _c;
|
|
13436
|
-
return (_c = (_b = (_a = params.config) === null || _a === void 0 ? void 0 : _a.tools) === null || _b === void 0 ? void 0 : _b.some((tool) => isMcpCallableTool(tool))) !== null && _c !== void 0 ? _c : false;
|
|
13437
|
-
}
|
|
13438
|
-
// Checks whether the list of tools contains any non-MCP tools. Will return true
|
|
13439
|
-
// if there is at least one non-MCP tool.
|
|
13440
|
-
function hasNonMcpTools(params) {
|
|
13441
|
-
var _a, _b, _c;
|
|
13442
|
-
return ((_c = (_b = (_a = params.config) === null || _a === void 0 ? void 0 : _a.tools) === null || _b === void 0 ? void 0 : _b.some((tool) => !isMcpCallableTool(tool))) !== null && _c !== void 0 ? _c : false);
|
|
13443
|
-
}
|
|
13444
13584
|
// Returns true if the object is a MCP CallableTool, otherwise false.
|
|
13445
13585
|
function isMcpCallableTool(object) {
|
|
13446
13586
|
return (object !== null &&
|
|
@@ -14299,6 +14439,18 @@ function shouldDisableAfc(config) {
|
|
|
14299
14439
|
function isCallableTool(tool) {
|
|
14300
14440
|
return 'callTool' in tool && typeof tool.callTool === 'function';
|
|
14301
14441
|
}
|
|
14442
|
+
// Checks whether the list of tools contains any CallableTools. Will return true
|
|
14443
|
+
// if there is at least one CallableTool.
|
|
14444
|
+
function hasCallableTools(params) {
|
|
14445
|
+
var _a, _b, _c;
|
|
14446
|
+
return (_c = (_b = (_a = params.config) === null || _a === void 0 ? void 0 : _a.tools) === null || _b === void 0 ? void 0 : _b.some((tool) => isCallableTool(tool))) !== null && _c !== void 0 ? _c : false;
|
|
14447
|
+
}
|
|
14448
|
+
// Checks whether the list of tools contains any non-callable tools. Will return
|
|
14449
|
+
// true if there is at least one non-Callable tool.
|
|
14450
|
+
function hasNonCallableTools(params) {
|
|
14451
|
+
var _a, _b, _c;
|
|
14452
|
+
return (_c = (_b = (_a = params.config) === null || _a === void 0 ? void 0 : _a.tools) === null || _b === void 0 ? void 0 : _b.some((tool) => !isCallableTool(tool))) !== null && _c !== void 0 ? _c : false;
|
|
14453
|
+
}
|
|
14302
14454
|
/**
|
|
14303
14455
|
* Returns whether to append automatic function calling history to the
|
|
14304
14456
|
* response.
|
|
@@ -14357,12 +14509,12 @@ class Models extends BaseModule {
|
|
|
14357
14509
|
*/
|
|
14358
14510
|
this.generateContent = async (params) => {
|
|
14359
14511
|
var _a, _b, _c, _d, _e;
|
|
14360
|
-
const transformedParams = await this.
|
|
14512
|
+
const transformedParams = await this.processParamsMaybeAddMcpUsage(params);
|
|
14361
14513
|
this.maybeMoveToResponseJsonSchem(params);
|
|
14362
|
-
if (!
|
|
14514
|
+
if (!hasCallableTools(params) || shouldDisableAfc(params.config)) {
|
|
14363
14515
|
return await this.generateContentInternal(transformedParams);
|
|
14364
14516
|
}
|
|
14365
|
-
if (
|
|
14517
|
+
if (hasNonCallableTools(params)) {
|
|
14366
14518
|
throw new Error('Automatic function calling with CallableTools and Tools is not yet supported.');
|
|
14367
14519
|
}
|
|
14368
14520
|
let response;
|
|
@@ -14447,7 +14599,7 @@ class Models extends BaseModule {
|
|
|
14447
14599
|
this.generateContentStream = async (params) => {
|
|
14448
14600
|
this.maybeMoveToResponseJsonSchem(params);
|
|
14449
14601
|
if (shouldDisableAfc(params.config)) {
|
|
14450
|
-
const transformedParams = await this.
|
|
14602
|
+
const transformedParams = await this.processParamsMaybeAddMcpUsage(params);
|
|
14451
14603
|
return await this.generateContentStreamInternal(transformedParams);
|
|
14452
14604
|
}
|
|
14453
14605
|
else {
|
|
@@ -14596,6 +14748,32 @@ class Models extends BaseModule {
|
|
|
14596
14748
|
};
|
|
14597
14749
|
return await this.upscaleImageInternal(apiParams);
|
|
14598
14750
|
};
|
|
14751
|
+
/**
|
|
14752
|
+
* Generates videos based on a text description and configuration.
|
|
14753
|
+
*
|
|
14754
|
+
* @param params - The parameters for generating videos.
|
|
14755
|
+
* @return A Promise<GenerateVideosOperation> which allows you to track the progress and eventually retrieve the generated videos using the operations.get method.
|
|
14756
|
+
*
|
|
14757
|
+
* @example
|
|
14758
|
+
* ```ts
|
|
14759
|
+
* const operation = await ai.models.generateVideos({
|
|
14760
|
+
* model: 'veo-2.0-generate-001',
|
|
14761
|
+
* prompt: 'A neon hologram of a cat driving at top speed',
|
|
14762
|
+
* config: {
|
|
14763
|
+
* numberOfVideos: 1
|
|
14764
|
+
* });
|
|
14765
|
+
*
|
|
14766
|
+
* while (!operation.done) {
|
|
14767
|
+
* await new Promise(resolve => setTimeout(resolve, 10000));
|
|
14768
|
+
* operation = await ai.operations.getVideosOperation({operation: operation});
|
|
14769
|
+
* }
|
|
14770
|
+
*
|
|
14771
|
+
* console.log(operation.response?.generatedVideos?.[0]?.video?.uri);
|
|
14772
|
+
* ```
|
|
14773
|
+
*/
|
|
14774
|
+
this.generateVideos = async (params) => {
|
|
14775
|
+
return await this.generateVideosInternal(params);
|
|
14776
|
+
};
|
|
14599
14777
|
}
|
|
14600
14778
|
/**
|
|
14601
14779
|
* This logic is needed for GenerateContentConfig only.
|
|
@@ -14621,7 +14799,7 @@ class Models extends BaseModule {
|
|
|
14621
14799
|
* modify the original params. Also sets the MCP usage header if there are
|
|
14622
14800
|
* MCP tools in the parameters.
|
|
14623
14801
|
*/
|
|
14624
|
-
async
|
|
14802
|
+
async processParamsMaybeAddMcpUsage(params) {
|
|
14625
14803
|
var _a, _b, _c;
|
|
14626
14804
|
const tools = (_a = params.config) === null || _a === void 0 ? void 0 : _a.tools;
|
|
14627
14805
|
if (!tools) {
|
|
@@ -14688,7 +14866,7 @@ class Models extends BaseModule {
|
|
|
14688
14866
|
remoteCallCount++;
|
|
14689
14867
|
wereFunctionsCalled = false;
|
|
14690
14868
|
}
|
|
14691
|
-
const transformedParams = yield __await(models.
|
|
14869
|
+
const transformedParams = yield __await(models.processParamsMaybeAddMcpUsage(params));
|
|
14692
14870
|
const response = yield __await(models.generateContentStreamInternal(transformedParams));
|
|
14693
14871
|
const functionResponses = [];
|
|
14694
14872
|
const responseContents = [];
|
|
@@ -15226,7 +15404,13 @@ class Models extends BaseModule {
|
|
|
15226
15404
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
15227
15405
|
})
|
|
15228
15406
|
.then((httpResponse) => {
|
|
15229
|
-
return httpResponse.json()
|
|
15407
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
15408
|
+
const response = jsonResponse;
|
|
15409
|
+
response.sdkHttpResponse = {
|
|
15410
|
+
headers: httpResponse.headers,
|
|
15411
|
+
};
|
|
15412
|
+
return response;
|
|
15413
|
+
});
|
|
15230
15414
|
});
|
|
15231
15415
|
return response.then((apiResponse) => {
|
|
15232
15416
|
const resp = listModelsResponseFromVertex(apiResponse);
|
|
@@ -15252,7 +15436,13 @@ class Models extends BaseModule {
|
|
|
15252
15436
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
15253
15437
|
})
|
|
15254
15438
|
.then((httpResponse) => {
|
|
15255
|
-
return httpResponse.json()
|
|
15439
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
15440
|
+
const response = jsonResponse;
|
|
15441
|
+
response.sdkHttpResponse = {
|
|
15442
|
+
headers: httpResponse.headers,
|
|
15443
|
+
};
|
|
15444
|
+
return response;
|
|
15445
|
+
});
|
|
15256
15446
|
});
|
|
15257
15447
|
return response.then((apiResponse) => {
|
|
15258
15448
|
const resp = listModelsResponseFromMldev(apiResponse);
|
|
@@ -15552,7 +15742,7 @@ class Models extends BaseModule {
|
|
|
15552
15742
|
* console.log(operation.response?.generatedVideos?.[0]?.video?.uri);
|
|
15553
15743
|
* ```
|
|
15554
15744
|
*/
|
|
15555
|
-
async
|
|
15745
|
+
async generateVideosInternal(params) {
|
|
15556
15746
|
var _a, _b, _c, _d;
|
|
15557
15747
|
let response;
|
|
15558
15748
|
let path = '';
|
|
@@ -15577,8 +15767,10 @@ class Models extends BaseModule {
|
|
|
15577
15767
|
return httpResponse.json();
|
|
15578
15768
|
});
|
|
15579
15769
|
return response.then((apiResponse) => {
|
|
15580
|
-
const resp = generateVideosOperationFromVertex
|
|
15581
|
-
|
|
15770
|
+
const resp = generateVideosOperationFromVertex(apiResponse);
|
|
15771
|
+
const typedResp = new GenerateVideosOperation();
|
|
15772
|
+
Object.assign(typedResp, resp);
|
|
15773
|
+
return typedResp;
|
|
15582
15774
|
});
|
|
15583
15775
|
}
|
|
15584
15776
|
else {
|
|
@@ -15601,8 +15793,10 @@ class Models extends BaseModule {
|
|
|
15601
15793
|
return httpResponse.json();
|
|
15602
15794
|
});
|
|
15603
15795
|
return response.then((apiResponse) => {
|
|
15604
|
-
const resp = generateVideosOperationFromMldev
|
|
15605
|
-
|
|
15796
|
+
const resp = generateVideosOperationFromMldev(apiResponse);
|
|
15797
|
+
const typedResp = new GenerateVideosOperation();
|
|
15798
|
+
Object.assign(typedResp, resp);
|
|
15799
|
+
return typedResp;
|
|
15606
15800
|
});
|
|
15607
15801
|
}
|
|
15608
15802
|
}
|
|
@@ -15660,164 +15854,6 @@ function fetchPredictOperationParametersToVertex(fromObject) {
|
|
|
15660
15854
|
}
|
|
15661
15855
|
return toObject;
|
|
15662
15856
|
}
|
|
15663
|
-
function videoFromMldev(fromObject) {
|
|
15664
|
-
const toObject = {};
|
|
15665
|
-
const fromUri = getValueByPath(fromObject, ['video', 'uri']);
|
|
15666
|
-
if (fromUri != null) {
|
|
15667
|
-
setValueByPath(toObject, ['uri'], fromUri);
|
|
15668
|
-
}
|
|
15669
|
-
const fromVideoBytes = getValueByPath(fromObject, [
|
|
15670
|
-
'video',
|
|
15671
|
-
'encodedVideo',
|
|
15672
|
-
]);
|
|
15673
|
-
if (fromVideoBytes != null) {
|
|
15674
|
-
setValueByPath(toObject, ['videoBytes'], tBytes(fromVideoBytes));
|
|
15675
|
-
}
|
|
15676
|
-
const fromMimeType = getValueByPath(fromObject, ['encoding']);
|
|
15677
|
-
if (fromMimeType != null) {
|
|
15678
|
-
setValueByPath(toObject, ['mimeType'], fromMimeType);
|
|
15679
|
-
}
|
|
15680
|
-
return toObject;
|
|
15681
|
-
}
|
|
15682
|
-
function generatedVideoFromMldev(fromObject) {
|
|
15683
|
-
const toObject = {};
|
|
15684
|
-
const fromVideo = getValueByPath(fromObject, ['_self']);
|
|
15685
|
-
if (fromVideo != null) {
|
|
15686
|
-
setValueByPath(toObject, ['video'], videoFromMldev(fromVideo));
|
|
15687
|
-
}
|
|
15688
|
-
return toObject;
|
|
15689
|
-
}
|
|
15690
|
-
function generateVideosResponseFromMldev(fromObject) {
|
|
15691
|
-
const toObject = {};
|
|
15692
|
-
const fromGeneratedVideos = getValueByPath(fromObject, [
|
|
15693
|
-
'generatedSamples',
|
|
15694
|
-
]);
|
|
15695
|
-
if (fromGeneratedVideos != null) {
|
|
15696
|
-
let transformedList = fromGeneratedVideos;
|
|
15697
|
-
if (Array.isArray(transformedList)) {
|
|
15698
|
-
transformedList = transformedList.map((item) => {
|
|
15699
|
-
return generatedVideoFromMldev(item);
|
|
15700
|
-
});
|
|
15701
|
-
}
|
|
15702
|
-
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
15703
|
-
}
|
|
15704
|
-
const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
|
|
15705
|
-
'raiMediaFilteredCount',
|
|
15706
|
-
]);
|
|
15707
|
-
if (fromRaiMediaFilteredCount != null) {
|
|
15708
|
-
setValueByPath(toObject, ['raiMediaFilteredCount'], fromRaiMediaFilteredCount);
|
|
15709
|
-
}
|
|
15710
|
-
const fromRaiMediaFilteredReasons = getValueByPath(fromObject, [
|
|
15711
|
-
'raiMediaFilteredReasons',
|
|
15712
|
-
]);
|
|
15713
|
-
if (fromRaiMediaFilteredReasons != null) {
|
|
15714
|
-
setValueByPath(toObject, ['raiMediaFilteredReasons'], fromRaiMediaFilteredReasons);
|
|
15715
|
-
}
|
|
15716
|
-
return toObject;
|
|
15717
|
-
}
|
|
15718
|
-
function generateVideosOperationFromMldev(fromObject) {
|
|
15719
|
-
const toObject = {};
|
|
15720
|
-
const fromName = getValueByPath(fromObject, ['name']);
|
|
15721
|
-
if (fromName != null) {
|
|
15722
|
-
setValueByPath(toObject, ['name'], fromName);
|
|
15723
|
-
}
|
|
15724
|
-
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
15725
|
-
if (fromMetadata != null) {
|
|
15726
|
-
setValueByPath(toObject, ['metadata'], fromMetadata);
|
|
15727
|
-
}
|
|
15728
|
-
const fromDone = getValueByPath(fromObject, ['done']);
|
|
15729
|
-
if (fromDone != null) {
|
|
15730
|
-
setValueByPath(toObject, ['done'], fromDone);
|
|
15731
|
-
}
|
|
15732
|
-
const fromError = getValueByPath(fromObject, ['error']);
|
|
15733
|
-
if (fromError != null) {
|
|
15734
|
-
setValueByPath(toObject, ['error'], fromError);
|
|
15735
|
-
}
|
|
15736
|
-
const fromResponse = getValueByPath(fromObject, [
|
|
15737
|
-
'response',
|
|
15738
|
-
'generateVideoResponse',
|
|
15739
|
-
]);
|
|
15740
|
-
if (fromResponse != null) {
|
|
15741
|
-
setValueByPath(toObject, ['response'], generateVideosResponseFromMldev(fromResponse));
|
|
15742
|
-
}
|
|
15743
|
-
return toObject;
|
|
15744
|
-
}
|
|
15745
|
-
function videoFromVertex(fromObject) {
|
|
15746
|
-
const toObject = {};
|
|
15747
|
-
const fromUri = getValueByPath(fromObject, ['gcsUri']);
|
|
15748
|
-
if (fromUri != null) {
|
|
15749
|
-
setValueByPath(toObject, ['uri'], fromUri);
|
|
15750
|
-
}
|
|
15751
|
-
const fromVideoBytes = getValueByPath(fromObject, [
|
|
15752
|
-
'bytesBase64Encoded',
|
|
15753
|
-
]);
|
|
15754
|
-
if (fromVideoBytes != null) {
|
|
15755
|
-
setValueByPath(toObject, ['videoBytes'], tBytes(fromVideoBytes));
|
|
15756
|
-
}
|
|
15757
|
-
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
15758
|
-
if (fromMimeType != null) {
|
|
15759
|
-
setValueByPath(toObject, ['mimeType'], fromMimeType);
|
|
15760
|
-
}
|
|
15761
|
-
return toObject;
|
|
15762
|
-
}
|
|
15763
|
-
function generatedVideoFromVertex(fromObject) {
|
|
15764
|
-
const toObject = {};
|
|
15765
|
-
const fromVideo = getValueByPath(fromObject, ['_self']);
|
|
15766
|
-
if (fromVideo != null) {
|
|
15767
|
-
setValueByPath(toObject, ['video'], videoFromVertex(fromVideo));
|
|
15768
|
-
}
|
|
15769
|
-
return toObject;
|
|
15770
|
-
}
|
|
15771
|
-
function generateVideosResponseFromVertex(fromObject) {
|
|
15772
|
-
const toObject = {};
|
|
15773
|
-
const fromGeneratedVideos = getValueByPath(fromObject, ['videos']);
|
|
15774
|
-
if (fromGeneratedVideos != null) {
|
|
15775
|
-
let transformedList = fromGeneratedVideos;
|
|
15776
|
-
if (Array.isArray(transformedList)) {
|
|
15777
|
-
transformedList = transformedList.map((item) => {
|
|
15778
|
-
return generatedVideoFromVertex(item);
|
|
15779
|
-
});
|
|
15780
|
-
}
|
|
15781
|
-
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
15782
|
-
}
|
|
15783
|
-
const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
|
|
15784
|
-
'raiMediaFilteredCount',
|
|
15785
|
-
]);
|
|
15786
|
-
if (fromRaiMediaFilteredCount != null) {
|
|
15787
|
-
setValueByPath(toObject, ['raiMediaFilteredCount'], fromRaiMediaFilteredCount);
|
|
15788
|
-
}
|
|
15789
|
-
const fromRaiMediaFilteredReasons = getValueByPath(fromObject, [
|
|
15790
|
-
'raiMediaFilteredReasons',
|
|
15791
|
-
]);
|
|
15792
|
-
if (fromRaiMediaFilteredReasons != null) {
|
|
15793
|
-
setValueByPath(toObject, ['raiMediaFilteredReasons'], fromRaiMediaFilteredReasons);
|
|
15794
|
-
}
|
|
15795
|
-
return toObject;
|
|
15796
|
-
}
|
|
15797
|
-
function generateVideosOperationFromVertex(fromObject) {
|
|
15798
|
-
const toObject = {};
|
|
15799
|
-
const fromName = getValueByPath(fromObject, ['name']);
|
|
15800
|
-
if (fromName != null) {
|
|
15801
|
-
setValueByPath(toObject, ['name'], fromName);
|
|
15802
|
-
}
|
|
15803
|
-
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
15804
|
-
if (fromMetadata != null) {
|
|
15805
|
-
setValueByPath(toObject, ['metadata'], fromMetadata);
|
|
15806
|
-
}
|
|
15807
|
-
const fromDone = getValueByPath(fromObject, ['done']);
|
|
15808
|
-
if (fromDone != null) {
|
|
15809
|
-
setValueByPath(toObject, ['done'], fromDone);
|
|
15810
|
-
}
|
|
15811
|
-
const fromError = getValueByPath(fromObject, ['error']);
|
|
15812
|
-
if (fromError != null) {
|
|
15813
|
-
setValueByPath(toObject, ['error'], fromError);
|
|
15814
|
-
}
|
|
15815
|
-
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
15816
|
-
if (fromResponse != null) {
|
|
15817
|
-
setValueByPath(toObject, ['response'], generateVideosResponseFromVertex(fromResponse));
|
|
15818
|
-
}
|
|
15819
|
-
return toObject;
|
|
15820
|
-
}
|
|
15821
15857
|
|
|
15822
15858
|
/**
|
|
15823
15859
|
* @license
|
|
@@ -15847,17 +15883,64 @@ class Operations extends BaseModule {
|
|
|
15847
15883
|
if (config && 'httpOptions' in config) {
|
|
15848
15884
|
httpOptions = config.httpOptions;
|
|
15849
15885
|
}
|
|
15850
|
-
|
|
15886
|
+
const rawOperation = await this.fetchPredictVideosOperationInternal({
|
|
15887
|
+
operationName: operation.name,
|
|
15888
|
+
resourceName: resourceName,
|
|
15889
|
+
config: { httpOptions: httpOptions },
|
|
15890
|
+
});
|
|
15891
|
+
return operation._fromAPIResponse({
|
|
15892
|
+
apiResponse: rawOperation,
|
|
15893
|
+
isVertexAI: true,
|
|
15894
|
+
});
|
|
15895
|
+
}
|
|
15896
|
+
else {
|
|
15897
|
+
const rawOperation = await this.getVideosOperationInternal({
|
|
15898
|
+
operationName: operation.name,
|
|
15899
|
+
config: config,
|
|
15900
|
+
});
|
|
15901
|
+
return operation._fromAPIResponse({
|
|
15902
|
+
apiResponse: rawOperation,
|
|
15903
|
+
isVertexAI: false,
|
|
15904
|
+
});
|
|
15905
|
+
}
|
|
15906
|
+
}
|
|
15907
|
+
/**
|
|
15908
|
+
* Gets the status of a long-running operation.
|
|
15909
|
+
*
|
|
15910
|
+
* @param parameters The parameters for the get operation request.
|
|
15911
|
+
* @return The updated Operation object, with the latest status or result.
|
|
15912
|
+
*/
|
|
15913
|
+
async get(parameters) {
|
|
15914
|
+
const operation = parameters.operation;
|
|
15915
|
+
const config = parameters.config;
|
|
15916
|
+
if (operation.name === undefined || operation.name === '') {
|
|
15917
|
+
throw new Error('Operation name is required.');
|
|
15918
|
+
}
|
|
15919
|
+
if (this.apiClient.isVertexAI()) {
|
|
15920
|
+
const resourceName = operation.name.split('/operations/')[0];
|
|
15921
|
+
let httpOptions = undefined;
|
|
15922
|
+
if (config && 'httpOptions' in config) {
|
|
15923
|
+
httpOptions = config.httpOptions;
|
|
15924
|
+
}
|
|
15925
|
+
const rawOperation = await this.fetchPredictVideosOperationInternal({
|
|
15851
15926
|
operationName: operation.name,
|
|
15852
15927
|
resourceName: resourceName,
|
|
15853
15928
|
config: { httpOptions: httpOptions },
|
|
15854
15929
|
});
|
|
15930
|
+
return operation._fromAPIResponse({
|
|
15931
|
+
apiResponse: rawOperation,
|
|
15932
|
+
isVertexAI: true,
|
|
15933
|
+
});
|
|
15855
15934
|
}
|
|
15856
15935
|
else {
|
|
15857
|
-
|
|
15936
|
+
const rawOperation = await this.getVideosOperationInternal({
|
|
15858
15937
|
operationName: operation.name,
|
|
15859
15938
|
config: config,
|
|
15860
15939
|
});
|
|
15940
|
+
return operation._fromAPIResponse({
|
|
15941
|
+
apiResponse: rawOperation,
|
|
15942
|
+
isVertexAI: false,
|
|
15943
|
+
});
|
|
15861
15944
|
}
|
|
15862
15945
|
}
|
|
15863
15946
|
async getVideosOperationInternal(params) {
|
|
@@ -15884,10 +15967,7 @@ class Operations extends BaseModule {
|
|
|
15884
15967
|
.then((httpResponse) => {
|
|
15885
15968
|
return httpResponse.json();
|
|
15886
15969
|
});
|
|
15887
|
-
return response
|
|
15888
|
-
const resp = generateVideosOperationFromVertex(apiResponse);
|
|
15889
|
-
return resp;
|
|
15890
|
-
});
|
|
15970
|
+
return response;
|
|
15891
15971
|
}
|
|
15892
15972
|
else {
|
|
15893
15973
|
const body = getOperationParametersToMldev(params);
|
|
@@ -15908,10 +15988,7 @@ class Operations extends BaseModule {
|
|
|
15908
15988
|
.then((httpResponse) => {
|
|
15909
15989
|
return httpResponse.json();
|
|
15910
15990
|
});
|
|
15911
|
-
return response
|
|
15912
|
-
const resp = generateVideosOperationFromMldev(apiResponse);
|
|
15913
|
-
return resp;
|
|
15914
|
-
});
|
|
15991
|
+
return response;
|
|
15915
15992
|
}
|
|
15916
15993
|
}
|
|
15917
15994
|
async fetchPredictVideosOperationInternal(params) {
|
|
@@ -15938,10 +16015,7 @@ class Operations extends BaseModule {
|
|
|
15938
16015
|
.then((httpResponse) => {
|
|
15939
16016
|
return httpResponse.json();
|
|
15940
16017
|
});
|
|
15941
|
-
return response
|
|
15942
|
-
const resp = generateVideosOperationFromVertex(apiResponse);
|
|
15943
|
-
return resp;
|
|
15944
|
-
});
|
|
16018
|
+
return response;
|
|
15945
16019
|
}
|
|
15946
16020
|
else {
|
|
15947
16021
|
throw new Error('This method is only supported by the Vertex AI.');
|
|
@@ -17168,6 +17242,12 @@ function tuningJobFromMldev(fromObject) {
|
|
|
17168
17242
|
}
|
|
17169
17243
|
function listTuningJobsResponseFromMldev(fromObject) {
|
|
17170
17244
|
const toObject = {};
|
|
17245
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
17246
|
+
'sdkHttpResponse',
|
|
17247
|
+
]);
|
|
17248
|
+
if (fromSdkHttpResponse != null) {
|
|
17249
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
17250
|
+
}
|
|
17171
17251
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
17172
17252
|
'nextPageToken',
|
|
17173
17253
|
]);
|
|
@@ -17356,6 +17436,12 @@ function tuningJobFromVertex(fromObject) {
|
|
|
17356
17436
|
}
|
|
17357
17437
|
function listTuningJobsResponseFromVertex(fromObject) {
|
|
17358
17438
|
const toObject = {};
|
|
17439
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
17440
|
+
'sdkHttpResponse',
|
|
17441
|
+
]);
|
|
17442
|
+
if (fromSdkHttpResponse != null) {
|
|
17443
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
17444
|
+
}
|
|
17359
17445
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
17360
17446
|
'nextPageToken',
|
|
17361
17447
|
]);
|
|
@@ -17516,7 +17602,13 @@ class Tunings extends BaseModule {
|
|
|
17516
17602
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
17517
17603
|
})
|
|
17518
17604
|
.then((httpResponse) => {
|
|
17519
|
-
return httpResponse.json()
|
|
17605
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
17606
|
+
const response = jsonResponse;
|
|
17607
|
+
response.sdkHttpResponse = {
|
|
17608
|
+
headers: httpResponse.headers,
|
|
17609
|
+
};
|
|
17610
|
+
return response;
|
|
17611
|
+
});
|
|
17520
17612
|
});
|
|
17521
17613
|
return response.then((apiResponse) => {
|
|
17522
17614
|
const resp = listTuningJobsResponseFromVertex(apiResponse);
|
|
@@ -17542,7 +17634,13 @@ class Tunings extends BaseModule {
|
|
|
17542
17634
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
17543
17635
|
})
|
|
17544
17636
|
.then((httpResponse) => {
|
|
17545
|
-
return httpResponse.json()
|
|
17637
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
17638
|
+
const response = jsonResponse;
|
|
17639
|
+
response.sdkHttpResponse = {
|
|
17640
|
+
headers: httpResponse.headers,
|
|
17641
|
+
};
|
|
17642
|
+
return response;
|
|
17643
|
+
});
|
|
17546
17644
|
});
|
|
17547
17645
|
return response.then((apiResponse) => {
|
|
17548
17646
|
const resp = listTuningJobsResponseFromMldev(apiResponse);
|
|
@@ -17735,6 +17833,7 @@ exports.GenerateContentResponse = GenerateContentResponse;
|
|
|
17735
17833
|
exports.GenerateContentResponsePromptFeedback = GenerateContentResponsePromptFeedback;
|
|
17736
17834
|
exports.GenerateContentResponseUsageMetadata = GenerateContentResponseUsageMetadata;
|
|
17737
17835
|
exports.GenerateImagesResponse = GenerateImagesResponse;
|
|
17836
|
+
exports.GenerateVideosOperation = GenerateVideosOperation;
|
|
17738
17837
|
exports.GenerateVideosResponse = GenerateVideosResponse;
|
|
17739
17838
|
exports.GoogleGenAI = GoogleGenAI;
|
|
17740
17839
|
exports.HttpResponse = HttpResponse;
|