@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.mjs
CHANGED
|
@@ -769,6 +769,10 @@ var FunctionCallingConfigMode;
|
|
|
769
769
|
* Model will not predict any function calls. Model behavior is same as when not passing any function declarations.
|
|
770
770
|
*/
|
|
771
771
|
FunctionCallingConfigMode["NONE"] = "NONE";
|
|
772
|
+
/**
|
|
773
|
+
* 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".
|
|
774
|
+
*/
|
|
775
|
+
FunctionCallingConfigMode["VALIDATED"] = "VALIDATED";
|
|
772
776
|
})(FunctionCallingConfigMode || (FunctionCallingConfigMode = {}));
|
|
773
777
|
/** Enum that controls the safety filter level for objectionable content. */
|
|
774
778
|
var SafetyFilterLevel;
|
|
@@ -867,6 +871,30 @@ var EditMode;
|
|
|
867
871
|
EditMode["EDIT_MODE_BGSWAP"] = "EDIT_MODE_BGSWAP";
|
|
868
872
|
EditMode["EDIT_MODE_PRODUCT_IMAGE"] = "EDIT_MODE_PRODUCT_IMAGE";
|
|
869
873
|
})(EditMode || (EditMode = {}));
|
|
874
|
+
/** Enum that represents the segmentation mode. */
|
|
875
|
+
var SegmentMode;
|
|
876
|
+
(function (SegmentMode) {
|
|
877
|
+
SegmentMode["FOREGROUND"] = "FOREGROUND";
|
|
878
|
+
SegmentMode["BACKGROUND"] = "BACKGROUND";
|
|
879
|
+
SegmentMode["PROMPT"] = "PROMPT";
|
|
880
|
+
SegmentMode["SEMANTIC"] = "SEMANTIC";
|
|
881
|
+
SegmentMode["INTERACTIVE"] = "INTERACTIVE";
|
|
882
|
+
})(SegmentMode || (SegmentMode = {}));
|
|
883
|
+
/** Enum for the reference type of a video generation reference image. */
|
|
884
|
+
var VideoGenerationReferenceType;
|
|
885
|
+
(function (VideoGenerationReferenceType) {
|
|
886
|
+
/**
|
|
887
|
+
* A reference image that provides assets to the generated video,
|
|
888
|
+
such as the scene, an object, a character, etc.
|
|
889
|
+
*/
|
|
890
|
+
VideoGenerationReferenceType["ASSET"] = "ASSET";
|
|
891
|
+
/**
|
|
892
|
+
* A reference image that provides aesthetics including colors,
|
|
893
|
+
lighting, texture, etc., to be used as the style of the generated video,
|
|
894
|
+
such as 'anime', 'photography', 'origami', etc.
|
|
895
|
+
*/
|
|
896
|
+
VideoGenerationReferenceType["STYLE"] = "STYLE";
|
|
897
|
+
})(VideoGenerationReferenceType || (VideoGenerationReferenceType = {}));
|
|
870
898
|
/** Enum that controls the compression quality of the generated videos. */
|
|
871
899
|
var VideoCompressionQuality;
|
|
872
900
|
(function (VideoCompressionQuality) {
|
|
@@ -1513,6 +1541,9 @@ class UpscaleImageResponse {
|
|
|
1513
1541
|
/** The output images response. */
|
|
1514
1542
|
class RecontextImageResponse {
|
|
1515
1543
|
}
|
|
1544
|
+
/** The output images response. */
|
|
1545
|
+
class SegmentImageResponse {
|
|
1546
|
+
}
|
|
1516
1547
|
class ListModelsResponse {
|
|
1517
1548
|
}
|
|
1518
1549
|
class DeleteModelResponse {
|
|
@@ -1526,6 +1557,65 @@ class ComputeTokensResponse {
|
|
|
1526
1557
|
/** Response with generated videos. */
|
|
1527
1558
|
class GenerateVideosResponse {
|
|
1528
1559
|
}
|
|
1560
|
+
/** A video generation operation. */
|
|
1561
|
+
class GenerateVideosOperation {
|
|
1562
|
+
/**
|
|
1563
|
+
* Instantiates an Operation of the same type as the one being called with the fields set from the API response.
|
|
1564
|
+
* @internal
|
|
1565
|
+
*/
|
|
1566
|
+
_fromAPIResponse({ apiResponse, isVertexAI, }) {
|
|
1567
|
+
const operation = new GenerateVideosOperation();
|
|
1568
|
+
operation.name = apiResponse['name'];
|
|
1569
|
+
operation.metadata = apiResponse['metadata'];
|
|
1570
|
+
operation.done = apiResponse['done'];
|
|
1571
|
+
operation.error = apiResponse['error'];
|
|
1572
|
+
if (isVertexAI) {
|
|
1573
|
+
const response = apiResponse['response'];
|
|
1574
|
+
if (response) {
|
|
1575
|
+
const operationResponse = new GenerateVideosResponse();
|
|
1576
|
+
const responseVideos = response['videos'];
|
|
1577
|
+
operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
|
|
1578
|
+
return {
|
|
1579
|
+
video: {
|
|
1580
|
+
uri: generatedVideo['gcsUri'],
|
|
1581
|
+
videoBytes: generatedVideo['bytesBase64Encoded']
|
|
1582
|
+
? tBytes$1(generatedVideo['bytesBase64Encoded'])
|
|
1583
|
+
: undefined,
|
|
1584
|
+
mimeType: generatedVideo['mimeType'],
|
|
1585
|
+
},
|
|
1586
|
+
};
|
|
1587
|
+
});
|
|
1588
|
+
operationResponse.raiMediaFilteredCount = response['raiMediaFilteredCount'];
|
|
1589
|
+
operationResponse.raiMediaFilteredReasons = response['raiMediaFilteredReasons'];
|
|
1590
|
+
operation.response = operationResponse;
|
|
1591
|
+
}
|
|
1592
|
+
}
|
|
1593
|
+
else {
|
|
1594
|
+
const response = apiResponse['response'];
|
|
1595
|
+
if (response) {
|
|
1596
|
+
const operationResponse = new GenerateVideosResponse();
|
|
1597
|
+
const generatedVideoResponse = response['generateVideoResponse'];
|
|
1598
|
+
const responseVideos = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['generatedSamples'];
|
|
1599
|
+
operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
|
|
1600
|
+
const video = generatedVideo['video'];
|
|
1601
|
+
return {
|
|
1602
|
+
video: {
|
|
1603
|
+
uri: video === null || video === void 0 ? void 0 : video['uri'],
|
|
1604
|
+
videoBytes: (video === null || video === void 0 ? void 0 : video['encodedVideo'])
|
|
1605
|
+
? tBytes$1(video === null || video === void 0 ? void 0 : video['encodedVideo'])
|
|
1606
|
+
: undefined,
|
|
1607
|
+
mimeType: generatedVideo['encoding'],
|
|
1608
|
+
},
|
|
1609
|
+
};
|
|
1610
|
+
});
|
|
1611
|
+
operationResponse.raiMediaFilteredCount = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredCount'];
|
|
1612
|
+
operationResponse.raiMediaFilteredReasons = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredReasons'];
|
|
1613
|
+
operation.response = operationResponse;
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1616
|
+
return operation;
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1529
1619
|
/** Response for the list tuning jobs method. */
|
|
1530
1620
|
class ListTuningJobsResponse {
|
|
1531
1621
|
}
|
|
@@ -1717,65 +1807,6 @@ class LiveServerMessage {
|
|
|
1717
1807
|
return data.length > 0 ? btoa(data) : undefined;
|
|
1718
1808
|
}
|
|
1719
1809
|
}
|
|
1720
|
-
/** A video generation long-running operation. */
|
|
1721
|
-
class GenerateVideosOperation {
|
|
1722
|
-
/**
|
|
1723
|
-
* Instantiates an Operation of the same type as the one being called with the fields set from the API response.
|
|
1724
|
-
* @internal
|
|
1725
|
-
*/
|
|
1726
|
-
_fromAPIResponse({ apiResponse, isVertexAI, }) {
|
|
1727
|
-
const operation = new GenerateVideosOperation();
|
|
1728
|
-
operation.name = apiResponse['name'];
|
|
1729
|
-
operation.metadata = apiResponse['metadata'];
|
|
1730
|
-
operation.done = apiResponse['done'];
|
|
1731
|
-
operation.error = apiResponse['error'];
|
|
1732
|
-
if (isVertexAI) {
|
|
1733
|
-
const response = apiResponse['response'];
|
|
1734
|
-
if (response) {
|
|
1735
|
-
const operationResponse = new GenerateVideosResponse();
|
|
1736
|
-
const responseVideos = response['videos'];
|
|
1737
|
-
operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
|
|
1738
|
-
return {
|
|
1739
|
-
video: {
|
|
1740
|
-
uri: generatedVideo['gcsUri'],
|
|
1741
|
-
videoBytes: generatedVideo['bytesBase64Encoded']
|
|
1742
|
-
? tBytes$1(generatedVideo['bytesBase64Encoded'])
|
|
1743
|
-
: undefined,
|
|
1744
|
-
mimeType: generatedVideo['mimeType'],
|
|
1745
|
-
},
|
|
1746
|
-
};
|
|
1747
|
-
});
|
|
1748
|
-
operationResponse.raiMediaFilteredCount = response['raiMediaFilteredCount'];
|
|
1749
|
-
operationResponse.raiMediaFilteredReasons = response['raiMediaFilteredReasons'];
|
|
1750
|
-
operation.response = operationResponse;
|
|
1751
|
-
}
|
|
1752
|
-
}
|
|
1753
|
-
else {
|
|
1754
|
-
const response = apiResponse['response'];
|
|
1755
|
-
if (response) {
|
|
1756
|
-
const operationResponse = new GenerateVideosResponse();
|
|
1757
|
-
const generatedVideoResponse = response['generateVideoResponse'];
|
|
1758
|
-
const responseVideos = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['generatedSamples'];
|
|
1759
|
-
operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
|
|
1760
|
-
const video = generatedVideo['video'];
|
|
1761
|
-
return {
|
|
1762
|
-
video: {
|
|
1763
|
-
uri: video === null || video === void 0 ? void 0 : video['uri'],
|
|
1764
|
-
videoBytes: (video === null || video === void 0 ? void 0 : video['encodedVideo'])
|
|
1765
|
-
? tBytes$1(video === null || video === void 0 ? void 0 : video['encodedVideo'])
|
|
1766
|
-
: undefined,
|
|
1767
|
-
mimeType: generatedVideo['encoding'],
|
|
1768
|
-
},
|
|
1769
|
-
};
|
|
1770
|
-
});
|
|
1771
|
-
operationResponse.raiMediaFilteredCount = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredCount'];
|
|
1772
|
-
operationResponse.raiMediaFilteredReasons = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredReasons'];
|
|
1773
|
-
operation.response = operationResponse;
|
|
1774
|
-
}
|
|
1775
|
-
}
|
|
1776
|
-
return operation;
|
|
1777
|
-
}
|
|
1778
|
-
}
|
|
1779
1810
|
/** Client generated response to a `ToolCall` received from the server.
|
|
1780
1811
|
|
|
1781
1812
|
Individual `FunctionResponse` objects are matched to the respective
|
|
@@ -2422,6 +2453,9 @@ function mcpToGeminiTool(mcpTool, config = {}) {
|
|
|
2422
2453
|
description: mcpToolSchema['description'],
|
|
2423
2454
|
parametersJsonSchema: mcpToolSchema['inputSchema'],
|
|
2424
2455
|
};
|
|
2456
|
+
if (mcpToolSchema['outputSchema']) {
|
|
2457
|
+
functionDeclaration['responseJsonSchema'] = mcpToolSchema['outputSchema'];
|
|
2458
|
+
}
|
|
2425
2459
|
if (config.behavior) {
|
|
2426
2460
|
functionDeclaration['behavior'] = config.behavior;
|
|
2427
2461
|
}
|
|
@@ -4251,6 +4285,7 @@ class Batches extends BaseModule {
|
|
|
4251
4285
|
* ```
|
|
4252
4286
|
*/
|
|
4253
4287
|
this.create = async (params) => {
|
|
4288
|
+
var _a, _b;
|
|
4254
4289
|
if (this.apiClient.isVertexAI()) {
|
|
4255
4290
|
const timestamp = Date.now();
|
|
4256
4291
|
const timestampStr = timestamp.toString();
|
|
@@ -4275,6 +4310,55 @@ class Batches extends BaseModule {
|
|
|
4275
4310
|
}
|
|
4276
4311
|
}
|
|
4277
4312
|
}
|
|
4313
|
+
else {
|
|
4314
|
+
if (Array.isArray(params.src) ||
|
|
4315
|
+
(typeof params.src !== 'string' && params.src.inlinedRequests)) {
|
|
4316
|
+
// Move system instruction to httpOptions extraBody.
|
|
4317
|
+
let path = '';
|
|
4318
|
+
let queryParams = {};
|
|
4319
|
+
const body = createBatchJobParametersToMldev(this.apiClient, params);
|
|
4320
|
+
path = formatMap('{model}:batchGenerateContent', body['_url']);
|
|
4321
|
+
queryParams = body['_query'];
|
|
4322
|
+
// Move system instruction to 'request':
|
|
4323
|
+
// {'systemInstruction': system_instruction}
|
|
4324
|
+
const batch = body['batch'];
|
|
4325
|
+
const inputConfig = batch['inputConfig'];
|
|
4326
|
+
const requestsWrapper = inputConfig['requests'];
|
|
4327
|
+
const requests = requestsWrapper['requests'];
|
|
4328
|
+
const newRequests = [];
|
|
4329
|
+
for (const request of requests) {
|
|
4330
|
+
const requestDict = request;
|
|
4331
|
+
if (requestDict['systemInstruction']) {
|
|
4332
|
+
const systemInstructionValue = requestDict['systemInstruction'];
|
|
4333
|
+
delete requestDict['systemInstruction'];
|
|
4334
|
+
const requestContent = requestDict['request'];
|
|
4335
|
+
requestContent['systemInstruction'] = systemInstructionValue;
|
|
4336
|
+
requestDict['request'] = requestContent;
|
|
4337
|
+
}
|
|
4338
|
+
newRequests.push(requestDict);
|
|
4339
|
+
}
|
|
4340
|
+
requestsWrapper['requests'] = newRequests;
|
|
4341
|
+
delete body['config'];
|
|
4342
|
+
delete body['_url'];
|
|
4343
|
+
delete body['_query'];
|
|
4344
|
+
const response = this.apiClient
|
|
4345
|
+
.request({
|
|
4346
|
+
path: path,
|
|
4347
|
+
queryParams: queryParams,
|
|
4348
|
+
body: JSON.stringify(body),
|
|
4349
|
+
httpMethod: 'POST',
|
|
4350
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
4351
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
4352
|
+
})
|
|
4353
|
+
.then((httpResponse) => {
|
|
4354
|
+
return httpResponse.json();
|
|
4355
|
+
});
|
|
4356
|
+
return response.then((apiResponse) => {
|
|
4357
|
+
const resp = batchJobFromMldev(apiResponse);
|
|
4358
|
+
return resp;
|
|
4359
|
+
});
|
|
4360
|
+
}
|
|
4361
|
+
}
|
|
4278
4362
|
return await this.createInternal(params);
|
|
4279
4363
|
};
|
|
4280
4364
|
/**
|
|
@@ -5619,8 +5703,14 @@ function cachedContentFromMldev(fromObject) {
|
|
|
5619
5703
|
}
|
|
5620
5704
|
return toObject;
|
|
5621
5705
|
}
|
|
5622
|
-
function deleteCachedContentResponseFromMldev() {
|
|
5706
|
+
function deleteCachedContentResponseFromMldev(fromObject) {
|
|
5623
5707
|
const toObject = {};
|
|
5708
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
5709
|
+
'sdkHttpResponse',
|
|
5710
|
+
]);
|
|
5711
|
+
if (fromSdkHttpResponse != null) {
|
|
5712
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
5713
|
+
}
|
|
5624
5714
|
return toObject;
|
|
5625
5715
|
}
|
|
5626
5716
|
function listCachedContentsResponseFromMldev(fromObject) {
|
|
@@ -5685,8 +5775,14 @@ function cachedContentFromVertex(fromObject) {
|
|
|
5685
5775
|
}
|
|
5686
5776
|
return toObject;
|
|
5687
5777
|
}
|
|
5688
|
-
function deleteCachedContentResponseFromVertex() {
|
|
5778
|
+
function deleteCachedContentResponseFromVertex(fromObject) {
|
|
5689
5779
|
const toObject = {};
|
|
5780
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
5781
|
+
'sdkHttpResponse',
|
|
5782
|
+
]);
|
|
5783
|
+
if (fromSdkHttpResponse != null) {
|
|
5784
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
5785
|
+
}
|
|
5690
5786
|
return toObject;
|
|
5691
5787
|
}
|
|
5692
5788
|
function listCachedContentsResponseFromVertex(fromObject) {
|
|
@@ -5923,10 +6019,16 @@ class Caches extends BaseModule {
|
|
|
5923
6019
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
5924
6020
|
})
|
|
5925
6021
|
.then((httpResponse) => {
|
|
5926
|
-
return httpResponse.json()
|
|
6022
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
6023
|
+
const response = jsonResponse;
|
|
6024
|
+
response.sdkHttpResponse = {
|
|
6025
|
+
headers: httpResponse.headers,
|
|
6026
|
+
};
|
|
6027
|
+
return response;
|
|
6028
|
+
});
|
|
5927
6029
|
});
|
|
5928
|
-
return response.then(() => {
|
|
5929
|
-
const resp = deleteCachedContentResponseFromVertex();
|
|
6030
|
+
return response.then((apiResponse) => {
|
|
6031
|
+
const resp = deleteCachedContentResponseFromVertex(apiResponse);
|
|
5930
6032
|
const typedResp = new DeleteCachedContentResponse();
|
|
5931
6033
|
Object.assign(typedResp, resp);
|
|
5932
6034
|
return typedResp;
|
|
@@ -5949,10 +6051,16 @@ class Caches extends BaseModule {
|
|
|
5949
6051
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
5950
6052
|
})
|
|
5951
6053
|
.then((httpResponse) => {
|
|
5952
|
-
return httpResponse.json()
|
|
6054
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
6055
|
+
const response = jsonResponse;
|
|
6056
|
+
response.sdkHttpResponse = {
|
|
6057
|
+
headers: httpResponse.headers,
|
|
6058
|
+
};
|
|
6059
|
+
return response;
|
|
6060
|
+
});
|
|
5953
6061
|
});
|
|
5954
|
-
return response.then(() => {
|
|
5955
|
-
const resp = deleteCachedContentResponseFromMldev();
|
|
6062
|
+
return response.then((apiResponse) => {
|
|
6063
|
+
const resp = deleteCachedContentResponseFromMldev(apiResponse);
|
|
5956
6064
|
const typedResp = new DeleteCachedContentResponse();
|
|
5957
6065
|
Object.assign(typedResp, resp);
|
|
5958
6066
|
return typedResp;
|
|
@@ -6185,9 +6293,6 @@ function isValidContent(content) {
|
|
|
6185
6293
|
if (part === undefined || Object.keys(part).length === 0) {
|
|
6186
6294
|
return false;
|
|
6187
6295
|
}
|
|
6188
|
-
if (!part.thought && part.text !== undefined && part.text === '') {
|
|
6189
|
-
return false;
|
|
6190
|
-
}
|
|
6191
6296
|
}
|
|
6192
6297
|
return true;
|
|
6193
6298
|
}
|
|
@@ -6510,7 +6615,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
6510
6615
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
6511
6616
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
6512
6617
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
6513
|
-
const SDK_VERSION = '1.
|
|
6618
|
+
const SDK_VERSION = '1.16.0'; // x-release-please-version
|
|
6514
6619
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
6515
6620
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
6516
6621
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -7456,8 +7561,14 @@ function createFileResponseFromMldev(fromObject) {
|
|
|
7456
7561
|
}
|
|
7457
7562
|
return toObject;
|
|
7458
7563
|
}
|
|
7459
|
-
function deleteFileResponseFromMldev() {
|
|
7564
|
+
function deleteFileResponseFromMldev(fromObject) {
|
|
7460
7565
|
const toObject = {};
|
|
7566
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
7567
|
+
'sdkHttpResponse',
|
|
7568
|
+
]);
|
|
7569
|
+
if (fromSdkHttpResponse != null) {
|
|
7570
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
7571
|
+
}
|
|
7461
7572
|
return toObject;
|
|
7462
7573
|
}
|
|
7463
7574
|
|
|
@@ -7726,10 +7837,16 @@ class Files extends BaseModule {
|
|
|
7726
7837
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
7727
7838
|
})
|
|
7728
7839
|
.then((httpResponse) => {
|
|
7729
|
-
return httpResponse.json()
|
|
7840
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
7841
|
+
const response = jsonResponse;
|
|
7842
|
+
response.sdkHttpResponse = {
|
|
7843
|
+
headers: httpResponse.headers,
|
|
7844
|
+
};
|
|
7845
|
+
return response;
|
|
7846
|
+
});
|
|
7730
7847
|
});
|
|
7731
|
-
return response.then(() => {
|
|
7732
|
-
const resp = deleteFileResponseFromMldev();
|
|
7848
|
+
return response.then((apiResponse) => {
|
|
7849
|
+
const resp = deleteFileResponseFromMldev(apiResponse);
|
|
7733
7850
|
const typedResp = new DeleteFileResponse();
|
|
7734
7851
|
Object.assign(typedResp, resp);
|
|
7735
7852
|
return typedResp;
|
|
@@ -11032,6 +11149,21 @@ function imageToMldev(fromObject) {
|
|
|
11032
11149
|
}
|
|
11033
11150
|
return toObject;
|
|
11034
11151
|
}
|
|
11152
|
+
function generateVideosSourceToMldev(fromObject, parentObject) {
|
|
11153
|
+
const toObject = {};
|
|
11154
|
+
const fromPrompt = getValueByPath(fromObject, ['prompt']);
|
|
11155
|
+
if (parentObject !== undefined && fromPrompt != null) {
|
|
11156
|
+
setValueByPath(parentObject, ['instances[0]', 'prompt'], fromPrompt);
|
|
11157
|
+
}
|
|
11158
|
+
const fromImage = getValueByPath(fromObject, ['image']);
|
|
11159
|
+
if (parentObject !== undefined && fromImage != null) {
|
|
11160
|
+
setValueByPath(parentObject, ['instances[0]', 'image'], imageToMldev(fromImage));
|
|
11161
|
+
}
|
|
11162
|
+
if (getValueByPath(fromObject, ['video']) !== undefined) {
|
|
11163
|
+
throw new Error('video parameter is not supported in Gemini API.');
|
|
11164
|
+
}
|
|
11165
|
+
return toObject;
|
|
11166
|
+
}
|
|
11035
11167
|
function generateVideosConfigToMldev(fromObject, parentObject) {
|
|
11036
11168
|
const toObject = {};
|
|
11037
11169
|
const fromNumberOfVideos = getValueByPath(fromObject, [
|
|
@@ -11089,6 +11221,9 @@ function generateVideosConfigToMldev(fromObject, parentObject) {
|
|
|
11089
11221
|
if (getValueByPath(fromObject, ['lastFrame']) !== undefined) {
|
|
11090
11222
|
throw new Error('lastFrame parameter is not supported in Gemini API.');
|
|
11091
11223
|
}
|
|
11224
|
+
if (getValueByPath(fromObject, ['referenceImages']) !== undefined) {
|
|
11225
|
+
throw new Error('referenceImages parameter is not supported in Gemini API.');
|
|
11226
|
+
}
|
|
11092
11227
|
if (getValueByPath(fromObject, ['compressionQuality']) !== undefined) {
|
|
11093
11228
|
throw new Error('compressionQuality parameter is not supported in Gemini API.');
|
|
11094
11229
|
}
|
|
@@ -11111,6 +11246,10 @@ function generateVideosParametersToMldev(apiClient, fromObject) {
|
|
|
11111
11246
|
if (getValueByPath(fromObject, ['video']) !== undefined) {
|
|
11112
11247
|
throw new Error('video parameter is not supported in Gemini API.');
|
|
11113
11248
|
}
|
|
11249
|
+
const fromSource = getValueByPath(fromObject, ['source']);
|
|
11250
|
+
if (fromSource != null) {
|
|
11251
|
+
setValueByPath(toObject, ['config'], generateVideosSourceToMldev(fromSource, toObject));
|
|
11252
|
+
}
|
|
11114
11253
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
11115
11254
|
if (fromConfig != null) {
|
|
11116
11255
|
setValueByPath(toObject, ['config'], generateVideosConfigToMldev(fromConfig, toObject));
|
|
@@ -12235,6 +12374,10 @@ function editImageParametersInternalToVertex(apiClient, fromObject) {
|
|
|
12235
12374
|
}
|
|
12236
12375
|
function upscaleImageAPIConfigInternalToVertex(fromObject, parentObject) {
|
|
12237
12376
|
const toObject = {};
|
|
12377
|
+
const fromOutputGcsUri = getValueByPath(fromObject, ['outputGcsUri']);
|
|
12378
|
+
if (parentObject !== undefined && fromOutputGcsUri != null) {
|
|
12379
|
+
setValueByPath(parentObject, ['parameters', 'storageUri'], fromOutputGcsUri);
|
|
12380
|
+
}
|
|
12238
12381
|
const fromIncludeRaiReason = getValueByPath(fromObject, [
|
|
12239
12382
|
'includeRaiReason',
|
|
12240
12383
|
]);
|
|
@@ -12363,6 +12506,10 @@ function recontextImageConfigToVertex(fromObject, parentObject) {
|
|
|
12363
12506
|
if (parentObject !== undefined && fromPersonGeneration != null) {
|
|
12364
12507
|
setValueByPath(parentObject, ['parameters', 'personGeneration'], fromPersonGeneration);
|
|
12365
12508
|
}
|
|
12509
|
+
const fromAddWatermark = getValueByPath(fromObject, ['addWatermark']);
|
|
12510
|
+
if (parentObject !== undefined && fromAddWatermark != null) {
|
|
12511
|
+
setValueByPath(parentObject, ['parameters', 'addWatermark'], fromAddWatermark);
|
|
12512
|
+
}
|
|
12366
12513
|
const fromOutputMimeType = getValueByPath(fromObject, [
|
|
12367
12514
|
'outputMimeType',
|
|
12368
12515
|
]);
|
|
@@ -12399,6 +12546,78 @@ function recontextImageParametersToVertex(apiClient, fromObject) {
|
|
|
12399
12546
|
}
|
|
12400
12547
|
return toObject;
|
|
12401
12548
|
}
|
|
12549
|
+
function scribbleImageToVertex(fromObject) {
|
|
12550
|
+
const toObject = {};
|
|
12551
|
+
const fromImage = getValueByPath(fromObject, ['image']);
|
|
12552
|
+
if (fromImage != null) {
|
|
12553
|
+
setValueByPath(toObject, ['image'], imageToVertex(fromImage));
|
|
12554
|
+
}
|
|
12555
|
+
return toObject;
|
|
12556
|
+
}
|
|
12557
|
+
function segmentImageSourceToVertex(fromObject, parentObject) {
|
|
12558
|
+
const toObject = {};
|
|
12559
|
+
const fromPrompt = getValueByPath(fromObject, ['prompt']);
|
|
12560
|
+
if (parentObject !== undefined && fromPrompt != null) {
|
|
12561
|
+
setValueByPath(parentObject, ['instances[0]', 'prompt'], fromPrompt);
|
|
12562
|
+
}
|
|
12563
|
+
const fromImage = getValueByPath(fromObject, ['image']);
|
|
12564
|
+
if (parentObject !== undefined && fromImage != null) {
|
|
12565
|
+
setValueByPath(parentObject, ['instances[0]', 'image'], imageToVertex(fromImage));
|
|
12566
|
+
}
|
|
12567
|
+
const fromScribbleImage = getValueByPath(fromObject, [
|
|
12568
|
+
'scribbleImage',
|
|
12569
|
+
]);
|
|
12570
|
+
if (parentObject !== undefined && fromScribbleImage != null) {
|
|
12571
|
+
setValueByPath(parentObject, ['instances[0]', 'scribble'], scribbleImageToVertex(fromScribbleImage));
|
|
12572
|
+
}
|
|
12573
|
+
return toObject;
|
|
12574
|
+
}
|
|
12575
|
+
function segmentImageConfigToVertex(fromObject, parentObject) {
|
|
12576
|
+
const toObject = {};
|
|
12577
|
+
const fromMode = getValueByPath(fromObject, ['mode']);
|
|
12578
|
+
if (parentObject !== undefined && fromMode != null) {
|
|
12579
|
+
setValueByPath(parentObject, ['parameters', 'mode'], fromMode);
|
|
12580
|
+
}
|
|
12581
|
+
const fromMaxPredictions = getValueByPath(fromObject, [
|
|
12582
|
+
'maxPredictions',
|
|
12583
|
+
]);
|
|
12584
|
+
if (parentObject !== undefined && fromMaxPredictions != null) {
|
|
12585
|
+
setValueByPath(parentObject, ['parameters', 'maxPredictions'], fromMaxPredictions);
|
|
12586
|
+
}
|
|
12587
|
+
const fromConfidenceThreshold = getValueByPath(fromObject, [
|
|
12588
|
+
'confidenceThreshold',
|
|
12589
|
+
]);
|
|
12590
|
+
if (parentObject !== undefined && fromConfidenceThreshold != null) {
|
|
12591
|
+
setValueByPath(parentObject, ['parameters', 'confidenceThreshold'], fromConfidenceThreshold);
|
|
12592
|
+
}
|
|
12593
|
+
const fromMaskDilation = getValueByPath(fromObject, ['maskDilation']);
|
|
12594
|
+
if (parentObject !== undefined && fromMaskDilation != null) {
|
|
12595
|
+
setValueByPath(parentObject, ['parameters', 'maskDilation'], fromMaskDilation);
|
|
12596
|
+
}
|
|
12597
|
+
const fromBinaryColorThreshold = getValueByPath(fromObject, [
|
|
12598
|
+
'binaryColorThreshold',
|
|
12599
|
+
]);
|
|
12600
|
+
if (parentObject !== undefined && fromBinaryColorThreshold != null) {
|
|
12601
|
+
setValueByPath(parentObject, ['parameters', 'binaryColorThreshold'], fromBinaryColorThreshold);
|
|
12602
|
+
}
|
|
12603
|
+
return toObject;
|
|
12604
|
+
}
|
|
12605
|
+
function segmentImageParametersToVertex(apiClient, fromObject) {
|
|
12606
|
+
const toObject = {};
|
|
12607
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
12608
|
+
if (fromModel != null) {
|
|
12609
|
+
setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
|
|
12610
|
+
}
|
|
12611
|
+
const fromSource = getValueByPath(fromObject, ['source']);
|
|
12612
|
+
if (fromSource != null) {
|
|
12613
|
+
setValueByPath(toObject, ['config'], segmentImageSourceToVertex(fromSource, toObject));
|
|
12614
|
+
}
|
|
12615
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
12616
|
+
if (fromConfig != null) {
|
|
12617
|
+
setValueByPath(toObject, ['config'], segmentImageConfigToVertex(fromConfig, toObject));
|
|
12618
|
+
}
|
|
12619
|
+
return toObject;
|
|
12620
|
+
}
|
|
12402
12621
|
function getModelParametersToVertex(apiClient, fromObject) {
|
|
12403
12622
|
const toObject = {};
|
|
12404
12623
|
const fromModel = getValueByPath(fromObject, ['model']);
|
|
@@ -12567,6 +12786,36 @@ function videoToVertex(fromObject) {
|
|
|
12567
12786
|
}
|
|
12568
12787
|
return toObject;
|
|
12569
12788
|
}
|
|
12789
|
+
function generateVideosSourceToVertex(fromObject, parentObject) {
|
|
12790
|
+
const toObject = {};
|
|
12791
|
+
const fromPrompt = getValueByPath(fromObject, ['prompt']);
|
|
12792
|
+
if (parentObject !== undefined && fromPrompt != null) {
|
|
12793
|
+
setValueByPath(parentObject, ['instances[0]', 'prompt'], fromPrompt);
|
|
12794
|
+
}
|
|
12795
|
+
const fromImage = getValueByPath(fromObject, ['image']);
|
|
12796
|
+
if (parentObject !== undefined && fromImage != null) {
|
|
12797
|
+
setValueByPath(parentObject, ['instances[0]', 'image'], imageToVertex(fromImage));
|
|
12798
|
+
}
|
|
12799
|
+
const fromVideo = getValueByPath(fromObject, ['video']);
|
|
12800
|
+
if (parentObject !== undefined && fromVideo != null) {
|
|
12801
|
+
setValueByPath(parentObject, ['instances[0]', 'video'], videoToVertex(fromVideo));
|
|
12802
|
+
}
|
|
12803
|
+
return toObject;
|
|
12804
|
+
}
|
|
12805
|
+
function videoGenerationReferenceImageToVertex(fromObject) {
|
|
12806
|
+
const toObject = {};
|
|
12807
|
+
const fromImage = getValueByPath(fromObject, ['image']);
|
|
12808
|
+
if (fromImage != null) {
|
|
12809
|
+
setValueByPath(toObject, ['image'], imageToVertex(fromImage));
|
|
12810
|
+
}
|
|
12811
|
+
const fromReferenceType = getValueByPath(fromObject, [
|
|
12812
|
+
'referenceType',
|
|
12813
|
+
]);
|
|
12814
|
+
if (fromReferenceType != null) {
|
|
12815
|
+
setValueByPath(toObject, ['referenceType'], fromReferenceType);
|
|
12816
|
+
}
|
|
12817
|
+
return toObject;
|
|
12818
|
+
}
|
|
12570
12819
|
function generateVideosConfigToVertex(fromObject, parentObject) {
|
|
12571
12820
|
const toObject = {};
|
|
12572
12821
|
const fromNumberOfVideos = getValueByPath(fromObject, [
|
|
@@ -12633,6 +12882,18 @@ function generateVideosConfigToVertex(fromObject, parentObject) {
|
|
|
12633
12882
|
if (parentObject !== undefined && fromLastFrame != null) {
|
|
12634
12883
|
setValueByPath(parentObject, ['instances[0]', 'lastFrame'], imageToVertex(fromLastFrame));
|
|
12635
12884
|
}
|
|
12885
|
+
const fromReferenceImages = getValueByPath(fromObject, [
|
|
12886
|
+
'referenceImages',
|
|
12887
|
+
]);
|
|
12888
|
+
if (parentObject !== undefined && fromReferenceImages != null) {
|
|
12889
|
+
let transformedList = fromReferenceImages;
|
|
12890
|
+
if (Array.isArray(transformedList)) {
|
|
12891
|
+
transformedList = transformedList.map((item) => {
|
|
12892
|
+
return videoGenerationReferenceImageToVertex(item);
|
|
12893
|
+
});
|
|
12894
|
+
}
|
|
12895
|
+
setValueByPath(parentObject, ['instances[0]', 'referenceImages'], transformedList);
|
|
12896
|
+
}
|
|
12636
12897
|
const fromCompressionQuality = getValueByPath(fromObject, [
|
|
12637
12898
|
'compressionQuality',
|
|
12638
12899
|
]);
|
|
@@ -12659,6 +12920,10 @@ function generateVideosParametersToVertex(apiClient, fromObject) {
|
|
|
12659
12920
|
if (fromVideo != null) {
|
|
12660
12921
|
setValueByPath(toObject, ['instances[0]', 'video'], videoToVertex(fromVideo));
|
|
12661
12922
|
}
|
|
12923
|
+
const fromSource = getValueByPath(fromObject, ['source']);
|
|
12924
|
+
if (fromSource != null) {
|
|
12925
|
+
setValueByPath(toObject, ['config'], generateVideosSourceToVertex(fromSource, toObject));
|
|
12926
|
+
}
|
|
12662
12927
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
12663
12928
|
if (fromConfig != null) {
|
|
12664
12929
|
setValueByPath(toObject, ['config'], generateVideosConfigToVertex(fromConfig, toObject));
|
|
@@ -13109,8 +13374,14 @@ function listModelsResponseFromMldev(fromObject) {
|
|
|
13109
13374
|
}
|
|
13110
13375
|
return toObject;
|
|
13111
13376
|
}
|
|
13112
|
-
function deleteModelResponseFromMldev() {
|
|
13377
|
+
function deleteModelResponseFromMldev(fromObject) {
|
|
13113
13378
|
const toObject = {};
|
|
13379
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
13380
|
+
'sdkHttpResponse',
|
|
13381
|
+
]);
|
|
13382
|
+
if (fromSdkHttpResponse != null) {
|
|
13383
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
13384
|
+
}
|
|
13114
13385
|
return toObject;
|
|
13115
13386
|
}
|
|
13116
13387
|
function countTokensResponseFromMldev(fromObject) {
|
|
@@ -13682,6 +13953,50 @@ function recontextImageResponseFromVertex(fromObject) {
|
|
|
13682
13953
|
}
|
|
13683
13954
|
return toObject;
|
|
13684
13955
|
}
|
|
13956
|
+
function entityLabelFromVertex(fromObject) {
|
|
13957
|
+
const toObject = {};
|
|
13958
|
+
const fromLabel = getValueByPath(fromObject, ['label']);
|
|
13959
|
+
if (fromLabel != null) {
|
|
13960
|
+
setValueByPath(toObject, ['label'], fromLabel);
|
|
13961
|
+
}
|
|
13962
|
+
const fromScore = getValueByPath(fromObject, ['score']);
|
|
13963
|
+
if (fromScore != null) {
|
|
13964
|
+
setValueByPath(toObject, ['score'], fromScore);
|
|
13965
|
+
}
|
|
13966
|
+
return toObject;
|
|
13967
|
+
}
|
|
13968
|
+
function generatedImageMaskFromVertex(fromObject) {
|
|
13969
|
+
const toObject = {};
|
|
13970
|
+
const fromMask = getValueByPath(fromObject, ['_self']);
|
|
13971
|
+
if (fromMask != null) {
|
|
13972
|
+
setValueByPath(toObject, ['mask'], imageFromVertex(fromMask));
|
|
13973
|
+
}
|
|
13974
|
+
const fromLabels = getValueByPath(fromObject, ['labels']);
|
|
13975
|
+
if (fromLabels != null) {
|
|
13976
|
+
let transformedList = fromLabels;
|
|
13977
|
+
if (Array.isArray(transformedList)) {
|
|
13978
|
+
transformedList = transformedList.map((item) => {
|
|
13979
|
+
return entityLabelFromVertex(item);
|
|
13980
|
+
});
|
|
13981
|
+
}
|
|
13982
|
+
setValueByPath(toObject, ['labels'], transformedList);
|
|
13983
|
+
}
|
|
13984
|
+
return toObject;
|
|
13985
|
+
}
|
|
13986
|
+
function segmentImageResponseFromVertex(fromObject) {
|
|
13987
|
+
const toObject = {};
|
|
13988
|
+
const fromGeneratedMasks = getValueByPath(fromObject, ['predictions']);
|
|
13989
|
+
if (fromGeneratedMasks != null) {
|
|
13990
|
+
let transformedList = fromGeneratedMasks;
|
|
13991
|
+
if (Array.isArray(transformedList)) {
|
|
13992
|
+
transformedList = transformedList.map((item) => {
|
|
13993
|
+
return generatedImageMaskFromVertex(item);
|
|
13994
|
+
});
|
|
13995
|
+
}
|
|
13996
|
+
setValueByPath(toObject, ['generatedMasks'], transformedList);
|
|
13997
|
+
}
|
|
13998
|
+
return toObject;
|
|
13999
|
+
}
|
|
13685
14000
|
function endpointFromVertex(fromObject) {
|
|
13686
14001
|
const toObject = {};
|
|
13687
14002
|
const fromName = getValueByPath(fromObject, ['endpoint']);
|
|
@@ -13811,8 +14126,14 @@ function listModelsResponseFromVertex(fromObject) {
|
|
|
13811
14126
|
}
|
|
13812
14127
|
return toObject;
|
|
13813
14128
|
}
|
|
13814
|
-
function deleteModelResponseFromVertex() {
|
|
14129
|
+
function deleteModelResponseFromVertex(fromObject) {
|
|
13815
14130
|
const toObject = {};
|
|
14131
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
14132
|
+
'sdkHttpResponse',
|
|
14133
|
+
]);
|
|
14134
|
+
if (fromSdkHttpResponse != null) {
|
|
14135
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
14136
|
+
}
|
|
13816
14137
|
return toObject;
|
|
13817
14138
|
}
|
|
13818
14139
|
function countTokensResponseFromVertex(fromObject) {
|
|
@@ -15127,7 +15448,9 @@ class Models extends BaseModule {
|
|
|
15127
15448
|
* ```ts
|
|
15128
15449
|
* const operation = await ai.models.generateVideos({
|
|
15129
15450
|
* model: 'veo-2.0-generate-001',
|
|
15130
|
-
*
|
|
15451
|
+
* source: {
|
|
15452
|
+
* prompt: 'A neon hologram of a cat driving at top speed',
|
|
15453
|
+
* },
|
|
15131
15454
|
* config: {
|
|
15132
15455
|
* numberOfVideos: 1
|
|
15133
15456
|
* });
|
|
@@ -15141,6 +15464,9 @@ class Models extends BaseModule {
|
|
|
15141
15464
|
* ```
|
|
15142
15465
|
*/
|
|
15143
15466
|
this.generateVideos = async (params) => {
|
|
15467
|
+
if ((params.prompt || params.image || params.video) && params.source) {
|
|
15468
|
+
throw new Error('Source and prompt/image/video are mutually exclusive. Please only use source.');
|
|
15469
|
+
}
|
|
15144
15470
|
return await this.generateVideosInternal(params);
|
|
15145
15471
|
};
|
|
15146
15472
|
}
|
|
@@ -15798,6 +16124,61 @@ class Models extends BaseModule {
|
|
|
15798
16124
|
throw new Error('This method is only supported by the Vertex AI.');
|
|
15799
16125
|
}
|
|
15800
16126
|
}
|
|
16127
|
+
/**
|
|
16128
|
+
* Segments an image, creating a mask of a specified area.
|
|
16129
|
+
*
|
|
16130
|
+
* @param params - The parameters for segmenting an image.
|
|
16131
|
+
* @return The response from the API.
|
|
16132
|
+
*
|
|
16133
|
+
* @example
|
|
16134
|
+
* ```ts
|
|
16135
|
+
* const response = await ai.models.segmentImage({
|
|
16136
|
+
* model: 'image-segmentation-001',
|
|
16137
|
+
* source: {
|
|
16138
|
+
* image: image,
|
|
16139
|
+
* },
|
|
16140
|
+
* config: {
|
|
16141
|
+
* mode: 'foreground',
|
|
16142
|
+
* },
|
|
16143
|
+
* });
|
|
16144
|
+
* console.log(response?.generatedMasks?.[0]?.mask?.imageBytes);
|
|
16145
|
+
* ```
|
|
16146
|
+
*/
|
|
16147
|
+
async segmentImage(params) {
|
|
16148
|
+
var _a, _b;
|
|
16149
|
+
let response;
|
|
16150
|
+
let path = '';
|
|
16151
|
+
let queryParams = {};
|
|
16152
|
+
if (this.apiClient.isVertexAI()) {
|
|
16153
|
+
const body = segmentImageParametersToVertex(this.apiClient, params);
|
|
16154
|
+
path = formatMap('{model}:predict', body['_url']);
|
|
16155
|
+
queryParams = body['_query'];
|
|
16156
|
+
delete body['config'];
|
|
16157
|
+
delete body['_url'];
|
|
16158
|
+
delete body['_query'];
|
|
16159
|
+
response = this.apiClient
|
|
16160
|
+
.request({
|
|
16161
|
+
path: path,
|
|
16162
|
+
queryParams: queryParams,
|
|
16163
|
+
body: JSON.stringify(body),
|
|
16164
|
+
httpMethod: 'POST',
|
|
16165
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
16166
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
16167
|
+
})
|
|
16168
|
+
.then((httpResponse) => {
|
|
16169
|
+
return httpResponse.json();
|
|
16170
|
+
});
|
|
16171
|
+
return response.then((apiResponse) => {
|
|
16172
|
+
const resp = segmentImageResponseFromVertex(apiResponse);
|
|
16173
|
+
const typedResp = new SegmentImageResponse();
|
|
16174
|
+
Object.assign(typedResp, resp);
|
|
16175
|
+
return typedResp;
|
|
16176
|
+
});
|
|
16177
|
+
}
|
|
16178
|
+
else {
|
|
16179
|
+
throw new Error('This method is only supported by the Vertex AI.');
|
|
16180
|
+
}
|
|
16181
|
+
}
|
|
15801
16182
|
/**
|
|
15802
16183
|
* Fetches information about a model by name.
|
|
15803
16184
|
*
|
|
@@ -16034,10 +16415,16 @@ class Models extends BaseModule {
|
|
|
16034
16415
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
16035
16416
|
})
|
|
16036
16417
|
.then((httpResponse) => {
|
|
16037
|
-
return httpResponse.json()
|
|
16418
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
16419
|
+
const response = jsonResponse;
|
|
16420
|
+
response.sdkHttpResponse = {
|
|
16421
|
+
headers: httpResponse.headers,
|
|
16422
|
+
};
|
|
16423
|
+
return response;
|
|
16424
|
+
});
|
|
16038
16425
|
});
|
|
16039
|
-
return response.then(() => {
|
|
16040
|
-
const resp = deleteModelResponseFromVertex();
|
|
16426
|
+
return response.then((apiResponse) => {
|
|
16427
|
+
const resp = deleteModelResponseFromVertex(apiResponse);
|
|
16041
16428
|
const typedResp = new DeleteModelResponse();
|
|
16042
16429
|
Object.assign(typedResp, resp);
|
|
16043
16430
|
return typedResp;
|
|
@@ -16060,10 +16447,16 @@ class Models extends BaseModule {
|
|
|
16060
16447
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
16061
16448
|
})
|
|
16062
16449
|
.then((httpResponse) => {
|
|
16063
|
-
return httpResponse.json()
|
|
16450
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
16451
|
+
const response = jsonResponse;
|
|
16452
|
+
response.sdkHttpResponse = {
|
|
16453
|
+
headers: httpResponse.headers,
|
|
16454
|
+
};
|
|
16455
|
+
return response;
|
|
16456
|
+
});
|
|
16064
16457
|
});
|
|
16065
|
-
return response.then(() => {
|
|
16066
|
-
const resp = deleteModelResponseFromMldev();
|
|
16458
|
+
return response.then((apiResponse) => {
|
|
16459
|
+
const resp = deleteModelResponseFromMldev(apiResponse);
|
|
16067
16460
|
const typedResp = new DeleteModelResponse();
|
|
16068
16461
|
Object.assign(typedResp, resp);
|
|
16069
16462
|
return typedResp;
|
|
@@ -16318,13 +16711,17 @@ function getOperationParametersToMldev(fromObject) {
|
|
|
16318
16711
|
}
|
|
16319
16712
|
return toObject;
|
|
16320
16713
|
}
|
|
16321
|
-
function
|
|
16714
|
+
function fetchPredictOperationParametersToVertex(fromObject) {
|
|
16322
16715
|
const toObject = {};
|
|
16323
16716
|
const fromOperationName = getValueByPath(fromObject, [
|
|
16324
16717
|
'operationName',
|
|
16325
16718
|
]);
|
|
16326
16719
|
if (fromOperationName != null) {
|
|
16327
|
-
setValueByPath(toObject, ['
|
|
16720
|
+
setValueByPath(toObject, ['operationName'], fromOperationName);
|
|
16721
|
+
}
|
|
16722
|
+
const fromResourceName = getValueByPath(fromObject, ['resourceName']);
|
|
16723
|
+
if (fromResourceName != null) {
|
|
16724
|
+
setValueByPath(toObject, ['_url', 'resourceName'], fromResourceName);
|
|
16328
16725
|
}
|
|
16329
16726
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
16330
16727
|
if (fromConfig != null) {
|
|
@@ -16332,17 +16729,13 @@ function getOperationParametersToVertex(fromObject) {
|
|
|
16332
16729
|
}
|
|
16333
16730
|
return toObject;
|
|
16334
16731
|
}
|
|
16335
|
-
function
|
|
16732
|
+
function getOperationParametersToVertex(fromObject) {
|
|
16336
16733
|
const toObject = {};
|
|
16337
16734
|
const fromOperationName = getValueByPath(fromObject, [
|
|
16338
16735
|
'operationName',
|
|
16339
16736
|
]);
|
|
16340
16737
|
if (fromOperationName != null) {
|
|
16341
|
-
setValueByPath(toObject, ['operationName'], fromOperationName);
|
|
16342
|
-
}
|
|
16343
|
-
const fromResourceName = getValueByPath(fromObject, ['resourceName']);
|
|
16344
|
-
if (fromResourceName != null) {
|
|
16345
|
-
setValueByPath(toObject, ['_url', 'resourceName'], fromResourceName);
|
|
16738
|
+
setValueByPath(toObject, ['_url', 'operationName'], fromOperationName);
|
|
16346
16739
|
}
|
|
16347
16740
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
16348
16741
|
if (fromConfig != null) {
|
|
@@ -17429,6 +17822,18 @@ function listTuningJobsParametersToMldev(fromObject) {
|
|
|
17429
17822
|
}
|
|
17430
17823
|
return toObject;
|
|
17431
17824
|
}
|
|
17825
|
+
function cancelTuningJobParametersToMldev(fromObject) {
|
|
17826
|
+
const toObject = {};
|
|
17827
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
17828
|
+
if (fromName != null) {
|
|
17829
|
+
setValueByPath(toObject, ['_url', 'name'], fromName);
|
|
17830
|
+
}
|
|
17831
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
17832
|
+
if (fromConfig != null) {
|
|
17833
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
17834
|
+
}
|
|
17835
|
+
return toObject;
|
|
17836
|
+
}
|
|
17432
17837
|
function tuningExampleToMldev(fromObject) {
|
|
17433
17838
|
const toObject = {};
|
|
17434
17839
|
const fromTextInput = getValueByPath(fromObject, ['textInput']);
|
|
@@ -17566,6 +17971,18 @@ function listTuningJobsParametersToVertex(fromObject) {
|
|
|
17566
17971
|
}
|
|
17567
17972
|
return toObject;
|
|
17568
17973
|
}
|
|
17974
|
+
function cancelTuningJobParametersToVertex(fromObject) {
|
|
17975
|
+
const toObject = {};
|
|
17976
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
17977
|
+
if (fromName != null) {
|
|
17978
|
+
setValueByPath(toObject, ['_url', 'name'], fromName);
|
|
17979
|
+
}
|
|
17980
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
17981
|
+
if (fromConfig != null) {
|
|
17982
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
17983
|
+
}
|
|
17984
|
+
return toObject;
|
|
17985
|
+
}
|
|
17569
17986
|
function tuningDatasetToVertex(fromObject, parentObject) {
|
|
17570
17987
|
const toObject = {};
|
|
17571
17988
|
const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
|
|
@@ -18219,6 +18636,54 @@ class Tunings extends BaseModule {
|
|
|
18219
18636
|
});
|
|
18220
18637
|
}
|
|
18221
18638
|
}
|
|
18639
|
+
/**
|
|
18640
|
+
* Cancels a tuning job.
|
|
18641
|
+
*
|
|
18642
|
+
* @param params - The parameters for the cancel request.
|
|
18643
|
+
* @return The empty response returned by the API.
|
|
18644
|
+
*
|
|
18645
|
+
* @example
|
|
18646
|
+
* ```ts
|
|
18647
|
+
* await ai.tunings.cancel({name: '...'}); // The server-generated resource name.
|
|
18648
|
+
* ```
|
|
18649
|
+
*/
|
|
18650
|
+
async cancel(params) {
|
|
18651
|
+
var _a, _b, _c, _d;
|
|
18652
|
+
let path = '';
|
|
18653
|
+
let queryParams = {};
|
|
18654
|
+
if (this.apiClient.isVertexAI()) {
|
|
18655
|
+
const body = cancelTuningJobParametersToVertex(params);
|
|
18656
|
+
path = formatMap('{name}:cancel', body['_url']);
|
|
18657
|
+
queryParams = body['_query'];
|
|
18658
|
+
delete body['config'];
|
|
18659
|
+
delete body['_url'];
|
|
18660
|
+
delete body['_query'];
|
|
18661
|
+
await this.apiClient.request({
|
|
18662
|
+
path: path,
|
|
18663
|
+
queryParams: queryParams,
|
|
18664
|
+
body: JSON.stringify(body),
|
|
18665
|
+
httpMethod: 'POST',
|
|
18666
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
18667
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
18668
|
+
});
|
|
18669
|
+
}
|
|
18670
|
+
else {
|
|
18671
|
+
const body = cancelTuningJobParametersToMldev(params);
|
|
18672
|
+
path = formatMap('{name}:cancel', body['_url']);
|
|
18673
|
+
queryParams = body['_query'];
|
|
18674
|
+
delete body['config'];
|
|
18675
|
+
delete body['_url'];
|
|
18676
|
+
delete body['_query'];
|
|
18677
|
+
await this.apiClient.request({
|
|
18678
|
+
path: path,
|
|
18679
|
+
queryParams: queryParams,
|
|
18680
|
+
body: JSON.stringify(body),
|
|
18681
|
+
httpMethod: 'POST',
|
|
18682
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
18683
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
18684
|
+
});
|
|
18685
|
+
}
|
|
18686
|
+
}
|
|
18222
18687
|
async tuneInternal(params) {
|
|
18223
18688
|
var _a, _b;
|
|
18224
18689
|
let response;
|
|
@@ -18394,5 +18859,5 @@ class GoogleGenAI {
|
|
|
18394
18859
|
}
|
|
18395
18860
|
}
|
|
18396
18861
|
|
|
18397
|
-
export { ActivityHandling, AdapterSize, ApiError, ApiSpec, AuthType, Batches, Behavior, BlockedReason, Caches, Chat, Chats, ComputeTokensResponse, ControlReferenceImage, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DeleteModelResponse, DynamicRetrievalConfigMode, EditImageResponse, EditMode, EmbedContentResponse, EndSensitivity, Environment, FeatureSelectionPreference, FileSource, FileState, Files, FinishReason, FunctionCallingConfigMode, FunctionResponse, FunctionResponseScheduling, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GenerateVideosOperation, GenerateVideosResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpResponse, ImagePromptLanguage, InlinedResponse, JobState, Language, ListBatchJobsResponse, ListCachedContentsResponse, ListFilesResponse, ListModelsResponse, ListTuningJobsResponse, Live, LiveClientToolResponse, LiveMusicPlaybackControl, LiveMusicServerMessage, LiveSendToolResponseParameters, LiveServerMessage, MaskReferenceImage, MaskReferenceMode, MediaModality, MediaResolution, Modality, Mode, Models, MusicGenerationMode, Operations, Outcome, PagedItem, Pager, PersonGeneration, RawReferenceImage, RecontextImageResponse, ReplayResponse, SafetyFilterLevel, Scale, Session, StartSensitivity, StyleReferenceImage, SubjectReferenceImage, SubjectReferenceType, Tokens, TrafficType, TuningMode, TurnCoverage, Type, UpscaleImageResponse, UrlRetrievalStatus, VideoCompressionQuality, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent, mcpToTool, setDefaultBaseUrls };
|
|
18862
|
+
export { ActivityHandling, AdapterSize, ApiError, ApiSpec, AuthType, Batches, Behavior, BlockedReason, Caches, Chat, Chats, ComputeTokensResponse, ControlReferenceImage, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DeleteModelResponse, DynamicRetrievalConfigMode, EditImageResponse, EditMode, EmbedContentResponse, EndSensitivity, Environment, FeatureSelectionPreference, FileSource, FileState, Files, FinishReason, FunctionCallingConfigMode, FunctionResponse, FunctionResponseScheduling, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GenerateVideosOperation, GenerateVideosResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpResponse, ImagePromptLanguage, InlinedResponse, JobState, Language, ListBatchJobsResponse, ListCachedContentsResponse, ListFilesResponse, ListModelsResponse, ListTuningJobsResponse, Live, LiveClientToolResponse, LiveMusicPlaybackControl, LiveMusicServerMessage, LiveSendToolResponseParameters, LiveServerMessage, MaskReferenceImage, MaskReferenceMode, MediaModality, MediaResolution, Modality, Mode, Models, MusicGenerationMode, Operations, Outcome, PagedItem, Pager, PersonGeneration, RawReferenceImage, RecontextImageResponse, ReplayResponse, SafetyFilterLevel, Scale, SegmentImageResponse, SegmentMode, Session, StartSensitivity, StyleReferenceImage, SubjectReferenceImage, SubjectReferenceType, Tokens, TrafficType, TuningMode, TurnCoverage, Type, UpscaleImageResponse, UrlRetrievalStatus, VideoCompressionQuality, VideoGenerationReferenceType, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent, mcpToTool, setDefaultBaseUrls };
|
|
18398
18863
|
//# sourceMappingURL=index.mjs.map
|