@google/genai 1.14.0 → 1.16.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/README.md +24 -0
- package/dist/genai.d.ts +231 -11
- package/dist/index.cjs +558 -92
- package/dist/index.mjs +558 -93
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.cjs +559 -93
- package/dist/node/index.mjs +559 -94
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/node.d.ts +231 -11
- package/dist/web/index.mjs +558 -93
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +231 -11
- package/package.json +3 -3
package/dist/node/index.cjs
CHANGED
|
@@ -827,6 +827,10 @@ exports.FunctionCallingConfigMode = void 0;
|
|
|
827
827
|
* Model will not predict any function calls. Model behavior is same as when not passing any function declarations.
|
|
828
828
|
*/
|
|
829
829
|
FunctionCallingConfigMode["NONE"] = "NONE";
|
|
830
|
+
/**
|
|
831
|
+
* Model decides to predict either a function call or a natural language response, but will validate function calls with constrained decoding. If "allowed_function_names" are set, the predicted function call will be limited to any one of "allowed_function_names", else the predicted function call will be any one of the provided "function_declarations".
|
|
832
|
+
*/
|
|
833
|
+
FunctionCallingConfigMode["VALIDATED"] = "VALIDATED";
|
|
830
834
|
})(exports.FunctionCallingConfigMode || (exports.FunctionCallingConfigMode = {}));
|
|
831
835
|
/** Enum that controls the safety filter level for objectionable content. */
|
|
832
836
|
exports.SafetyFilterLevel = void 0;
|
|
@@ -925,6 +929,30 @@ exports.EditMode = void 0;
|
|
|
925
929
|
EditMode["EDIT_MODE_BGSWAP"] = "EDIT_MODE_BGSWAP";
|
|
926
930
|
EditMode["EDIT_MODE_PRODUCT_IMAGE"] = "EDIT_MODE_PRODUCT_IMAGE";
|
|
927
931
|
})(exports.EditMode || (exports.EditMode = {}));
|
|
932
|
+
/** Enum that represents the segmentation mode. */
|
|
933
|
+
exports.SegmentMode = void 0;
|
|
934
|
+
(function (SegmentMode) {
|
|
935
|
+
SegmentMode["FOREGROUND"] = "FOREGROUND";
|
|
936
|
+
SegmentMode["BACKGROUND"] = "BACKGROUND";
|
|
937
|
+
SegmentMode["PROMPT"] = "PROMPT";
|
|
938
|
+
SegmentMode["SEMANTIC"] = "SEMANTIC";
|
|
939
|
+
SegmentMode["INTERACTIVE"] = "INTERACTIVE";
|
|
940
|
+
})(exports.SegmentMode || (exports.SegmentMode = {}));
|
|
941
|
+
/** Enum for the reference type of a video generation reference image. */
|
|
942
|
+
exports.VideoGenerationReferenceType = void 0;
|
|
943
|
+
(function (VideoGenerationReferenceType) {
|
|
944
|
+
/**
|
|
945
|
+
* A reference image that provides assets to the generated video,
|
|
946
|
+
such as the scene, an object, a character, etc.
|
|
947
|
+
*/
|
|
948
|
+
VideoGenerationReferenceType["ASSET"] = "ASSET";
|
|
949
|
+
/**
|
|
950
|
+
* A reference image that provides aesthetics including colors,
|
|
951
|
+
lighting, texture, etc., to be used as the style of the generated video,
|
|
952
|
+
such as 'anime', 'photography', 'origami', etc.
|
|
953
|
+
*/
|
|
954
|
+
VideoGenerationReferenceType["STYLE"] = "STYLE";
|
|
955
|
+
})(exports.VideoGenerationReferenceType || (exports.VideoGenerationReferenceType = {}));
|
|
928
956
|
/** Enum that controls the compression quality of the generated videos. */
|
|
929
957
|
exports.VideoCompressionQuality = void 0;
|
|
930
958
|
(function (VideoCompressionQuality) {
|
|
@@ -1571,6 +1599,9 @@ class UpscaleImageResponse {
|
|
|
1571
1599
|
/** The output images response. */
|
|
1572
1600
|
class RecontextImageResponse {
|
|
1573
1601
|
}
|
|
1602
|
+
/** The output images response. */
|
|
1603
|
+
class SegmentImageResponse {
|
|
1604
|
+
}
|
|
1574
1605
|
class ListModelsResponse {
|
|
1575
1606
|
}
|
|
1576
1607
|
class DeleteModelResponse {
|
|
@@ -1584,6 +1615,65 @@ class ComputeTokensResponse {
|
|
|
1584
1615
|
/** Response with generated videos. */
|
|
1585
1616
|
class GenerateVideosResponse {
|
|
1586
1617
|
}
|
|
1618
|
+
/** A video generation operation. */
|
|
1619
|
+
class GenerateVideosOperation {
|
|
1620
|
+
/**
|
|
1621
|
+
* Instantiates an Operation of the same type as the one being called with the fields set from the API response.
|
|
1622
|
+
* @internal
|
|
1623
|
+
*/
|
|
1624
|
+
_fromAPIResponse({ apiResponse, isVertexAI, }) {
|
|
1625
|
+
const operation = new GenerateVideosOperation();
|
|
1626
|
+
operation.name = apiResponse['name'];
|
|
1627
|
+
operation.metadata = apiResponse['metadata'];
|
|
1628
|
+
operation.done = apiResponse['done'];
|
|
1629
|
+
operation.error = apiResponse['error'];
|
|
1630
|
+
if (isVertexAI) {
|
|
1631
|
+
const response = apiResponse['response'];
|
|
1632
|
+
if (response) {
|
|
1633
|
+
const operationResponse = new GenerateVideosResponse();
|
|
1634
|
+
const responseVideos = response['videos'];
|
|
1635
|
+
operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
|
|
1636
|
+
return {
|
|
1637
|
+
video: {
|
|
1638
|
+
uri: generatedVideo['gcsUri'],
|
|
1639
|
+
videoBytes: generatedVideo['bytesBase64Encoded']
|
|
1640
|
+
? tBytes$1(generatedVideo['bytesBase64Encoded'])
|
|
1641
|
+
: undefined,
|
|
1642
|
+
mimeType: generatedVideo['mimeType'],
|
|
1643
|
+
},
|
|
1644
|
+
};
|
|
1645
|
+
});
|
|
1646
|
+
operationResponse.raiMediaFilteredCount = response['raiMediaFilteredCount'];
|
|
1647
|
+
operationResponse.raiMediaFilteredReasons = response['raiMediaFilteredReasons'];
|
|
1648
|
+
operation.response = operationResponse;
|
|
1649
|
+
}
|
|
1650
|
+
}
|
|
1651
|
+
else {
|
|
1652
|
+
const response = apiResponse['response'];
|
|
1653
|
+
if (response) {
|
|
1654
|
+
const operationResponse = new GenerateVideosResponse();
|
|
1655
|
+
const generatedVideoResponse = response['generateVideoResponse'];
|
|
1656
|
+
const responseVideos = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['generatedSamples'];
|
|
1657
|
+
operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
|
|
1658
|
+
const video = generatedVideo['video'];
|
|
1659
|
+
return {
|
|
1660
|
+
video: {
|
|
1661
|
+
uri: video === null || video === void 0 ? void 0 : video['uri'],
|
|
1662
|
+
videoBytes: (video === null || video === void 0 ? void 0 : video['encodedVideo'])
|
|
1663
|
+
? tBytes$1(video === null || video === void 0 ? void 0 : video['encodedVideo'])
|
|
1664
|
+
: undefined,
|
|
1665
|
+
mimeType: generatedVideo['encoding'],
|
|
1666
|
+
},
|
|
1667
|
+
};
|
|
1668
|
+
});
|
|
1669
|
+
operationResponse.raiMediaFilteredCount = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredCount'];
|
|
1670
|
+
operationResponse.raiMediaFilteredReasons = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredReasons'];
|
|
1671
|
+
operation.response = operationResponse;
|
|
1672
|
+
}
|
|
1673
|
+
}
|
|
1674
|
+
return operation;
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1587
1677
|
/** Response for the list tuning jobs method. */
|
|
1588
1678
|
class ListTuningJobsResponse {
|
|
1589
1679
|
}
|
|
@@ -1775,65 +1865,6 @@ class LiveServerMessage {
|
|
|
1775
1865
|
return data.length > 0 ? btoa(data) : undefined;
|
|
1776
1866
|
}
|
|
1777
1867
|
}
|
|
1778
|
-
/** A video generation long-running operation. */
|
|
1779
|
-
class GenerateVideosOperation {
|
|
1780
|
-
/**
|
|
1781
|
-
* Instantiates an Operation of the same type as the one being called with the fields set from the API response.
|
|
1782
|
-
* @internal
|
|
1783
|
-
*/
|
|
1784
|
-
_fromAPIResponse({ apiResponse, isVertexAI, }) {
|
|
1785
|
-
const operation = new GenerateVideosOperation();
|
|
1786
|
-
operation.name = apiResponse['name'];
|
|
1787
|
-
operation.metadata = apiResponse['metadata'];
|
|
1788
|
-
operation.done = apiResponse['done'];
|
|
1789
|
-
operation.error = apiResponse['error'];
|
|
1790
|
-
if (isVertexAI) {
|
|
1791
|
-
const response = apiResponse['response'];
|
|
1792
|
-
if (response) {
|
|
1793
|
-
const operationResponse = new GenerateVideosResponse();
|
|
1794
|
-
const responseVideos = response['videos'];
|
|
1795
|
-
operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
|
|
1796
|
-
return {
|
|
1797
|
-
video: {
|
|
1798
|
-
uri: generatedVideo['gcsUri'],
|
|
1799
|
-
videoBytes: generatedVideo['bytesBase64Encoded']
|
|
1800
|
-
? tBytes$1(generatedVideo['bytesBase64Encoded'])
|
|
1801
|
-
: undefined,
|
|
1802
|
-
mimeType: generatedVideo['mimeType'],
|
|
1803
|
-
},
|
|
1804
|
-
};
|
|
1805
|
-
});
|
|
1806
|
-
operationResponse.raiMediaFilteredCount = response['raiMediaFilteredCount'];
|
|
1807
|
-
operationResponse.raiMediaFilteredReasons = response['raiMediaFilteredReasons'];
|
|
1808
|
-
operation.response = operationResponse;
|
|
1809
|
-
}
|
|
1810
|
-
}
|
|
1811
|
-
else {
|
|
1812
|
-
const response = apiResponse['response'];
|
|
1813
|
-
if (response) {
|
|
1814
|
-
const operationResponse = new GenerateVideosResponse();
|
|
1815
|
-
const generatedVideoResponse = response['generateVideoResponse'];
|
|
1816
|
-
const responseVideos = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['generatedSamples'];
|
|
1817
|
-
operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
|
|
1818
|
-
const video = generatedVideo['video'];
|
|
1819
|
-
return {
|
|
1820
|
-
video: {
|
|
1821
|
-
uri: video === null || video === void 0 ? void 0 : video['uri'],
|
|
1822
|
-
videoBytes: (video === null || video === void 0 ? void 0 : video['encodedVideo'])
|
|
1823
|
-
? tBytes$1(video === null || video === void 0 ? void 0 : video['encodedVideo'])
|
|
1824
|
-
: undefined,
|
|
1825
|
-
mimeType: generatedVideo['encoding'],
|
|
1826
|
-
},
|
|
1827
|
-
};
|
|
1828
|
-
});
|
|
1829
|
-
operationResponse.raiMediaFilteredCount = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredCount'];
|
|
1830
|
-
operationResponse.raiMediaFilteredReasons = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredReasons'];
|
|
1831
|
-
operation.response = operationResponse;
|
|
1832
|
-
}
|
|
1833
|
-
}
|
|
1834
|
-
return operation;
|
|
1835
|
-
}
|
|
1836
|
-
}
|
|
1837
1868
|
/** Client generated response to a `ToolCall` received from the server.
|
|
1838
1869
|
|
|
1839
1870
|
Individual `FunctionResponse` objects are matched to the respective
|
|
@@ -2480,6 +2511,9 @@ function mcpToGeminiTool(mcpTool, config = {}) {
|
|
|
2480
2511
|
description: mcpToolSchema['description'],
|
|
2481
2512
|
parametersJsonSchema: mcpToolSchema['inputSchema'],
|
|
2482
2513
|
};
|
|
2514
|
+
if (mcpToolSchema['outputSchema']) {
|
|
2515
|
+
functionDeclaration['responseJsonSchema'] = mcpToolSchema['outputSchema'];
|
|
2516
|
+
}
|
|
2483
2517
|
if (config.behavior) {
|
|
2484
2518
|
functionDeclaration['behavior'] = config.behavior;
|
|
2485
2519
|
}
|
|
@@ -4309,6 +4343,7 @@ class Batches extends BaseModule {
|
|
|
4309
4343
|
* ```
|
|
4310
4344
|
*/
|
|
4311
4345
|
this.create = async (params) => {
|
|
4346
|
+
var _a, _b;
|
|
4312
4347
|
if (this.apiClient.isVertexAI()) {
|
|
4313
4348
|
const timestamp = Date.now();
|
|
4314
4349
|
const timestampStr = timestamp.toString();
|
|
@@ -4333,6 +4368,55 @@ class Batches extends BaseModule {
|
|
|
4333
4368
|
}
|
|
4334
4369
|
}
|
|
4335
4370
|
}
|
|
4371
|
+
else {
|
|
4372
|
+
if (Array.isArray(params.src) ||
|
|
4373
|
+
(typeof params.src !== 'string' && params.src.inlinedRequests)) {
|
|
4374
|
+
// Move system instruction to httpOptions extraBody.
|
|
4375
|
+
let path = '';
|
|
4376
|
+
let queryParams = {};
|
|
4377
|
+
const body = createBatchJobParametersToMldev(this.apiClient, params);
|
|
4378
|
+
path = formatMap('{model}:batchGenerateContent', body['_url']);
|
|
4379
|
+
queryParams = body['_query'];
|
|
4380
|
+
// Move system instruction to 'request':
|
|
4381
|
+
// {'systemInstruction': system_instruction}
|
|
4382
|
+
const batch = body['batch'];
|
|
4383
|
+
const inputConfig = batch['inputConfig'];
|
|
4384
|
+
const requestsWrapper = inputConfig['requests'];
|
|
4385
|
+
const requests = requestsWrapper['requests'];
|
|
4386
|
+
const newRequests = [];
|
|
4387
|
+
for (const request of requests) {
|
|
4388
|
+
const requestDict = request;
|
|
4389
|
+
if (requestDict['systemInstruction']) {
|
|
4390
|
+
const systemInstructionValue = requestDict['systemInstruction'];
|
|
4391
|
+
delete requestDict['systemInstruction'];
|
|
4392
|
+
const requestContent = requestDict['request'];
|
|
4393
|
+
requestContent['systemInstruction'] = systemInstructionValue;
|
|
4394
|
+
requestDict['request'] = requestContent;
|
|
4395
|
+
}
|
|
4396
|
+
newRequests.push(requestDict);
|
|
4397
|
+
}
|
|
4398
|
+
requestsWrapper['requests'] = newRequests;
|
|
4399
|
+
delete body['config'];
|
|
4400
|
+
delete body['_url'];
|
|
4401
|
+
delete body['_query'];
|
|
4402
|
+
const response = this.apiClient
|
|
4403
|
+
.request({
|
|
4404
|
+
path: path,
|
|
4405
|
+
queryParams: queryParams,
|
|
4406
|
+
body: JSON.stringify(body),
|
|
4407
|
+
httpMethod: 'POST',
|
|
4408
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
4409
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
4410
|
+
})
|
|
4411
|
+
.then((httpResponse) => {
|
|
4412
|
+
return httpResponse.json();
|
|
4413
|
+
});
|
|
4414
|
+
return response.then((apiResponse) => {
|
|
4415
|
+
const resp = batchJobFromMldev(apiResponse);
|
|
4416
|
+
return resp;
|
|
4417
|
+
});
|
|
4418
|
+
}
|
|
4419
|
+
}
|
|
4336
4420
|
return await this.createInternal(params);
|
|
4337
4421
|
};
|
|
4338
4422
|
/**
|
|
@@ -5677,8 +5761,14 @@ function cachedContentFromMldev(fromObject) {
|
|
|
5677
5761
|
}
|
|
5678
5762
|
return toObject;
|
|
5679
5763
|
}
|
|
5680
|
-
function deleteCachedContentResponseFromMldev() {
|
|
5764
|
+
function deleteCachedContentResponseFromMldev(fromObject) {
|
|
5681
5765
|
const toObject = {};
|
|
5766
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
5767
|
+
'sdkHttpResponse',
|
|
5768
|
+
]);
|
|
5769
|
+
if (fromSdkHttpResponse != null) {
|
|
5770
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
5771
|
+
}
|
|
5682
5772
|
return toObject;
|
|
5683
5773
|
}
|
|
5684
5774
|
function listCachedContentsResponseFromMldev(fromObject) {
|
|
@@ -5743,8 +5833,14 @@ function cachedContentFromVertex(fromObject) {
|
|
|
5743
5833
|
}
|
|
5744
5834
|
return toObject;
|
|
5745
5835
|
}
|
|
5746
|
-
function deleteCachedContentResponseFromVertex() {
|
|
5836
|
+
function deleteCachedContentResponseFromVertex(fromObject) {
|
|
5747
5837
|
const toObject = {};
|
|
5838
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
5839
|
+
'sdkHttpResponse',
|
|
5840
|
+
]);
|
|
5841
|
+
if (fromSdkHttpResponse != null) {
|
|
5842
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
5843
|
+
}
|
|
5748
5844
|
return toObject;
|
|
5749
5845
|
}
|
|
5750
5846
|
function listCachedContentsResponseFromVertex(fromObject) {
|
|
@@ -5981,10 +6077,16 @@ class Caches extends BaseModule {
|
|
|
5981
6077
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
5982
6078
|
})
|
|
5983
6079
|
.then((httpResponse) => {
|
|
5984
|
-
return httpResponse.json()
|
|
6080
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
6081
|
+
const response = jsonResponse;
|
|
6082
|
+
response.sdkHttpResponse = {
|
|
6083
|
+
headers: httpResponse.headers,
|
|
6084
|
+
};
|
|
6085
|
+
return response;
|
|
6086
|
+
});
|
|
5985
6087
|
});
|
|
5986
|
-
return response.then(() => {
|
|
5987
|
-
const resp = deleteCachedContentResponseFromVertex();
|
|
6088
|
+
return response.then((apiResponse) => {
|
|
6089
|
+
const resp = deleteCachedContentResponseFromVertex(apiResponse);
|
|
5988
6090
|
const typedResp = new DeleteCachedContentResponse();
|
|
5989
6091
|
Object.assign(typedResp, resp);
|
|
5990
6092
|
return typedResp;
|
|
@@ -6007,10 +6109,16 @@ class Caches extends BaseModule {
|
|
|
6007
6109
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
6008
6110
|
})
|
|
6009
6111
|
.then((httpResponse) => {
|
|
6010
|
-
return httpResponse.json()
|
|
6112
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
6113
|
+
const response = jsonResponse;
|
|
6114
|
+
response.sdkHttpResponse = {
|
|
6115
|
+
headers: httpResponse.headers,
|
|
6116
|
+
};
|
|
6117
|
+
return response;
|
|
6118
|
+
});
|
|
6011
6119
|
});
|
|
6012
|
-
return response.then(() => {
|
|
6013
|
-
const resp = deleteCachedContentResponseFromMldev();
|
|
6120
|
+
return response.then((apiResponse) => {
|
|
6121
|
+
const resp = deleteCachedContentResponseFromMldev(apiResponse);
|
|
6014
6122
|
const typedResp = new DeleteCachedContentResponse();
|
|
6015
6123
|
Object.assign(typedResp, resp);
|
|
6016
6124
|
return typedResp;
|
|
@@ -6243,9 +6351,6 @@ function isValidContent(content) {
|
|
|
6243
6351
|
if (part === undefined || Object.keys(part).length === 0) {
|
|
6244
6352
|
return false;
|
|
6245
6353
|
}
|
|
6246
|
-
if (!part.thought && part.text !== undefined && part.text === '') {
|
|
6247
|
-
return false;
|
|
6248
|
-
}
|
|
6249
6354
|
}
|
|
6250
6355
|
return true;
|
|
6251
6356
|
}
|
|
@@ -6817,8 +6922,14 @@ function createFileResponseFromMldev(fromObject) {
|
|
|
6817
6922
|
}
|
|
6818
6923
|
return toObject;
|
|
6819
6924
|
}
|
|
6820
|
-
function deleteFileResponseFromMldev() {
|
|
6925
|
+
function deleteFileResponseFromMldev(fromObject) {
|
|
6821
6926
|
const toObject = {};
|
|
6927
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
6928
|
+
'sdkHttpResponse',
|
|
6929
|
+
]);
|
|
6930
|
+
if (fromSdkHttpResponse != null) {
|
|
6931
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
6932
|
+
}
|
|
6822
6933
|
return toObject;
|
|
6823
6934
|
}
|
|
6824
6935
|
|
|
@@ -7087,10 +7198,16 @@ class Files extends BaseModule {
|
|
|
7087
7198
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
7088
7199
|
})
|
|
7089
7200
|
.then((httpResponse) => {
|
|
7090
|
-
return httpResponse.json()
|
|
7201
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
7202
|
+
const response = jsonResponse;
|
|
7203
|
+
response.sdkHttpResponse = {
|
|
7204
|
+
headers: httpResponse.headers,
|
|
7205
|
+
};
|
|
7206
|
+
return response;
|
|
7207
|
+
});
|
|
7091
7208
|
});
|
|
7092
|
-
return response.then(() => {
|
|
7093
|
-
const resp = deleteFileResponseFromMldev();
|
|
7209
|
+
return response.then((apiResponse) => {
|
|
7210
|
+
const resp = deleteFileResponseFromMldev(apiResponse);
|
|
7094
7211
|
const typedResp = new DeleteFileResponse();
|
|
7095
7212
|
Object.assign(typedResp, resp);
|
|
7096
7213
|
return typedResp;
|
|
@@ -10393,6 +10510,21 @@ function imageToMldev(fromObject) {
|
|
|
10393
10510
|
}
|
|
10394
10511
|
return toObject;
|
|
10395
10512
|
}
|
|
10513
|
+
function generateVideosSourceToMldev(fromObject, parentObject) {
|
|
10514
|
+
const toObject = {};
|
|
10515
|
+
const fromPrompt = getValueByPath(fromObject, ['prompt']);
|
|
10516
|
+
if (parentObject !== undefined && fromPrompt != null) {
|
|
10517
|
+
setValueByPath(parentObject, ['instances[0]', 'prompt'], fromPrompt);
|
|
10518
|
+
}
|
|
10519
|
+
const fromImage = getValueByPath(fromObject, ['image']);
|
|
10520
|
+
if (parentObject !== undefined && fromImage != null) {
|
|
10521
|
+
setValueByPath(parentObject, ['instances[0]', 'image'], imageToMldev(fromImage));
|
|
10522
|
+
}
|
|
10523
|
+
if (getValueByPath(fromObject, ['video']) !== undefined) {
|
|
10524
|
+
throw new Error('video parameter is not supported in Gemini API.');
|
|
10525
|
+
}
|
|
10526
|
+
return toObject;
|
|
10527
|
+
}
|
|
10396
10528
|
function generateVideosConfigToMldev(fromObject, parentObject) {
|
|
10397
10529
|
const toObject = {};
|
|
10398
10530
|
const fromNumberOfVideos = getValueByPath(fromObject, [
|
|
@@ -10450,6 +10582,9 @@ function generateVideosConfigToMldev(fromObject, parentObject) {
|
|
|
10450
10582
|
if (getValueByPath(fromObject, ['lastFrame']) !== undefined) {
|
|
10451
10583
|
throw new Error('lastFrame parameter is not supported in Gemini API.');
|
|
10452
10584
|
}
|
|
10585
|
+
if (getValueByPath(fromObject, ['referenceImages']) !== undefined) {
|
|
10586
|
+
throw new Error('referenceImages parameter is not supported in Gemini API.');
|
|
10587
|
+
}
|
|
10453
10588
|
if (getValueByPath(fromObject, ['compressionQuality']) !== undefined) {
|
|
10454
10589
|
throw new Error('compressionQuality parameter is not supported in Gemini API.');
|
|
10455
10590
|
}
|
|
@@ -10472,6 +10607,10 @@ function generateVideosParametersToMldev(apiClient, fromObject) {
|
|
|
10472
10607
|
if (getValueByPath(fromObject, ['video']) !== undefined) {
|
|
10473
10608
|
throw new Error('video parameter is not supported in Gemini API.');
|
|
10474
10609
|
}
|
|
10610
|
+
const fromSource = getValueByPath(fromObject, ['source']);
|
|
10611
|
+
if (fromSource != null) {
|
|
10612
|
+
setValueByPath(toObject, ['config'], generateVideosSourceToMldev(fromSource, toObject));
|
|
10613
|
+
}
|
|
10475
10614
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
10476
10615
|
if (fromConfig != null) {
|
|
10477
10616
|
setValueByPath(toObject, ['config'], generateVideosConfigToMldev(fromConfig, toObject));
|
|
@@ -11596,6 +11735,10 @@ function editImageParametersInternalToVertex(apiClient, fromObject) {
|
|
|
11596
11735
|
}
|
|
11597
11736
|
function upscaleImageAPIConfigInternalToVertex(fromObject, parentObject) {
|
|
11598
11737
|
const toObject = {};
|
|
11738
|
+
const fromOutputGcsUri = getValueByPath(fromObject, ['outputGcsUri']);
|
|
11739
|
+
if (parentObject !== undefined && fromOutputGcsUri != null) {
|
|
11740
|
+
setValueByPath(parentObject, ['parameters', 'storageUri'], fromOutputGcsUri);
|
|
11741
|
+
}
|
|
11599
11742
|
const fromIncludeRaiReason = getValueByPath(fromObject, [
|
|
11600
11743
|
'includeRaiReason',
|
|
11601
11744
|
]);
|
|
@@ -11724,6 +11867,10 @@ function recontextImageConfigToVertex(fromObject, parentObject) {
|
|
|
11724
11867
|
if (parentObject !== undefined && fromPersonGeneration != null) {
|
|
11725
11868
|
setValueByPath(parentObject, ['parameters', 'personGeneration'], fromPersonGeneration);
|
|
11726
11869
|
}
|
|
11870
|
+
const fromAddWatermark = getValueByPath(fromObject, ['addWatermark']);
|
|
11871
|
+
if (parentObject !== undefined && fromAddWatermark != null) {
|
|
11872
|
+
setValueByPath(parentObject, ['parameters', 'addWatermark'], fromAddWatermark);
|
|
11873
|
+
}
|
|
11727
11874
|
const fromOutputMimeType = getValueByPath(fromObject, [
|
|
11728
11875
|
'outputMimeType',
|
|
11729
11876
|
]);
|
|
@@ -11760,6 +11907,78 @@ function recontextImageParametersToVertex(apiClient, fromObject) {
|
|
|
11760
11907
|
}
|
|
11761
11908
|
return toObject;
|
|
11762
11909
|
}
|
|
11910
|
+
function scribbleImageToVertex(fromObject) {
|
|
11911
|
+
const toObject = {};
|
|
11912
|
+
const fromImage = getValueByPath(fromObject, ['image']);
|
|
11913
|
+
if (fromImage != null) {
|
|
11914
|
+
setValueByPath(toObject, ['image'], imageToVertex(fromImage));
|
|
11915
|
+
}
|
|
11916
|
+
return toObject;
|
|
11917
|
+
}
|
|
11918
|
+
function segmentImageSourceToVertex(fromObject, parentObject) {
|
|
11919
|
+
const toObject = {};
|
|
11920
|
+
const fromPrompt = getValueByPath(fromObject, ['prompt']);
|
|
11921
|
+
if (parentObject !== undefined && fromPrompt != null) {
|
|
11922
|
+
setValueByPath(parentObject, ['instances[0]', 'prompt'], fromPrompt);
|
|
11923
|
+
}
|
|
11924
|
+
const fromImage = getValueByPath(fromObject, ['image']);
|
|
11925
|
+
if (parentObject !== undefined && fromImage != null) {
|
|
11926
|
+
setValueByPath(parentObject, ['instances[0]', 'image'], imageToVertex(fromImage));
|
|
11927
|
+
}
|
|
11928
|
+
const fromScribbleImage = getValueByPath(fromObject, [
|
|
11929
|
+
'scribbleImage',
|
|
11930
|
+
]);
|
|
11931
|
+
if (parentObject !== undefined && fromScribbleImage != null) {
|
|
11932
|
+
setValueByPath(parentObject, ['instances[0]', 'scribble'], scribbleImageToVertex(fromScribbleImage));
|
|
11933
|
+
}
|
|
11934
|
+
return toObject;
|
|
11935
|
+
}
|
|
11936
|
+
function segmentImageConfigToVertex(fromObject, parentObject) {
|
|
11937
|
+
const toObject = {};
|
|
11938
|
+
const fromMode = getValueByPath(fromObject, ['mode']);
|
|
11939
|
+
if (parentObject !== undefined && fromMode != null) {
|
|
11940
|
+
setValueByPath(parentObject, ['parameters', 'mode'], fromMode);
|
|
11941
|
+
}
|
|
11942
|
+
const fromMaxPredictions = getValueByPath(fromObject, [
|
|
11943
|
+
'maxPredictions',
|
|
11944
|
+
]);
|
|
11945
|
+
if (parentObject !== undefined && fromMaxPredictions != null) {
|
|
11946
|
+
setValueByPath(parentObject, ['parameters', 'maxPredictions'], fromMaxPredictions);
|
|
11947
|
+
}
|
|
11948
|
+
const fromConfidenceThreshold = getValueByPath(fromObject, [
|
|
11949
|
+
'confidenceThreshold',
|
|
11950
|
+
]);
|
|
11951
|
+
if (parentObject !== undefined && fromConfidenceThreshold != null) {
|
|
11952
|
+
setValueByPath(parentObject, ['parameters', 'confidenceThreshold'], fromConfidenceThreshold);
|
|
11953
|
+
}
|
|
11954
|
+
const fromMaskDilation = getValueByPath(fromObject, ['maskDilation']);
|
|
11955
|
+
if (parentObject !== undefined && fromMaskDilation != null) {
|
|
11956
|
+
setValueByPath(parentObject, ['parameters', 'maskDilation'], fromMaskDilation);
|
|
11957
|
+
}
|
|
11958
|
+
const fromBinaryColorThreshold = getValueByPath(fromObject, [
|
|
11959
|
+
'binaryColorThreshold',
|
|
11960
|
+
]);
|
|
11961
|
+
if (parentObject !== undefined && fromBinaryColorThreshold != null) {
|
|
11962
|
+
setValueByPath(parentObject, ['parameters', 'binaryColorThreshold'], fromBinaryColorThreshold);
|
|
11963
|
+
}
|
|
11964
|
+
return toObject;
|
|
11965
|
+
}
|
|
11966
|
+
function segmentImageParametersToVertex(apiClient, fromObject) {
|
|
11967
|
+
const toObject = {};
|
|
11968
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
11969
|
+
if (fromModel != null) {
|
|
11970
|
+
setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
|
|
11971
|
+
}
|
|
11972
|
+
const fromSource = getValueByPath(fromObject, ['source']);
|
|
11973
|
+
if (fromSource != null) {
|
|
11974
|
+
setValueByPath(toObject, ['config'], segmentImageSourceToVertex(fromSource, toObject));
|
|
11975
|
+
}
|
|
11976
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
11977
|
+
if (fromConfig != null) {
|
|
11978
|
+
setValueByPath(toObject, ['config'], segmentImageConfigToVertex(fromConfig, toObject));
|
|
11979
|
+
}
|
|
11980
|
+
return toObject;
|
|
11981
|
+
}
|
|
11763
11982
|
function getModelParametersToVertex(apiClient, fromObject) {
|
|
11764
11983
|
const toObject = {};
|
|
11765
11984
|
const fromModel = getValueByPath(fromObject, ['model']);
|
|
@@ -11928,6 +12147,36 @@ function videoToVertex(fromObject) {
|
|
|
11928
12147
|
}
|
|
11929
12148
|
return toObject;
|
|
11930
12149
|
}
|
|
12150
|
+
function generateVideosSourceToVertex(fromObject, parentObject) {
|
|
12151
|
+
const toObject = {};
|
|
12152
|
+
const fromPrompt = getValueByPath(fromObject, ['prompt']);
|
|
12153
|
+
if (parentObject !== undefined && fromPrompt != null) {
|
|
12154
|
+
setValueByPath(parentObject, ['instances[0]', 'prompt'], fromPrompt);
|
|
12155
|
+
}
|
|
12156
|
+
const fromImage = getValueByPath(fromObject, ['image']);
|
|
12157
|
+
if (parentObject !== undefined && fromImage != null) {
|
|
12158
|
+
setValueByPath(parentObject, ['instances[0]', 'image'], imageToVertex(fromImage));
|
|
12159
|
+
}
|
|
12160
|
+
const fromVideo = getValueByPath(fromObject, ['video']);
|
|
12161
|
+
if (parentObject !== undefined && fromVideo != null) {
|
|
12162
|
+
setValueByPath(parentObject, ['instances[0]', 'video'], videoToVertex(fromVideo));
|
|
12163
|
+
}
|
|
12164
|
+
return toObject;
|
|
12165
|
+
}
|
|
12166
|
+
function videoGenerationReferenceImageToVertex(fromObject) {
|
|
12167
|
+
const toObject = {};
|
|
12168
|
+
const fromImage = getValueByPath(fromObject, ['image']);
|
|
12169
|
+
if (fromImage != null) {
|
|
12170
|
+
setValueByPath(toObject, ['image'], imageToVertex(fromImage));
|
|
12171
|
+
}
|
|
12172
|
+
const fromReferenceType = getValueByPath(fromObject, [
|
|
12173
|
+
'referenceType',
|
|
12174
|
+
]);
|
|
12175
|
+
if (fromReferenceType != null) {
|
|
12176
|
+
setValueByPath(toObject, ['referenceType'], fromReferenceType);
|
|
12177
|
+
}
|
|
12178
|
+
return toObject;
|
|
12179
|
+
}
|
|
11931
12180
|
function generateVideosConfigToVertex(fromObject, parentObject) {
|
|
11932
12181
|
const toObject = {};
|
|
11933
12182
|
const fromNumberOfVideos = getValueByPath(fromObject, [
|
|
@@ -11994,6 +12243,18 @@ function generateVideosConfigToVertex(fromObject, parentObject) {
|
|
|
11994
12243
|
if (parentObject !== undefined && fromLastFrame != null) {
|
|
11995
12244
|
setValueByPath(parentObject, ['instances[0]', 'lastFrame'], imageToVertex(fromLastFrame));
|
|
11996
12245
|
}
|
|
12246
|
+
const fromReferenceImages = getValueByPath(fromObject, [
|
|
12247
|
+
'referenceImages',
|
|
12248
|
+
]);
|
|
12249
|
+
if (parentObject !== undefined && fromReferenceImages != null) {
|
|
12250
|
+
let transformedList = fromReferenceImages;
|
|
12251
|
+
if (Array.isArray(transformedList)) {
|
|
12252
|
+
transformedList = transformedList.map((item) => {
|
|
12253
|
+
return videoGenerationReferenceImageToVertex(item);
|
|
12254
|
+
});
|
|
12255
|
+
}
|
|
12256
|
+
setValueByPath(parentObject, ['instances[0]', 'referenceImages'], transformedList);
|
|
12257
|
+
}
|
|
11997
12258
|
const fromCompressionQuality = getValueByPath(fromObject, [
|
|
11998
12259
|
'compressionQuality',
|
|
11999
12260
|
]);
|
|
@@ -12020,6 +12281,10 @@ function generateVideosParametersToVertex(apiClient, fromObject) {
|
|
|
12020
12281
|
if (fromVideo != null) {
|
|
12021
12282
|
setValueByPath(toObject, ['instances[0]', 'video'], videoToVertex(fromVideo));
|
|
12022
12283
|
}
|
|
12284
|
+
const fromSource = getValueByPath(fromObject, ['source']);
|
|
12285
|
+
if (fromSource != null) {
|
|
12286
|
+
setValueByPath(toObject, ['config'], generateVideosSourceToVertex(fromSource, toObject));
|
|
12287
|
+
}
|
|
12023
12288
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
12024
12289
|
if (fromConfig != null) {
|
|
12025
12290
|
setValueByPath(toObject, ['config'], generateVideosConfigToVertex(fromConfig, toObject));
|
|
@@ -12470,8 +12735,14 @@ function listModelsResponseFromMldev(fromObject) {
|
|
|
12470
12735
|
}
|
|
12471
12736
|
return toObject;
|
|
12472
12737
|
}
|
|
12473
|
-
function deleteModelResponseFromMldev() {
|
|
12738
|
+
function deleteModelResponseFromMldev(fromObject) {
|
|
12474
12739
|
const toObject = {};
|
|
12740
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
12741
|
+
'sdkHttpResponse',
|
|
12742
|
+
]);
|
|
12743
|
+
if (fromSdkHttpResponse != null) {
|
|
12744
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
12745
|
+
}
|
|
12475
12746
|
return toObject;
|
|
12476
12747
|
}
|
|
12477
12748
|
function countTokensResponseFromMldev(fromObject) {
|
|
@@ -13043,6 +13314,50 @@ function recontextImageResponseFromVertex(fromObject) {
|
|
|
13043
13314
|
}
|
|
13044
13315
|
return toObject;
|
|
13045
13316
|
}
|
|
13317
|
+
function entityLabelFromVertex(fromObject) {
|
|
13318
|
+
const toObject = {};
|
|
13319
|
+
const fromLabel = getValueByPath(fromObject, ['label']);
|
|
13320
|
+
if (fromLabel != null) {
|
|
13321
|
+
setValueByPath(toObject, ['label'], fromLabel);
|
|
13322
|
+
}
|
|
13323
|
+
const fromScore = getValueByPath(fromObject, ['score']);
|
|
13324
|
+
if (fromScore != null) {
|
|
13325
|
+
setValueByPath(toObject, ['score'], fromScore);
|
|
13326
|
+
}
|
|
13327
|
+
return toObject;
|
|
13328
|
+
}
|
|
13329
|
+
function generatedImageMaskFromVertex(fromObject) {
|
|
13330
|
+
const toObject = {};
|
|
13331
|
+
const fromMask = getValueByPath(fromObject, ['_self']);
|
|
13332
|
+
if (fromMask != null) {
|
|
13333
|
+
setValueByPath(toObject, ['mask'], imageFromVertex(fromMask));
|
|
13334
|
+
}
|
|
13335
|
+
const fromLabels = getValueByPath(fromObject, ['labels']);
|
|
13336
|
+
if (fromLabels != null) {
|
|
13337
|
+
let transformedList = fromLabels;
|
|
13338
|
+
if (Array.isArray(transformedList)) {
|
|
13339
|
+
transformedList = transformedList.map((item) => {
|
|
13340
|
+
return entityLabelFromVertex(item);
|
|
13341
|
+
});
|
|
13342
|
+
}
|
|
13343
|
+
setValueByPath(toObject, ['labels'], transformedList);
|
|
13344
|
+
}
|
|
13345
|
+
return toObject;
|
|
13346
|
+
}
|
|
13347
|
+
function segmentImageResponseFromVertex(fromObject) {
|
|
13348
|
+
const toObject = {};
|
|
13349
|
+
const fromGeneratedMasks = getValueByPath(fromObject, ['predictions']);
|
|
13350
|
+
if (fromGeneratedMasks != null) {
|
|
13351
|
+
let transformedList = fromGeneratedMasks;
|
|
13352
|
+
if (Array.isArray(transformedList)) {
|
|
13353
|
+
transformedList = transformedList.map((item) => {
|
|
13354
|
+
return generatedImageMaskFromVertex(item);
|
|
13355
|
+
});
|
|
13356
|
+
}
|
|
13357
|
+
setValueByPath(toObject, ['generatedMasks'], transformedList);
|
|
13358
|
+
}
|
|
13359
|
+
return toObject;
|
|
13360
|
+
}
|
|
13046
13361
|
function endpointFromVertex(fromObject) {
|
|
13047
13362
|
const toObject = {};
|
|
13048
13363
|
const fromName = getValueByPath(fromObject, ['endpoint']);
|
|
@@ -13172,8 +13487,14 @@ function listModelsResponseFromVertex(fromObject) {
|
|
|
13172
13487
|
}
|
|
13173
13488
|
return toObject;
|
|
13174
13489
|
}
|
|
13175
|
-
function deleteModelResponseFromVertex() {
|
|
13490
|
+
function deleteModelResponseFromVertex(fromObject) {
|
|
13176
13491
|
const toObject = {};
|
|
13492
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
13493
|
+
'sdkHttpResponse',
|
|
13494
|
+
]);
|
|
13495
|
+
if (fromSdkHttpResponse != null) {
|
|
13496
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
13497
|
+
}
|
|
13177
13498
|
return toObject;
|
|
13178
13499
|
}
|
|
13179
13500
|
function countTokensResponseFromVertex(fromObject) {
|
|
@@ -13290,7 +13611,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
13290
13611
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
13291
13612
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
13292
13613
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
13293
|
-
const SDK_VERSION = '1.
|
|
13614
|
+
const SDK_VERSION = '1.16.0'; // x-release-please-version
|
|
13294
13615
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
13295
13616
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
13296
13617
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -15062,7 +15383,9 @@ class Models extends BaseModule {
|
|
|
15062
15383
|
* ```ts
|
|
15063
15384
|
* const operation = await ai.models.generateVideos({
|
|
15064
15385
|
* model: 'veo-2.0-generate-001',
|
|
15065
|
-
*
|
|
15386
|
+
* source: {
|
|
15387
|
+
* prompt: 'A neon hologram of a cat driving at top speed',
|
|
15388
|
+
* },
|
|
15066
15389
|
* config: {
|
|
15067
15390
|
* numberOfVideos: 1
|
|
15068
15391
|
* });
|
|
@@ -15076,6 +15399,9 @@ class Models extends BaseModule {
|
|
|
15076
15399
|
* ```
|
|
15077
15400
|
*/
|
|
15078
15401
|
this.generateVideos = async (params) => {
|
|
15402
|
+
if ((params.prompt || params.image || params.video) && params.source) {
|
|
15403
|
+
throw new Error('Source and prompt/image/video are mutually exclusive. Please only use source.');
|
|
15404
|
+
}
|
|
15079
15405
|
return await this.generateVideosInternal(params);
|
|
15080
15406
|
};
|
|
15081
15407
|
}
|
|
@@ -15733,6 +16059,61 @@ class Models extends BaseModule {
|
|
|
15733
16059
|
throw new Error('This method is only supported by the Vertex AI.');
|
|
15734
16060
|
}
|
|
15735
16061
|
}
|
|
16062
|
+
/**
|
|
16063
|
+
* Segments an image, creating a mask of a specified area.
|
|
16064
|
+
*
|
|
16065
|
+
* @param params - The parameters for segmenting an image.
|
|
16066
|
+
* @return The response from the API.
|
|
16067
|
+
*
|
|
16068
|
+
* @example
|
|
16069
|
+
* ```ts
|
|
16070
|
+
* const response = await ai.models.segmentImage({
|
|
16071
|
+
* model: 'image-segmentation-001',
|
|
16072
|
+
* source: {
|
|
16073
|
+
* image: image,
|
|
16074
|
+
* },
|
|
16075
|
+
* config: {
|
|
16076
|
+
* mode: 'foreground',
|
|
16077
|
+
* },
|
|
16078
|
+
* });
|
|
16079
|
+
* console.log(response?.generatedMasks?.[0]?.mask?.imageBytes);
|
|
16080
|
+
* ```
|
|
16081
|
+
*/
|
|
16082
|
+
async segmentImage(params) {
|
|
16083
|
+
var _a, _b;
|
|
16084
|
+
let response;
|
|
16085
|
+
let path = '';
|
|
16086
|
+
let queryParams = {};
|
|
16087
|
+
if (this.apiClient.isVertexAI()) {
|
|
16088
|
+
const body = segmentImageParametersToVertex(this.apiClient, params);
|
|
16089
|
+
path = formatMap('{model}:predict', body['_url']);
|
|
16090
|
+
queryParams = body['_query'];
|
|
16091
|
+
delete body['config'];
|
|
16092
|
+
delete body['_url'];
|
|
16093
|
+
delete body['_query'];
|
|
16094
|
+
response = this.apiClient
|
|
16095
|
+
.request({
|
|
16096
|
+
path: path,
|
|
16097
|
+
queryParams: queryParams,
|
|
16098
|
+
body: JSON.stringify(body),
|
|
16099
|
+
httpMethod: 'POST',
|
|
16100
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
16101
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
16102
|
+
})
|
|
16103
|
+
.then((httpResponse) => {
|
|
16104
|
+
return httpResponse.json();
|
|
16105
|
+
});
|
|
16106
|
+
return response.then((apiResponse) => {
|
|
16107
|
+
const resp = segmentImageResponseFromVertex(apiResponse);
|
|
16108
|
+
const typedResp = new SegmentImageResponse();
|
|
16109
|
+
Object.assign(typedResp, resp);
|
|
16110
|
+
return typedResp;
|
|
16111
|
+
});
|
|
16112
|
+
}
|
|
16113
|
+
else {
|
|
16114
|
+
throw new Error('This method is only supported by the Vertex AI.');
|
|
16115
|
+
}
|
|
16116
|
+
}
|
|
15736
16117
|
/**
|
|
15737
16118
|
* Fetches information about a model by name.
|
|
15738
16119
|
*
|
|
@@ -15969,10 +16350,16 @@ class Models extends BaseModule {
|
|
|
15969
16350
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
15970
16351
|
})
|
|
15971
16352
|
.then((httpResponse) => {
|
|
15972
|
-
return httpResponse.json()
|
|
16353
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
16354
|
+
const response = jsonResponse;
|
|
16355
|
+
response.sdkHttpResponse = {
|
|
16356
|
+
headers: httpResponse.headers,
|
|
16357
|
+
};
|
|
16358
|
+
return response;
|
|
16359
|
+
});
|
|
15973
16360
|
});
|
|
15974
|
-
return response.then(() => {
|
|
15975
|
-
const resp = deleteModelResponseFromVertex();
|
|
16361
|
+
return response.then((apiResponse) => {
|
|
16362
|
+
const resp = deleteModelResponseFromVertex(apiResponse);
|
|
15976
16363
|
const typedResp = new DeleteModelResponse();
|
|
15977
16364
|
Object.assign(typedResp, resp);
|
|
15978
16365
|
return typedResp;
|
|
@@ -15995,10 +16382,16 @@ class Models extends BaseModule {
|
|
|
15995
16382
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
15996
16383
|
})
|
|
15997
16384
|
.then((httpResponse) => {
|
|
15998
|
-
return httpResponse.json()
|
|
16385
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
16386
|
+
const response = jsonResponse;
|
|
16387
|
+
response.sdkHttpResponse = {
|
|
16388
|
+
headers: httpResponse.headers,
|
|
16389
|
+
};
|
|
16390
|
+
return response;
|
|
16391
|
+
});
|
|
15999
16392
|
});
|
|
16000
|
-
return response.then(() => {
|
|
16001
|
-
const resp = deleteModelResponseFromMldev();
|
|
16393
|
+
return response.then((apiResponse) => {
|
|
16394
|
+
const resp = deleteModelResponseFromMldev(apiResponse);
|
|
16002
16395
|
const typedResp = new DeleteModelResponse();
|
|
16003
16396
|
Object.assign(typedResp, resp);
|
|
16004
16397
|
return typedResp;
|
|
@@ -16253,13 +16646,17 @@ function getOperationParametersToMldev(fromObject) {
|
|
|
16253
16646
|
}
|
|
16254
16647
|
return toObject;
|
|
16255
16648
|
}
|
|
16256
|
-
function
|
|
16649
|
+
function fetchPredictOperationParametersToVertex(fromObject) {
|
|
16257
16650
|
const toObject = {};
|
|
16258
16651
|
const fromOperationName = getValueByPath(fromObject, [
|
|
16259
16652
|
'operationName',
|
|
16260
16653
|
]);
|
|
16261
16654
|
if (fromOperationName != null) {
|
|
16262
|
-
setValueByPath(toObject, ['
|
|
16655
|
+
setValueByPath(toObject, ['operationName'], fromOperationName);
|
|
16656
|
+
}
|
|
16657
|
+
const fromResourceName = getValueByPath(fromObject, ['resourceName']);
|
|
16658
|
+
if (fromResourceName != null) {
|
|
16659
|
+
setValueByPath(toObject, ['_url', 'resourceName'], fromResourceName);
|
|
16263
16660
|
}
|
|
16264
16661
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
16265
16662
|
if (fromConfig != null) {
|
|
@@ -16267,17 +16664,13 @@ function getOperationParametersToVertex(fromObject) {
|
|
|
16267
16664
|
}
|
|
16268
16665
|
return toObject;
|
|
16269
16666
|
}
|
|
16270
|
-
function
|
|
16667
|
+
function getOperationParametersToVertex(fromObject) {
|
|
16271
16668
|
const toObject = {};
|
|
16272
16669
|
const fromOperationName = getValueByPath(fromObject, [
|
|
16273
16670
|
'operationName',
|
|
16274
16671
|
]);
|
|
16275
16672
|
if (fromOperationName != null) {
|
|
16276
|
-
setValueByPath(toObject, ['operationName'], fromOperationName);
|
|
16277
|
-
}
|
|
16278
|
-
const fromResourceName = getValueByPath(fromObject, ['resourceName']);
|
|
16279
|
-
if (fromResourceName != null) {
|
|
16280
|
-
setValueByPath(toObject, ['_url', 'resourceName'], fromResourceName);
|
|
16673
|
+
setValueByPath(toObject, ['_url', 'operationName'], fromOperationName);
|
|
16281
16674
|
}
|
|
16282
16675
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
16283
16676
|
if (fromConfig != null) {
|
|
@@ -17538,6 +17931,18 @@ function listTuningJobsParametersToMldev(fromObject) {
|
|
|
17538
17931
|
}
|
|
17539
17932
|
return toObject;
|
|
17540
17933
|
}
|
|
17934
|
+
function cancelTuningJobParametersToMldev(fromObject) {
|
|
17935
|
+
const toObject = {};
|
|
17936
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
17937
|
+
if (fromName != null) {
|
|
17938
|
+
setValueByPath(toObject, ['_url', 'name'], fromName);
|
|
17939
|
+
}
|
|
17940
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
17941
|
+
if (fromConfig != null) {
|
|
17942
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
17943
|
+
}
|
|
17944
|
+
return toObject;
|
|
17945
|
+
}
|
|
17541
17946
|
function tuningExampleToMldev(fromObject) {
|
|
17542
17947
|
const toObject = {};
|
|
17543
17948
|
const fromTextInput = getValueByPath(fromObject, ['textInput']);
|
|
@@ -17675,6 +18080,18 @@ function listTuningJobsParametersToVertex(fromObject) {
|
|
|
17675
18080
|
}
|
|
17676
18081
|
return toObject;
|
|
17677
18082
|
}
|
|
18083
|
+
function cancelTuningJobParametersToVertex(fromObject) {
|
|
18084
|
+
const toObject = {};
|
|
18085
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
18086
|
+
if (fromName != null) {
|
|
18087
|
+
setValueByPath(toObject, ['_url', 'name'], fromName);
|
|
18088
|
+
}
|
|
18089
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
18090
|
+
if (fromConfig != null) {
|
|
18091
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
18092
|
+
}
|
|
18093
|
+
return toObject;
|
|
18094
|
+
}
|
|
17678
18095
|
function tuningDatasetToVertex(fromObject, parentObject) {
|
|
17679
18096
|
const toObject = {};
|
|
17680
18097
|
const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
|
|
@@ -18328,6 +18745,54 @@ class Tunings extends BaseModule {
|
|
|
18328
18745
|
});
|
|
18329
18746
|
}
|
|
18330
18747
|
}
|
|
18748
|
+
/**
|
|
18749
|
+
* Cancels a tuning job.
|
|
18750
|
+
*
|
|
18751
|
+
* @param params - The parameters for the cancel request.
|
|
18752
|
+
* @return The empty response returned by the API.
|
|
18753
|
+
*
|
|
18754
|
+
* @example
|
|
18755
|
+
* ```ts
|
|
18756
|
+
* await ai.tunings.cancel({name: '...'}); // The server-generated resource name.
|
|
18757
|
+
* ```
|
|
18758
|
+
*/
|
|
18759
|
+
async cancel(params) {
|
|
18760
|
+
var _a, _b, _c, _d;
|
|
18761
|
+
let path = '';
|
|
18762
|
+
let queryParams = {};
|
|
18763
|
+
if (this.apiClient.isVertexAI()) {
|
|
18764
|
+
const body = cancelTuningJobParametersToVertex(params);
|
|
18765
|
+
path = formatMap('{name}:cancel', body['_url']);
|
|
18766
|
+
queryParams = body['_query'];
|
|
18767
|
+
delete body['config'];
|
|
18768
|
+
delete body['_url'];
|
|
18769
|
+
delete body['_query'];
|
|
18770
|
+
await this.apiClient.request({
|
|
18771
|
+
path: path,
|
|
18772
|
+
queryParams: queryParams,
|
|
18773
|
+
body: JSON.stringify(body),
|
|
18774
|
+
httpMethod: 'POST',
|
|
18775
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
18776
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
18777
|
+
});
|
|
18778
|
+
}
|
|
18779
|
+
else {
|
|
18780
|
+
const body = cancelTuningJobParametersToMldev(params);
|
|
18781
|
+
path = formatMap('{name}:cancel', body['_url']);
|
|
18782
|
+
queryParams = body['_query'];
|
|
18783
|
+
delete body['config'];
|
|
18784
|
+
delete body['_url'];
|
|
18785
|
+
delete body['_query'];
|
|
18786
|
+
await this.apiClient.request({
|
|
18787
|
+
path: path,
|
|
18788
|
+
queryParams: queryParams,
|
|
18789
|
+
body: JSON.stringify(body),
|
|
18790
|
+
httpMethod: 'POST',
|
|
18791
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
18792
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
18793
|
+
});
|
|
18794
|
+
}
|
|
18795
|
+
}
|
|
18331
18796
|
async tuneInternal(params) {
|
|
18332
18797
|
var _a, _b;
|
|
18333
18798
|
let response;
|
|
@@ -18811,7 +19276,7 @@ function getApiKeyFromEnv() {
|
|
|
18811
19276
|
if (envGoogleApiKey && envGeminiApiKey) {
|
|
18812
19277
|
console.warn('Both GOOGLE_API_KEY and GEMINI_API_KEY are set. Using GOOGLE_API_KEY.');
|
|
18813
19278
|
}
|
|
18814
|
-
return envGoogleApiKey || envGeminiApiKey;
|
|
19279
|
+
return envGoogleApiKey || envGeminiApiKey || undefined;
|
|
18815
19280
|
}
|
|
18816
19281
|
|
|
18817
19282
|
exports.ApiError = ApiError;
|
|
@@ -18856,6 +19321,7 @@ exports.Pager = Pager;
|
|
|
18856
19321
|
exports.RawReferenceImage = RawReferenceImage;
|
|
18857
19322
|
exports.RecontextImageResponse = RecontextImageResponse;
|
|
18858
19323
|
exports.ReplayResponse = ReplayResponse;
|
|
19324
|
+
exports.SegmentImageResponse = SegmentImageResponse;
|
|
18859
19325
|
exports.Session = Session;
|
|
18860
19326
|
exports.StyleReferenceImage = StyleReferenceImage;
|
|
18861
19327
|
exports.SubjectReferenceImage = SubjectReferenceImage;
|