@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/web/index.mjs
CHANGED
|
@@ -799,6 +799,10 @@ var FunctionCallingConfigMode;
|
|
|
799
799
|
* Model will not predict any function calls. Model behavior is same as when not passing any function declarations.
|
|
800
800
|
*/
|
|
801
801
|
FunctionCallingConfigMode["NONE"] = "NONE";
|
|
802
|
+
/**
|
|
803
|
+
* 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".
|
|
804
|
+
*/
|
|
805
|
+
FunctionCallingConfigMode["VALIDATED"] = "VALIDATED";
|
|
802
806
|
})(FunctionCallingConfigMode || (FunctionCallingConfigMode = {}));
|
|
803
807
|
/** Enum that controls the safety filter level for objectionable content. */
|
|
804
808
|
var SafetyFilterLevel;
|
|
@@ -897,6 +901,30 @@ var EditMode;
|
|
|
897
901
|
EditMode["EDIT_MODE_BGSWAP"] = "EDIT_MODE_BGSWAP";
|
|
898
902
|
EditMode["EDIT_MODE_PRODUCT_IMAGE"] = "EDIT_MODE_PRODUCT_IMAGE";
|
|
899
903
|
})(EditMode || (EditMode = {}));
|
|
904
|
+
/** Enum that represents the segmentation mode. */
|
|
905
|
+
var SegmentMode;
|
|
906
|
+
(function (SegmentMode) {
|
|
907
|
+
SegmentMode["FOREGROUND"] = "FOREGROUND";
|
|
908
|
+
SegmentMode["BACKGROUND"] = "BACKGROUND";
|
|
909
|
+
SegmentMode["PROMPT"] = "PROMPT";
|
|
910
|
+
SegmentMode["SEMANTIC"] = "SEMANTIC";
|
|
911
|
+
SegmentMode["INTERACTIVE"] = "INTERACTIVE";
|
|
912
|
+
})(SegmentMode || (SegmentMode = {}));
|
|
913
|
+
/** Enum for the reference type of a video generation reference image. */
|
|
914
|
+
var VideoGenerationReferenceType;
|
|
915
|
+
(function (VideoGenerationReferenceType) {
|
|
916
|
+
/**
|
|
917
|
+
* A reference image that provides assets to the generated video,
|
|
918
|
+
such as the scene, an object, a character, etc.
|
|
919
|
+
*/
|
|
920
|
+
VideoGenerationReferenceType["ASSET"] = "ASSET";
|
|
921
|
+
/**
|
|
922
|
+
* A reference image that provides aesthetics including colors,
|
|
923
|
+
lighting, texture, etc., to be used as the style of the generated video,
|
|
924
|
+
such as 'anime', 'photography', 'origami', etc.
|
|
925
|
+
*/
|
|
926
|
+
VideoGenerationReferenceType["STYLE"] = "STYLE";
|
|
927
|
+
})(VideoGenerationReferenceType || (VideoGenerationReferenceType = {}));
|
|
900
928
|
/** Enum that controls the compression quality of the generated videos. */
|
|
901
929
|
var VideoCompressionQuality;
|
|
902
930
|
(function (VideoCompressionQuality) {
|
|
@@ -1543,6 +1571,9 @@ class UpscaleImageResponse {
|
|
|
1543
1571
|
/** The output images response. */
|
|
1544
1572
|
class RecontextImageResponse {
|
|
1545
1573
|
}
|
|
1574
|
+
/** The output images response. */
|
|
1575
|
+
class SegmentImageResponse {
|
|
1576
|
+
}
|
|
1546
1577
|
class ListModelsResponse {
|
|
1547
1578
|
}
|
|
1548
1579
|
class DeleteModelResponse {
|
|
@@ -1556,6 +1587,65 @@ class ComputeTokensResponse {
|
|
|
1556
1587
|
/** Response with generated videos. */
|
|
1557
1588
|
class GenerateVideosResponse {
|
|
1558
1589
|
}
|
|
1590
|
+
/** A video generation operation. */
|
|
1591
|
+
class GenerateVideosOperation {
|
|
1592
|
+
/**
|
|
1593
|
+
* Instantiates an Operation of the same type as the one being called with the fields set from the API response.
|
|
1594
|
+
* @internal
|
|
1595
|
+
*/
|
|
1596
|
+
_fromAPIResponse({ apiResponse, isVertexAI, }) {
|
|
1597
|
+
const operation = new GenerateVideosOperation();
|
|
1598
|
+
operation.name = apiResponse['name'];
|
|
1599
|
+
operation.metadata = apiResponse['metadata'];
|
|
1600
|
+
operation.done = apiResponse['done'];
|
|
1601
|
+
operation.error = apiResponse['error'];
|
|
1602
|
+
if (isVertexAI) {
|
|
1603
|
+
const response = apiResponse['response'];
|
|
1604
|
+
if (response) {
|
|
1605
|
+
const operationResponse = new GenerateVideosResponse();
|
|
1606
|
+
const responseVideos = response['videos'];
|
|
1607
|
+
operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
|
|
1608
|
+
return {
|
|
1609
|
+
video: {
|
|
1610
|
+
uri: generatedVideo['gcsUri'],
|
|
1611
|
+
videoBytes: generatedVideo['bytesBase64Encoded']
|
|
1612
|
+
? tBytes$1(generatedVideo['bytesBase64Encoded'])
|
|
1613
|
+
: undefined,
|
|
1614
|
+
mimeType: generatedVideo['mimeType'],
|
|
1615
|
+
},
|
|
1616
|
+
};
|
|
1617
|
+
});
|
|
1618
|
+
operationResponse.raiMediaFilteredCount = response['raiMediaFilteredCount'];
|
|
1619
|
+
operationResponse.raiMediaFilteredReasons = response['raiMediaFilteredReasons'];
|
|
1620
|
+
operation.response = operationResponse;
|
|
1621
|
+
}
|
|
1622
|
+
}
|
|
1623
|
+
else {
|
|
1624
|
+
const response = apiResponse['response'];
|
|
1625
|
+
if (response) {
|
|
1626
|
+
const operationResponse = new GenerateVideosResponse();
|
|
1627
|
+
const generatedVideoResponse = response['generateVideoResponse'];
|
|
1628
|
+
const responseVideos = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['generatedSamples'];
|
|
1629
|
+
operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
|
|
1630
|
+
const video = generatedVideo['video'];
|
|
1631
|
+
return {
|
|
1632
|
+
video: {
|
|
1633
|
+
uri: video === null || video === void 0 ? void 0 : video['uri'],
|
|
1634
|
+
videoBytes: (video === null || video === void 0 ? void 0 : video['encodedVideo'])
|
|
1635
|
+
? tBytes$1(video === null || video === void 0 ? void 0 : video['encodedVideo'])
|
|
1636
|
+
: undefined,
|
|
1637
|
+
mimeType: generatedVideo['encoding'],
|
|
1638
|
+
},
|
|
1639
|
+
};
|
|
1640
|
+
});
|
|
1641
|
+
operationResponse.raiMediaFilteredCount = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredCount'];
|
|
1642
|
+
operationResponse.raiMediaFilteredReasons = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredReasons'];
|
|
1643
|
+
operation.response = operationResponse;
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
return operation;
|
|
1647
|
+
}
|
|
1648
|
+
}
|
|
1559
1649
|
/** Response for the list tuning jobs method. */
|
|
1560
1650
|
class ListTuningJobsResponse {
|
|
1561
1651
|
}
|
|
@@ -1747,65 +1837,6 @@ class LiveServerMessage {
|
|
|
1747
1837
|
return data.length > 0 ? btoa(data) : undefined;
|
|
1748
1838
|
}
|
|
1749
1839
|
}
|
|
1750
|
-
/** A video generation long-running operation. */
|
|
1751
|
-
class GenerateVideosOperation {
|
|
1752
|
-
/**
|
|
1753
|
-
* Instantiates an Operation of the same type as the one being called with the fields set from the API response.
|
|
1754
|
-
* @internal
|
|
1755
|
-
*/
|
|
1756
|
-
_fromAPIResponse({ apiResponse, isVertexAI, }) {
|
|
1757
|
-
const operation = new GenerateVideosOperation();
|
|
1758
|
-
operation.name = apiResponse['name'];
|
|
1759
|
-
operation.metadata = apiResponse['metadata'];
|
|
1760
|
-
operation.done = apiResponse['done'];
|
|
1761
|
-
operation.error = apiResponse['error'];
|
|
1762
|
-
if (isVertexAI) {
|
|
1763
|
-
const response = apiResponse['response'];
|
|
1764
|
-
if (response) {
|
|
1765
|
-
const operationResponse = new GenerateVideosResponse();
|
|
1766
|
-
const responseVideos = response['videos'];
|
|
1767
|
-
operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
|
|
1768
|
-
return {
|
|
1769
|
-
video: {
|
|
1770
|
-
uri: generatedVideo['gcsUri'],
|
|
1771
|
-
videoBytes: generatedVideo['bytesBase64Encoded']
|
|
1772
|
-
? tBytes$1(generatedVideo['bytesBase64Encoded'])
|
|
1773
|
-
: undefined,
|
|
1774
|
-
mimeType: generatedVideo['mimeType'],
|
|
1775
|
-
},
|
|
1776
|
-
};
|
|
1777
|
-
});
|
|
1778
|
-
operationResponse.raiMediaFilteredCount = response['raiMediaFilteredCount'];
|
|
1779
|
-
operationResponse.raiMediaFilteredReasons = response['raiMediaFilteredReasons'];
|
|
1780
|
-
operation.response = operationResponse;
|
|
1781
|
-
}
|
|
1782
|
-
}
|
|
1783
|
-
else {
|
|
1784
|
-
const response = apiResponse['response'];
|
|
1785
|
-
if (response) {
|
|
1786
|
-
const operationResponse = new GenerateVideosResponse();
|
|
1787
|
-
const generatedVideoResponse = response['generateVideoResponse'];
|
|
1788
|
-
const responseVideos = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['generatedSamples'];
|
|
1789
|
-
operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
|
|
1790
|
-
const video = generatedVideo['video'];
|
|
1791
|
-
return {
|
|
1792
|
-
video: {
|
|
1793
|
-
uri: video === null || video === void 0 ? void 0 : video['uri'],
|
|
1794
|
-
videoBytes: (video === null || video === void 0 ? void 0 : video['encodedVideo'])
|
|
1795
|
-
? tBytes$1(video === null || video === void 0 ? void 0 : video['encodedVideo'])
|
|
1796
|
-
: undefined,
|
|
1797
|
-
mimeType: generatedVideo['encoding'],
|
|
1798
|
-
},
|
|
1799
|
-
};
|
|
1800
|
-
});
|
|
1801
|
-
operationResponse.raiMediaFilteredCount = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredCount'];
|
|
1802
|
-
operationResponse.raiMediaFilteredReasons = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredReasons'];
|
|
1803
|
-
operation.response = operationResponse;
|
|
1804
|
-
}
|
|
1805
|
-
}
|
|
1806
|
-
return operation;
|
|
1807
|
-
}
|
|
1808
|
-
}
|
|
1809
1840
|
/** Client generated response to a `ToolCall` received from the server.
|
|
1810
1841
|
|
|
1811
1842
|
Individual `FunctionResponse` objects are matched to the respective
|
|
@@ -2452,6 +2483,9 @@ function mcpToGeminiTool(mcpTool, config = {}) {
|
|
|
2452
2483
|
description: mcpToolSchema['description'],
|
|
2453
2484
|
parametersJsonSchema: mcpToolSchema['inputSchema'],
|
|
2454
2485
|
};
|
|
2486
|
+
if (mcpToolSchema['outputSchema']) {
|
|
2487
|
+
functionDeclaration['responseJsonSchema'] = mcpToolSchema['outputSchema'];
|
|
2488
|
+
}
|
|
2455
2489
|
if (config.behavior) {
|
|
2456
2490
|
functionDeclaration['behavior'] = config.behavior;
|
|
2457
2491
|
}
|
|
@@ -4281,6 +4315,7 @@ class Batches extends BaseModule {
|
|
|
4281
4315
|
* ```
|
|
4282
4316
|
*/
|
|
4283
4317
|
this.create = async (params) => {
|
|
4318
|
+
var _a, _b;
|
|
4284
4319
|
if (this.apiClient.isVertexAI()) {
|
|
4285
4320
|
const timestamp = Date.now();
|
|
4286
4321
|
const timestampStr = timestamp.toString();
|
|
@@ -4305,6 +4340,55 @@ class Batches extends BaseModule {
|
|
|
4305
4340
|
}
|
|
4306
4341
|
}
|
|
4307
4342
|
}
|
|
4343
|
+
else {
|
|
4344
|
+
if (Array.isArray(params.src) ||
|
|
4345
|
+
(typeof params.src !== 'string' && params.src.inlinedRequests)) {
|
|
4346
|
+
// Move system instruction to httpOptions extraBody.
|
|
4347
|
+
let path = '';
|
|
4348
|
+
let queryParams = {};
|
|
4349
|
+
const body = createBatchJobParametersToMldev(this.apiClient, params);
|
|
4350
|
+
path = formatMap('{model}:batchGenerateContent', body['_url']);
|
|
4351
|
+
queryParams = body['_query'];
|
|
4352
|
+
// Move system instruction to 'request':
|
|
4353
|
+
// {'systemInstruction': system_instruction}
|
|
4354
|
+
const batch = body['batch'];
|
|
4355
|
+
const inputConfig = batch['inputConfig'];
|
|
4356
|
+
const requestsWrapper = inputConfig['requests'];
|
|
4357
|
+
const requests = requestsWrapper['requests'];
|
|
4358
|
+
const newRequests = [];
|
|
4359
|
+
for (const request of requests) {
|
|
4360
|
+
const requestDict = request;
|
|
4361
|
+
if (requestDict['systemInstruction']) {
|
|
4362
|
+
const systemInstructionValue = requestDict['systemInstruction'];
|
|
4363
|
+
delete requestDict['systemInstruction'];
|
|
4364
|
+
const requestContent = requestDict['request'];
|
|
4365
|
+
requestContent['systemInstruction'] = systemInstructionValue;
|
|
4366
|
+
requestDict['request'] = requestContent;
|
|
4367
|
+
}
|
|
4368
|
+
newRequests.push(requestDict);
|
|
4369
|
+
}
|
|
4370
|
+
requestsWrapper['requests'] = newRequests;
|
|
4371
|
+
delete body['config'];
|
|
4372
|
+
delete body['_url'];
|
|
4373
|
+
delete body['_query'];
|
|
4374
|
+
const response = this.apiClient
|
|
4375
|
+
.request({
|
|
4376
|
+
path: path,
|
|
4377
|
+
queryParams: queryParams,
|
|
4378
|
+
body: JSON.stringify(body),
|
|
4379
|
+
httpMethod: 'POST',
|
|
4380
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
4381
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
4382
|
+
})
|
|
4383
|
+
.then((httpResponse) => {
|
|
4384
|
+
return httpResponse.json();
|
|
4385
|
+
});
|
|
4386
|
+
return response.then((apiResponse) => {
|
|
4387
|
+
const resp = batchJobFromMldev(apiResponse);
|
|
4388
|
+
return resp;
|
|
4389
|
+
});
|
|
4390
|
+
}
|
|
4391
|
+
}
|
|
4308
4392
|
return await this.createInternal(params);
|
|
4309
4393
|
};
|
|
4310
4394
|
/**
|
|
@@ -5649,8 +5733,14 @@ function cachedContentFromMldev(fromObject) {
|
|
|
5649
5733
|
}
|
|
5650
5734
|
return toObject;
|
|
5651
5735
|
}
|
|
5652
|
-
function deleteCachedContentResponseFromMldev() {
|
|
5736
|
+
function deleteCachedContentResponseFromMldev(fromObject) {
|
|
5653
5737
|
const toObject = {};
|
|
5738
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
5739
|
+
'sdkHttpResponse',
|
|
5740
|
+
]);
|
|
5741
|
+
if (fromSdkHttpResponse != null) {
|
|
5742
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
5743
|
+
}
|
|
5654
5744
|
return toObject;
|
|
5655
5745
|
}
|
|
5656
5746
|
function listCachedContentsResponseFromMldev(fromObject) {
|
|
@@ -5715,8 +5805,14 @@ function cachedContentFromVertex(fromObject) {
|
|
|
5715
5805
|
}
|
|
5716
5806
|
return toObject;
|
|
5717
5807
|
}
|
|
5718
|
-
function deleteCachedContentResponseFromVertex() {
|
|
5808
|
+
function deleteCachedContentResponseFromVertex(fromObject) {
|
|
5719
5809
|
const toObject = {};
|
|
5810
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
5811
|
+
'sdkHttpResponse',
|
|
5812
|
+
]);
|
|
5813
|
+
if (fromSdkHttpResponse != null) {
|
|
5814
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
5815
|
+
}
|
|
5720
5816
|
return toObject;
|
|
5721
5817
|
}
|
|
5722
5818
|
function listCachedContentsResponseFromVertex(fromObject) {
|
|
@@ -5953,10 +6049,16 @@ class Caches extends BaseModule {
|
|
|
5953
6049
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
5954
6050
|
})
|
|
5955
6051
|
.then((httpResponse) => {
|
|
5956
|
-
return httpResponse.json()
|
|
6052
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
6053
|
+
const response = jsonResponse;
|
|
6054
|
+
response.sdkHttpResponse = {
|
|
6055
|
+
headers: httpResponse.headers,
|
|
6056
|
+
};
|
|
6057
|
+
return response;
|
|
6058
|
+
});
|
|
5957
6059
|
});
|
|
5958
|
-
return response.then(() => {
|
|
5959
|
-
const resp = deleteCachedContentResponseFromVertex();
|
|
6060
|
+
return response.then((apiResponse) => {
|
|
6061
|
+
const resp = deleteCachedContentResponseFromVertex(apiResponse);
|
|
5960
6062
|
const typedResp = new DeleteCachedContentResponse();
|
|
5961
6063
|
Object.assign(typedResp, resp);
|
|
5962
6064
|
return typedResp;
|
|
@@ -5979,10 +6081,16 @@ class Caches extends BaseModule {
|
|
|
5979
6081
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
5980
6082
|
})
|
|
5981
6083
|
.then((httpResponse) => {
|
|
5982
|
-
return httpResponse.json()
|
|
6084
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
6085
|
+
const response = jsonResponse;
|
|
6086
|
+
response.sdkHttpResponse = {
|
|
6087
|
+
headers: httpResponse.headers,
|
|
6088
|
+
};
|
|
6089
|
+
return response;
|
|
6090
|
+
});
|
|
5983
6091
|
});
|
|
5984
|
-
return response.then(() => {
|
|
5985
|
-
const resp = deleteCachedContentResponseFromMldev();
|
|
6092
|
+
return response.then((apiResponse) => {
|
|
6093
|
+
const resp = deleteCachedContentResponseFromMldev(apiResponse);
|
|
5986
6094
|
const typedResp = new DeleteCachedContentResponse();
|
|
5987
6095
|
Object.assign(typedResp, resp);
|
|
5988
6096
|
return typedResp;
|
|
@@ -6215,9 +6323,6 @@ function isValidContent(content) {
|
|
|
6215
6323
|
if (part === undefined || Object.keys(part).length === 0) {
|
|
6216
6324
|
return false;
|
|
6217
6325
|
}
|
|
6218
|
-
if (!part.thought && part.text !== undefined && part.text === '') {
|
|
6219
|
-
return false;
|
|
6220
|
-
}
|
|
6221
6326
|
}
|
|
6222
6327
|
return true;
|
|
6223
6328
|
}
|
|
@@ -6789,8 +6894,14 @@ function createFileResponseFromMldev(fromObject) {
|
|
|
6789
6894
|
}
|
|
6790
6895
|
return toObject;
|
|
6791
6896
|
}
|
|
6792
|
-
function deleteFileResponseFromMldev() {
|
|
6897
|
+
function deleteFileResponseFromMldev(fromObject) {
|
|
6793
6898
|
const toObject = {};
|
|
6899
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
6900
|
+
'sdkHttpResponse',
|
|
6901
|
+
]);
|
|
6902
|
+
if (fromSdkHttpResponse != null) {
|
|
6903
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
6904
|
+
}
|
|
6794
6905
|
return toObject;
|
|
6795
6906
|
}
|
|
6796
6907
|
|
|
@@ -7059,10 +7170,16 @@ class Files extends BaseModule {
|
|
|
7059
7170
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
7060
7171
|
})
|
|
7061
7172
|
.then((httpResponse) => {
|
|
7062
|
-
return httpResponse.json()
|
|
7173
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
7174
|
+
const response = jsonResponse;
|
|
7175
|
+
response.sdkHttpResponse = {
|
|
7176
|
+
headers: httpResponse.headers,
|
|
7177
|
+
};
|
|
7178
|
+
return response;
|
|
7179
|
+
});
|
|
7063
7180
|
});
|
|
7064
|
-
return response.then(() => {
|
|
7065
|
-
const resp = deleteFileResponseFromMldev();
|
|
7181
|
+
return response.then((apiResponse) => {
|
|
7182
|
+
const resp = deleteFileResponseFromMldev(apiResponse);
|
|
7066
7183
|
const typedResp = new DeleteFileResponse();
|
|
7067
7184
|
Object.assign(typedResp, resp);
|
|
7068
7185
|
return typedResp;
|
|
@@ -10365,6 +10482,21 @@ function imageToMldev(fromObject) {
|
|
|
10365
10482
|
}
|
|
10366
10483
|
return toObject;
|
|
10367
10484
|
}
|
|
10485
|
+
function generateVideosSourceToMldev(fromObject, parentObject) {
|
|
10486
|
+
const toObject = {};
|
|
10487
|
+
const fromPrompt = getValueByPath(fromObject, ['prompt']);
|
|
10488
|
+
if (parentObject !== undefined && fromPrompt != null) {
|
|
10489
|
+
setValueByPath(parentObject, ['instances[0]', 'prompt'], fromPrompt);
|
|
10490
|
+
}
|
|
10491
|
+
const fromImage = getValueByPath(fromObject, ['image']);
|
|
10492
|
+
if (parentObject !== undefined && fromImage != null) {
|
|
10493
|
+
setValueByPath(parentObject, ['instances[0]', 'image'], imageToMldev(fromImage));
|
|
10494
|
+
}
|
|
10495
|
+
if (getValueByPath(fromObject, ['video']) !== undefined) {
|
|
10496
|
+
throw new Error('video parameter is not supported in Gemini API.');
|
|
10497
|
+
}
|
|
10498
|
+
return toObject;
|
|
10499
|
+
}
|
|
10368
10500
|
function generateVideosConfigToMldev(fromObject, parentObject) {
|
|
10369
10501
|
const toObject = {};
|
|
10370
10502
|
const fromNumberOfVideos = getValueByPath(fromObject, [
|
|
@@ -10422,6 +10554,9 @@ function generateVideosConfigToMldev(fromObject, parentObject) {
|
|
|
10422
10554
|
if (getValueByPath(fromObject, ['lastFrame']) !== undefined) {
|
|
10423
10555
|
throw new Error('lastFrame parameter is not supported in Gemini API.');
|
|
10424
10556
|
}
|
|
10557
|
+
if (getValueByPath(fromObject, ['referenceImages']) !== undefined) {
|
|
10558
|
+
throw new Error('referenceImages parameter is not supported in Gemini API.');
|
|
10559
|
+
}
|
|
10425
10560
|
if (getValueByPath(fromObject, ['compressionQuality']) !== undefined) {
|
|
10426
10561
|
throw new Error('compressionQuality parameter is not supported in Gemini API.');
|
|
10427
10562
|
}
|
|
@@ -10444,6 +10579,10 @@ function generateVideosParametersToMldev(apiClient, fromObject) {
|
|
|
10444
10579
|
if (getValueByPath(fromObject, ['video']) !== undefined) {
|
|
10445
10580
|
throw new Error('video parameter is not supported in Gemini API.');
|
|
10446
10581
|
}
|
|
10582
|
+
const fromSource = getValueByPath(fromObject, ['source']);
|
|
10583
|
+
if (fromSource != null) {
|
|
10584
|
+
setValueByPath(toObject, ['config'], generateVideosSourceToMldev(fromSource, toObject));
|
|
10585
|
+
}
|
|
10447
10586
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
10448
10587
|
if (fromConfig != null) {
|
|
10449
10588
|
setValueByPath(toObject, ['config'], generateVideosConfigToMldev(fromConfig, toObject));
|
|
@@ -11568,6 +11707,10 @@ function editImageParametersInternalToVertex(apiClient, fromObject) {
|
|
|
11568
11707
|
}
|
|
11569
11708
|
function upscaleImageAPIConfigInternalToVertex(fromObject, parentObject) {
|
|
11570
11709
|
const toObject = {};
|
|
11710
|
+
const fromOutputGcsUri = getValueByPath(fromObject, ['outputGcsUri']);
|
|
11711
|
+
if (parentObject !== undefined && fromOutputGcsUri != null) {
|
|
11712
|
+
setValueByPath(parentObject, ['parameters', 'storageUri'], fromOutputGcsUri);
|
|
11713
|
+
}
|
|
11571
11714
|
const fromIncludeRaiReason = getValueByPath(fromObject, [
|
|
11572
11715
|
'includeRaiReason',
|
|
11573
11716
|
]);
|
|
@@ -11696,6 +11839,10 @@ function recontextImageConfigToVertex(fromObject, parentObject) {
|
|
|
11696
11839
|
if (parentObject !== undefined && fromPersonGeneration != null) {
|
|
11697
11840
|
setValueByPath(parentObject, ['parameters', 'personGeneration'], fromPersonGeneration);
|
|
11698
11841
|
}
|
|
11842
|
+
const fromAddWatermark = getValueByPath(fromObject, ['addWatermark']);
|
|
11843
|
+
if (parentObject !== undefined && fromAddWatermark != null) {
|
|
11844
|
+
setValueByPath(parentObject, ['parameters', 'addWatermark'], fromAddWatermark);
|
|
11845
|
+
}
|
|
11699
11846
|
const fromOutputMimeType = getValueByPath(fromObject, [
|
|
11700
11847
|
'outputMimeType',
|
|
11701
11848
|
]);
|
|
@@ -11732,6 +11879,78 @@ function recontextImageParametersToVertex(apiClient, fromObject) {
|
|
|
11732
11879
|
}
|
|
11733
11880
|
return toObject;
|
|
11734
11881
|
}
|
|
11882
|
+
function scribbleImageToVertex(fromObject) {
|
|
11883
|
+
const toObject = {};
|
|
11884
|
+
const fromImage = getValueByPath(fromObject, ['image']);
|
|
11885
|
+
if (fromImage != null) {
|
|
11886
|
+
setValueByPath(toObject, ['image'], imageToVertex(fromImage));
|
|
11887
|
+
}
|
|
11888
|
+
return toObject;
|
|
11889
|
+
}
|
|
11890
|
+
function segmentImageSourceToVertex(fromObject, parentObject) {
|
|
11891
|
+
const toObject = {};
|
|
11892
|
+
const fromPrompt = getValueByPath(fromObject, ['prompt']);
|
|
11893
|
+
if (parentObject !== undefined && fromPrompt != null) {
|
|
11894
|
+
setValueByPath(parentObject, ['instances[0]', 'prompt'], fromPrompt);
|
|
11895
|
+
}
|
|
11896
|
+
const fromImage = getValueByPath(fromObject, ['image']);
|
|
11897
|
+
if (parentObject !== undefined && fromImage != null) {
|
|
11898
|
+
setValueByPath(parentObject, ['instances[0]', 'image'], imageToVertex(fromImage));
|
|
11899
|
+
}
|
|
11900
|
+
const fromScribbleImage = getValueByPath(fromObject, [
|
|
11901
|
+
'scribbleImage',
|
|
11902
|
+
]);
|
|
11903
|
+
if (parentObject !== undefined && fromScribbleImage != null) {
|
|
11904
|
+
setValueByPath(parentObject, ['instances[0]', 'scribble'], scribbleImageToVertex(fromScribbleImage));
|
|
11905
|
+
}
|
|
11906
|
+
return toObject;
|
|
11907
|
+
}
|
|
11908
|
+
function segmentImageConfigToVertex(fromObject, parentObject) {
|
|
11909
|
+
const toObject = {};
|
|
11910
|
+
const fromMode = getValueByPath(fromObject, ['mode']);
|
|
11911
|
+
if (parentObject !== undefined && fromMode != null) {
|
|
11912
|
+
setValueByPath(parentObject, ['parameters', 'mode'], fromMode);
|
|
11913
|
+
}
|
|
11914
|
+
const fromMaxPredictions = getValueByPath(fromObject, [
|
|
11915
|
+
'maxPredictions',
|
|
11916
|
+
]);
|
|
11917
|
+
if (parentObject !== undefined && fromMaxPredictions != null) {
|
|
11918
|
+
setValueByPath(parentObject, ['parameters', 'maxPredictions'], fromMaxPredictions);
|
|
11919
|
+
}
|
|
11920
|
+
const fromConfidenceThreshold = getValueByPath(fromObject, [
|
|
11921
|
+
'confidenceThreshold',
|
|
11922
|
+
]);
|
|
11923
|
+
if (parentObject !== undefined && fromConfidenceThreshold != null) {
|
|
11924
|
+
setValueByPath(parentObject, ['parameters', 'confidenceThreshold'], fromConfidenceThreshold);
|
|
11925
|
+
}
|
|
11926
|
+
const fromMaskDilation = getValueByPath(fromObject, ['maskDilation']);
|
|
11927
|
+
if (parentObject !== undefined && fromMaskDilation != null) {
|
|
11928
|
+
setValueByPath(parentObject, ['parameters', 'maskDilation'], fromMaskDilation);
|
|
11929
|
+
}
|
|
11930
|
+
const fromBinaryColorThreshold = getValueByPath(fromObject, [
|
|
11931
|
+
'binaryColorThreshold',
|
|
11932
|
+
]);
|
|
11933
|
+
if (parentObject !== undefined && fromBinaryColorThreshold != null) {
|
|
11934
|
+
setValueByPath(parentObject, ['parameters', 'binaryColorThreshold'], fromBinaryColorThreshold);
|
|
11935
|
+
}
|
|
11936
|
+
return toObject;
|
|
11937
|
+
}
|
|
11938
|
+
function segmentImageParametersToVertex(apiClient, fromObject) {
|
|
11939
|
+
const toObject = {};
|
|
11940
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
11941
|
+
if (fromModel != null) {
|
|
11942
|
+
setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
|
|
11943
|
+
}
|
|
11944
|
+
const fromSource = getValueByPath(fromObject, ['source']);
|
|
11945
|
+
if (fromSource != null) {
|
|
11946
|
+
setValueByPath(toObject, ['config'], segmentImageSourceToVertex(fromSource, toObject));
|
|
11947
|
+
}
|
|
11948
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
11949
|
+
if (fromConfig != null) {
|
|
11950
|
+
setValueByPath(toObject, ['config'], segmentImageConfigToVertex(fromConfig, toObject));
|
|
11951
|
+
}
|
|
11952
|
+
return toObject;
|
|
11953
|
+
}
|
|
11735
11954
|
function getModelParametersToVertex(apiClient, fromObject) {
|
|
11736
11955
|
const toObject = {};
|
|
11737
11956
|
const fromModel = getValueByPath(fromObject, ['model']);
|
|
@@ -11900,6 +12119,36 @@ function videoToVertex(fromObject) {
|
|
|
11900
12119
|
}
|
|
11901
12120
|
return toObject;
|
|
11902
12121
|
}
|
|
12122
|
+
function generateVideosSourceToVertex(fromObject, parentObject) {
|
|
12123
|
+
const toObject = {};
|
|
12124
|
+
const fromPrompt = getValueByPath(fromObject, ['prompt']);
|
|
12125
|
+
if (parentObject !== undefined && fromPrompt != null) {
|
|
12126
|
+
setValueByPath(parentObject, ['instances[0]', 'prompt'], fromPrompt);
|
|
12127
|
+
}
|
|
12128
|
+
const fromImage = getValueByPath(fromObject, ['image']);
|
|
12129
|
+
if (parentObject !== undefined && fromImage != null) {
|
|
12130
|
+
setValueByPath(parentObject, ['instances[0]', 'image'], imageToVertex(fromImage));
|
|
12131
|
+
}
|
|
12132
|
+
const fromVideo = getValueByPath(fromObject, ['video']);
|
|
12133
|
+
if (parentObject !== undefined && fromVideo != null) {
|
|
12134
|
+
setValueByPath(parentObject, ['instances[0]', 'video'], videoToVertex(fromVideo));
|
|
12135
|
+
}
|
|
12136
|
+
return toObject;
|
|
12137
|
+
}
|
|
12138
|
+
function videoGenerationReferenceImageToVertex(fromObject) {
|
|
12139
|
+
const toObject = {};
|
|
12140
|
+
const fromImage = getValueByPath(fromObject, ['image']);
|
|
12141
|
+
if (fromImage != null) {
|
|
12142
|
+
setValueByPath(toObject, ['image'], imageToVertex(fromImage));
|
|
12143
|
+
}
|
|
12144
|
+
const fromReferenceType = getValueByPath(fromObject, [
|
|
12145
|
+
'referenceType',
|
|
12146
|
+
]);
|
|
12147
|
+
if (fromReferenceType != null) {
|
|
12148
|
+
setValueByPath(toObject, ['referenceType'], fromReferenceType);
|
|
12149
|
+
}
|
|
12150
|
+
return toObject;
|
|
12151
|
+
}
|
|
11903
12152
|
function generateVideosConfigToVertex(fromObject, parentObject) {
|
|
11904
12153
|
const toObject = {};
|
|
11905
12154
|
const fromNumberOfVideos = getValueByPath(fromObject, [
|
|
@@ -11966,6 +12215,18 @@ function generateVideosConfigToVertex(fromObject, parentObject) {
|
|
|
11966
12215
|
if (parentObject !== undefined && fromLastFrame != null) {
|
|
11967
12216
|
setValueByPath(parentObject, ['instances[0]', 'lastFrame'], imageToVertex(fromLastFrame));
|
|
11968
12217
|
}
|
|
12218
|
+
const fromReferenceImages = getValueByPath(fromObject, [
|
|
12219
|
+
'referenceImages',
|
|
12220
|
+
]);
|
|
12221
|
+
if (parentObject !== undefined && fromReferenceImages != null) {
|
|
12222
|
+
let transformedList = fromReferenceImages;
|
|
12223
|
+
if (Array.isArray(transformedList)) {
|
|
12224
|
+
transformedList = transformedList.map((item) => {
|
|
12225
|
+
return videoGenerationReferenceImageToVertex(item);
|
|
12226
|
+
});
|
|
12227
|
+
}
|
|
12228
|
+
setValueByPath(parentObject, ['instances[0]', 'referenceImages'], transformedList);
|
|
12229
|
+
}
|
|
11969
12230
|
const fromCompressionQuality = getValueByPath(fromObject, [
|
|
11970
12231
|
'compressionQuality',
|
|
11971
12232
|
]);
|
|
@@ -11992,6 +12253,10 @@ function generateVideosParametersToVertex(apiClient, fromObject) {
|
|
|
11992
12253
|
if (fromVideo != null) {
|
|
11993
12254
|
setValueByPath(toObject, ['instances[0]', 'video'], videoToVertex(fromVideo));
|
|
11994
12255
|
}
|
|
12256
|
+
const fromSource = getValueByPath(fromObject, ['source']);
|
|
12257
|
+
if (fromSource != null) {
|
|
12258
|
+
setValueByPath(toObject, ['config'], generateVideosSourceToVertex(fromSource, toObject));
|
|
12259
|
+
}
|
|
11995
12260
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
11996
12261
|
if (fromConfig != null) {
|
|
11997
12262
|
setValueByPath(toObject, ['config'], generateVideosConfigToVertex(fromConfig, toObject));
|
|
@@ -12442,8 +12707,14 @@ function listModelsResponseFromMldev(fromObject) {
|
|
|
12442
12707
|
}
|
|
12443
12708
|
return toObject;
|
|
12444
12709
|
}
|
|
12445
|
-
function deleteModelResponseFromMldev() {
|
|
12710
|
+
function deleteModelResponseFromMldev(fromObject) {
|
|
12446
12711
|
const toObject = {};
|
|
12712
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
12713
|
+
'sdkHttpResponse',
|
|
12714
|
+
]);
|
|
12715
|
+
if (fromSdkHttpResponse != null) {
|
|
12716
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
12717
|
+
}
|
|
12447
12718
|
return toObject;
|
|
12448
12719
|
}
|
|
12449
12720
|
function countTokensResponseFromMldev(fromObject) {
|
|
@@ -13015,6 +13286,50 @@ function recontextImageResponseFromVertex(fromObject) {
|
|
|
13015
13286
|
}
|
|
13016
13287
|
return toObject;
|
|
13017
13288
|
}
|
|
13289
|
+
function entityLabelFromVertex(fromObject) {
|
|
13290
|
+
const toObject = {};
|
|
13291
|
+
const fromLabel = getValueByPath(fromObject, ['label']);
|
|
13292
|
+
if (fromLabel != null) {
|
|
13293
|
+
setValueByPath(toObject, ['label'], fromLabel);
|
|
13294
|
+
}
|
|
13295
|
+
const fromScore = getValueByPath(fromObject, ['score']);
|
|
13296
|
+
if (fromScore != null) {
|
|
13297
|
+
setValueByPath(toObject, ['score'], fromScore);
|
|
13298
|
+
}
|
|
13299
|
+
return toObject;
|
|
13300
|
+
}
|
|
13301
|
+
function generatedImageMaskFromVertex(fromObject) {
|
|
13302
|
+
const toObject = {};
|
|
13303
|
+
const fromMask = getValueByPath(fromObject, ['_self']);
|
|
13304
|
+
if (fromMask != null) {
|
|
13305
|
+
setValueByPath(toObject, ['mask'], imageFromVertex(fromMask));
|
|
13306
|
+
}
|
|
13307
|
+
const fromLabels = getValueByPath(fromObject, ['labels']);
|
|
13308
|
+
if (fromLabels != null) {
|
|
13309
|
+
let transformedList = fromLabels;
|
|
13310
|
+
if (Array.isArray(transformedList)) {
|
|
13311
|
+
transformedList = transformedList.map((item) => {
|
|
13312
|
+
return entityLabelFromVertex(item);
|
|
13313
|
+
});
|
|
13314
|
+
}
|
|
13315
|
+
setValueByPath(toObject, ['labels'], transformedList);
|
|
13316
|
+
}
|
|
13317
|
+
return toObject;
|
|
13318
|
+
}
|
|
13319
|
+
function segmentImageResponseFromVertex(fromObject) {
|
|
13320
|
+
const toObject = {};
|
|
13321
|
+
const fromGeneratedMasks = getValueByPath(fromObject, ['predictions']);
|
|
13322
|
+
if (fromGeneratedMasks != null) {
|
|
13323
|
+
let transformedList = fromGeneratedMasks;
|
|
13324
|
+
if (Array.isArray(transformedList)) {
|
|
13325
|
+
transformedList = transformedList.map((item) => {
|
|
13326
|
+
return generatedImageMaskFromVertex(item);
|
|
13327
|
+
});
|
|
13328
|
+
}
|
|
13329
|
+
setValueByPath(toObject, ['generatedMasks'], transformedList);
|
|
13330
|
+
}
|
|
13331
|
+
return toObject;
|
|
13332
|
+
}
|
|
13018
13333
|
function endpointFromVertex(fromObject) {
|
|
13019
13334
|
const toObject = {};
|
|
13020
13335
|
const fromName = getValueByPath(fromObject, ['endpoint']);
|
|
@@ -13144,8 +13459,14 @@ function listModelsResponseFromVertex(fromObject) {
|
|
|
13144
13459
|
}
|
|
13145
13460
|
return toObject;
|
|
13146
13461
|
}
|
|
13147
|
-
function deleteModelResponseFromVertex() {
|
|
13462
|
+
function deleteModelResponseFromVertex(fromObject) {
|
|
13148
13463
|
const toObject = {};
|
|
13464
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
13465
|
+
'sdkHttpResponse',
|
|
13466
|
+
]);
|
|
13467
|
+
if (fromSdkHttpResponse != null) {
|
|
13468
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
13469
|
+
}
|
|
13149
13470
|
return toObject;
|
|
13150
13471
|
}
|
|
13151
13472
|
function countTokensResponseFromVertex(fromObject) {
|
|
@@ -13262,7 +13583,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
13262
13583
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
13263
13584
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
13264
13585
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
13265
|
-
const SDK_VERSION = '1.
|
|
13586
|
+
const SDK_VERSION = '1.16.0'; // x-release-please-version
|
|
13266
13587
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
13267
13588
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
13268
13589
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -15034,7 +15355,9 @@ class Models extends BaseModule {
|
|
|
15034
15355
|
* ```ts
|
|
15035
15356
|
* const operation = await ai.models.generateVideos({
|
|
15036
15357
|
* model: 'veo-2.0-generate-001',
|
|
15037
|
-
*
|
|
15358
|
+
* source: {
|
|
15359
|
+
* prompt: 'A neon hologram of a cat driving at top speed',
|
|
15360
|
+
* },
|
|
15038
15361
|
* config: {
|
|
15039
15362
|
* numberOfVideos: 1
|
|
15040
15363
|
* });
|
|
@@ -15048,6 +15371,9 @@ class Models extends BaseModule {
|
|
|
15048
15371
|
* ```
|
|
15049
15372
|
*/
|
|
15050
15373
|
this.generateVideos = async (params) => {
|
|
15374
|
+
if ((params.prompt || params.image || params.video) && params.source) {
|
|
15375
|
+
throw new Error('Source and prompt/image/video are mutually exclusive. Please only use source.');
|
|
15376
|
+
}
|
|
15051
15377
|
return await this.generateVideosInternal(params);
|
|
15052
15378
|
};
|
|
15053
15379
|
}
|
|
@@ -15705,6 +16031,61 @@ class Models extends BaseModule {
|
|
|
15705
16031
|
throw new Error('This method is only supported by the Vertex AI.');
|
|
15706
16032
|
}
|
|
15707
16033
|
}
|
|
16034
|
+
/**
|
|
16035
|
+
* Segments an image, creating a mask of a specified area.
|
|
16036
|
+
*
|
|
16037
|
+
* @param params - The parameters for segmenting an image.
|
|
16038
|
+
* @return The response from the API.
|
|
16039
|
+
*
|
|
16040
|
+
* @example
|
|
16041
|
+
* ```ts
|
|
16042
|
+
* const response = await ai.models.segmentImage({
|
|
16043
|
+
* model: 'image-segmentation-001',
|
|
16044
|
+
* source: {
|
|
16045
|
+
* image: image,
|
|
16046
|
+
* },
|
|
16047
|
+
* config: {
|
|
16048
|
+
* mode: 'foreground',
|
|
16049
|
+
* },
|
|
16050
|
+
* });
|
|
16051
|
+
* console.log(response?.generatedMasks?.[0]?.mask?.imageBytes);
|
|
16052
|
+
* ```
|
|
16053
|
+
*/
|
|
16054
|
+
async segmentImage(params) {
|
|
16055
|
+
var _a, _b;
|
|
16056
|
+
let response;
|
|
16057
|
+
let path = '';
|
|
16058
|
+
let queryParams = {};
|
|
16059
|
+
if (this.apiClient.isVertexAI()) {
|
|
16060
|
+
const body = segmentImageParametersToVertex(this.apiClient, params);
|
|
16061
|
+
path = formatMap('{model}:predict', body['_url']);
|
|
16062
|
+
queryParams = body['_query'];
|
|
16063
|
+
delete body['config'];
|
|
16064
|
+
delete body['_url'];
|
|
16065
|
+
delete body['_query'];
|
|
16066
|
+
response = this.apiClient
|
|
16067
|
+
.request({
|
|
16068
|
+
path: path,
|
|
16069
|
+
queryParams: queryParams,
|
|
16070
|
+
body: JSON.stringify(body),
|
|
16071
|
+
httpMethod: 'POST',
|
|
16072
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
16073
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
16074
|
+
})
|
|
16075
|
+
.then((httpResponse) => {
|
|
16076
|
+
return httpResponse.json();
|
|
16077
|
+
});
|
|
16078
|
+
return response.then((apiResponse) => {
|
|
16079
|
+
const resp = segmentImageResponseFromVertex(apiResponse);
|
|
16080
|
+
const typedResp = new SegmentImageResponse();
|
|
16081
|
+
Object.assign(typedResp, resp);
|
|
16082
|
+
return typedResp;
|
|
16083
|
+
});
|
|
16084
|
+
}
|
|
16085
|
+
else {
|
|
16086
|
+
throw new Error('This method is only supported by the Vertex AI.');
|
|
16087
|
+
}
|
|
16088
|
+
}
|
|
15708
16089
|
/**
|
|
15709
16090
|
* Fetches information about a model by name.
|
|
15710
16091
|
*
|
|
@@ -15941,10 +16322,16 @@ class Models extends BaseModule {
|
|
|
15941
16322
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
15942
16323
|
})
|
|
15943
16324
|
.then((httpResponse) => {
|
|
15944
|
-
return httpResponse.json()
|
|
16325
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
16326
|
+
const response = jsonResponse;
|
|
16327
|
+
response.sdkHttpResponse = {
|
|
16328
|
+
headers: httpResponse.headers,
|
|
16329
|
+
};
|
|
16330
|
+
return response;
|
|
16331
|
+
});
|
|
15945
16332
|
});
|
|
15946
|
-
return response.then(() => {
|
|
15947
|
-
const resp = deleteModelResponseFromVertex();
|
|
16333
|
+
return response.then((apiResponse) => {
|
|
16334
|
+
const resp = deleteModelResponseFromVertex(apiResponse);
|
|
15948
16335
|
const typedResp = new DeleteModelResponse();
|
|
15949
16336
|
Object.assign(typedResp, resp);
|
|
15950
16337
|
return typedResp;
|
|
@@ -15967,10 +16354,16 @@ class Models extends BaseModule {
|
|
|
15967
16354
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
15968
16355
|
})
|
|
15969
16356
|
.then((httpResponse) => {
|
|
15970
|
-
return httpResponse.json()
|
|
16357
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
16358
|
+
const response = jsonResponse;
|
|
16359
|
+
response.sdkHttpResponse = {
|
|
16360
|
+
headers: httpResponse.headers,
|
|
16361
|
+
};
|
|
16362
|
+
return response;
|
|
16363
|
+
});
|
|
15971
16364
|
});
|
|
15972
|
-
return response.then(() => {
|
|
15973
|
-
const resp = deleteModelResponseFromMldev();
|
|
16365
|
+
return response.then((apiResponse) => {
|
|
16366
|
+
const resp = deleteModelResponseFromMldev(apiResponse);
|
|
15974
16367
|
const typedResp = new DeleteModelResponse();
|
|
15975
16368
|
Object.assign(typedResp, resp);
|
|
15976
16369
|
return typedResp;
|
|
@@ -16225,13 +16618,17 @@ function getOperationParametersToMldev(fromObject) {
|
|
|
16225
16618
|
}
|
|
16226
16619
|
return toObject;
|
|
16227
16620
|
}
|
|
16228
|
-
function
|
|
16621
|
+
function fetchPredictOperationParametersToVertex(fromObject) {
|
|
16229
16622
|
const toObject = {};
|
|
16230
16623
|
const fromOperationName = getValueByPath(fromObject, [
|
|
16231
16624
|
'operationName',
|
|
16232
16625
|
]);
|
|
16233
16626
|
if (fromOperationName != null) {
|
|
16234
|
-
setValueByPath(toObject, ['
|
|
16627
|
+
setValueByPath(toObject, ['operationName'], fromOperationName);
|
|
16628
|
+
}
|
|
16629
|
+
const fromResourceName = getValueByPath(fromObject, ['resourceName']);
|
|
16630
|
+
if (fromResourceName != null) {
|
|
16631
|
+
setValueByPath(toObject, ['_url', 'resourceName'], fromResourceName);
|
|
16235
16632
|
}
|
|
16236
16633
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
16237
16634
|
if (fromConfig != null) {
|
|
@@ -16239,17 +16636,13 @@ function getOperationParametersToVertex(fromObject) {
|
|
|
16239
16636
|
}
|
|
16240
16637
|
return toObject;
|
|
16241
16638
|
}
|
|
16242
|
-
function
|
|
16639
|
+
function getOperationParametersToVertex(fromObject) {
|
|
16243
16640
|
const toObject = {};
|
|
16244
16641
|
const fromOperationName = getValueByPath(fromObject, [
|
|
16245
16642
|
'operationName',
|
|
16246
16643
|
]);
|
|
16247
16644
|
if (fromOperationName != null) {
|
|
16248
|
-
setValueByPath(toObject, ['operationName'], fromOperationName);
|
|
16249
|
-
}
|
|
16250
|
-
const fromResourceName = getValueByPath(fromObject, ['resourceName']);
|
|
16251
|
-
if (fromResourceName != null) {
|
|
16252
|
-
setValueByPath(toObject, ['_url', 'resourceName'], fromResourceName);
|
|
16645
|
+
setValueByPath(toObject, ['_url', 'operationName'], fromOperationName);
|
|
16253
16646
|
}
|
|
16254
16647
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
16255
16648
|
if (fromConfig != null) {
|
|
@@ -17336,6 +17729,18 @@ function listTuningJobsParametersToMldev(fromObject) {
|
|
|
17336
17729
|
}
|
|
17337
17730
|
return toObject;
|
|
17338
17731
|
}
|
|
17732
|
+
function cancelTuningJobParametersToMldev(fromObject) {
|
|
17733
|
+
const toObject = {};
|
|
17734
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
17735
|
+
if (fromName != null) {
|
|
17736
|
+
setValueByPath(toObject, ['_url', 'name'], fromName);
|
|
17737
|
+
}
|
|
17738
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
17739
|
+
if (fromConfig != null) {
|
|
17740
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
17741
|
+
}
|
|
17742
|
+
return toObject;
|
|
17743
|
+
}
|
|
17339
17744
|
function tuningExampleToMldev(fromObject) {
|
|
17340
17745
|
const toObject = {};
|
|
17341
17746
|
const fromTextInput = getValueByPath(fromObject, ['textInput']);
|
|
@@ -17473,6 +17878,18 @@ function listTuningJobsParametersToVertex(fromObject) {
|
|
|
17473
17878
|
}
|
|
17474
17879
|
return toObject;
|
|
17475
17880
|
}
|
|
17881
|
+
function cancelTuningJobParametersToVertex(fromObject) {
|
|
17882
|
+
const toObject = {};
|
|
17883
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
17884
|
+
if (fromName != null) {
|
|
17885
|
+
setValueByPath(toObject, ['_url', 'name'], fromName);
|
|
17886
|
+
}
|
|
17887
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
17888
|
+
if (fromConfig != null) {
|
|
17889
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
17890
|
+
}
|
|
17891
|
+
return toObject;
|
|
17892
|
+
}
|
|
17476
17893
|
function tuningDatasetToVertex(fromObject, parentObject) {
|
|
17477
17894
|
const toObject = {};
|
|
17478
17895
|
const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
|
|
@@ -18126,6 +18543,54 @@ class Tunings extends BaseModule {
|
|
|
18126
18543
|
});
|
|
18127
18544
|
}
|
|
18128
18545
|
}
|
|
18546
|
+
/**
|
|
18547
|
+
* Cancels a tuning job.
|
|
18548
|
+
*
|
|
18549
|
+
* @param params - The parameters for the cancel request.
|
|
18550
|
+
* @return The empty response returned by the API.
|
|
18551
|
+
*
|
|
18552
|
+
* @example
|
|
18553
|
+
* ```ts
|
|
18554
|
+
* await ai.tunings.cancel({name: '...'}); // The server-generated resource name.
|
|
18555
|
+
* ```
|
|
18556
|
+
*/
|
|
18557
|
+
async cancel(params) {
|
|
18558
|
+
var _a, _b, _c, _d;
|
|
18559
|
+
let path = '';
|
|
18560
|
+
let queryParams = {};
|
|
18561
|
+
if (this.apiClient.isVertexAI()) {
|
|
18562
|
+
const body = cancelTuningJobParametersToVertex(params);
|
|
18563
|
+
path = formatMap('{name}:cancel', body['_url']);
|
|
18564
|
+
queryParams = body['_query'];
|
|
18565
|
+
delete body['config'];
|
|
18566
|
+
delete body['_url'];
|
|
18567
|
+
delete body['_query'];
|
|
18568
|
+
await this.apiClient.request({
|
|
18569
|
+
path: path,
|
|
18570
|
+
queryParams: queryParams,
|
|
18571
|
+
body: JSON.stringify(body),
|
|
18572
|
+
httpMethod: 'POST',
|
|
18573
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
18574
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
18575
|
+
});
|
|
18576
|
+
}
|
|
18577
|
+
else {
|
|
18578
|
+
const body = cancelTuningJobParametersToMldev(params);
|
|
18579
|
+
path = formatMap('{name}:cancel', body['_url']);
|
|
18580
|
+
queryParams = body['_query'];
|
|
18581
|
+
delete body['config'];
|
|
18582
|
+
delete body['_url'];
|
|
18583
|
+
delete body['_query'];
|
|
18584
|
+
await this.apiClient.request({
|
|
18585
|
+
path: path,
|
|
18586
|
+
queryParams: queryParams,
|
|
18587
|
+
body: JSON.stringify(body),
|
|
18588
|
+
httpMethod: 'POST',
|
|
18589
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
18590
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
18591
|
+
});
|
|
18592
|
+
}
|
|
18593
|
+
}
|
|
18129
18594
|
async tuneInternal(params) {
|
|
18130
18595
|
var _a, _b;
|
|
18131
18596
|
let response;
|
|
@@ -18454,5 +18919,5 @@ class GoogleGenAI {
|
|
|
18454
18919
|
}
|
|
18455
18920
|
}
|
|
18456
18921
|
|
|
18457
|
-
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 };
|
|
18922
|
+
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 };
|
|
18458
18923
|
//# sourceMappingURL=index.mjs.map
|