@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.mjs
CHANGED
|
@@ -50,18 +50,18 @@ function getDefaultBaseUrls() {
|
|
|
50
50
|
* 2. Base URLs set via the latest call to setDefaultBaseUrls.
|
|
51
51
|
* 3. Base URLs set via environment variables.
|
|
52
52
|
*/
|
|
53
|
-
function getBaseUrl(
|
|
54
|
-
var _a, _b
|
|
55
|
-
if (!(
|
|
53
|
+
function getBaseUrl(httpOptions, vertexai, vertexBaseUrlFromEnv, geminiBaseUrlFromEnv) {
|
|
54
|
+
var _a, _b;
|
|
55
|
+
if (!(httpOptions === null || httpOptions === void 0 ? void 0 : httpOptions.baseUrl)) {
|
|
56
56
|
const defaultBaseUrls = getDefaultBaseUrls();
|
|
57
|
-
if (
|
|
58
|
-
return (
|
|
57
|
+
if (vertexai) {
|
|
58
|
+
return (_a = defaultBaseUrls.vertexUrl) !== null && _a !== void 0 ? _a : vertexBaseUrlFromEnv;
|
|
59
59
|
}
|
|
60
60
|
else {
|
|
61
|
-
return (
|
|
61
|
+
return (_b = defaultBaseUrls.geminiUrl) !== null && _b !== void 0 ? _b : geminiBaseUrlFromEnv;
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
return
|
|
64
|
+
return httpOptions.baseUrl;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
/**
|
|
@@ -196,6 +196,20 @@ function getValueByPath(data, keys) {
|
|
|
196
196
|
* Copyright 2025 Google LLC
|
|
197
197
|
* SPDX-License-Identifier: Apache-2.0
|
|
198
198
|
*/
|
|
199
|
+
function tBytes$1(fromBytes) {
|
|
200
|
+
if (typeof fromBytes !== 'string') {
|
|
201
|
+
throw new Error('fromImageBytes must be a string');
|
|
202
|
+
}
|
|
203
|
+
// TODO(b/389133914): Remove dummy bytes converter.
|
|
204
|
+
return fromBytes;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* @license
|
|
209
|
+
* Copyright 2025 Google LLC
|
|
210
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
211
|
+
*/
|
|
212
|
+
// Code generated by the Google Gen AI SDK generator DO NOT EDIT.
|
|
199
213
|
/** Required. Outcome of the code execution. */
|
|
200
214
|
var Outcome;
|
|
201
215
|
(function (Outcome) {
|
|
@@ -1689,6 +1703,65 @@ class LiveServerMessage {
|
|
|
1689
1703
|
return data.length > 0 ? btoa(data) : undefined;
|
|
1690
1704
|
}
|
|
1691
1705
|
}
|
|
1706
|
+
/** A video generation long-running operation. */
|
|
1707
|
+
class GenerateVideosOperation {
|
|
1708
|
+
/**
|
|
1709
|
+
* Instantiates an Operation of the same type as the one being called with the fields set from the API response.
|
|
1710
|
+
* @internal
|
|
1711
|
+
*/
|
|
1712
|
+
_fromAPIResponse({ apiResponse, isVertexAI, }) {
|
|
1713
|
+
const operation = new GenerateVideosOperation();
|
|
1714
|
+
operation.name = apiResponse['name'];
|
|
1715
|
+
operation.metadata = apiResponse['metadata'];
|
|
1716
|
+
operation.done = apiResponse['done'];
|
|
1717
|
+
operation.error = apiResponse['error'];
|
|
1718
|
+
if (isVertexAI) {
|
|
1719
|
+
const response = apiResponse['response'];
|
|
1720
|
+
if (response) {
|
|
1721
|
+
const operationResponse = new GenerateVideosResponse();
|
|
1722
|
+
const responseVideos = response['videos'];
|
|
1723
|
+
operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
|
|
1724
|
+
return {
|
|
1725
|
+
video: {
|
|
1726
|
+
uri: generatedVideo['gcsUri'],
|
|
1727
|
+
videoBytes: generatedVideo['bytesBase64Encoded']
|
|
1728
|
+
? tBytes$1(generatedVideo['bytesBase64Encoded'])
|
|
1729
|
+
: undefined,
|
|
1730
|
+
mimeType: generatedVideo['mimeType'],
|
|
1731
|
+
},
|
|
1732
|
+
};
|
|
1733
|
+
});
|
|
1734
|
+
operationResponse.raiMediaFilteredCount = response['raiMediaFilteredCount'];
|
|
1735
|
+
operationResponse.raiMediaFilteredReasons = response['raiMediaFilteredReasons'];
|
|
1736
|
+
operation.response = operationResponse;
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1739
|
+
else {
|
|
1740
|
+
const response = apiResponse['response'];
|
|
1741
|
+
if (response) {
|
|
1742
|
+
const operationResponse = new GenerateVideosResponse();
|
|
1743
|
+
const generatedVideoResponse = response['generateVideoResponse'];
|
|
1744
|
+
const responseVideos = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['generatedSamples'];
|
|
1745
|
+
operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
|
|
1746
|
+
const video = generatedVideo['video'];
|
|
1747
|
+
return {
|
|
1748
|
+
video: {
|
|
1749
|
+
uri: video === null || video === void 0 ? void 0 : video['uri'],
|
|
1750
|
+
videoBytes: (video === null || video === void 0 ? void 0 : video['encodedVideo'])
|
|
1751
|
+
? tBytes$1(video === null || video === void 0 ? void 0 : video['encodedVideo'])
|
|
1752
|
+
: undefined,
|
|
1753
|
+
mimeType: generatedVideo['encoding'],
|
|
1754
|
+
},
|
|
1755
|
+
};
|
|
1756
|
+
});
|
|
1757
|
+
operationResponse.raiMediaFilteredCount = response['raiMediaFilteredCount'];
|
|
1758
|
+
operationResponse.raiMediaFilteredReasons = response['raiMediaFilteredReasons'];
|
|
1759
|
+
operation.response = operationResponse;
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1762
|
+
return operation;
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1692
1765
|
/** Client generated response to a `ToolCall` received from the server.
|
|
1693
1766
|
|
|
1694
1767
|
Individual `FunctionResponse` objects are matched to the respective
|
|
@@ -2250,11 +2323,7 @@ function tTuningJobStatus(status) {
|
|
|
2250
2323
|
}
|
|
2251
2324
|
}
|
|
2252
2325
|
function tBytes(fromImageBytes) {
|
|
2253
|
-
|
|
2254
|
-
throw new Error('fromImageBytes must be a string');
|
|
2255
|
-
}
|
|
2256
|
-
// TODO(b/389133914): Remove dummy bytes converter.
|
|
2257
|
-
return fromImageBytes;
|
|
2326
|
+
return tBytes$1(fromImageBytes);
|
|
2258
2327
|
}
|
|
2259
2328
|
function _isFile(origin) {
|
|
2260
2329
|
return (origin !== null &&
|
|
@@ -3742,6 +3811,12 @@ function batchJobFromMldev(fromObject) {
|
|
|
3742
3811
|
}
|
|
3743
3812
|
function listBatchJobsResponseFromMldev(fromObject) {
|
|
3744
3813
|
const toObject = {};
|
|
3814
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
3815
|
+
'sdkHttpResponse',
|
|
3816
|
+
]);
|
|
3817
|
+
if (fromSdkHttpResponse != null) {
|
|
3818
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
3819
|
+
}
|
|
3745
3820
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
3746
3821
|
'nextPageToken',
|
|
3747
3822
|
]);
|
|
@@ -3883,6 +3958,12 @@ function batchJobFromVertex(fromObject) {
|
|
|
3883
3958
|
}
|
|
3884
3959
|
function listBatchJobsResponseFromVertex(fromObject) {
|
|
3885
3960
|
const toObject = {};
|
|
3961
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
3962
|
+
'sdkHttpResponse',
|
|
3963
|
+
]);
|
|
3964
|
+
if (fromSdkHttpResponse != null) {
|
|
3965
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
3966
|
+
}
|
|
3886
3967
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
3887
3968
|
'nextPageToken',
|
|
3888
3969
|
]);
|
|
@@ -3925,9 +4006,6 @@ function deleteResourceJobFromVertex(fromObject) {
|
|
|
3925
4006
|
* Copyright 2025 Google LLC
|
|
3926
4007
|
* SPDX-License-Identifier: Apache-2.0
|
|
3927
4008
|
*/
|
|
3928
|
-
/**
|
|
3929
|
-
* Pagers for the GenAI List APIs.
|
|
3930
|
-
*/
|
|
3931
4009
|
var PagedItem;
|
|
3932
4010
|
(function (PagedItem) {
|
|
3933
4011
|
PagedItem["PAGED_ITEM_BATCH_JOBS"] = "batchJobs";
|
|
@@ -3950,9 +4028,10 @@ class Pager {
|
|
|
3950
4028
|
var _a, _b;
|
|
3951
4029
|
this.nameInternal = name;
|
|
3952
4030
|
this.pageInternal = response[this.nameInternal] || [];
|
|
4031
|
+
this.sdkHttpResponseInternal = response === null || response === void 0 ? void 0 : response.sdkHttpResponse;
|
|
3953
4032
|
this.idxInternal = 0;
|
|
3954
4033
|
let requestParams = { config: {} };
|
|
3955
|
-
if (!params) {
|
|
4034
|
+
if (!params || Object.keys(params).length === 0) {
|
|
3956
4035
|
requestParams = { config: {} };
|
|
3957
4036
|
}
|
|
3958
4037
|
else if (typeof params === 'object') {
|
|
@@ -3996,6 +4075,12 @@ class Pager {
|
|
|
3996
4075
|
get pageSize() {
|
|
3997
4076
|
return this.pageInternalSize;
|
|
3998
4077
|
}
|
|
4078
|
+
/**
|
|
4079
|
+
* Returns the headers of the API response.
|
|
4080
|
+
*/
|
|
4081
|
+
get sdkHttpResponse() {
|
|
4082
|
+
return this.sdkHttpResponseInternal;
|
|
4083
|
+
}
|
|
3999
4084
|
/**
|
|
4000
4085
|
* Returns the parameters when making the API request for the next page.
|
|
4001
4086
|
*
|
|
@@ -4365,7 +4450,13 @@ class Batches extends BaseModule {
|
|
|
4365
4450
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
4366
4451
|
})
|
|
4367
4452
|
.then((httpResponse) => {
|
|
4368
|
-
return httpResponse.json()
|
|
4453
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
4454
|
+
const response = jsonResponse;
|
|
4455
|
+
response.sdkHttpResponse = {
|
|
4456
|
+
headers: httpResponse.headers,
|
|
4457
|
+
};
|
|
4458
|
+
return response;
|
|
4459
|
+
});
|
|
4369
4460
|
});
|
|
4370
4461
|
return response.then((apiResponse) => {
|
|
4371
4462
|
const resp = listBatchJobsResponseFromVertex(apiResponse);
|
|
@@ -4391,7 +4482,13 @@ class Batches extends BaseModule {
|
|
|
4391
4482
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
4392
4483
|
})
|
|
4393
4484
|
.then((httpResponse) => {
|
|
4394
|
-
return httpResponse.json()
|
|
4485
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
4486
|
+
const response = jsonResponse;
|
|
4487
|
+
response.sdkHttpResponse = {
|
|
4488
|
+
headers: httpResponse.headers,
|
|
4489
|
+
};
|
|
4490
|
+
return response;
|
|
4491
|
+
});
|
|
4395
4492
|
});
|
|
4396
4493
|
return response.then((apiResponse) => {
|
|
4397
4494
|
const resp = listBatchJobsResponseFromMldev(apiResponse);
|
|
@@ -5444,6 +5541,12 @@ function deleteCachedContentResponseFromMldev() {
|
|
|
5444
5541
|
}
|
|
5445
5542
|
function listCachedContentsResponseFromMldev(fromObject) {
|
|
5446
5543
|
const toObject = {};
|
|
5544
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
5545
|
+
'sdkHttpResponse',
|
|
5546
|
+
]);
|
|
5547
|
+
if (fromSdkHttpResponse != null) {
|
|
5548
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
5549
|
+
}
|
|
5447
5550
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
5448
5551
|
'nextPageToken',
|
|
5449
5552
|
]);
|
|
@@ -5504,6 +5607,12 @@ function deleteCachedContentResponseFromVertex() {
|
|
|
5504
5607
|
}
|
|
5505
5608
|
function listCachedContentsResponseFromVertex(fromObject) {
|
|
5506
5609
|
const toObject = {};
|
|
5610
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
5611
|
+
'sdkHttpResponse',
|
|
5612
|
+
]);
|
|
5613
|
+
if (fromSdkHttpResponse != null) {
|
|
5614
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
5615
|
+
}
|
|
5507
5616
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
5508
5617
|
'nextPageToken',
|
|
5509
5618
|
]);
|
|
@@ -5856,7 +5965,13 @@ class Caches extends BaseModule {
|
|
|
5856
5965
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
5857
5966
|
})
|
|
5858
5967
|
.then((httpResponse) => {
|
|
5859
|
-
return httpResponse.json()
|
|
5968
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
5969
|
+
const response = jsonResponse;
|
|
5970
|
+
response.sdkHttpResponse = {
|
|
5971
|
+
headers: httpResponse.headers,
|
|
5972
|
+
};
|
|
5973
|
+
return response;
|
|
5974
|
+
});
|
|
5860
5975
|
});
|
|
5861
5976
|
return response.then((apiResponse) => {
|
|
5862
5977
|
const resp = listCachedContentsResponseFromVertex(apiResponse);
|
|
@@ -5882,7 +5997,13 @@ class Caches extends BaseModule {
|
|
|
5882
5997
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
5883
5998
|
})
|
|
5884
5999
|
.then((httpResponse) => {
|
|
5885
|
-
return httpResponse.json()
|
|
6000
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
6001
|
+
const response = jsonResponse;
|
|
6002
|
+
response.sdkHttpResponse = {
|
|
6003
|
+
headers: httpResponse.headers,
|
|
6004
|
+
};
|
|
6005
|
+
return response;
|
|
6006
|
+
});
|
|
5886
6007
|
});
|
|
5887
6008
|
return response.then((apiResponse) => {
|
|
5888
6009
|
const resp = listCachedContentsResponseFromMldev(apiResponse);
|
|
@@ -6520,6 +6641,12 @@ function fileFromMldev(fromObject) {
|
|
|
6520
6641
|
}
|
|
6521
6642
|
function listFilesResponseFromMldev(fromObject) {
|
|
6522
6643
|
const toObject = {};
|
|
6644
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
6645
|
+
'sdkHttpResponse',
|
|
6646
|
+
]);
|
|
6647
|
+
if (fromSdkHttpResponse != null) {
|
|
6648
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
6649
|
+
}
|
|
6523
6650
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
6524
6651
|
'nextPageToken',
|
|
6525
6652
|
]);
|
|
@@ -6681,7 +6808,13 @@ class Files extends BaseModule {
|
|
|
6681
6808
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
6682
6809
|
})
|
|
6683
6810
|
.then((httpResponse) => {
|
|
6684
|
-
return httpResponse.json()
|
|
6811
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
6812
|
+
const response = jsonResponse;
|
|
6813
|
+
response.sdkHttpResponse = {
|
|
6814
|
+
headers: httpResponse.headers,
|
|
6815
|
+
};
|
|
6816
|
+
return response;
|
|
6817
|
+
});
|
|
6685
6818
|
});
|
|
6686
6819
|
return response.then((apiResponse) => {
|
|
6687
6820
|
const resp = listFilesResponseFromMldev(apiResponse);
|
|
@@ -9907,6 +10040,9 @@ function generateImagesConfigToMldev(fromObject, parentObject) {
|
|
|
9907
10040
|
if (getValueByPath(fromObject, ['addWatermark']) !== undefined) {
|
|
9908
10041
|
throw new Error('addWatermark parameter is not supported in Gemini API.');
|
|
9909
10042
|
}
|
|
10043
|
+
if (getValueByPath(fromObject, ['imageSize']) !== undefined) {
|
|
10044
|
+
throw new Error('imageSize parameter is not supported in Gemini API.');
|
|
10045
|
+
}
|
|
9910
10046
|
if (getValueByPath(fromObject, ['enhancePrompt']) !== undefined) {
|
|
9911
10047
|
throw new Error('enhancePrompt parameter is not supported in Gemini API.');
|
|
9912
10048
|
}
|
|
@@ -10983,6 +11119,10 @@ function generateImagesConfigToVertex(fromObject, parentObject) {
|
|
|
10983
11119
|
if (parentObject !== undefined && fromAddWatermark != null) {
|
|
10984
11120
|
setValueByPath(parentObject, ['parameters', 'addWatermark'], fromAddWatermark);
|
|
10985
11121
|
}
|
|
11122
|
+
const fromImageSize = getValueByPath(fromObject, ['imageSize']);
|
|
11123
|
+
if (parentObject !== undefined && fromImageSize != null) {
|
|
11124
|
+
setValueByPath(parentObject, ['parameters', 'sampleImageSize'], fromImageSize);
|
|
11125
|
+
}
|
|
10986
11126
|
const fromEnhancePrompt = getValueByPath(fromObject, [
|
|
10987
11127
|
'enhancePrompt',
|
|
10988
11128
|
]);
|
|
@@ -11973,6 +12113,12 @@ function modelFromMldev(fromObject) {
|
|
|
11973
12113
|
}
|
|
11974
12114
|
function listModelsResponseFromMldev(fromObject) {
|
|
11975
12115
|
const toObject = {};
|
|
12116
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
12117
|
+
'sdkHttpResponse',
|
|
12118
|
+
]);
|
|
12119
|
+
if (fromSdkHttpResponse != null) {
|
|
12120
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
12121
|
+
}
|
|
11976
12122
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
11977
12123
|
'nextPageToken',
|
|
11978
12124
|
]);
|
|
@@ -12009,7 +12155,7 @@ function countTokensResponseFromMldev(fromObject) {
|
|
|
12009
12155
|
}
|
|
12010
12156
|
return toObject;
|
|
12011
12157
|
}
|
|
12012
|
-
function videoFromMldev
|
|
12158
|
+
function videoFromMldev(fromObject) {
|
|
12013
12159
|
const toObject = {};
|
|
12014
12160
|
const fromUri = getValueByPath(fromObject, ['video', 'uri']);
|
|
12015
12161
|
if (fromUri != null) {
|
|
@@ -12028,15 +12174,15 @@ function videoFromMldev$1(fromObject) {
|
|
|
12028
12174
|
}
|
|
12029
12175
|
return toObject;
|
|
12030
12176
|
}
|
|
12031
|
-
function generatedVideoFromMldev
|
|
12177
|
+
function generatedVideoFromMldev(fromObject) {
|
|
12032
12178
|
const toObject = {};
|
|
12033
12179
|
const fromVideo = getValueByPath(fromObject, ['_self']);
|
|
12034
12180
|
if (fromVideo != null) {
|
|
12035
|
-
setValueByPath(toObject, ['video'], videoFromMldev
|
|
12181
|
+
setValueByPath(toObject, ['video'], videoFromMldev(fromVideo));
|
|
12036
12182
|
}
|
|
12037
12183
|
return toObject;
|
|
12038
12184
|
}
|
|
12039
|
-
function generateVideosResponseFromMldev
|
|
12185
|
+
function generateVideosResponseFromMldev(fromObject) {
|
|
12040
12186
|
const toObject = {};
|
|
12041
12187
|
const fromGeneratedVideos = getValueByPath(fromObject, [
|
|
12042
12188
|
'generatedSamples',
|
|
@@ -12045,7 +12191,7 @@ function generateVideosResponseFromMldev$1(fromObject) {
|
|
|
12045
12191
|
let transformedList = fromGeneratedVideos;
|
|
12046
12192
|
if (Array.isArray(transformedList)) {
|
|
12047
12193
|
transformedList = transformedList.map((item) => {
|
|
12048
|
-
return generatedVideoFromMldev
|
|
12194
|
+
return generatedVideoFromMldev(item);
|
|
12049
12195
|
});
|
|
12050
12196
|
}
|
|
12051
12197
|
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
@@ -12064,7 +12210,7 @@ function generateVideosResponseFromMldev$1(fromObject) {
|
|
|
12064
12210
|
}
|
|
12065
12211
|
return toObject;
|
|
12066
12212
|
}
|
|
12067
|
-
function generateVideosOperationFromMldev
|
|
12213
|
+
function generateVideosOperationFromMldev(fromObject) {
|
|
12068
12214
|
const toObject = {};
|
|
12069
12215
|
const fromName = getValueByPath(fromObject, ['name']);
|
|
12070
12216
|
if (fromName != null) {
|
|
@@ -12087,7 +12233,7 @@ function generateVideosOperationFromMldev$1(fromObject) {
|
|
|
12087
12233
|
'generateVideoResponse',
|
|
12088
12234
|
]);
|
|
12089
12235
|
if (fromResponse != null) {
|
|
12090
|
-
setValueByPath(toObject, ['response'], generateVideosResponseFromMldev
|
|
12236
|
+
setValueByPath(toObject, ['response'], generateVideosResponseFromMldev(fromResponse));
|
|
12091
12237
|
}
|
|
12092
12238
|
return toObject;
|
|
12093
12239
|
}
|
|
@@ -12623,6 +12769,12 @@ function modelFromVertex(fromObject) {
|
|
|
12623
12769
|
}
|
|
12624
12770
|
function listModelsResponseFromVertex(fromObject) {
|
|
12625
12771
|
const toObject = {};
|
|
12772
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
12773
|
+
'sdkHttpResponse',
|
|
12774
|
+
]);
|
|
12775
|
+
if (fromSdkHttpResponse != null) {
|
|
12776
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
12777
|
+
}
|
|
12626
12778
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
12627
12779
|
'nextPageToken',
|
|
12628
12780
|
]);
|
|
@@ -12661,7 +12813,7 @@ function computeTokensResponseFromVertex(fromObject) {
|
|
|
12661
12813
|
}
|
|
12662
12814
|
return toObject;
|
|
12663
12815
|
}
|
|
12664
|
-
function videoFromVertex
|
|
12816
|
+
function videoFromVertex(fromObject) {
|
|
12665
12817
|
const toObject = {};
|
|
12666
12818
|
const fromUri = getValueByPath(fromObject, ['gcsUri']);
|
|
12667
12819
|
if (fromUri != null) {
|
|
@@ -12679,22 +12831,22 @@ function videoFromVertex$1(fromObject) {
|
|
|
12679
12831
|
}
|
|
12680
12832
|
return toObject;
|
|
12681
12833
|
}
|
|
12682
|
-
function generatedVideoFromVertex
|
|
12834
|
+
function generatedVideoFromVertex(fromObject) {
|
|
12683
12835
|
const toObject = {};
|
|
12684
12836
|
const fromVideo = getValueByPath(fromObject, ['_self']);
|
|
12685
12837
|
if (fromVideo != null) {
|
|
12686
|
-
setValueByPath(toObject, ['video'], videoFromVertex
|
|
12838
|
+
setValueByPath(toObject, ['video'], videoFromVertex(fromVideo));
|
|
12687
12839
|
}
|
|
12688
12840
|
return toObject;
|
|
12689
12841
|
}
|
|
12690
|
-
function generateVideosResponseFromVertex
|
|
12842
|
+
function generateVideosResponseFromVertex(fromObject) {
|
|
12691
12843
|
const toObject = {};
|
|
12692
12844
|
const fromGeneratedVideos = getValueByPath(fromObject, ['videos']);
|
|
12693
12845
|
if (fromGeneratedVideos != null) {
|
|
12694
12846
|
let transformedList = fromGeneratedVideos;
|
|
12695
12847
|
if (Array.isArray(transformedList)) {
|
|
12696
12848
|
transformedList = transformedList.map((item) => {
|
|
12697
|
-
return generatedVideoFromVertex
|
|
12849
|
+
return generatedVideoFromVertex(item);
|
|
12698
12850
|
});
|
|
12699
12851
|
}
|
|
12700
12852
|
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
@@ -12713,7 +12865,7 @@ function generateVideosResponseFromVertex$1(fromObject) {
|
|
|
12713
12865
|
}
|
|
12714
12866
|
return toObject;
|
|
12715
12867
|
}
|
|
12716
|
-
function generateVideosOperationFromVertex
|
|
12868
|
+
function generateVideosOperationFromVertex(fromObject) {
|
|
12717
12869
|
const toObject = {};
|
|
12718
12870
|
const fromName = getValueByPath(fromObject, ['name']);
|
|
12719
12871
|
if (fromName != null) {
|
|
@@ -12733,7 +12885,7 @@ function generateVideosOperationFromVertex$1(fromObject) {
|
|
|
12733
12885
|
}
|
|
12734
12886
|
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
12735
12887
|
if (fromResponse != null) {
|
|
12736
|
-
setValueByPath(toObject, ['response'], generateVideosResponseFromVertex
|
|
12888
|
+
setValueByPath(toObject, ['response'], generateVideosResponseFromVertex(fromResponse));
|
|
12737
12889
|
}
|
|
12738
12890
|
return toObject;
|
|
12739
12891
|
}
|
|
@@ -12747,7 +12899,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
12747
12899
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
12748
12900
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
12749
12901
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
12750
|
-
const SDK_VERSION = '1.
|
|
12902
|
+
const SDK_VERSION = '1.11.0'; // x-release-please-version
|
|
12751
12903
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
12752
12904
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
12753
12905
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -13340,18 +13492,6 @@ function setMcpUsageHeader(headers) {
|
|
|
13340
13492
|
const existingHeader = (_a = headers[GOOGLE_API_CLIENT_HEADER]) !== null && _a !== void 0 ? _a : '';
|
|
13341
13493
|
headers[GOOGLE_API_CLIENT_HEADER] = (existingHeader + ` ${MCP_LABEL}`).trimStart();
|
|
13342
13494
|
}
|
|
13343
|
-
// Checks whether the list of tools contains any MCP clients. Will return true
|
|
13344
|
-
// if there is at least one MCP client.
|
|
13345
|
-
function hasMcpClientTools(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
|
-
// Checks whether the list of tools contains any non-MCP tools. Will return true
|
|
13350
|
-
// if there is at least one non-MCP tool.
|
|
13351
|
-
function hasNonMcpTools(params) {
|
|
13352
|
-
var _a, _b, _c;
|
|
13353
|
-
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);
|
|
13354
|
-
}
|
|
13355
13495
|
// Returns true if the object is a MCP CallableTool, otherwise false.
|
|
13356
13496
|
function isMcpCallableTool(object) {
|
|
13357
13497
|
return (object !== null &&
|
|
@@ -14210,6 +14350,18 @@ function shouldDisableAfc(config) {
|
|
|
14210
14350
|
function isCallableTool(tool) {
|
|
14211
14351
|
return 'callTool' in tool && typeof tool.callTool === 'function';
|
|
14212
14352
|
}
|
|
14353
|
+
// Checks whether the list of tools contains any CallableTools. Will return true
|
|
14354
|
+
// if there is at least one CallableTool.
|
|
14355
|
+
function hasCallableTools(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
|
+
}
|
|
14359
|
+
// Checks whether the list of tools contains any non-callable tools. Will return
|
|
14360
|
+
// true if there is at least one non-Callable tool.
|
|
14361
|
+
function hasNonCallableTools(params) {
|
|
14362
|
+
var _a, _b, _c;
|
|
14363
|
+
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;
|
|
14364
|
+
}
|
|
14213
14365
|
/**
|
|
14214
14366
|
* Returns whether to append automatic function calling history to the
|
|
14215
14367
|
* response.
|
|
@@ -14268,12 +14420,12 @@ class Models extends BaseModule {
|
|
|
14268
14420
|
*/
|
|
14269
14421
|
this.generateContent = async (params) => {
|
|
14270
14422
|
var _a, _b, _c, _d, _e;
|
|
14271
|
-
const transformedParams = await this.
|
|
14423
|
+
const transformedParams = await this.processParamsMaybeAddMcpUsage(params);
|
|
14272
14424
|
this.maybeMoveToResponseJsonSchem(params);
|
|
14273
|
-
if (!
|
|
14425
|
+
if (!hasCallableTools(params) || shouldDisableAfc(params.config)) {
|
|
14274
14426
|
return await this.generateContentInternal(transformedParams);
|
|
14275
14427
|
}
|
|
14276
|
-
if (
|
|
14428
|
+
if (hasNonCallableTools(params)) {
|
|
14277
14429
|
throw new Error('Automatic function calling with CallableTools and Tools is not yet supported.');
|
|
14278
14430
|
}
|
|
14279
14431
|
let response;
|
|
@@ -14358,7 +14510,7 @@ class Models extends BaseModule {
|
|
|
14358
14510
|
this.generateContentStream = async (params) => {
|
|
14359
14511
|
this.maybeMoveToResponseJsonSchem(params);
|
|
14360
14512
|
if (shouldDisableAfc(params.config)) {
|
|
14361
|
-
const transformedParams = await this.
|
|
14513
|
+
const transformedParams = await this.processParamsMaybeAddMcpUsage(params);
|
|
14362
14514
|
return await this.generateContentStreamInternal(transformedParams);
|
|
14363
14515
|
}
|
|
14364
14516
|
else {
|
|
@@ -14507,6 +14659,32 @@ class Models extends BaseModule {
|
|
|
14507
14659
|
};
|
|
14508
14660
|
return await this.upscaleImageInternal(apiParams);
|
|
14509
14661
|
};
|
|
14662
|
+
/**
|
|
14663
|
+
* Generates videos based on a text description and configuration.
|
|
14664
|
+
*
|
|
14665
|
+
* @param params - The parameters for generating videos.
|
|
14666
|
+
* @return A Promise<GenerateVideosOperation> which allows you to track the progress and eventually retrieve the generated videos using the operations.get method.
|
|
14667
|
+
*
|
|
14668
|
+
* @example
|
|
14669
|
+
* ```ts
|
|
14670
|
+
* const operation = await ai.models.generateVideos({
|
|
14671
|
+
* model: 'veo-2.0-generate-001',
|
|
14672
|
+
* prompt: 'A neon hologram of a cat driving at top speed',
|
|
14673
|
+
* config: {
|
|
14674
|
+
* numberOfVideos: 1
|
|
14675
|
+
* });
|
|
14676
|
+
*
|
|
14677
|
+
* while (!operation.done) {
|
|
14678
|
+
* await new Promise(resolve => setTimeout(resolve, 10000));
|
|
14679
|
+
* operation = await ai.operations.getVideosOperation({operation: operation});
|
|
14680
|
+
* }
|
|
14681
|
+
*
|
|
14682
|
+
* console.log(operation.response?.generatedVideos?.[0]?.video?.uri);
|
|
14683
|
+
* ```
|
|
14684
|
+
*/
|
|
14685
|
+
this.generateVideos = async (params) => {
|
|
14686
|
+
return await this.generateVideosInternal(params);
|
|
14687
|
+
};
|
|
14510
14688
|
}
|
|
14511
14689
|
/**
|
|
14512
14690
|
* This logic is needed for GenerateContentConfig only.
|
|
@@ -14532,7 +14710,7 @@ class Models extends BaseModule {
|
|
|
14532
14710
|
* modify the original params. Also sets the MCP usage header if there are
|
|
14533
14711
|
* MCP tools in the parameters.
|
|
14534
14712
|
*/
|
|
14535
|
-
async
|
|
14713
|
+
async processParamsMaybeAddMcpUsage(params) {
|
|
14536
14714
|
var _a, _b, _c;
|
|
14537
14715
|
const tools = (_a = params.config) === null || _a === void 0 ? void 0 : _a.tools;
|
|
14538
14716
|
if (!tools) {
|
|
@@ -14599,7 +14777,7 @@ class Models extends BaseModule {
|
|
|
14599
14777
|
remoteCallCount++;
|
|
14600
14778
|
wereFunctionsCalled = false;
|
|
14601
14779
|
}
|
|
14602
|
-
const transformedParams = yield __await(models.
|
|
14780
|
+
const transformedParams = yield __await(models.processParamsMaybeAddMcpUsage(params));
|
|
14603
14781
|
const response = yield __await(models.generateContentStreamInternal(transformedParams));
|
|
14604
14782
|
const functionResponses = [];
|
|
14605
14783
|
const responseContents = [];
|
|
@@ -15137,7 +15315,13 @@ class Models extends BaseModule {
|
|
|
15137
15315
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
15138
15316
|
})
|
|
15139
15317
|
.then((httpResponse) => {
|
|
15140
|
-
return httpResponse.json()
|
|
15318
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
15319
|
+
const response = jsonResponse;
|
|
15320
|
+
response.sdkHttpResponse = {
|
|
15321
|
+
headers: httpResponse.headers,
|
|
15322
|
+
};
|
|
15323
|
+
return response;
|
|
15324
|
+
});
|
|
15141
15325
|
});
|
|
15142
15326
|
return response.then((apiResponse) => {
|
|
15143
15327
|
const resp = listModelsResponseFromVertex(apiResponse);
|
|
@@ -15163,7 +15347,13 @@ class Models extends BaseModule {
|
|
|
15163
15347
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
15164
15348
|
})
|
|
15165
15349
|
.then((httpResponse) => {
|
|
15166
|
-
return httpResponse.json()
|
|
15350
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
15351
|
+
const response = jsonResponse;
|
|
15352
|
+
response.sdkHttpResponse = {
|
|
15353
|
+
headers: httpResponse.headers,
|
|
15354
|
+
};
|
|
15355
|
+
return response;
|
|
15356
|
+
});
|
|
15167
15357
|
});
|
|
15168
15358
|
return response.then((apiResponse) => {
|
|
15169
15359
|
const resp = listModelsResponseFromMldev(apiResponse);
|
|
@@ -15463,7 +15653,7 @@ class Models extends BaseModule {
|
|
|
15463
15653
|
* console.log(operation.response?.generatedVideos?.[0]?.video?.uri);
|
|
15464
15654
|
* ```
|
|
15465
15655
|
*/
|
|
15466
|
-
async
|
|
15656
|
+
async generateVideosInternal(params) {
|
|
15467
15657
|
var _a, _b, _c, _d;
|
|
15468
15658
|
let response;
|
|
15469
15659
|
let path = '';
|
|
@@ -15488,8 +15678,10 @@ class Models extends BaseModule {
|
|
|
15488
15678
|
return httpResponse.json();
|
|
15489
15679
|
});
|
|
15490
15680
|
return response.then((apiResponse) => {
|
|
15491
|
-
const resp = generateVideosOperationFromVertex
|
|
15492
|
-
|
|
15681
|
+
const resp = generateVideosOperationFromVertex(apiResponse);
|
|
15682
|
+
const typedResp = new GenerateVideosOperation();
|
|
15683
|
+
Object.assign(typedResp, resp);
|
|
15684
|
+
return typedResp;
|
|
15493
15685
|
});
|
|
15494
15686
|
}
|
|
15495
15687
|
else {
|
|
@@ -15512,8 +15704,10 @@ class Models extends BaseModule {
|
|
|
15512
15704
|
return httpResponse.json();
|
|
15513
15705
|
});
|
|
15514
15706
|
return response.then((apiResponse) => {
|
|
15515
|
-
const resp = generateVideosOperationFromMldev
|
|
15516
|
-
|
|
15707
|
+
const resp = generateVideosOperationFromMldev(apiResponse);
|
|
15708
|
+
const typedResp = new GenerateVideosOperation();
|
|
15709
|
+
Object.assign(typedResp, resp);
|
|
15710
|
+
return typedResp;
|
|
15517
15711
|
});
|
|
15518
15712
|
}
|
|
15519
15713
|
}
|
|
@@ -15571,164 +15765,6 @@ function fetchPredictOperationParametersToVertex(fromObject) {
|
|
|
15571
15765
|
}
|
|
15572
15766
|
return toObject;
|
|
15573
15767
|
}
|
|
15574
|
-
function videoFromMldev(fromObject) {
|
|
15575
|
-
const toObject = {};
|
|
15576
|
-
const fromUri = getValueByPath(fromObject, ['video', 'uri']);
|
|
15577
|
-
if (fromUri != null) {
|
|
15578
|
-
setValueByPath(toObject, ['uri'], fromUri);
|
|
15579
|
-
}
|
|
15580
|
-
const fromVideoBytes = getValueByPath(fromObject, [
|
|
15581
|
-
'video',
|
|
15582
|
-
'encodedVideo',
|
|
15583
|
-
]);
|
|
15584
|
-
if (fromVideoBytes != null) {
|
|
15585
|
-
setValueByPath(toObject, ['videoBytes'], tBytes(fromVideoBytes));
|
|
15586
|
-
}
|
|
15587
|
-
const fromMimeType = getValueByPath(fromObject, ['encoding']);
|
|
15588
|
-
if (fromMimeType != null) {
|
|
15589
|
-
setValueByPath(toObject, ['mimeType'], fromMimeType);
|
|
15590
|
-
}
|
|
15591
|
-
return toObject;
|
|
15592
|
-
}
|
|
15593
|
-
function generatedVideoFromMldev(fromObject) {
|
|
15594
|
-
const toObject = {};
|
|
15595
|
-
const fromVideo = getValueByPath(fromObject, ['_self']);
|
|
15596
|
-
if (fromVideo != null) {
|
|
15597
|
-
setValueByPath(toObject, ['video'], videoFromMldev(fromVideo));
|
|
15598
|
-
}
|
|
15599
|
-
return toObject;
|
|
15600
|
-
}
|
|
15601
|
-
function generateVideosResponseFromMldev(fromObject) {
|
|
15602
|
-
const toObject = {};
|
|
15603
|
-
const fromGeneratedVideos = getValueByPath(fromObject, [
|
|
15604
|
-
'generatedSamples',
|
|
15605
|
-
]);
|
|
15606
|
-
if (fromGeneratedVideos != null) {
|
|
15607
|
-
let transformedList = fromGeneratedVideos;
|
|
15608
|
-
if (Array.isArray(transformedList)) {
|
|
15609
|
-
transformedList = transformedList.map((item) => {
|
|
15610
|
-
return generatedVideoFromMldev(item);
|
|
15611
|
-
});
|
|
15612
|
-
}
|
|
15613
|
-
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
15614
|
-
}
|
|
15615
|
-
const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
|
|
15616
|
-
'raiMediaFilteredCount',
|
|
15617
|
-
]);
|
|
15618
|
-
if (fromRaiMediaFilteredCount != null) {
|
|
15619
|
-
setValueByPath(toObject, ['raiMediaFilteredCount'], fromRaiMediaFilteredCount);
|
|
15620
|
-
}
|
|
15621
|
-
const fromRaiMediaFilteredReasons = getValueByPath(fromObject, [
|
|
15622
|
-
'raiMediaFilteredReasons',
|
|
15623
|
-
]);
|
|
15624
|
-
if (fromRaiMediaFilteredReasons != null) {
|
|
15625
|
-
setValueByPath(toObject, ['raiMediaFilteredReasons'], fromRaiMediaFilteredReasons);
|
|
15626
|
-
}
|
|
15627
|
-
return toObject;
|
|
15628
|
-
}
|
|
15629
|
-
function generateVideosOperationFromMldev(fromObject) {
|
|
15630
|
-
const toObject = {};
|
|
15631
|
-
const fromName = getValueByPath(fromObject, ['name']);
|
|
15632
|
-
if (fromName != null) {
|
|
15633
|
-
setValueByPath(toObject, ['name'], fromName);
|
|
15634
|
-
}
|
|
15635
|
-
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
15636
|
-
if (fromMetadata != null) {
|
|
15637
|
-
setValueByPath(toObject, ['metadata'], fromMetadata);
|
|
15638
|
-
}
|
|
15639
|
-
const fromDone = getValueByPath(fromObject, ['done']);
|
|
15640
|
-
if (fromDone != null) {
|
|
15641
|
-
setValueByPath(toObject, ['done'], fromDone);
|
|
15642
|
-
}
|
|
15643
|
-
const fromError = getValueByPath(fromObject, ['error']);
|
|
15644
|
-
if (fromError != null) {
|
|
15645
|
-
setValueByPath(toObject, ['error'], fromError);
|
|
15646
|
-
}
|
|
15647
|
-
const fromResponse = getValueByPath(fromObject, [
|
|
15648
|
-
'response',
|
|
15649
|
-
'generateVideoResponse',
|
|
15650
|
-
]);
|
|
15651
|
-
if (fromResponse != null) {
|
|
15652
|
-
setValueByPath(toObject, ['response'], generateVideosResponseFromMldev(fromResponse));
|
|
15653
|
-
}
|
|
15654
|
-
return toObject;
|
|
15655
|
-
}
|
|
15656
|
-
function videoFromVertex(fromObject) {
|
|
15657
|
-
const toObject = {};
|
|
15658
|
-
const fromUri = getValueByPath(fromObject, ['gcsUri']);
|
|
15659
|
-
if (fromUri != null) {
|
|
15660
|
-
setValueByPath(toObject, ['uri'], fromUri);
|
|
15661
|
-
}
|
|
15662
|
-
const fromVideoBytes = getValueByPath(fromObject, [
|
|
15663
|
-
'bytesBase64Encoded',
|
|
15664
|
-
]);
|
|
15665
|
-
if (fromVideoBytes != null) {
|
|
15666
|
-
setValueByPath(toObject, ['videoBytes'], tBytes(fromVideoBytes));
|
|
15667
|
-
}
|
|
15668
|
-
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
15669
|
-
if (fromMimeType != null) {
|
|
15670
|
-
setValueByPath(toObject, ['mimeType'], fromMimeType);
|
|
15671
|
-
}
|
|
15672
|
-
return toObject;
|
|
15673
|
-
}
|
|
15674
|
-
function generatedVideoFromVertex(fromObject) {
|
|
15675
|
-
const toObject = {};
|
|
15676
|
-
const fromVideo = getValueByPath(fromObject, ['_self']);
|
|
15677
|
-
if (fromVideo != null) {
|
|
15678
|
-
setValueByPath(toObject, ['video'], videoFromVertex(fromVideo));
|
|
15679
|
-
}
|
|
15680
|
-
return toObject;
|
|
15681
|
-
}
|
|
15682
|
-
function generateVideosResponseFromVertex(fromObject) {
|
|
15683
|
-
const toObject = {};
|
|
15684
|
-
const fromGeneratedVideos = getValueByPath(fromObject, ['videos']);
|
|
15685
|
-
if (fromGeneratedVideos != null) {
|
|
15686
|
-
let transformedList = fromGeneratedVideos;
|
|
15687
|
-
if (Array.isArray(transformedList)) {
|
|
15688
|
-
transformedList = transformedList.map((item) => {
|
|
15689
|
-
return generatedVideoFromVertex(item);
|
|
15690
|
-
});
|
|
15691
|
-
}
|
|
15692
|
-
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
15693
|
-
}
|
|
15694
|
-
const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
|
|
15695
|
-
'raiMediaFilteredCount',
|
|
15696
|
-
]);
|
|
15697
|
-
if (fromRaiMediaFilteredCount != null) {
|
|
15698
|
-
setValueByPath(toObject, ['raiMediaFilteredCount'], fromRaiMediaFilteredCount);
|
|
15699
|
-
}
|
|
15700
|
-
const fromRaiMediaFilteredReasons = getValueByPath(fromObject, [
|
|
15701
|
-
'raiMediaFilteredReasons',
|
|
15702
|
-
]);
|
|
15703
|
-
if (fromRaiMediaFilteredReasons != null) {
|
|
15704
|
-
setValueByPath(toObject, ['raiMediaFilteredReasons'], fromRaiMediaFilteredReasons);
|
|
15705
|
-
}
|
|
15706
|
-
return toObject;
|
|
15707
|
-
}
|
|
15708
|
-
function generateVideosOperationFromVertex(fromObject) {
|
|
15709
|
-
const toObject = {};
|
|
15710
|
-
const fromName = getValueByPath(fromObject, ['name']);
|
|
15711
|
-
if (fromName != null) {
|
|
15712
|
-
setValueByPath(toObject, ['name'], fromName);
|
|
15713
|
-
}
|
|
15714
|
-
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
15715
|
-
if (fromMetadata != null) {
|
|
15716
|
-
setValueByPath(toObject, ['metadata'], fromMetadata);
|
|
15717
|
-
}
|
|
15718
|
-
const fromDone = getValueByPath(fromObject, ['done']);
|
|
15719
|
-
if (fromDone != null) {
|
|
15720
|
-
setValueByPath(toObject, ['done'], fromDone);
|
|
15721
|
-
}
|
|
15722
|
-
const fromError = getValueByPath(fromObject, ['error']);
|
|
15723
|
-
if (fromError != null) {
|
|
15724
|
-
setValueByPath(toObject, ['error'], fromError);
|
|
15725
|
-
}
|
|
15726
|
-
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
15727
|
-
if (fromResponse != null) {
|
|
15728
|
-
setValueByPath(toObject, ['response'], generateVideosResponseFromVertex(fromResponse));
|
|
15729
|
-
}
|
|
15730
|
-
return toObject;
|
|
15731
|
-
}
|
|
15732
15768
|
|
|
15733
15769
|
/**
|
|
15734
15770
|
* @license
|
|
@@ -15758,17 +15794,64 @@ class Operations extends BaseModule {
|
|
|
15758
15794
|
if (config && 'httpOptions' in config) {
|
|
15759
15795
|
httpOptions = config.httpOptions;
|
|
15760
15796
|
}
|
|
15761
|
-
|
|
15797
|
+
const rawOperation = await this.fetchPredictVideosOperationInternal({
|
|
15762
15798
|
operationName: operation.name,
|
|
15763
15799
|
resourceName: resourceName,
|
|
15764
15800
|
config: { httpOptions: httpOptions },
|
|
15765
15801
|
});
|
|
15802
|
+
return operation._fromAPIResponse({
|
|
15803
|
+
apiResponse: rawOperation,
|
|
15804
|
+
isVertexAI: true,
|
|
15805
|
+
});
|
|
15766
15806
|
}
|
|
15767
15807
|
else {
|
|
15768
|
-
|
|
15808
|
+
const rawOperation = await this.getVideosOperationInternal({
|
|
15769
15809
|
operationName: operation.name,
|
|
15770
15810
|
config: config,
|
|
15771
15811
|
});
|
|
15812
|
+
return operation._fromAPIResponse({
|
|
15813
|
+
apiResponse: rawOperation,
|
|
15814
|
+
isVertexAI: false,
|
|
15815
|
+
});
|
|
15816
|
+
}
|
|
15817
|
+
}
|
|
15818
|
+
/**
|
|
15819
|
+
* Gets the status of a long-running operation.
|
|
15820
|
+
*
|
|
15821
|
+
* @param parameters The parameters for the get operation request.
|
|
15822
|
+
* @return The updated Operation object, with the latest status or result.
|
|
15823
|
+
*/
|
|
15824
|
+
async get(parameters) {
|
|
15825
|
+
const operation = parameters.operation;
|
|
15826
|
+
const config = parameters.config;
|
|
15827
|
+
if (operation.name === undefined || operation.name === '') {
|
|
15828
|
+
throw new Error('Operation name is required.');
|
|
15829
|
+
}
|
|
15830
|
+
if (this.apiClient.isVertexAI()) {
|
|
15831
|
+
const resourceName = operation.name.split('/operations/')[0];
|
|
15832
|
+
let httpOptions = undefined;
|
|
15833
|
+
if (config && 'httpOptions' in config) {
|
|
15834
|
+
httpOptions = config.httpOptions;
|
|
15835
|
+
}
|
|
15836
|
+
const rawOperation = await this.fetchPredictVideosOperationInternal({
|
|
15837
|
+
operationName: operation.name,
|
|
15838
|
+
resourceName: resourceName,
|
|
15839
|
+
config: { httpOptions: httpOptions },
|
|
15840
|
+
});
|
|
15841
|
+
return operation._fromAPIResponse({
|
|
15842
|
+
apiResponse: rawOperation,
|
|
15843
|
+
isVertexAI: true,
|
|
15844
|
+
});
|
|
15845
|
+
}
|
|
15846
|
+
else {
|
|
15847
|
+
const rawOperation = await this.getVideosOperationInternal({
|
|
15848
|
+
operationName: operation.name,
|
|
15849
|
+
config: config,
|
|
15850
|
+
});
|
|
15851
|
+
return operation._fromAPIResponse({
|
|
15852
|
+
apiResponse: rawOperation,
|
|
15853
|
+
isVertexAI: false,
|
|
15854
|
+
});
|
|
15772
15855
|
}
|
|
15773
15856
|
}
|
|
15774
15857
|
async getVideosOperationInternal(params) {
|
|
@@ -15795,10 +15878,7 @@ class Operations extends BaseModule {
|
|
|
15795
15878
|
.then((httpResponse) => {
|
|
15796
15879
|
return httpResponse.json();
|
|
15797
15880
|
});
|
|
15798
|
-
return response
|
|
15799
|
-
const resp = generateVideosOperationFromVertex(apiResponse);
|
|
15800
|
-
return resp;
|
|
15801
|
-
});
|
|
15881
|
+
return response;
|
|
15802
15882
|
}
|
|
15803
15883
|
else {
|
|
15804
15884
|
const body = getOperationParametersToMldev(params);
|
|
@@ -15819,10 +15899,7 @@ class Operations extends BaseModule {
|
|
|
15819
15899
|
.then((httpResponse) => {
|
|
15820
15900
|
return httpResponse.json();
|
|
15821
15901
|
});
|
|
15822
|
-
return response
|
|
15823
|
-
const resp = generateVideosOperationFromMldev(apiResponse);
|
|
15824
|
-
return resp;
|
|
15825
|
-
});
|
|
15902
|
+
return response;
|
|
15826
15903
|
}
|
|
15827
15904
|
}
|
|
15828
15905
|
async fetchPredictVideosOperationInternal(params) {
|
|
@@ -15849,10 +15926,7 @@ class Operations extends BaseModule {
|
|
|
15849
15926
|
.then((httpResponse) => {
|
|
15850
15927
|
return httpResponse.json();
|
|
15851
15928
|
});
|
|
15852
|
-
return response
|
|
15853
|
-
const resp = generateVideosOperationFromVertex(apiResponse);
|
|
15854
|
-
return resp;
|
|
15855
|
-
});
|
|
15929
|
+
return response;
|
|
15856
15930
|
}
|
|
15857
15931
|
else {
|
|
15858
15932
|
throw new Error('This method is only supported by the Vertex AI.');
|
|
@@ -17253,6 +17327,12 @@ function tuningJobFromMldev(fromObject) {
|
|
|
17253
17327
|
}
|
|
17254
17328
|
function listTuningJobsResponseFromMldev(fromObject) {
|
|
17255
17329
|
const toObject = {};
|
|
17330
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
17331
|
+
'sdkHttpResponse',
|
|
17332
|
+
]);
|
|
17333
|
+
if (fromSdkHttpResponse != null) {
|
|
17334
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
17335
|
+
}
|
|
17256
17336
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
17257
17337
|
'nextPageToken',
|
|
17258
17338
|
]);
|
|
@@ -17441,6 +17521,12 @@ function tuningJobFromVertex(fromObject) {
|
|
|
17441
17521
|
}
|
|
17442
17522
|
function listTuningJobsResponseFromVertex(fromObject) {
|
|
17443
17523
|
const toObject = {};
|
|
17524
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
17525
|
+
'sdkHttpResponse',
|
|
17526
|
+
]);
|
|
17527
|
+
if (fromSdkHttpResponse != null) {
|
|
17528
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
17529
|
+
}
|
|
17444
17530
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
17445
17531
|
'nextPageToken',
|
|
17446
17532
|
]);
|
|
@@ -17601,7 +17687,13 @@ class Tunings extends BaseModule {
|
|
|
17601
17687
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
17602
17688
|
})
|
|
17603
17689
|
.then((httpResponse) => {
|
|
17604
|
-
return httpResponse.json()
|
|
17690
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
17691
|
+
const response = jsonResponse;
|
|
17692
|
+
response.sdkHttpResponse = {
|
|
17693
|
+
headers: httpResponse.headers,
|
|
17694
|
+
};
|
|
17695
|
+
return response;
|
|
17696
|
+
});
|
|
17605
17697
|
});
|
|
17606
17698
|
return response.then((apiResponse) => {
|
|
17607
17699
|
const resp = listTuningJobsResponseFromVertex(apiResponse);
|
|
@@ -17627,7 +17719,13 @@ class Tunings extends BaseModule {
|
|
|
17627
17719
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
17628
17720
|
})
|
|
17629
17721
|
.then((httpResponse) => {
|
|
17630
|
-
return httpResponse.json()
|
|
17722
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
17723
|
+
const response = jsonResponse;
|
|
17724
|
+
response.sdkHttpResponse = {
|
|
17725
|
+
headers: httpResponse.headers,
|
|
17726
|
+
};
|
|
17727
|
+
return response;
|
|
17728
|
+
});
|
|
17631
17729
|
});
|
|
17632
17730
|
return response.then((apiResponse) => {
|
|
17633
17731
|
const resp = listTuningJobsResponseFromMldev(apiResponse);
|
|
@@ -18052,7 +18150,7 @@ class GoogleGenAI {
|
|
|
18052
18150
|
this.apiKey = undefined;
|
|
18053
18151
|
}
|
|
18054
18152
|
}
|
|
18055
|
-
const baseUrl = getBaseUrl(options, getEnv('GOOGLE_VERTEX_BASE_URL'), getEnv('GOOGLE_GEMINI_BASE_URL'));
|
|
18153
|
+
const baseUrl = getBaseUrl(options.httpOptions, options.vertexai, getEnv('GOOGLE_VERTEX_BASE_URL'), getEnv('GOOGLE_GEMINI_BASE_URL'));
|
|
18056
18154
|
if (baseUrl) {
|
|
18057
18155
|
if (options.httpOptions) {
|
|
18058
18156
|
options.httpOptions.baseUrl = baseUrl;
|
|
@@ -18111,5 +18209,5 @@ function getApiKeyFromEnv() {
|
|
|
18111
18209
|
return envGoogleApiKey || envGeminiApiKey;
|
|
18112
18210
|
}
|
|
18113
18211
|
|
|
18114
|
-
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 };
|
|
18212
|
+
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 };
|
|
18115
18213
|
//# sourceMappingURL=index.mjs.map
|