@google/genai 1.14.0 → 1.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -0
- package/dist/genai.d.ts +231 -11
- package/dist/index.cjs +558 -92
- package/dist/index.mjs +558 -93
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.cjs +559 -93
- package/dist/node/index.mjs +559 -94
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/node.d.ts +231 -11
- package/dist/web/index.mjs +558 -93
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +231 -11
- package/package.json +3 -3
package/dist/node/index.mjs
CHANGED
|
@@ -805,6 +805,10 @@ var FunctionCallingConfigMode;
|
|
|
805
805
|
* Model will not predict any function calls. Model behavior is same as when not passing any function declarations.
|
|
806
806
|
*/
|
|
807
807
|
FunctionCallingConfigMode["NONE"] = "NONE";
|
|
808
|
+
/**
|
|
809
|
+
* 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".
|
|
810
|
+
*/
|
|
811
|
+
FunctionCallingConfigMode["VALIDATED"] = "VALIDATED";
|
|
808
812
|
})(FunctionCallingConfigMode || (FunctionCallingConfigMode = {}));
|
|
809
813
|
/** Enum that controls the safety filter level for objectionable content. */
|
|
810
814
|
var SafetyFilterLevel;
|
|
@@ -903,6 +907,30 @@ var EditMode;
|
|
|
903
907
|
EditMode["EDIT_MODE_BGSWAP"] = "EDIT_MODE_BGSWAP";
|
|
904
908
|
EditMode["EDIT_MODE_PRODUCT_IMAGE"] = "EDIT_MODE_PRODUCT_IMAGE";
|
|
905
909
|
})(EditMode || (EditMode = {}));
|
|
910
|
+
/** Enum that represents the segmentation mode. */
|
|
911
|
+
var SegmentMode;
|
|
912
|
+
(function (SegmentMode) {
|
|
913
|
+
SegmentMode["FOREGROUND"] = "FOREGROUND";
|
|
914
|
+
SegmentMode["BACKGROUND"] = "BACKGROUND";
|
|
915
|
+
SegmentMode["PROMPT"] = "PROMPT";
|
|
916
|
+
SegmentMode["SEMANTIC"] = "SEMANTIC";
|
|
917
|
+
SegmentMode["INTERACTIVE"] = "INTERACTIVE";
|
|
918
|
+
})(SegmentMode || (SegmentMode = {}));
|
|
919
|
+
/** Enum for the reference type of a video generation reference image. */
|
|
920
|
+
var VideoGenerationReferenceType;
|
|
921
|
+
(function (VideoGenerationReferenceType) {
|
|
922
|
+
/**
|
|
923
|
+
* A reference image that provides assets to the generated video,
|
|
924
|
+
such as the scene, an object, a character, etc.
|
|
925
|
+
*/
|
|
926
|
+
VideoGenerationReferenceType["ASSET"] = "ASSET";
|
|
927
|
+
/**
|
|
928
|
+
* A reference image that provides aesthetics including colors,
|
|
929
|
+
lighting, texture, etc., to be used as the style of the generated video,
|
|
930
|
+
such as 'anime', 'photography', 'origami', etc.
|
|
931
|
+
*/
|
|
932
|
+
VideoGenerationReferenceType["STYLE"] = "STYLE";
|
|
933
|
+
})(VideoGenerationReferenceType || (VideoGenerationReferenceType = {}));
|
|
906
934
|
/** Enum that controls the compression quality of the generated videos. */
|
|
907
935
|
var VideoCompressionQuality;
|
|
908
936
|
(function (VideoCompressionQuality) {
|
|
@@ -1549,6 +1577,9 @@ class UpscaleImageResponse {
|
|
|
1549
1577
|
/** The output images response. */
|
|
1550
1578
|
class RecontextImageResponse {
|
|
1551
1579
|
}
|
|
1580
|
+
/** The output images response. */
|
|
1581
|
+
class SegmentImageResponse {
|
|
1582
|
+
}
|
|
1552
1583
|
class ListModelsResponse {
|
|
1553
1584
|
}
|
|
1554
1585
|
class DeleteModelResponse {
|
|
@@ -1562,6 +1593,65 @@ class ComputeTokensResponse {
|
|
|
1562
1593
|
/** Response with generated videos. */
|
|
1563
1594
|
class GenerateVideosResponse {
|
|
1564
1595
|
}
|
|
1596
|
+
/** A video generation operation. */
|
|
1597
|
+
class GenerateVideosOperation {
|
|
1598
|
+
/**
|
|
1599
|
+
* Instantiates an Operation of the same type as the one being called with the fields set from the API response.
|
|
1600
|
+
* @internal
|
|
1601
|
+
*/
|
|
1602
|
+
_fromAPIResponse({ apiResponse, isVertexAI, }) {
|
|
1603
|
+
const operation = new GenerateVideosOperation();
|
|
1604
|
+
operation.name = apiResponse['name'];
|
|
1605
|
+
operation.metadata = apiResponse['metadata'];
|
|
1606
|
+
operation.done = apiResponse['done'];
|
|
1607
|
+
operation.error = apiResponse['error'];
|
|
1608
|
+
if (isVertexAI) {
|
|
1609
|
+
const response = apiResponse['response'];
|
|
1610
|
+
if (response) {
|
|
1611
|
+
const operationResponse = new GenerateVideosResponse();
|
|
1612
|
+
const responseVideos = response['videos'];
|
|
1613
|
+
operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
|
|
1614
|
+
return {
|
|
1615
|
+
video: {
|
|
1616
|
+
uri: generatedVideo['gcsUri'],
|
|
1617
|
+
videoBytes: generatedVideo['bytesBase64Encoded']
|
|
1618
|
+
? tBytes$1(generatedVideo['bytesBase64Encoded'])
|
|
1619
|
+
: undefined,
|
|
1620
|
+
mimeType: generatedVideo['mimeType'],
|
|
1621
|
+
},
|
|
1622
|
+
};
|
|
1623
|
+
});
|
|
1624
|
+
operationResponse.raiMediaFilteredCount = response['raiMediaFilteredCount'];
|
|
1625
|
+
operationResponse.raiMediaFilteredReasons = response['raiMediaFilteredReasons'];
|
|
1626
|
+
operation.response = operationResponse;
|
|
1627
|
+
}
|
|
1628
|
+
}
|
|
1629
|
+
else {
|
|
1630
|
+
const response = apiResponse['response'];
|
|
1631
|
+
if (response) {
|
|
1632
|
+
const operationResponse = new GenerateVideosResponse();
|
|
1633
|
+
const generatedVideoResponse = response['generateVideoResponse'];
|
|
1634
|
+
const responseVideos = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['generatedSamples'];
|
|
1635
|
+
operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
|
|
1636
|
+
const video = generatedVideo['video'];
|
|
1637
|
+
return {
|
|
1638
|
+
video: {
|
|
1639
|
+
uri: video === null || video === void 0 ? void 0 : video['uri'],
|
|
1640
|
+
videoBytes: (video === null || video === void 0 ? void 0 : video['encodedVideo'])
|
|
1641
|
+
? tBytes$1(video === null || video === void 0 ? void 0 : video['encodedVideo'])
|
|
1642
|
+
: undefined,
|
|
1643
|
+
mimeType: generatedVideo['encoding'],
|
|
1644
|
+
},
|
|
1645
|
+
};
|
|
1646
|
+
});
|
|
1647
|
+
operationResponse.raiMediaFilteredCount = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredCount'];
|
|
1648
|
+
operationResponse.raiMediaFilteredReasons = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredReasons'];
|
|
1649
|
+
operation.response = operationResponse;
|
|
1650
|
+
}
|
|
1651
|
+
}
|
|
1652
|
+
return operation;
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1565
1655
|
/** Response for the list tuning jobs method. */
|
|
1566
1656
|
class ListTuningJobsResponse {
|
|
1567
1657
|
}
|
|
@@ -1753,65 +1843,6 @@ class LiveServerMessage {
|
|
|
1753
1843
|
return data.length > 0 ? btoa(data) : undefined;
|
|
1754
1844
|
}
|
|
1755
1845
|
}
|
|
1756
|
-
/** A video generation long-running operation. */
|
|
1757
|
-
class GenerateVideosOperation {
|
|
1758
|
-
/**
|
|
1759
|
-
* Instantiates an Operation of the same type as the one being called with the fields set from the API response.
|
|
1760
|
-
* @internal
|
|
1761
|
-
*/
|
|
1762
|
-
_fromAPIResponse({ apiResponse, isVertexAI, }) {
|
|
1763
|
-
const operation = new GenerateVideosOperation();
|
|
1764
|
-
operation.name = apiResponse['name'];
|
|
1765
|
-
operation.metadata = apiResponse['metadata'];
|
|
1766
|
-
operation.done = apiResponse['done'];
|
|
1767
|
-
operation.error = apiResponse['error'];
|
|
1768
|
-
if (isVertexAI) {
|
|
1769
|
-
const response = apiResponse['response'];
|
|
1770
|
-
if (response) {
|
|
1771
|
-
const operationResponse = new GenerateVideosResponse();
|
|
1772
|
-
const responseVideos = response['videos'];
|
|
1773
|
-
operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
|
|
1774
|
-
return {
|
|
1775
|
-
video: {
|
|
1776
|
-
uri: generatedVideo['gcsUri'],
|
|
1777
|
-
videoBytes: generatedVideo['bytesBase64Encoded']
|
|
1778
|
-
? tBytes$1(generatedVideo['bytesBase64Encoded'])
|
|
1779
|
-
: undefined,
|
|
1780
|
-
mimeType: generatedVideo['mimeType'],
|
|
1781
|
-
},
|
|
1782
|
-
};
|
|
1783
|
-
});
|
|
1784
|
-
operationResponse.raiMediaFilteredCount = response['raiMediaFilteredCount'];
|
|
1785
|
-
operationResponse.raiMediaFilteredReasons = response['raiMediaFilteredReasons'];
|
|
1786
|
-
operation.response = operationResponse;
|
|
1787
|
-
}
|
|
1788
|
-
}
|
|
1789
|
-
else {
|
|
1790
|
-
const response = apiResponse['response'];
|
|
1791
|
-
if (response) {
|
|
1792
|
-
const operationResponse = new GenerateVideosResponse();
|
|
1793
|
-
const generatedVideoResponse = response['generateVideoResponse'];
|
|
1794
|
-
const responseVideos = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['generatedSamples'];
|
|
1795
|
-
operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
|
|
1796
|
-
const video = generatedVideo['video'];
|
|
1797
|
-
return {
|
|
1798
|
-
video: {
|
|
1799
|
-
uri: video === null || video === void 0 ? void 0 : video['uri'],
|
|
1800
|
-
videoBytes: (video === null || video === void 0 ? void 0 : video['encodedVideo'])
|
|
1801
|
-
? tBytes$1(video === null || video === void 0 ? void 0 : video['encodedVideo'])
|
|
1802
|
-
: undefined,
|
|
1803
|
-
mimeType: generatedVideo['encoding'],
|
|
1804
|
-
},
|
|
1805
|
-
};
|
|
1806
|
-
});
|
|
1807
|
-
operationResponse.raiMediaFilteredCount = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredCount'];
|
|
1808
|
-
operationResponse.raiMediaFilteredReasons = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredReasons'];
|
|
1809
|
-
operation.response = operationResponse;
|
|
1810
|
-
}
|
|
1811
|
-
}
|
|
1812
|
-
return operation;
|
|
1813
|
-
}
|
|
1814
|
-
}
|
|
1815
1846
|
/** Client generated response to a `ToolCall` received from the server.
|
|
1816
1847
|
|
|
1817
1848
|
Individual `FunctionResponse` objects are matched to the respective
|
|
@@ -2458,6 +2489,9 @@ function mcpToGeminiTool(mcpTool, config = {}) {
|
|
|
2458
2489
|
description: mcpToolSchema['description'],
|
|
2459
2490
|
parametersJsonSchema: mcpToolSchema['inputSchema'],
|
|
2460
2491
|
};
|
|
2492
|
+
if (mcpToolSchema['outputSchema']) {
|
|
2493
|
+
functionDeclaration['responseJsonSchema'] = mcpToolSchema['outputSchema'];
|
|
2494
|
+
}
|
|
2461
2495
|
if (config.behavior) {
|
|
2462
2496
|
functionDeclaration['behavior'] = config.behavior;
|
|
2463
2497
|
}
|
|
@@ -4287,6 +4321,7 @@ class Batches extends BaseModule {
|
|
|
4287
4321
|
* ```
|
|
4288
4322
|
*/
|
|
4289
4323
|
this.create = async (params) => {
|
|
4324
|
+
var _a, _b;
|
|
4290
4325
|
if (this.apiClient.isVertexAI()) {
|
|
4291
4326
|
const timestamp = Date.now();
|
|
4292
4327
|
const timestampStr = timestamp.toString();
|
|
@@ -4311,6 +4346,55 @@ class Batches extends BaseModule {
|
|
|
4311
4346
|
}
|
|
4312
4347
|
}
|
|
4313
4348
|
}
|
|
4349
|
+
else {
|
|
4350
|
+
if (Array.isArray(params.src) ||
|
|
4351
|
+
(typeof params.src !== 'string' && params.src.inlinedRequests)) {
|
|
4352
|
+
// Move system instruction to httpOptions extraBody.
|
|
4353
|
+
let path = '';
|
|
4354
|
+
let queryParams = {};
|
|
4355
|
+
const body = createBatchJobParametersToMldev(this.apiClient, params);
|
|
4356
|
+
path = formatMap('{model}:batchGenerateContent', body['_url']);
|
|
4357
|
+
queryParams = body['_query'];
|
|
4358
|
+
// Move system instruction to 'request':
|
|
4359
|
+
// {'systemInstruction': system_instruction}
|
|
4360
|
+
const batch = body['batch'];
|
|
4361
|
+
const inputConfig = batch['inputConfig'];
|
|
4362
|
+
const requestsWrapper = inputConfig['requests'];
|
|
4363
|
+
const requests = requestsWrapper['requests'];
|
|
4364
|
+
const newRequests = [];
|
|
4365
|
+
for (const request of requests) {
|
|
4366
|
+
const requestDict = request;
|
|
4367
|
+
if (requestDict['systemInstruction']) {
|
|
4368
|
+
const systemInstructionValue = requestDict['systemInstruction'];
|
|
4369
|
+
delete requestDict['systemInstruction'];
|
|
4370
|
+
const requestContent = requestDict['request'];
|
|
4371
|
+
requestContent['systemInstruction'] = systemInstructionValue;
|
|
4372
|
+
requestDict['request'] = requestContent;
|
|
4373
|
+
}
|
|
4374
|
+
newRequests.push(requestDict);
|
|
4375
|
+
}
|
|
4376
|
+
requestsWrapper['requests'] = newRequests;
|
|
4377
|
+
delete body['config'];
|
|
4378
|
+
delete body['_url'];
|
|
4379
|
+
delete body['_query'];
|
|
4380
|
+
const response = this.apiClient
|
|
4381
|
+
.request({
|
|
4382
|
+
path: path,
|
|
4383
|
+
queryParams: queryParams,
|
|
4384
|
+
body: JSON.stringify(body),
|
|
4385
|
+
httpMethod: 'POST',
|
|
4386
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
4387
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
4388
|
+
})
|
|
4389
|
+
.then((httpResponse) => {
|
|
4390
|
+
return httpResponse.json();
|
|
4391
|
+
});
|
|
4392
|
+
return response.then((apiResponse) => {
|
|
4393
|
+
const resp = batchJobFromMldev(apiResponse);
|
|
4394
|
+
return resp;
|
|
4395
|
+
});
|
|
4396
|
+
}
|
|
4397
|
+
}
|
|
4314
4398
|
return await this.createInternal(params);
|
|
4315
4399
|
};
|
|
4316
4400
|
/**
|
|
@@ -5655,8 +5739,14 @@ function cachedContentFromMldev(fromObject) {
|
|
|
5655
5739
|
}
|
|
5656
5740
|
return toObject;
|
|
5657
5741
|
}
|
|
5658
|
-
function deleteCachedContentResponseFromMldev() {
|
|
5742
|
+
function deleteCachedContentResponseFromMldev(fromObject) {
|
|
5659
5743
|
const toObject = {};
|
|
5744
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
5745
|
+
'sdkHttpResponse',
|
|
5746
|
+
]);
|
|
5747
|
+
if (fromSdkHttpResponse != null) {
|
|
5748
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
5749
|
+
}
|
|
5660
5750
|
return toObject;
|
|
5661
5751
|
}
|
|
5662
5752
|
function listCachedContentsResponseFromMldev(fromObject) {
|
|
@@ -5721,8 +5811,14 @@ function cachedContentFromVertex(fromObject) {
|
|
|
5721
5811
|
}
|
|
5722
5812
|
return toObject;
|
|
5723
5813
|
}
|
|
5724
|
-
function deleteCachedContentResponseFromVertex() {
|
|
5814
|
+
function deleteCachedContentResponseFromVertex(fromObject) {
|
|
5725
5815
|
const toObject = {};
|
|
5816
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
5817
|
+
'sdkHttpResponse',
|
|
5818
|
+
]);
|
|
5819
|
+
if (fromSdkHttpResponse != null) {
|
|
5820
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
5821
|
+
}
|
|
5726
5822
|
return toObject;
|
|
5727
5823
|
}
|
|
5728
5824
|
function listCachedContentsResponseFromVertex(fromObject) {
|
|
@@ -5959,10 +6055,16 @@ class Caches extends BaseModule {
|
|
|
5959
6055
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
5960
6056
|
})
|
|
5961
6057
|
.then((httpResponse) => {
|
|
5962
|
-
return httpResponse.json()
|
|
6058
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
6059
|
+
const response = jsonResponse;
|
|
6060
|
+
response.sdkHttpResponse = {
|
|
6061
|
+
headers: httpResponse.headers,
|
|
6062
|
+
};
|
|
6063
|
+
return response;
|
|
6064
|
+
});
|
|
5963
6065
|
});
|
|
5964
|
-
return response.then(() => {
|
|
5965
|
-
const resp = deleteCachedContentResponseFromVertex();
|
|
6066
|
+
return response.then((apiResponse) => {
|
|
6067
|
+
const resp = deleteCachedContentResponseFromVertex(apiResponse);
|
|
5966
6068
|
const typedResp = new DeleteCachedContentResponse();
|
|
5967
6069
|
Object.assign(typedResp, resp);
|
|
5968
6070
|
return typedResp;
|
|
@@ -5985,10 +6087,16 @@ class Caches extends BaseModule {
|
|
|
5985
6087
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
5986
6088
|
})
|
|
5987
6089
|
.then((httpResponse) => {
|
|
5988
|
-
return httpResponse.json()
|
|
6090
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
6091
|
+
const response = jsonResponse;
|
|
6092
|
+
response.sdkHttpResponse = {
|
|
6093
|
+
headers: httpResponse.headers,
|
|
6094
|
+
};
|
|
6095
|
+
return response;
|
|
6096
|
+
});
|
|
5989
6097
|
});
|
|
5990
|
-
return response.then(() => {
|
|
5991
|
-
const resp = deleteCachedContentResponseFromMldev();
|
|
6098
|
+
return response.then((apiResponse) => {
|
|
6099
|
+
const resp = deleteCachedContentResponseFromMldev(apiResponse);
|
|
5992
6100
|
const typedResp = new DeleteCachedContentResponse();
|
|
5993
6101
|
Object.assign(typedResp, resp);
|
|
5994
6102
|
return typedResp;
|
|
@@ -6221,9 +6329,6 @@ function isValidContent(content) {
|
|
|
6221
6329
|
if (part === undefined || Object.keys(part).length === 0) {
|
|
6222
6330
|
return false;
|
|
6223
6331
|
}
|
|
6224
|
-
if (!part.thought && part.text !== undefined && part.text === '') {
|
|
6225
|
-
return false;
|
|
6226
|
-
}
|
|
6227
6332
|
}
|
|
6228
6333
|
return true;
|
|
6229
6334
|
}
|
|
@@ -6795,8 +6900,14 @@ function createFileResponseFromMldev(fromObject) {
|
|
|
6795
6900
|
}
|
|
6796
6901
|
return toObject;
|
|
6797
6902
|
}
|
|
6798
|
-
function deleteFileResponseFromMldev() {
|
|
6903
|
+
function deleteFileResponseFromMldev(fromObject) {
|
|
6799
6904
|
const toObject = {};
|
|
6905
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
6906
|
+
'sdkHttpResponse',
|
|
6907
|
+
]);
|
|
6908
|
+
if (fromSdkHttpResponse != null) {
|
|
6909
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
6910
|
+
}
|
|
6800
6911
|
return toObject;
|
|
6801
6912
|
}
|
|
6802
6913
|
|
|
@@ -7065,10 +7176,16 @@ class Files extends BaseModule {
|
|
|
7065
7176
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
7066
7177
|
})
|
|
7067
7178
|
.then((httpResponse) => {
|
|
7068
|
-
return httpResponse.json()
|
|
7179
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
7180
|
+
const response = jsonResponse;
|
|
7181
|
+
response.sdkHttpResponse = {
|
|
7182
|
+
headers: httpResponse.headers,
|
|
7183
|
+
};
|
|
7184
|
+
return response;
|
|
7185
|
+
});
|
|
7069
7186
|
});
|
|
7070
|
-
return response.then(() => {
|
|
7071
|
-
const resp = deleteFileResponseFromMldev();
|
|
7187
|
+
return response.then((apiResponse) => {
|
|
7188
|
+
const resp = deleteFileResponseFromMldev(apiResponse);
|
|
7072
7189
|
const typedResp = new DeleteFileResponse();
|
|
7073
7190
|
Object.assign(typedResp, resp);
|
|
7074
7191
|
return typedResp;
|
|
@@ -10371,6 +10488,21 @@ function imageToMldev(fromObject) {
|
|
|
10371
10488
|
}
|
|
10372
10489
|
return toObject;
|
|
10373
10490
|
}
|
|
10491
|
+
function generateVideosSourceToMldev(fromObject, parentObject) {
|
|
10492
|
+
const toObject = {};
|
|
10493
|
+
const fromPrompt = getValueByPath(fromObject, ['prompt']);
|
|
10494
|
+
if (parentObject !== undefined && fromPrompt != null) {
|
|
10495
|
+
setValueByPath(parentObject, ['instances[0]', 'prompt'], fromPrompt);
|
|
10496
|
+
}
|
|
10497
|
+
const fromImage = getValueByPath(fromObject, ['image']);
|
|
10498
|
+
if (parentObject !== undefined && fromImage != null) {
|
|
10499
|
+
setValueByPath(parentObject, ['instances[0]', 'image'], imageToMldev(fromImage));
|
|
10500
|
+
}
|
|
10501
|
+
if (getValueByPath(fromObject, ['video']) !== undefined) {
|
|
10502
|
+
throw new Error('video parameter is not supported in Gemini API.');
|
|
10503
|
+
}
|
|
10504
|
+
return toObject;
|
|
10505
|
+
}
|
|
10374
10506
|
function generateVideosConfigToMldev(fromObject, parentObject) {
|
|
10375
10507
|
const toObject = {};
|
|
10376
10508
|
const fromNumberOfVideos = getValueByPath(fromObject, [
|
|
@@ -10428,6 +10560,9 @@ function generateVideosConfigToMldev(fromObject, parentObject) {
|
|
|
10428
10560
|
if (getValueByPath(fromObject, ['lastFrame']) !== undefined) {
|
|
10429
10561
|
throw new Error('lastFrame parameter is not supported in Gemini API.');
|
|
10430
10562
|
}
|
|
10563
|
+
if (getValueByPath(fromObject, ['referenceImages']) !== undefined) {
|
|
10564
|
+
throw new Error('referenceImages parameter is not supported in Gemini API.');
|
|
10565
|
+
}
|
|
10431
10566
|
if (getValueByPath(fromObject, ['compressionQuality']) !== undefined) {
|
|
10432
10567
|
throw new Error('compressionQuality parameter is not supported in Gemini API.');
|
|
10433
10568
|
}
|
|
@@ -10450,6 +10585,10 @@ function generateVideosParametersToMldev(apiClient, fromObject) {
|
|
|
10450
10585
|
if (getValueByPath(fromObject, ['video']) !== undefined) {
|
|
10451
10586
|
throw new Error('video parameter is not supported in Gemini API.');
|
|
10452
10587
|
}
|
|
10588
|
+
const fromSource = getValueByPath(fromObject, ['source']);
|
|
10589
|
+
if (fromSource != null) {
|
|
10590
|
+
setValueByPath(toObject, ['config'], generateVideosSourceToMldev(fromSource, toObject));
|
|
10591
|
+
}
|
|
10453
10592
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
10454
10593
|
if (fromConfig != null) {
|
|
10455
10594
|
setValueByPath(toObject, ['config'], generateVideosConfigToMldev(fromConfig, toObject));
|
|
@@ -11574,6 +11713,10 @@ function editImageParametersInternalToVertex(apiClient, fromObject) {
|
|
|
11574
11713
|
}
|
|
11575
11714
|
function upscaleImageAPIConfigInternalToVertex(fromObject, parentObject) {
|
|
11576
11715
|
const toObject = {};
|
|
11716
|
+
const fromOutputGcsUri = getValueByPath(fromObject, ['outputGcsUri']);
|
|
11717
|
+
if (parentObject !== undefined && fromOutputGcsUri != null) {
|
|
11718
|
+
setValueByPath(parentObject, ['parameters', 'storageUri'], fromOutputGcsUri);
|
|
11719
|
+
}
|
|
11577
11720
|
const fromIncludeRaiReason = getValueByPath(fromObject, [
|
|
11578
11721
|
'includeRaiReason',
|
|
11579
11722
|
]);
|
|
@@ -11702,6 +11845,10 @@ function recontextImageConfigToVertex(fromObject, parentObject) {
|
|
|
11702
11845
|
if (parentObject !== undefined && fromPersonGeneration != null) {
|
|
11703
11846
|
setValueByPath(parentObject, ['parameters', 'personGeneration'], fromPersonGeneration);
|
|
11704
11847
|
}
|
|
11848
|
+
const fromAddWatermark = getValueByPath(fromObject, ['addWatermark']);
|
|
11849
|
+
if (parentObject !== undefined && fromAddWatermark != null) {
|
|
11850
|
+
setValueByPath(parentObject, ['parameters', 'addWatermark'], fromAddWatermark);
|
|
11851
|
+
}
|
|
11705
11852
|
const fromOutputMimeType = getValueByPath(fromObject, [
|
|
11706
11853
|
'outputMimeType',
|
|
11707
11854
|
]);
|
|
@@ -11738,6 +11885,78 @@ function recontextImageParametersToVertex(apiClient, fromObject) {
|
|
|
11738
11885
|
}
|
|
11739
11886
|
return toObject;
|
|
11740
11887
|
}
|
|
11888
|
+
function scribbleImageToVertex(fromObject) {
|
|
11889
|
+
const toObject = {};
|
|
11890
|
+
const fromImage = getValueByPath(fromObject, ['image']);
|
|
11891
|
+
if (fromImage != null) {
|
|
11892
|
+
setValueByPath(toObject, ['image'], imageToVertex(fromImage));
|
|
11893
|
+
}
|
|
11894
|
+
return toObject;
|
|
11895
|
+
}
|
|
11896
|
+
function segmentImageSourceToVertex(fromObject, parentObject) {
|
|
11897
|
+
const toObject = {};
|
|
11898
|
+
const fromPrompt = getValueByPath(fromObject, ['prompt']);
|
|
11899
|
+
if (parentObject !== undefined && fromPrompt != null) {
|
|
11900
|
+
setValueByPath(parentObject, ['instances[0]', 'prompt'], fromPrompt);
|
|
11901
|
+
}
|
|
11902
|
+
const fromImage = getValueByPath(fromObject, ['image']);
|
|
11903
|
+
if (parentObject !== undefined && fromImage != null) {
|
|
11904
|
+
setValueByPath(parentObject, ['instances[0]', 'image'], imageToVertex(fromImage));
|
|
11905
|
+
}
|
|
11906
|
+
const fromScribbleImage = getValueByPath(fromObject, [
|
|
11907
|
+
'scribbleImage',
|
|
11908
|
+
]);
|
|
11909
|
+
if (parentObject !== undefined && fromScribbleImage != null) {
|
|
11910
|
+
setValueByPath(parentObject, ['instances[0]', 'scribble'], scribbleImageToVertex(fromScribbleImage));
|
|
11911
|
+
}
|
|
11912
|
+
return toObject;
|
|
11913
|
+
}
|
|
11914
|
+
function segmentImageConfigToVertex(fromObject, parentObject) {
|
|
11915
|
+
const toObject = {};
|
|
11916
|
+
const fromMode = getValueByPath(fromObject, ['mode']);
|
|
11917
|
+
if (parentObject !== undefined && fromMode != null) {
|
|
11918
|
+
setValueByPath(parentObject, ['parameters', 'mode'], fromMode);
|
|
11919
|
+
}
|
|
11920
|
+
const fromMaxPredictions = getValueByPath(fromObject, [
|
|
11921
|
+
'maxPredictions',
|
|
11922
|
+
]);
|
|
11923
|
+
if (parentObject !== undefined && fromMaxPredictions != null) {
|
|
11924
|
+
setValueByPath(parentObject, ['parameters', 'maxPredictions'], fromMaxPredictions);
|
|
11925
|
+
}
|
|
11926
|
+
const fromConfidenceThreshold = getValueByPath(fromObject, [
|
|
11927
|
+
'confidenceThreshold',
|
|
11928
|
+
]);
|
|
11929
|
+
if (parentObject !== undefined && fromConfidenceThreshold != null) {
|
|
11930
|
+
setValueByPath(parentObject, ['parameters', 'confidenceThreshold'], fromConfidenceThreshold);
|
|
11931
|
+
}
|
|
11932
|
+
const fromMaskDilation = getValueByPath(fromObject, ['maskDilation']);
|
|
11933
|
+
if (parentObject !== undefined && fromMaskDilation != null) {
|
|
11934
|
+
setValueByPath(parentObject, ['parameters', 'maskDilation'], fromMaskDilation);
|
|
11935
|
+
}
|
|
11936
|
+
const fromBinaryColorThreshold = getValueByPath(fromObject, [
|
|
11937
|
+
'binaryColorThreshold',
|
|
11938
|
+
]);
|
|
11939
|
+
if (parentObject !== undefined && fromBinaryColorThreshold != null) {
|
|
11940
|
+
setValueByPath(parentObject, ['parameters', 'binaryColorThreshold'], fromBinaryColorThreshold);
|
|
11941
|
+
}
|
|
11942
|
+
return toObject;
|
|
11943
|
+
}
|
|
11944
|
+
function segmentImageParametersToVertex(apiClient, fromObject) {
|
|
11945
|
+
const toObject = {};
|
|
11946
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
11947
|
+
if (fromModel != null) {
|
|
11948
|
+
setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
|
|
11949
|
+
}
|
|
11950
|
+
const fromSource = getValueByPath(fromObject, ['source']);
|
|
11951
|
+
if (fromSource != null) {
|
|
11952
|
+
setValueByPath(toObject, ['config'], segmentImageSourceToVertex(fromSource, toObject));
|
|
11953
|
+
}
|
|
11954
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
11955
|
+
if (fromConfig != null) {
|
|
11956
|
+
setValueByPath(toObject, ['config'], segmentImageConfigToVertex(fromConfig, toObject));
|
|
11957
|
+
}
|
|
11958
|
+
return toObject;
|
|
11959
|
+
}
|
|
11741
11960
|
function getModelParametersToVertex(apiClient, fromObject) {
|
|
11742
11961
|
const toObject = {};
|
|
11743
11962
|
const fromModel = getValueByPath(fromObject, ['model']);
|
|
@@ -11906,6 +12125,36 @@ function videoToVertex(fromObject) {
|
|
|
11906
12125
|
}
|
|
11907
12126
|
return toObject;
|
|
11908
12127
|
}
|
|
12128
|
+
function generateVideosSourceToVertex(fromObject, parentObject) {
|
|
12129
|
+
const toObject = {};
|
|
12130
|
+
const fromPrompt = getValueByPath(fromObject, ['prompt']);
|
|
12131
|
+
if (parentObject !== undefined && fromPrompt != null) {
|
|
12132
|
+
setValueByPath(parentObject, ['instances[0]', 'prompt'], fromPrompt);
|
|
12133
|
+
}
|
|
12134
|
+
const fromImage = getValueByPath(fromObject, ['image']);
|
|
12135
|
+
if (parentObject !== undefined && fromImage != null) {
|
|
12136
|
+
setValueByPath(parentObject, ['instances[0]', 'image'], imageToVertex(fromImage));
|
|
12137
|
+
}
|
|
12138
|
+
const fromVideo = getValueByPath(fromObject, ['video']);
|
|
12139
|
+
if (parentObject !== undefined && fromVideo != null) {
|
|
12140
|
+
setValueByPath(parentObject, ['instances[0]', 'video'], videoToVertex(fromVideo));
|
|
12141
|
+
}
|
|
12142
|
+
return toObject;
|
|
12143
|
+
}
|
|
12144
|
+
function videoGenerationReferenceImageToVertex(fromObject) {
|
|
12145
|
+
const toObject = {};
|
|
12146
|
+
const fromImage = getValueByPath(fromObject, ['image']);
|
|
12147
|
+
if (fromImage != null) {
|
|
12148
|
+
setValueByPath(toObject, ['image'], imageToVertex(fromImage));
|
|
12149
|
+
}
|
|
12150
|
+
const fromReferenceType = getValueByPath(fromObject, [
|
|
12151
|
+
'referenceType',
|
|
12152
|
+
]);
|
|
12153
|
+
if (fromReferenceType != null) {
|
|
12154
|
+
setValueByPath(toObject, ['referenceType'], fromReferenceType);
|
|
12155
|
+
}
|
|
12156
|
+
return toObject;
|
|
12157
|
+
}
|
|
11909
12158
|
function generateVideosConfigToVertex(fromObject, parentObject) {
|
|
11910
12159
|
const toObject = {};
|
|
11911
12160
|
const fromNumberOfVideos = getValueByPath(fromObject, [
|
|
@@ -11972,6 +12221,18 @@ function generateVideosConfigToVertex(fromObject, parentObject) {
|
|
|
11972
12221
|
if (parentObject !== undefined && fromLastFrame != null) {
|
|
11973
12222
|
setValueByPath(parentObject, ['instances[0]', 'lastFrame'], imageToVertex(fromLastFrame));
|
|
11974
12223
|
}
|
|
12224
|
+
const fromReferenceImages = getValueByPath(fromObject, [
|
|
12225
|
+
'referenceImages',
|
|
12226
|
+
]);
|
|
12227
|
+
if (parentObject !== undefined && fromReferenceImages != null) {
|
|
12228
|
+
let transformedList = fromReferenceImages;
|
|
12229
|
+
if (Array.isArray(transformedList)) {
|
|
12230
|
+
transformedList = transformedList.map((item) => {
|
|
12231
|
+
return videoGenerationReferenceImageToVertex(item);
|
|
12232
|
+
});
|
|
12233
|
+
}
|
|
12234
|
+
setValueByPath(parentObject, ['instances[0]', 'referenceImages'], transformedList);
|
|
12235
|
+
}
|
|
11975
12236
|
const fromCompressionQuality = getValueByPath(fromObject, [
|
|
11976
12237
|
'compressionQuality',
|
|
11977
12238
|
]);
|
|
@@ -11998,6 +12259,10 @@ function generateVideosParametersToVertex(apiClient, fromObject) {
|
|
|
11998
12259
|
if (fromVideo != null) {
|
|
11999
12260
|
setValueByPath(toObject, ['instances[0]', 'video'], videoToVertex(fromVideo));
|
|
12000
12261
|
}
|
|
12262
|
+
const fromSource = getValueByPath(fromObject, ['source']);
|
|
12263
|
+
if (fromSource != null) {
|
|
12264
|
+
setValueByPath(toObject, ['config'], generateVideosSourceToVertex(fromSource, toObject));
|
|
12265
|
+
}
|
|
12001
12266
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
12002
12267
|
if (fromConfig != null) {
|
|
12003
12268
|
setValueByPath(toObject, ['config'], generateVideosConfigToVertex(fromConfig, toObject));
|
|
@@ -12448,8 +12713,14 @@ function listModelsResponseFromMldev(fromObject) {
|
|
|
12448
12713
|
}
|
|
12449
12714
|
return toObject;
|
|
12450
12715
|
}
|
|
12451
|
-
function deleteModelResponseFromMldev() {
|
|
12716
|
+
function deleteModelResponseFromMldev(fromObject) {
|
|
12452
12717
|
const toObject = {};
|
|
12718
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
12719
|
+
'sdkHttpResponse',
|
|
12720
|
+
]);
|
|
12721
|
+
if (fromSdkHttpResponse != null) {
|
|
12722
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
12723
|
+
}
|
|
12453
12724
|
return toObject;
|
|
12454
12725
|
}
|
|
12455
12726
|
function countTokensResponseFromMldev(fromObject) {
|
|
@@ -13021,6 +13292,50 @@ function recontextImageResponseFromVertex(fromObject) {
|
|
|
13021
13292
|
}
|
|
13022
13293
|
return toObject;
|
|
13023
13294
|
}
|
|
13295
|
+
function entityLabelFromVertex(fromObject) {
|
|
13296
|
+
const toObject = {};
|
|
13297
|
+
const fromLabel = getValueByPath(fromObject, ['label']);
|
|
13298
|
+
if (fromLabel != null) {
|
|
13299
|
+
setValueByPath(toObject, ['label'], fromLabel);
|
|
13300
|
+
}
|
|
13301
|
+
const fromScore = getValueByPath(fromObject, ['score']);
|
|
13302
|
+
if (fromScore != null) {
|
|
13303
|
+
setValueByPath(toObject, ['score'], fromScore);
|
|
13304
|
+
}
|
|
13305
|
+
return toObject;
|
|
13306
|
+
}
|
|
13307
|
+
function generatedImageMaskFromVertex(fromObject) {
|
|
13308
|
+
const toObject = {};
|
|
13309
|
+
const fromMask = getValueByPath(fromObject, ['_self']);
|
|
13310
|
+
if (fromMask != null) {
|
|
13311
|
+
setValueByPath(toObject, ['mask'], imageFromVertex(fromMask));
|
|
13312
|
+
}
|
|
13313
|
+
const fromLabels = getValueByPath(fromObject, ['labels']);
|
|
13314
|
+
if (fromLabels != null) {
|
|
13315
|
+
let transformedList = fromLabels;
|
|
13316
|
+
if (Array.isArray(transformedList)) {
|
|
13317
|
+
transformedList = transformedList.map((item) => {
|
|
13318
|
+
return entityLabelFromVertex(item);
|
|
13319
|
+
});
|
|
13320
|
+
}
|
|
13321
|
+
setValueByPath(toObject, ['labels'], transformedList);
|
|
13322
|
+
}
|
|
13323
|
+
return toObject;
|
|
13324
|
+
}
|
|
13325
|
+
function segmentImageResponseFromVertex(fromObject) {
|
|
13326
|
+
const toObject = {};
|
|
13327
|
+
const fromGeneratedMasks = getValueByPath(fromObject, ['predictions']);
|
|
13328
|
+
if (fromGeneratedMasks != null) {
|
|
13329
|
+
let transformedList = fromGeneratedMasks;
|
|
13330
|
+
if (Array.isArray(transformedList)) {
|
|
13331
|
+
transformedList = transformedList.map((item) => {
|
|
13332
|
+
return generatedImageMaskFromVertex(item);
|
|
13333
|
+
});
|
|
13334
|
+
}
|
|
13335
|
+
setValueByPath(toObject, ['generatedMasks'], transformedList);
|
|
13336
|
+
}
|
|
13337
|
+
return toObject;
|
|
13338
|
+
}
|
|
13024
13339
|
function endpointFromVertex(fromObject) {
|
|
13025
13340
|
const toObject = {};
|
|
13026
13341
|
const fromName = getValueByPath(fromObject, ['endpoint']);
|
|
@@ -13150,8 +13465,14 @@ function listModelsResponseFromVertex(fromObject) {
|
|
|
13150
13465
|
}
|
|
13151
13466
|
return toObject;
|
|
13152
13467
|
}
|
|
13153
|
-
function deleteModelResponseFromVertex() {
|
|
13468
|
+
function deleteModelResponseFromVertex(fromObject) {
|
|
13154
13469
|
const toObject = {};
|
|
13470
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
13471
|
+
'sdkHttpResponse',
|
|
13472
|
+
]);
|
|
13473
|
+
if (fromSdkHttpResponse != null) {
|
|
13474
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
13475
|
+
}
|
|
13155
13476
|
return toObject;
|
|
13156
13477
|
}
|
|
13157
13478
|
function countTokensResponseFromVertex(fromObject) {
|
|
@@ -13268,7 +13589,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
13268
13589
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
13269
13590
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
13270
13591
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
13271
|
-
const SDK_VERSION = '1.
|
|
13592
|
+
const SDK_VERSION = '1.16.0'; // x-release-please-version
|
|
13272
13593
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
13273
13594
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
13274
13595
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -15040,7 +15361,9 @@ class Models extends BaseModule {
|
|
|
15040
15361
|
* ```ts
|
|
15041
15362
|
* const operation = await ai.models.generateVideos({
|
|
15042
15363
|
* model: 'veo-2.0-generate-001',
|
|
15043
|
-
*
|
|
15364
|
+
* source: {
|
|
15365
|
+
* prompt: 'A neon hologram of a cat driving at top speed',
|
|
15366
|
+
* },
|
|
15044
15367
|
* config: {
|
|
15045
15368
|
* numberOfVideos: 1
|
|
15046
15369
|
* });
|
|
@@ -15054,6 +15377,9 @@ class Models extends BaseModule {
|
|
|
15054
15377
|
* ```
|
|
15055
15378
|
*/
|
|
15056
15379
|
this.generateVideos = async (params) => {
|
|
15380
|
+
if ((params.prompt || params.image || params.video) && params.source) {
|
|
15381
|
+
throw new Error('Source and prompt/image/video are mutually exclusive. Please only use source.');
|
|
15382
|
+
}
|
|
15057
15383
|
return await this.generateVideosInternal(params);
|
|
15058
15384
|
};
|
|
15059
15385
|
}
|
|
@@ -15711,6 +16037,61 @@ class Models extends BaseModule {
|
|
|
15711
16037
|
throw new Error('This method is only supported by the Vertex AI.');
|
|
15712
16038
|
}
|
|
15713
16039
|
}
|
|
16040
|
+
/**
|
|
16041
|
+
* Segments an image, creating a mask of a specified area.
|
|
16042
|
+
*
|
|
16043
|
+
* @param params - The parameters for segmenting an image.
|
|
16044
|
+
* @return The response from the API.
|
|
16045
|
+
*
|
|
16046
|
+
* @example
|
|
16047
|
+
* ```ts
|
|
16048
|
+
* const response = await ai.models.segmentImage({
|
|
16049
|
+
* model: 'image-segmentation-001',
|
|
16050
|
+
* source: {
|
|
16051
|
+
* image: image,
|
|
16052
|
+
* },
|
|
16053
|
+
* config: {
|
|
16054
|
+
* mode: 'foreground',
|
|
16055
|
+
* },
|
|
16056
|
+
* });
|
|
16057
|
+
* console.log(response?.generatedMasks?.[0]?.mask?.imageBytes);
|
|
16058
|
+
* ```
|
|
16059
|
+
*/
|
|
16060
|
+
async segmentImage(params) {
|
|
16061
|
+
var _a, _b;
|
|
16062
|
+
let response;
|
|
16063
|
+
let path = '';
|
|
16064
|
+
let queryParams = {};
|
|
16065
|
+
if (this.apiClient.isVertexAI()) {
|
|
16066
|
+
const body = segmentImageParametersToVertex(this.apiClient, params);
|
|
16067
|
+
path = formatMap('{model}:predict', body['_url']);
|
|
16068
|
+
queryParams = body['_query'];
|
|
16069
|
+
delete body['config'];
|
|
16070
|
+
delete body['_url'];
|
|
16071
|
+
delete body['_query'];
|
|
16072
|
+
response = this.apiClient
|
|
16073
|
+
.request({
|
|
16074
|
+
path: path,
|
|
16075
|
+
queryParams: queryParams,
|
|
16076
|
+
body: JSON.stringify(body),
|
|
16077
|
+
httpMethod: 'POST',
|
|
16078
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
16079
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
16080
|
+
})
|
|
16081
|
+
.then((httpResponse) => {
|
|
16082
|
+
return httpResponse.json();
|
|
16083
|
+
});
|
|
16084
|
+
return response.then((apiResponse) => {
|
|
16085
|
+
const resp = segmentImageResponseFromVertex(apiResponse);
|
|
16086
|
+
const typedResp = new SegmentImageResponse();
|
|
16087
|
+
Object.assign(typedResp, resp);
|
|
16088
|
+
return typedResp;
|
|
16089
|
+
});
|
|
16090
|
+
}
|
|
16091
|
+
else {
|
|
16092
|
+
throw new Error('This method is only supported by the Vertex AI.');
|
|
16093
|
+
}
|
|
16094
|
+
}
|
|
15714
16095
|
/**
|
|
15715
16096
|
* Fetches information about a model by name.
|
|
15716
16097
|
*
|
|
@@ -15947,10 +16328,16 @@ class Models extends BaseModule {
|
|
|
15947
16328
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
15948
16329
|
})
|
|
15949
16330
|
.then((httpResponse) => {
|
|
15950
|
-
return httpResponse.json()
|
|
16331
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
16332
|
+
const response = jsonResponse;
|
|
16333
|
+
response.sdkHttpResponse = {
|
|
16334
|
+
headers: httpResponse.headers,
|
|
16335
|
+
};
|
|
16336
|
+
return response;
|
|
16337
|
+
});
|
|
15951
16338
|
});
|
|
15952
|
-
return response.then(() => {
|
|
15953
|
-
const resp = deleteModelResponseFromVertex();
|
|
16339
|
+
return response.then((apiResponse) => {
|
|
16340
|
+
const resp = deleteModelResponseFromVertex(apiResponse);
|
|
15954
16341
|
const typedResp = new DeleteModelResponse();
|
|
15955
16342
|
Object.assign(typedResp, resp);
|
|
15956
16343
|
return typedResp;
|
|
@@ -15973,10 +16360,16 @@ class Models extends BaseModule {
|
|
|
15973
16360
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
15974
16361
|
})
|
|
15975
16362
|
.then((httpResponse) => {
|
|
15976
|
-
return httpResponse.json()
|
|
16363
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
16364
|
+
const response = jsonResponse;
|
|
16365
|
+
response.sdkHttpResponse = {
|
|
16366
|
+
headers: httpResponse.headers,
|
|
16367
|
+
};
|
|
16368
|
+
return response;
|
|
16369
|
+
});
|
|
15977
16370
|
});
|
|
15978
|
-
return response.then(() => {
|
|
15979
|
-
const resp = deleteModelResponseFromMldev();
|
|
16371
|
+
return response.then((apiResponse) => {
|
|
16372
|
+
const resp = deleteModelResponseFromMldev(apiResponse);
|
|
15980
16373
|
const typedResp = new DeleteModelResponse();
|
|
15981
16374
|
Object.assign(typedResp, resp);
|
|
15982
16375
|
return typedResp;
|
|
@@ -16231,13 +16624,17 @@ function getOperationParametersToMldev(fromObject) {
|
|
|
16231
16624
|
}
|
|
16232
16625
|
return toObject;
|
|
16233
16626
|
}
|
|
16234
|
-
function
|
|
16627
|
+
function fetchPredictOperationParametersToVertex(fromObject) {
|
|
16235
16628
|
const toObject = {};
|
|
16236
16629
|
const fromOperationName = getValueByPath(fromObject, [
|
|
16237
16630
|
'operationName',
|
|
16238
16631
|
]);
|
|
16239
16632
|
if (fromOperationName != null) {
|
|
16240
|
-
setValueByPath(toObject, ['
|
|
16633
|
+
setValueByPath(toObject, ['operationName'], fromOperationName);
|
|
16634
|
+
}
|
|
16635
|
+
const fromResourceName = getValueByPath(fromObject, ['resourceName']);
|
|
16636
|
+
if (fromResourceName != null) {
|
|
16637
|
+
setValueByPath(toObject, ['_url', 'resourceName'], fromResourceName);
|
|
16241
16638
|
}
|
|
16242
16639
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
16243
16640
|
if (fromConfig != null) {
|
|
@@ -16245,17 +16642,13 @@ function getOperationParametersToVertex(fromObject) {
|
|
|
16245
16642
|
}
|
|
16246
16643
|
return toObject;
|
|
16247
16644
|
}
|
|
16248
|
-
function
|
|
16645
|
+
function getOperationParametersToVertex(fromObject) {
|
|
16249
16646
|
const toObject = {};
|
|
16250
16647
|
const fromOperationName = getValueByPath(fromObject, [
|
|
16251
16648
|
'operationName',
|
|
16252
16649
|
]);
|
|
16253
16650
|
if (fromOperationName != null) {
|
|
16254
|
-
setValueByPath(toObject, ['operationName'], fromOperationName);
|
|
16255
|
-
}
|
|
16256
|
-
const fromResourceName = getValueByPath(fromObject, ['resourceName']);
|
|
16257
|
-
if (fromResourceName != null) {
|
|
16258
|
-
setValueByPath(toObject, ['_url', 'resourceName'], fromResourceName);
|
|
16651
|
+
setValueByPath(toObject, ['_url', 'operationName'], fromOperationName);
|
|
16259
16652
|
}
|
|
16260
16653
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
16261
16654
|
if (fromConfig != null) {
|
|
@@ -17516,6 +17909,18 @@ function listTuningJobsParametersToMldev(fromObject) {
|
|
|
17516
17909
|
}
|
|
17517
17910
|
return toObject;
|
|
17518
17911
|
}
|
|
17912
|
+
function cancelTuningJobParametersToMldev(fromObject) {
|
|
17913
|
+
const toObject = {};
|
|
17914
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
17915
|
+
if (fromName != null) {
|
|
17916
|
+
setValueByPath(toObject, ['_url', 'name'], fromName);
|
|
17917
|
+
}
|
|
17918
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
17919
|
+
if (fromConfig != null) {
|
|
17920
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
17921
|
+
}
|
|
17922
|
+
return toObject;
|
|
17923
|
+
}
|
|
17519
17924
|
function tuningExampleToMldev(fromObject) {
|
|
17520
17925
|
const toObject = {};
|
|
17521
17926
|
const fromTextInput = getValueByPath(fromObject, ['textInput']);
|
|
@@ -17653,6 +18058,18 @@ function listTuningJobsParametersToVertex(fromObject) {
|
|
|
17653
18058
|
}
|
|
17654
18059
|
return toObject;
|
|
17655
18060
|
}
|
|
18061
|
+
function cancelTuningJobParametersToVertex(fromObject) {
|
|
18062
|
+
const toObject = {};
|
|
18063
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
18064
|
+
if (fromName != null) {
|
|
18065
|
+
setValueByPath(toObject, ['_url', 'name'], fromName);
|
|
18066
|
+
}
|
|
18067
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
18068
|
+
if (fromConfig != null) {
|
|
18069
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
18070
|
+
}
|
|
18071
|
+
return toObject;
|
|
18072
|
+
}
|
|
17656
18073
|
function tuningDatasetToVertex(fromObject, parentObject) {
|
|
17657
18074
|
const toObject = {};
|
|
17658
18075
|
const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
|
|
@@ -18306,6 +18723,54 @@ class Tunings extends BaseModule {
|
|
|
18306
18723
|
});
|
|
18307
18724
|
}
|
|
18308
18725
|
}
|
|
18726
|
+
/**
|
|
18727
|
+
* Cancels a tuning job.
|
|
18728
|
+
*
|
|
18729
|
+
* @param params - The parameters for the cancel request.
|
|
18730
|
+
* @return The empty response returned by the API.
|
|
18731
|
+
*
|
|
18732
|
+
* @example
|
|
18733
|
+
* ```ts
|
|
18734
|
+
* await ai.tunings.cancel({name: '...'}); // The server-generated resource name.
|
|
18735
|
+
* ```
|
|
18736
|
+
*/
|
|
18737
|
+
async cancel(params) {
|
|
18738
|
+
var _a, _b, _c, _d;
|
|
18739
|
+
let path = '';
|
|
18740
|
+
let queryParams = {};
|
|
18741
|
+
if (this.apiClient.isVertexAI()) {
|
|
18742
|
+
const body = cancelTuningJobParametersToVertex(params);
|
|
18743
|
+
path = formatMap('{name}:cancel', body['_url']);
|
|
18744
|
+
queryParams = body['_query'];
|
|
18745
|
+
delete body['config'];
|
|
18746
|
+
delete body['_url'];
|
|
18747
|
+
delete body['_query'];
|
|
18748
|
+
await this.apiClient.request({
|
|
18749
|
+
path: path,
|
|
18750
|
+
queryParams: queryParams,
|
|
18751
|
+
body: JSON.stringify(body),
|
|
18752
|
+
httpMethod: 'POST',
|
|
18753
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
18754
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
18755
|
+
});
|
|
18756
|
+
}
|
|
18757
|
+
else {
|
|
18758
|
+
const body = cancelTuningJobParametersToMldev(params);
|
|
18759
|
+
path = formatMap('{name}:cancel', body['_url']);
|
|
18760
|
+
queryParams = body['_query'];
|
|
18761
|
+
delete body['config'];
|
|
18762
|
+
delete body['_url'];
|
|
18763
|
+
delete body['_query'];
|
|
18764
|
+
await this.apiClient.request({
|
|
18765
|
+
path: path,
|
|
18766
|
+
queryParams: queryParams,
|
|
18767
|
+
body: JSON.stringify(body),
|
|
18768
|
+
httpMethod: 'POST',
|
|
18769
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
18770
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
18771
|
+
});
|
|
18772
|
+
}
|
|
18773
|
+
}
|
|
18309
18774
|
async tuneInternal(params) {
|
|
18310
18775
|
var _a, _b;
|
|
18311
18776
|
let response;
|
|
@@ -18789,8 +19254,8 @@ function getApiKeyFromEnv() {
|
|
|
18789
19254
|
if (envGoogleApiKey && envGeminiApiKey) {
|
|
18790
19255
|
console.warn('Both GOOGLE_API_KEY and GEMINI_API_KEY are set. Using GOOGLE_API_KEY.');
|
|
18791
19256
|
}
|
|
18792
|
-
return envGoogleApiKey || envGeminiApiKey;
|
|
19257
|
+
return envGoogleApiKey || envGeminiApiKey || undefined;
|
|
18793
19258
|
}
|
|
18794
19259
|
|
|
18795
|
-
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 };
|
|
19260
|
+
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 };
|
|
18796
19261
|
//# sourceMappingURL=index.mjs.map
|