@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/node/index.cjs
CHANGED
|
@@ -72,18 +72,18 @@ function getDefaultBaseUrls() {
|
|
|
72
72
|
* 2. Base URLs set via the latest call to setDefaultBaseUrls.
|
|
73
73
|
* 3. Base URLs set via environment variables.
|
|
74
74
|
*/
|
|
75
|
-
function getBaseUrl(
|
|
76
|
-
var _a, _b
|
|
77
|
-
if (!(
|
|
75
|
+
function getBaseUrl(httpOptions, vertexai, vertexBaseUrlFromEnv, geminiBaseUrlFromEnv) {
|
|
76
|
+
var _a, _b;
|
|
77
|
+
if (!(httpOptions === null || httpOptions === void 0 ? void 0 : httpOptions.baseUrl)) {
|
|
78
78
|
const defaultBaseUrls = getDefaultBaseUrls();
|
|
79
|
-
if (
|
|
80
|
-
return (
|
|
79
|
+
if (vertexai) {
|
|
80
|
+
return (_a = defaultBaseUrls.vertexUrl) !== null && _a !== void 0 ? _a : vertexBaseUrlFromEnv;
|
|
81
81
|
}
|
|
82
82
|
else {
|
|
83
|
-
return (
|
|
83
|
+
return (_b = defaultBaseUrls.geminiUrl) !== null && _b !== void 0 ? _b : geminiBaseUrlFromEnv;
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
|
-
return
|
|
86
|
+
return httpOptions.baseUrl;
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
/**
|
|
@@ -218,6 +218,20 @@ function getValueByPath(data, keys) {
|
|
|
218
218
|
* Copyright 2025 Google LLC
|
|
219
219
|
* SPDX-License-Identifier: Apache-2.0
|
|
220
220
|
*/
|
|
221
|
+
function tBytes$1(fromBytes) {
|
|
222
|
+
if (typeof fromBytes !== 'string') {
|
|
223
|
+
throw new Error('fromImageBytes must be a string');
|
|
224
|
+
}
|
|
225
|
+
// TODO(b/389133914): Remove dummy bytes converter.
|
|
226
|
+
return fromBytes;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* @license
|
|
231
|
+
* Copyright 2025 Google LLC
|
|
232
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
233
|
+
*/
|
|
234
|
+
// Code generated by the Google Gen AI SDK generator DO NOT EDIT.
|
|
221
235
|
/** Required. Outcome of the code execution. */
|
|
222
236
|
exports.Outcome = void 0;
|
|
223
237
|
(function (Outcome) {
|
|
@@ -1711,6 +1725,65 @@ class LiveServerMessage {
|
|
|
1711
1725
|
return data.length > 0 ? btoa(data) : undefined;
|
|
1712
1726
|
}
|
|
1713
1727
|
}
|
|
1728
|
+
/** A video generation long-running operation. */
|
|
1729
|
+
class GenerateVideosOperation {
|
|
1730
|
+
/**
|
|
1731
|
+
* Instantiates an Operation of the same type as the one being called with the fields set from the API response.
|
|
1732
|
+
* @internal
|
|
1733
|
+
*/
|
|
1734
|
+
_fromAPIResponse({ apiResponse, isVertexAI, }) {
|
|
1735
|
+
const operation = new GenerateVideosOperation();
|
|
1736
|
+
operation.name = apiResponse['name'];
|
|
1737
|
+
operation.metadata = apiResponse['metadata'];
|
|
1738
|
+
operation.done = apiResponse['done'];
|
|
1739
|
+
operation.error = apiResponse['error'];
|
|
1740
|
+
if (isVertexAI) {
|
|
1741
|
+
const response = apiResponse['response'];
|
|
1742
|
+
if (response) {
|
|
1743
|
+
const operationResponse = new GenerateVideosResponse();
|
|
1744
|
+
const responseVideos = response['videos'];
|
|
1745
|
+
operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
|
|
1746
|
+
return {
|
|
1747
|
+
video: {
|
|
1748
|
+
uri: generatedVideo['gcsUri'],
|
|
1749
|
+
videoBytes: generatedVideo['bytesBase64Encoded']
|
|
1750
|
+
? tBytes$1(generatedVideo['bytesBase64Encoded'])
|
|
1751
|
+
: undefined,
|
|
1752
|
+
mimeType: generatedVideo['mimeType'],
|
|
1753
|
+
},
|
|
1754
|
+
};
|
|
1755
|
+
});
|
|
1756
|
+
operationResponse.raiMediaFilteredCount = response['raiMediaFilteredCount'];
|
|
1757
|
+
operationResponse.raiMediaFilteredReasons = response['raiMediaFilteredReasons'];
|
|
1758
|
+
operation.response = operationResponse;
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
else {
|
|
1762
|
+
const response = apiResponse['response'];
|
|
1763
|
+
if (response) {
|
|
1764
|
+
const operationResponse = new GenerateVideosResponse();
|
|
1765
|
+
const generatedVideoResponse = response['generateVideoResponse'];
|
|
1766
|
+
const responseVideos = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['generatedSamples'];
|
|
1767
|
+
operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
|
|
1768
|
+
const video = generatedVideo['video'];
|
|
1769
|
+
return {
|
|
1770
|
+
video: {
|
|
1771
|
+
uri: video === null || video === void 0 ? void 0 : video['uri'],
|
|
1772
|
+
videoBytes: (video === null || video === void 0 ? void 0 : video['encodedVideo'])
|
|
1773
|
+
? tBytes$1(video === null || video === void 0 ? void 0 : video['encodedVideo'])
|
|
1774
|
+
: undefined,
|
|
1775
|
+
mimeType: generatedVideo['encoding'],
|
|
1776
|
+
},
|
|
1777
|
+
};
|
|
1778
|
+
});
|
|
1779
|
+
operationResponse.raiMediaFilteredCount = response['raiMediaFilteredCount'];
|
|
1780
|
+
operationResponse.raiMediaFilteredReasons = response['raiMediaFilteredReasons'];
|
|
1781
|
+
operation.response = operationResponse;
|
|
1782
|
+
}
|
|
1783
|
+
}
|
|
1784
|
+
return operation;
|
|
1785
|
+
}
|
|
1786
|
+
}
|
|
1714
1787
|
/** Client generated response to a `ToolCall` received from the server.
|
|
1715
1788
|
|
|
1716
1789
|
Individual `FunctionResponse` objects are matched to the respective
|
|
@@ -2272,11 +2345,7 @@ function tTuningJobStatus(status) {
|
|
|
2272
2345
|
}
|
|
2273
2346
|
}
|
|
2274
2347
|
function tBytes(fromImageBytes) {
|
|
2275
|
-
|
|
2276
|
-
throw new Error('fromImageBytes must be a string');
|
|
2277
|
-
}
|
|
2278
|
-
// TODO(b/389133914): Remove dummy bytes converter.
|
|
2279
|
-
return fromImageBytes;
|
|
2348
|
+
return tBytes$1(fromImageBytes);
|
|
2280
2349
|
}
|
|
2281
2350
|
function _isFile(origin) {
|
|
2282
2351
|
return (origin !== null &&
|
|
@@ -3764,6 +3833,12 @@ function batchJobFromMldev(fromObject) {
|
|
|
3764
3833
|
}
|
|
3765
3834
|
function listBatchJobsResponseFromMldev(fromObject) {
|
|
3766
3835
|
const toObject = {};
|
|
3836
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
3837
|
+
'sdkHttpResponse',
|
|
3838
|
+
]);
|
|
3839
|
+
if (fromSdkHttpResponse != null) {
|
|
3840
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
3841
|
+
}
|
|
3767
3842
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
3768
3843
|
'nextPageToken',
|
|
3769
3844
|
]);
|
|
@@ -3905,6 +3980,12 @@ function batchJobFromVertex(fromObject) {
|
|
|
3905
3980
|
}
|
|
3906
3981
|
function listBatchJobsResponseFromVertex(fromObject) {
|
|
3907
3982
|
const toObject = {};
|
|
3983
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
3984
|
+
'sdkHttpResponse',
|
|
3985
|
+
]);
|
|
3986
|
+
if (fromSdkHttpResponse != null) {
|
|
3987
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
3988
|
+
}
|
|
3908
3989
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
3909
3990
|
'nextPageToken',
|
|
3910
3991
|
]);
|
|
@@ -3947,9 +4028,6 @@ function deleteResourceJobFromVertex(fromObject) {
|
|
|
3947
4028
|
* Copyright 2025 Google LLC
|
|
3948
4029
|
* SPDX-License-Identifier: Apache-2.0
|
|
3949
4030
|
*/
|
|
3950
|
-
/**
|
|
3951
|
-
* Pagers for the GenAI List APIs.
|
|
3952
|
-
*/
|
|
3953
4031
|
exports.PagedItem = void 0;
|
|
3954
4032
|
(function (PagedItem) {
|
|
3955
4033
|
PagedItem["PAGED_ITEM_BATCH_JOBS"] = "batchJobs";
|
|
@@ -3972,9 +4050,10 @@ class Pager {
|
|
|
3972
4050
|
var _a, _b;
|
|
3973
4051
|
this.nameInternal = name;
|
|
3974
4052
|
this.pageInternal = response[this.nameInternal] || [];
|
|
4053
|
+
this.sdkHttpResponseInternal = response === null || response === void 0 ? void 0 : response.sdkHttpResponse;
|
|
3975
4054
|
this.idxInternal = 0;
|
|
3976
4055
|
let requestParams = { config: {} };
|
|
3977
|
-
if (!params) {
|
|
4056
|
+
if (!params || Object.keys(params).length === 0) {
|
|
3978
4057
|
requestParams = { config: {} };
|
|
3979
4058
|
}
|
|
3980
4059
|
else if (typeof params === 'object') {
|
|
@@ -4018,6 +4097,12 @@ class Pager {
|
|
|
4018
4097
|
get pageSize() {
|
|
4019
4098
|
return this.pageInternalSize;
|
|
4020
4099
|
}
|
|
4100
|
+
/**
|
|
4101
|
+
* Returns the headers of the API response.
|
|
4102
|
+
*/
|
|
4103
|
+
get sdkHttpResponse() {
|
|
4104
|
+
return this.sdkHttpResponseInternal;
|
|
4105
|
+
}
|
|
4021
4106
|
/**
|
|
4022
4107
|
* Returns the parameters when making the API request for the next page.
|
|
4023
4108
|
*
|
|
@@ -4387,7 +4472,13 @@ class Batches extends BaseModule {
|
|
|
4387
4472
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
4388
4473
|
})
|
|
4389
4474
|
.then((httpResponse) => {
|
|
4390
|
-
return httpResponse.json()
|
|
4475
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
4476
|
+
const response = jsonResponse;
|
|
4477
|
+
response.sdkHttpResponse = {
|
|
4478
|
+
headers: httpResponse.headers,
|
|
4479
|
+
};
|
|
4480
|
+
return response;
|
|
4481
|
+
});
|
|
4391
4482
|
});
|
|
4392
4483
|
return response.then((apiResponse) => {
|
|
4393
4484
|
const resp = listBatchJobsResponseFromVertex(apiResponse);
|
|
@@ -4413,7 +4504,13 @@ class Batches extends BaseModule {
|
|
|
4413
4504
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
4414
4505
|
})
|
|
4415
4506
|
.then((httpResponse) => {
|
|
4416
|
-
return httpResponse.json()
|
|
4507
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
4508
|
+
const response = jsonResponse;
|
|
4509
|
+
response.sdkHttpResponse = {
|
|
4510
|
+
headers: httpResponse.headers,
|
|
4511
|
+
};
|
|
4512
|
+
return response;
|
|
4513
|
+
});
|
|
4417
4514
|
});
|
|
4418
4515
|
return response.then((apiResponse) => {
|
|
4419
4516
|
const resp = listBatchJobsResponseFromMldev(apiResponse);
|
|
@@ -5466,6 +5563,12 @@ function deleteCachedContentResponseFromMldev() {
|
|
|
5466
5563
|
}
|
|
5467
5564
|
function listCachedContentsResponseFromMldev(fromObject) {
|
|
5468
5565
|
const toObject = {};
|
|
5566
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
5567
|
+
'sdkHttpResponse',
|
|
5568
|
+
]);
|
|
5569
|
+
if (fromSdkHttpResponse != null) {
|
|
5570
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
5571
|
+
}
|
|
5469
5572
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
5470
5573
|
'nextPageToken',
|
|
5471
5574
|
]);
|
|
@@ -5526,6 +5629,12 @@ function deleteCachedContentResponseFromVertex() {
|
|
|
5526
5629
|
}
|
|
5527
5630
|
function listCachedContentsResponseFromVertex(fromObject) {
|
|
5528
5631
|
const toObject = {};
|
|
5632
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
5633
|
+
'sdkHttpResponse',
|
|
5634
|
+
]);
|
|
5635
|
+
if (fromSdkHttpResponse != null) {
|
|
5636
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
5637
|
+
}
|
|
5529
5638
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
5530
5639
|
'nextPageToken',
|
|
5531
5640
|
]);
|
|
@@ -5878,7 +5987,13 @@ class Caches extends BaseModule {
|
|
|
5878
5987
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
5879
5988
|
})
|
|
5880
5989
|
.then((httpResponse) => {
|
|
5881
|
-
return httpResponse.json()
|
|
5990
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
5991
|
+
const response = jsonResponse;
|
|
5992
|
+
response.sdkHttpResponse = {
|
|
5993
|
+
headers: httpResponse.headers,
|
|
5994
|
+
};
|
|
5995
|
+
return response;
|
|
5996
|
+
});
|
|
5882
5997
|
});
|
|
5883
5998
|
return response.then((apiResponse) => {
|
|
5884
5999
|
const resp = listCachedContentsResponseFromVertex(apiResponse);
|
|
@@ -5904,7 +6019,13 @@ class Caches extends BaseModule {
|
|
|
5904
6019
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
5905
6020
|
})
|
|
5906
6021
|
.then((httpResponse) => {
|
|
5907
|
-
return httpResponse.json()
|
|
6022
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
6023
|
+
const response = jsonResponse;
|
|
6024
|
+
response.sdkHttpResponse = {
|
|
6025
|
+
headers: httpResponse.headers,
|
|
6026
|
+
};
|
|
6027
|
+
return response;
|
|
6028
|
+
});
|
|
5908
6029
|
});
|
|
5909
6030
|
return response.then((apiResponse) => {
|
|
5910
6031
|
const resp = listCachedContentsResponseFromMldev(apiResponse);
|
|
@@ -6542,6 +6663,12 @@ function fileFromMldev(fromObject) {
|
|
|
6542
6663
|
}
|
|
6543
6664
|
function listFilesResponseFromMldev(fromObject) {
|
|
6544
6665
|
const toObject = {};
|
|
6666
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
6667
|
+
'sdkHttpResponse',
|
|
6668
|
+
]);
|
|
6669
|
+
if (fromSdkHttpResponse != null) {
|
|
6670
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
6671
|
+
}
|
|
6545
6672
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
6546
6673
|
'nextPageToken',
|
|
6547
6674
|
]);
|
|
@@ -6703,7 +6830,13 @@ class Files extends BaseModule {
|
|
|
6703
6830
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
6704
6831
|
})
|
|
6705
6832
|
.then((httpResponse) => {
|
|
6706
|
-
return httpResponse.json()
|
|
6833
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
6834
|
+
const response = jsonResponse;
|
|
6835
|
+
response.sdkHttpResponse = {
|
|
6836
|
+
headers: httpResponse.headers,
|
|
6837
|
+
};
|
|
6838
|
+
return response;
|
|
6839
|
+
});
|
|
6707
6840
|
});
|
|
6708
6841
|
return response.then((apiResponse) => {
|
|
6709
6842
|
const resp = listFilesResponseFromMldev(apiResponse);
|
|
@@ -9929,6 +10062,9 @@ function generateImagesConfigToMldev(fromObject, parentObject) {
|
|
|
9929
10062
|
if (getValueByPath(fromObject, ['addWatermark']) !== undefined) {
|
|
9930
10063
|
throw new Error('addWatermark parameter is not supported in Gemini API.');
|
|
9931
10064
|
}
|
|
10065
|
+
if (getValueByPath(fromObject, ['imageSize']) !== undefined) {
|
|
10066
|
+
throw new Error('imageSize parameter is not supported in Gemini API.');
|
|
10067
|
+
}
|
|
9932
10068
|
if (getValueByPath(fromObject, ['enhancePrompt']) !== undefined) {
|
|
9933
10069
|
throw new Error('enhancePrompt parameter is not supported in Gemini API.');
|
|
9934
10070
|
}
|
|
@@ -11005,6 +11141,10 @@ function generateImagesConfigToVertex(fromObject, parentObject) {
|
|
|
11005
11141
|
if (parentObject !== undefined && fromAddWatermark != null) {
|
|
11006
11142
|
setValueByPath(parentObject, ['parameters', 'addWatermark'], fromAddWatermark);
|
|
11007
11143
|
}
|
|
11144
|
+
const fromImageSize = getValueByPath(fromObject, ['imageSize']);
|
|
11145
|
+
if (parentObject !== undefined && fromImageSize != null) {
|
|
11146
|
+
setValueByPath(parentObject, ['parameters', 'sampleImageSize'], fromImageSize);
|
|
11147
|
+
}
|
|
11008
11148
|
const fromEnhancePrompt = getValueByPath(fromObject, [
|
|
11009
11149
|
'enhancePrompt',
|
|
11010
11150
|
]);
|
|
@@ -11995,6 +12135,12 @@ function modelFromMldev(fromObject) {
|
|
|
11995
12135
|
}
|
|
11996
12136
|
function listModelsResponseFromMldev(fromObject) {
|
|
11997
12137
|
const toObject = {};
|
|
12138
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
12139
|
+
'sdkHttpResponse',
|
|
12140
|
+
]);
|
|
12141
|
+
if (fromSdkHttpResponse != null) {
|
|
12142
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
12143
|
+
}
|
|
11998
12144
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
11999
12145
|
'nextPageToken',
|
|
12000
12146
|
]);
|
|
@@ -12031,7 +12177,7 @@ function countTokensResponseFromMldev(fromObject) {
|
|
|
12031
12177
|
}
|
|
12032
12178
|
return toObject;
|
|
12033
12179
|
}
|
|
12034
|
-
function videoFromMldev
|
|
12180
|
+
function videoFromMldev(fromObject) {
|
|
12035
12181
|
const toObject = {};
|
|
12036
12182
|
const fromUri = getValueByPath(fromObject, ['video', 'uri']);
|
|
12037
12183
|
if (fromUri != null) {
|
|
@@ -12050,15 +12196,15 @@ function videoFromMldev$1(fromObject) {
|
|
|
12050
12196
|
}
|
|
12051
12197
|
return toObject;
|
|
12052
12198
|
}
|
|
12053
|
-
function generatedVideoFromMldev
|
|
12199
|
+
function generatedVideoFromMldev(fromObject) {
|
|
12054
12200
|
const toObject = {};
|
|
12055
12201
|
const fromVideo = getValueByPath(fromObject, ['_self']);
|
|
12056
12202
|
if (fromVideo != null) {
|
|
12057
|
-
setValueByPath(toObject, ['video'], videoFromMldev
|
|
12203
|
+
setValueByPath(toObject, ['video'], videoFromMldev(fromVideo));
|
|
12058
12204
|
}
|
|
12059
12205
|
return toObject;
|
|
12060
12206
|
}
|
|
12061
|
-
function generateVideosResponseFromMldev
|
|
12207
|
+
function generateVideosResponseFromMldev(fromObject) {
|
|
12062
12208
|
const toObject = {};
|
|
12063
12209
|
const fromGeneratedVideos = getValueByPath(fromObject, [
|
|
12064
12210
|
'generatedSamples',
|
|
@@ -12067,7 +12213,7 @@ function generateVideosResponseFromMldev$1(fromObject) {
|
|
|
12067
12213
|
let transformedList = fromGeneratedVideos;
|
|
12068
12214
|
if (Array.isArray(transformedList)) {
|
|
12069
12215
|
transformedList = transformedList.map((item) => {
|
|
12070
|
-
return generatedVideoFromMldev
|
|
12216
|
+
return generatedVideoFromMldev(item);
|
|
12071
12217
|
});
|
|
12072
12218
|
}
|
|
12073
12219
|
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
@@ -12086,7 +12232,7 @@ function generateVideosResponseFromMldev$1(fromObject) {
|
|
|
12086
12232
|
}
|
|
12087
12233
|
return toObject;
|
|
12088
12234
|
}
|
|
12089
|
-
function generateVideosOperationFromMldev
|
|
12235
|
+
function generateVideosOperationFromMldev(fromObject) {
|
|
12090
12236
|
const toObject = {};
|
|
12091
12237
|
const fromName = getValueByPath(fromObject, ['name']);
|
|
12092
12238
|
if (fromName != null) {
|
|
@@ -12109,7 +12255,7 @@ function generateVideosOperationFromMldev$1(fromObject) {
|
|
|
12109
12255
|
'generateVideoResponse',
|
|
12110
12256
|
]);
|
|
12111
12257
|
if (fromResponse != null) {
|
|
12112
|
-
setValueByPath(toObject, ['response'], generateVideosResponseFromMldev
|
|
12258
|
+
setValueByPath(toObject, ['response'], generateVideosResponseFromMldev(fromResponse));
|
|
12113
12259
|
}
|
|
12114
12260
|
return toObject;
|
|
12115
12261
|
}
|
|
@@ -12645,6 +12791,12 @@ function modelFromVertex(fromObject) {
|
|
|
12645
12791
|
}
|
|
12646
12792
|
function listModelsResponseFromVertex(fromObject) {
|
|
12647
12793
|
const toObject = {};
|
|
12794
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
12795
|
+
'sdkHttpResponse',
|
|
12796
|
+
]);
|
|
12797
|
+
if (fromSdkHttpResponse != null) {
|
|
12798
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
12799
|
+
}
|
|
12648
12800
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
12649
12801
|
'nextPageToken',
|
|
12650
12802
|
]);
|
|
@@ -12683,7 +12835,7 @@ function computeTokensResponseFromVertex(fromObject) {
|
|
|
12683
12835
|
}
|
|
12684
12836
|
return toObject;
|
|
12685
12837
|
}
|
|
12686
|
-
function videoFromVertex
|
|
12838
|
+
function videoFromVertex(fromObject) {
|
|
12687
12839
|
const toObject = {};
|
|
12688
12840
|
const fromUri = getValueByPath(fromObject, ['gcsUri']);
|
|
12689
12841
|
if (fromUri != null) {
|
|
@@ -12701,22 +12853,22 @@ function videoFromVertex$1(fromObject) {
|
|
|
12701
12853
|
}
|
|
12702
12854
|
return toObject;
|
|
12703
12855
|
}
|
|
12704
|
-
function generatedVideoFromVertex
|
|
12856
|
+
function generatedVideoFromVertex(fromObject) {
|
|
12705
12857
|
const toObject = {};
|
|
12706
12858
|
const fromVideo = getValueByPath(fromObject, ['_self']);
|
|
12707
12859
|
if (fromVideo != null) {
|
|
12708
|
-
setValueByPath(toObject, ['video'], videoFromVertex
|
|
12860
|
+
setValueByPath(toObject, ['video'], videoFromVertex(fromVideo));
|
|
12709
12861
|
}
|
|
12710
12862
|
return toObject;
|
|
12711
12863
|
}
|
|
12712
|
-
function generateVideosResponseFromVertex
|
|
12864
|
+
function generateVideosResponseFromVertex(fromObject) {
|
|
12713
12865
|
const toObject = {};
|
|
12714
12866
|
const fromGeneratedVideos = getValueByPath(fromObject, ['videos']);
|
|
12715
12867
|
if (fromGeneratedVideos != null) {
|
|
12716
12868
|
let transformedList = fromGeneratedVideos;
|
|
12717
12869
|
if (Array.isArray(transformedList)) {
|
|
12718
12870
|
transformedList = transformedList.map((item) => {
|
|
12719
|
-
return generatedVideoFromVertex
|
|
12871
|
+
return generatedVideoFromVertex(item);
|
|
12720
12872
|
});
|
|
12721
12873
|
}
|
|
12722
12874
|
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
@@ -12735,7 +12887,7 @@ function generateVideosResponseFromVertex$1(fromObject) {
|
|
|
12735
12887
|
}
|
|
12736
12888
|
return toObject;
|
|
12737
12889
|
}
|
|
12738
|
-
function generateVideosOperationFromVertex
|
|
12890
|
+
function generateVideosOperationFromVertex(fromObject) {
|
|
12739
12891
|
const toObject = {};
|
|
12740
12892
|
const fromName = getValueByPath(fromObject, ['name']);
|
|
12741
12893
|
if (fromName != null) {
|
|
@@ -12755,7 +12907,7 @@ function generateVideosOperationFromVertex$1(fromObject) {
|
|
|
12755
12907
|
}
|
|
12756
12908
|
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
12757
12909
|
if (fromResponse != null) {
|
|
12758
|
-
setValueByPath(toObject, ['response'], generateVideosResponseFromVertex
|
|
12910
|
+
setValueByPath(toObject, ['response'], generateVideosResponseFromVertex(fromResponse));
|
|
12759
12911
|
}
|
|
12760
12912
|
return toObject;
|
|
12761
12913
|
}
|
|
@@ -12769,7 +12921,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
12769
12921
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
12770
12922
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
12771
12923
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
12772
|
-
const SDK_VERSION = '1.
|
|
12924
|
+
const SDK_VERSION = '1.11.0'; // x-release-please-version
|
|
12773
12925
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
12774
12926
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
12775
12927
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -13362,18 +13514,6 @@ function setMcpUsageHeader(headers) {
|
|
|
13362
13514
|
const existingHeader = (_a = headers[GOOGLE_API_CLIENT_HEADER]) !== null && _a !== void 0 ? _a : '';
|
|
13363
13515
|
headers[GOOGLE_API_CLIENT_HEADER] = (existingHeader + ` ${MCP_LABEL}`).trimStart();
|
|
13364
13516
|
}
|
|
13365
|
-
// Checks whether the list of tools contains any MCP clients. Will return true
|
|
13366
|
-
// if there is at least one MCP client.
|
|
13367
|
-
function hasMcpClientTools(params) {
|
|
13368
|
-
var _a, _b, _c;
|
|
13369
|
-
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;
|
|
13370
|
-
}
|
|
13371
|
-
// Checks whether the list of tools contains any non-MCP tools. Will return true
|
|
13372
|
-
// if there is at least one non-MCP tool.
|
|
13373
|
-
function hasNonMcpTools(params) {
|
|
13374
|
-
var _a, _b, _c;
|
|
13375
|
-
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);
|
|
13376
|
-
}
|
|
13377
13517
|
// Returns true if the object is a MCP CallableTool, otherwise false.
|
|
13378
13518
|
function isMcpCallableTool(object) {
|
|
13379
13519
|
return (object !== null &&
|
|
@@ -14232,6 +14372,18 @@ function shouldDisableAfc(config) {
|
|
|
14232
14372
|
function isCallableTool(tool) {
|
|
14233
14373
|
return 'callTool' in tool && typeof tool.callTool === 'function';
|
|
14234
14374
|
}
|
|
14375
|
+
// Checks whether the list of tools contains any CallableTools. Will return true
|
|
14376
|
+
// if there is at least one CallableTool.
|
|
14377
|
+
function hasCallableTools(params) {
|
|
14378
|
+
var _a, _b, _c;
|
|
14379
|
+
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;
|
|
14380
|
+
}
|
|
14381
|
+
// Checks whether the list of tools contains any non-callable tools. Will return
|
|
14382
|
+
// true if there is at least one non-Callable tool.
|
|
14383
|
+
function hasNonCallableTools(params) {
|
|
14384
|
+
var _a, _b, _c;
|
|
14385
|
+
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;
|
|
14386
|
+
}
|
|
14235
14387
|
/**
|
|
14236
14388
|
* Returns whether to append automatic function calling history to the
|
|
14237
14389
|
* response.
|
|
@@ -14290,12 +14442,12 @@ class Models extends BaseModule {
|
|
|
14290
14442
|
*/
|
|
14291
14443
|
this.generateContent = async (params) => {
|
|
14292
14444
|
var _a, _b, _c, _d, _e;
|
|
14293
|
-
const transformedParams = await this.
|
|
14445
|
+
const transformedParams = await this.processParamsMaybeAddMcpUsage(params);
|
|
14294
14446
|
this.maybeMoveToResponseJsonSchem(params);
|
|
14295
|
-
if (!
|
|
14447
|
+
if (!hasCallableTools(params) || shouldDisableAfc(params.config)) {
|
|
14296
14448
|
return await this.generateContentInternal(transformedParams);
|
|
14297
14449
|
}
|
|
14298
|
-
if (
|
|
14450
|
+
if (hasNonCallableTools(params)) {
|
|
14299
14451
|
throw new Error('Automatic function calling with CallableTools and Tools is not yet supported.');
|
|
14300
14452
|
}
|
|
14301
14453
|
let response;
|
|
@@ -14380,7 +14532,7 @@ class Models extends BaseModule {
|
|
|
14380
14532
|
this.generateContentStream = async (params) => {
|
|
14381
14533
|
this.maybeMoveToResponseJsonSchem(params);
|
|
14382
14534
|
if (shouldDisableAfc(params.config)) {
|
|
14383
|
-
const transformedParams = await this.
|
|
14535
|
+
const transformedParams = await this.processParamsMaybeAddMcpUsage(params);
|
|
14384
14536
|
return await this.generateContentStreamInternal(transformedParams);
|
|
14385
14537
|
}
|
|
14386
14538
|
else {
|
|
@@ -14529,6 +14681,32 @@ class Models extends BaseModule {
|
|
|
14529
14681
|
};
|
|
14530
14682
|
return await this.upscaleImageInternal(apiParams);
|
|
14531
14683
|
};
|
|
14684
|
+
/**
|
|
14685
|
+
* Generates videos based on a text description and configuration.
|
|
14686
|
+
*
|
|
14687
|
+
* @param params - The parameters for generating videos.
|
|
14688
|
+
* @return A Promise<GenerateVideosOperation> which allows you to track the progress and eventually retrieve the generated videos using the operations.get method.
|
|
14689
|
+
*
|
|
14690
|
+
* @example
|
|
14691
|
+
* ```ts
|
|
14692
|
+
* const operation = await ai.models.generateVideos({
|
|
14693
|
+
* model: 'veo-2.0-generate-001',
|
|
14694
|
+
* prompt: 'A neon hologram of a cat driving at top speed',
|
|
14695
|
+
* config: {
|
|
14696
|
+
* numberOfVideos: 1
|
|
14697
|
+
* });
|
|
14698
|
+
*
|
|
14699
|
+
* while (!operation.done) {
|
|
14700
|
+
* await new Promise(resolve => setTimeout(resolve, 10000));
|
|
14701
|
+
* operation = await ai.operations.getVideosOperation({operation: operation});
|
|
14702
|
+
* }
|
|
14703
|
+
*
|
|
14704
|
+
* console.log(operation.response?.generatedVideos?.[0]?.video?.uri);
|
|
14705
|
+
* ```
|
|
14706
|
+
*/
|
|
14707
|
+
this.generateVideos = async (params) => {
|
|
14708
|
+
return await this.generateVideosInternal(params);
|
|
14709
|
+
};
|
|
14532
14710
|
}
|
|
14533
14711
|
/**
|
|
14534
14712
|
* This logic is needed for GenerateContentConfig only.
|
|
@@ -14554,7 +14732,7 @@ class Models extends BaseModule {
|
|
|
14554
14732
|
* modify the original params. Also sets the MCP usage header if there are
|
|
14555
14733
|
* MCP tools in the parameters.
|
|
14556
14734
|
*/
|
|
14557
|
-
async
|
|
14735
|
+
async processParamsMaybeAddMcpUsage(params) {
|
|
14558
14736
|
var _a, _b, _c;
|
|
14559
14737
|
const tools = (_a = params.config) === null || _a === void 0 ? void 0 : _a.tools;
|
|
14560
14738
|
if (!tools) {
|
|
@@ -14621,7 +14799,7 @@ class Models extends BaseModule {
|
|
|
14621
14799
|
remoteCallCount++;
|
|
14622
14800
|
wereFunctionsCalled = false;
|
|
14623
14801
|
}
|
|
14624
|
-
const transformedParams = yield __await(models.
|
|
14802
|
+
const transformedParams = yield __await(models.processParamsMaybeAddMcpUsage(params));
|
|
14625
14803
|
const response = yield __await(models.generateContentStreamInternal(transformedParams));
|
|
14626
14804
|
const functionResponses = [];
|
|
14627
14805
|
const responseContents = [];
|
|
@@ -15159,7 +15337,13 @@ class Models extends BaseModule {
|
|
|
15159
15337
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
15160
15338
|
})
|
|
15161
15339
|
.then((httpResponse) => {
|
|
15162
|
-
return httpResponse.json()
|
|
15340
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
15341
|
+
const response = jsonResponse;
|
|
15342
|
+
response.sdkHttpResponse = {
|
|
15343
|
+
headers: httpResponse.headers,
|
|
15344
|
+
};
|
|
15345
|
+
return response;
|
|
15346
|
+
});
|
|
15163
15347
|
});
|
|
15164
15348
|
return response.then((apiResponse) => {
|
|
15165
15349
|
const resp = listModelsResponseFromVertex(apiResponse);
|
|
@@ -15185,7 +15369,13 @@ class Models extends BaseModule {
|
|
|
15185
15369
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
15186
15370
|
})
|
|
15187
15371
|
.then((httpResponse) => {
|
|
15188
|
-
return httpResponse.json()
|
|
15372
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
15373
|
+
const response = jsonResponse;
|
|
15374
|
+
response.sdkHttpResponse = {
|
|
15375
|
+
headers: httpResponse.headers,
|
|
15376
|
+
};
|
|
15377
|
+
return response;
|
|
15378
|
+
});
|
|
15189
15379
|
});
|
|
15190
15380
|
return response.then((apiResponse) => {
|
|
15191
15381
|
const resp = listModelsResponseFromMldev(apiResponse);
|
|
@@ -15485,7 +15675,7 @@ class Models extends BaseModule {
|
|
|
15485
15675
|
* console.log(operation.response?.generatedVideos?.[0]?.video?.uri);
|
|
15486
15676
|
* ```
|
|
15487
15677
|
*/
|
|
15488
|
-
async
|
|
15678
|
+
async generateVideosInternal(params) {
|
|
15489
15679
|
var _a, _b, _c, _d;
|
|
15490
15680
|
let response;
|
|
15491
15681
|
let path = '';
|
|
@@ -15510,8 +15700,10 @@ class Models extends BaseModule {
|
|
|
15510
15700
|
return httpResponse.json();
|
|
15511
15701
|
});
|
|
15512
15702
|
return response.then((apiResponse) => {
|
|
15513
|
-
const resp = generateVideosOperationFromVertex
|
|
15514
|
-
|
|
15703
|
+
const resp = generateVideosOperationFromVertex(apiResponse);
|
|
15704
|
+
const typedResp = new GenerateVideosOperation();
|
|
15705
|
+
Object.assign(typedResp, resp);
|
|
15706
|
+
return typedResp;
|
|
15515
15707
|
});
|
|
15516
15708
|
}
|
|
15517
15709
|
else {
|
|
@@ -15534,8 +15726,10 @@ class Models extends BaseModule {
|
|
|
15534
15726
|
return httpResponse.json();
|
|
15535
15727
|
});
|
|
15536
15728
|
return response.then((apiResponse) => {
|
|
15537
|
-
const resp = generateVideosOperationFromMldev
|
|
15538
|
-
|
|
15729
|
+
const resp = generateVideosOperationFromMldev(apiResponse);
|
|
15730
|
+
const typedResp = new GenerateVideosOperation();
|
|
15731
|
+
Object.assign(typedResp, resp);
|
|
15732
|
+
return typedResp;
|
|
15539
15733
|
});
|
|
15540
15734
|
}
|
|
15541
15735
|
}
|
|
@@ -15593,164 +15787,6 @@ function fetchPredictOperationParametersToVertex(fromObject) {
|
|
|
15593
15787
|
}
|
|
15594
15788
|
return toObject;
|
|
15595
15789
|
}
|
|
15596
|
-
function videoFromMldev(fromObject) {
|
|
15597
|
-
const toObject = {};
|
|
15598
|
-
const fromUri = getValueByPath(fromObject, ['video', 'uri']);
|
|
15599
|
-
if (fromUri != null) {
|
|
15600
|
-
setValueByPath(toObject, ['uri'], fromUri);
|
|
15601
|
-
}
|
|
15602
|
-
const fromVideoBytes = getValueByPath(fromObject, [
|
|
15603
|
-
'video',
|
|
15604
|
-
'encodedVideo',
|
|
15605
|
-
]);
|
|
15606
|
-
if (fromVideoBytes != null) {
|
|
15607
|
-
setValueByPath(toObject, ['videoBytes'], tBytes(fromVideoBytes));
|
|
15608
|
-
}
|
|
15609
|
-
const fromMimeType = getValueByPath(fromObject, ['encoding']);
|
|
15610
|
-
if (fromMimeType != null) {
|
|
15611
|
-
setValueByPath(toObject, ['mimeType'], fromMimeType);
|
|
15612
|
-
}
|
|
15613
|
-
return toObject;
|
|
15614
|
-
}
|
|
15615
|
-
function generatedVideoFromMldev(fromObject) {
|
|
15616
|
-
const toObject = {};
|
|
15617
|
-
const fromVideo = getValueByPath(fromObject, ['_self']);
|
|
15618
|
-
if (fromVideo != null) {
|
|
15619
|
-
setValueByPath(toObject, ['video'], videoFromMldev(fromVideo));
|
|
15620
|
-
}
|
|
15621
|
-
return toObject;
|
|
15622
|
-
}
|
|
15623
|
-
function generateVideosResponseFromMldev(fromObject) {
|
|
15624
|
-
const toObject = {};
|
|
15625
|
-
const fromGeneratedVideos = getValueByPath(fromObject, [
|
|
15626
|
-
'generatedSamples',
|
|
15627
|
-
]);
|
|
15628
|
-
if (fromGeneratedVideos != null) {
|
|
15629
|
-
let transformedList = fromGeneratedVideos;
|
|
15630
|
-
if (Array.isArray(transformedList)) {
|
|
15631
|
-
transformedList = transformedList.map((item) => {
|
|
15632
|
-
return generatedVideoFromMldev(item);
|
|
15633
|
-
});
|
|
15634
|
-
}
|
|
15635
|
-
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
15636
|
-
}
|
|
15637
|
-
const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
|
|
15638
|
-
'raiMediaFilteredCount',
|
|
15639
|
-
]);
|
|
15640
|
-
if (fromRaiMediaFilteredCount != null) {
|
|
15641
|
-
setValueByPath(toObject, ['raiMediaFilteredCount'], fromRaiMediaFilteredCount);
|
|
15642
|
-
}
|
|
15643
|
-
const fromRaiMediaFilteredReasons = getValueByPath(fromObject, [
|
|
15644
|
-
'raiMediaFilteredReasons',
|
|
15645
|
-
]);
|
|
15646
|
-
if (fromRaiMediaFilteredReasons != null) {
|
|
15647
|
-
setValueByPath(toObject, ['raiMediaFilteredReasons'], fromRaiMediaFilteredReasons);
|
|
15648
|
-
}
|
|
15649
|
-
return toObject;
|
|
15650
|
-
}
|
|
15651
|
-
function generateVideosOperationFromMldev(fromObject) {
|
|
15652
|
-
const toObject = {};
|
|
15653
|
-
const fromName = getValueByPath(fromObject, ['name']);
|
|
15654
|
-
if (fromName != null) {
|
|
15655
|
-
setValueByPath(toObject, ['name'], fromName);
|
|
15656
|
-
}
|
|
15657
|
-
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
15658
|
-
if (fromMetadata != null) {
|
|
15659
|
-
setValueByPath(toObject, ['metadata'], fromMetadata);
|
|
15660
|
-
}
|
|
15661
|
-
const fromDone = getValueByPath(fromObject, ['done']);
|
|
15662
|
-
if (fromDone != null) {
|
|
15663
|
-
setValueByPath(toObject, ['done'], fromDone);
|
|
15664
|
-
}
|
|
15665
|
-
const fromError = getValueByPath(fromObject, ['error']);
|
|
15666
|
-
if (fromError != null) {
|
|
15667
|
-
setValueByPath(toObject, ['error'], fromError);
|
|
15668
|
-
}
|
|
15669
|
-
const fromResponse = getValueByPath(fromObject, [
|
|
15670
|
-
'response',
|
|
15671
|
-
'generateVideoResponse',
|
|
15672
|
-
]);
|
|
15673
|
-
if (fromResponse != null) {
|
|
15674
|
-
setValueByPath(toObject, ['response'], generateVideosResponseFromMldev(fromResponse));
|
|
15675
|
-
}
|
|
15676
|
-
return toObject;
|
|
15677
|
-
}
|
|
15678
|
-
function videoFromVertex(fromObject) {
|
|
15679
|
-
const toObject = {};
|
|
15680
|
-
const fromUri = getValueByPath(fromObject, ['gcsUri']);
|
|
15681
|
-
if (fromUri != null) {
|
|
15682
|
-
setValueByPath(toObject, ['uri'], fromUri);
|
|
15683
|
-
}
|
|
15684
|
-
const fromVideoBytes = getValueByPath(fromObject, [
|
|
15685
|
-
'bytesBase64Encoded',
|
|
15686
|
-
]);
|
|
15687
|
-
if (fromVideoBytes != null) {
|
|
15688
|
-
setValueByPath(toObject, ['videoBytes'], tBytes(fromVideoBytes));
|
|
15689
|
-
}
|
|
15690
|
-
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
15691
|
-
if (fromMimeType != null) {
|
|
15692
|
-
setValueByPath(toObject, ['mimeType'], fromMimeType);
|
|
15693
|
-
}
|
|
15694
|
-
return toObject;
|
|
15695
|
-
}
|
|
15696
|
-
function generatedVideoFromVertex(fromObject) {
|
|
15697
|
-
const toObject = {};
|
|
15698
|
-
const fromVideo = getValueByPath(fromObject, ['_self']);
|
|
15699
|
-
if (fromVideo != null) {
|
|
15700
|
-
setValueByPath(toObject, ['video'], videoFromVertex(fromVideo));
|
|
15701
|
-
}
|
|
15702
|
-
return toObject;
|
|
15703
|
-
}
|
|
15704
|
-
function generateVideosResponseFromVertex(fromObject) {
|
|
15705
|
-
const toObject = {};
|
|
15706
|
-
const fromGeneratedVideos = getValueByPath(fromObject, ['videos']);
|
|
15707
|
-
if (fromGeneratedVideos != null) {
|
|
15708
|
-
let transformedList = fromGeneratedVideos;
|
|
15709
|
-
if (Array.isArray(transformedList)) {
|
|
15710
|
-
transformedList = transformedList.map((item) => {
|
|
15711
|
-
return generatedVideoFromVertex(item);
|
|
15712
|
-
});
|
|
15713
|
-
}
|
|
15714
|
-
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
15715
|
-
}
|
|
15716
|
-
const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
|
|
15717
|
-
'raiMediaFilteredCount',
|
|
15718
|
-
]);
|
|
15719
|
-
if (fromRaiMediaFilteredCount != null) {
|
|
15720
|
-
setValueByPath(toObject, ['raiMediaFilteredCount'], fromRaiMediaFilteredCount);
|
|
15721
|
-
}
|
|
15722
|
-
const fromRaiMediaFilteredReasons = getValueByPath(fromObject, [
|
|
15723
|
-
'raiMediaFilteredReasons',
|
|
15724
|
-
]);
|
|
15725
|
-
if (fromRaiMediaFilteredReasons != null) {
|
|
15726
|
-
setValueByPath(toObject, ['raiMediaFilteredReasons'], fromRaiMediaFilteredReasons);
|
|
15727
|
-
}
|
|
15728
|
-
return toObject;
|
|
15729
|
-
}
|
|
15730
|
-
function generateVideosOperationFromVertex(fromObject) {
|
|
15731
|
-
const toObject = {};
|
|
15732
|
-
const fromName = getValueByPath(fromObject, ['name']);
|
|
15733
|
-
if (fromName != null) {
|
|
15734
|
-
setValueByPath(toObject, ['name'], fromName);
|
|
15735
|
-
}
|
|
15736
|
-
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
15737
|
-
if (fromMetadata != null) {
|
|
15738
|
-
setValueByPath(toObject, ['metadata'], fromMetadata);
|
|
15739
|
-
}
|
|
15740
|
-
const fromDone = getValueByPath(fromObject, ['done']);
|
|
15741
|
-
if (fromDone != null) {
|
|
15742
|
-
setValueByPath(toObject, ['done'], fromDone);
|
|
15743
|
-
}
|
|
15744
|
-
const fromError = getValueByPath(fromObject, ['error']);
|
|
15745
|
-
if (fromError != null) {
|
|
15746
|
-
setValueByPath(toObject, ['error'], fromError);
|
|
15747
|
-
}
|
|
15748
|
-
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
15749
|
-
if (fromResponse != null) {
|
|
15750
|
-
setValueByPath(toObject, ['response'], generateVideosResponseFromVertex(fromResponse));
|
|
15751
|
-
}
|
|
15752
|
-
return toObject;
|
|
15753
|
-
}
|
|
15754
15790
|
|
|
15755
15791
|
/**
|
|
15756
15792
|
* @license
|
|
@@ -15780,17 +15816,64 @@ class Operations extends BaseModule {
|
|
|
15780
15816
|
if (config && 'httpOptions' in config) {
|
|
15781
15817
|
httpOptions = config.httpOptions;
|
|
15782
15818
|
}
|
|
15783
|
-
|
|
15819
|
+
const rawOperation = await this.fetchPredictVideosOperationInternal({
|
|
15784
15820
|
operationName: operation.name,
|
|
15785
15821
|
resourceName: resourceName,
|
|
15786
15822
|
config: { httpOptions: httpOptions },
|
|
15787
15823
|
});
|
|
15824
|
+
return operation._fromAPIResponse({
|
|
15825
|
+
apiResponse: rawOperation,
|
|
15826
|
+
isVertexAI: true,
|
|
15827
|
+
});
|
|
15788
15828
|
}
|
|
15789
15829
|
else {
|
|
15790
|
-
|
|
15830
|
+
const rawOperation = await this.getVideosOperationInternal({
|
|
15791
15831
|
operationName: operation.name,
|
|
15792
15832
|
config: config,
|
|
15793
15833
|
});
|
|
15834
|
+
return operation._fromAPIResponse({
|
|
15835
|
+
apiResponse: rawOperation,
|
|
15836
|
+
isVertexAI: false,
|
|
15837
|
+
});
|
|
15838
|
+
}
|
|
15839
|
+
}
|
|
15840
|
+
/**
|
|
15841
|
+
* Gets the status of a long-running operation.
|
|
15842
|
+
*
|
|
15843
|
+
* @param parameters The parameters for the get operation request.
|
|
15844
|
+
* @return The updated Operation object, with the latest status or result.
|
|
15845
|
+
*/
|
|
15846
|
+
async get(parameters) {
|
|
15847
|
+
const operation = parameters.operation;
|
|
15848
|
+
const config = parameters.config;
|
|
15849
|
+
if (operation.name === undefined || operation.name === '') {
|
|
15850
|
+
throw new Error('Operation name is required.');
|
|
15851
|
+
}
|
|
15852
|
+
if (this.apiClient.isVertexAI()) {
|
|
15853
|
+
const resourceName = operation.name.split('/operations/')[0];
|
|
15854
|
+
let httpOptions = undefined;
|
|
15855
|
+
if (config && 'httpOptions' in config) {
|
|
15856
|
+
httpOptions = config.httpOptions;
|
|
15857
|
+
}
|
|
15858
|
+
const rawOperation = await this.fetchPredictVideosOperationInternal({
|
|
15859
|
+
operationName: operation.name,
|
|
15860
|
+
resourceName: resourceName,
|
|
15861
|
+
config: { httpOptions: httpOptions },
|
|
15862
|
+
});
|
|
15863
|
+
return operation._fromAPIResponse({
|
|
15864
|
+
apiResponse: rawOperation,
|
|
15865
|
+
isVertexAI: true,
|
|
15866
|
+
});
|
|
15867
|
+
}
|
|
15868
|
+
else {
|
|
15869
|
+
const rawOperation = await this.getVideosOperationInternal({
|
|
15870
|
+
operationName: operation.name,
|
|
15871
|
+
config: config,
|
|
15872
|
+
});
|
|
15873
|
+
return operation._fromAPIResponse({
|
|
15874
|
+
apiResponse: rawOperation,
|
|
15875
|
+
isVertexAI: false,
|
|
15876
|
+
});
|
|
15794
15877
|
}
|
|
15795
15878
|
}
|
|
15796
15879
|
async getVideosOperationInternal(params) {
|
|
@@ -15817,10 +15900,7 @@ class Operations extends BaseModule {
|
|
|
15817
15900
|
.then((httpResponse) => {
|
|
15818
15901
|
return httpResponse.json();
|
|
15819
15902
|
});
|
|
15820
|
-
return response
|
|
15821
|
-
const resp = generateVideosOperationFromVertex(apiResponse);
|
|
15822
|
-
return resp;
|
|
15823
|
-
});
|
|
15903
|
+
return response;
|
|
15824
15904
|
}
|
|
15825
15905
|
else {
|
|
15826
15906
|
const body = getOperationParametersToMldev(params);
|
|
@@ -15841,10 +15921,7 @@ class Operations extends BaseModule {
|
|
|
15841
15921
|
.then((httpResponse) => {
|
|
15842
15922
|
return httpResponse.json();
|
|
15843
15923
|
});
|
|
15844
|
-
return response
|
|
15845
|
-
const resp = generateVideosOperationFromMldev(apiResponse);
|
|
15846
|
-
return resp;
|
|
15847
|
-
});
|
|
15924
|
+
return response;
|
|
15848
15925
|
}
|
|
15849
15926
|
}
|
|
15850
15927
|
async fetchPredictVideosOperationInternal(params) {
|
|
@@ -15871,10 +15948,7 @@ class Operations extends BaseModule {
|
|
|
15871
15948
|
.then((httpResponse) => {
|
|
15872
15949
|
return httpResponse.json();
|
|
15873
15950
|
});
|
|
15874
|
-
return response
|
|
15875
|
-
const resp = generateVideosOperationFromVertex(apiResponse);
|
|
15876
|
-
return resp;
|
|
15877
|
-
});
|
|
15951
|
+
return response;
|
|
15878
15952
|
}
|
|
15879
15953
|
else {
|
|
15880
15954
|
throw new Error('This method is only supported by the Vertex AI.');
|
|
@@ -17275,6 +17349,12 @@ function tuningJobFromMldev(fromObject) {
|
|
|
17275
17349
|
}
|
|
17276
17350
|
function listTuningJobsResponseFromMldev(fromObject) {
|
|
17277
17351
|
const toObject = {};
|
|
17352
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
17353
|
+
'sdkHttpResponse',
|
|
17354
|
+
]);
|
|
17355
|
+
if (fromSdkHttpResponse != null) {
|
|
17356
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
17357
|
+
}
|
|
17278
17358
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
17279
17359
|
'nextPageToken',
|
|
17280
17360
|
]);
|
|
@@ -17463,6 +17543,12 @@ function tuningJobFromVertex(fromObject) {
|
|
|
17463
17543
|
}
|
|
17464
17544
|
function listTuningJobsResponseFromVertex(fromObject) {
|
|
17465
17545
|
const toObject = {};
|
|
17546
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
17547
|
+
'sdkHttpResponse',
|
|
17548
|
+
]);
|
|
17549
|
+
if (fromSdkHttpResponse != null) {
|
|
17550
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
17551
|
+
}
|
|
17466
17552
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
17467
17553
|
'nextPageToken',
|
|
17468
17554
|
]);
|
|
@@ -17623,7 +17709,13 @@ class Tunings extends BaseModule {
|
|
|
17623
17709
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
17624
17710
|
})
|
|
17625
17711
|
.then((httpResponse) => {
|
|
17626
|
-
return httpResponse.json()
|
|
17712
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
17713
|
+
const response = jsonResponse;
|
|
17714
|
+
response.sdkHttpResponse = {
|
|
17715
|
+
headers: httpResponse.headers,
|
|
17716
|
+
};
|
|
17717
|
+
return response;
|
|
17718
|
+
});
|
|
17627
17719
|
});
|
|
17628
17720
|
return response.then((apiResponse) => {
|
|
17629
17721
|
const resp = listTuningJobsResponseFromVertex(apiResponse);
|
|
@@ -17649,7 +17741,13 @@ class Tunings extends BaseModule {
|
|
|
17649
17741
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
17650
17742
|
})
|
|
17651
17743
|
.then((httpResponse) => {
|
|
17652
|
-
return httpResponse.json()
|
|
17744
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
17745
|
+
const response = jsonResponse;
|
|
17746
|
+
response.sdkHttpResponse = {
|
|
17747
|
+
headers: httpResponse.headers,
|
|
17748
|
+
};
|
|
17749
|
+
return response;
|
|
17750
|
+
});
|
|
17653
17751
|
});
|
|
17654
17752
|
return response.then((apiResponse) => {
|
|
17655
17753
|
const resp = listTuningJobsResponseFromMldev(apiResponse);
|
|
@@ -18074,7 +18172,7 @@ class GoogleGenAI {
|
|
|
18074
18172
|
this.apiKey = undefined;
|
|
18075
18173
|
}
|
|
18076
18174
|
}
|
|
18077
|
-
const baseUrl = getBaseUrl(options, getEnv('GOOGLE_VERTEX_BASE_URL'), getEnv('GOOGLE_GEMINI_BASE_URL'));
|
|
18175
|
+
const baseUrl = getBaseUrl(options.httpOptions, options.vertexai, getEnv('GOOGLE_VERTEX_BASE_URL'), getEnv('GOOGLE_GEMINI_BASE_URL'));
|
|
18078
18176
|
if (baseUrl) {
|
|
18079
18177
|
if (options.httpOptions) {
|
|
18080
18178
|
options.httpOptions.baseUrl = baseUrl;
|
|
@@ -18153,6 +18251,7 @@ exports.GenerateContentResponse = GenerateContentResponse;
|
|
|
18153
18251
|
exports.GenerateContentResponsePromptFeedback = GenerateContentResponsePromptFeedback;
|
|
18154
18252
|
exports.GenerateContentResponseUsageMetadata = GenerateContentResponseUsageMetadata;
|
|
18155
18253
|
exports.GenerateImagesResponse = GenerateImagesResponse;
|
|
18254
|
+
exports.GenerateVideosOperation = GenerateVideosOperation;
|
|
18156
18255
|
exports.GenerateVideosResponse = GenerateVideosResponse;
|
|
18157
18256
|
exports.GoogleGenAI = GoogleGenAI;
|
|
18158
18257
|
exports.HttpResponse = HttpResponse;
|