@google/genai 1.10.0 → 1.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/genai.d.ts +95 -18
- package/dist/index.cjs +327 -228
- package/dist/index.mjs +327 -229
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.cjs +335 -236
- package/dist/node/index.mjs +335 -237
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/node.d.ts +95 -18
- package/dist/web/index.mjs +335 -237
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +95 -18
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -160,6 +160,20 @@ function getValueByPath(data, keys) {
|
|
|
160
160
|
* Copyright 2025 Google LLC
|
|
161
161
|
* SPDX-License-Identifier: Apache-2.0
|
|
162
162
|
*/
|
|
163
|
+
function tBytes$1(fromBytes) {
|
|
164
|
+
if (typeof fromBytes !== 'string') {
|
|
165
|
+
throw new Error('fromImageBytes must be a string');
|
|
166
|
+
}
|
|
167
|
+
// TODO(b/389133914): Remove dummy bytes converter.
|
|
168
|
+
return fromBytes;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* @license
|
|
173
|
+
* Copyright 2025 Google LLC
|
|
174
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
175
|
+
*/
|
|
176
|
+
// Code generated by the Google Gen AI SDK generator DO NOT EDIT.
|
|
163
177
|
/** Required. Outcome of the code execution. */
|
|
164
178
|
var Outcome;
|
|
165
179
|
(function (Outcome) {
|
|
@@ -1653,6 +1667,65 @@ class LiveServerMessage {
|
|
|
1653
1667
|
return data.length > 0 ? btoa(data) : undefined;
|
|
1654
1668
|
}
|
|
1655
1669
|
}
|
|
1670
|
+
/** A video generation long-running operation. */
|
|
1671
|
+
class GenerateVideosOperation {
|
|
1672
|
+
/**
|
|
1673
|
+
* Instantiates an Operation of the same type as the one being called with the fields set from the API response.
|
|
1674
|
+
* @internal
|
|
1675
|
+
*/
|
|
1676
|
+
_fromAPIResponse({ apiResponse, isVertexAI, }) {
|
|
1677
|
+
const operation = new GenerateVideosOperation();
|
|
1678
|
+
operation.name = apiResponse['name'];
|
|
1679
|
+
operation.metadata = apiResponse['metadata'];
|
|
1680
|
+
operation.done = apiResponse['done'];
|
|
1681
|
+
operation.error = apiResponse['error'];
|
|
1682
|
+
if (isVertexAI) {
|
|
1683
|
+
const response = apiResponse['response'];
|
|
1684
|
+
if (response) {
|
|
1685
|
+
const operationResponse = new GenerateVideosResponse();
|
|
1686
|
+
const responseVideos = response['videos'];
|
|
1687
|
+
operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
|
|
1688
|
+
return {
|
|
1689
|
+
video: {
|
|
1690
|
+
uri: generatedVideo['gcsUri'],
|
|
1691
|
+
videoBytes: generatedVideo['bytesBase64Encoded']
|
|
1692
|
+
? tBytes$1(generatedVideo['bytesBase64Encoded'])
|
|
1693
|
+
: undefined,
|
|
1694
|
+
mimeType: generatedVideo['mimeType'],
|
|
1695
|
+
},
|
|
1696
|
+
};
|
|
1697
|
+
});
|
|
1698
|
+
operationResponse.raiMediaFilteredCount = response['raiMediaFilteredCount'];
|
|
1699
|
+
operationResponse.raiMediaFilteredReasons = response['raiMediaFilteredReasons'];
|
|
1700
|
+
operation.response = operationResponse;
|
|
1701
|
+
}
|
|
1702
|
+
}
|
|
1703
|
+
else {
|
|
1704
|
+
const response = apiResponse['response'];
|
|
1705
|
+
if (response) {
|
|
1706
|
+
const operationResponse = new GenerateVideosResponse();
|
|
1707
|
+
const generatedVideoResponse = response['generateVideoResponse'];
|
|
1708
|
+
const responseVideos = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['generatedSamples'];
|
|
1709
|
+
operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
|
|
1710
|
+
const video = generatedVideo['video'];
|
|
1711
|
+
return {
|
|
1712
|
+
video: {
|
|
1713
|
+
uri: video === null || video === void 0 ? void 0 : video['uri'],
|
|
1714
|
+
videoBytes: (video === null || video === void 0 ? void 0 : video['encodedVideo'])
|
|
1715
|
+
? tBytes$1(video === null || video === void 0 ? void 0 : video['encodedVideo'])
|
|
1716
|
+
: undefined,
|
|
1717
|
+
mimeType: generatedVideo['encoding'],
|
|
1718
|
+
},
|
|
1719
|
+
};
|
|
1720
|
+
});
|
|
1721
|
+
operationResponse.raiMediaFilteredCount = response['raiMediaFilteredCount'];
|
|
1722
|
+
operationResponse.raiMediaFilteredReasons = response['raiMediaFilteredReasons'];
|
|
1723
|
+
operation.response = operationResponse;
|
|
1724
|
+
}
|
|
1725
|
+
}
|
|
1726
|
+
return operation;
|
|
1727
|
+
}
|
|
1728
|
+
}
|
|
1656
1729
|
/** Client generated response to a `ToolCall` received from the server.
|
|
1657
1730
|
|
|
1658
1731
|
Individual `FunctionResponse` objects are matched to the respective
|
|
@@ -2214,11 +2287,7 @@ function tTuningJobStatus(status) {
|
|
|
2214
2287
|
}
|
|
2215
2288
|
}
|
|
2216
2289
|
function tBytes(fromImageBytes) {
|
|
2217
|
-
|
|
2218
|
-
throw new Error('fromImageBytes must be a string');
|
|
2219
|
-
}
|
|
2220
|
-
// TODO(b/389133914): Remove dummy bytes converter.
|
|
2221
|
-
return fromImageBytes;
|
|
2290
|
+
return tBytes$1(fromImageBytes);
|
|
2222
2291
|
}
|
|
2223
2292
|
function _isFile(origin) {
|
|
2224
2293
|
return (origin !== null &&
|
|
@@ -3706,6 +3775,12 @@ function batchJobFromMldev(fromObject) {
|
|
|
3706
3775
|
}
|
|
3707
3776
|
function listBatchJobsResponseFromMldev(fromObject) {
|
|
3708
3777
|
const toObject = {};
|
|
3778
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
3779
|
+
'sdkHttpResponse',
|
|
3780
|
+
]);
|
|
3781
|
+
if (fromSdkHttpResponse != null) {
|
|
3782
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
3783
|
+
}
|
|
3709
3784
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
3710
3785
|
'nextPageToken',
|
|
3711
3786
|
]);
|
|
@@ -3847,6 +3922,12 @@ function batchJobFromVertex(fromObject) {
|
|
|
3847
3922
|
}
|
|
3848
3923
|
function listBatchJobsResponseFromVertex(fromObject) {
|
|
3849
3924
|
const toObject = {};
|
|
3925
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
3926
|
+
'sdkHttpResponse',
|
|
3927
|
+
]);
|
|
3928
|
+
if (fromSdkHttpResponse != null) {
|
|
3929
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
3930
|
+
}
|
|
3850
3931
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
3851
3932
|
'nextPageToken',
|
|
3852
3933
|
]);
|
|
@@ -3889,9 +3970,6 @@ function deleteResourceJobFromVertex(fromObject) {
|
|
|
3889
3970
|
* Copyright 2025 Google LLC
|
|
3890
3971
|
* SPDX-License-Identifier: Apache-2.0
|
|
3891
3972
|
*/
|
|
3892
|
-
/**
|
|
3893
|
-
* Pagers for the GenAI List APIs.
|
|
3894
|
-
*/
|
|
3895
3973
|
var PagedItem;
|
|
3896
3974
|
(function (PagedItem) {
|
|
3897
3975
|
PagedItem["PAGED_ITEM_BATCH_JOBS"] = "batchJobs";
|
|
@@ -3914,9 +3992,10 @@ class Pager {
|
|
|
3914
3992
|
var _a, _b;
|
|
3915
3993
|
this.nameInternal = name;
|
|
3916
3994
|
this.pageInternal = response[this.nameInternal] || [];
|
|
3995
|
+
this.sdkHttpResponseInternal = response === null || response === void 0 ? void 0 : response.sdkHttpResponse;
|
|
3917
3996
|
this.idxInternal = 0;
|
|
3918
3997
|
let requestParams = { config: {} };
|
|
3919
|
-
if (!params) {
|
|
3998
|
+
if (!params || Object.keys(params).length === 0) {
|
|
3920
3999
|
requestParams = { config: {} };
|
|
3921
4000
|
}
|
|
3922
4001
|
else if (typeof params === 'object') {
|
|
@@ -3960,6 +4039,12 @@ class Pager {
|
|
|
3960
4039
|
get pageSize() {
|
|
3961
4040
|
return this.pageInternalSize;
|
|
3962
4041
|
}
|
|
4042
|
+
/**
|
|
4043
|
+
* Returns the headers of the API response.
|
|
4044
|
+
*/
|
|
4045
|
+
get sdkHttpResponse() {
|
|
4046
|
+
return this.sdkHttpResponseInternal;
|
|
4047
|
+
}
|
|
3963
4048
|
/**
|
|
3964
4049
|
* Returns the parameters when making the API request for the next page.
|
|
3965
4050
|
*
|
|
@@ -4329,7 +4414,13 @@ class Batches extends BaseModule {
|
|
|
4329
4414
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
4330
4415
|
})
|
|
4331
4416
|
.then((httpResponse) => {
|
|
4332
|
-
return httpResponse.json()
|
|
4417
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
4418
|
+
const response = jsonResponse;
|
|
4419
|
+
response.sdkHttpResponse = {
|
|
4420
|
+
headers: httpResponse.headers,
|
|
4421
|
+
};
|
|
4422
|
+
return response;
|
|
4423
|
+
});
|
|
4333
4424
|
});
|
|
4334
4425
|
return response.then((apiResponse) => {
|
|
4335
4426
|
const resp = listBatchJobsResponseFromVertex(apiResponse);
|
|
@@ -4355,7 +4446,13 @@ class Batches extends BaseModule {
|
|
|
4355
4446
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
4356
4447
|
})
|
|
4357
4448
|
.then((httpResponse) => {
|
|
4358
|
-
return httpResponse.json()
|
|
4449
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
4450
|
+
const response = jsonResponse;
|
|
4451
|
+
response.sdkHttpResponse = {
|
|
4452
|
+
headers: httpResponse.headers,
|
|
4453
|
+
};
|
|
4454
|
+
return response;
|
|
4455
|
+
});
|
|
4359
4456
|
});
|
|
4360
4457
|
return response.then((apiResponse) => {
|
|
4361
4458
|
const resp = listBatchJobsResponseFromMldev(apiResponse);
|
|
@@ -5408,6 +5505,12 @@ function deleteCachedContentResponseFromMldev() {
|
|
|
5408
5505
|
}
|
|
5409
5506
|
function listCachedContentsResponseFromMldev(fromObject) {
|
|
5410
5507
|
const toObject = {};
|
|
5508
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
5509
|
+
'sdkHttpResponse',
|
|
5510
|
+
]);
|
|
5511
|
+
if (fromSdkHttpResponse != null) {
|
|
5512
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
5513
|
+
}
|
|
5411
5514
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
5412
5515
|
'nextPageToken',
|
|
5413
5516
|
]);
|
|
@@ -5468,6 +5571,12 @@ function deleteCachedContentResponseFromVertex() {
|
|
|
5468
5571
|
}
|
|
5469
5572
|
function listCachedContentsResponseFromVertex(fromObject) {
|
|
5470
5573
|
const toObject = {};
|
|
5574
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
5575
|
+
'sdkHttpResponse',
|
|
5576
|
+
]);
|
|
5577
|
+
if (fromSdkHttpResponse != null) {
|
|
5578
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
5579
|
+
}
|
|
5471
5580
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
5472
5581
|
'nextPageToken',
|
|
5473
5582
|
]);
|
|
@@ -5820,7 +5929,13 @@ class Caches extends BaseModule {
|
|
|
5820
5929
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
5821
5930
|
})
|
|
5822
5931
|
.then((httpResponse) => {
|
|
5823
|
-
return httpResponse.json()
|
|
5932
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
5933
|
+
const response = jsonResponse;
|
|
5934
|
+
response.sdkHttpResponse = {
|
|
5935
|
+
headers: httpResponse.headers,
|
|
5936
|
+
};
|
|
5937
|
+
return response;
|
|
5938
|
+
});
|
|
5824
5939
|
});
|
|
5825
5940
|
return response.then((apiResponse) => {
|
|
5826
5941
|
const resp = listCachedContentsResponseFromVertex(apiResponse);
|
|
@@ -5846,7 +5961,13 @@ class Caches extends BaseModule {
|
|
|
5846
5961
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
5847
5962
|
})
|
|
5848
5963
|
.then((httpResponse) => {
|
|
5849
|
-
return httpResponse.json()
|
|
5964
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
5965
|
+
const response = jsonResponse;
|
|
5966
|
+
response.sdkHttpResponse = {
|
|
5967
|
+
headers: httpResponse.headers,
|
|
5968
|
+
};
|
|
5969
|
+
return response;
|
|
5970
|
+
});
|
|
5850
5971
|
});
|
|
5851
5972
|
return response.then((apiResponse) => {
|
|
5852
5973
|
const resp = listCachedContentsResponseFromMldev(apiResponse);
|
|
@@ -6269,7 +6390,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
6269
6390
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
6270
6391
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
6271
6392
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
6272
|
-
const SDK_VERSION = '1.
|
|
6393
|
+
const SDK_VERSION = '1.11.0'; // x-release-please-version
|
|
6273
6394
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
6274
6395
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
6275
6396
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -7181,6 +7302,12 @@ function fileFromMldev(fromObject) {
|
|
|
7181
7302
|
}
|
|
7182
7303
|
function listFilesResponseFromMldev(fromObject) {
|
|
7183
7304
|
const toObject = {};
|
|
7305
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
7306
|
+
'sdkHttpResponse',
|
|
7307
|
+
]);
|
|
7308
|
+
if (fromSdkHttpResponse != null) {
|
|
7309
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
7310
|
+
}
|
|
7184
7311
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
7185
7312
|
'nextPageToken',
|
|
7186
7313
|
]);
|
|
@@ -7342,7 +7469,13 @@ class Files extends BaseModule {
|
|
|
7342
7469
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
7343
7470
|
})
|
|
7344
7471
|
.then((httpResponse) => {
|
|
7345
|
-
return httpResponse.json()
|
|
7472
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
7473
|
+
const response = jsonResponse;
|
|
7474
|
+
response.sdkHttpResponse = {
|
|
7475
|
+
headers: httpResponse.headers,
|
|
7476
|
+
};
|
|
7477
|
+
return response;
|
|
7478
|
+
});
|
|
7346
7479
|
});
|
|
7347
7480
|
return response.then((apiResponse) => {
|
|
7348
7481
|
const resp = listFilesResponseFromMldev(apiResponse);
|
|
@@ -10568,6 +10701,9 @@ function generateImagesConfigToMldev(fromObject, parentObject) {
|
|
|
10568
10701
|
if (getValueByPath(fromObject, ['addWatermark']) !== undefined) {
|
|
10569
10702
|
throw new Error('addWatermark parameter is not supported in Gemini API.');
|
|
10570
10703
|
}
|
|
10704
|
+
if (getValueByPath(fromObject, ['imageSize']) !== undefined) {
|
|
10705
|
+
throw new Error('imageSize parameter is not supported in Gemini API.');
|
|
10706
|
+
}
|
|
10571
10707
|
if (getValueByPath(fromObject, ['enhancePrompt']) !== undefined) {
|
|
10572
10708
|
throw new Error('enhancePrompt parameter is not supported in Gemini API.');
|
|
10573
10709
|
}
|
|
@@ -11644,6 +11780,10 @@ function generateImagesConfigToVertex(fromObject, parentObject) {
|
|
|
11644
11780
|
if (parentObject !== undefined && fromAddWatermark != null) {
|
|
11645
11781
|
setValueByPath(parentObject, ['parameters', 'addWatermark'], fromAddWatermark);
|
|
11646
11782
|
}
|
|
11783
|
+
const fromImageSize = getValueByPath(fromObject, ['imageSize']);
|
|
11784
|
+
if (parentObject !== undefined && fromImageSize != null) {
|
|
11785
|
+
setValueByPath(parentObject, ['parameters', 'sampleImageSize'], fromImageSize);
|
|
11786
|
+
}
|
|
11647
11787
|
const fromEnhancePrompt = getValueByPath(fromObject, [
|
|
11648
11788
|
'enhancePrompt',
|
|
11649
11789
|
]);
|
|
@@ -12634,6 +12774,12 @@ function modelFromMldev(fromObject) {
|
|
|
12634
12774
|
}
|
|
12635
12775
|
function listModelsResponseFromMldev(fromObject) {
|
|
12636
12776
|
const toObject = {};
|
|
12777
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
12778
|
+
'sdkHttpResponse',
|
|
12779
|
+
]);
|
|
12780
|
+
if (fromSdkHttpResponse != null) {
|
|
12781
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
12782
|
+
}
|
|
12637
12783
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
12638
12784
|
'nextPageToken',
|
|
12639
12785
|
]);
|
|
@@ -12670,7 +12816,7 @@ function countTokensResponseFromMldev(fromObject) {
|
|
|
12670
12816
|
}
|
|
12671
12817
|
return toObject;
|
|
12672
12818
|
}
|
|
12673
|
-
function videoFromMldev
|
|
12819
|
+
function videoFromMldev(fromObject) {
|
|
12674
12820
|
const toObject = {};
|
|
12675
12821
|
const fromUri = getValueByPath(fromObject, ['video', 'uri']);
|
|
12676
12822
|
if (fromUri != null) {
|
|
@@ -12689,15 +12835,15 @@ function videoFromMldev$1(fromObject) {
|
|
|
12689
12835
|
}
|
|
12690
12836
|
return toObject;
|
|
12691
12837
|
}
|
|
12692
|
-
function generatedVideoFromMldev
|
|
12838
|
+
function generatedVideoFromMldev(fromObject) {
|
|
12693
12839
|
const toObject = {};
|
|
12694
12840
|
const fromVideo = getValueByPath(fromObject, ['_self']);
|
|
12695
12841
|
if (fromVideo != null) {
|
|
12696
|
-
setValueByPath(toObject, ['video'], videoFromMldev
|
|
12842
|
+
setValueByPath(toObject, ['video'], videoFromMldev(fromVideo));
|
|
12697
12843
|
}
|
|
12698
12844
|
return toObject;
|
|
12699
12845
|
}
|
|
12700
|
-
function generateVideosResponseFromMldev
|
|
12846
|
+
function generateVideosResponseFromMldev(fromObject) {
|
|
12701
12847
|
const toObject = {};
|
|
12702
12848
|
const fromGeneratedVideos = getValueByPath(fromObject, [
|
|
12703
12849
|
'generatedSamples',
|
|
@@ -12706,7 +12852,7 @@ function generateVideosResponseFromMldev$1(fromObject) {
|
|
|
12706
12852
|
let transformedList = fromGeneratedVideos;
|
|
12707
12853
|
if (Array.isArray(transformedList)) {
|
|
12708
12854
|
transformedList = transformedList.map((item) => {
|
|
12709
|
-
return generatedVideoFromMldev
|
|
12855
|
+
return generatedVideoFromMldev(item);
|
|
12710
12856
|
});
|
|
12711
12857
|
}
|
|
12712
12858
|
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
@@ -12725,7 +12871,7 @@ function generateVideosResponseFromMldev$1(fromObject) {
|
|
|
12725
12871
|
}
|
|
12726
12872
|
return toObject;
|
|
12727
12873
|
}
|
|
12728
|
-
function generateVideosOperationFromMldev
|
|
12874
|
+
function generateVideosOperationFromMldev(fromObject) {
|
|
12729
12875
|
const toObject = {};
|
|
12730
12876
|
const fromName = getValueByPath(fromObject, ['name']);
|
|
12731
12877
|
if (fromName != null) {
|
|
@@ -12748,7 +12894,7 @@ function generateVideosOperationFromMldev$1(fromObject) {
|
|
|
12748
12894
|
'generateVideoResponse',
|
|
12749
12895
|
]);
|
|
12750
12896
|
if (fromResponse != null) {
|
|
12751
|
-
setValueByPath(toObject, ['response'], generateVideosResponseFromMldev
|
|
12897
|
+
setValueByPath(toObject, ['response'], generateVideosResponseFromMldev(fromResponse));
|
|
12752
12898
|
}
|
|
12753
12899
|
return toObject;
|
|
12754
12900
|
}
|
|
@@ -13284,6 +13430,12 @@ function modelFromVertex(fromObject) {
|
|
|
13284
13430
|
}
|
|
13285
13431
|
function listModelsResponseFromVertex(fromObject) {
|
|
13286
13432
|
const toObject = {};
|
|
13433
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
13434
|
+
'sdkHttpResponse',
|
|
13435
|
+
]);
|
|
13436
|
+
if (fromSdkHttpResponse != null) {
|
|
13437
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
13438
|
+
}
|
|
13287
13439
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
13288
13440
|
'nextPageToken',
|
|
13289
13441
|
]);
|
|
@@ -13322,7 +13474,7 @@ function computeTokensResponseFromVertex(fromObject) {
|
|
|
13322
13474
|
}
|
|
13323
13475
|
return toObject;
|
|
13324
13476
|
}
|
|
13325
|
-
function videoFromVertex
|
|
13477
|
+
function videoFromVertex(fromObject) {
|
|
13326
13478
|
const toObject = {};
|
|
13327
13479
|
const fromUri = getValueByPath(fromObject, ['gcsUri']);
|
|
13328
13480
|
if (fromUri != null) {
|
|
@@ -13340,22 +13492,22 @@ function videoFromVertex$1(fromObject) {
|
|
|
13340
13492
|
}
|
|
13341
13493
|
return toObject;
|
|
13342
13494
|
}
|
|
13343
|
-
function generatedVideoFromVertex
|
|
13495
|
+
function generatedVideoFromVertex(fromObject) {
|
|
13344
13496
|
const toObject = {};
|
|
13345
13497
|
const fromVideo = getValueByPath(fromObject, ['_self']);
|
|
13346
13498
|
if (fromVideo != null) {
|
|
13347
|
-
setValueByPath(toObject, ['video'], videoFromVertex
|
|
13499
|
+
setValueByPath(toObject, ['video'], videoFromVertex(fromVideo));
|
|
13348
13500
|
}
|
|
13349
13501
|
return toObject;
|
|
13350
13502
|
}
|
|
13351
|
-
function generateVideosResponseFromVertex
|
|
13503
|
+
function generateVideosResponseFromVertex(fromObject) {
|
|
13352
13504
|
const toObject = {};
|
|
13353
13505
|
const fromGeneratedVideos = getValueByPath(fromObject, ['videos']);
|
|
13354
13506
|
if (fromGeneratedVideos != null) {
|
|
13355
13507
|
let transformedList = fromGeneratedVideos;
|
|
13356
13508
|
if (Array.isArray(transformedList)) {
|
|
13357
13509
|
transformedList = transformedList.map((item) => {
|
|
13358
|
-
return generatedVideoFromVertex
|
|
13510
|
+
return generatedVideoFromVertex(item);
|
|
13359
13511
|
});
|
|
13360
13512
|
}
|
|
13361
13513
|
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
@@ -13374,7 +13526,7 @@ function generateVideosResponseFromVertex$1(fromObject) {
|
|
|
13374
13526
|
}
|
|
13375
13527
|
return toObject;
|
|
13376
13528
|
}
|
|
13377
|
-
function generateVideosOperationFromVertex
|
|
13529
|
+
function generateVideosOperationFromVertex(fromObject) {
|
|
13378
13530
|
const toObject = {};
|
|
13379
13531
|
const fromName = getValueByPath(fromObject, ['name']);
|
|
13380
13532
|
if (fromName != null) {
|
|
@@ -13394,7 +13546,7 @@ function generateVideosOperationFromVertex$1(fromObject) {
|
|
|
13394
13546
|
}
|
|
13395
13547
|
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
13396
13548
|
if (fromResponse != null) {
|
|
13397
|
-
setValueByPath(toObject, ['response'], generateVideosResponseFromVertex
|
|
13549
|
+
setValueByPath(toObject, ['response'], generateVideosResponseFromVertex(fromResponse));
|
|
13398
13550
|
}
|
|
13399
13551
|
return toObject;
|
|
13400
13552
|
}
|
|
@@ -13427,18 +13579,6 @@ function setMcpUsageHeader(headers) {
|
|
|
13427
13579
|
const existingHeader = (_a = headers[GOOGLE_API_CLIENT_HEADER]) !== null && _a !== void 0 ? _a : '';
|
|
13428
13580
|
headers[GOOGLE_API_CLIENT_HEADER] = (existingHeader + ` ${MCP_LABEL}`).trimStart();
|
|
13429
13581
|
}
|
|
13430
|
-
// Checks whether the list of tools contains any MCP clients. Will return true
|
|
13431
|
-
// if there is at least one MCP client.
|
|
13432
|
-
function hasMcpClientTools(params) {
|
|
13433
|
-
var _a, _b, _c;
|
|
13434
|
-
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;
|
|
13435
|
-
}
|
|
13436
|
-
// Checks whether the list of tools contains any non-MCP tools. Will return true
|
|
13437
|
-
// if there is at least one non-MCP tool.
|
|
13438
|
-
function hasNonMcpTools(params) {
|
|
13439
|
-
var _a, _b, _c;
|
|
13440
|
-
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);
|
|
13441
|
-
}
|
|
13442
13582
|
// Returns true if the object is a MCP CallableTool, otherwise false.
|
|
13443
13583
|
function isMcpCallableTool(object) {
|
|
13444
13584
|
return (object !== null &&
|
|
@@ -14297,6 +14437,18 @@ function shouldDisableAfc(config) {
|
|
|
14297
14437
|
function isCallableTool(tool) {
|
|
14298
14438
|
return 'callTool' in tool && typeof tool.callTool === 'function';
|
|
14299
14439
|
}
|
|
14440
|
+
// Checks whether the list of tools contains any CallableTools. Will return true
|
|
14441
|
+
// if there is at least one CallableTool.
|
|
14442
|
+
function hasCallableTools(params) {
|
|
14443
|
+
var _a, _b, _c;
|
|
14444
|
+
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;
|
|
14445
|
+
}
|
|
14446
|
+
// Checks whether the list of tools contains any non-callable tools. Will return
|
|
14447
|
+
// true if there is at least one non-Callable tool.
|
|
14448
|
+
function hasNonCallableTools(params) {
|
|
14449
|
+
var _a, _b, _c;
|
|
14450
|
+
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;
|
|
14451
|
+
}
|
|
14300
14452
|
/**
|
|
14301
14453
|
* Returns whether to append automatic function calling history to the
|
|
14302
14454
|
* response.
|
|
@@ -14355,12 +14507,12 @@ class Models extends BaseModule {
|
|
|
14355
14507
|
*/
|
|
14356
14508
|
this.generateContent = async (params) => {
|
|
14357
14509
|
var _a, _b, _c, _d, _e;
|
|
14358
|
-
const transformedParams = await this.
|
|
14510
|
+
const transformedParams = await this.processParamsMaybeAddMcpUsage(params);
|
|
14359
14511
|
this.maybeMoveToResponseJsonSchem(params);
|
|
14360
|
-
if (!
|
|
14512
|
+
if (!hasCallableTools(params) || shouldDisableAfc(params.config)) {
|
|
14361
14513
|
return await this.generateContentInternal(transformedParams);
|
|
14362
14514
|
}
|
|
14363
|
-
if (
|
|
14515
|
+
if (hasNonCallableTools(params)) {
|
|
14364
14516
|
throw new Error('Automatic function calling with CallableTools and Tools is not yet supported.');
|
|
14365
14517
|
}
|
|
14366
14518
|
let response;
|
|
@@ -14445,7 +14597,7 @@ class Models extends BaseModule {
|
|
|
14445
14597
|
this.generateContentStream = async (params) => {
|
|
14446
14598
|
this.maybeMoveToResponseJsonSchem(params);
|
|
14447
14599
|
if (shouldDisableAfc(params.config)) {
|
|
14448
|
-
const transformedParams = await this.
|
|
14600
|
+
const transformedParams = await this.processParamsMaybeAddMcpUsage(params);
|
|
14449
14601
|
return await this.generateContentStreamInternal(transformedParams);
|
|
14450
14602
|
}
|
|
14451
14603
|
else {
|
|
@@ -14594,6 +14746,32 @@ class Models extends BaseModule {
|
|
|
14594
14746
|
};
|
|
14595
14747
|
return await this.upscaleImageInternal(apiParams);
|
|
14596
14748
|
};
|
|
14749
|
+
/**
|
|
14750
|
+
* Generates videos based on a text description and configuration.
|
|
14751
|
+
*
|
|
14752
|
+
* @param params - The parameters for generating videos.
|
|
14753
|
+
* @return A Promise<GenerateVideosOperation> which allows you to track the progress and eventually retrieve the generated videos using the operations.get method.
|
|
14754
|
+
*
|
|
14755
|
+
* @example
|
|
14756
|
+
* ```ts
|
|
14757
|
+
* const operation = await ai.models.generateVideos({
|
|
14758
|
+
* model: 'veo-2.0-generate-001',
|
|
14759
|
+
* prompt: 'A neon hologram of a cat driving at top speed',
|
|
14760
|
+
* config: {
|
|
14761
|
+
* numberOfVideos: 1
|
|
14762
|
+
* });
|
|
14763
|
+
*
|
|
14764
|
+
* while (!operation.done) {
|
|
14765
|
+
* await new Promise(resolve => setTimeout(resolve, 10000));
|
|
14766
|
+
* operation = await ai.operations.getVideosOperation({operation: operation});
|
|
14767
|
+
* }
|
|
14768
|
+
*
|
|
14769
|
+
* console.log(operation.response?.generatedVideos?.[0]?.video?.uri);
|
|
14770
|
+
* ```
|
|
14771
|
+
*/
|
|
14772
|
+
this.generateVideos = async (params) => {
|
|
14773
|
+
return await this.generateVideosInternal(params);
|
|
14774
|
+
};
|
|
14597
14775
|
}
|
|
14598
14776
|
/**
|
|
14599
14777
|
* This logic is needed for GenerateContentConfig only.
|
|
@@ -14619,7 +14797,7 @@ class Models extends BaseModule {
|
|
|
14619
14797
|
* modify the original params. Also sets the MCP usage header if there are
|
|
14620
14798
|
* MCP tools in the parameters.
|
|
14621
14799
|
*/
|
|
14622
|
-
async
|
|
14800
|
+
async processParamsMaybeAddMcpUsage(params) {
|
|
14623
14801
|
var _a, _b, _c;
|
|
14624
14802
|
const tools = (_a = params.config) === null || _a === void 0 ? void 0 : _a.tools;
|
|
14625
14803
|
if (!tools) {
|
|
@@ -14686,7 +14864,7 @@ class Models extends BaseModule {
|
|
|
14686
14864
|
remoteCallCount++;
|
|
14687
14865
|
wereFunctionsCalled = false;
|
|
14688
14866
|
}
|
|
14689
|
-
const transformedParams = yield __await(models.
|
|
14867
|
+
const transformedParams = yield __await(models.processParamsMaybeAddMcpUsage(params));
|
|
14690
14868
|
const response = yield __await(models.generateContentStreamInternal(transformedParams));
|
|
14691
14869
|
const functionResponses = [];
|
|
14692
14870
|
const responseContents = [];
|
|
@@ -15224,7 +15402,13 @@ class Models extends BaseModule {
|
|
|
15224
15402
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
15225
15403
|
})
|
|
15226
15404
|
.then((httpResponse) => {
|
|
15227
|
-
return httpResponse.json()
|
|
15405
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
15406
|
+
const response = jsonResponse;
|
|
15407
|
+
response.sdkHttpResponse = {
|
|
15408
|
+
headers: httpResponse.headers,
|
|
15409
|
+
};
|
|
15410
|
+
return response;
|
|
15411
|
+
});
|
|
15228
15412
|
});
|
|
15229
15413
|
return response.then((apiResponse) => {
|
|
15230
15414
|
const resp = listModelsResponseFromVertex(apiResponse);
|
|
@@ -15250,7 +15434,13 @@ class Models extends BaseModule {
|
|
|
15250
15434
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
15251
15435
|
})
|
|
15252
15436
|
.then((httpResponse) => {
|
|
15253
|
-
return httpResponse.json()
|
|
15437
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
15438
|
+
const response = jsonResponse;
|
|
15439
|
+
response.sdkHttpResponse = {
|
|
15440
|
+
headers: httpResponse.headers,
|
|
15441
|
+
};
|
|
15442
|
+
return response;
|
|
15443
|
+
});
|
|
15254
15444
|
});
|
|
15255
15445
|
return response.then((apiResponse) => {
|
|
15256
15446
|
const resp = listModelsResponseFromMldev(apiResponse);
|
|
@@ -15550,7 +15740,7 @@ class Models extends BaseModule {
|
|
|
15550
15740
|
* console.log(operation.response?.generatedVideos?.[0]?.video?.uri);
|
|
15551
15741
|
* ```
|
|
15552
15742
|
*/
|
|
15553
|
-
async
|
|
15743
|
+
async generateVideosInternal(params) {
|
|
15554
15744
|
var _a, _b, _c, _d;
|
|
15555
15745
|
let response;
|
|
15556
15746
|
let path = '';
|
|
@@ -15575,8 +15765,10 @@ class Models extends BaseModule {
|
|
|
15575
15765
|
return httpResponse.json();
|
|
15576
15766
|
});
|
|
15577
15767
|
return response.then((apiResponse) => {
|
|
15578
|
-
const resp = generateVideosOperationFromVertex
|
|
15579
|
-
|
|
15768
|
+
const resp = generateVideosOperationFromVertex(apiResponse);
|
|
15769
|
+
const typedResp = new GenerateVideosOperation();
|
|
15770
|
+
Object.assign(typedResp, resp);
|
|
15771
|
+
return typedResp;
|
|
15580
15772
|
});
|
|
15581
15773
|
}
|
|
15582
15774
|
else {
|
|
@@ -15599,8 +15791,10 @@ class Models extends BaseModule {
|
|
|
15599
15791
|
return httpResponse.json();
|
|
15600
15792
|
});
|
|
15601
15793
|
return response.then((apiResponse) => {
|
|
15602
|
-
const resp = generateVideosOperationFromMldev
|
|
15603
|
-
|
|
15794
|
+
const resp = generateVideosOperationFromMldev(apiResponse);
|
|
15795
|
+
const typedResp = new GenerateVideosOperation();
|
|
15796
|
+
Object.assign(typedResp, resp);
|
|
15797
|
+
return typedResp;
|
|
15604
15798
|
});
|
|
15605
15799
|
}
|
|
15606
15800
|
}
|
|
@@ -15658,164 +15852,6 @@ function fetchPredictOperationParametersToVertex(fromObject) {
|
|
|
15658
15852
|
}
|
|
15659
15853
|
return toObject;
|
|
15660
15854
|
}
|
|
15661
|
-
function videoFromMldev(fromObject) {
|
|
15662
|
-
const toObject = {};
|
|
15663
|
-
const fromUri = getValueByPath(fromObject, ['video', 'uri']);
|
|
15664
|
-
if (fromUri != null) {
|
|
15665
|
-
setValueByPath(toObject, ['uri'], fromUri);
|
|
15666
|
-
}
|
|
15667
|
-
const fromVideoBytes = getValueByPath(fromObject, [
|
|
15668
|
-
'video',
|
|
15669
|
-
'encodedVideo',
|
|
15670
|
-
]);
|
|
15671
|
-
if (fromVideoBytes != null) {
|
|
15672
|
-
setValueByPath(toObject, ['videoBytes'], tBytes(fromVideoBytes));
|
|
15673
|
-
}
|
|
15674
|
-
const fromMimeType = getValueByPath(fromObject, ['encoding']);
|
|
15675
|
-
if (fromMimeType != null) {
|
|
15676
|
-
setValueByPath(toObject, ['mimeType'], fromMimeType);
|
|
15677
|
-
}
|
|
15678
|
-
return toObject;
|
|
15679
|
-
}
|
|
15680
|
-
function generatedVideoFromMldev(fromObject) {
|
|
15681
|
-
const toObject = {};
|
|
15682
|
-
const fromVideo = getValueByPath(fromObject, ['_self']);
|
|
15683
|
-
if (fromVideo != null) {
|
|
15684
|
-
setValueByPath(toObject, ['video'], videoFromMldev(fromVideo));
|
|
15685
|
-
}
|
|
15686
|
-
return toObject;
|
|
15687
|
-
}
|
|
15688
|
-
function generateVideosResponseFromMldev(fromObject) {
|
|
15689
|
-
const toObject = {};
|
|
15690
|
-
const fromGeneratedVideos = getValueByPath(fromObject, [
|
|
15691
|
-
'generatedSamples',
|
|
15692
|
-
]);
|
|
15693
|
-
if (fromGeneratedVideos != null) {
|
|
15694
|
-
let transformedList = fromGeneratedVideos;
|
|
15695
|
-
if (Array.isArray(transformedList)) {
|
|
15696
|
-
transformedList = transformedList.map((item) => {
|
|
15697
|
-
return generatedVideoFromMldev(item);
|
|
15698
|
-
});
|
|
15699
|
-
}
|
|
15700
|
-
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
15701
|
-
}
|
|
15702
|
-
const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
|
|
15703
|
-
'raiMediaFilteredCount',
|
|
15704
|
-
]);
|
|
15705
|
-
if (fromRaiMediaFilteredCount != null) {
|
|
15706
|
-
setValueByPath(toObject, ['raiMediaFilteredCount'], fromRaiMediaFilteredCount);
|
|
15707
|
-
}
|
|
15708
|
-
const fromRaiMediaFilteredReasons = getValueByPath(fromObject, [
|
|
15709
|
-
'raiMediaFilteredReasons',
|
|
15710
|
-
]);
|
|
15711
|
-
if (fromRaiMediaFilteredReasons != null) {
|
|
15712
|
-
setValueByPath(toObject, ['raiMediaFilteredReasons'], fromRaiMediaFilteredReasons);
|
|
15713
|
-
}
|
|
15714
|
-
return toObject;
|
|
15715
|
-
}
|
|
15716
|
-
function generateVideosOperationFromMldev(fromObject) {
|
|
15717
|
-
const toObject = {};
|
|
15718
|
-
const fromName = getValueByPath(fromObject, ['name']);
|
|
15719
|
-
if (fromName != null) {
|
|
15720
|
-
setValueByPath(toObject, ['name'], fromName);
|
|
15721
|
-
}
|
|
15722
|
-
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
15723
|
-
if (fromMetadata != null) {
|
|
15724
|
-
setValueByPath(toObject, ['metadata'], fromMetadata);
|
|
15725
|
-
}
|
|
15726
|
-
const fromDone = getValueByPath(fromObject, ['done']);
|
|
15727
|
-
if (fromDone != null) {
|
|
15728
|
-
setValueByPath(toObject, ['done'], fromDone);
|
|
15729
|
-
}
|
|
15730
|
-
const fromError = getValueByPath(fromObject, ['error']);
|
|
15731
|
-
if (fromError != null) {
|
|
15732
|
-
setValueByPath(toObject, ['error'], fromError);
|
|
15733
|
-
}
|
|
15734
|
-
const fromResponse = getValueByPath(fromObject, [
|
|
15735
|
-
'response',
|
|
15736
|
-
'generateVideoResponse',
|
|
15737
|
-
]);
|
|
15738
|
-
if (fromResponse != null) {
|
|
15739
|
-
setValueByPath(toObject, ['response'], generateVideosResponseFromMldev(fromResponse));
|
|
15740
|
-
}
|
|
15741
|
-
return toObject;
|
|
15742
|
-
}
|
|
15743
|
-
function videoFromVertex(fromObject) {
|
|
15744
|
-
const toObject = {};
|
|
15745
|
-
const fromUri = getValueByPath(fromObject, ['gcsUri']);
|
|
15746
|
-
if (fromUri != null) {
|
|
15747
|
-
setValueByPath(toObject, ['uri'], fromUri);
|
|
15748
|
-
}
|
|
15749
|
-
const fromVideoBytes = getValueByPath(fromObject, [
|
|
15750
|
-
'bytesBase64Encoded',
|
|
15751
|
-
]);
|
|
15752
|
-
if (fromVideoBytes != null) {
|
|
15753
|
-
setValueByPath(toObject, ['videoBytes'], tBytes(fromVideoBytes));
|
|
15754
|
-
}
|
|
15755
|
-
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
15756
|
-
if (fromMimeType != null) {
|
|
15757
|
-
setValueByPath(toObject, ['mimeType'], fromMimeType);
|
|
15758
|
-
}
|
|
15759
|
-
return toObject;
|
|
15760
|
-
}
|
|
15761
|
-
function generatedVideoFromVertex(fromObject) {
|
|
15762
|
-
const toObject = {};
|
|
15763
|
-
const fromVideo = getValueByPath(fromObject, ['_self']);
|
|
15764
|
-
if (fromVideo != null) {
|
|
15765
|
-
setValueByPath(toObject, ['video'], videoFromVertex(fromVideo));
|
|
15766
|
-
}
|
|
15767
|
-
return toObject;
|
|
15768
|
-
}
|
|
15769
|
-
function generateVideosResponseFromVertex(fromObject) {
|
|
15770
|
-
const toObject = {};
|
|
15771
|
-
const fromGeneratedVideos = getValueByPath(fromObject, ['videos']);
|
|
15772
|
-
if (fromGeneratedVideos != null) {
|
|
15773
|
-
let transformedList = fromGeneratedVideos;
|
|
15774
|
-
if (Array.isArray(transformedList)) {
|
|
15775
|
-
transformedList = transformedList.map((item) => {
|
|
15776
|
-
return generatedVideoFromVertex(item);
|
|
15777
|
-
});
|
|
15778
|
-
}
|
|
15779
|
-
setValueByPath(toObject, ['generatedVideos'], transformedList);
|
|
15780
|
-
}
|
|
15781
|
-
const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
|
|
15782
|
-
'raiMediaFilteredCount',
|
|
15783
|
-
]);
|
|
15784
|
-
if (fromRaiMediaFilteredCount != null) {
|
|
15785
|
-
setValueByPath(toObject, ['raiMediaFilteredCount'], fromRaiMediaFilteredCount);
|
|
15786
|
-
}
|
|
15787
|
-
const fromRaiMediaFilteredReasons = getValueByPath(fromObject, [
|
|
15788
|
-
'raiMediaFilteredReasons',
|
|
15789
|
-
]);
|
|
15790
|
-
if (fromRaiMediaFilteredReasons != null) {
|
|
15791
|
-
setValueByPath(toObject, ['raiMediaFilteredReasons'], fromRaiMediaFilteredReasons);
|
|
15792
|
-
}
|
|
15793
|
-
return toObject;
|
|
15794
|
-
}
|
|
15795
|
-
function generateVideosOperationFromVertex(fromObject) {
|
|
15796
|
-
const toObject = {};
|
|
15797
|
-
const fromName = getValueByPath(fromObject, ['name']);
|
|
15798
|
-
if (fromName != null) {
|
|
15799
|
-
setValueByPath(toObject, ['name'], fromName);
|
|
15800
|
-
}
|
|
15801
|
-
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
15802
|
-
if (fromMetadata != null) {
|
|
15803
|
-
setValueByPath(toObject, ['metadata'], fromMetadata);
|
|
15804
|
-
}
|
|
15805
|
-
const fromDone = getValueByPath(fromObject, ['done']);
|
|
15806
|
-
if (fromDone != null) {
|
|
15807
|
-
setValueByPath(toObject, ['done'], fromDone);
|
|
15808
|
-
}
|
|
15809
|
-
const fromError = getValueByPath(fromObject, ['error']);
|
|
15810
|
-
if (fromError != null) {
|
|
15811
|
-
setValueByPath(toObject, ['error'], fromError);
|
|
15812
|
-
}
|
|
15813
|
-
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
15814
|
-
if (fromResponse != null) {
|
|
15815
|
-
setValueByPath(toObject, ['response'], generateVideosResponseFromVertex(fromResponse));
|
|
15816
|
-
}
|
|
15817
|
-
return toObject;
|
|
15818
|
-
}
|
|
15819
15855
|
|
|
15820
15856
|
/**
|
|
15821
15857
|
* @license
|
|
@@ -15845,17 +15881,64 @@ class Operations extends BaseModule {
|
|
|
15845
15881
|
if (config && 'httpOptions' in config) {
|
|
15846
15882
|
httpOptions = config.httpOptions;
|
|
15847
15883
|
}
|
|
15848
|
-
|
|
15884
|
+
const rawOperation = await this.fetchPredictVideosOperationInternal({
|
|
15885
|
+
operationName: operation.name,
|
|
15886
|
+
resourceName: resourceName,
|
|
15887
|
+
config: { httpOptions: httpOptions },
|
|
15888
|
+
});
|
|
15889
|
+
return operation._fromAPIResponse({
|
|
15890
|
+
apiResponse: rawOperation,
|
|
15891
|
+
isVertexAI: true,
|
|
15892
|
+
});
|
|
15893
|
+
}
|
|
15894
|
+
else {
|
|
15895
|
+
const rawOperation = await this.getVideosOperationInternal({
|
|
15896
|
+
operationName: operation.name,
|
|
15897
|
+
config: config,
|
|
15898
|
+
});
|
|
15899
|
+
return operation._fromAPIResponse({
|
|
15900
|
+
apiResponse: rawOperation,
|
|
15901
|
+
isVertexAI: false,
|
|
15902
|
+
});
|
|
15903
|
+
}
|
|
15904
|
+
}
|
|
15905
|
+
/**
|
|
15906
|
+
* Gets the status of a long-running operation.
|
|
15907
|
+
*
|
|
15908
|
+
* @param parameters The parameters for the get operation request.
|
|
15909
|
+
* @return The updated Operation object, with the latest status or result.
|
|
15910
|
+
*/
|
|
15911
|
+
async get(parameters) {
|
|
15912
|
+
const operation = parameters.operation;
|
|
15913
|
+
const config = parameters.config;
|
|
15914
|
+
if (operation.name === undefined || operation.name === '') {
|
|
15915
|
+
throw new Error('Operation name is required.');
|
|
15916
|
+
}
|
|
15917
|
+
if (this.apiClient.isVertexAI()) {
|
|
15918
|
+
const resourceName = operation.name.split('/operations/')[0];
|
|
15919
|
+
let httpOptions = undefined;
|
|
15920
|
+
if (config && 'httpOptions' in config) {
|
|
15921
|
+
httpOptions = config.httpOptions;
|
|
15922
|
+
}
|
|
15923
|
+
const rawOperation = await this.fetchPredictVideosOperationInternal({
|
|
15849
15924
|
operationName: operation.name,
|
|
15850
15925
|
resourceName: resourceName,
|
|
15851
15926
|
config: { httpOptions: httpOptions },
|
|
15852
15927
|
});
|
|
15928
|
+
return operation._fromAPIResponse({
|
|
15929
|
+
apiResponse: rawOperation,
|
|
15930
|
+
isVertexAI: true,
|
|
15931
|
+
});
|
|
15853
15932
|
}
|
|
15854
15933
|
else {
|
|
15855
|
-
|
|
15934
|
+
const rawOperation = await this.getVideosOperationInternal({
|
|
15856
15935
|
operationName: operation.name,
|
|
15857
15936
|
config: config,
|
|
15858
15937
|
});
|
|
15938
|
+
return operation._fromAPIResponse({
|
|
15939
|
+
apiResponse: rawOperation,
|
|
15940
|
+
isVertexAI: false,
|
|
15941
|
+
});
|
|
15859
15942
|
}
|
|
15860
15943
|
}
|
|
15861
15944
|
async getVideosOperationInternal(params) {
|
|
@@ -15882,10 +15965,7 @@ class Operations extends BaseModule {
|
|
|
15882
15965
|
.then((httpResponse) => {
|
|
15883
15966
|
return httpResponse.json();
|
|
15884
15967
|
});
|
|
15885
|
-
return response
|
|
15886
|
-
const resp = generateVideosOperationFromVertex(apiResponse);
|
|
15887
|
-
return resp;
|
|
15888
|
-
});
|
|
15968
|
+
return response;
|
|
15889
15969
|
}
|
|
15890
15970
|
else {
|
|
15891
15971
|
const body = getOperationParametersToMldev(params);
|
|
@@ -15906,10 +15986,7 @@ class Operations extends BaseModule {
|
|
|
15906
15986
|
.then((httpResponse) => {
|
|
15907
15987
|
return httpResponse.json();
|
|
15908
15988
|
});
|
|
15909
|
-
return response
|
|
15910
|
-
const resp = generateVideosOperationFromMldev(apiResponse);
|
|
15911
|
-
return resp;
|
|
15912
|
-
});
|
|
15989
|
+
return response;
|
|
15913
15990
|
}
|
|
15914
15991
|
}
|
|
15915
15992
|
async fetchPredictVideosOperationInternal(params) {
|
|
@@ -15936,10 +16013,7 @@ class Operations extends BaseModule {
|
|
|
15936
16013
|
.then((httpResponse) => {
|
|
15937
16014
|
return httpResponse.json();
|
|
15938
16015
|
});
|
|
15939
|
-
return response
|
|
15940
|
-
const resp = generateVideosOperationFromVertex(apiResponse);
|
|
15941
|
-
return resp;
|
|
15942
|
-
});
|
|
16016
|
+
return response;
|
|
15943
16017
|
}
|
|
15944
16018
|
else {
|
|
15945
16019
|
throw new Error('This method is only supported by the Vertex AI.');
|
|
@@ -17166,6 +17240,12 @@ function tuningJobFromMldev(fromObject) {
|
|
|
17166
17240
|
}
|
|
17167
17241
|
function listTuningJobsResponseFromMldev(fromObject) {
|
|
17168
17242
|
const toObject = {};
|
|
17243
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
17244
|
+
'sdkHttpResponse',
|
|
17245
|
+
]);
|
|
17246
|
+
if (fromSdkHttpResponse != null) {
|
|
17247
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
17248
|
+
}
|
|
17169
17249
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
17170
17250
|
'nextPageToken',
|
|
17171
17251
|
]);
|
|
@@ -17354,6 +17434,12 @@ function tuningJobFromVertex(fromObject) {
|
|
|
17354
17434
|
}
|
|
17355
17435
|
function listTuningJobsResponseFromVertex(fromObject) {
|
|
17356
17436
|
const toObject = {};
|
|
17437
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
17438
|
+
'sdkHttpResponse',
|
|
17439
|
+
]);
|
|
17440
|
+
if (fromSdkHttpResponse != null) {
|
|
17441
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
17442
|
+
}
|
|
17357
17443
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
17358
17444
|
'nextPageToken',
|
|
17359
17445
|
]);
|
|
@@ -17514,7 +17600,13 @@ class Tunings extends BaseModule {
|
|
|
17514
17600
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
17515
17601
|
})
|
|
17516
17602
|
.then((httpResponse) => {
|
|
17517
|
-
return httpResponse.json()
|
|
17603
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
17604
|
+
const response = jsonResponse;
|
|
17605
|
+
response.sdkHttpResponse = {
|
|
17606
|
+
headers: httpResponse.headers,
|
|
17607
|
+
};
|
|
17608
|
+
return response;
|
|
17609
|
+
});
|
|
17518
17610
|
});
|
|
17519
17611
|
return response.then((apiResponse) => {
|
|
17520
17612
|
const resp = listTuningJobsResponseFromVertex(apiResponse);
|
|
@@ -17540,7 +17632,13 @@ class Tunings extends BaseModule {
|
|
|
17540
17632
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
17541
17633
|
})
|
|
17542
17634
|
.then((httpResponse) => {
|
|
17543
|
-
return httpResponse.json()
|
|
17635
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
17636
|
+
const response = jsonResponse;
|
|
17637
|
+
response.sdkHttpResponse = {
|
|
17638
|
+
headers: httpResponse.headers,
|
|
17639
|
+
};
|
|
17640
|
+
return response;
|
|
17641
|
+
});
|
|
17544
17642
|
});
|
|
17545
17643
|
return response.then((apiResponse) => {
|
|
17546
17644
|
const resp = listTuningJobsResponseFromMldev(apiResponse);
|
|
@@ -17713,5 +17811,5 @@ class GoogleGenAI {
|
|
|
17713
17811
|
}
|
|
17714
17812
|
}
|
|
17715
17813
|
|
|
17716
|
-
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 };
|
|
17814
|
+
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 };
|
|
17717
17815
|
//# sourceMappingURL=index.mjs.map
|