@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/web/index.mjs
CHANGED
|
@@ -44,18 +44,18 @@ function getDefaultBaseUrls() {
|
|
|
44
44
|
* 2. Base URLs set via the latest call to setDefaultBaseUrls.
|
|
45
45
|
* 3. Base URLs set via environment variables.
|
|
46
46
|
*/
|
|
47
|
-
function getBaseUrl(
|
|
48
|
-
var _a, _b
|
|
49
|
-
if (!(
|
|
47
|
+
function getBaseUrl(httpOptions, vertexai, vertexBaseUrlFromEnv, geminiBaseUrlFromEnv) {
|
|
48
|
+
var _a, _b;
|
|
49
|
+
if (!(httpOptions === null || httpOptions === void 0 ? void 0 : httpOptions.baseUrl)) {
|
|
50
50
|
const defaultBaseUrls = getDefaultBaseUrls();
|
|
51
|
-
if (
|
|
52
|
-
return (
|
|
51
|
+
if (vertexai) {
|
|
52
|
+
return (_a = defaultBaseUrls.vertexUrl) !== null && _a !== void 0 ? _a : vertexBaseUrlFromEnv;
|
|
53
53
|
}
|
|
54
54
|
else {
|
|
55
|
-
return (
|
|
55
|
+
return (_b = defaultBaseUrls.geminiUrl) !== null && _b !== void 0 ? _b : geminiBaseUrlFromEnv;
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
return
|
|
58
|
+
return httpOptions.baseUrl;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
/**
|
|
@@ -190,6 +190,20 @@ function getValueByPath(data, keys) {
|
|
|
190
190
|
* Copyright 2025 Google LLC
|
|
191
191
|
* SPDX-License-Identifier: Apache-2.0
|
|
192
192
|
*/
|
|
193
|
+
function tBytes$1(fromBytes) {
|
|
194
|
+
if (typeof fromBytes !== 'string') {
|
|
195
|
+
throw new Error('fromImageBytes must be a string');
|
|
196
|
+
}
|
|
197
|
+
// TODO(b/389133914): Remove dummy bytes converter.
|
|
198
|
+
return fromBytes;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* @license
|
|
203
|
+
* Copyright 2025 Google LLC
|
|
204
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
205
|
+
*/
|
|
206
|
+
// Code generated by the Google Gen AI SDK generator DO NOT EDIT.
|
|
193
207
|
/** Required. Outcome of the code execution. */
|
|
194
208
|
var Outcome;
|
|
195
209
|
(function (Outcome) {
|
|
@@ -1683,6 +1697,65 @@ class LiveServerMessage {
|
|
|
1683
1697
|
return data.length > 0 ? btoa(data) : undefined;
|
|
1684
1698
|
}
|
|
1685
1699
|
}
|
|
1700
|
+
/** A video generation long-running operation. */
|
|
1701
|
+
class GenerateVideosOperation {
|
|
1702
|
+
/**
|
|
1703
|
+
* Instantiates an Operation of the same type as the one being called with the fields set from the API response.
|
|
1704
|
+
* @internal
|
|
1705
|
+
*/
|
|
1706
|
+
_fromAPIResponse({ apiResponse, isVertexAI, }) {
|
|
1707
|
+
const operation = new GenerateVideosOperation();
|
|
1708
|
+
operation.name = apiResponse['name'];
|
|
1709
|
+
operation.metadata = apiResponse['metadata'];
|
|
1710
|
+
operation.done = apiResponse['done'];
|
|
1711
|
+
operation.error = apiResponse['error'];
|
|
1712
|
+
if (isVertexAI) {
|
|
1713
|
+
const response = apiResponse['response'];
|
|
1714
|
+
if (response) {
|
|
1715
|
+
const operationResponse = new GenerateVideosResponse();
|
|
1716
|
+
const responseVideos = response['videos'];
|
|
1717
|
+
operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
|
|
1718
|
+
return {
|
|
1719
|
+
video: {
|
|
1720
|
+
uri: generatedVideo['gcsUri'],
|
|
1721
|
+
videoBytes: generatedVideo['bytesBase64Encoded']
|
|
1722
|
+
? tBytes$1(generatedVideo['bytesBase64Encoded'])
|
|
1723
|
+
: undefined,
|
|
1724
|
+
mimeType: generatedVideo['mimeType'],
|
|
1725
|
+
},
|
|
1726
|
+
};
|
|
1727
|
+
});
|
|
1728
|
+
operationResponse.raiMediaFilteredCount = response['raiMediaFilteredCount'];
|
|
1729
|
+
operationResponse.raiMediaFilteredReasons = response['raiMediaFilteredReasons'];
|
|
1730
|
+
operation.response = operationResponse;
|
|
1731
|
+
}
|
|
1732
|
+
}
|
|
1733
|
+
else {
|
|
1734
|
+
const response = apiResponse['response'];
|
|
1735
|
+
if (response) {
|
|
1736
|
+
const operationResponse = new GenerateVideosResponse();
|
|
1737
|
+
const generatedVideoResponse = response['generateVideoResponse'];
|
|
1738
|
+
const responseVideos = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['generatedSamples'];
|
|
1739
|
+
operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
|
|
1740
|
+
const video = generatedVideo['video'];
|
|
1741
|
+
return {
|
|
1742
|
+
video: {
|
|
1743
|
+
uri: video === null || video === void 0 ? void 0 : video['uri'],
|
|
1744
|
+
videoBytes: (video === null || video === void 0 ? void 0 : video['encodedVideo'])
|
|
1745
|
+
? tBytes$1(video === null || video === void 0 ? void 0 : video['encodedVideo'])
|
|
1746
|
+
: undefined,
|
|
1747
|
+
mimeType: generatedVideo['encoding'],
|
|
1748
|
+
},
|
|
1749
|
+
};
|
|
1750
|
+
});
|
|
1751
|
+
operationResponse.raiMediaFilteredCount = response['raiMediaFilteredCount'];
|
|
1752
|
+
operationResponse.raiMediaFilteredReasons = response['raiMediaFilteredReasons'];
|
|
1753
|
+
operation.response = operationResponse;
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
return operation;
|
|
1757
|
+
}
|
|
1758
|
+
}
|
|
1686
1759
|
/** Client generated response to a `ToolCall` received from the server.
|
|
1687
1760
|
|
|
1688
1761
|
Individual `FunctionResponse` objects are matched to the respective
|
|
@@ -2244,11 +2317,7 @@ function tTuningJobStatus(status) {
|
|
|
2244
2317
|
}
|
|
2245
2318
|
}
|
|
2246
2319
|
function tBytes(fromImageBytes) {
|
|
2247
|
-
|
|
2248
|
-
throw new Error('fromImageBytes must be a string');
|
|
2249
|
-
}
|
|
2250
|
-
// TODO(b/389133914): Remove dummy bytes converter.
|
|
2251
|
-
return fromImageBytes;
|
|
2320
|
+
return tBytes$1(fromImageBytes);
|
|
2252
2321
|
}
|
|
2253
2322
|
function _isFile(origin) {
|
|
2254
2323
|
return (origin !== null &&
|
|
@@ -3736,6 +3805,12 @@ function batchJobFromMldev(fromObject) {
|
|
|
3736
3805
|
}
|
|
3737
3806
|
function listBatchJobsResponseFromMldev(fromObject) {
|
|
3738
3807
|
const toObject = {};
|
|
3808
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
3809
|
+
'sdkHttpResponse',
|
|
3810
|
+
]);
|
|
3811
|
+
if (fromSdkHttpResponse != null) {
|
|
3812
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
3813
|
+
}
|
|
3739
3814
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
3740
3815
|
'nextPageToken',
|
|
3741
3816
|
]);
|
|
@@ -3877,6 +3952,12 @@ function batchJobFromVertex(fromObject) {
|
|
|
3877
3952
|
}
|
|
3878
3953
|
function listBatchJobsResponseFromVertex(fromObject) {
|
|
3879
3954
|
const toObject = {};
|
|
3955
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
3956
|
+
'sdkHttpResponse',
|
|
3957
|
+
]);
|
|
3958
|
+
if (fromSdkHttpResponse != null) {
|
|
3959
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
3960
|
+
}
|
|
3880
3961
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
3881
3962
|
'nextPageToken',
|
|
3882
3963
|
]);
|
|
@@ -3919,9 +4000,6 @@ function deleteResourceJobFromVertex(fromObject) {
|
|
|
3919
4000
|
* Copyright 2025 Google LLC
|
|
3920
4001
|
* SPDX-License-Identifier: Apache-2.0
|
|
3921
4002
|
*/
|
|
3922
|
-
/**
|
|
3923
|
-
* Pagers for the GenAI List APIs.
|
|
3924
|
-
*/
|
|
3925
4003
|
var PagedItem;
|
|
3926
4004
|
(function (PagedItem) {
|
|
3927
4005
|
PagedItem["PAGED_ITEM_BATCH_JOBS"] = "batchJobs";
|
|
@@ -3944,9 +4022,10 @@ class Pager {
|
|
|
3944
4022
|
var _a, _b;
|
|
3945
4023
|
this.nameInternal = name;
|
|
3946
4024
|
this.pageInternal = response[this.nameInternal] || [];
|
|
4025
|
+
this.sdkHttpResponseInternal = response === null || response === void 0 ? void 0 : response.sdkHttpResponse;
|
|
3947
4026
|
this.idxInternal = 0;
|
|
3948
4027
|
let requestParams = { config: {} };
|
|
3949
|
-
if (!params) {
|
|
4028
|
+
if (!params || Object.keys(params).length === 0) {
|
|
3950
4029
|
requestParams = { config: {} };
|
|
3951
4030
|
}
|
|
3952
4031
|
else if (typeof params === 'object') {
|
|
@@ -3990,6 +4069,12 @@ class Pager {
|
|
|
3990
4069
|
get pageSize() {
|
|
3991
4070
|
return this.pageInternalSize;
|
|
3992
4071
|
}
|
|
4072
|
+
/**
|
|
4073
|
+
* Returns the headers of the API response.
|
|
4074
|
+
*/
|
|
4075
|
+
get sdkHttpResponse() {
|
|
4076
|
+
return this.sdkHttpResponseInternal;
|
|
4077
|
+
}
|
|
3993
4078
|
/**
|
|
3994
4079
|
* Returns the parameters when making the API request for the next page.
|
|
3995
4080
|
*
|
|
@@ -4359,7 +4444,13 @@ class Batches extends BaseModule {
|
|
|
4359
4444
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
4360
4445
|
})
|
|
4361
4446
|
.then((httpResponse) => {
|
|
4362
|
-
return httpResponse.json()
|
|
4447
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
4448
|
+
const response = jsonResponse;
|
|
4449
|
+
response.sdkHttpResponse = {
|
|
4450
|
+
headers: httpResponse.headers,
|
|
4451
|
+
};
|
|
4452
|
+
return response;
|
|
4453
|
+
});
|
|
4363
4454
|
});
|
|
4364
4455
|
return response.then((apiResponse) => {
|
|
4365
4456
|
const resp = listBatchJobsResponseFromVertex(apiResponse);
|
|
@@ -4385,7 +4476,13 @@ class Batches extends BaseModule {
|
|
|
4385
4476
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
4386
4477
|
})
|
|
4387
4478
|
.then((httpResponse) => {
|
|
4388
|
-
return httpResponse.json()
|
|
4479
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
4480
|
+
const response = jsonResponse;
|
|
4481
|
+
response.sdkHttpResponse = {
|
|
4482
|
+
headers: httpResponse.headers,
|
|
4483
|
+
};
|
|
4484
|
+
return response;
|
|
4485
|
+
});
|
|
4389
4486
|
});
|
|
4390
4487
|
return response.then((apiResponse) => {
|
|
4391
4488
|
const resp = listBatchJobsResponseFromMldev(apiResponse);
|
|
@@ -5438,6 +5535,12 @@ function deleteCachedContentResponseFromMldev() {
|
|
|
5438
5535
|
}
|
|
5439
5536
|
function listCachedContentsResponseFromMldev(fromObject) {
|
|
5440
5537
|
const toObject = {};
|
|
5538
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
5539
|
+
'sdkHttpResponse',
|
|
5540
|
+
]);
|
|
5541
|
+
if (fromSdkHttpResponse != null) {
|
|
5542
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
5543
|
+
}
|
|
5441
5544
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
5442
5545
|
'nextPageToken',
|
|
5443
5546
|
]);
|
|
@@ -5498,6 +5601,12 @@ function deleteCachedContentResponseFromVertex() {
|
|
|
5498
5601
|
}
|
|
5499
5602
|
function listCachedContentsResponseFromVertex(fromObject) {
|
|
5500
5603
|
const toObject = {};
|
|
5604
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
5605
|
+
'sdkHttpResponse',
|
|
5606
|
+
]);
|
|
5607
|
+
if (fromSdkHttpResponse != null) {
|
|
5608
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
5609
|
+
}
|
|
5501
5610
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
5502
5611
|
'nextPageToken',
|
|
5503
5612
|
]);
|
|
@@ -5850,7 +5959,13 @@ class Caches extends BaseModule {
|
|
|
5850
5959
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
5851
5960
|
})
|
|
5852
5961
|
.then((httpResponse) => {
|
|
5853
|
-
return httpResponse.json()
|
|
5962
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
5963
|
+
const response = jsonResponse;
|
|
5964
|
+
response.sdkHttpResponse = {
|
|
5965
|
+
headers: httpResponse.headers,
|
|
5966
|
+
};
|
|
5967
|
+
return response;
|
|
5968
|
+
});
|
|
5854
5969
|
});
|
|
5855
5970
|
return response.then((apiResponse) => {
|
|
5856
5971
|
const resp = listCachedContentsResponseFromVertex(apiResponse);
|
|
@@ -5876,7 +5991,13 @@ class Caches extends BaseModule {
|
|
|
5876
5991
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
5877
5992
|
})
|
|
5878
5993
|
.then((httpResponse) => {
|
|
5879
|
-
return httpResponse.json()
|
|
5994
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
5995
|
+
const response = jsonResponse;
|
|
5996
|
+
response.sdkHttpResponse = {
|
|
5997
|
+
headers: httpResponse.headers,
|
|
5998
|
+
};
|
|
5999
|
+
return response;
|
|
6000
|
+
});
|
|
5880
6001
|
});
|
|
5881
6002
|
return response.then((apiResponse) => {
|
|
5882
6003
|
const resp = listCachedContentsResponseFromMldev(apiResponse);
|
|
@@ -6514,6 +6635,12 @@ function fileFromMldev(fromObject) {
|
|
|
6514
6635
|
}
|
|
6515
6636
|
function listFilesResponseFromMldev(fromObject) {
|
|
6516
6637
|
const toObject = {};
|
|
6638
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
6639
|
+
'sdkHttpResponse',
|
|
6640
|
+
]);
|
|
6641
|
+
if (fromSdkHttpResponse != null) {
|
|
6642
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
6643
|
+
}
|
|
6517
6644
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
6518
6645
|
'nextPageToken',
|
|
6519
6646
|
]);
|
|
@@ -6675,7 +6802,13 @@ class Files extends BaseModule {
|
|
|
6675
6802
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
6676
6803
|
})
|
|
6677
6804
|
.then((httpResponse) => {
|
|
6678
|
-
return httpResponse.json()
|
|
6805
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
6806
|
+
const response = jsonResponse;
|
|
6807
|
+
response.sdkHttpResponse = {
|
|
6808
|
+
headers: httpResponse.headers,
|
|
6809
|
+
};
|
|
6810
|
+
return response;
|
|
6811
|
+
});
|
|
6679
6812
|
});
|
|
6680
6813
|
return response.then((apiResponse) => {
|
|
6681
6814
|
const resp = listFilesResponseFromMldev(apiResponse);
|
|
@@ -9901,6 +10034,9 @@ function generateImagesConfigToMldev(fromObject, parentObject) {
|
|
|
9901
10034
|
if (getValueByPath(fromObject, ['addWatermark']) !== undefined) {
|
|
9902
10035
|
throw new Error('addWatermark parameter is not supported in Gemini API.');
|
|
9903
10036
|
}
|
|
10037
|
+
if (getValueByPath(fromObject, ['imageSize']) !== undefined) {
|
|
10038
|
+
throw new Error('imageSize parameter is not supported in Gemini API.');
|
|
10039
|
+
}
|
|
9904
10040
|
if (getValueByPath(fromObject, ['enhancePrompt']) !== undefined) {
|
|
9905
10041
|
throw new Error('enhancePrompt parameter is not supported in Gemini API.');
|
|
9906
10042
|
}
|
|
@@ -10977,6 +11113,10 @@ function generateImagesConfigToVertex(fromObject, parentObject) {
|
|
|
10977
11113
|
if (parentObject !== undefined && fromAddWatermark != null) {
|
|
10978
11114
|
setValueByPath(parentObject, ['parameters', 'addWatermark'], fromAddWatermark);
|
|
10979
11115
|
}
|
|
11116
|
+
const fromImageSize = getValueByPath(fromObject, ['imageSize']);
|
|
11117
|
+
if (parentObject !== undefined && fromImageSize != null) {
|
|
11118
|
+
setValueByPath(parentObject, ['parameters', 'sampleImageSize'], fromImageSize);
|
|
11119
|
+
}
|
|
10980
11120
|
const fromEnhancePrompt = getValueByPath(fromObject, [
|
|
10981
11121
|
'enhancePrompt',
|
|
10982
11122
|
]);
|
|
@@ -11967,6 +12107,12 @@ function modelFromMldev(fromObject) {
|
|
|
11967
12107
|
}
|
|
11968
12108
|
function listModelsResponseFromMldev(fromObject) {
|
|
11969
12109
|
const toObject = {};
|
|
12110
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
12111
|
+
'sdkHttpResponse',
|
|
12112
|
+
]);
|
|
12113
|
+
if (fromSdkHttpResponse != null) {
|
|
12114
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
12115
|
+
}
|
|
11970
12116
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
11971
12117
|
'nextPageToken',
|
|
11972
12118
|
]);
|
|
@@ -12003,7 +12149,7 @@ function countTokensResponseFromMldev(fromObject) {
|
|
|
12003
12149
|
}
|
|
12004
12150
|
return toObject;
|
|
12005
12151
|
}
|
|
12006
|
-
function videoFromMldev
|
|
12152
|
+
function videoFromMldev(fromObject) {
|
|
12007
12153
|
const toObject = {};
|
|
12008
12154
|
const fromUri = getValueByPath(fromObject, ['video', 'uri']);
|
|
12009
12155
|
if (fromUri != null) {
|
|
@@ -12022,15 +12168,15 @@ function videoFromMldev$1(fromObject) {
|
|
|
12022
12168
|
}
|
|
12023
12169
|
return toObject;
|
|
12024
12170
|
}
|
|
12025
|
-
function generatedVideoFromMldev
|
|
12171
|
+
function generatedVideoFromMldev(fromObject) {
|
|
12026
12172
|
const toObject = {};
|
|
12027
12173
|
const fromVideo = getValueByPath(fromObject, ['_self']);
|
|
12028
12174
|
if (fromVideo != null) {
|
|
12029
|
-
setValueByPath(toObject, ['video'], videoFromMldev
|
|
12175
|
+
setValueByPath(toObject, ['video'], videoFromMldev(fromVideo));
|
|
12030
12176
|
}
|
|
12031
12177
|
return toObject;
|
|
12032
12178
|
}
|
|
12033
|
-
function generateVideosResponseFromMldev
|
|
12179
|
+
function generateVideosResponseFromMldev(fromObject) {
|
|
12034
12180
|
const toObject = {};
|
|
12035
12181
|
const fromGeneratedVideos = getValueByPath(fromObject, [
|
|
12036
12182
|
'generatedSamples',
|
|
@@ -12039,7 +12185,7 @@ function generateVideosResponseFromMldev$1(fromObject) {
|
|
|
12039
12185
|
let transformedList = fromGeneratedVideos;
|
|
12040
12186
|
if (Array.isArray(transformedList)) {
|
|
12041
12187
|
transformedList = transformedList.map((item) => {
|
|
12042
|
-
return generatedVideoFromMldev
|
|
12188
|
+
return generatedVideoFromMldev(item);
|
|
12043
12189
|
});
|
|
12044
12190
|
}
|
|
12045
12191
|
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
@@ -12058,7 +12204,7 @@ function generateVideosResponseFromMldev$1(fromObject) {
|
|
|
12058
12204
|
}
|
|
12059
12205
|
return toObject;
|
|
12060
12206
|
}
|
|
12061
|
-
function generateVideosOperationFromMldev
|
|
12207
|
+
function generateVideosOperationFromMldev(fromObject) {
|
|
12062
12208
|
const toObject = {};
|
|
12063
12209
|
const fromName = getValueByPath(fromObject, ['name']);
|
|
12064
12210
|
if (fromName != null) {
|
|
@@ -12081,7 +12227,7 @@ function generateVideosOperationFromMldev$1(fromObject) {
|
|
|
12081
12227
|
'generateVideoResponse',
|
|
12082
12228
|
]);
|
|
12083
12229
|
if (fromResponse != null) {
|
|
12084
|
-
setValueByPath(toObject, ['response'], generateVideosResponseFromMldev
|
|
12230
|
+
setValueByPath(toObject, ['response'], generateVideosResponseFromMldev(fromResponse));
|
|
12085
12231
|
}
|
|
12086
12232
|
return toObject;
|
|
12087
12233
|
}
|
|
@@ -12617,6 +12763,12 @@ function modelFromVertex(fromObject) {
|
|
|
12617
12763
|
}
|
|
12618
12764
|
function listModelsResponseFromVertex(fromObject) {
|
|
12619
12765
|
const toObject = {};
|
|
12766
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
12767
|
+
'sdkHttpResponse',
|
|
12768
|
+
]);
|
|
12769
|
+
if (fromSdkHttpResponse != null) {
|
|
12770
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
12771
|
+
}
|
|
12620
12772
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
12621
12773
|
'nextPageToken',
|
|
12622
12774
|
]);
|
|
@@ -12655,7 +12807,7 @@ function computeTokensResponseFromVertex(fromObject) {
|
|
|
12655
12807
|
}
|
|
12656
12808
|
return toObject;
|
|
12657
12809
|
}
|
|
12658
|
-
function videoFromVertex
|
|
12810
|
+
function videoFromVertex(fromObject) {
|
|
12659
12811
|
const toObject = {};
|
|
12660
12812
|
const fromUri = getValueByPath(fromObject, ['gcsUri']);
|
|
12661
12813
|
if (fromUri != null) {
|
|
@@ -12673,22 +12825,22 @@ function videoFromVertex$1(fromObject) {
|
|
|
12673
12825
|
}
|
|
12674
12826
|
return toObject;
|
|
12675
12827
|
}
|
|
12676
|
-
function generatedVideoFromVertex
|
|
12828
|
+
function generatedVideoFromVertex(fromObject) {
|
|
12677
12829
|
const toObject = {};
|
|
12678
12830
|
const fromVideo = getValueByPath(fromObject, ['_self']);
|
|
12679
12831
|
if (fromVideo != null) {
|
|
12680
|
-
setValueByPath(toObject, ['video'], videoFromVertex
|
|
12832
|
+
setValueByPath(toObject, ['video'], videoFromVertex(fromVideo));
|
|
12681
12833
|
}
|
|
12682
12834
|
return toObject;
|
|
12683
12835
|
}
|
|
12684
|
-
function generateVideosResponseFromVertex
|
|
12836
|
+
function generateVideosResponseFromVertex(fromObject) {
|
|
12685
12837
|
const toObject = {};
|
|
12686
12838
|
const fromGeneratedVideos = getValueByPath(fromObject, ['videos']);
|
|
12687
12839
|
if (fromGeneratedVideos != null) {
|
|
12688
12840
|
let transformedList = fromGeneratedVideos;
|
|
12689
12841
|
if (Array.isArray(transformedList)) {
|
|
12690
12842
|
transformedList = transformedList.map((item) => {
|
|
12691
|
-
return generatedVideoFromVertex
|
|
12843
|
+
return generatedVideoFromVertex(item);
|
|
12692
12844
|
});
|
|
12693
12845
|
}
|
|
12694
12846
|
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
@@ -12707,7 +12859,7 @@ function generateVideosResponseFromVertex$1(fromObject) {
|
|
|
12707
12859
|
}
|
|
12708
12860
|
return toObject;
|
|
12709
12861
|
}
|
|
12710
|
-
function generateVideosOperationFromVertex
|
|
12862
|
+
function generateVideosOperationFromVertex(fromObject) {
|
|
12711
12863
|
const toObject = {};
|
|
12712
12864
|
const fromName = getValueByPath(fromObject, ['name']);
|
|
12713
12865
|
if (fromName != null) {
|
|
@@ -12727,7 +12879,7 @@ function generateVideosOperationFromVertex$1(fromObject) {
|
|
|
12727
12879
|
}
|
|
12728
12880
|
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
12729
12881
|
if (fromResponse != null) {
|
|
12730
|
-
setValueByPath(toObject, ['response'], generateVideosResponseFromVertex
|
|
12882
|
+
setValueByPath(toObject, ['response'], generateVideosResponseFromVertex(fromResponse));
|
|
12731
12883
|
}
|
|
12732
12884
|
return toObject;
|
|
12733
12885
|
}
|
|
@@ -12741,7 +12893,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
12741
12893
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
12742
12894
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
12743
12895
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
12744
|
-
const SDK_VERSION = '1.
|
|
12896
|
+
const SDK_VERSION = '1.11.0'; // x-release-please-version
|
|
12745
12897
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
12746
12898
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
12747
12899
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -13334,18 +13486,6 @@ function setMcpUsageHeader(headers) {
|
|
|
13334
13486
|
const existingHeader = (_a = headers[GOOGLE_API_CLIENT_HEADER]) !== null && _a !== void 0 ? _a : '';
|
|
13335
13487
|
headers[GOOGLE_API_CLIENT_HEADER] = (existingHeader + ` ${MCP_LABEL}`).trimStart();
|
|
13336
13488
|
}
|
|
13337
|
-
// Checks whether the list of tools contains any MCP clients. Will return true
|
|
13338
|
-
// if there is at least one MCP client.
|
|
13339
|
-
function hasMcpClientTools(params) {
|
|
13340
|
-
var _a, _b, _c;
|
|
13341
|
-
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;
|
|
13342
|
-
}
|
|
13343
|
-
// Checks whether the list of tools contains any non-MCP tools. Will return true
|
|
13344
|
-
// if there is at least one non-MCP tool.
|
|
13345
|
-
function hasNonMcpTools(params) {
|
|
13346
|
-
var _a, _b, _c;
|
|
13347
|
-
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);
|
|
13348
|
-
}
|
|
13349
13489
|
// Returns true if the object is a MCP CallableTool, otherwise false.
|
|
13350
13490
|
function isMcpCallableTool(object) {
|
|
13351
13491
|
return (object !== null &&
|
|
@@ -14204,6 +14344,18 @@ function shouldDisableAfc(config) {
|
|
|
14204
14344
|
function isCallableTool(tool) {
|
|
14205
14345
|
return 'callTool' in tool && typeof tool.callTool === 'function';
|
|
14206
14346
|
}
|
|
14347
|
+
// Checks whether the list of tools contains any CallableTools. Will return true
|
|
14348
|
+
// if there is at least one CallableTool.
|
|
14349
|
+
function hasCallableTools(params) {
|
|
14350
|
+
var _a, _b, _c;
|
|
14351
|
+
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;
|
|
14352
|
+
}
|
|
14353
|
+
// Checks whether the list of tools contains any non-callable tools. Will return
|
|
14354
|
+
// true if there is at least one non-Callable tool.
|
|
14355
|
+
function hasNonCallableTools(params) {
|
|
14356
|
+
var _a, _b, _c;
|
|
14357
|
+
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;
|
|
14358
|
+
}
|
|
14207
14359
|
/**
|
|
14208
14360
|
* Returns whether to append automatic function calling history to the
|
|
14209
14361
|
* response.
|
|
@@ -14262,12 +14414,12 @@ class Models extends BaseModule {
|
|
|
14262
14414
|
*/
|
|
14263
14415
|
this.generateContent = async (params) => {
|
|
14264
14416
|
var _a, _b, _c, _d, _e;
|
|
14265
|
-
const transformedParams = await this.
|
|
14417
|
+
const transformedParams = await this.processParamsMaybeAddMcpUsage(params);
|
|
14266
14418
|
this.maybeMoveToResponseJsonSchem(params);
|
|
14267
|
-
if (!
|
|
14419
|
+
if (!hasCallableTools(params) || shouldDisableAfc(params.config)) {
|
|
14268
14420
|
return await this.generateContentInternal(transformedParams);
|
|
14269
14421
|
}
|
|
14270
|
-
if (
|
|
14422
|
+
if (hasNonCallableTools(params)) {
|
|
14271
14423
|
throw new Error('Automatic function calling with CallableTools and Tools is not yet supported.');
|
|
14272
14424
|
}
|
|
14273
14425
|
let response;
|
|
@@ -14352,7 +14504,7 @@ class Models extends BaseModule {
|
|
|
14352
14504
|
this.generateContentStream = async (params) => {
|
|
14353
14505
|
this.maybeMoveToResponseJsonSchem(params);
|
|
14354
14506
|
if (shouldDisableAfc(params.config)) {
|
|
14355
|
-
const transformedParams = await this.
|
|
14507
|
+
const transformedParams = await this.processParamsMaybeAddMcpUsage(params);
|
|
14356
14508
|
return await this.generateContentStreamInternal(transformedParams);
|
|
14357
14509
|
}
|
|
14358
14510
|
else {
|
|
@@ -14501,6 +14653,32 @@ class Models extends BaseModule {
|
|
|
14501
14653
|
};
|
|
14502
14654
|
return await this.upscaleImageInternal(apiParams);
|
|
14503
14655
|
};
|
|
14656
|
+
/**
|
|
14657
|
+
* Generates videos based on a text description and configuration.
|
|
14658
|
+
*
|
|
14659
|
+
* @param params - The parameters for generating videos.
|
|
14660
|
+
* @return A Promise<GenerateVideosOperation> which allows you to track the progress and eventually retrieve the generated videos using the operations.get method.
|
|
14661
|
+
*
|
|
14662
|
+
* @example
|
|
14663
|
+
* ```ts
|
|
14664
|
+
* const operation = await ai.models.generateVideos({
|
|
14665
|
+
* model: 'veo-2.0-generate-001',
|
|
14666
|
+
* prompt: 'A neon hologram of a cat driving at top speed',
|
|
14667
|
+
* config: {
|
|
14668
|
+
* numberOfVideos: 1
|
|
14669
|
+
* });
|
|
14670
|
+
*
|
|
14671
|
+
* while (!operation.done) {
|
|
14672
|
+
* await new Promise(resolve => setTimeout(resolve, 10000));
|
|
14673
|
+
* operation = await ai.operations.getVideosOperation({operation: operation});
|
|
14674
|
+
* }
|
|
14675
|
+
*
|
|
14676
|
+
* console.log(operation.response?.generatedVideos?.[0]?.video?.uri);
|
|
14677
|
+
* ```
|
|
14678
|
+
*/
|
|
14679
|
+
this.generateVideos = async (params) => {
|
|
14680
|
+
return await this.generateVideosInternal(params);
|
|
14681
|
+
};
|
|
14504
14682
|
}
|
|
14505
14683
|
/**
|
|
14506
14684
|
* This logic is needed for GenerateContentConfig only.
|
|
@@ -14526,7 +14704,7 @@ class Models extends BaseModule {
|
|
|
14526
14704
|
* modify the original params. Also sets the MCP usage header if there are
|
|
14527
14705
|
* MCP tools in the parameters.
|
|
14528
14706
|
*/
|
|
14529
|
-
async
|
|
14707
|
+
async processParamsMaybeAddMcpUsage(params) {
|
|
14530
14708
|
var _a, _b, _c;
|
|
14531
14709
|
const tools = (_a = params.config) === null || _a === void 0 ? void 0 : _a.tools;
|
|
14532
14710
|
if (!tools) {
|
|
@@ -14593,7 +14771,7 @@ class Models extends BaseModule {
|
|
|
14593
14771
|
remoteCallCount++;
|
|
14594
14772
|
wereFunctionsCalled = false;
|
|
14595
14773
|
}
|
|
14596
|
-
const transformedParams = yield __await(models.
|
|
14774
|
+
const transformedParams = yield __await(models.processParamsMaybeAddMcpUsage(params));
|
|
14597
14775
|
const response = yield __await(models.generateContentStreamInternal(transformedParams));
|
|
14598
14776
|
const functionResponses = [];
|
|
14599
14777
|
const responseContents = [];
|
|
@@ -15131,7 +15309,13 @@ class Models extends BaseModule {
|
|
|
15131
15309
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
15132
15310
|
})
|
|
15133
15311
|
.then((httpResponse) => {
|
|
15134
|
-
return httpResponse.json()
|
|
15312
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
15313
|
+
const response = jsonResponse;
|
|
15314
|
+
response.sdkHttpResponse = {
|
|
15315
|
+
headers: httpResponse.headers,
|
|
15316
|
+
};
|
|
15317
|
+
return response;
|
|
15318
|
+
});
|
|
15135
15319
|
});
|
|
15136
15320
|
return response.then((apiResponse) => {
|
|
15137
15321
|
const resp = listModelsResponseFromVertex(apiResponse);
|
|
@@ -15157,7 +15341,13 @@ class Models extends BaseModule {
|
|
|
15157
15341
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
15158
15342
|
})
|
|
15159
15343
|
.then((httpResponse) => {
|
|
15160
|
-
return httpResponse.json()
|
|
15344
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
15345
|
+
const response = jsonResponse;
|
|
15346
|
+
response.sdkHttpResponse = {
|
|
15347
|
+
headers: httpResponse.headers,
|
|
15348
|
+
};
|
|
15349
|
+
return response;
|
|
15350
|
+
});
|
|
15161
15351
|
});
|
|
15162
15352
|
return response.then((apiResponse) => {
|
|
15163
15353
|
const resp = listModelsResponseFromMldev(apiResponse);
|
|
@@ -15457,7 +15647,7 @@ class Models extends BaseModule {
|
|
|
15457
15647
|
* console.log(operation.response?.generatedVideos?.[0]?.video?.uri);
|
|
15458
15648
|
* ```
|
|
15459
15649
|
*/
|
|
15460
|
-
async
|
|
15650
|
+
async generateVideosInternal(params) {
|
|
15461
15651
|
var _a, _b, _c, _d;
|
|
15462
15652
|
let response;
|
|
15463
15653
|
let path = '';
|
|
@@ -15482,8 +15672,10 @@ class Models extends BaseModule {
|
|
|
15482
15672
|
return httpResponse.json();
|
|
15483
15673
|
});
|
|
15484
15674
|
return response.then((apiResponse) => {
|
|
15485
|
-
const resp = generateVideosOperationFromVertex
|
|
15486
|
-
|
|
15675
|
+
const resp = generateVideosOperationFromVertex(apiResponse);
|
|
15676
|
+
const typedResp = new GenerateVideosOperation();
|
|
15677
|
+
Object.assign(typedResp, resp);
|
|
15678
|
+
return typedResp;
|
|
15487
15679
|
});
|
|
15488
15680
|
}
|
|
15489
15681
|
else {
|
|
@@ -15506,8 +15698,10 @@ class Models extends BaseModule {
|
|
|
15506
15698
|
return httpResponse.json();
|
|
15507
15699
|
});
|
|
15508
15700
|
return response.then((apiResponse) => {
|
|
15509
|
-
const resp = generateVideosOperationFromMldev
|
|
15510
|
-
|
|
15701
|
+
const resp = generateVideosOperationFromMldev(apiResponse);
|
|
15702
|
+
const typedResp = new GenerateVideosOperation();
|
|
15703
|
+
Object.assign(typedResp, resp);
|
|
15704
|
+
return typedResp;
|
|
15511
15705
|
});
|
|
15512
15706
|
}
|
|
15513
15707
|
}
|
|
@@ -15565,164 +15759,6 @@ function fetchPredictOperationParametersToVertex(fromObject) {
|
|
|
15565
15759
|
}
|
|
15566
15760
|
return toObject;
|
|
15567
15761
|
}
|
|
15568
|
-
function videoFromMldev(fromObject) {
|
|
15569
|
-
const toObject = {};
|
|
15570
|
-
const fromUri = getValueByPath(fromObject, ['video', 'uri']);
|
|
15571
|
-
if (fromUri != null) {
|
|
15572
|
-
setValueByPath(toObject, ['uri'], fromUri);
|
|
15573
|
-
}
|
|
15574
|
-
const fromVideoBytes = getValueByPath(fromObject, [
|
|
15575
|
-
'video',
|
|
15576
|
-
'encodedVideo',
|
|
15577
|
-
]);
|
|
15578
|
-
if (fromVideoBytes != null) {
|
|
15579
|
-
setValueByPath(toObject, ['videoBytes'], tBytes(fromVideoBytes));
|
|
15580
|
-
}
|
|
15581
|
-
const fromMimeType = getValueByPath(fromObject, ['encoding']);
|
|
15582
|
-
if (fromMimeType != null) {
|
|
15583
|
-
setValueByPath(toObject, ['mimeType'], fromMimeType);
|
|
15584
|
-
}
|
|
15585
|
-
return toObject;
|
|
15586
|
-
}
|
|
15587
|
-
function generatedVideoFromMldev(fromObject) {
|
|
15588
|
-
const toObject = {};
|
|
15589
|
-
const fromVideo = getValueByPath(fromObject, ['_self']);
|
|
15590
|
-
if (fromVideo != null) {
|
|
15591
|
-
setValueByPath(toObject, ['video'], videoFromMldev(fromVideo));
|
|
15592
|
-
}
|
|
15593
|
-
return toObject;
|
|
15594
|
-
}
|
|
15595
|
-
function generateVideosResponseFromMldev(fromObject) {
|
|
15596
|
-
const toObject = {};
|
|
15597
|
-
const fromGeneratedVideos = getValueByPath(fromObject, [
|
|
15598
|
-
'generatedSamples',
|
|
15599
|
-
]);
|
|
15600
|
-
if (fromGeneratedVideos != null) {
|
|
15601
|
-
let transformedList = fromGeneratedVideos;
|
|
15602
|
-
if (Array.isArray(transformedList)) {
|
|
15603
|
-
transformedList = transformedList.map((item) => {
|
|
15604
|
-
return generatedVideoFromMldev(item);
|
|
15605
|
-
});
|
|
15606
|
-
}
|
|
15607
|
-
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
15608
|
-
}
|
|
15609
|
-
const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
|
|
15610
|
-
'raiMediaFilteredCount',
|
|
15611
|
-
]);
|
|
15612
|
-
if (fromRaiMediaFilteredCount != null) {
|
|
15613
|
-
setValueByPath(toObject, ['raiMediaFilteredCount'], fromRaiMediaFilteredCount);
|
|
15614
|
-
}
|
|
15615
|
-
const fromRaiMediaFilteredReasons = getValueByPath(fromObject, [
|
|
15616
|
-
'raiMediaFilteredReasons',
|
|
15617
|
-
]);
|
|
15618
|
-
if (fromRaiMediaFilteredReasons != null) {
|
|
15619
|
-
setValueByPath(toObject, ['raiMediaFilteredReasons'], fromRaiMediaFilteredReasons);
|
|
15620
|
-
}
|
|
15621
|
-
return toObject;
|
|
15622
|
-
}
|
|
15623
|
-
function generateVideosOperationFromMldev(fromObject) {
|
|
15624
|
-
const toObject = {};
|
|
15625
|
-
const fromName = getValueByPath(fromObject, ['name']);
|
|
15626
|
-
if (fromName != null) {
|
|
15627
|
-
setValueByPath(toObject, ['name'], fromName);
|
|
15628
|
-
}
|
|
15629
|
-
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
15630
|
-
if (fromMetadata != null) {
|
|
15631
|
-
setValueByPath(toObject, ['metadata'], fromMetadata);
|
|
15632
|
-
}
|
|
15633
|
-
const fromDone = getValueByPath(fromObject, ['done']);
|
|
15634
|
-
if (fromDone != null) {
|
|
15635
|
-
setValueByPath(toObject, ['done'], fromDone);
|
|
15636
|
-
}
|
|
15637
|
-
const fromError = getValueByPath(fromObject, ['error']);
|
|
15638
|
-
if (fromError != null) {
|
|
15639
|
-
setValueByPath(toObject, ['error'], fromError);
|
|
15640
|
-
}
|
|
15641
|
-
const fromResponse = getValueByPath(fromObject, [
|
|
15642
|
-
'response',
|
|
15643
|
-
'generateVideoResponse',
|
|
15644
|
-
]);
|
|
15645
|
-
if (fromResponse != null) {
|
|
15646
|
-
setValueByPath(toObject, ['response'], generateVideosResponseFromMldev(fromResponse));
|
|
15647
|
-
}
|
|
15648
|
-
return toObject;
|
|
15649
|
-
}
|
|
15650
|
-
function videoFromVertex(fromObject) {
|
|
15651
|
-
const toObject = {};
|
|
15652
|
-
const fromUri = getValueByPath(fromObject, ['gcsUri']);
|
|
15653
|
-
if (fromUri != null) {
|
|
15654
|
-
setValueByPath(toObject, ['uri'], fromUri);
|
|
15655
|
-
}
|
|
15656
|
-
const fromVideoBytes = getValueByPath(fromObject, [
|
|
15657
|
-
'bytesBase64Encoded',
|
|
15658
|
-
]);
|
|
15659
|
-
if (fromVideoBytes != null) {
|
|
15660
|
-
setValueByPath(toObject, ['videoBytes'], tBytes(fromVideoBytes));
|
|
15661
|
-
}
|
|
15662
|
-
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
15663
|
-
if (fromMimeType != null) {
|
|
15664
|
-
setValueByPath(toObject, ['mimeType'], fromMimeType);
|
|
15665
|
-
}
|
|
15666
|
-
return toObject;
|
|
15667
|
-
}
|
|
15668
|
-
function generatedVideoFromVertex(fromObject) {
|
|
15669
|
-
const toObject = {};
|
|
15670
|
-
const fromVideo = getValueByPath(fromObject, ['_self']);
|
|
15671
|
-
if (fromVideo != null) {
|
|
15672
|
-
setValueByPath(toObject, ['video'], videoFromVertex(fromVideo));
|
|
15673
|
-
}
|
|
15674
|
-
return toObject;
|
|
15675
|
-
}
|
|
15676
|
-
function generateVideosResponseFromVertex(fromObject) {
|
|
15677
|
-
const toObject = {};
|
|
15678
|
-
const fromGeneratedVideos = getValueByPath(fromObject, ['videos']);
|
|
15679
|
-
if (fromGeneratedVideos != null) {
|
|
15680
|
-
let transformedList = fromGeneratedVideos;
|
|
15681
|
-
if (Array.isArray(transformedList)) {
|
|
15682
|
-
transformedList = transformedList.map((item) => {
|
|
15683
|
-
return generatedVideoFromVertex(item);
|
|
15684
|
-
});
|
|
15685
|
-
}
|
|
15686
|
-
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
15687
|
-
}
|
|
15688
|
-
const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
|
|
15689
|
-
'raiMediaFilteredCount',
|
|
15690
|
-
]);
|
|
15691
|
-
if (fromRaiMediaFilteredCount != null) {
|
|
15692
|
-
setValueByPath(toObject, ['raiMediaFilteredCount'], fromRaiMediaFilteredCount);
|
|
15693
|
-
}
|
|
15694
|
-
const fromRaiMediaFilteredReasons = getValueByPath(fromObject, [
|
|
15695
|
-
'raiMediaFilteredReasons',
|
|
15696
|
-
]);
|
|
15697
|
-
if (fromRaiMediaFilteredReasons != null) {
|
|
15698
|
-
setValueByPath(toObject, ['raiMediaFilteredReasons'], fromRaiMediaFilteredReasons);
|
|
15699
|
-
}
|
|
15700
|
-
return toObject;
|
|
15701
|
-
}
|
|
15702
|
-
function generateVideosOperationFromVertex(fromObject) {
|
|
15703
|
-
const toObject = {};
|
|
15704
|
-
const fromName = getValueByPath(fromObject, ['name']);
|
|
15705
|
-
if (fromName != null) {
|
|
15706
|
-
setValueByPath(toObject, ['name'], fromName);
|
|
15707
|
-
}
|
|
15708
|
-
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
15709
|
-
if (fromMetadata != null) {
|
|
15710
|
-
setValueByPath(toObject, ['metadata'], fromMetadata);
|
|
15711
|
-
}
|
|
15712
|
-
const fromDone = getValueByPath(fromObject, ['done']);
|
|
15713
|
-
if (fromDone != null) {
|
|
15714
|
-
setValueByPath(toObject, ['done'], fromDone);
|
|
15715
|
-
}
|
|
15716
|
-
const fromError = getValueByPath(fromObject, ['error']);
|
|
15717
|
-
if (fromError != null) {
|
|
15718
|
-
setValueByPath(toObject, ['error'], fromError);
|
|
15719
|
-
}
|
|
15720
|
-
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
15721
|
-
if (fromResponse != null) {
|
|
15722
|
-
setValueByPath(toObject, ['response'], generateVideosResponseFromVertex(fromResponse));
|
|
15723
|
-
}
|
|
15724
|
-
return toObject;
|
|
15725
|
-
}
|
|
15726
15762
|
|
|
15727
15763
|
/**
|
|
15728
15764
|
* @license
|
|
@@ -15752,17 +15788,64 @@ class Operations extends BaseModule {
|
|
|
15752
15788
|
if (config && 'httpOptions' in config) {
|
|
15753
15789
|
httpOptions = config.httpOptions;
|
|
15754
15790
|
}
|
|
15755
|
-
|
|
15791
|
+
const rawOperation = await this.fetchPredictVideosOperationInternal({
|
|
15792
|
+
operationName: operation.name,
|
|
15793
|
+
resourceName: resourceName,
|
|
15794
|
+
config: { httpOptions: httpOptions },
|
|
15795
|
+
});
|
|
15796
|
+
return operation._fromAPIResponse({
|
|
15797
|
+
apiResponse: rawOperation,
|
|
15798
|
+
isVertexAI: true,
|
|
15799
|
+
});
|
|
15800
|
+
}
|
|
15801
|
+
else {
|
|
15802
|
+
const rawOperation = await this.getVideosOperationInternal({
|
|
15803
|
+
operationName: operation.name,
|
|
15804
|
+
config: config,
|
|
15805
|
+
});
|
|
15806
|
+
return operation._fromAPIResponse({
|
|
15807
|
+
apiResponse: rawOperation,
|
|
15808
|
+
isVertexAI: false,
|
|
15809
|
+
});
|
|
15810
|
+
}
|
|
15811
|
+
}
|
|
15812
|
+
/**
|
|
15813
|
+
* Gets the status of a long-running operation.
|
|
15814
|
+
*
|
|
15815
|
+
* @param parameters The parameters for the get operation request.
|
|
15816
|
+
* @return The updated Operation object, with the latest status or result.
|
|
15817
|
+
*/
|
|
15818
|
+
async get(parameters) {
|
|
15819
|
+
const operation = parameters.operation;
|
|
15820
|
+
const config = parameters.config;
|
|
15821
|
+
if (operation.name === undefined || operation.name === '') {
|
|
15822
|
+
throw new Error('Operation name is required.');
|
|
15823
|
+
}
|
|
15824
|
+
if (this.apiClient.isVertexAI()) {
|
|
15825
|
+
const resourceName = operation.name.split('/operations/')[0];
|
|
15826
|
+
let httpOptions = undefined;
|
|
15827
|
+
if (config && 'httpOptions' in config) {
|
|
15828
|
+
httpOptions = config.httpOptions;
|
|
15829
|
+
}
|
|
15830
|
+
const rawOperation = await this.fetchPredictVideosOperationInternal({
|
|
15756
15831
|
operationName: operation.name,
|
|
15757
15832
|
resourceName: resourceName,
|
|
15758
15833
|
config: { httpOptions: httpOptions },
|
|
15759
15834
|
});
|
|
15835
|
+
return operation._fromAPIResponse({
|
|
15836
|
+
apiResponse: rawOperation,
|
|
15837
|
+
isVertexAI: true,
|
|
15838
|
+
});
|
|
15760
15839
|
}
|
|
15761
15840
|
else {
|
|
15762
|
-
|
|
15841
|
+
const rawOperation = await this.getVideosOperationInternal({
|
|
15763
15842
|
operationName: operation.name,
|
|
15764
15843
|
config: config,
|
|
15765
15844
|
});
|
|
15845
|
+
return operation._fromAPIResponse({
|
|
15846
|
+
apiResponse: rawOperation,
|
|
15847
|
+
isVertexAI: false,
|
|
15848
|
+
});
|
|
15766
15849
|
}
|
|
15767
15850
|
}
|
|
15768
15851
|
async getVideosOperationInternal(params) {
|
|
@@ -15789,10 +15872,7 @@ class Operations extends BaseModule {
|
|
|
15789
15872
|
.then((httpResponse) => {
|
|
15790
15873
|
return httpResponse.json();
|
|
15791
15874
|
});
|
|
15792
|
-
return response
|
|
15793
|
-
const resp = generateVideosOperationFromVertex(apiResponse);
|
|
15794
|
-
return resp;
|
|
15795
|
-
});
|
|
15875
|
+
return response;
|
|
15796
15876
|
}
|
|
15797
15877
|
else {
|
|
15798
15878
|
const body = getOperationParametersToMldev(params);
|
|
@@ -15813,10 +15893,7 @@ class Operations extends BaseModule {
|
|
|
15813
15893
|
.then((httpResponse) => {
|
|
15814
15894
|
return httpResponse.json();
|
|
15815
15895
|
});
|
|
15816
|
-
return response
|
|
15817
|
-
const resp = generateVideosOperationFromMldev(apiResponse);
|
|
15818
|
-
return resp;
|
|
15819
|
-
});
|
|
15896
|
+
return response;
|
|
15820
15897
|
}
|
|
15821
15898
|
}
|
|
15822
15899
|
async fetchPredictVideosOperationInternal(params) {
|
|
@@ -15843,10 +15920,7 @@ class Operations extends BaseModule {
|
|
|
15843
15920
|
.then((httpResponse) => {
|
|
15844
15921
|
return httpResponse.json();
|
|
15845
15922
|
});
|
|
15846
|
-
return response
|
|
15847
|
-
const resp = generateVideosOperationFromVertex(apiResponse);
|
|
15848
|
-
return resp;
|
|
15849
|
-
});
|
|
15923
|
+
return response;
|
|
15850
15924
|
}
|
|
15851
15925
|
else {
|
|
15852
15926
|
throw new Error('This method is only supported by the Vertex AI.');
|
|
@@ -17073,6 +17147,12 @@ function tuningJobFromMldev(fromObject) {
|
|
|
17073
17147
|
}
|
|
17074
17148
|
function listTuningJobsResponseFromMldev(fromObject) {
|
|
17075
17149
|
const toObject = {};
|
|
17150
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
17151
|
+
'sdkHttpResponse',
|
|
17152
|
+
]);
|
|
17153
|
+
if (fromSdkHttpResponse != null) {
|
|
17154
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
17155
|
+
}
|
|
17076
17156
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
17077
17157
|
'nextPageToken',
|
|
17078
17158
|
]);
|
|
@@ -17261,6 +17341,12 @@ function tuningJobFromVertex(fromObject) {
|
|
|
17261
17341
|
}
|
|
17262
17342
|
function listTuningJobsResponseFromVertex(fromObject) {
|
|
17263
17343
|
const toObject = {};
|
|
17344
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
17345
|
+
'sdkHttpResponse',
|
|
17346
|
+
]);
|
|
17347
|
+
if (fromSdkHttpResponse != null) {
|
|
17348
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
17349
|
+
}
|
|
17264
17350
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
17265
17351
|
'nextPageToken',
|
|
17266
17352
|
]);
|
|
@@ -17421,7 +17507,13 @@ class Tunings extends BaseModule {
|
|
|
17421
17507
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
17422
17508
|
})
|
|
17423
17509
|
.then((httpResponse) => {
|
|
17424
|
-
return httpResponse.json()
|
|
17510
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
17511
|
+
const response = jsonResponse;
|
|
17512
|
+
response.sdkHttpResponse = {
|
|
17513
|
+
headers: httpResponse.headers,
|
|
17514
|
+
};
|
|
17515
|
+
return response;
|
|
17516
|
+
});
|
|
17425
17517
|
});
|
|
17426
17518
|
return response.then((apiResponse) => {
|
|
17427
17519
|
const resp = listTuningJobsResponseFromVertex(apiResponse);
|
|
@@ -17447,7 +17539,13 @@ class Tunings extends BaseModule {
|
|
|
17447
17539
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
17448
17540
|
})
|
|
17449
17541
|
.then((httpResponse) => {
|
|
17450
|
-
return httpResponse.json()
|
|
17542
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
17543
|
+
const response = jsonResponse;
|
|
17544
|
+
response.sdkHttpResponse = {
|
|
17545
|
+
headers: httpResponse.headers,
|
|
17546
|
+
};
|
|
17547
|
+
return response;
|
|
17548
|
+
});
|
|
17451
17549
|
});
|
|
17452
17550
|
return response.then((apiResponse) => {
|
|
17453
17551
|
const resp = listTuningJobsResponseFromMldev(apiResponse);
|
|
@@ -17738,7 +17836,7 @@ class GoogleGenAI {
|
|
|
17738
17836
|
}
|
|
17739
17837
|
this.vertexai = (_a = options.vertexai) !== null && _a !== void 0 ? _a : false;
|
|
17740
17838
|
this.apiKey = options.apiKey;
|
|
17741
|
-
const baseUrl = getBaseUrl(options,
|
|
17839
|
+
const baseUrl = getBaseUrl(options.httpOptions, options.vertexai,
|
|
17742
17840
|
/*vertexBaseUrlFromEnv*/ undefined,
|
|
17743
17841
|
/*geminiBaseUrlFromEnv*/ undefined);
|
|
17744
17842
|
if (baseUrl) {
|
|
@@ -17773,5 +17871,5 @@ class GoogleGenAI {
|
|
|
17773
17871
|
}
|
|
17774
17872
|
}
|
|
17775
17873
|
|
|
17776
|
-
export { ActivityHandling, AdapterSize, ApiError, ApiSpec, AuthType, Batches, Behavior, BlockedReason, Caches, Chat, Chats, ComputeTokensResponse, ControlReferenceImage, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DeleteModelResponse, DynamicRetrievalConfigMode, EditImageResponse, EditMode, EmbedContentResponse, EndSensitivity, Environment, FeatureSelectionPreference, FileSource, FileState, Files, FinishReason, FunctionCallingConfigMode, FunctionResponse, FunctionResponseScheduling, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GenerateVideosResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpResponse, ImagePromptLanguage, InlinedResponse, JobState, Language, ListBatchJobsResponse, ListCachedContentsResponse, ListFilesResponse, ListModelsResponse, ListTuningJobsResponse, Live, LiveClientToolResponse, LiveMusicPlaybackControl, LiveMusicServerMessage, LiveSendToolResponseParameters, LiveServerMessage, MaskReferenceImage, MaskReferenceMode, MediaModality, MediaResolution, Modality, Mode, Models, Operations, Outcome, PagedItem, Pager, PersonGeneration, RawReferenceImage, ReplayResponse, SafetyFilterLevel, Scale, Session, StartSensitivity, StyleReferenceImage, SubjectReferenceImage, SubjectReferenceType, Tokens, TrafficType, TurnCoverage, Type, UpscaleImageResponse, UrlRetrievalStatus, VideoCompressionQuality, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent, mcpToTool, setDefaultBaseUrls };
|
|
17874
|
+
export { ActivityHandling, AdapterSize, ApiError, ApiSpec, AuthType, Batches, Behavior, BlockedReason, Caches, Chat, Chats, ComputeTokensResponse, ControlReferenceImage, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DeleteModelResponse, DynamicRetrievalConfigMode, EditImageResponse, EditMode, EmbedContentResponse, EndSensitivity, Environment, FeatureSelectionPreference, FileSource, FileState, Files, FinishReason, FunctionCallingConfigMode, FunctionResponse, FunctionResponseScheduling, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GenerateVideosOperation, GenerateVideosResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpResponse, ImagePromptLanguage, InlinedResponse, JobState, Language, ListBatchJobsResponse, ListCachedContentsResponse, ListFilesResponse, ListModelsResponse, ListTuningJobsResponse, Live, LiveClientToolResponse, LiveMusicPlaybackControl, LiveMusicServerMessage, LiveSendToolResponseParameters, LiveServerMessage, MaskReferenceImage, MaskReferenceMode, MediaModality, MediaResolution, Modality, Mode, Models, Operations, Outcome, PagedItem, Pager, PersonGeneration, RawReferenceImage, ReplayResponse, SafetyFilterLevel, Scale, Session, StartSensitivity, StyleReferenceImage, SubjectReferenceImage, SubjectReferenceType, Tokens, TrafficType, TurnCoverage, Type, UpscaleImageResponse, UrlRetrievalStatus, VideoCompressionQuality, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent, mcpToTool, setDefaultBaseUrls };
|
|
17777
17875
|
//# sourceMappingURL=index.mjs.map
|