@google/genai 1.10.0 → 1.12.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 +113 -18
- package/dist/index.cjs +497 -246
- package/dist/index.mjs +497 -247
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.cjs +509 -258
- package/dist/node/index.mjs +509 -259
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/node.d.ts +113 -18
- package/dist/web/index.mjs +504 -254
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +113 -18
- package/package.json +5 -5
package/dist/web/index.mjs
CHANGED
|
@@ -44,18 +44,18 @@ function getDefaultBaseUrls() {
|
|
|
44
44
|
* 2. Base URLs set via the latest call to setDefaultBaseUrls.
|
|
45
45
|
* 3. Base URLs set via environment variables.
|
|
46
46
|
*/
|
|
47
|
-
function getBaseUrl(
|
|
48
|
-
var _a, _b
|
|
49
|
-
if (!(
|
|
47
|
+
function getBaseUrl(httpOptions, vertexai, vertexBaseUrlFromEnv, geminiBaseUrlFromEnv) {
|
|
48
|
+
var _a, _b;
|
|
49
|
+
if (!(httpOptions === null || httpOptions === void 0 ? void 0 : httpOptions.baseUrl)) {
|
|
50
50
|
const defaultBaseUrls = getDefaultBaseUrls();
|
|
51
|
-
if (
|
|
52
|
-
return (
|
|
51
|
+
if (vertexai) {
|
|
52
|
+
return (_a = defaultBaseUrls.vertexUrl) !== null && _a !== void 0 ? _a : vertexBaseUrlFromEnv;
|
|
53
53
|
}
|
|
54
54
|
else {
|
|
55
|
-
return (
|
|
55
|
+
return (_b = defaultBaseUrls.geminiUrl) !== null && _b !== void 0 ? _b : geminiBaseUrlFromEnv;
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
return
|
|
58
|
+
return httpOptions.baseUrl;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
/**
|
|
@@ -190,6 +190,20 @@ function getValueByPath(data, keys) {
|
|
|
190
190
|
* Copyright 2025 Google LLC
|
|
191
191
|
* SPDX-License-Identifier: Apache-2.0
|
|
192
192
|
*/
|
|
193
|
+
function tBytes$1(fromBytes) {
|
|
194
|
+
if (typeof fromBytes !== 'string') {
|
|
195
|
+
throw new Error('fromImageBytes must be a string');
|
|
196
|
+
}
|
|
197
|
+
// TODO(b/389133914): Remove dummy bytes converter.
|
|
198
|
+
return fromBytes;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* @license
|
|
203
|
+
* Copyright 2025 Google LLC
|
|
204
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
205
|
+
*/
|
|
206
|
+
// Code generated by the Google Gen AI SDK generator DO NOT EDIT.
|
|
193
207
|
/** Required. Outcome of the code execution. */
|
|
194
208
|
var Outcome;
|
|
195
209
|
(function (Outcome) {
|
|
@@ -1683,6 +1697,65 @@ class LiveServerMessage {
|
|
|
1683
1697
|
return data.length > 0 ? btoa(data) : undefined;
|
|
1684
1698
|
}
|
|
1685
1699
|
}
|
|
1700
|
+
/** A video generation long-running operation. */
|
|
1701
|
+
class GenerateVideosOperation {
|
|
1702
|
+
/**
|
|
1703
|
+
* Instantiates an Operation of the same type as the one being called with the fields set from the API response.
|
|
1704
|
+
* @internal
|
|
1705
|
+
*/
|
|
1706
|
+
_fromAPIResponse({ apiResponse, isVertexAI, }) {
|
|
1707
|
+
const operation = new GenerateVideosOperation();
|
|
1708
|
+
operation.name = apiResponse['name'];
|
|
1709
|
+
operation.metadata = apiResponse['metadata'];
|
|
1710
|
+
operation.done = apiResponse['done'];
|
|
1711
|
+
operation.error = apiResponse['error'];
|
|
1712
|
+
if (isVertexAI) {
|
|
1713
|
+
const response = apiResponse['response'];
|
|
1714
|
+
if (response) {
|
|
1715
|
+
const operationResponse = new GenerateVideosResponse();
|
|
1716
|
+
const responseVideos = response['videos'];
|
|
1717
|
+
operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
|
|
1718
|
+
return {
|
|
1719
|
+
video: {
|
|
1720
|
+
uri: generatedVideo['gcsUri'],
|
|
1721
|
+
videoBytes: generatedVideo['bytesBase64Encoded']
|
|
1722
|
+
? tBytes$1(generatedVideo['bytesBase64Encoded'])
|
|
1723
|
+
: undefined,
|
|
1724
|
+
mimeType: generatedVideo['mimeType'],
|
|
1725
|
+
},
|
|
1726
|
+
};
|
|
1727
|
+
});
|
|
1728
|
+
operationResponse.raiMediaFilteredCount = response['raiMediaFilteredCount'];
|
|
1729
|
+
operationResponse.raiMediaFilteredReasons = response['raiMediaFilteredReasons'];
|
|
1730
|
+
operation.response = operationResponse;
|
|
1731
|
+
}
|
|
1732
|
+
}
|
|
1733
|
+
else {
|
|
1734
|
+
const response = apiResponse['response'];
|
|
1735
|
+
if (response) {
|
|
1736
|
+
const operationResponse = new GenerateVideosResponse();
|
|
1737
|
+
const generatedVideoResponse = response['generateVideoResponse'];
|
|
1738
|
+
const responseVideos = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['generatedSamples'];
|
|
1739
|
+
operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
|
|
1740
|
+
const video = generatedVideo['video'];
|
|
1741
|
+
return {
|
|
1742
|
+
video: {
|
|
1743
|
+
uri: video === null || video === void 0 ? void 0 : video['uri'],
|
|
1744
|
+
videoBytes: (video === null || video === void 0 ? void 0 : video['encodedVideo'])
|
|
1745
|
+
? tBytes$1(video === null || video === void 0 ? void 0 : video['encodedVideo'])
|
|
1746
|
+
: undefined,
|
|
1747
|
+
mimeType: generatedVideo['encoding'],
|
|
1748
|
+
},
|
|
1749
|
+
};
|
|
1750
|
+
});
|
|
1751
|
+
operationResponse.raiMediaFilteredCount = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredCount'];
|
|
1752
|
+
operationResponse.raiMediaFilteredReasons = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredReasons'];
|
|
1753
|
+
operation.response = operationResponse;
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
return operation;
|
|
1757
|
+
}
|
|
1758
|
+
}
|
|
1686
1759
|
/** Client generated response to a `ToolCall` received from the server.
|
|
1687
1760
|
|
|
1688
1761
|
Individual `FunctionResponse` objects are matched to the respective
|
|
@@ -2244,11 +2317,7 @@ function tTuningJobStatus(status) {
|
|
|
2244
2317
|
}
|
|
2245
2318
|
}
|
|
2246
2319
|
function tBytes(fromImageBytes) {
|
|
2247
|
-
|
|
2248
|
-
throw new Error('fromImageBytes must be a string');
|
|
2249
|
-
}
|
|
2250
|
-
// TODO(b/389133914): Remove dummy bytes converter.
|
|
2251
|
-
return fromImageBytes;
|
|
2320
|
+
return tBytes$1(fromImageBytes);
|
|
2252
2321
|
}
|
|
2253
2322
|
function _isFile(origin) {
|
|
2254
2323
|
return (origin !== null &&
|
|
@@ -3736,6 +3805,12 @@ function batchJobFromMldev(fromObject) {
|
|
|
3736
3805
|
}
|
|
3737
3806
|
function listBatchJobsResponseFromMldev(fromObject) {
|
|
3738
3807
|
const toObject = {};
|
|
3808
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
3809
|
+
'sdkHttpResponse',
|
|
3810
|
+
]);
|
|
3811
|
+
if (fromSdkHttpResponse != null) {
|
|
3812
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
3813
|
+
}
|
|
3739
3814
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
3740
3815
|
'nextPageToken',
|
|
3741
3816
|
]);
|
|
@@ -3877,6 +3952,12 @@ function batchJobFromVertex(fromObject) {
|
|
|
3877
3952
|
}
|
|
3878
3953
|
function listBatchJobsResponseFromVertex(fromObject) {
|
|
3879
3954
|
const toObject = {};
|
|
3955
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
3956
|
+
'sdkHttpResponse',
|
|
3957
|
+
]);
|
|
3958
|
+
if (fromSdkHttpResponse != null) {
|
|
3959
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
3960
|
+
}
|
|
3880
3961
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
3881
3962
|
'nextPageToken',
|
|
3882
3963
|
]);
|
|
@@ -3919,9 +4000,6 @@ function deleteResourceJobFromVertex(fromObject) {
|
|
|
3919
4000
|
* Copyright 2025 Google LLC
|
|
3920
4001
|
* SPDX-License-Identifier: Apache-2.0
|
|
3921
4002
|
*/
|
|
3922
|
-
/**
|
|
3923
|
-
* Pagers for the GenAI List APIs.
|
|
3924
|
-
*/
|
|
3925
4003
|
var PagedItem;
|
|
3926
4004
|
(function (PagedItem) {
|
|
3927
4005
|
PagedItem["PAGED_ITEM_BATCH_JOBS"] = "batchJobs";
|
|
@@ -3944,9 +4022,10 @@ class Pager {
|
|
|
3944
4022
|
var _a, _b;
|
|
3945
4023
|
this.nameInternal = name;
|
|
3946
4024
|
this.pageInternal = response[this.nameInternal] || [];
|
|
4025
|
+
this.sdkHttpResponseInternal = response === null || response === void 0 ? void 0 : response.sdkHttpResponse;
|
|
3947
4026
|
this.idxInternal = 0;
|
|
3948
4027
|
let requestParams = { config: {} };
|
|
3949
|
-
if (!params) {
|
|
4028
|
+
if (!params || Object.keys(params).length === 0) {
|
|
3950
4029
|
requestParams = { config: {} };
|
|
3951
4030
|
}
|
|
3952
4031
|
else if (typeof params === 'object') {
|
|
@@ -3990,6 +4069,12 @@ class Pager {
|
|
|
3990
4069
|
get pageSize() {
|
|
3991
4070
|
return this.pageInternalSize;
|
|
3992
4071
|
}
|
|
4072
|
+
/**
|
|
4073
|
+
* Returns the headers of the API response.
|
|
4074
|
+
*/
|
|
4075
|
+
get sdkHttpResponse() {
|
|
4076
|
+
return this.sdkHttpResponseInternal;
|
|
4077
|
+
}
|
|
3993
4078
|
/**
|
|
3994
4079
|
* Returns the parameters when making the API request for the next page.
|
|
3995
4080
|
*
|
|
@@ -4359,7 +4444,13 @@ class Batches extends BaseModule {
|
|
|
4359
4444
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
4360
4445
|
})
|
|
4361
4446
|
.then((httpResponse) => {
|
|
4362
|
-
return httpResponse.json()
|
|
4447
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
4448
|
+
const response = jsonResponse;
|
|
4449
|
+
response.sdkHttpResponse = {
|
|
4450
|
+
headers: httpResponse.headers,
|
|
4451
|
+
};
|
|
4452
|
+
return response;
|
|
4453
|
+
});
|
|
4363
4454
|
});
|
|
4364
4455
|
return response.then((apiResponse) => {
|
|
4365
4456
|
const resp = listBatchJobsResponseFromVertex(apiResponse);
|
|
@@ -4385,7 +4476,13 @@ class Batches extends BaseModule {
|
|
|
4385
4476
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
4386
4477
|
})
|
|
4387
4478
|
.then((httpResponse) => {
|
|
4388
|
-
return httpResponse.json()
|
|
4479
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
4480
|
+
const response = jsonResponse;
|
|
4481
|
+
response.sdkHttpResponse = {
|
|
4482
|
+
headers: httpResponse.headers,
|
|
4483
|
+
};
|
|
4484
|
+
return response;
|
|
4485
|
+
});
|
|
4389
4486
|
});
|
|
4390
4487
|
return response.then((apiResponse) => {
|
|
4391
4488
|
const resp = listBatchJobsResponseFromMldev(apiResponse);
|
|
@@ -5438,6 +5535,12 @@ function deleteCachedContentResponseFromMldev() {
|
|
|
5438
5535
|
}
|
|
5439
5536
|
function listCachedContentsResponseFromMldev(fromObject) {
|
|
5440
5537
|
const toObject = {};
|
|
5538
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
5539
|
+
'sdkHttpResponse',
|
|
5540
|
+
]);
|
|
5541
|
+
if (fromSdkHttpResponse != null) {
|
|
5542
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
5543
|
+
}
|
|
5441
5544
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
5442
5545
|
'nextPageToken',
|
|
5443
5546
|
]);
|
|
@@ -5498,6 +5601,12 @@ function deleteCachedContentResponseFromVertex() {
|
|
|
5498
5601
|
}
|
|
5499
5602
|
function listCachedContentsResponseFromVertex(fromObject) {
|
|
5500
5603
|
const toObject = {};
|
|
5604
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
5605
|
+
'sdkHttpResponse',
|
|
5606
|
+
]);
|
|
5607
|
+
if (fromSdkHttpResponse != null) {
|
|
5608
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
5609
|
+
}
|
|
5501
5610
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
5502
5611
|
'nextPageToken',
|
|
5503
5612
|
]);
|
|
@@ -5850,7 +5959,13 @@ class Caches extends BaseModule {
|
|
|
5850
5959
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
5851
5960
|
})
|
|
5852
5961
|
.then((httpResponse) => {
|
|
5853
|
-
return httpResponse.json()
|
|
5962
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
5963
|
+
const response = jsonResponse;
|
|
5964
|
+
response.sdkHttpResponse = {
|
|
5965
|
+
headers: httpResponse.headers,
|
|
5966
|
+
};
|
|
5967
|
+
return response;
|
|
5968
|
+
});
|
|
5854
5969
|
});
|
|
5855
5970
|
return response.then((apiResponse) => {
|
|
5856
5971
|
const resp = listCachedContentsResponseFromVertex(apiResponse);
|
|
@@ -5876,7 +5991,13 @@ class Caches extends BaseModule {
|
|
|
5876
5991
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
5877
5992
|
})
|
|
5878
5993
|
.then((httpResponse) => {
|
|
5879
|
-
return httpResponse.json()
|
|
5994
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
5995
|
+
const response = jsonResponse;
|
|
5996
|
+
response.sdkHttpResponse = {
|
|
5997
|
+
headers: httpResponse.headers,
|
|
5998
|
+
};
|
|
5999
|
+
return response;
|
|
6000
|
+
});
|
|
5880
6001
|
});
|
|
5881
6002
|
return response.then((apiResponse) => {
|
|
5882
6003
|
const resp = listCachedContentsResponseFromMldev(apiResponse);
|
|
@@ -6514,6 +6635,12 @@ function fileFromMldev(fromObject) {
|
|
|
6514
6635
|
}
|
|
6515
6636
|
function listFilesResponseFromMldev(fromObject) {
|
|
6516
6637
|
const toObject = {};
|
|
6638
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
6639
|
+
'sdkHttpResponse',
|
|
6640
|
+
]);
|
|
6641
|
+
if (fromSdkHttpResponse != null) {
|
|
6642
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
6643
|
+
}
|
|
6517
6644
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
6518
6645
|
'nextPageToken',
|
|
6519
6646
|
]);
|
|
@@ -6675,7 +6802,13 @@ class Files extends BaseModule {
|
|
|
6675
6802
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
6676
6803
|
})
|
|
6677
6804
|
.then((httpResponse) => {
|
|
6678
|
-
return httpResponse.json()
|
|
6805
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
6806
|
+
const response = jsonResponse;
|
|
6807
|
+
response.sdkHttpResponse = {
|
|
6808
|
+
headers: httpResponse.headers,
|
|
6809
|
+
};
|
|
6810
|
+
return response;
|
|
6811
|
+
});
|
|
6679
6812
|
});
|
|
6680
6813
|
return response.then((apiResponse) => {
|
|
6681
6814
|
const resp = listFilesResponseFromMldev(apiResponse);
|
|
@@ -9901,6 +10034,9 @@ function generateImagesConfigToMldev(fromObject, parentObject) {
|
|
|
9901
10034
|
if (getValueByPath(fromObject, ['addWatermark']) !== undefined) {
|
|
9902
10035
|
throw new Error('addWatermark parameter is not supported in Gemini API.');
|
|
9903
10036
|
}
|
|
10037
|
+
if (getValueByPath(fromObject, ['imageSize']) !== undefined) {
|
|
10038
|
+
throw new Error('imageSize parameter is not supported in Gemini API.');
|
|
10039
|
+
}
|
|
9904
10040
|
if (getValueByPath(fromObject, ['enhancePrompt']) !== undefined) {
|
|
9905
10041
|
throw new Error('enhancePrompt parameter is not supported in Gemini API.');
|
|
9906
10042
|
}
|
|
@@ -10977,6 +11113,10 @@ function generateImagesConfigToVertex(fromObject, parentObject) {
|
|
|
10977
11113
|
if (parentObject !== undefined && fromAddWatermark != null) {
|
|
10978
11114
|
setValueByPath(parentObject, ['parameters', 'addWatermark'], fromAddWatermark);
|
|
10979
11115
|
}
|
|
11116
|
+
const fromImageSize = getValueByPath(fromObject, ['imageSize']);
|
|
11117
|
+
if (parentObject !== undefined && fromImageSize != null) {
|
|
11118
|
+
setValueByPath(parentObject, ['parameters', 'sampleImageSize'], fromImageSize);
|
|
11119
|
+
}
|
|
10980
11120
|
const fromEnhancePrompt = getValueByPath(fromObject, [
|
|
10981
11121
|
'enhancePrompt',
|
|
10982
11122
|
]);
|
|
@@ -11815,6 +11955,12 @@ function embedContentMetadataFromMldev() {
|
|
|
11815
11955
|
}
|
|
11816
11956
|
function embedContentResponseFromMldev(fromObject) {
|
|
11817
11957
|
const toObject = {};
|
|
11958
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
11959
|
+
'sdkHttpResponse',
|
|
11960
|
+
]);
|
|
11961
|
+
if (fromSdkHttpResponse != null) {
|
|
11962
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
11963
|
+
}
|
|
11818
11964
|
const fromEmbeddings = getValueByPath(fromObject, ['embeddings']);
|
|
11819
11965
|
if (fromEmbeddings != null) {
|
|
11820
11966
|
let transformedList = fromEmbeddings;
|
|
@@ -11887,6 +12033,12 @@ function generatedImageFromMldev(fromObject) {
|
|
|
11887
12033
|
}
|
|
11888
12034
|
function generateImagesResponseFromMldev(fromObject) {
|
|
11889
12035
|
const toObject = {};
|
|
12036
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
12037
|
+
'sdkHttpResponse',
|
|
12038
|
+
]);
|
|
12039
|
+
if (fromSdkHttpResponse != null) {
|
|
12040
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
12041
|
+
}
|
|
11890
12042
|
const fromGeneratedImages = getValueByPath(fromObject, [
|
|
11891
12043
|
'predictions',
|
|
11892
12044
|
]);
|
|
@@ -11967,6 +12119,12 @@ function modelFromMldev(fromObject) {
|
|
|
11967
12119
|
}
|
|
11968
12120
|
function listModelsResponseFromMldev(fromObject) {
|
|
11969
12121
|
const toObject = {};
|
|
12122
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
12123
|
+
'sdkHttpResponse',
|
|
12124
|
+
]);
|
|
12125
|
+
if (fromSdkHttpResponse != null) {
|
|
12126
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
12127
|
+
}
|
|
11970
12128
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
11971
12129
|
'nextPageToken',
|
|
11972
12130
|
]);
|
|
@@ -11991,6 +12149,12 @@ function deleteModelResponseFromMldev() {
|
|
|
11991
12149
|
}
|
|
11992
12150
|
function countTokensResponseFromMldev(fromObject) {
|
|
11993
12151
|
const toObject = {};
|
|
12152
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
12153
|
+
'sdkHttpResponse',
|
|
12154
|
+
]);
|
|
12155
|
+
if (fromSdkHttpResponse != null) {
|
|
12156
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
12157
|
+
}
|
|
11994
12158
|
const fromTotalTokens = getValueByPath(fromObject, ['totalTokens']);
|
|
11995
12159
|
if (fromTotalTokens != null) {
|
|
11996
12160
|
setValueByPath(toObject, ['totalTokens'], fromTotalTokens);
|
|
@@ -12003,7 +12167,7 @@ function countTokensResponseFromMldev(fromObject) {
|
|
|
12003
12167
|
}
|
|
12004
12168
|
return toObject;
|
|
12005
12169
|
}
|
|
12006
|
-
function videoFromMldev
|
|
12170
|
+
function videoFromMldev(fromObject) {
|
|
12007
12171
|
const toObject = {};
|
|
12008
12172
|
const fromUri = getValueByPath(fromObject, ['video', 'uri']);
|
|
12009
12173
|
if (fromUri != null) {
|
|
@@ -12022,15 +12186,15 @@ function videoFromMldev$1(fromObject) {
|
|
|
12022
12186
|
}
|
|
12023
12187
|
return toObject;
|
|
12024
12188
|
}
|
|
12025
|
-
function generatedVideoFromMldev
|
|
12189
|
+
function generatedVideoFromMldev(fromObject) {
|
|
12026
12190
|
const toObject = {};
|
|
12027
12191
|
const fromVideo = getValueByPath(fromObject, ['_self']);
|
|
12028
12192
|
if (fromVideo != null) {
|
|
12029
|
-
setValueByPath(toObject, ['video'], videoFromMldev
|
|
12193
|
+
setValueByPath(toObject, ['video'], videoFromMldev(fromVideo));
|
|
12030
12194
|
}
|
|
12031
12195
|
return toObject;
|
|
12032
12196
|
}
|
|
12033
|
-
function generateVideosResponseFromMldev
|
|
12197
|
+
function generateVideosResponseFromMldev(fromObject) {
|
|
12034
12198
|
const toObject = {};
|
|
12035
12199
|
const fromGeneratedVideos = getValueByPath(fromObject, [
|
|
12036
12200
|
'generatedSamples',
|
|
@@ -12039,7 +12203,7 @@ function generateVideosResponseFromMldev$1(fromObject) {
|
|
|
12039
12203
|
let transformedList = fromGeneratedVideos;
|
|
12040
12204
|
if (Array.isArray(transformedList)) {
|
|
12041
12205
|
transformedList = transformedList.map((item) => {
|
|
12042
|
-
return generatedVideoFromMldev
|
|
12206
|
+
return generatedVideoFromMldev(item);
|
|
12043
12207
|
});
|
|
12044
12208
|
}
|
|
12045
12209
|
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
@@ -12058,7 +12222,7 @@ function generateVideosResponseFromMldev$1(fromObject) {
|
|
|
12058
12222
|
}
|
|
12059
12223
|
return toObject;
|
|
12060
12224
|
}
|
|
12061
|
-
function generateVideosOperationFromMldev
|
|
12225
|
+
function generateVideosOperationFromMldev(fromObject) {
|
|
12062
12226
|
const toObject = {};
|
|
12063
12227
|
const fromName = getValueByPath(fromObject, ['name']);
|
|
12064
12228
|
if (fromName != null) {
|
|
@@ -12081,7 +12245,7 @@ function generateVideosOperationFromMldev$1(fromObject) {
|
|
|
12081
12245
|
'generateVideoResponse',
|
|
12082
12246
|
]);
|
|
12083
12247
|
if (fromResponse != null) {
|
|
12084
|
-
setValueByPath(toObject, ['response'], generateVideosResponseFromMldev
|
|
12248
|
+
setValueByPath(toObject, ['response'], generateVideosResponseFromMldev(fromResponse));
|
|
12085
12249
|
}
|
|
12086
12250
|
return toObject;
|
|
12087
12251
|
}
|
|
@@ -12377,6 +12541,12 @@ function embedContentMetadataFromVertex(fromObject) {
|
|
|
12377
12541
|
}
|
|
12378
12542
|
function embedContentResponseFromVertex(fromObject) {
|
|
12379
12543
|
const toObject = {};
|
|
12544
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
12545
|
+
'sdkHttpResponse',
|
|
12546
|
+
]);
|
|
12547
|
+
if (fromSdkHttpResponse != null) {
|
|
12548
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
12549
|
+
}
|
|
12380
12550
|
const fromEmbeddings = getValueByPath(fromObject, [
|
|
12381
12551
|
'predictions[]',
|
|
12382
12552
|
'embeddings',
|
|
@@ -12460,6 +12630,12 @@ function generatedImageFromVertex(fromObject) {
|
|
|
12460
12630
|
}
|
|
12461
12631
|
function generateImagesResponseFromVertex(fromObject) {
|
|
12462
12632
|
const toObject = {};
|
|
12633
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
12634
|
+
'sdkHttpResponse',
|
|
12635
|
+
]);
|
|
12636
|
+
if (fromSdkHttpResponse != null) {
|
|
12637
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
12638
|
+
}
|
|
12463
12639
|
const fromGeneratedImages = getValueByPath(fromObject, [
|
|
12464
12640
|
'predictions',
|
|
12465
12641
|
]);
|
|
@@ -12482,6 +12658,12 @@ function generateImagesResponseFromVertex(fromObject) {
|
|
|
12482
12658
|
}
|
|
12483
12659
|
function editImageResponseFromVertex(fromObject) {
|
|
12484
12660
|
const toObject = {};
|
|
12661
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
12662
|
+
'sdkHttpResponse',
|
|
12663
|
+
]);
|
|
12664
|
+
if (fromSdkHttpResponse != null) {
|
|
12665
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
12666
|
+
}
|
|
12485
12667
|
const fromGeneratedImages = getValueByPath(fromObject, [
|
|
12486
12668
|
'predictions',
|
|
12487
12669
|
]);
|
|
@@ -12498,6 +12680,12 @@ function editImageResponseFromVertex(fromObject) {
|
|
|
12498
12680
|
}
|
|
12499
12681
|
function upscaleImageResponseFromVertex(fromObject) {
|
|
12500
12682
|
const toObject = {};
|
|
12683
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
12684
|
+
'sdkHttpResponse',
|
|
12685
|
+
]);
|
|
12686
|
+
if (fromSdkHttpResponse != null) {
|
|
12687
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
12688
|
+
}
|
|
12501
12689
|
const fromGeneratedImages = getValueByPath(fromObject, [
|
|
12502
12690
|
'predictions',
|
|
12503
12691
|
]);
|
|
@@ -12617,6 +12805,12 @@ function modelFromVertex(fromObject) {
|
|
|
12617
12805
|
}
|
|
12618
12806
|
function listModelsResponseFromVertex(fromObject) {
|
|
12619
12807
|
const toObject = {};
|
|
12808
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
12809
|
+
'sdkHttpResponse',
|
|
12810
|
+
]);
|
|
12811
|
+
if (fromSdkHttpResponse != null) {
|
|
12812
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
12813
|
+
}
|
|
12620
12814
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
12621
12815
|
'nextPageToken',
|
|
12622
12816
|
]);
|
|
@@ -12641,6 +12835,12 @@ function deleteModelResponseFromVertex() {
|
|
|
12641
12835
|
}
|
|
12642
12836
|
function countTokensResponseFromVertex(fromObject) {
|
|
12643
12837
|
const toObject = {};
|
|
12838
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
12839
|
+
'sdkHttpResponse',
|
|
12840
|
+
]);
|
|
12841
|
+
if (fromSdkHttpResponse != null) {
|
|
12842
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
12843
|
+
}
|
|
12644
12844
|
const fromTotalTokens = getValueByPath(fromObject, ['totalTokens']);
|
|
12645
12845
|
if (fromTotalTokens != null) {
|
|
12646
12846
|
setValueByPath(toObject, ['totalTokens'], fromTotalTokens);
|
|
@@ -12649,13 +12849,19 @@ function countTokensResponseFromVertex(fromObject) {
|
|
|
12649
12849
|
}
|
|
12650
12850
|
function computeTokensResponseFromVertex(fromObject) {
|
|
12651
12851
|
const toObject = {};
|
|
12852
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
12853
|
+
'sdkHttpResponse',
|
|
12854
|
+
]);
|
|
12855
|
+
if (fromSdkHttpResponse != null) {
|
|
12856
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
12857
|
+
}
|
|
12652
12858
|
const fromTokensInfo = getValueByPath(fromObject, ['tokensInfo']);
|
|
12653
12859
|
if (fromTokensInfo != null) {
|
|
12654
12860
|
setValueByPath(toObject, ['tokensInfo'], fromTokensInfo);
|
|
12655
12861
|
}
|
|
12656
12862
|
return toObject;
|
|
12657
12863
|
}
|
|
12658
|
-
function videoFromVertex
|
|
12864
|
+
function videoFromVertex(fromObject) {
|
|
12659
12865
|
const toObject = {};
|
|
12660
12866
|
const fromUri = getValueByPath(fromObject, ['gcsUri']);
|
|
12661
12867
|
if (fromUri != null) {
|
|
@@ -12673,22 +12879,22 @@ function videoFromVertex$1(fromObject) {
|
|
|
12673
12879
|
}
|
|
12674
12880
|
return toObject;
|
|
12675
12881
|
}
|
|
12676
|
-
function generatedVideoFromVertex
|
|
12882
|
+
function generatedVideoFromVertex(fromObject) {
|
|
12677
12883
|
const toObject = {};
|
|
12678
12884
|
const fromVideo = getValueByPath(fromObject, ['_self']);
|
|
12679
12885
|
if (fromVideo != null) {
|
|
12680
|
-
setValueByPath(toObject, ['video'], videoFromVertex
|
|
12886
|
+
setValueByPath(toObject, ['video'], videoFromVertex(fromVideo));
|
|
12681
12887
|
}
|
|
12682
12888
|
return toObject;
|
|
12683
12889
|
}
|
|
12684
|
-
function generateVideosResponseFromVertex
|
|
12890
|
+
function generateVideosResponseFromVertex(fromObject) {
|
|
12685
12891
|
const toObject = {};
|
|
12686
12892
|
const fromGeneratedVideos = getValueByPath(fromObject, ['videos']);
|
|
12687
12893
|
if (fromGeneratedVideos != null) {
|
|
12688
12894
|
let transformedList = fromGeneratedVideos;
|
|
12689
12895
|
if (Array.isArray(transformedList)) {
|
|
12690
12896
|
transformedList = transformedList.map((item) => {
|
|
12691
|
-
return generatedVideoFromVertex
|
|
12897
|
+
return generatedVideoFromVertex(item);
|
|
12692
12898
|
});
|
|
12693
12899
|
}
|
|
12694
12900
|
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
@@ -12707,7 +12913,7 @@ function generateVideosResponseFromVertex$1(fromObject) {
|
|
|
12707
12913
|
}
|
|
12708
12914
|
return toObject;
|
|
12709
12915
|
}
|
|
12710
|
-
function generateVideosOperationFromVertex
|
|
12916
|
+
function generateVideosOperationFromVertex(fromObject) {
|
|
12711
12917
|
const toObject = {};
|
|
12712
12918
|
const fromName = getValueByPath(fromObject, ['name']);
|
|
12713
12919
|
if (fromName != null) {
|
|
@@ -12727,7 +12933,7 @@ function generateVideosOperationFromVertex$1(fromObject) {
|
|
|
12727
12933
|
}
|
|
12728
12934
|
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
12729
12935
|
if (fromResponse != null) {
|
|
12730
|
-
setValueByPath(toObject, ['response'], generateVideosResponseFromVertex
|
|
12936
|
+
setValueByPath(toObject, ['response'], generateVideosResponseFromVertex(fromResponse));
|
|
12731
12937
|
}
|
|
12732
12938
|
return toObject;
|
|
12733
12939
|
}
|
|
@@ -12741,7 +12947,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
12741
12947
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
12742
12948
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
12743
12949
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
12744
|
-
const SDK_VERSION = '1.
|
|
12950
|
+
const SDK_VERSION = '1.12.0'; // x-release-please-version
|
|
12745
12951
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
12746
12952
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
12747
12953
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -13334,18 +13540,6 @@ function setMcpUsageHeader(headers) {
|
|
|
13334
13540
|
const existingHeader = (_a = headers[GOOGLE_API_CLIENT_HEADER]) !== null && _a !== void 0 ? _a : '';
|
|
13335
13541
|
headers[GOOGLE_API_CLIENT_HEADER] = (existingHeader + ` ${MCP_LABEL}`).trimStart();
|
|
13336
13542
|
}
|
|
13337
|
-
// Checks whether the list of tools contains any MCP clients. Will return true
|
|
13338
|
-
// if there is at least one MCP client.
|
|
13339
|
-
function hasMcpClientTools(params) {
|
|
13340
|
-
var _a, _b, _c;
|
|
13341
|
-
return (_c = (_b = (_a = params.config) === null || _a === void 0 ? void 0 : _a.tools) === null || _b === void 0 ? void 0 : _b.some((tool) => isMcpCallableTool(tool))) !== null && _c !== void 0 ? _c : false;
|
|
13342
|
-
}
|
|
13343
|
-
// Checks whether the list of tools contains any non-MCP tools. Will return true
|
|
13344
|
-
// if there is at least one non-MCP tool.
|
|
13345
|
-
function hasNonMcpTools(params) {
|
|
13346
|
-
var _a, _b, _c;
|
|
13347
|
-
return ((_c = (_b = (_a = params.config) === null || _a === void 0 ? void 0 : _a.tools) === null || _b === void 0 ? void 0 : _b.some((tool) => !isMcpCallableTool(tool))) !== null && _c !== void 0 ? _c : false);
|
|
13348
|
-
}
|
|
13349
13543
|
// Returns true if the object is a MCP CallableTool, otherwise false.
|
|
13350
13544
|
function isMcpCallableTool(object) {
|
|
13351
13545
|
return (object !== null &&
|
|
@@ -13839,13 +14033,13 @@ class Live {
|
|
|
13839
14033
|
const websocketBaseUrl = this.apiClient.getWebsocketBaseUrl();
|
|
13840
14034
|
const apiVersion = this.apiClient.getApiVersion();
|
|
13841
14035
|
let url;
|
|
13842
|
-
const
|
|
14036
|
+
const clientHeaders = this.apiClient.getHeaders();
|
|
13843
14037
|
if (params.config &&
|
|
13844
14038
|
params.config.tools &&
|
|
13845
14039
|
hasMcpToolUsage(params.config.tools)) {
|
|
13846
|
-
setMcpUsageHeader(
|
|
14040
|
+
setMcpUsageHeader(clientHeaders);
|
|
13847
14041
|
}
|
|
13848
|
-
const headers = mapToHeaders(
|
|
14042
|
+
const headers = mapToHeaders(clientHeaders);
|
|
13849
14043
|
if (this.apiClient.isVertexAI()) {
|
|
13850
14044
|
url = `${websocketBaseUrl}/ws/google.cloud.aiplatform.${apiVersion}.LlmBidiService/BidiGenerateContent`;
|
|
13851
14045
|
await this.auth.addAuthHeaders(headers);
|
|
@@ -14204,6 +14398,18 @@ function shouldDisableAfc(config) {
|
|
|
14204
14398
|
function isCallableTool(tool) {
|
|
14205
14399
|
return 'callTool' in tool && typeof tool.callTool === 'function';
|
|
14206
14400
|
}
|
|
14401
|
+
// Checks whether the list of tools contains any CallableTools. Will return true
|
|
14402
|
+
// if there is at least one CallableTool.
|
|
14403
|
+
function hasCallableTools(params) {
|
|
14404
|
+
var _a, _b, _c;
|
|
14405
|
+
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;
|
|
14406
|
+
}
|
|
14407
|
+
// Checks whether the list of tools contains any non-callable tools. Will return
|
|
14408
|
+
// true if there is at least one non-Callable tool.
|
|
14409
|
+
function hasNonCallableTools(params) {
|
|
14410
|
+
var _a, _b, _c;
|
|
14411
|
+
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;
|
|
14412
|
+
}
|
|
14207
14413
|
/**
|
|
14208
14414
|
* Returns whether to append automatic function calling history to the
|
|
14209
14415
|
* response.
|
|
@@ -14262,12 +14468,12 @@ class Models extends BaseModule {
|
|
|
14262
14468
|
*/
|
|
14263
14469
|
this.generateContent = async (params) => {
|
|
14264
14470
|
var _a, _b, _c, _d, _e;
|
|
14265
|
-
const transformedParams = await this.
|
|
14471
|
+
const transformedParams = await this.processParamsMaybeAddMcpUsage(params);
|
|
14266
14472
|
this.maybeMoveToResponseJsonSchem(params);
|
|
14267
|
-
if (!
|
|
14473
|
+
if (!hasCallableTools(params) || shouldDisableAfc(params.config)) {
|
|
14268
14474
|
return await this.generateContentInternal(transformedParams);
|
|
14269
14475
|
}
|
|
14270
|
-
if (
|
|
14476
|
+
if (hasNonCallableTools(params)) {
|
|
14271
14477
|
throw new Error('Automatic function calling with CallableTools and Tools is not yet supported.');
|
|
14272
14478
|
}
|
|
14273
14479
|
let response;
|
|
@@ -14352,7 +14558,7 @@ class Models extends BaseModule {
|
|
|
14352
14558
|
this.generateContentStream = async (params) => {
|
|
14353
14559
|
this.maybeMoveToResponseJsonSchem(params);
|
|
14354
14560
|
if (shouldDisableAfc(params.config)) {
|
|
14355
|
-
const transformedParams = await this.
|
|
14561
|
+
const transformedParams = await this.processParamsMaybeAddMcpUsage(params);
|
|
14356
14562
|
return await this.generateContentStreamInternal(transformedParams);
|
|
14357
14563
|
}
|
|
14358
14564
|
else {
|
|
@@ -14400,11 +14606,13 @@ class Models extends BaseModule {
|
|
|
14400
14606
|
response = {
|
|
14401
14607
|
generatedImages: generatedImages,
|
|
14402
14608
|
positivePromptSafetyAttributes: positivePromptSafetyAttributes,
|
|
14609
|
+
sdkHttpResponse: apiResponse.sdkHttpResponse,
|
|
14403
14610
|
};
|
|
14404
14611
|
}
|
|
14405
14612
|
else {
|
|
14406
14613
|
response = {
|
|
14407
14614
|
generatedImages: generatedImages,
|
|
14615
|
+
sdkHttpResponse: apiResponse.sdkHttpResponse,
|
|
14408
14616
|
};
|
|
14409
14617
|
}
|
|
14410
14618
|
return response;
|
|
@@ -14501,6 +14709,32 @@ class Models extends BaseModule {
|
|
|
14501
14709
|
};
|
|
14502
14710
|
return await this.upscaleImageInternal(apiParams);
|
|
14503
14711
|
};
|
|
14712
|
+
/**
|
|
14713
|
+
* Generates videos based on a text description and configuration.
|
|
14714
|
+
*
|
|
14715
|
+
* @param params - The parameters for generating videos.
|
|
14716
|
+
* @return A Promise<GenerateVideosOperation> which allows you to track the progress and eventually retrieve the generated videos using the operations.get method.
|
|
14717
|
+
*
|
|
14718
|
+
* @example
|
|
14719
|
+
* ```ts
|
|
14720
|
+
* const operation = await ai.models.generateVideos({
|
|
14721
|
+
* model: 'veo-2.0-generate-001',
|
|
14722
|
+
* prompt: 'A neon hologram of a cat driving at top speed',
|
|
14723
|
+
* config: {
|
|
14724
|
+
* numberOfVideos: 1
|
|
14725
|
+
* });
|
|
14726
|
+
*
|
|
14727
|
+
* while (!operation.done) {
|
|
14728
|
+
* await new Promise(resolve => setTimeout(resolve, 10000));
|
|
14729
|
+
* operation = await ai.operations.getVideosOperation({operation: operation});
|
|
14730
|
+
* }
|
|
14731
|
+
*
|
|
14732
|
+
* console.log(operation.response?.generatedVideos?.[0]?.video?.uri);
|
|
14733
|
+
* ```
|
|
14734
|
+
*/
|
|
14735
|
+
this.generateVideos = async (params) => {
|
|
14736
|
+
return await this.generateVideosInternal(params);
|
|
14737
|
+
};
|
|
14504
14738
|
}
|
|
14505
14739
|
/**
|
|
14506
14740
|
* This logic is needed for GenerateContentConfig only.
|
|
@@ -14526,7 +14760,7 @@ class Models extends BaseModule {
|
|
|
14526
14760
|
* modify the original params. Also sets the MCP usage header if there are
|
|
14527
14761
|
* MCP tools in the parameters.
|
|
14528
14762
|
*/
|
|
14529
|
-
async
|
|
14763
|
+
async processParamsMaybeAddMcpUsage(params) {
|
|
14530
14764
|
var _a, _b, _c;
|
|
14531
14765
|
const tools = (_a = params.config) === null || _a === void 0 ? void 0 : _a.tools;
|
|
14532
14766
|
if (!tools) {
|
|
@@ -14593,7 +14827,7 @@ class Models extends BaseModule {
|
|
|
14593
14827
|
remoteCallCount++;
|
|
14594
14828
|
wereFunctionsCalled = false;
|
|
14595
14829
|
}
|
|
14596
|
-
const transformedParams = yield __await(models.
|
|
14830
|
+
const transformedParams = yield __await(models.processParamsMaybeAddMcpUsage(params));
|
|
14597
14831
|
const response = yield __await(models.generateContentStreamInternal(transformedParams));
|
|
14598
14832
|
const functionResponses = [];
|
|
14599
14833
|
const responseContents = [];
|
|
@@ -14864,7 +15098,13 @@ class Models extends BaseModule {
|
|
|
14864
15098
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
14865
15099
|
})
|
|
14866
15100
|
.then((httpResponse) => {
|
|
14867
|
-
return httpResponse.json()
|
|
15101
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
15102
|
+
const response = jsonResponse;
|
|
15103
|
+
response.sdkHttpResponse = {
|
|
15104
|
+
headers: httpResponse.headers,
|
|
15105
|
+
};
|
|
15106
|
+
return response;
|
|
15107
|
+
});
|
|
14868
15108
|
});
|
|
14869
15109
|
return response.then((apiResponse) => {
|
|
14870
15110
|
const resp = embedContentResponseFromVertex(apiResponse);
|
|
@@ -14890,7 +15130,13 @@ class Models extends BaseModule {
|
|
|
14890
15130
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
14891
15131
|
})
|
|
14892
15132
|
.then((httpResponse) => {
|
|
14893
|
-
return httpResponse.json()
|
|
15133
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
15134
|
+
const response = jsonResponse;
|
|
15135
|
+
response.sdkHttpResponse = {
|
|
15136
|
+
headers: httpResponse.headers,
|
|
15137
|
+
};
|
|
15138
|
+
return response;
|
|
15139
|
+
});
|
|
14894
15140
|
});
|
|
14895
15141
|
return response.then((apiResponse) => {
|
|
14896
15142
|
const resp = embedContentResponseFromMldev(apiResponse);
|
|
@@ -14941,7 +15187,13 @@ class Models extends BaseModule {
|
|
|
14941
15187
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
14942
15188
|
})
|
|
14943
15189
|
.then((httpResponse) => {
|
|
14944
|
-
return httpResponse.json()
|
|
15190
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
15191
|
+
const response = jsonResponse;
|
|
15192
|
+
response.sdkHttpResponse = {
|
|
15193
|
+
headers: httpResponse.headers,
|
|
15194
|
+
};
|
|
15195
|
+
return response;
|
|
15196
|
+
});
|
|
14945
15197
|
});
|
|
14946
15198
|
return response.then((apiResponse) => {
|
|
14947
15199
|
const resp = generateImagesResponseFromVertex(apiResponse);
|
|
@@ -14967,7 +15219,13 @@ class Models extends BaseModule {
|
|
|
14967
15219
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
14968
15220
|
})
|
|
14969
15221
|
.then((httpResponse) => {
|
|
14970
|
-
return httpResponse.json()
|
|
15222
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
15223
|
+
const response = jsonResponse;
|
|
15224
|
+
response.sdkHttpResponse = {
|
|
15225
|
+
headers: httpResponse.headers,
|
|
15226
|
+
};
|
|
15227
|
+
return response;
|
|
15228
|
+
});
|
|
14971
15229
|
});
|
|
14972
15230
|
return response.then((apiResponse) => {
|
|
14973
15231
|
const resp = generateImagesResponseFromMldev(apiResponse);
|
|
@@ -14999,7 +15257,13 @@ class Models extends BaseModule {
|
|
|
14999
15257
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
15000
15258
|
})
|
|
15001
15259
|
.then((httpResponse) => {
|
|
15002
|
-
return httpResponse.json()
|
|
15260
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
15261
|
+
const response = jsonResponse;
|
|
15262
|
+
response.sdkHttpResponse = {
|
|
15263
|
+
headers: httpResponse.headers,
|
|
15264
|
+
};
|
|
15265
|
+
return response;
|
|
15266
|
+
});
|
|
15003
15267
|
});
|
|
15004
15268
|
return response.then((apiResponse) => {
|
|
15005
15269
|
const resp = editImageResponseFromVertex(apiResponse);
|
|
@@ -15034,7 +15298,13 @@ class Models extends BaseModule {
|
|
|
15034
15298
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
15035
15299
|
})
|
|
15036
15300
|
.then((httpResponse) => {
|
|
15037
|
-
return httpResponse.json()
|
|
15301
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
15302
|
+
const response = jsonResponse;
|
|
15303
|
+
response.sdkHttpResponse = {
|
|
15304
|
+
headers: httpResponse.headers,
|
|
15305
|
+
};
|
|
15306
|
+
return response;
|
|
15307
|
+
});
|
|
15038
15308
|
});
|
|
15039
15309
|
return response.then((apiResponse) => {
|
|
15040
15310
|
const resp = upscaleImageResponseFromVertex(apiResponse);
|
|
@@ -15131,8 +15401,14 @@ class Models extends BaseModule {
|
|
|
15131
15401
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
15132
15402
|
})
|
|
15133
15403
|
.then((httpResponse) => {
|
|
15134
|
-
return httpResponse.json()
|
|
15135
|
-
|
|
15404
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
15405
|
+
const response = jsonResponse;
|
|
15406
|
+
response.sdkHttpResponse = {
|
|
15407
|
+
headers: httpResponse.headers,
|
|
15408
|
+
};
|
|
15409
|
+
return response;
|
|
15410
|
+
});
|
|
15411
|
+
});
|
|
15136
15412
|
return response.then((apiResponse) => {
|
|
15137
15413
|
const resp = listModelsResponseFromVertex(apiResponse);
|
|
15138
15414
|
const typedResp = new ListModelsResponse();
|
|
@@ -15157,7 +15433,13 @@ class Models extends BaseModule {
|
|
|
15157
15433
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
15158
15434
|
})
|
|
15159
15435
|
.then((httpResponse) => {
|
|
15160
|
-
return httpResponse.json()
|
|
15436
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
15437
|
+
const response = jsonResponse;
|
|
15438
|
+
response.sdkHttpResponse = {
|
|
15439
|
+
headers: httpResponse.headers,
|
|
15440
|
+
};
|
|
15441
|
+
return response;
|
|
15442
|
+
});
|
|
15161
15443
|
});
|
|
15162
15444
|
return response.then((apiResponse) => {
|
|
15163
15445
|
const resp = listModelsResponseFromMldev(apiResponse);
|
|
@@ -15345,7 +15627,13 @@ class Models extends BaseModule {
|
|
|
15345
15627
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
15346
15628
|
})
|
|
15347
15629
|
.then((httpResponse) => {
|
|
15348
|
-
return httpResponse.json()
|
|
15630
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
15631
|
+
const response = jsonResponse;
|
|
15632
|
+
response.sdkHttpResponse = {
|
|
15633
|
+
headers: httpResponse.headers,
|
|
15634
|
+
};
|
|
15635
|
+
return response;
|
|
15636
|
+
});
|
|
15349
15637
|
});
|
|
15350
15638
|
return response.then((apiResponse) => {
|
|
15351
15639
|
const resp = countTokensResponseFromVertex(apiResponse);
|
|
@@ -15371,7 +15659,13 @@ class Models extends BaseModule {
|
|
|
15371
15659
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
15372
15660
|
})
|
|
15373
15661
|
.then((httpResponse) => {
|
|
15374
|
-
return httpResponse.json()
|
|
15662
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
15663
|
+
const response = jsonResponse;
|
|
15664
|
+
response.sdkHttpResponse = {
|
|
15665
|
+
headers: httpResponse.headers,
|
|
15666
|
+
};
|
|
15667
|
+
return response;
|
|
15668
|
+
});
|
|
15375
15669
|
});
|
|
15376
15670
|
return response.then((apiResponse) => {
|
|
15377
15671
|
const resp = countTokensResponseFromMldev(apiResponse);
|
|
@@ -15421,7 +15715,13 @@ class Models extends BaseModule {
|
|
|
15421
15715
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
15422
15716
|
})
|
|
15423
15717
|
.then((httpResponse) => {
|
|
15424
|
-
return httpResponse.json()
|
|
15718
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
15719
|
+
const response = jsonResponse;
|
|
15720
|
+
response.sdkHttpResponse = {
|
|
15721
|
+
headers: httpResponse.headers,
|
|
15722
|
+
};
|
|
15723
|
+
return response;
|
|
15724
|
+
});
|
|
15425
15725
|
});
|
|
15426
15726
|
return response.then((apiResponse) => {
|
|
15427
15727
|
const resp = computeTokensResponseFromVertex(apiResponse);
|
|
@@ -15457,7 +15757,7 @@ class Models extends BaseModule {
|
|
|
15457
15757
|
* console.log(operation.response?.generatedVideos?.[0]?.video?.uri);
|
|
15458
15758
|
* ```
|
|
15459
15759
|
*/
|
|
15460
|
-
async
|
|
15760
|
+
async generateVideosInternal(params) {
|
|
15461
15761
|
var _a, _b, _c, _d;
|
|
15462
15762
|
let response;
|
|
15463
15763
|
let path = '';
|
|
@@ -15482,8 +15782,10 @@ class Models extends BaseModule {
|
|
|
15482
15782
|
return httpResponse.json();
|
|
15483
15783
|
});
|
|
15484
15784
|
return response.then((apiResponse) => {
|
|
15485
|
-
const resp = generateVideosOperationFromVertex
|
|
15486
|
-
|
|
15785
|
+
const resp = generateVideosOperationFromVertex(apiResponse);
|
|
15786
|
+
const typedResp = new GenerateVideosOperation();
|
|
15787
|
+
Object.assign(typedResp, resp);
|
|
15788
|
+
return typedResp;
|
|
15487
15789
|
});
|
|
15488
15790
|
}
|
|
15489
15791
|
else {
|
|
@@ -15506,8 +15808,10 @@ class Models extends BaseModule {
|
|
|
15506
15808
|
return httpResponse.json();
|
|
15507
15809
|
});
|
|
15508
15810
|
return response.then((apiResponse) => {
|
|
15509
|
-
const resp = generateVideosOperationFromMldev
|
|
15510
|
-
|
|
15811
|
+
const resp = generateVideosOperationFromMldev(apiResponse);
|
|
15812
|
+
const typedResp = new GenerateVideosOperation();
|
|
15813
|
+
Object.assign(typedResp, resp);
|
|
15814
|
+
return typedResp;
|
|
15511
15815
|
});
|
|
15512
15816
|
}
|
|
15513
15817
|
}
|
|
@@ -15565,164 +15869,6 @@ function fetchPredictOperationParametersToVertex(fromObject) {
|
|
|
15565
15869
|
}
|
|
15566
15870
|
return toObject;
|
|
15567
15871
|
}
|
|
15568
|
-
function videoFromMldev(fromObject) {
|
|
15569
|
-
const toObject = {};
|
|
15570
|
-
const fromUri = getValueByPath(fromObject, ['video', 'uri']);
|
|
15571
|
-
if (fromUri != null) {
|
|
15572
|
-
setValueByPath(toObject, ['uri'], fromUri);
|
|
15573
|
-
}
|
|
15574
|
-
const fromVideoBytes = getValueByPath(fromObject, [
|
|
15575
|
-
'video',
|
|
15576
|
-
'encodedVideo',
|
|
15577
|
-
]);
|
|
15578
|
-
if (fromVideoBytes != null) {
|
|
15579
|
-
setValueByPath(toObject, ['videoBytes'], tBytes(fromVideoBytes));
|
|
15580
|
-
}
|
|
15581
|
-
const fromMimeType = getValueByPath(fromObject, ['encoding']);
|
|
15582
|
-
if (fromMimeType != null) {
|
|
15583
|
-
setValueByPath(toObject, ['mimeType'], fromMimeType);
|
|
15584
|
-
}
|
|
15585
|
-
return toObject;
|
|
15586
|
-
}
|
|
15587
|
-
function generatedVideoFromMldev(fromObject) {
|
|
15588
|
-
const toObject = {};
|
|
15589
|
-
const fromVideo = getValueByPath(fromObject, ['_self']);
|
|
15590
|
-
if (fromVideo != null) {
|
|
15591
|
-
setValueByPath(toObject, ['video'], videoFromMldev(fromVideo));
|
|
15592
|
-
}
|
|
15593
|
-
return toObject;
|
|
15594
|
-
}
|
|
15595
|
-
function generateVideosResponseFromMldev(fromObject) {
|
|
15596
|
-
const toObject = {};
|
|
15597
|
-
const fromGeneratedVideos = getValueByPath(fromObject, [
|
|
15598
|
-
'generatedSamples',
|
|
15599
|
-
]);
|
|
15600
|
-
if (fromGeneratedVideos != null) {
|
|
15601
|
-
let transformedList = fromGeneratedVideos;
|
|
15602
|
-
if (Array.isArray(transformedList)) {
|
|
15603
|
-
transformedList = transformedList.map((item) => {
|
|
15604
|
-
return generatedVideoFromMldev(item);
|
|
15605
|
-
});
|
|
15606
|
-
}
|
|
15607
|
-
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
15608
|
-
}
|
|
15609
|
-
const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
|
|
15610
|
-
'raiMediaFilteredCount',
|
|
15611
|
-
]);
|
|
15612
|
-
if (fromRaiMediaFilteredCount != null) {
|
|
15613
|
-
setValueByPath(toObject, ['raiMediaFilteredCount'], fromRaiMediaFilteredCount);
|
|
15614
|
-
}
|
|
15615
|
-
const fromRaiMediaFilteredReasons = getValueByPath(fromObject, [
|
|
15616
|
-
'raiMediaFilteredReasons',
|
|
15617
|
-
]);
|
|
15618
|
-
if (fromRaiMediaFilteredReasons != null) {
|
|
15619
|
-
setValueByPath(toObject, ['raiMediaFilteredReasons'], fromRaiMediaFilteredReasons);
|
|
15620
|
-
}
|
|
15621
|
-
return toObject;
|
|
15622
|
-
}
|
|
15623
|
-
function generateVideosOperationFromMldev(fromObject) {
|
|
15624
|
-
const toObject = {};
|
|
15625
|
-
const fromName = getValueByPath(fromObject, ['name']);
|
|
15626
|
-
if (fromName != null) {
|
|
15627
|
-
setValueByPath(toObject, ['name'], fromName);
|
|
15628
|
-
}
|
|
15629
|
-
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
15630
|
-
if (fromMetadata != null) {
|
|
15631
|
-
setValueByPath(toObject, ['metadata'], fromMetadata);
|
|
15632
|
-
}
|
|
15633
|
-
const fromDone = getValueByPath(fromObject, ['done']);
|
|
15634
|
-
if (fromDone != null) {
|
|
15635
|
-
setValueByPath(toObject, ['done'], fromDone);
|
|
15636
|
-
}
|
|
15637
|
-
const fromError = getValueByPath(fromObject, ['error']);
|
|
15638
|
-
if (fromError != null) {
|
|
15639
|
-
setValueByPath(toObject, ['error'], fromError);
|
|
15640
|
-
}
|
|
15641
|
-
const fromResponse = getValueByPath(fromObject, [
|
|
15642
|
-
'response',
|
|
15643
|
-
'generateVideoResponse',
|
|
15644
|
-
]);
|
|
15645
|
-
if (fromResponse != null) {
|
|
15646
|
-
setValueByPath(toObject, ['response'], generateVideosResponseFromMldev(fromResponse));
|
|
15647
|
-
}
|
|
15648
|
-
return toObject;
|
|
15649
|
-
}
|
|
15650
|
-
function videoFromVertex(fromObject) {
|
|
15651
|
-
const toObject = {};
|
|
15652
|
-
const fromUri = getValueByPath(fromObject, ['gcsUri']);
|
|
15653
|
-
if (fromUri != null) {
|
|
15654
|
-
setValueByPath(toObject, ['uri'], fromUri);
|
|
15655
|
-
}
|
|
15656
|
-
const fromVideoBytes = getValueByPath(fromObject, [
|
|
15657
|
-
'bytesBase64Encoded',
|
|
15658
|
-
]);
|
|
15659
|
-
if (fromVideoBytes != null) {
|
|
15660
|
-
setValueByPath(toObject, ['videoBytes'], tBytes(fromVideoBytes));
|
|
15661
|
-
}
|
|
15662
|
-
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
15663
|
-
if (fromMimeType != null) {
|
|
15664
|
-
setValueByPath(toObject, ['mimeType'], fromMimeType);
|
|
15665
|
-
}
|
|
15666
|
-
return toObject;
|
|
15667
|
-
}
|
|
15668
|
-
function generatedVideoFromVertex(fromObject) {
|
|
15669
|
-
const toObject = {};
|
|
15670
|
-
const fromVideo = getValueByPath(fromObject, ['_self']);
|
|
15671
|
-
if (fromVideo != null) {
|
|
15672
|
-
setValueByPath(toObject, ['video'], videoFromVertex(fromVideo));
|
|
15673
|
-
}
|
|
15674
|
-
return toObject;
|
|
15675
|
-
}
|
|
15676
|
-
function generateVideosResponseFromVertex(fromObject) {
|
|
15677
|
-
const toObject = {};
|
|
15678
|
-
const fromGeneratedVideos = getValueByPath(fromObject, ['videos']);
|
|
15679
|
-
if (fromGeneratedVideos != null) {
|
|
15680
|
-
let transformedList = fromGeneratedVideos;
|
|
15681
|
-
if (Array.isArray(transformedList)) {
|
|
15682
|
-
transformedList = transformedList.map((item) => {
|
|
15683
|
-
return generatedVideoFromVertex(item);
|
|
15684
|
-
});
|
|
15685
|
-
}
|
|
15686
|
-
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
15687
|
-
}
|
|
15688
|
-
const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
|
|
15689
|
-
'raiMediaFilteredCount',
|
|
15690
|
-
]);
|
|
15691
|
-
if (fromRaiMediaFilteredCount != null) {
|
|
15692
|
-
setValueByPath(toObject, ['raiMediaFilteredCount'], fromRaiMediaFilteredCount);
|
|
15693
|
-
}
|
|
15694
|
-
const fromRaiMediaFilteredReasons = getValueByPath(fromObject, [
|
|
15695
|
-
'raiMediaFilteredReasons',
|
|
15696
|
-
]);
|
|
15697
|
-
if (fromRaiMediaFilteredReasons != null) {
|
|
15698
|
-
setValueByPath(toObject, ['raiMediaFilteredReasons'], fromRaiMediaFilteredReasons);
|
|
15699
|
-
}
|
|
15700
|
-
return toObject;
|
|
15701
|
-
}
|
|
15702
|
-
function generateVideosOperationFromVertex(fromObject) {
|
|
15703
|
-
const toObject = {};
|
|
15704
|
-
const fromName = getValueByPath(fromObject, ['name']);
|
|
15705
|
-
if (fromName != null) {
|
|
15706
|
-
setValueByPath(toObject, ['name'], fromName);
|
|
15707
|
-
}
|
|
15708
|
-
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
15709
|
-
if (fromMetadata != null) {
|
|
15710
|
-
setValueByPath(toObject, ['metadata'], fromMetadata);
|
|
15711
|
-
}
|
|
15712
|
-
const fromDone = getValueByPath(fromObject, ['done']);
|
|
15713
|
-
if (fromDone != null) {
|
|
15714
|
-
setValueByPath(toObject, ['done'], fromDone);
|
|
15715
|
-
}
|
|
15716
|
-
const fromError = getValueByPath(fromObject, ['error']);
|
|
15717
|
-
if (fromError != null) {
|
|
15718
|
-
setValueByPath(toObject, ['error'], fromError);
|
|
15719
|
-
}
|
|
15720
|
-
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
15721
|
-
if (fromResponse != null) {
|
|
15722
|
-
setValueByPath(toObject, ['response'], generateVideosResponseFromVertex(fromResponse));
|
|
15723
|
-
}
|
|
15724
|
-
return toObject;
|
|
15725
|
-
}
|
|
15726
15872
|
|
|
15727
15873
|
/**
|
|
15728
15874
|
* @license
|
|
@@ -15752,17 +15898,64 @@ class Operations extends BaseModule {
|
|
|
15752
15898
|
if (config && 'httpOptions' in config) {
|
|
15753
15899
|
httpOptions = config.httpOptions;
|
|
15754
15900
|
}
|
|
15755
|
-
|
|
15901
|
+
const rawOperation = await this.fetchPredictVideosOperationInternal({
|
|
15756
15902
|
operationName: operation.name,
|
|
15757
15903
|
resourceName: resourceName,
|
|
15758
15904
|
config: { httpOptions: httpOptions },
|
|
15759
15905
|
});
|
|
15906
|
+
return operation._fromAPIResponse({
|
|
15907
|
+
apiResponse: rawOperation,
|
|
15908
|
+
isVertexAI: true,
|
|
15909
|
+
});
|
|
15760
15910
|
}
|
|
15761
15911
|
else {
|
|
15762
|
-
|
|
15912
|
+
const rawOperation = await this.getVideosOperationInternal({
|
|
15763
15913
|
operationName: operation.name,
|
|
15764
15914
|
config: config,
|
|
15765
15915
|
});
|
|
15916
|
+
return operation._fromAPIResponse({
|
|
15917
|
+
apiResponse: rawOperation,
|
|
15918
|
+
isVertexAI: false,
|
|
15919
|
+
});
|
|
15920
|
+
}
|
|
15921
|
+
}
|
|
15922
|
+
/**
|
|
15923
|
+
* Gets the status of a long-running operation.
|
|
15924
|
+
*
|
|
15925
|
+
* @param parameters The parameters for the get operation request.
|
|
15926
|
+
* @return The updated Operation object, with the latest status or result.
|
|
15927
|
+
*/
|
|
15928
|
+
async get(parameters) {
|
|
15929
|
+
const operation = parameters.operation;
|
|
15930
|
+
const config = parameters.config;
|
|
15931
|
+
if (operation.name === undefined || operation.name === '') {
|
|
15932
|
+
throw new Error('Operation name is required.');
|
|
15933
|
+
}
|
|
15934
|
+
if (this.apiClient.isVertexAI()) {
|
|
15935
|
+
const resourceName = operation.name.split('/operations/')[0];
|
|
15936
|
+
let httpOptions = undefined;
|
|
15937
|
+
if (config && 'httpOptions' in config) {
|
|
15938
|
+
httpOptions = config.httpOptions;
|
|
15939
|
+
}
|
|
15940
|
+
const rawOperation = await this.fetchPredictVideosOperationInternal({
|
|
15941
|
+
operationName: operation.name,
|
|
15942
|
+
resourceName: resourceName,
|
|
15943
|
+
config: { httpOptions: httpOptions },
|
|
15944
|
+
});
|
|
15945
|
+
return operation._fromAPIResponse({
|
|
15946
|
+
apiResponse: rawOperation,
|
|
15947
|
+
isVertexAI: true,
|
|
15948
|
+
});
|
|
15949
|
+
}
|
|
15950
|
+
else {
|
|
15951
|
+
const rawOperation = await this.getVideosOperationInternal({
|
|
15952
|
+
operationName: operation.name,
|
|
15953
|
+
config: config,
|
|
15954
|
+
});
|
|
15955
|
+
return operation._fromAPIResponse({
|
|
15956
|
+
apiResponse: rawOperation,
|
|
15957
|
+
isVertexAI: false,
|
|
15958
|
+
});
|
|
15766
15959
|
}
|
|
15767
15960
|
}
|
|
15768
15961
|
async getVideosOperationInternal(params) {
|
|
@@ -15789,10 +15982,7 @@ class Operations extends BaseModule {
|
|
|
15789
15982
|
.then((httpResponse) => {
|
|
15790
15983
|
return httpResponse.json();
|
|
15791
15984
|
});
|
|
15792
|
-
return response
|
|
15793
|
-
const resp = generateVideosOperationFromVertex(apiResponse);
|
|
15794
|
-
return resp;
|
|
15795
|
-
});
|
|
15985
|
+
return response;
|
|
15796
15986
|
}
|
|
15797
15987
|
else {
|
|
15798
15988
|
const body = getOperationParametersToMldev(params);
|
|
@@ -15813,10 +16003,7 @@ class Operations extends BaseModule {
|
|
|
15813
16003
|
.then((httpResponse) => {
|
|
15814
16004
|
return httpResponse.json();
|
|
15815
16005
|
});
|
|
15816
|
-
return response
|
|
15817
|
-
const resp = generateVideosOperationFromMldev(apiResponse);
|
|
15818
|
-
return resp;
|
|
15819
|
-
});
|
|
16006
|
+
return response;
|
|
15820
16007
|
}
|
|
15821
16008
|
}
|
|
15822
16009
|
async fetchPredictVideosOperationInternal(params) {
|
|
@@ -15843,10 +16030,7 @@ class Operations extends BaseModule {
|
|
|
15843
16030
|
.then((httpResponse) => {
|
|
15844
16031
|
return httpResponse.json();
|
|
15845
16032
|
});
|
|
15846
|
-
return response
|
|
15847
|
-
const resp = generateVideosOperationFromVertex(apiResponse);
|
|
15848
|
-
return resp;
|
|
15849
|
-
});
|
|
16033
|
+
return response;
|
|
15850
16034
|
}
|
|
15851
16035
|
else {
|
|
15852
16036
|
throw new Error('This method is only supported by the Vertex AI.');
|
|
@@ -16989,6 +17173,12 @@ function tunedModelFromMldev(fromObject) {
|
|
|
16989
17173
|
}
|
|
16990
17174
|
function tuningJobFromMldev(fromObject) {
|
|
16991
17175
|
const toObject = {};
|
|
17176
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
17177
|
+
'sdkHttpResponse',
|
|
17178
|
+
]);
|
|
17179
|
+
if (fromSdkHttpResponse != null) {
|
|
17180
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
17181
|
+
}
|
|
16992
17182
|
const fromName = getValueByPath(fromObject, ['name']);
|
|
16993
17183
|
if (fromName != null) {
|
|
16994
17184
|
setValueByPath(toObject, ['name'], fromName);
|
|
@@ -17073,6 +17263,12 @@ function tuningJobFromMldev(fromObject) {
|
|
|
17073
17263
|
}
|
|
17074
17264
|
function listTuningJobsResponseFromMldev(fromObject) {
|
|
17075
17265
|
const toObject = {};
|
|
17266
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
17267
|
+
'sdkHttpResponse',
|
|
17268
|
+
]);
|
|
17269
|
+
if (fromSdkHttpResponse != null) {
|
|
17270
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
17271
|
+
}
|
|
17076
17272
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
17077
17273
|
'nextPageToken',
|
|
17078
17274
|
]);
|
|
@@ -17093,6 +17289,12 @@ function listTuningJobsResponseFromMldev(fromObject) {
|
|
|
17093
17289
|
}
|
|
17094
17290
|
function tuningOperationFromMldev(fromObject) {
|
|
17095
17291
|
const toObject = {};
|
|
17292
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
17293
|
+
'sdkHttpResponse',
|
|
17294
|
+
]);
|
|
17295
|
+
if (fromSdkHttpResponse != null) {
|
|
17296
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
17297
|
+
}
|
|
17096
17298
|
const fromName = getValueByPath(fromObject, ['name']);
|
|
17097
17299
|
if (fromName != null) {
|
|
17098
17300
|
setValueByPath(toObject, ['name'], fromName);
|
|
@@ -17155,6 +17357,12 @@ function tunedModelFromVertex(fromObject) {
|
|
|
17155
17357
|
}
|
|
17156
17358
|
function tuningJobFromVertex(fromObject) {
|
|
17157
17359
|
const toObject = {};
|
|
17360
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
17361
|
+
'sdkHttpResponse',
|
|
17362
|
+
]);
|
|
17363
|
+
if (fromSdkHttpResponse != null) {
|
|
17364
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
17365
|
+
}
|
|
17158
17366
|
const fromName = getValueByPath(fromObject, ['name']);
|
|
17159
17367
|
if (fromName != null) {
|
|
17160
17368
|
setValueByPath(toObject, ['name'], fromName);
|
|
@@ -17261,6 +17469,12 @@ function tuningJobFromVertex(fromObject) {
|
|
|
17261
17469
|
}
|
|
17262
17470
|
function listTuningJobsResponseFromVertex(fromObject) {
|
|
17263
17471
|
const toObject = {};
|
|
17472
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
17473
|
+
'sdkHttpResponse',
|
|
17474
|
+
]);
|
|
17475
|
+
if (fromSdkHttpResponse != null) {
|
|
17476
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
17477
|
+
}
|
|
17264
17478
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
17265
17479
|
'nextPageToken',
|
|
17266
17480
|
]);
|
|
@@ -17367,7 +17581,13 @@ class Tunings extends BaseModule {
|
|
|
17367
17581
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
17368
17582
|
})
|
|
17369
17583
|
.then((httpResponse) => {
|
|
17370
|
-
return httpResponse.json()
|
|
17584
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
17585
|
+
const response = jsonResponse;
|
|
17586
|
+
response.sdkHttpResponse = {
|
|
17587
|
+
headers: httpResponse.headers,
|
|
17588
|
+
};
|
|
17589
|
+
return response;
|
|
17590
|
+
});
|
|
17371
17591
|
});
|
|
17372
17592
|
return response.then((apiResponse) => {
|
|
17373
17593
|
const resp = tuningJobFromVertex(apiResponse);
|
|
@@ -17391,7 +17611,13 @@ class Tunings extends BaseModule {
|
|
|
17391
17611
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
17392
17612
|
})
|
|
17393
17613
|
.then((httpResponse) => {
|
|
17394
|
-
return httpResponse.json()
|
|
17614
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
17615
|
+
const response = jsonResponse;
|
|
17616
|
+
response.sdkHttpResponse = {
|
|
17617
|
+
headers: httpResponse.headers,
|
|
17618
|
+
};
|
|
17619
|
+
return response;
|
|
17620
|
+
});
|
|
17395
17621
|
});
|
|
17396
17622
|
return response.then((apiResponse) => {
|
|
17397
17623
|
const resp = tuningJobFromMldev(apiResponse);
|
|
@@ -17421,7 +17647,13 @@ class Tunings extends BaseModule {
|
|
|
17421
17647
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
17422
17648
|
})
|
|
17423
17649
|
.then((httpResponse) => {
|
|
17424
|
-
return httpResponse.json()
|
|
17650
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
17651
|
+
const response = jsonResponse;
|
|
17652
|
+
response.sdkHttpResponse = {
|
|
17653
|
+
headers: httpResponse.headers,
|
|
17654
|
+
};
|
|
17655
|
+
return response;
|
|
17656
|
+
});
|
|
17425
17657
|
});
|
|
17426
17658
|
return response.then((apiResponse) => {
|
|
17427
17659
|
const resp = listTuningJobsResponseFromVertex(apiResponse);
|
|
@@ -17447,7 +17679,13 @@ class Tunings extends BaseModule {
|
|
|
17447
17679
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
17448
17680
|
})
|
|
17449
17681
|
.then((httpResponse) => {
|
|
17450
|
-
return httpResponse.json()
|
|
17682
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
17683
|
+
const response = jsonResponse;
|
|
17684
|
+
response.sdkHttpResponse = {
|
|
17685
|
+
headers: httpResponse.headers,
|
|
17686
|
+
};
|
|
17687
|
+
return response;
|
|
17688
|
+
});
|
|
17451
17689
|
});
|
|
17452
17690
|
return response.then((apiResponse) => {
|
|
17453
17691
|
const resp = listTuningJobsResponseFromMldev(apiResponse);
|
|
@@ -17479,7 +17717,13 @@ class Tunings extends BaseModule {
|
|
|
17479
17717
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
17480
17718
|
})
|
|
17481
17719
|
.then((httpResponse) => {
|
|
17482
|
-
return httpResponse.json()
|
|
17720
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
17721
|
+
const response = jsonResponse;
|
|
17722
|
+
response.sdkHttpResponse = {
|
|
17723
|
+
headers: httpResponse.headers,
|
|
17724
|
+
};
|
|
17725
|
+
return response;
|
|
17726
|
+
});
|
|
17483
17727
|
});
|
|
17484
17728
|
return response.then((apiResponse) => {
|
|
17485
17729
|
const resp = tuningJobFromVertex(apiResponse);
|
|
@@ -17515,7 +17759,13 @@ class Tunings extends BaseModule {
|
|
|
17515
17759
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
17516
17760
|
})
|
|
17517
17761
|
.then((httpResponse) => {
|
|
17518
|
-
return httpResponse.json()
|
|
17762
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
17763
|
+
const response = jsonResponse;
|
|
17764
|
+
response.sdkHttpResponse = {
|
|
17765
|
+
headers: httpResponse.headers,
|
|
17766
|
+
};
|
|
17767
|
+
return response;
|
|
17768
|
+
});
|
|
17519
17769
|
});
|
|
17520
17770
|
return response.then((apiResponse) => {
|
|
17521
17771
|
const resp = tuningOperationFromMldev(apiResponse);
|
|
@@ -17738,7 +17988,7 @@ class GoogleGenAI {
|
|
|
17738
17988
|
}
|
|
17739
17989
|
this.vertexai = (_a = options.vertexai) !== null && _a !== void 0 ? _a : false;
|
|
17740
17990
|
this.apiKey = options.apiKey;
|
|
17741
|
-
const baseUrl = getBaseUrl(options,
|
|
17991
|
+
const baseUrl = getBaseUrl(options.httpOptions, options.vertexai,
|
|
17742
17992
|
/*vertexBaseUrlFromEnv*/ undefined,
|
|
17743
17993
|
/*geminiBaseUrlFromEnv*/ undefined);
|
|
17744
17994
|
if (baseUrl) {
|
|
@@ -17773,5 +18023,5 @@ class GoogleGenAI {
|
|
|
17773
18023
|
}
|
|
17774
18024
|
}
|
|
17775
18025
|
|
|
17776
|
-
export { ActivityHandling, AdapterSize, ApiError, ApiSpec, AuthType, Batches, Behavior, BlockedReason, Caches, Chat, Chats, ComputeTokensResponse, ControlReferenceImage, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DeleteModelResponse, DynamicRetrievalConfigMode, EditImageResponse, EditMode, EmbedContentResponse, EndSensitivity, Environment, FeatureSelectionPreference, FileSource, FileState, Files, FinishReason, FunctionCallingConfigMode, FunctionResponse, FunctionResponseScheduling, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GenerateVideosResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpResponse, ImagePromptLanguage, InlinedResponse, JobState, Language, ListBatchJobsResponse, ListCachedContentsResponse, ListFilesResponse, ListModelsResponse, ListTuningJobsResponse, Live, LiveClientToolResponse, LiveMusicPlaybackControl, LiveMusicServerMessage, LiveSendToolResponseParameters, LiveServerMessage, MaskReferenceImage, MaskReferenceMode, MediaModality, MediaResolution, Modality, Mode, Models, Operations, Outcome, PagedItem, Pager, PersonGeneration, RawReferenceImage, ReplayResponse, SafetyFilterLevel, Scale, Session, StartSensitivity, StyleReferenceImage, SubjectReferenceImage, SubjectReferenceType, Tokens, TrafficType, TurnCoverage, Type, UpscaleImageResponse, UrlRetrievalStatus, VideoCompressionQuality, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent, mcpToTool, setDefaultBaseUrls };
|
|
18026
|
+
export { ActivityHandling, AdapterSize, ApiError, ApiSpec, AuthType, Batches, Behavior, BlockedReason, Caches, Chat, Chats, ComputeTokensResponse, ControlReferenceImage, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DeleteModelResponse, DynamicRetrievalConfigMode, EditImageResponse, EditMode, EmbedContentResponse, EndSensitivity, Environment, FeatureSelectionPreference, FileSource, FileState, Files, FinishReason, FunctionCallingConfigMode, FunctionResponse, FunctionResponseScheduling, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GenerateVideosOperation, GenerateVideosResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpResponse, ImagePromptLanguage, InlinedResponse, JobState, Language, ListBatchJobsResponse, ListCachedContentsResponse, ListFilesResponse, ListModelsResponse, ListTuningJobsResponse, Live, LiveClientToolResponse, LiveMusicPlaybackControl, LiveMusicServerMessage, LiveSendToolResponseParameters, LiveServerMessage, MaskReferenceImage, MaskReferenceMode, MediaModality, MediaResolution, Modality, Mode, Models, Operations, Outcome, PagedItem, Pager, PersonGeneration, RawReferenceImage, ReplayResponse, SafetyFilterLevel, Scale, Session, StartSensitivity, StyleReferenceImage, SubjectReferenceImage, SubjectReferenceType, Tokens, TrafficType, TurnCoverage, Type, UpscaleImageResponse, UrlRetrievalStatus, VideoCompressionQuality, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent, mcpToTool, setDefaultBaseUrls };
|
|
17777
18027
|
//# sourceMappingURL=index.mjs.map
|