@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/index.cjs
CHANGED
|
@@ -771,6 +771,10 @@ exports.FunctionCallingConfigMode = void 0;
|
|
|
771
771
|
* Model will not predict any function calls. Model behavior is same as when not passing any function declarations.
|
|
772
772
|
*/
|
|
773
773
|
FunctionCallingConfigMode["NONE"] = "NONE";
|
|
774
|
+
/**
|
|
775
|
+
* 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".
|
|
776
|
+
*/
|
|
777
|
+
FunctionCallingConfigMode["VALIDATED"] = "VALIDATED";
|
|
774
778
|
})(exports.FunctionCallingConfigMode || (exports.FunctionCallingConfigMode = {}));
|
|
775
779
|
/** Enum that controls the safety filter level for objectionable content. */
|
|
776
780
|
exports.SafetyFilterLevel = void 0;
|
|
@@ -869,6 +873,30 @@ exports.EditMode = void 0;
|
|
|
869
873
|
EditMode["EDIT_MODE_BGSWAP"] = "EDIT_MODE_BGSWAP";
|
|
870
874
|
EditMode["EDIT_MODE_PRODUCT_IMAGE"] = "EDIT_MODE_PRODUCT_IMAGE";
|
|
871
875
|
})(exports.EditMode || (exports.EditMode = {}));
|
|
876
|
+
/** Enum that represents the segmentation mode. */
|
|
877
|
+
exports.SegmentMode = void 0;
|
|
878
|
+
(function (SegmentMode) {
|
|
879
|
+
SegmentMode["FOREGROUND"] = "FOREGROUND";
|
|
880
|
+
SegmentMode["BACKGROUND"] = "BACKGROUND";
|
|
881
|
+
SegmentMode["PROMPT"] = "PROMPT";
|
|
882
|
+
SegmentMode["SEMANTIC"] = "SEMANTIC";
|
|
883
|
+
SegmentMode["INTERACTIVE"] = "INTERACTIVE";
|
|
884
|
+
})(exports.SegmentMode || (exports.SegmentMode = {}));
|
|
885
|
+
/** Enum for the reference type of a video generation reference image. */
|
|
886
|
+
exports.VideoGenerationReferenceType = void 0;
|
|
887
|
+
(function (VideoGenerationReferenceType) {
|
|
888
|
+
/**
|
|
889
|
+
* A reference image that provides assets to the generated video,
|
|
890
|
+
such as the scene, an object, a character, etc.
|
|
891
|
+
*/
|
|
892
|
+
VideoGenerationReferenceType["ASSET"] = "ASSET";
|
|
893
|
+
/**
|
|
894
|
+
* A reference image that provides aesthetics including colors,
|
|
895
|
+
lighting, texture, etc., to be used as the style of the generated video,
|
|
896
|
+
such as 'anime', 'photography', 'origami', etc.
|
|
897
|
+
*/
|
|
898
|
+
VideoGenerationReferenceType["STYLE"] = "STYLE";
|
|
899
|
+
})(exports.VideoGenerationReferenceType || (exports.VideoGenerationReferenceType = {}));
|
|
872
900
|
/** Enum that controls the compression quality of the generated videos. */
|
|
873
901
|
exports.VideoCompressionQuality = void 0;
|
|
874
902
|
(function (VideoCompressionQuality) {
|
|
@@ -1515,6 +1543,9 @@ class UpscaleImageResponse {
|
|
|
1515
1543
|
/** The output images response. */
|
|
1516
1544
|
class RecontextImageResponse {
|
|
1517
1545
|
}
|
|
1546
|
+
/** The output images response. */
|
|
1547
|
+
class SegmentImageResponse {
|
|
1548
|
+
}
|
|
1518
1549
|
class ListModelsResponse {
|
|
1519
1550
|
}
|
|
1520
1551
|
class DeleteModelResponse {
|
|
@@ -1528,6 +1559,65 @@ class ComputeTokensResponse {
|
|
|
1528
1559
|
/** Response with generated videos. */
|
|
1529
1560
|
class GenerateVideosResponse {
|
|
1530
1561
|
}
|
|
1562
|
+
/** A video generation operation. */
|
|
1563
|
+
class GenerateVideosOperation {
|
|
1564
|
+
/**
|
|
1565
|
+
* Instantiates an Operation of the same type as the one being called with the fields set from the API response.
|
|
1566
|
+
* @internal
|
|
1567
|
+
*/
|
|
1568
|
+
_fromAPIResponse({ apiResponse, isVertexAI, }) {
|
|
1569
|
+
const operation = new GenerateVideosOperation();
|
|
1570
|
+
operation.name = apiResponse['name'];
|
|
1571
|
+
operation.metadata = apiResponse['metadata'];
|
|
1572
|
+
operation.done = apiResponse['done'];
|
|
1573
|
+
operation.error = apiResponse['error'];
|
|
1574
|
+
if (isVertexAI) {
|
|
1575
|
+
const response = apiResponse['response'];
|
|
1576
|
+
if (response) {
|
|
1577
|
+
const operationResponse = new GenerateVideosResponse();
|
|
1578
|
+
const responseVideos = response['videos'];
|
|
1579
|
+
operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
|
|
1580
|
+
return {
|
|
1581
|
+
video: {
|
|
1582
|
+
uri: generatedVideo['gcsUri'],
|
|
1583
|
+
videoBytes: generatedVideo['bytesBase64Encoded']
|
|
1584
|
+
? tBytes$1(generatedVideo['bytesBase64Encoded'])
|
|
1585
|
+
: undefined,
|
|
1586
|
+
mimeType: generatedVideo['mimeType'],
|
|
1587
|
+
},
|
|
1588
|
+
};
|
|
1589
|
+
});
|
|
1590
|
+
operationResponse.raiMediaFilteredCount = response['raiMediaFilteredCount'];
|
|
1591
|
+
operationResponse.raiMediaFilteredReasons = response['raiMediaFilteredReasons'];
|
|
1592
|
+
operation.response = operationResponse;
|
|
1593
|
+
}
|
|
1594
|
+
}
|
|
1595
|
+
else {
|
|
1596
|
+
const response = apiResponse['response'];
|
|
1597
|
+
if (response) {
|
|
1598
|
+
const operationResponse = new GenerateVideosResponse();
|
|
1599
|
+
const generatedVideoResponse = response['generateVideoResponse'];
|
|
1600
|
+
const responseVideos = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['generatedSamples'];
|
|
1601
|
+
operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
|
|
1602
|
+
const video = generatedVideo['video'];
|
|
1603
|
+
return {
|
|
1604
|
+
video: {
|
|
1605
|
+
uri: video === null || video === void 0 ? void 0 : video['uri'],
|
|
1606
|
+
videoBytes: (video === null || video === void 0 ? void 0 : video['encodedVideo'])
|
|
1607
|
+
? tBytes$1(video === null || video === void 0 ? void 0 : video['encodedVideo'])
|
|
1608
|
+
: undefined,
|
|
1609
|
+
mimeType: generatedVideo['encoding'],
|
|
1610
|
+
},
|
|
1611
|
+
};
|
|
1612
|
+
});
|
|
1613
|
+
operationResponse.raiMediaFilteredCount = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredCount'];
|
|
1614
|
+
operationResponse.raiMediaFilteredReasons = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredReasons'];
|
|
1615
|
+
operation.response = operationResponse;
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1618
|
+
return operation;
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1531
1621
|
/** Response for the list tuning jobs method. */
|
|
1532
1622
|
class ListTuningJobsResponse {
|
|
1533
1623
|
}
|
|
@@ -1719,65 +1809,6 @@ class LiveServerMessage {
|
|
|
1719
1809
|
return data.length > 0 ? btoa(data) : undefined;
|
|
1720
1810
|
}
|
|
1721
1811
|
}
|
|
1722
|
-
/** A video generation long-running operation. */
|
|
1723
|
-
class GenerateVideosOperation {
|
|
1724
|
-
/**
|
|
1725
|
-
* Instantiates an Operation of the same type as the one being called with the fields set from the API response.
|
|
1726
|
-
* @internal
|
|
1727
|
-
*/
|
|
1728
|
-
_fromAPIResponse({ apiResponse, isVertexAI, }) {
|
|
1729
|
-
const operation = new GenerateVideosOperation();
|
|
1730
|
-
operation.name = apiResponse['name'];
|
|
1731
|
-
operation.metadata = apiResponse['metadata'];
|
|
1732
|
-
operation.done = apiResponse['done'];
|
|
1733
|
-
operation.error = apiResponse['error'];
|
|
1734
|
-
if (isVertexAI) {
|
|
1735
|
-
const response = apiResponse['response'];
|
|
1736
|
-
if (response) {
|
|
1737
|
-
const operationResponse = new GenerateVideosResponse();
|
|
1738
|
-
const responseVideos = response['videos'];
|
|
1739
|
-
operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
|
|
1740
|
-
return {
|
|
1741
|
-
video: {
|
|
1742
|
-
uri: generatedVideo['gcsUri'],
|
|
1743
|
-
videoBytes: generatedVideo['bytesBase64Encoded']
|
|
1744
|
-
? tBytes$1(generatedVideo['bytesBase64Encoded'])
|
|
1745
|
-
: undefined,
|
|
1746
|
-
mimeType: generatedVideo['mimeType'],
|
|
1747
|
-
},
|
|
1748
|
-
};
|
|
1749
|
-
});
|
|
1750
|
-
operationResponse.raiMediaFilteredCount = response['raiMediaFilteredCount'];
|
|
1751
|
-
operationResponse.raiMediaFilteredReasons = response['raiMediaFilteredReasons'];
|
|
1752
|
-
operation.response = operationResponse;
|
|
1753
|
-
}
|
|
1754
|
-
}
|
|
1755
|
-
else {
|
|
1756
|
-
const response = apiResponse['response'];
|
|
1757
|
-
if (response) {
|
|
1758
|
-
const operationResponse = new GenerateVideosResponse();
|
|
1759
|
-
const generatedVideoResponse = response['generateVideoResponse'];
|
|
1760
|
-
const responseVideos = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['generatedSamples'];
|
|
1761
|
-
operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
|
|
1762
|
-
const video = generatedVideo['video'];
|
|
1763
|
-
return {
|
|
1764
|
-
video: {
|
|
1765
|
-
uri: video === null || video === void 0 ? void 0 : video['uri'],
|
|
1766
|
-
videoBytes: (video === null || video === void 0 ? void 0 : video['encodedVideo'])
|
|
1767
|
-
? tBytes$1(video === null || video === void 0 ? void 0 : video['encodedVideo'])
|
|
1768
|
-
: undefined,
|
|
1769
|
-
mimeType: generatedVideo['encoding'],
|
|
1770
|
-
},
|
|
1771
|
-
};
|
|
1772
|
-
});
|
|
1773
|
-
operationResponse.raiMediaFilteredCount = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredCount'];
|
|
1774
|
-
operationResponse.raiMediaFilteredReasons = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredReasons'];
|
|
1775
|
-
operation.response = operationResponse;
|
|
1776
|
-
}
|
|
1777
|
-
}
|
|
1778
|
-
return operation;
|
|
1779
|
-
}
|
|
1780
|
-
}
|
|
1781
1812
|
/** Client generated response to a `ToolCall` received from the server.
|
|
1782
1813
|
|
|
1783
1814
|
Individual `FunctionResponse` objects are matched to the respective
|
|
@@ -2424,6 +2455,9 @@ function mcpToGeminiTool(mcpTool, config = {}) {
|
|
|
2424
2455
|
description: mcpToolSchema['description'],
|
|
2425
2456
|
parametersJsonSchema: mcpToolSchema['inputSchema'],
|
|
2426
2457
|
};
|
|
2458
|
+
if (mcpToolSchema['outputSchema']) {
|
|
2459
|
+
functionDeclaration['responseJsonSchema'] = mcpToolSchema['outputSchema'];
|
|
2460
|
+
}
|
|
2427
2461
|
if (config.behavior) {
|
|
2428
2462
|
functionDeclaration['behavior'] = config.behavior;
|
|
2429
2463
|
}
|
|
@@ -4253,6 +4287,7 @@ class Batches extends BaseModule {
|
|
|
4253
4287
|
* ```
|
|
4254
4288
|
*/
|
|
4255
4289
|
this.create = async (params) => {
|
|
4290
|
+
var _a, _b;
|
|
4256
4291
|
if (this.apiClient.isVertexAI()) {
|
|
4257
4292
|
const timestamp = Date.now();
|
|
4258
4293
|
const timestampStr = timestamp.toString();
|
|
@@ -4277,6 +4312,55 @@ class Batches extends BaseModule {
|
|
|
4277
4312
|
}
|
|
4278
4313
|
}
|
|
4279
4314
|
}
|
|
4315
|
+
else {
|
|
4316
|
+
if (Array.isArray(params.src) ||
|
|
4317
|
+
(typeof params.src !== 'string' && params.src.inlinedRequests)) {
|
|
4318
|
+
// Move system instruction to httpOptions extraBody.
|
|
4319
|
+
let path = '';
|
|
4320
|
+
let queryParams = {};
|
|
4321
|
+
const body = createBatchJobParametersToMldev(this.apiClient, params);
|
|
4322
|
+
path = formatMap('{model}:batchGenerateContent', body['_url']);
|
|
4323
|
+
queryParams = body['_query'];
|
|
4324
|
+
// Move system instruction to 'request':
|
|
4325
|
+
// {'systemInstruction': system_instruction}
|
|
4326
|
+
const batch = body['batch'];
|
|
4327
|
+
const inputConfig = batch['inputConfig'];
|
|
4328
|
+
const requestsWrapper = inputConfig['requests'];
|
|
4329
|
+
const requests = requestsWrapper['requests'];
|
|
4330
|
+
const newRequests = [];
|
|
4331
|
+
for (const request of requests) {
|
|
4332
|
+
const requestDict = request;
|
|
4333
|
+
if (requestDict['systemInstruction']) {
|
|
4334
|
+
const systemInstructionValue = requestDict['systemInstruction'];
|
|
4335
|
+
delete requestDict['systemInstruction'];
|
|
4336
|
+
const requestContent = requestDict['request'];
|
|
4337
|
+
requestContent['systemInstruction'] = systemInstructionValue;
|
|
4338
|
+
requestDict['request'] = requestContent;
|
|
4339
|
+
}
|
|
4340
|
+
newRequests.push(requestDict);
|
|
4341
|
+
}
|
|
4342
|
+
requestsWrapper['requests'] = newRequests;
|
|
4343
|
+
delete body['config'];
|
|
4344
|
+
delete body['_url'];
|
|
4345
|
+
delete body['_query'];
|
|
4346
|
+
const response = this.apiClient
|
|
4347
|
+
.request({
|
|
4348
|
+
path: path,
|
|
4349
|
+
queryParams: queryParams,
|
|
4350
|
+
body: JSON.stringify(body),
|
|
4351
|
+
httpMethod: 'POST',
|
|
4352
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
4353
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
4354
|
+
})
|
|
4355
|
+
.then((httpResponse) => {
|
|
4356
|
+
return httpResponse.json();
|
|
4357
|
+
});
|
|
4358
|
+
return response.then((apiResponse) => {
|
|
4359
|
+
const resp = batchJobFromMldev(apiResponse);
|
|
4360
|
+
return resp;
|
|
4361
|
+
});
|
|
4362
|
+
}
|
|
4363
|
+
}
|
|
4280
4364
|
return await this.createInternal(params);
|
|
4281
4365
|
};
|
|
4282
4366
|
/**
|
|
@@ -5621,8 +5705,14 @@ function cachedContentFromMldev(fromObject) {
|
|
|
5621
5705
|
}
|
|
5622
5706
|
return toObject;
|
|
5623
5707
|
}
|
|
5624
|
-
function deleteCachedContentResponseFromMldev() {
|
|
5708
|
+
function deleteCachedContentResponseFromMldev(fromObject) {
|
|
5625
5709
|
const toObject = {};
|
|
5710
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
5711
|
+
'sdkHttpResponse',
|
|
5712
|
+
]);
|
|
5713
|
+
if (fromSdkHttpResponse != null) {
|
|
5714
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
5715
|
+
}
|
|
5626
5716
|
return toObject;
|
|
5627
5717
|
}
|
|
5628
5718
|
function listCachedContentsResponseFromMldev(fromObject) {
|
|
@@ -5687,8 +5777,14 @@ function cachedContentFromVertex(fromObject) {
|
|
|
5687
5777
|
}
|
|
5688
5778
|
return toObject;
|
|
5689
5779
|
}
|
|
5690
|
-
function deleteCachedContentResponseFromVertex() {
|
|
5780
|
+
function deleteCachedContentResponseFromVertex(fromObject) {
|
|
5691
5781
|
const toObject = {};
|
|
5782
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
5783
|
+
'sdkHttpResponse',
|
|
5784
|
+
]);
|
|
5785
|
+
if (fromSdkHttpResponse != null) {
|
|
5786
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
5787
|
+
}
|
|
5692
5788
|
return toObject;
|
|
5693
5789
|
}
|
|
5694
5790
|
function listCachedContentsResponseFromVertex(fromObject) {
|
|
@@ -5925,10 +6021,16 @@ class Caches extends BaseModule {
|
|
|
5925
6021
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
5926
6022
|
})
|
|
5927
6023
|
.then((httpResponse) => {
|
|
5928
|
-
return httpResponse.json()
|
|
6024
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
6025
|
+
const response = jsonResponse;
|
|
6026
|
+
response.sdkHttpResponse = {
|
|
6027
|
+
headers: httpResponse.headers,
|
|
6028
|
+
};
|
|
6029
|
+
return response;
|
|
6030
|
+
});
|
|
5929
6031
|
});
|
|
5930
|
-
return response.then(() => {
|
|
5931
|
-
const resp = deleteCachedContentResponseFromVertex();
|
|
6032
|
+
return response.then((apiResponse) => {
|
|
6033
|
+
const resp = deleteCachedContentResponseFromVertex(apiResponse);
|
|
5932
6034
|
const typedResp = new DeleteCachedContentResponse();
|
|
5933
6035
|
Object.assign(typedResp, resp);
|
|
5934
6036
|
return typedResp;
|
|
@@ -5951,10 +6053,16 @@ class Caches extends BaseModule {
|
|
|
5951
6053
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
5952
6054
|
})
|
|
5953
6055
|
.then((httpResponse) => {
|
|
5954
|
-
return httpResponse.json()
|
|
6056
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
6057
|
+
const response = jsonResponse;
|
|
6058
|
+
response.sdkHttpResponse = {
|
|
6059
|
+
headers: httpResponse.headers,
|
|
6060
|
+
};
|
|
6061
|
+
return response;
|
|
6062
|
+
});
|
|
5955
6063
|
});
|
|
5956
|
-
return response.then(() => {
|
|
5957
|
-
const resp = deleteCachedContentResponseFromMldev();
|
|
6064
|
+
return response.then((apiResponse) => {
|
|
6065
|
+
const resp = deleteCachedContentResponseFromMldev(apiResponse);
|
|
5958
6066
|
const typedResp = new DeleteCachedContentResponse();
|
|
5959
6067
|
Object.assign(typedResp, resp);
|
|
5960
6068
|
return typedResp;
|
|
@@ -6187,9 +6295,6 @@ function isValidContent(content) {
|
|
|
6187
6295
|
if (part === undefined || Object.keys(part).length === 0) {
|
|
6188
6296
|
return false;
|
|
6189
6297
|
}
|
|
6190
|
-
if (!part.thought && part.text !== undefined && part.text === '') {
|
|
6191
|
-
return false;
|
|
6192
|
-
}
|
|
6193
6298
|
}
|
|
6194
6299
|
return true;
|
|
6195
6300
|
}
|
|
@@ -6512,7 +6617,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
6512
6617
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
6513
6618
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
6514
6619
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
6515
|
-
const SDK_VERSION = '1.
|
|
6620
|
+
const SDK_VERSION = '1.16.0'; // x-release-please-version
|
|
6516
6621
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
6517
6622
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
6518
6623
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -7458,8 +7563,14 @@ function createFileResponseFromMldev(fromObject) {
|
|
|
7458
7563
|
}
|
|
7459
7564
|
return toObject;
|
|
7460
7565
|
}
|
|
7461
|
-
function deleteFileResponseFromMldev() {
|
|
7566
|
+
function deleteFileResponseFromMldev(fromObject) {
|
|
7462
7567
|
const toObject = {};
|
|
7568
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
7569
|
+
'sdkHttpResponse',
|
|
7570
|
+
]);
|
|
7571
|
+
if (fromSdkHttpResponse != null) {
|
|
7572
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
7573
|
+
}
|
|
7463
7574
|
return toObject;
|
|
7464
7575
|
}
|
|
7465
7576
|
|
|
@@ -7728,10 +7839,16 @@ class Files extends BaseModule {
|
|
|
7728
7839
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
7729
7840
|
})
|
|
7730
7841
|
.then((httpResponse) => {
|
|
7731
|
-
return httpResponse.json()
|
|
7842
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
7843
|
+
const response = jsonResponse;
|
|
7844
|
+
response.sdkHttpResponse = {
|
|
7845
|
+
headers: httpResponse.headers,
|
|
7846
|
+
};
|
|
7847
|
+
return response;
|
|
7848
|
+
});
|
|
7732
7849
|
});
|
|
7733
|
-
return response.then(() => {
|
|
7734
|
-
const resp = deleteFileResponseFromMldev();
|
|
7850
|
+
return response.then((apiResponse) => {
|
|
7851
|
+
const resp = deleteFileResponseFromMldev(apiResponse);
|
|
7735
7852
|
const typedResp = new DeleteFileResponse();
|
|
7736
7853
|
Object.assign(typedResp, resp);
|
|
7737
7854
|
return typedResp;
|
|
@@ -11034,6 +11151,21 @@ function imageToMldev(fromObject) {
|
|
|
11034
11151
|
}
|
|
11035
11152
|
return toObject;
|
|
11036
11153
|
}
|
|
11154
|
+
function generateVideosSourceToMldev(fromObject, parentObject) {
|
|
11155
|
+
const toObject = {};
|
|
11156
|
+
const fromPrompt = getValueByPath(fromObject, ['prompt']);
|
|
11157
|
+
if (parentObject !== undefined && fromPrompt != null) {
|
|
11158
|
+
setValueByPath(parentObject, ['instances[0]', 'prompt'], fromPrompt);
|
|
11159
|
+
}
|
|
11160
|
+
const fromImage = getValueByPath(fromObject, ['image']);
|
|
11161
|
+
if (parentObject !== undefined && fromImage != null) {
|
|
11162
|
+
setValueByPath(parentObject, ['instances[0]', 'image'], imageToMldev(fromImage));
|
|
11163
|
+
}
|
|
11164
|
+
if (getValueByPath(fromObject, ['video']) !== undefined) {
|
|
11165
|
+
throw new Error('video parameter is not supported in Gemini API.');
|
|
11166
|
+
}
|
|
11167
|
+
return toObject;
|
|
11168
|
+
}
|
|
11037
11169
|
function generateVideosConfigToMldev(fromObject, parentObject) {
|
|
11038
11170
|
const toObject = {};
|
|
11039
11171
|
const fromNumberOfVideos = getValueByPath(fromObject, [
|
|
@@ -11091,6 +11223,9 @@ function generateVideosConfigToMldev(fromObject, parentObject) {
|
|
|
11091
11223
|
if (getValueByPath(fromObject, ['lastFrame']) !== undefined) {
|
|
11092
11224
|
throw new Error('lastFrame parameter is not supported in Gemini API.');
|
|
11093
11225
|
}
|
|
11226
|
+
if (getValueByPath(fromObject, ['referenceImages']) !== undefined) {
|
|
11227
|
+
throw new Error('referenceImages parameter is not supported in Gemini API.');
|
|
11228
|
+
}
|
|
11094
11229
|
if (getValueByPath(fromObject, ['compressionQuality']) !== undefined) {
|
|
11095
11230
|
throw new Error('compressionQuality parameter is not supported in Gemini API.');
|
|
11096
11231
|
}
|
|
@@ -11113,6 +11248,10 @@ function generateVideosParametersToMldev(apiClient, fromObject) {
|
|
|
11113
11248
|
if (getValueByPath(fromObject, ['video']) !== undefined) {
|
|
11114
11249
|
throw new Error('video parameter is not supported in Gemini API.');
|
|
11115
11250
|
}
|
|
11251
|
+
const fromSource = getValueByPath(fromObject, ['source']);
|
|
11252
|
+
if (fromSource != null) {
|
|
11253
|
+
setValueByPath(toObject, ['config'], generateVideosSourceToMldev(fromSource, toObject));
|
|
11254
|
+
}
|
|
11116
11255
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
11117
11256
|
if (fromConfig != null) {
|
|
11118
11257
|
setValueByPath(toObject, ['config'], generateVideosConfigToMldev(fromConfig, toObject));
|
|
@@ -12237,6 +12376,10 @@ function editImageParametersInternalToVertex(apiClient, fromObject) {
|
|
|
12237
12376
|
}
|
|
12238
12377
|
function upscaleImageAPIConfigInternalToVertex(fromObject, parentObject) {
|
|
12239
12378
|
const toObject = {};
|
|
12379
|
+
const fromOutputGcsUri = getValueByPath(fromObject, ['outputGcsUri']);
|
|
12380
|
+
if (parentObject !== undefined && fromOutputGcsUri != null) {
|
|
12381
|
+
setValueByPath(parentObject, ['parameters', 'storageUri'], fromOutputGcsUri);
|
|
12382
|
+
}
|
|
12240
12383
|
const fromIncludeRaiReason = getValueByPath(fromObject, [
|
|
12241
12384
|
'includeRaiReason',
|
|
12242
12385
|
]);
|
|
@@ -12365,6 +12508,10 @@ function recontextImageConfigToVertex(fromObject, parentObject) {
|
|
|
12365
12508
|
if (parentObject !== undefined && fromPersonGeneration != null) {
|
|
12366
12509
|
setValueByPath(parentObject, ['parameters', 'personGeneration'], fromPersonGeneration);
|
|
12367
12510
|
}
|
|
12511
|
+
const fromAddWatermark = getValueByPath(fromObject, ['addWatermark']);
|
|
12512
|
+
if (parentObject !== undefined && fromAddWatermark != null) {
|
|
12513
|
+
setValueByPath(parentObject, ['parameters', 'addWatermark'], fromAddWatermark);
|
|
12514
|
+
}
|
|
12368
12515
|
const fromOutputMimeType = getValueByPath(fromObject, [
|
|
12369
12516
|
'outputMimeType',
|
|
12370
12517
|
]);
|
|
@@ -12401,6 +12548,78 @@ function recontextImageParametersToVertex(apiClient, fromObject) {
|
|
|
12401
12548
|
}
|
|
12402
12549
|
return toObject;
|
|
12403
12550
|
}
|
|
12551
|
+
function scribbleImageToVertex(fromObject) {
|
|
12552
|
+
const toObject = {};
|
|
12553
|
+
const fromImage = getValueByPath(fromObject, ['image']);
|
|
12554
|
+
if (fromImage != null) {
|
|
12555
|
+
setValueByPath(toObject, ['image'], imageToVertex(fromImage));
|
|
12556
|
+
}
|
|
12557
|
+
return toObject;
|
|
12558
|
+
}
|
|
12559
|
+
function segmentImageSourceToVertex(fromObject, parentObject) {
|
|
12560
|
+
const toObject = {};
|
|
12561
|
+
const fromPrompt = getValueByPath(fromObject, ['prompt']);
|
|
12562
|
+
if (parentObject !== undefined && fromPrompt != null) {
|
|
12563
|
+
setValueByPath(parentObject, ['instances[0]', 'prompt'], fromPrompt);
|
|
12564
|
+
}
|
|
12565
|
+
const fromImage = getValueByPath(fromObject, ['image']);
|
|
12566
|
+
if (parentObject !== undefined && fromImage != null) {
|
|
12567
|
+
setValueByPath(parentObject, ['instances[0]', 'image'], imageToVertex(fromImage));
|
|
12568
|
+
}
|
|
12569
|
+
const fromScribbleImage = getValueByPath(fromObject, [
|
|
12570
|
+
'scribbleImage',
|
|
12571
|
+
]);
|
|
12572
|
+
if (parentObject !== undefined && fromScribbleImage != null) {
|
|
12573
|
+
setValueByPath(parentObject, ['instances[0]', 'scribble'], scribbleImageToVertex(fromScribbleImage));
|
|
12574
|
+
}
|
|
12575
|
+
return toObject;
|
|
12576
|
+
}
|
|
12577
|
+
function segmentImageConfigToVertex(fromObject, parentObject) {
|
|
12578
|
+
const toObject = {};
|
|
12579
|
+
const fromMode = getValueByPath(fromObject, ['mode']);
|
|
12580
|
+
if (parentObject !== undefined && fromMode != null) {
|
|
12581
|
+
setValueByPath(parentObject, ['parameters', 'mode'], fromMode);
|
|
12582
|
+
}
|
|
12583
|
+
const fromMaxPredictions = getValueByPath(fromObject, [
|
|
12584
|
+
'maxPredictions',
|
|
12585
|
+
]);
|
|
12586
|
+
if (parentObject !== undefined && fromMaxPredictions != null) {
|
|
12587
|
+
setValueByPath(parentObject, ['parameters', 'maxPredictions'], fromMaxPredictions);
|
|
12588
|
+
}
|
|
12589
|
+
const fromConfidenceThreshold = getValueByPath(fromObject, [
|
|
12590
|
+
'confidenceThreshold',
|
|
12591
|
+
]);
|
|
12592
|
+
if (parentObject !== undefined && fromConfidenceThreshold != null) {
|
|
12593
|
+
setValueByPath(parentObject, ['parameters', 'confidenceThreshold'], fromConfidenceThreshold);
|
|
12594
|
+
}
|
|
12595
|
+
const fromMaskDilation = getValueByPath(fromObject, ['maskDilation']);
|
|
12596
|
+
if (parentObject !== undefined && fromMaskDilation != null) {
|
|
12597
|
+
setValueByPath(parentObject, ['parameters', 'maskDilation'], fromMaskDilation);
|
|
12598
|
+
}
|
|
12599
|
+
const fromBinaryColorThreshold = getValueByPath(fromObject, [
|
|
12600
|
+
'binaryColorThreshold',
|
|
12601
|
+
]);
|
|
12602
|
+
if (parentObject !== undefined && fromBinaryColorThreshold != null) {
|
|
12603
|
+
setValueByPath(parentObject, ['parameters', 'binaryColorThreshold'], fromBinaryColorThreshold);
|
|
12604
|
+
}
|
|
12605
|
+
return toObject;
|
|
12606
|
+
}
|
|
12607
|
+
function segmentImageParametersToVertex(apiClient, fromObject) {
|
|
12608
|
+
const toObject = {};
|
|
12609
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
12610
|
+
if (fromModel != null) {
|
|
12611
|
+
setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
|
|
12612
|
+
}
|
|
12613
|
+
const fromSource = getValueByPath(fromObject, ['source']);
|
|
12614
|
+
if (fromSource != null) {
|
|
12615
|
+
setValueByPath(toObject, ['config'], segmentImageSourceToVertex(fromSource, toObject));
|
|
12616
|
+
}
|
|
12617
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
12618
|
+
if (fromConfig != null) {
|
|
12619
|
+
setValueByPath(toObject, ['config'], segmentImageConfigToVertex(fromConfig, toObject));
|
|
12620
|
+
}
|
|
12621
|
+
return toObject;
|
|
12622
|
+
}
|
|
12404
12623
|
function getModelParametersToVertex(apiClient, fromObject) {
|
|
12405
12624
|
const toObject = {};
|
|
12406
12625
|
const fromModel = getValueByPath(fromObject, ['model']);
|
|
@@ -12569,6 +12788,36 @@ function videoToVertex(fromObject) {
|
|
|
12569
12788
|
}
|
|
12570
12789
|
return toObject;
|
|
12571
12790
|
}
|
|
12791
|
+
function generateVideosSourceToVertex(fromObject, parentObject) {
|
|
12792
|
+
const toObject = {};
|
|
12793
|
+
const fromPrompt = getValueByPath(fromObject, ['prompt']);
|
|
12794
|
+
if (parentObject !== undefined && fromPrompt != null) {
|
|
12795
|
+
setValueByPath(parentObject, ['instances[0]', 'prompt'], fromPrompt);
|
|
12796
|
+
}
|
|
12797
|
+
const fromImage = getValueByPath(fromObject, ['image']);
|
|
12798
|
+
if (parentObject !== undefined && fromImage != null) {
|
|
12799
|
+
setValueByPath(parentObject, ['instances[0]', 'image'], imageToVertex(fromImage));
|
|
12800
|
+
}
|
|
12801
|
+
const fromVideo = getValueByPath(fromObject, ['video']);
|
|
12802
|
+
if (parentObject !== undefined && fromVideo != null) {
|
|
12803
|
+
setValueByPath(parentObject, ['instances[0]', 'video'], videoToVertex(fromVideo));
|
|
12804
|
+
}
|
|
12805
|
+
return toObject;
|
|
12806
|
+
}
|
|
12807
|
+
function videoGenerationReferenceImageToVertex(fromObject) {
|
|
12808
|
+
const toObject = {};
|
|
12809
|
+
const fromImage = getValueByPath(fromObject, ['image']);
|
|
12810
|
+
if (fromImage != null) {
|
|
12811
|
+
setValueByPath(toObject, ['image'], imageToVertex(fromImage));
|
|
12812
|
+
}
|
|
12813
|
+
const fromReferenceType = getValueByPath(fromObject, [
|
|
12814
|
+
'referenceType',
|
|
12815
|
+
]);
|
|
12816
|
+
if (fromReferenceType != null) {
|
|
12817
|
+
setValueByPath(toObject, ['referenceType'], fromReferenceType);
|
|
12818
|
+
}
|
|
12819
|
+
return toObject;
|
|
12820
|
+
}
|
|
12572
12821
|
function generateVideosConfigToVertex(fromObject, parentObject) {
|
|
12573
12822
|
const toObject = {};
|
|
12574
12823
|
const fromNumberOfVideos = getValueByPath(fromObject, [
|
|
@@ -12635,6 +12884,18 @@ function generateVideosConfigToVertex(fromObject, parentObject) {
|
|
|
12635
12884
|
if (parentObject !== undefined && fromLastFrame != null) {
|
|
12636
12885
|
setValueByPath(parentObject, ['instances[0]', 'lastFrame'], imageToVertex(fromLastFrame));
|
|
12637
12886
|
}
|
|
12887
|
+
const fromReferenceImages = getValueByPath(fromObject, [
|
|
12888
|
+
'referenceImages',
|
|
12889
|
+
]);
|
|
12890
|
+
if (parentObject !== undefined && fromReferenceImages != null) {
|
|
12891
|
+
let transformedList = fromReferenceImages;
|
|
12892
|
+
if (Array.isArray(transformedList)) {
|
|
12893
|
+
transformedList = transformedList.map((item) => {
|
|
12894
|
+
return videoGenerationReferenceImageToVertex(item);
|
|
12895
|
+
});
|
|
12896
|
+
}
|
|
12897
|
+
setValueByPath(parentObject, ['instances[0]', 'referenceImages'], transformedList);
|
|
12898
|
+
}
|
|
12638
12899
|
const fromCompressionQuality = getValueByPath(fromObject, [
|
|
12639
12900
|
'compressionQuality',
|
|
12640
12901
|
]);
|
|
@@ -12661,6 +12922,10 @@ function generateVideosParametersToVertex(apiClient, fromObject) {
|
|
|
12661
12922
|
if (fromVideo != null) {
|
|
12662
12923
|
setValueByPath(toObject, ['instances[0]', 'video'], videoToVertex(fromVideo));
|
|
12663
12924
|
}
|
|
12925
|
+
const fromSource = getValueByPath(fromObject, ['source']);
|
|
12926
|
+
if (fromSource != null) {
|
|
12927
|
+
setValueByPath(toObject, ['config'], generateVideosSourceToVertex(fromSource, toObject));
|
|
12928
|
+
}
|
|
12664
12929
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
12665
12930
|
if (fromConfig != null) {
|
|
12666
12931
|
setValueByPath(toObject, ['config'], generateVideosConfigToVertex(fromConfig, toObject));
|
|
@@ -13111,8 +13376,14 @@ function listModelsResponseFromMldev(fromObject) {
|
|
|
13111
13376
|
}
|
|
13112
13377
|
return toObject;
|
|
13113
13378
|
}
|
|
13114
|
-
function deleteModelResponseFromMldev() {
|
|
13379
|
+
function deleteModelResponseFromMldev(fromObject) {
|
|
13115
13380
|
const toObject = {};
|
|
13381
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
13382
|
+
'sdkHttpResponse',
|
|
13383
|
+
]);
|
|
13384
|
+
if (fromSdkHttpResponse != null) {
|
|
13385
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
13386
|
+
}
|
|
13116
13387
|
return toObject;
|
|
13117
13388
|
}
|
|
13118
13389
|
function countTokensResponseFromMldev(fromObject) {
|
|
@@ -13684,6 +13955,50 @@ function recontextImageResponseFromVertex(fromObject) {
|
|
|
13684
13955
|
}
|
|
13685
13956
|
return toObject;
|
|
13686
13957
|
}
|
|
13958
|
+
function entityLabelFromVertex(fromObject) {
|
|
13959
|
+
const toObject = {};
|
|
13960
|
+
const fromLabel = getValueByPath(fromObject, ['label']);
|
|
13961
|
+
if (fromLabel != null) {
|
|
13962
|
+
setValueByPath(toObject, ['label'], fromLabel);
|
|
13963
|
+
}
|
|
13964
|
+
const fromScore = getValueByPath(fromObject, ['score']);
|
|
13965
|
+
if (fromScore != null) {
|
|
13966
|
+
setValueByPath(toObject, ['score'], fromScore);
|
|
13967
|
+
}
|
|
13968
|
+
return toObject;
|
|
13969
|
+
}
|
|
13970
|
+
function generatedImageMaskFromVertex(fromObject) {
|
|
13971
|
+
const toObject = {};
|
|
13972
|
+
const fromMask = getValueByPath(fromObject, ['_self']);
|
|
13973
|
+
if (fromMask != null) {
|
|
13974
|
+
setValueByPath(toObject, ['mask'], imageFromVertex(fromMask));
|
|
13975
|
+
}
|
|
13976
|
+
const fromLabels = getValueByPath(fromObject, ['labels']);
|
|
13977
|
+
if (fromLabels != null) {
|
|
13978
|
+
let transformedList = fromLabels;
|
|
13979
|
+
if (Array.isArray(transformedList)) {
|
|
13980
|
+
transformedList = transformedList.map((item) => {
|
|
13981
|
+
return entityLabelFromVertex(item);
|
|
13982
|
+
});
|
|
13983
|
+
}
|
|
13984
|
+
setValueByPath(toObject, ['labels'], transformedList);
|
|
13985
|
+
}
|
|
13986
|
+
return toObject;
|
|
13987
|
+
}
|
|
13988
|
+
function segmentImageResponseFromVertex(fromObject) {
|
|
13989
|
+
const toObject = {};
|
|
13990
|
+
const fromGeneratedMasks = getValueByPath(fromObject, ['predictions']);
|
|
13991
|
+
if (fromGeneratedMasks != null) {
|
|
13992
|
+
let transformedList = fromGeneratedMasks;
|
|
13993
|
+
if (Array.isArray(transformedList)) {
|
|
13994
|
+
transformedList = transformedList.map((item) => {
|
|
13995
|
+
return generatedImageMaskFromVertex(item);
|
|
13996
|
+
});
|
|
13997
|
+
}
|
|
13998
|
+
setValueByPath(toObject, ['generatedMasks'], transformedList);
|
|
13999
|
+
}
|
|
14000
|
+
return toObject;
|
|
14001
|
+
}
|
|
13687
14002
|
function endpointFromVertex(fromObject) {
|
|
13688
14003
|
const toObject = {};
|
|
13689
14004
|
const fromName = getValueByPath(fromObject, ['endpoint']);
|
|
@@ -13813,8 +14128,14 @@ function listModelsResponseFromVertex(fromObject) {
|
|
|
13813
14128
|
}
|
|
13814
14129
|
return toObject;
|
|
13815
14130
|
}
|
|
13816
|
-
function deleteModelResponseFromVertex() {
|
|
14131
|
+
function deleteModelResponseFromVertex(fromObject) {
|
|
13817
14132
|
const toObject = {};
|
|
14133
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
14134
|
+
'sdkHttpResponse',
|
|
14135
|
+
]);
|
|
14136
|
+
if (fromSdkHttpResponse != null) {
|
|
14137
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
14138
|
+
}
|
|
13818
14139
|
return toObject;
|
|
13819
14140
|
}
|
|
13820
14141
|
function countTokensResponseFromVertex(fromObject) {
|
|
@@ -15129,7 +15450,9 @@ class Models extends BaseModule {
|
|
|
15129
15450
|
* ```ts
|
|
15130
15451
|
* const operation = await ai.models.generateVideos({
|
|
15131
15452
|
* model: 'veo-2.0-generate-001',
|
|
15132
|
-
*
|
|
15453
|
+
* source: {
|
|
15454
|
+
* prompt: 'A neon hologram of a cat driving at top speed',
|
|
15455
|
+
* },
|
|
15133
15456
|
* config: {
|
|
15134
15457
|
* numberOfVideos: 1
|
|
15135
15458
|
* });
|
|
@@ -15143,6 +15466,9 @@ class Models extends BaseModule {
|
|
|
15143
15466
|
* ```
|
|
15144
15467
|
*/
|
|
15145
15468
|
this.generateVideos = async (params) => {
|
|
15469
|
+
if ((params.prompt || params.image || params.video) && params.source) {
|
|
15470
|
+
throw new Error('Source and prompt/image/video are mutually exclusive. Please only use source.');
|
|
15471
|
+
}
|
|
15146
15472
|
return await this.generateVideosInternal(params);
|
|
15147
15473
|
};
|
|
15148
15474
|
}
|
|
@@ -15800,6 +16126,61 @@ class Models extends BaseModule {
|
|
|
15800
16126
|
throw new Error('This method is only supported by the Vertex AI.');
|
|
15801
16127
|
}
|
|
15802
16128
|
}
|
|
16129
|
+
/**
|
|
16130
|
+
* Segments an image, creating a mask of a specified area.
|
|
16131
|
+
*
|
|
16132
|
+
* @param params - The parameters for segmenting an image.
|
|
16133
|
+
* @return The response from the API.
|
|
16134
|
+
*
|
|
16135
|
+
* @example
|
|
16136
|
+
* ```ts
|
|
16137
|
+
* const response = await ai.models.segmentImage({
|
|
16138
|
+
* model: 'image-segmentation-001',
|
|
16139
|
+
* source: {
|
|
16140
|
+
* image: image,
|
|
16141
|
+
* },
|
|
16142
|
+
* config: {
|
|
16143
|
+
* mode: 'foreground',
|
|
16144
|
+
* },
|
|
16145
|
+
* });
|
|
16146
|
+
* console.log(response?.generatedMasks?.[0]?.mask?.imageBytes);
|
|
16147
|
+
* ```
|
|
16148
|
+
*/
|
|
16149
|
+
async segmentImage(params) {
|
|
16150
|
+
var _a, _b;
|
|
16151
|
+
let response;
|
|
16152
|
+
let path = '';
|
|
16153
|
+
let queryParams = {};
|
|
16154
|
+
if (this.apiClient.isVertexAI()) {
|
|
16155
|
+
const body = segmentImageParametersToVertex(this.apiClient, params);
|
|
16156
|
+
path = formatMap('{model}:predict', body['_url']);
|
|
16157
|
+
queryParams = body['_query'];
|
|
16158
|
+
delete body['config'];
|
|
16159
|
+
delete body['_url'];
|
|
16160
|
+
delete body['_query'];
|
|
16161
|
+
response = this.apiClient
|
|
16162
|
+
.request({
|
|
16163
|
+
path: path,
|
|
16164
|
+
queryParams: queryParams,
|
|
16165
|
+
body: JSON.stringify(body),
|
|
16166
|
+
httpMethod: 'POST',
|
|
16167
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
16168
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
16169
|
+
})
|
|
16170
|
+
.then((httpResponse) => {
|
|
16171
|
+
return httpResponse.json();
|
|
16172
|
+
});
|
|
16173
|
+
return response.then((apiResponse) => {
|
|
16174
|
+
const resp = segmentImageResponseFromVertex(apiResponse);
|
|
16175
|
+
const typedResp = new SegmentImageResponse();
|
|
16176
|
+
Object.assign(typedResp, resp);
|
|
16177
|
+
return typedResp;
|
|
16178
|
+
});
|
|
16179
|
+
}
|
|
16180
|
+
else {
|
|
16181
|
+
throw new Error('This method is only supported by the Vertex AI.');
|
|
16182
|
+
}
|
|
16183
|
+
}
|
|
15803
16184
|
/**
|
|
15804
16185
|
* Fetches information about a model by name.
|
|
15805
16186
|
*
|
|
@@ -16036,10 +16417,16 @@ class Models extends BaseModule {
|
|
|
16036
16417
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
16037
16418
|
})
|
|
16038
16419
|
.then((httpResponse) => {
|
|
16039
|
-
return httpResponse.json()
|
|
16420
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
16421
|
+
const response = jsonResponse;
|
|
16422
|
+
response.sdkHttpResponse = {
|
|
16423
|
+
headers: httpResponse.headers,
|
|
16424
|
+
};
|
|
16425
|
+
return response;
|
|
16426
|
+
});
|
|
16040
16427
|
});
|
|
16041
|
-
return response.then(() => {
|
|
16042
|
-
const resp = deleteModelResponseFromVertex();
|
|
16428
|
+
return response.then((apiResponse) => {
|
|
16429
|
+
const resp = deleteModelResponseFromVertex(apiResponse);
|
|
16043
16430
|
const typedResp = new DeleteModelResponse();
|
|
16044
16431
|
Object.assign(typedResp, resp);
|
|
16045
16432
|
return typedResp;
|
|
@@ -16062,10 +16449,16 @@ class Models extends BaseModule {
|
|
|
16062
16449
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
16063
16450
|
})
|
|
16064
16451
|
.then((httpResponse) => {
|
|
16065
|
-
return httpResponse.json()
|
|
16452
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
16453
|
+
const response = jsonResponse;
|
|
16454
|
+
response.sdkHttpResponse = {
|
|
16455
|
+
headers: httpResponse.headers,
|
|
16456
|
+
};
|
|
16457
|
+
return response;
|
|
16458
|
+
});
|
|
16066
16459
|
});
|
|
16067
|
-
return response.then(() => {
|
|
16068
|
-
const resp = deleteModelResponseFromMldev();
|
|
16460
|
+
return response.then((apiResponse) => {
|
|
16461
|
+
const resp = deleteModelResponseFromMldev(apiResponse);
|
|
16069
16462
|
const typedResp = new DeleteModelResponse();
|
|
16070
16463
|
Object.assign(typedResp, resp);
|
|
16071
16464
|
return typedResp;
|
|
@@ -16320,13 +16713,17 @@ function getOperationParametersToMldev(fromObject) {
|
|
|
16320
16713
|
}
|
|
16321
16714
|
return toObject;
|
|
16322
16715
|
}
|
|
16323
|
-
function
|
|
16716
|
+
function fetchPredictOperationParametersToVertex(fromObject) {
|
|
16324
16717
|
const toObject = {};
|
|
16325
16718
|
const fromOperationName = getValueByPath(fromObject, [
|
|
16326
16719
|
'operationName',
|
|
16327
16720
|
]);
|
|
16328
16721
|
if (fromOperationName != null) {
|
|
16329
|
-
setValueByPath(toObject, ['
|
|
16722
|
+
setValueByPath(toObject, ['operationName'], fromOperationName);
|
|
16723
|
+
}
|
|
16724
|
+
const fromResourceName = getValueByPath(fromObject, ['resourceName']);
|
|
16725
|
+
if (fromResourceName != null) {
|
|
16726
|
+
setValueByPath(toObject, ['_url', 'resourceName'], fromResourceName);
|
|
16330
16727
|
}
|
|
16331
16728
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
16332
16729
|
if (fromConfig != null) {
|
|
@@ -16334,17 +16731,13 @@ function getOperationParametersToVertex(fromObject) {
|
|
|
16334
16731
|
}
|
|
16335
16732
|
return toObject;
|
|
16336
16733
|
}
|
|
16337
|
-
function
|
|
16734
|
+
function getOperationParametersToVertex(fromObject) {
|
|
16338
16735
|
const toObject = {};
|
|
16339
16736
|
const fromOperationName = getValueByPath(fromObject, [
|
|
16340
16737
|
'operationName',
|
|
16341
16738
|
]);
|
|
16342
16739
|
if (fromOperationName != null) {
|
|
16343
|
-
setValueByPath(toObject, ['operationName'], fromOperationName);
|
|
16344
|
-
}
|
|
16345
|
-
const fromResourceName = getValueByPath(fromObject, ['resourceName']);
|
|
16346
|
-
if (fromResourceName != null) {
|
|
16347
|
-
setValueByPath(toObject, ['_url', 'resourceName'], fromResourceName);
|
|
16740
|
+
setValueByPath(toObject, ['_url', 'operationName'], fromOperationName);
|
|
16348
16741
|
}
|
|
16349
16742
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
16350
16743
|
if (fromConfig != null) {
|
|
@@ -17431,6 +17824,18 @@ function listTuningJobsParametersToMldev(fromObject) {
|
|
|
17431
17824
|
}
|
|
17432
17825
|
return toObject;
|
|
17433
17826
|
}
|
|
17827
|
+
function cancelTuningJobParametersToMldev(fromObject) {
|
|
17828
|
+
const toObject = {};
|
|
17829
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
17830
|
+
if (fromName != null) {
|
|
17831
|
+
setValueByPath(toObject, ['_url', 'name'], fromName);
|
|
17832
|
+
}
|
|
17833
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
17834
|
+
if (fromConfig != null) {
|
|
17835
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
17836
|
+
}
|
|
17837
|
+
return toObject;
|
|
17838
|
+
}
|
|
17434
17839
|
function tuningExampleToMldev(fromObject) {
|
|
17435
17840
|
const toObject = {};
|
|
17436
17841
|
const fromTextInput = getValueByPath(fromObject, ['textInput']);
|
|
@@ -17568,6 +17973,18 @@ function listTuningJobsParametersToVertex(fromObject) {
|
|
|
17568
17973
|
}
|
|
17569
17974
|
return toObject;
|
|
17570
17975
|
}
|
|
17976
|
+
function cancelTuningJobParametersToVertex(fromObject) {
|
|
17977
|
+
const toObject = {};
|
|
17978
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
17979
|
+
if (fromName != null) {
|
|
17980
|
+
setValueByPath(toObject, ['_url', 'name'], fromName);
|
|
17981
|
+
}
|
|
17982
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
17983
|
+
if (fromConfig != null) {
|
|
17984
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
17985
|
+
}
|
|
17986
|
+
return toObject;
|
|
17987
|
+
}
|
|
17571
17988
|
function tuningDatasetToVertex(fromObject, parentObject) {
|
|
17572
17989
|
const toObject = {};
|
|
17573
17990
|
const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
|
|
@@ -18221,6 +18638,54 @@ class Tunings extends BaseModule {
|
|
|
18221
18638
|
});
|
|
18222
18639
|
}
|
|
18223
18640
|
}
|
|
18641
|
+
/**
|
|
18642
|
+
* Cancels a tuning job.
|
|
18643
|
+
*
|
|
18644
|
+
* @param params - The parameters for the cancel request.
|
|
18645
|
+
* @return The empty response returned by the API.
|
|
18646
|
+
*
|
|
18647
|
+
* @example
|
|
18648
|
+
* ```ts
|
|
18649
|
+
* await ai.tunings.cancel({name: '...'}); // The server-generated resource name.
|
|
18650
|
+
* ```
|
|
18651
|
+
*/
|
|
18652
|
+
async cancel(params) {
|
|
18653
|
+
var _a, _b, _c, _d;
|
|
18654
|
+
let path = '';
|
|
18655
|
+
let queryParams = {};
|
|
18656
|
+
if (this.apiClient.isVertexAI()) {
|
|
18657
|
+
const body = cancelTuningJobParametersToVertex(params);
|
|
18658
|
+
path = formatMap('{name}:cancel', body['_url']);
|
|
18659
|
+
queryParams = body['_query'];
|
|
18660
|
+
delete body['config'];
|
|
18661
|
+
delete body['_url'];
|
|
18662
|
+
delete body['_query'];
|
|
18663
|
+
await this.apiClient.request({
|
|
18664
|
+
path: path,
|
|
18665
|
+
queryParams: queryParams,
|
|
18666
|
+
body: JSON.stringify(body),
|
|
18667
|
+
httpMethod: 'POST',
|
|
18668
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
18669
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
18670
|
+
});
|
|
18671
|
+
}
|
|
18672
|
+
else {
|
|
18673
|
+
const body = cancelTuningJobParametersToMldev(params);
|
|
18674
|
+
path = formatMap('{name}:cancel', body['_url']);
|
|
18675
|
+
queryParams = body['_query'];
|
|
18676
|
+
delete body['config'];
|
|
18677
|
+
delete body['_url'];
|
|
18678
|
+
delete body['_query'];
|
|
18679
|
+
await this.apiClient.request({
|
|
18680
|
+
path: path,
|
|
18681
|
+
queryParams: queryParams,
|
|
18682
|
+
body: JSON.stringify(body),
|
|
18683
|
+
httpMethod: 'POST',
|
|
18684
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
18685
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
18686
|
+
});
|
|
18687
|
+
}
|
|
18688
|
+
}
|
|
18224
18689
|
async tuneInternal(params) {
|
|
18225
18690
|
var _a, _b;
|
|
18226
18691
|
let response;
|
|
@@ -18438,6 +18903,7 @@ exports.Pager = Pager;
|
|
|
18438
18903
|
exports.RawReferenceImage = RawReferenceImage;
|
|
18439
18904
|
exports.RecontextImageResponse = RecontextImageResponse;
|
|
18440
18905
|
exports.ReplayResponse = ReplayResponse;
|
|
18906
|
+
exports.SegmentImageResponse = SegmentImageResponse;
|
|
18441
18907
|
exports.Session = Session;
|
|
18442
18908
|
exports.StyleReferenceImage = StyleReferenceImage;
|
|
18443
18909
|
exports.SubjectReferenceImage = SubjectReferenceImage;
|