@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/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 = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredCount'];
|
|
1758
|
+
operationResponse.raiMediaFilteredReasons = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['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
|
]);
|
|
@@ -11821,6 +11961,12 @@ function embedContentMetadataFromMldev() {
|
|
|
11821
11961
|
}
|
|
11822
11962
|
function embedContentResponseFromMldev(fromObject) {
|
|
11823
11963
|
const toObject = {};
|
|
11964
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
11965
|
+
'sdkHttpResponse',
|
|
11966
|
+
]);
|
|
11967
|
+
if (fromSdkHttpResponse != null) {
|
|
11968
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
11969
|
+
}
|
|
11824
11970
|
const fromEmbeddings = getValueByPath(fromObject, ['embeddings']);
|
|
11825
11971
|
if (fromEmbeddings != null) {
|
|
11826
11972
|
let transformedList = fromEmbeddings;
|
|
@@ -11893,6 +12039,12 @@ function generatedImageFromMldev(fromObject) {
|
|
|
11893
12039
|
}
|
|
11894
12040
|
function generateImagesResponseFromMldev(fromObject) {
|
|
11895
12041
|
const toObject = {};
|
|
12042
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
12043
|
+
'sdkHttpResponse',
|
|
12044
|
+
]);
|
|
12045
|
+
if (fromSdkHttpResponse != null) {
|
|
12046
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
12047
|
+
}
|
|
11896
12048
|
const fromGeneratedImages = getValueByPath(fromObject, [
|
|
11897
12049
|
'predictions',
|
|
11898
12050
|
]);
|
|
@@ -11973,6 +12125,12 @@ function modelFromMldev(fromObject) {
|
|
|
11973
12125
|
}
|
|
11974
12126
|
function listModelsResponseFromMldev(fromObject) {
|
|
11975
12127
|
const toObject = {};
|
|
12128
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
12129
|
+
'sdkHttpResponse',
|
|
12130
|
+
]);
|
|
12131
|
+
if (fromSdkHttpResponse != null) {
|
|
12132
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
12133
|
+
}
|
|
11976
12134
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
11977
12135
|
'nextPageToken',
|
|
11978
12136
|
]);
|
|
@@ -11997,6 +12155,12 @@ function deleteModelResponseFromMldev() {
|
|
|
11997
12155
|
}
|
|
11998
12156
|
function countTokensResponseFromMldev(fromObject) {
|
|
11999
12157
|
const toObject = {};
|
|
12158
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
12159
|
+
'sdkHttpResponse',
|
|
12160
|
+
]);
|
|
12161
|
+
if (fromSdkHttpResponse != null) {
|
|
12162
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
12163
|
+
}
|
|
12000
12164
|
const fromTotalTokens = getValueByPath(fromObject, ['totalTokens']);
|
|
12001
12165
|
if (fromTotalTokens != null) {
|
|
12002
12166
|
setValueByPath(toObject, ['totalTokens'], fromTotalTokens);
|
|
@@ -12009,7 +12173,7 @@ function countTokensResponseFromMldev(fromObject) {
|
|
|
12009
12173
|
}
|
|
12010
12174
|
return toObject;
|
|
12011
12175
|
}
|
|
12012
|
-
function videoFromMldev
|
|
12176
|
+
function videoFromMldev(fromObject) {
|
|
12013
12177
|
const toObject = {};
|
|
12014
12178
|
const fromUri = getValueByPath(fromObject, ['video', 'uri']);
|
|
12015
12179
|
if (fromUri != null) {
|
|
@@ -12028,15 +12192,15 @@ function videoFromMldev$1(fromObject) {
|
|
|
12028
12192
|
}
|
|
12029
12193
|
return toObject;
|
|
12030
12194
|
}
|
|
12031
|
-
function generatedVideoFromMldev
|
|
12195
|
+
function generatedVideoFromMldev(fromObject) {
|
|
12032
12196
|
const toObject = {};
|
|
12033
12197
|
const fromVideo = getValueByPath(fromObject, ['_self']);
|
|
12034
12198
|
if (fromVideo != null) {
|
|
12035
|
-
setValueByPath(toObject, ['video'], videoFromMldev
|
|
12199
|
+
setValueByPath(toObject, ['video'], videoFromMldev(fromVideo));
|
|
12036
12200
|
}
|
|
12037
12201
|
return toObject;
|
|
12038
12202
|
}
|
|
12039
|
-
function generateVideosResponseFromMldev
|
|
12203
|
+
function generateVideosResponseFromMldev(fromObject) {
|
|
12040
12204
|
const toObject = {};
|
|
12041
12205
|
const fromGeneratedVideos = getValueByPath(fromObject, [
|
|
12042
12206
|
'generatedSamples',
|
|
@@ -12045,7 +12209,7 @@ function generateVideosResponseFromMldev$1(fromObject) {
|
|
|
12045
12209
|
let transformedList = fromGeneratedVideos;
|
|
12046
12210
|
if (Array.isArray(transformedList)) {
|
|
12047
12211
|
transformedList = transformedList.map((item) => {
|
|
12048
|
-
return generatedVideoFromMldev
|
|
12212
|
+
return generatedVideoFromMldev(item);
|
|
12049
12213
|
});
|
|
12050
12214
|
}
|
|
12051
12215
|
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
@@ -12064,7 +12228,7 @@ function generateVideosResponseFromMldev$1(fromObject) {
|
|
|
12064
12228
|
}
|
|
12065
12229
|
return toObject;
|
|
12066
12230
|
}
|
|
12067
|
-
function generateVideosOperationFromMldev
|
|
12231
|
+
function generateVideosOperationFromMldev(fromObject) {
|
|
12068
12232
|
const toObject = {};
|
|
12069
12233
|
const fromName = getValueByPath(fromObject, ['name']);
|
|
12070
12234
|
if (fromName != null) {
|
|
@@ -12087,7 +12251,7 @@ function generateVideosOperationFromMldev$1(fromObject) {
|
|
|
12087
12251
|
'generateVideoResponse',
|
|
12088
12252
|
]);
|
|
12089
12253
|
if (fromResponse != null) {
|
|
12090
|
-
setValueByPath(toObject, ['response'], generateVideosResponseFromMldev
|
|
12254
|
+
setValueByPath(toObject, ['response'], generateVideosResponseFromMldev(fromResponse));
|
|
12091
12255
|
}
|
|
12092
12256
|
return toObject;
|
|
12093
12257
|
}
|
|
@@ -12383,6 +12547,12 @@ function embedContentMetadataFromVertex(fromObject) {
|
|
|
12383
12547
|
}
|
|
12384
12548
|
function embedContentResponseFromVertex(fromObject) {
|
|
12385
12549
|
const toObject = {};
|
|
12550
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
12551
|
+
'sdkHttpResponse',
|
|
12552
|
+
]);
|
|
12553
|
+
if (fromSdkHttpResponse != null) {
|
|
12554
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
12555
|
+
}
|
|
12386
12556
|
const fromEmbeddings = getValueByPath(fromObject, [
|
|
12387
12557
|
'predictions[]',
|
|
12388
12558
|
'embeddings',
|
|
@@ -12466,6 +12636,12 @@ function generatedImageFromVertex(fromObject) {
|
|
|
12466
12636
|
}
|
|
12467
12637
|
function generateImagesResponseFromVertex(fromObject) {
|
|
12468
12638
|
const toObject = {};
|
|
12639
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
12640
|
+
'sdkHttpResponse',
|
|
12641
|
+
]);
|
|
12642
|
+
if (fromSdkHttpResponse != null) {
|
|
12643
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
12644
|
+
}
|
|
12469
12645
|
const fromGeneratedImages = getValueByPath(fromObject, [
|
|
12470
12646
|
'predictions',
|
|
12471
12647
|
]);
|
|
@@ -12488,6 +12664,12 @@ function generateImagesResponseFromVertex(fromObject) {
|
|
|
12488
12664
|
}
|
|
12489
12665
|
function editImageResponseFromVertex(fromObject) {
|
|
12490
12666
|
const toObject = {};
|
|
12667
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
12668
|
+
'sdkHttpResponse',
|
|
12669
|
+
]);
|
|
12670
|
+
if (fromSdkHttpResponse != null) {
|
|
12671
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
12672
|
+
}
|
|
12491
12673
|
const fromGeneratedImages = getValueByPath(fromObject, [
|
|
12492
12674
|
'predictions',
|
|
12493
12675
|
]);
|
|
@@ -12504,6 +12686,12 @@ function editImageResponseFromVertex(fromObject) {
|
|
|
12504
12686
|
}
|
|
12505
12687
|
function upscaleImageResponseFromVertex(fromObject) {
|
|
12506
12688
|
const toObject = {};
|
|
12689
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
12690
|
+
'sdkHttpResponse',
|
|
12691
|
+
]);
|
|
12692
|
+
if (fromSdkHttpResponse != null) {
|
|
12693
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
12694
|
+
}
|
|
12507
12695
|
const fromGeneratedImages = getValueByPath(fromObject, [
|
|
12508
12696
|
'predictions',
|
|
12509
12697
|
]);
|
|
@@ -12623,6 +12811,12 @@ function modelFromVertex(fromObject) {
|
|
|
12623
12811
|
}
|
|
12624
12812
|
function listModelsResponseFromVertex(fromObject) {
|
|
12625
12813
|
const toObject = {};
|
|
12814
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
12815
|
+
'sdkHttpResponse',
|
|
12816
|
+
]);
|
|
12817
|
+
if (fromSdkHttpResponse != null) {
|
|
12818
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
12819
|
+
}
|
|
12626
12820
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
12627
12821
|
'nextPageToken',
|
|
12628
12822
|
]);
|
|
@@ -12647,6 +12841,12 @@ function deleteModelResponseFromVertex() {
|
|
|
12647
12841
|
}
|
|
12648
12842
|
function countTokensResponseFromVertex(fromObject) {
|
|
12649
12843
|
const toObject = {};
|
|
12844
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
12845
|
+
'sdkHttpResponse',
|
|
12846
|
+
]);
|
|
12847
|
+
if (fromSdkHttpResponse != null) {
|
|
12848
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
12849
|
+
}
|
|
12650
12850
|
const fromTotalTokens = getValueByPath(fromObject, ['totalTokens']);
|
|
12651
12851
|
if (fromTotalTokens != null) {
|
|
12652
12852
|
setValueByPath(toObject, ['totalTokens'], fromTotalTokens);
|
|
@@ -12655,13 +12855,19 @@ function countTokensResponseFromVertex(fromObject) {
|
|
|
12655
12855
|
}
|
|
12656
12856
|
function computeTokensResponseFromVertex(fromObject) {
|
|
12657
12857
|
const toObject = {};
|
|
12858
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
12859
|
+
'sdkHttpResponse',
|
|
12860
|
+
]);
|
|
12861
|
+
if (fromSdkHttpResponse != null) {
|
|
12862
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
12863
|
+
}
|
|
12658
12864
|
const fromTokensInfo = getValueByPath(fromObject, ['tokensInfo']);
|
|
12659
12865
|
if (fromTokensInfo != null) {
|
|
12660
12866
|
setValueByPath(toObject, ['tokensInfo'], fromTokensInfo);
|
|
12661
12867
|
}
|
|
12662
12868
|
return toObject;
|
|
12663
12869
|
}
|
|
12664
|
-
function videoFromVertex
|
|
12870
|
+
function videoFromVertex(fromObject) {
|
|
12665
12871
|
const toObject = {};
|
|
12666
12872
|
const fromUri = getValueByPath(fromObject, ['gcsUri']);
|
|
12667
12873
|
if (fromUri != null) {
|
|
@@ -12679,22 +12885,22 @@ function videoFromVertex$1(fromObject) {
|
|
|
12679
12885
|
}
|
|
12680
12886
|
return toObject;
|
|
12681
12887
|
}
|
|
12682
|
-
function generatedVideoFromVertex
|
|
12888
|
+
function generatedVideoFromVertex(fromObject) {
|
|
12683
12889
|
const toObject = {};
|
|
12684
12890
|
const fromVideo = getValueByPath(fromObject, ['_self']);
|
|
12685
12891
|
if (fromVideo != null) {
|
|
12686
|
-
setValueByPath(toObject, ['video'], videoFromVertex
|
|
12892
|
+
setValueByPath(toObject, ['video'], videoFromVertex(fromVideo));
|
|
12687
12893
|
}
|
|
12688
12894
|
return toObject;
|
|
12689
12895
|
}
|
|
12690
|
-
function generateVideosResponseFromVertex
|
|
12896
|
+
function generateVideosResponseFromVertex(fromObject) {
|
|
12691
12897
|
const toObject = {};
|
|
12692
12898
|
const fromGeneratedVideos = getValueByPath(fromObject, ['videos']);
|
|
12693
12899
|
if (fromGeneratedVideos != null) {
|
|
12694
12900
|
let transformedList = fromGeneratedVideos;
|
|
12695
12901
|
if (Array.isArray(transformedList)) {
|
|
12696
12902
|
transformedList = transformedList.map((item) => {
|
|
12697
|
-
return generatedVideoFromVertex
|
|
12903
|
+
return generatedVideoFromVertex(item);
|
|
12698
12904
|
});
|
|
12699
12905
|
}
|
|
12700
12906
|
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
@@ -12713,7 +12919,7 @@ function generateVideosResponseFromVertex$1(fromObject) {
|
|
|
12713
12919
|
}
|
|
12714
12920
|
return toObject;
|
|
12715
12921
|
}
|
|
12716
|
-
function generateVideosOperationFromVertex
|
|
12922
|
+
function generateVideosOperationFromVertex(fromObject) {
|
|
12717
12923
|
const toObject = {};
|
|
12718
12924
|
const fromName = getValueByPath(fromObject, ['name']);
|
|
12719
12925
|
if (fromName != null) {
|
|
@@ -12733,7 +12939,7 @@ function generateVideosOperationFromVertex$1(fromObject) {
|
|
|
12733
12939
|
}
|
|
12734
12940
|
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
12735
12941
|
if (fromResponse != null) {
|
|
12736
|
-
setValueByPath(toObject, ['response'], generateVideosResponseFromVertex
|
|
12942
|
+
setValueByPath(toObject, ['response'], generateVideosResponseFromVertex(fromResponse));
|
|
12737
12943
|
}
|
|
12738
12944
|
return toObject;
|
|
12739
12945
|
}
|
|
@@ -12747,7 +12953,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
12747
12953
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
12748
12954
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
12749
12955
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
12750
|
-
const SDK_VERSION = '1.
|
|
12956
|
+
const SDK_VERSION = '1.12.0'; // x-release-please-version
|
|
12751
12957
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
12752
12958
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
12753
12959
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -13340,18 +13546,6 @@ function setMcpUsageHeader(headers) {
|
|
|
13340
13546
|
const existingHeader = (_a = headers[GOOGLE_API_CLIENT_HEADER]) !== null && _a !== void 0 ? _a : '';
|
|
13341
13547
|
headers[GOOGLE_API_CLIENT_HEADER] = (existingHeader + ` ${MCP_LABEL}`).trimStart();
|
|
13342
13548
|
}
|
|
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
13549
|
// Returns true if the object is a MCP CallableTool, otherwise false.
|
|
13356
13550
|
function isMcpCallableTool(object) {
|
|
13357
13551
|
return (object !== null &&
|
|
@@ -13845,13 +14039,13 @@ class Live {
|
|
|
13845
14039
|
const websocketBaseUrl = this.apiClient.getWebsocketBaseUrl();
|
|
13846
14040
|
const apiVersion = this.apiClient.getApiVersion();
|
|
13847
14041
|
let url;
|
|
13848
|
-
const
|
|
14042
|
+
const clientHeaders = this.apiClient.getHeaders();
|
|
13849
14043
|
if (params.config &&
|
|
13850
14044
|
params.config.tools &&
|
|
13851
14045
|
hasMcpToolUsage(params.config.tools)) {
|
|
13852
|
-
setMcpUsageHeader(
|
|
14046
|
+
setMcpUsageHeader(clientHeaders);
|
|
13853
14047
|
}
|
|
13854
|
-
const headers = mapToHeaders(
|
|
14048
|
+
const headers = mapToHeaders(clientHeaders);
|
|
13855
14049
|
if (this.apiClient.isVertexAI()) {
|
|
13856
14050
|
url = `${websocketBaseUrl}/ws/google.cloud.aiplatform.${apiVersion}.LlmBidiService/BidiGenerateContent`;
|
|
13857
14051
|
await this.auth.addAuthHeaders(headers);
|
|
@@ -14210,6 +14404,18 @@ function shouldDisableAfc(config) {
|
|
|
14210
14404
|
function isCallableTool(tool) {
|
|
14211
14405
|
return 'callTool' in tool && typeof tool.callTool === 'function';
|
|
14212
14406
|
}
|
|
14407
|
+
// Checks whether the list of tools contains any CallableTools. Will return true
|
|
14408
|
+
// if there is at least one CallableTool.
|
|
14409
|
+
function hasCallableTools(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
|
+
}
|
|
14413
|
+
// Checks whether the list of tools contains any non-callable tools. Will return
|
|
14414
|
+
// true if there is at least one non-Callable tool.
|
|
14415
|
+
function hasNonCallableTools(params) {
|
|
14416
|
+
var _a, _b, _c;
|
|
14417
|
+
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;
|
|
14418
|
+
}
|
|
14213
14419
|
/**
|
|
14214
14420
|
* Returns whether to append automatic function calling history to the
|
|
14215
14421
|
* response.
|
|
@@ -14268,12 +14474,12 @@ class Models extends BaseModule {
|
|
|
14268
14474
|
*/
|
|
14269
14475
|
this.generateContent = async (params) => {
|
|
14270
14476
|
var _a, _b, _c, _d, _e;
|
|
14271
|
-
const transformedParams = await this.
|
|
14477
|
+
const transformedParams = await this.processParamsMaybeAddMcpUsage(params);
|
|
14272
14478
|
this.maybeMoveToResponseJsonSchem(params);
|
|
14273
|
-
if (!
|
|
14479
|
+
if (!hasCallableTools(params) || shouldDisableAfc(params.config)) {
|
|
14274
14480
|
return await this.generateContentInternal(transformedParams);
|
|
14275
14481
|
}
|
|
14276
|
-
if (
|
|
14482
|
+
if (hasNonCallableTools(params)) {
|
|
14277
14483
|
throw new Error('Automatic function calling with CallableTools and Tools is not yet supported.');
|
|
14278
14484
|
}
|
|
14279
14485
|
let response;
|
|
@@ -14358,7 +14564,7 @@ class Models extends BaseModule {
|
|
|
14358
14564
|
this.generateContentStream = async (params) => {
|
|
14359
14565
|
this.maybeMoveToResponseJsonSchem(params);
|
|
14360
14566
|
if (shouldDisableAfc(params.config)) {
|
|
14361
|
-
const transformedParams = await this.
|
|
14567
|
+
const transformedParams = await this.processParamsMaybeAddMcpUsage(params);
|
|
14362
14568
|
return await this.generateContentStreamInternal(transformedParams);
|
|
14363
14569
|
}
|
|
14364
14570
|
else {
|
|
@@ -14406,11 +14612,13 @@ class Models extends BaseModule {
|
|
|
14406
14612
|
response = {
|
|
14407
14613
|
generatedImages: generatedImages,
|
|
14408
14614
|
positivePromptSafetyAttributes: positivePromptSafetyAttributes,
|
|
14615
|
+
sdkHttpResponse: apiResponse.sdkHttpResponse,
|
|
14409
14616
|
};
|
|
14410
14617
|
}
|
|
14411
14618
|
else {
|
|
14412
14619
|
response = {
|
|
14413
14620
|
generatedImages: generatedImages,
|
|
14621
|
+
sdkHttpResponse: apiResponse.sdkHttpResponse,
|
|
14414
14622
|
};
|
|
14415
14623
|
}
|
|
14416
14624
|
return response;
|
|
@@ -14507,6 +14715,32 @@ class Models extends BaseModule {
|
|
|
14507
14715
|
};
|
|
14508
14716
|
return await this.upscaleImageInternal(apiParams);
|
|
14509
14717
|
};
|
|
14718
|
+
/**
|
|
14719
|
+
* Generates videos based on a text description and configuration.
|
|
14720
|
+
*
|
|
14721
|
+
* @param params - The parameters for generating videos.
|
|
14722
|
+
* @return A Promise<GenerateVideosOperation> which allows you to track the progress and eventually retrieve the generated videos using the operations.get method.
|
|
14723
|
+
*
|
|
14724
|
+
* @example
|
|
14725
|
+
* ```ts
|
|
14726
|
+
* const operation = await ai.models.generateVideos({
|
|
14727
|
+
* model: 'veo-2.0-generate-001',
|
|
14728
|
+
* prompt: 'A neon hologram of a cat driving at top speed',
|
|
14729
|
+
* config: {
|
|
14730
|
+
* numberOfVideos: 1
|
|
14731
|
+
* });
|
|
14732
|
+
*
|
|
14733
|
+
* while (!operation.done) {
|
|
14734
|
+
* await new Promise(resolve => setTimeout(resolve, 10000));
|
|
14735
|
+
* operation = await ai.operations.getVideosOperation({operation: operation});
|
|
14736
|
+
* }
|
|
14737
|
+
*
|
|
14738
|
+
* console.log(operation.response?.generatedVideos?.[0]?.video?.uri);
|
|
14739
|
+
* ```
|
|
14740
|
+
*/
|
|
14741
|
+
this.generateVideos = async (params) => {
|
|
14742
|
+
return await this.generateVideosInternal(params);
|
|
14743
|
+
};
|
|
14510
14744
|
}
|
|
14511
14745
|
/**
|
|
14512
14746
|
* This logic is needed for GenerateContentConfig only.
|
|
@@ -14532,7 +14766,7 @@ class Models extends BaseModule {
|
|
|
14532
14766
|
* modify the original params. Also sets the MCP usage header if there are
|
|
14533
14767
|
* MCP tools in the parameters.
|
|
14534
14768
|
*/
|
|
14535
|
-
async
|
|
14769
|
+
async processParamsMaybeAddMcpUsage(params) {
|
|
14536
14770
|
var _a, _b, _c;
|
|
14537
14771
|
const tools = (_a = params.config) === null || _a === void 0 ? void 0 : _a.tools;
|
|
14538
14772
|
if (!tools) {
|
|
@@ -14599,7 +14833,7 @@ class Models extends BaseModule {
|
|
|
14599
14833
|
remoteCallCount++;
|
|
14600
14834
|
wereFunctionsCalled = false;
|
|
14601
14835
|
}
|
|
14602
|
-
const transformedParams = yield __await(models.
|
|
14836
|
+
const transformedParams = yield __await(models.processParamsMaybeAddMcpUsage(params));
|
|
14603
14837
|
const response = yield __await(models.generateContentStreamInternal(transformedParams));
|
|
14604
14838
|
const functionResponses = [];
|
|
14605
14839
|
const responseContents = [];
|
|
@@ -14870,7 +15104,13 @@ class Models extends BaseModule {
|
|
|
14870
15104
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
14871
15105
|
})
|
|
14872
15106
|
.then((httpResponse) => {
|
|
14873
|
-
return httpResponse.json()
|
|
15107
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
15108
|
+
const response = jsonResponse;
|
|
15109
|
+
response.sdkHttpResponse = {
|
|
15110
|
+
headers: httpResponse.headers,
|
|
15111
|
+
};
|
|
15112
|
+
return response;
|
|
15113
|
+
});
|
|
14874
15114
|
});
|
|
14875
15115
|
return response.then((apiResponse) => {
|
|
14876
15116
|
const resp = embedContentResponseFromVertex(apiResponse);
|
|
@@ -14896,7 +15136,13 @@ class Models extends BaseModule {
|
|
|
14896
15136
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
14897
15137
|
})
|
|
14898
15138
|
.then((httpResponse) => {
|
|
14899
|
-
return httpResponse.json()
|
|
15139
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
15140
|
+
const response = jsonResponse;
|
|
15141
|
+
response.sdkHttpResponse = {
|
|
15142
|
+
headers: httpResponse.headers,
|
|
15143
|
+
};
|
|
15144
|
+
return response;
|
|
15145
|
+
});
|
|
14900
15146
|
});
|
|
14901
15147
|
return response.then((apiResponse) => {
|
|
14902
15148
|
const resp = embedContentResponseFromMldev(apiResponse);
|
|
@@ -14947,7 +15193,13 @@ class Models extends BaseModule {
|
|
|
14947
15193
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
14948
15194
|
})
|
|
14949
15195
|
.then((httpResponse) => {
|
|
14950
|
-
return httpResponse.json()
|
|
15196
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
15197
|
+
const response = jsonResponse;
|
|
15198
|
+
response.sdkHttpResponse = {
|
|
15199
|
+
headers: httpResponse.headers,
|
|
15200
|
+
};
|
|
15201
|
+
return response;
|
|
15202
|
+
});
|
|
14951
15203
|
});
|
|
14952
15204
|
return response.then((apiResponse) => {
|
|
14953
15205
|
const resp = generateImagesResponseFromVertex(apiResponse);
|
|
@@ -14973,7 +15225,13 @@ class Models extends BaseModule {
|
|
|
14973
15225
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
14974
15226
|
})
|
|
14975
15227
|
.then((httpResponse) => {
|
|
14976
|
-
return httpResponse.json()
|
|
15228
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
15229
|
+
const response = jsonResponse;
|
|
15230
|
+
response.sdkHttpResponse = {
|
|
15231
|
+
headers: httpResponse.headers,
|
|
15232
|
+
};
|
|
15233
|
+
return response;
|
|
15234
|
+
});
|
|
14977
15235
|
});
|
|
14978
15236
|
return response.then((apiResponse) => {
|
|
14979
15237
|
const resp = generateImagesResponseFromMldev(apiResponse);
|
|
@@ -15005,7 +15263,13 @@ class Models extends BaseModule {
|
|
|
15005
15263
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
15006
15264
|
})
|
|
15007
15265
|
.then((httpResponse) => {
|
|
15008
|
-
return httpResponse.json()
|
|
15266
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
15267
|
+
const response = jsonResponse;
|
|
15268
|
+
response.sdkHttpResponse = {
|
|
15269
|
+
headers: httpResponse.headers,
|
|
15270
|
+
};
|
|
15271
|
+
return response;
|
|
15272
|
+
});
|
|
15009
15273
|
});
|
|
15010
15274
|
return response.then((apiResponse) => {
|
|
15011
15275
|
const resp = editImageResponseFromVertex(apiResponse);
|
|
@@ -15040,13 +15304,19 @@ class Models extends BaseModule {
|
|
|
15040
15304
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
15041
15305
|
})
|
|
15042
15306
|
.then((httpResponse) => {
|
|
15043
|
-
return httpResponse.json()
|
|
15044
|
-
|
|
15045
|
-
|
|
15046
|
-
|
|
15047
|
-
|
|
15048
|
-
|
|
15049
|
-
|
|
15307
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
15308
|
+
const response = jsonResponse;
|
|
15309
|
+
response.sdkHttpResponse = {
|
|
15310
|
+
headers: httpResponse.headers,
|
|
15311
|
+
};
|
|
15312
|
+
return response;
|
|
15313
|
+
});
|
|
15314
|
+
});
|
|
15315
|
+
return response.then((apiResponse) => {
|
|
15316
|
+
const resp = upscaleImageResponseFromVertex(apiResponse);
|
|
15317
|
+
const typedResp = new UpscaleImageResponse();
|
|
15318
|
+
Object.assign(typedResp, resp);
|
|
15319
|
+
return typedResp;
|
|
15050
15320
|
});
|
|
15051
15321
|
}
|
|
15052
15322
|
else {
|
|
@@ -15137,7 +15407,13 @@ class Models extends BaseModule {
|
|
|
15137
15407
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
15138
15408
|
})
|
|
15139
15409
|
.then((httpResponse) => {
|
|
15140
|
-
return httpResponse.json()
|
|
15410
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
15411
|
+
const response = jsonResponse;
|
|
15412
|
+
response.sdkHttpResponse = {
|
|
15413
|
+
headers: httpResponse.headers,
|
|
15414
|
+
};
|
|
15415
|
+
return response;
|
|
15416
|
+
});
|
|
15141
15417
|
});
|
|
15142
15418
|
return response.then((apiResponse) => {
|
|
15143
15419
|
const resp = listModelsResponseFromVertex(apiResponse);
|
|
@@ -15163,7 +15439,13 @@ class Models extends BaseModule {
|
|
|
15163
15439
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
15164
15440
|
})
|
|
15165
15441
|
.then((httpResponse) => {
|
|
15166
|
-
return httpResponse.json()
|
|
15442
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
15443
|
+
const response = jsonResponse;
|
|
15444
|
+
response.sdkHttpResponse = {
|
|
15445
|
+
headers: httpResponse.headers,
|
|
15446
|
+
};
|
|
15447
|
+
return response;
|
|
15448
|
+
});
|
|
15167
15449
|
});
|
|
15168
15450
|
return response.then((apiResponse) => {
|
|
15169
15451
|
const resp = listModelsResponseFromMldev(apiResponse);
|
|
@@ -15351,7 +15633,13 @@ class Models extends BaseModule {
|
|
|
15351
15633
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
15352
15634
|
})
|
|
15353
15635
|
.then((httpResponse) => {
|
|
15354
|
-
return httpResponse.json()
|
|
15636
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
15637
|
+
const response = jsonResponse;
|
|
15638
|
+
response.sdkHttpResponse = {
|
|
15639
|
+
headers: httpResponse.headers,
|
|
15640
|
+
};
|
|
15641
|
+
return response;
|
|
15642
|
+
});
|
|
15355
15643
|
});
|
|
15356
15644
|
return response.then((apiResponse) => {
|
|
15357
15645
|
const resp = countTokensResponseFromVertex(apiResponse);
|
|
@@ -15377,7 +15665,13 @@ class Models extends BaseModule {
|
|
|
15377
15665
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
15378
15666
|
})
|
|
15379
15667
|
.then((httpResponse) => {
|
|
15380
|
-
return httpResponse.json()
|
|
15668
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
15669
|
+
const response = jsonResponse;
|
|
15670
|
+
response.sdkHttpResponse = {
|
|
15671
|
+
headers: httpResponse.headers,
|
|
15672
|
+
};
|
|
15673
|
+
return response;
|
|
15674
|
+
});
|
|
15381
15675
|
});
|
|
15382
15676
|
return response.then((apiResponse) => {
|
|
15383
15677
|
const resp = countTokensResponseFromMldev(apiResponse);
|
|
@@ -15427,7 +15721,13 @@ class Models extends BaseModule {
|
|
|
15427
15721
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
15428
15722
|
})
|
|
15429
15723
|
.then((httpResponse) => {
|
|
15430
|
-
return httpResponse.json()
|
|
15724
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
15725
|
+
const response = jsonResponse;
|
|
15726
|
+
response.sdkHttpResponse = {
|
|
15727
|
+
headers: httpResponse.headers,
|
|
15728
|
+
};
|
|
15729
|
+
return response;
|
|
15730
|
+
});
|
|
15431
15731
|
});
|
|
15432
15732
|
return response.then((apiResponse) => {
|
|
15433
15733
|
const resp = computeTokensResponseFromVertex(apiResponse);
|
|
@@ -15463,7 +15763,7 @@ class Models extends BaseModule {
|
|
|
15463
15763
|
* console.log(operation.response?.generatedVideos?.[0]?.video?.uri);
|
|
15464
15764
|
* ```
|
|
15465
15765
|
*/
|
|
15466
|
-
async
|
|
15766
|
+
async generateVideosInternal(params) {
|
|
15467
15767
|
var _a, _b, _c, _d;
|
|
15468
15768
|
let response;
|
|
15469
15769
|
let path = '';
|
|
@@ -15488,8 +15788,10 @@ class Models extends BaseModule {
|
|
|
15488
15788
|
return httpResponse.json();
|
|
15489
15789
|
});
|
|
15490
15790
|
return response.then((apiResponse) => {
|
|
15491
|
-
const resp = generateVideosOperationFromVertex
|
|
15492
|
-
|
|
15791
|
+
const resp = generateVideosOperationFromVertex(apiResponse);
|
|
15792
|
+
const typedResp = new GenerateVideosOperation();
|
|
15793
|
+
Object.assign(typedResp, resp);
|
|
15794
|
+
return typedResp;
|
|
15493
15795
|
});
|
|
15494
15796
|
}
|
|
15495
15797
|
else {
|
|
@@ -15512,8 +15814,10 @@ class Models extends BaseModule {
|
|
|
15512
15814
|
return httpResponse.json();
|
|
15513
15815
|
});
|
|
15514
15816
|
return response.then((apiResponse) => {
|
|
15515
|
-
const resp = generateVideosOperationFromMldev
|
|
15516
|
-
|
|
15817
|
+
const resp = generateVideosOperationFromMldev(apiResponse);
|
|
15818
|
+
const typedResp = new GenerateVideosOperation();
|
|
15819
|
+
Object.assign(typedResp, resp);
|
|
15820
|
+
return typedResp;
|
|
15517
15821
|
});
|
|
15518
15822
|
}
|
|
15519
15823
|
}
|
|
@@ -15571,164 +15875,6 @@ function fetchPredictOperationParametersToVertex(fromObject) {
|
|
|
15571
15875
|
}
|
|
15572
15876
|
return toObject;
|
|
15573
15877
|
}
|
|
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
15878
|
|
|
15733
15879
|
/**
|
|
15734
15880
|
* @license
|
|
@@ -15758,17 +15904,64 @@ class Operations extends BaseModule {
|
|
|
15758
15904
|
if (config && 'httpOptions' in config) {
|
|
15759
15905
|
httpOptions = config.httpOptions;
|
|
15760
15906
|
}
|
|
15761
|
-
|
|
15907
|
+
const rawOperation = await this.fetchPredictVideosOperationInternal({
|
|
15762
15908
|
operationName: operation.name,
|
|
15763
15909
|
resourceName: resourceName,
|
|
15764
15910
|
config: { httpOptions: httpOptions },
|
|
15765
15911
|
});
|
|
15912
|
+
return operation._fromAPIResponse({
|
|
15913
|
+
apiResponse: rawOperation,
|
|
15914
|
+
isVertexAI: true,
|
|
15915
|
+
});
|
|
15766
15916
|
}
|
|
15767
15917
|
else {
|
|
15768
|
-
|
|
15918
|
+
const rawOperation = await this.getVideosOperationInternal({
|
|
15769
15919
|
operationName: operation.name,
|
|
15770
15920
|
config: config,
|
|
15771
15921
|
});
|
|
15922
|
+
return operation._fromAPIResponse({
|
|
15923
|
+
apiResponse: rawOperation,
|
|
15924
|
+
isVertexAI: false,
|
|
15925
|
+
});
|
|
15926
|
+
}
|
|
15927
|
+
}
|
|
15928
|
+
/**
|
|
15929
|
+
* Gets the status of a long-running operation.
|
|
15930
|
+
*
|
|
15931
|
+
* @param parameters The parameters for the get operation request.
|
|
15932
|
+
* @return The updated Operation object, with the latest status or result.
|
|
15933
|
+
*/
|
|
15934
|
+
async get(parameters) {
|
|
15935
|
+
const operation = parameters.operation;
|
|
15936
|
+
const config = parameters.config;
|
|
15937
|
+
if (operation.name === undefined || operation.name === '') {
|
|
15938
|
+
throw new Error('Operation name is required.');
|
|
15939
|
+
}
|
|
15940
|
+
if (this.apiClient.isVertexAI()) {
|
|
15941
|
+
const resourceName = operation.name.split('/operations/')[0];
|
|
15942
|
+
let httpOptions = undefined;
|
|
15943
|
+
if (config && 'httpOptions' in config) {
|
|
15944
|
+
httpOptions = config.httpOptions;
|
|
15945
|
+
}
|
|
15946
|
+
const rawOperation = await this.fetchPredictVideosOperationInternal({
|
|
15947
|
+
operationName: operation.name,
|
|
15948
|
+
resourceName: resourceName,
|
|
15949
|
+
config: { httpOptions: httpOptions },
|
|
15950
|
+
});
|
|
15951
|
+
return operation._fromAPIResponse({
|
|
15952
|
+
apiResponse: rawOperation,
|
|
15953
|
+
isVertexAI: true,
|
|
15954
|
+
});
|
|
15955
|
+
}
|
|
15956
|
+
else {
|
|
15957
|
+
const rawOperation = await this.getVideosOperationInternal({
|
|
15958
|
+
operationName: operation.name,
|
|
15959
|
+
config: config,
|
|
15960
|
+
});
|
|
15961
|
+
return operation._fromAPIResponse({
|
|
15962
|
+
apiResponse: rawOperation,
|
|
15963
|
+
isVertexAI: false,
|
|
15964
|
+
});
|
|
15772
15965
|
}
|
|
15773
15966
|
}
|
|
15774
15967
|
async getVideosOperationInternal(params) {
|
|
@@ -15795,10 +15988,7 @@ class Operations extends BaseModule {
|
|
|
15795
15988
|
.then((httpResponse) => {
|
|
15796
15989
|
return httpResponse.json();
|
|
15797
15990
|
});
|
|
15798
|
-
return response
|
|
15799
|
-
const resp = generateVideosOperationFromVertex(apiResponse);
|
|
15800
|
-
return resp;
|
|
15801
|
-
});
|
|
15991
|
+
return response;
|
|
15802
15992
|
}
|
|
15803
15993
|
else {
|
|
15804
15994
|
const body = getOperationParametersToMldev(params);
|
|
@@ -15819,10 +16009,7 @@ class Operations extends BaseModule {
|
|
|
15819
16009
|
.then((httpResponse) => {
|
|
15820
16010
|
return httpResponse.json();
|
|
15821
16011
|
});
|
|
15822
|
-
return response
|
|
15823
|
-
const resp = generateVideosOperationFromMldev(apiResponse);
|
|
15824
|
-
return resp;
|
|
15825
|
-
});
|
|
16012
|
+
return response;
|
|
15826
16013
|
}
|
|
15827
16014
|
}
|
|
15828
16015
|
async fetchPredictVideosOperationInternal(params) {
|
|
@@ -15849,10 +16036,7 @@ class Operations extends BaseModule {
|
|
|
15849
16036
|
.then((httpResponse) => {
|
|
15850
16037
|
return httpResponse.json();
|
|
15851
16038
|
});
|
|
15852
|
-
return response
|
|
15853
|
-
const resp = generateVideosOperationFromVertex(apiResponse);
|
|
15854
|
-
return resp;
|
|
15855
|
-
});
|
|
16039
|
+
return response;
|
|
15856
16040
|
}
|
|
15857
16041
|
else {
|
|
15858
16042
|
throw new Error('This method is only supported by the Vertex AI.');
|
|
@@ -17169,6 +17353,12 @@ function tunedModelFromMldev(fromObject) {
|
|
|
17169
17353
|
}
|
|
17170
17354
|
function tuningJobFromMldev(fromObject) {
|
|
17171
17355
|
const toObject = {};
|
|
17356
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
17357
|
+
'sdkHttpResponse',
|
|
17358
|
+
]);
|
|
17359
|
+
if (fromSdkHttpResponse != null) {
|
|
17360
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
17361
|
+
}
|
|
17172
17362
|
const fromName = getValueByPath(fromObject, ['name']);
|
|
17173
17363
|
if (fromName != null) {
|
|
17174
17364
|
setValueByPath(toObject, ['name'], fromName);
|
|
@@ -17253,6 +17443,12 @@ function tuningJobFromMldev(fromObject) {
|
|
|
17253
17443
|
}
|
|
17254
17444
|
function listTuningJobsResponseFromMldev(fromObject) {
|
|
17255
17445
|
const toObject = {};
|
|
17446
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
17447
|
+
'sdkHttpResponse',
|
|
17448
|
+
]);
|
|
17449
|
+
if (fromSdkHttpResponse != null) {
|
|
17450
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
17451
|
+
}
|
|
17256
17452
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
17257
17453
|
'nextPageToken',
|
|
17258
17454
|
]);
|
|
@@ -17273,6 +17469,12 @@ function listTuningJobsResponseFromMldev(fromObject) {
|
|
|
17273
17469
|
}
|
|
17274
17470
|
function tuningOperationFromMldev(fromObject) {
|
|
17275
17471
|
const toObject = {};
|
|
17472
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
17473
|
+
'sdkHttpResponse',
|
|
17474
|
+
]);
|
|
17475
|
+
if (fromSdkHttpResponse != null) {
|
|
17476
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
17477
|
+
}
|
|
17276
17478
|
const fromName = getValueByPath(fromObject, ['name']);
|
|
17277
17479
|
if (fromName != null) {
|
|
17278
17480
|
setValueByPath(toObject, ['name'], fromName);
|
|
@@ -17335,6 +17537,12 @@ function tunedModelFromVertex(fromObject) {
|
|
|
17335
17537
|
}
|
|
17336
17538
|
function tuningJobFromVertex(fromObject) {
|
|
17337
17539
|
const toObject = {};
|
|
17540
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
17541
|
+
'sdkHttpResponse',
|
|
17542
|
+
]);
|
|
17543
|
+
if (fromSdkHttpResponse != null) {
|
|
17544
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
17545
|
+
}
|
|
17338
17546
|
const fromName = getValueByPath(fromObject, ['name']);
|
|
17339
17547
|
if (fromName != null) {
|
|
17340
17548
|
setValueByPath(toObject, ['name'], fromName);
|
|
@@ -17441,6 +17649,12 @@ function tuningJobFromVertex(fromObject) {
|
|
|
17441
17649
|
}
|
|
17442
17650
|
function listTuningJobsResponseFromVertex(fromObject) {
|
|
17443
17651
|
const toObject = {};
|
|
17652
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
17653
|
+
'sdkHttpResponse',
|
|
17654
|
+
]);
|
|
17655
|
+
if (fromSdkHttpResponse != null) {
|
|
17656
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
17657
|
+
}
|
|
17444
17658
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
17445
17659
|
'nextPageToken',
|
|
17446
17660
|
]);
|
|
@@ -17547,7 +17761,13 @@ class Tunings extends BaseModule {
|
|
|
17547
17761
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
17548
17762
|
})
|
|
17549
17763
|
.then((httpResponse) => {
|
|
17550
|
-
return httpResponse.json()
|
|
17764
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
17765
|
+
const response = jsonResponse;
|
|
17766
|
+
response.sdkHttpResponse = {
|
|
17767
|
+
headers: httpResponse.headers,
|
|
17768
|
+
};
|
|
17769
|
+
return response;
|
|
17770
|
+
});
|
|
17551
17771
|
});
|
|
17552
17772
|
return response.then((apiResponse) => {
|
|
17553
17773
|
const resp = tuningJobFromVertex(apiResponse);
|
|
@@ -17571,7 +17791,13 @@ class Tunings extends BaseModule {
|
|
|
17571
17791
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
17572
17792
|
})
|
|
17573
17793
|
.then((httpResponse) => {
|
|
17574
|
-
return httpResponse.json()
|
|
17794
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
17795
|
+
const response = jsonResponse;
|
|
17796
|
+
response.sdkHttpResponse = {
|
|
17797
|
+
headers: httpResponse.headers,
|
|
17798
|
+
};
|
|
17799
|
+
return response;
|
|
17800
|
+
});
|
|
17575
17801
|
});
|
|
17576
17802
|
return response.then((apiResponse) => {
|
|
17577
17803
|
const resp = tuningJobFromMldev(apiResponse);
|
|
@@ -17601,7 +17827,13 @@ class Tunings extends BaseModule {
|
|
|
17601
17827
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
17602
17828
|
})
|
|
17603
17829
|
.then((httpResponse) => {
|
|
17604
|
-
return httpResponse.json()
|
|
17830
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
17831
|
+
const response = jsonResponse;
|
|
17832
|
+
response.sdkHttpResponse = {
|
|
17833
|
+
headers: httpResponse.headers,
|
|
17834
|
+
};
|
|
17835
|
+
return response;
|
|
17836
|
+
});
|
|
17605
17837
|
});
|
|
17606
17838
|
return response.then((apiResponse) => {
|
|
17607
17839
|
const resp = listTuningJobsResponseFromVertex(apiResponse);
|
|
@@ -17627,7 +17859,13 @@ class Tunings extends BaseModule {
|
|
|
17627
17859
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
17628
17860
|
})
|
|
17629
17861
|
.then((httpResponse) => {
|
|
17630
|
-
return httpResponse.json()
|
|
17862
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
17863
|
+
const response = jsonResponse;
|
|
17864
|
+
response.sdkHttpResponse = {
|
|
17865
|
+
headers: httpResponse.headers,
|
|
17866
|
+
};
|
|
17867
|
+
return response;
|
|
17868
|
+
});
|
|
17631
17869
|
});
|
|
17632
17870
|
return response.then((apiResponse) => {
|
|
17633
17871
|
const resp = listTuningJobsResponseFromMldev(apiResponse);
|
|
@@ -17659,7 +17897,13 @@ class Tunings extends BaseModule {
|
|
|
17659
17897
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
17660
17898
|
})
|
|
17661
17899
|
.then((httpResponse) => {
|
|
17662
|
-
return httpResponse.json()
|
|
17900
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
17901
|
+
const response = jsonResponse;
|
|
17902
|
+
response.sdkHttpResponse = {
|
|
17903
|
+
headers: httpResponse.headers,
|
|
17904
|
+
};
|
|
17905
|
+
return response;
|
|
17906
|
+
});
|
|
17663
17907
|
});
|
|
17664
17908
|
return response.then((apiResponse) => {
|
|
17665
17909
|
const resp = tuningJobFromVertex(apiResponse);
|
|
@@ -17695,7 +17939,13 @@ class Tunings extends BaseModule {
|
|
|
17695
17939
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
17696
17940
|
})
|
|
17697
17941
|
.then((httpResponse) => {
|
|
17698
|
-
return httpResponse.json()
|
|
17942
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
17943
|
+
const response = jsonResponse;
|
|
17944
|
+
response.sdkHttpResponse = {
|
|
17945
|
+
headers: httpResponse.headers,
|
|
17946
|
+
};
|
|
17947
|
+
return response;
|
|
17948
|
+
});
|
|
17699
17949
|
});
|
|
17700
17950
|
return response.then((apiResponse) => {
|
|
17701
17951
|
const resp = tuningOperationFromMldev(apiResponse);
|
|
@@ -18052,7 +18302,7 @@ class GoogleGenAI {
|
|
|
18052
18302
|
this.apiKey = undefined;
|
|
18053
18303
|
}
|
|
18054
18304
|
}
|
|
18055
|
-
const baseUrl = getBaseUrl(options, getEnv('GOOGLE_VERTEX_BASE_URL'), getEnv('GOOGLE_GEMINI_BASE_URL'));
|
|
18305
|
+
const baseUrl = getBaseUrl(options.httpOptions, options.vertexai, getEnv('GOOGLE_VERTEX_BASE_URL'), getEnv('GOOGLE_GEMINI_BASE_URL'));
|
|
18056
18306
|
if (baseUrl) {
|
|
18057
18307
|
if (options.httpOptions) {
|
|
18058
18308
|
options.httpOptions.baseUrl = baseUrl;
|
|
@@ -18111,5 +18361,5 @@ function getApiKeyFromEnv() {
|
|
|
18111
18361
|
return envGoogleApiKey || envGeminiApiKey;
|
|
18112
18362
|
}
|
|
18113
18363
|
|
|
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 };
|
|
18364
|
+
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
18365
|
//# sourceMappingURL=index.mjs.map
|