@google/genai 1.15.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/dist/genai.d.ts +96 -14
- package/dist/index.cjs +295 -89
- package/dist/index.mjs +296 -90
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.cjs +296 -90
- package/dist/node/index.mjs +297 -91
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/node.d.ts +96 -14
- package/dist/web/index.mjs +296 -90
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +96 -14
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -771,6 +771,10 @@ exports.FunctionCallingConfigMode = void 0;
|
|
|
771
771
|
* Model will not predict any function calls. Model behavior is same as when not passing any function declarations.
|
|
772
772
|
*/
|
|
773
773
|
FunctionCallingConfigMode["NONE"] = "NONE";
|
|
774
|
+
/**
|
|
775
|
+
* Model decides to predict either a function call or a natural language response, but will validate function calls with constrained decoding. If "allowed_function_names" are set, the predicted function call will be limited to any one of "allowed_function_names", else the predicted function call will be any one of the provided "function_declarations".
|
|
776
|
+
*/
|
|
777
|
+
FunctionCallingConfigMode["VALIDATED"] = "VALIDATED";
|
|
774
778
|
})(exports.FunctionCallingConfigMode || (exports.FunctionCallingConfigMode = {}));
|
|
775
779
|
/** Enum that controls the safety filter level for objectionable content. */
|
|
776
780
|
exports.SafetyFilterLevel = void 0;
|
|
@@ -878,6 +882,21 @@ exports.SegmentMode = void 0;
|
|
|
878
882
|
SegmentMode["SEMANTIC"] = "SEMANTIC";
|
|
879
883
|
SegmentMode["INTERACTIVE"] = "INTERACTIVE";
|
|
880
884
|
})(exports.SegmentMode || (exports.SegmentMode = {}));
|
|
885
|
+
/** Enum for the reference type of a video generation reference image. */
|
|
886
|
+
exports.VideoGenerationReferenceType = void 0;
|
|
887
|
+
(function (VideoGenerationReferenceType) {
|
|
888
|
+
/**
|
|
889
|
+
* A reference image that provides assets to the generated video,
|
|
890
|
+
such as the scene, an object, a character, etc.
|
|
891
|
+
*/
|
|
892
|
+
VideoGenerationReferenceType["ASSET"] = "ASSET";
|
|
893
|
+
/**
|
|
894
|
+
* A reference image that provides aesthetics including colors,
|
|
895
|
+
lighting, texture, etc., to be used as the style of the generated video,
|
|
896
|
+
such as 'anime', 'photography', 'origami', etc.
|
|
897
|
+
*/
|
|
898
|
+
VideoGenerationReferenceType["STYLE"] = "STYLE";
|
|
899
|
+
})(exports.VideoGenerationReferenceType || (exports.VideoGenerationReferenceType = {}));
|
|
881
900
|
/** Enum that controls the compression quality of the generated videos. */
|
|
882
901
|
exports.VideoCompressionQuality = void 0;
|
|
883
902
|
(function (VideoCompressionQuality) {
|
|
@@ -1540,6 +1559,65 @@ class ComputeTokensResponse {
|
|
|
1540
1559
|
/** Response with generated videos. */
|
|
1541
1560
|
class GenerateVideosResponse {
|
|
1542
1561
|
}
|
|
1562
|
+
/** A video generation operation. */
|
|
1563
|
+
class GenerateVideosOperation {
|
|
1564
|
+
/**
|
|
1565
|
+
* Instantiates an Operation of the same type as the one being called with the fields set from the API response.
|
|
1566
|
+
* @internal
|
|
1567
|
+
*/
|
|
1568
|
+
_fromAPIResponse({ apiResponse, isVertexAI, }) {
|
|
1569
|
+
const operation = new GenerateVideosOperation();
|
|
1570
|
+
operation.name = apiResponse['name'];
|
|
1571
|
+
operation.metadata = apiResponse['metadata'];
|
|
1572
|
+
operation.done = apiResponse['done'];
|
|
1573
|
+
operation.error = apiResponse['error'];
|
|
1574
|
+
if (isVertexAI) {
|
|
1575
|
+
const response = apiResponse['response'];
|
|
1576
|
+
if (response) {
|
|
1577
|
+
const operationResponse = new GenerateVideosResponse();
|
|
1578
|
+
const responseVideos = response['videos'];
|
|
1579
|
+
operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
|
|
1580
|
+
return {
|
|
1581
|
+
video: {
|
|
1582
|
+
uri: generatedVideo['gcsUri'],
|
|
1583
|
+
videoBytes: generatedVideo['bytesBase64Encoded']
|
|
1584
|
+
? tBytes$1(generatedVideo['bytesBase64Encoded'])
|
|
1585
|
+
: undefined,
|
|
1586
|
+
mimeType: generatedVideo['mimeType'],
|
|
1587
|
+
},
|
|
1588
|
+
};
|
|
1589
|
+
});
|
|
1590
|
+
operationResponse.raiMediaFilteredCount = response['raiMediaFilteredCount'];
|
|
1591
|
+
operationResponse.raiMediaFilteredReasons = response['raiMediaFilteredReasons'];
|
|
1592
|
+
operation.response = operationResponse;
|
|
1593
|
+
}
|
|
1594
|
+
}
|
|
1595
|
+
else {
|
|
1596
|
+
const response = apiResponse['response'];
|
|
1597
|
+
if (response) {
|
|
1598
|
+
const operationResponse = new GenerateVideosResponse();
|
|
1599
|
+
const generatedVideoResponse = response['generateVideoResponse'];
|
|
1600
|
+
const responseVideos = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['generatedSamples'];
|
|
1601
|
+
operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
|
|
1602
|
+
const video = generatedVideo['video'];
|
|
1603
|
+
return {
|
|
1604
|
+
video: {
|
|
1605
|
+
uri: video === null || video === void 0 ? void 0 : video['uri'],
|
|
1606
|
+
videoBytes: (video === null || video === void 0 ? void 0 : video['encodedVideo'])
|
|
1607
|
+
? tBytes$1(video === null || video === void 0 ? void 0 : video['encodedVideo'])
|
|
1608
|
+
: undefined,
|
|
1609
|
+
mimeType: generatedVideo['encoding'],
|
|
1610
|
+
},
|
|
1611
|
+
};
|
|
1612
|
+
});
|
|
1613
|
+
operationResponse.raiMediaFilteredCount = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredCount'];
|
|
1614
|
+
operationResponse.raiMediaFilteredReasons = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredReasons'];
|
|
1615
|
+
operation.response = operationResponse;
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1618
|
+
return operation;
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1543
1621
|
/** Response for the list tuning jobs method. */
|
|
1544
1622
|
class ListTuningJobsResponse {
|
|
1545
1623
|
}
|
|
@@ -1731,65 +1809,6 @@ class LiveServerMessage {
|
|
|
1731
1809
|
return data.length > 0 ? btoa(data) : undefined;
|
|
1732
1810
|
}
|
|
1733
1811
|
}
|
|
1734
|
-
/** A video generation long-running operation. */
|
|
1735
|
-
class GenerateVideosOperation {
|
|
1736
|
-
/**
|
|
1737
|
-
* Instantiates an Operation of the same type as the one being called with the fields set from the API response.
|
|
1738
|
-
* @internal
|
|
1739
|
-
*/
|
|
1740
|
-
_fromAPIResponse({ apiResponse, isVertexAI, }) {
|
|
1741
|
-
const operation = new GenerateVideosOperation();
|
|
1742
|
-
operation.name = apiResponse['name'];
|
|
1743
|
-
operation.metadata = apiResponse['metadata'];
|
|
1744
|
-
operation.done = apiResponse['done'];
|
|
1745
|
-
operation.error = apiResponse['error'];
|
|
1746
|
-
if (isVertexAI) {
|
|
1747
|
-
const response = apiResponse['response'];
|
|
1748
|
-
if (response) {
|
|
1749
|
-
const operationResponse = new GenerateVideosResponse();
|
|
1750
|
-
const responseVideos = response['videos'];
|
|
1751
|
-
operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
|
|
1752
|
-
return {
|
|
1753
|
-
video: {
|
|
1754
|
-
uri: generatedVideo['gcsUri'],
|
|
1755
|
-
videoBytes: generatedVideo['bytesBase64Encoded']
|
|
1756
|
-
? tBytes$1(generatedVideo['bytesBase64Encoded'])
|
|
1757
|
-
: undefined,
|
|
1758
|
-
mimeType: generatedVideo['mimeType'],
|
|
1759
|
-
},
|
|
1760
|
-
};
|
|
1761
|
-
});
|
|
1762
|
-
operationResponse.raiMediaFilteredCount = response['raiMediaFilteredCount'];
|
|
1763
|
-
operationResponse.raiMediaFilteredReasons = response['raiMediaFilteredReasons'];
|
|
1764
|
-
operation.response = operationResponse;
|
|
1765
|
-
}
|
|
1766
|
-
}
|
|
1767
|
-
else {
|
|
1768
|
-
const response = apiResponse['response'];
|
|
1769
|
-
if (response) {
|
|
1770
|
-
const operationResponse = new GenerateVideosResponse();
|
|
1771
|
-
const generatedVideoResponse = response['generateVideoResponse'];
|
|
1772
|
-
const responseVideos = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['generatedSamples'];
|
|
1773
|
-
operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
|
|
1774
|
-
const video = generatedVideo['video'];
|
|
1775
|
-
return {
|
|
1776
|
-
video: {
|
|
1777
|
-
uri: video === null || video === void 0 ? void 0 : video['uri'],
|
|
1778
|
-
videoBytes: (video === null || video === void 0 ? void 0 : video['encodedVideo'])
|
|
1779
|
-
? tBytes$1(video === null || video === void 0 ? void 0 : video['encodedVideo'])
|
|
1780
|
-
: undefined,
|
|
1781
|
-
mimeType: generatedVideo['encoding'],
|
|
1782
|
-
},
|
|
1783
|
-
};
|
|
1784
|
-
});
|
|
1785
|
-
operationResponse.raiMediaFilteredCount = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredCount'];
|
|
1786
|
-
operationResponse.raiMediaFilteredReasons = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredReasons'];
|
|
1787
|
-
operation.response = operationResponse;
|
|
1788
|
-
}
|
|
1789
|
-
}
|
|
1790
|
-
return operation;
|
|
1791
|
-
}
|
|
1792
|
-
}
|
|
1793
1812
|
/** Client generated response to a `ToolCall` received from the server.
|
|
1794
1813
|
|
|
1795
1814
|
Individual `FunctionResponse` objects are matched to the respective
|
|
@@ -2436,6 +2455,9 @@ function mcpToGeminiTool(mcpTool, config = {}) {
|
|
|
2436
2455
|
description: mcpToolSchema['description'],
|
|
2437
2456
|
parametersJsonSchema: mcpToolSchema['inputSchema'],
|
|
2438
2457
|
};
|
|
2458
|
+
if (mcpToolSchema['outputSchema']) {
|
|
2459
|
+
functionDeclaration['responseJsonSchema'] = mcpToolSchema['outputSchema'];
|
|
2460
|
+
}
|
|
2439
2461
|
if (config.behavior) {
|
|
2440
2462
|
functionDeclaration['behavior'] = config.behavior;
|
|
2441
2463
|
}
|
|
@@ -5683,8 +5705,14 @@ function cachedContentFromMldev(fromObject) {
|
|
|
5683
5705
|
}
|
|
5684
5706
|
return toObject;
|
|
5685
5707
|
}
|
|
5686
|
-
function deleteCachedContentResponseFromMldev() {
|
|
5708
|
+
function deleteCachedContentResponseFromMldev(fromObject) {
|
|
5687
5709
|
const toObject = {};
|
|
5710
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
5711
|
+
'sdkHttpResponse',
|
|
5712
|
+
]);
|
|
5713
|
+
if (fromSdkHttpResponse != null) {
|
|
5714
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
5715
|
+
}
|
|
5688
5716
|
return toObject;
|
|
5689
5717
|
}
|
|
5690
5718
|
function listCachedContentsResponseFromMldev(fromObject) {
|
|
@@ -5749,8 +5777,14 @@ function cachedContentFromVertex(fromObject) {
|
|
|
5749
5777
|
}
|
|
5750
5778
|
return toObject;
|
|
5751
5779
|
}
|
|
5752
|
-
function deleteCachedContentResponseFromVertex() {
|
|
5780
|
+
function deleteCachedContentResponseFromVertex(fromObject) {
|
|
5753
5781
|
const toObject = {};
|
|
5782
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
5783
|
+
'sdkHttpResponse',
|
|
5784
|
+
]);
|
|
5785
|
+
if (fromSdkHttpResponse != null) {
|
|
5786
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
5787
|
+
}
|
|
5754
5788
|
return toObject;
|
|
5755
5789
|
}
|
|
5756
5790
|
function listCachedContentsResponseFromVertex(fromObject) {
|
|
@@ -5987,10 +6021,16 @@ class Caches extends BaseModule {
|
|
|
5987
6021
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
5988
6022
|
})
|
|
5989
6023
|
.then((httpResponse) => {
|
|
5990
|
-
return httpResponse.json()
|
|
6024
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
6025
|
+
const response = jsonResponse;
|
|
6026
|
+
response.sdkHttpResponse = {
|
|
6027
|
+
headers: httpResponse.headers,
|
|
6028
|
+
};
|
|
6029
|
+
return response;
|
|
6030
|
+
});
|
|
5991
6031
|
});
|
|
5992
|
-
return response.then(() => {
|
|
5993
|
-
const resp = deleteCachedContentResponseFromVertex();
|
|
6032
|
+
return response.then((apiResponse) => {
|
|
6033
|
+
const resp = deleteCachedContentResponseFromVertex(apiResponse);
|
|
5994
6034
|
const typedResp = new DeleteCachedContentResponse();
|
|
5995
6035
|
Object.assign(typedResp, resp);
|
|
5996
6036
|
return typedResp;
|
|
@@ -6013,10 +6053,16 @@ class Caches extends BaseModule {
|
|
|
6013
6053
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
6014
6054
|
})
|
|
6015
6055
|
.then((httpResponse) => {
|
|
6016
|
-
return httpResponse.json()
|
|
6056
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
6057
|
+
const response = jsonResponse;
|
|
6058
|
+
response.sdkHttpResponse = {
|
|
6059
|
+
headers: httpResponse.headers,
|
|
6060
|
+
};
|
|
6061
|
+
return response;
|
|
6062
|
+
});
|
|
6017
6063
|
});
|
|
6018
|
-
return response.then(() => {
|
|
6019
|
-
const resp = deleteCachedContentResponseFromMldev();
|
|
6064
|
+
return response.then((apiResponse) => {
|
|
6065
|
+
const resp = deleteCachedContentResponseFromMldev(apiResponse);
|
|
6020
6066
|
const typedResp = new DeleteCachedContentResponse();
|
|
6021
6067
|
Object.assign(typedResp, resp);
|
|
6022
6068
|
return typedResp;
|
|
@@ -6571,7 +6617,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
6571
6617
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
6572
6618
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
6573
6619
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
6574
|
-
const SDK_VERSION = '1.
|
|
6620
|
+
const SDK_VERSION = '1.16.0'; // x-release-please-version
|
|
6575
6621
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
6576
6622
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
6577
6623
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -7517,8 +7563,14 @@ function createFileResponseFromMldev(fromObject) {
|
|
|
7517
7563
|
}
|
|
7518
7564
|
return toObject;
|
|
7519
7565
|
}
|
|
7520
|
-
function deleteFileResponseFromMldev() {
|
|
7566
|
+
function deleteFileResponseFromMldev(fromObject) {
|
|
7521
7567
|
const toObject = {};
|
|
7568
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
7569
|
+
'sdkHttpResponse',
|
|
7570
|
+
]);
|
|
7571
|
+
if (fromSdkHttpResponse != null) {
|
|
7572
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
7573
|
+
}
|
|
7522
7574
|
return toObject;
|
|
7523
7575
|
}
|
|
7524
7576
|
|
|
@@ -7787,10 +7839,16 @@ class Files extends BaseModule {
|
|
|
7787
7839
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
7788
7840
|
})
|
|
7789
7841
|
.then((httpResponse) => {
|
|
7790
|
-
return httpResponse.json()
|
|
7842
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
7843
|
+
const response = jsonResponse;
|
|
7844
|
+
response.sdkHttpResponse = {
|
|
7845
|
+
headers: httpResponse.headers,
|
|
7846
|
+
};
|
|
7847
|
+
return response;
|
|
7848
|
+
});
|
|
7791
7849
|
});
|
|
7792
|
-
return response.then(() => {
|
|
7793
|
-
const resp = deleteFileResponseFromMldev();
|
|
7850
|
+
return response.then((apiResponse) => {
|
|
7851
|
+
const resp = deleteFileResponseFromMldev(apiResponse);
|
|
7794
7852
|
const typedResp = new DeleteFileResponse();
|
|
7795
7853
|
Object.assign(typedResp, resp);
|
|
7796
7854
|
return typedResp;
|
|
@@ -11093,6 +11151,21 @@ function imageToMldev(fromObject) {
|
|
|
11093
11151
|
}
|
|
11094
11152
|
return toObject;
|
|
11095
11153
|
}
|
|
11154
|
+
function generateVideosSourceToMldev(fromObject, parentObject) {
|
|
11155
|
+
const toObject = {};
|
|
11156
|
+
const fromPrompt = getValueByPath(fromObject, ['prompt']);
|
|
11157
|
+
if (parentObject !== undefined && fromPrompt != null) {
|
|
11158
|
+
setValueByPath(parentObject, ['instances[0]', 'prompt'], fromPrompt);
|
|
11159
|
+
}
|
|
11160
|
+
const fromImage = getValueByPath(fromObject, ['image']);
|
|
11161
|
+
if (parentObject !== undefined && fromImage != null) {
|
|
11162
|
+
setValueByPath(parentObject, ['instances[0]', 'image'], imageToMldev(fromImage));
|
|
11163
|
+
}
|
|
11164
|
+
if (getValueByPath(fromObject, ['video']) !== undefined) {
|
|
11165
|
+
throw new Error('video parameter is not supported in Gemini API.');
|
|
11166
|
+
}
|
|
11167
|
+
return toObject;
|
|
11168
|
+
}
|
|
11096
11169
|
function generateVideosConfigToMldev(fromObject, parentObject) {
|
|
11097
11170
|
const toObject = {};
|
|
11098
11171
|
const fromNumberOfVideos = getValueByPath(fromObject, [
|
|
@@ -11175,6 +11248,10 @@ function generateVideosParametersToMldev(apiClient, fromObject) {
|
|
|
11175
11248
|
if (getValueByPath(fromObject, ['video']) !== undefined) {
|
|
11176
11249
|
throw new Error('video parameter is not supported in Gemini API.');
|
|
11177
11250
|
}
|
|
11251
|
+
const fromSource = getValueByPath(fromObject, ['source']);
|
|
11252
|
+
if (fromSource != null) {
|
|
11253
|
+
setValueByPath(toObject, ['config'], generateVideosSourceToMldev(fromSource, toObject));
|
|
11254
|
+
}
|
|
11178
11255
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
11179
11256
|
if (fromConfig != null) {
|
|
11180
11257
|
setValueByPath(toObject, ['config'], generateVideosConfigToMldev(fromConfig, toObject));
|
|
@@ -12299,6 +12376,10 @@ function editImageParametersInternalToVertex(apiClient, fromObject) {
|
|
|
12299
12376
|
}
|
|
12300
12377
|
function upscaleImageAPIConfigInternalToVertex(fromObject, parentObject) {
|
|
12301
12378
|
const toObject = {};
|
|
12379
|
+
const fromOutputGcsUri = getValueByPath(fromObject, ['outputGcsUri']);
|
|
12380
|
+
if (parentObject !== undefined && fromOutputGcsUri != null) {
|
|
12381
|
+
setValueByPath(parentObject, ['parameters', 'storageUri'], fromOutputGcsUri);
|
|
12382
|
+
}
|
|
12302
12383
|
const fromIncludeRaiReason = getValueByPath(fromObject, [
|
|
12303
12384
|
'includeRaiReason',
|
|
12304
12385
|
]);
|
|
@@ -12427,6 +12508,10 @@ function recontextImageConfigToVertex(fromObject, parentObject) {
|
|
|
12427
12508
|
if (parentObject !== undefined && fromPersonGeneration != null) {
|
|
12428
12509
|
setValueByPath(parentObject, ['parameters', 'personGeneration'], fromPersonGeneration);
|
|
12429
12510
|
}
|
|
12511
|
+
const fromAddWatermark = getValueByPath(fromObject, ['addWatermark']);
|
|
12512
|
+
if (parentObject !== undefined && fromAddWatermark != null) {
|
|
12513
|
+
setValueByPath(parentObject, ['parameters', 'addWatermark'], fromAddWatermark);
|
|
12514
|
+
}
|
|
12430
12515
|
const fromOutputMimeType = getValueByPath(fromObject, [
|
|
12431
12516
|
'outputMimeType',
|
|
12432
12517
|
]);
|
|
@@ -12703,6 +12788,22 @@ function videoToVertex(fromObject) {
|
|
|
12703
12788
|
}
|
|
12704
12789
|
return toObject;
|
|
12705
12790
|
}
|
|
12791
|
+
function generateVideosSourceToVertex(fromObject, parentObject) {
|
|
12792
|
+
const toObject = {};
|
|
12793
|
+
const fromPrompt = getValueByPath(fromObject, ['prompt']);
|
|
12794
|
+
if (parentObject !== undefined && fromPrompt != null) {
|
|
12795
|
+
setValueByPath(parentObject, ['instances[0]', 'prompt'], fromPrompt);
|
|
12796
|
+
}
|
|
12797
|
+
const fromImage = getValueByPath(fromObject, ['image']);
|
|
12798
|
+
if (parentObject !== undefined && fromImage != null) {
|
|
12799
|
+
setValueByPath(parentObject, ['instances[0]', 'image'], imageToVertex(fromImage));
|
|
12800
|
+
}
|
|
12801
|
+
const fromVideo = getValueByPath(fromObject, ['video']);
|
|
12802
|
+
if (parentObject !== undefined && fromVideo != null) {
|
|
12803
|
+
setValueByPath(parentObject, ['instances[0]', 'video'], videoToVertex(fromVideo));
|
|
12804
|
+
}
|
|
12805
|
+
return toObject;
|
|
12806
|
+
}
|
|
12706
12807
|
function videoGenerationReferenceImageToVertex(fromObject) {
|
|
12707
12808
|
const toObject = {};
|
|
12708
12809
|
const fromImage = getValueByPath(fromObject, ['image']);
|
|
@@ -12821,6 +12922,10 @@ function generateVideosParametersToVertex(apiClient, fromObject) {
|
|
|
12821
12922
|
if (fromVideo != null) {
|
|
12822
12923
|
setValueByPath(toObject, ['instances[0]', 'video'], videoToVertex(fromVideo));
|
|
12823
12924
|
}
|
|
12925
|
+
const fromSource = getValueByPath(fromObject, ['source']);
|
|
12926
|
+
if (fromSource != null) {
|
|
12927
|
+
setValueByPath(toObject, ['config'], generateVideosSourceToVertex(fromSource, toObject));
|
|
12928
|
+
}
|
|
12824
12929
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
12825
12930
|
if (fromConfig != null) {
|
|
12826
12931
|
setValueByPath(toObject, ['config'], generateVideosConfigToVertex(fromConfig, toObject));
|
|
@@ -13271,8 +13376,14 @@ function listModelsResponseFromMldev(fromObject) {
|
|
|
13271
13376
|
}
|
|
13272
13377
|
return toObject;
|
|
13273
13378
|
}
|
|
13274
|
-
function deleteModelResponseFromMldev() {
|
|
13379
|
+
function deleteModelResponseFromMldev(fromObject) {
|
|
13275
13380
|
const toObject = {};
|
|
13381
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
13382
|
+
'sdkHttpResponse',
|
|
13383
|
+
]);
|
|
13384
|
+
if (fromSdkHttpResponse != null) {
|
|
13385
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
13386
|
+
}
|
|
13276
13387
|
return toObject;
|
|
13277
13388
|
}
|
|
13278
13389
|
function countTokensResponseFromMldev(fromObject) {
|
|
@@ -14017,8 +14128,14 @@ function listModelsResponseFromVertex(fromObject) {
|
|
|
14017
14128
|
}
|
|
14018
14129
|
return toObject;
|
|
14019
14130
|
}
|
|
14020
|
-
function deleteModelResponseFromVertex() {
|
|
14131
|
+
function deleteModelResponseFromVertex(fromObject) {
|
|
14021
14132
|
const toObject = {};
|
|
14133
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
14134
|
+
'sdkHttpResponse',
|
|
14135
|
+
]);
|
|
14136
|
+
if (fromSdkHttpResponse != null) {
|
|
14137
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
14138
|
+
}
|
|
14022
14139
|
return toObject;
|
|
14023
14140
|
}
|
|
14024
14141
|
function countTokensResponseFromVertex(fromObject) {
|
|
@@ -15333,7 +15450,9 @@ class Models extends BaseModule {
|
|
|
15333
15450
|
* ```ts
|
|
15334
15451
|
* const operation = await ai.models.generateVideos({
|
|
15335
15452
|
* model: 'veo-2.0-generate-001',
|
|
15336
|
-
*
|
|
15453
|
+
* source: {
|
|
15454
|
+
* prompt: 'A neon hologram of a cat driving at top speed',
|
|
15455
|
+
* },
|
|
15337
15456
|
* config: {
|
|
15338
15457
|
* numberOfVideos: 1
|
|
15339
15458
|
* });
|
|
@@ -15347,6 +15466,9 @@ class Models extends BaseModule {
|
|
|
15347
15466
|
* ```
|
|
15348
15467
|
*/
|
|
15349
15468
|
this.generateVideos = async (params) => {
|
|
15469
|
+
if ((params.prompt || params.image || params.video) && params.source) {
|
|
15470
|
+
throw new Error('Source and prompt/image/video are mutually exclusive. Please only use source.');
|
|
15471
|
+
}
|
|
15350
15472
|
return await this.generateVideosInternal(params);
|
|
15351
15473
|
};
|
|
15352
15474
|
}
|
|
@@ -16295,10 +16417,16 @@ class Models extends BaseModule {
|
|
|
16295
16417
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
16296
16418
|
})
|
|
16297
16419
|
.then((httpResponse) => {
|
|
16298
|
-
return httpResponse.json()
|
|
16420
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
16421
|
+
const response = jsonResponse;
|
|
16422
|
+
response.sdkHttpResponse = {
|
|
16423
|
+
headers: httpResponse.headers,
|
|
16424
|
+
};
|
|
16425
|
+
return response;
|
|
16426
|
+
});
|
|
16299
16427
|
});
|
|
16300
|
-
return response.then(() => {
|
|
16301
|
-
const resp = deleteModelResponseFromVertex();
|
|
16428
|
+
return response.then((apiResponse) => {
|
|
16429
|
+
const resp = deleteModelResponseFromVertex(apiResponse);
|
|
16302
16430
|
const typedResp = new DeleteModelResponse();
|
|
16303
16431
|
Object.assign(typedResp, resp);
|
|
16304
16432
|
return typedResp;
|
|
@@ -16321,10 +16449,16 @@ class Models extends BaseModule {
|
|
|
16321
16449
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
16322
16450
|
})
|
|
16323
16451
|
.then((httpResponse) => {
|
|
16324
|
-
return httpResponse.json()
|
|
16452
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
16453
|
+
const response = jsonResponse;
|
|
16454
|
+
response.sdkHttpResponse = {
|
|
16455
|
+
headers: httpResponse.headers,
|
|
16456
|
+
};
|
|
16457
|
+
return response;
|
|
16458
|
+
});
|
|
16325
16459
|
});
|
|
16326
|
-
return response.then(() => {
|
|
16327
|
-
const resp = deleteModelResponseFromMldev();
|
|
16460
|
+
return response.then((apiResponse) => {
|
|
16461
|
+
const resp = deleteModelResponseFromMldev(apiResponse);
|
|
16328
16462
|
const typedResp = new DeleteModelResponse();
|
|
16329
16463
|
Object.assign(typedResp, resp);
|
|
16330
16464
|
return typedResp;
|
|
@@ -16579,13 +16713,17 @@ function getOperationParametersToMldev(fromObject) {
|
|
|
16579
16713
|
}
|
|
16580
16714
|
return toObject;
|
|
16581
16715
|
}
|
|
16582
|
-
function
|
|
16716
|
+
function fetchPredictOperationParametersToVertex(fromObject) {
|
|
16583
16717
|
const toObject = {};
|
|
16584
16718
|
const fromOperationName = getValueByPath(fromObject, [
|
|
16585
16719
|
'operationName',
|
|
16586
16720
|
]);
|
|
16587
16721
|
if (fromOperationName != null) {
|
|
16588
|
-
setValueByPath(toObject, ['
|
|
16722
|
+
setValueByPath(toObject, ['operationName'], fromOperationName);
|
|
16723
|
+
}
|
|
16724
|
+
const fromResourceName = getValueByPath(fromObject, ['resourceName']);
|
|
16725
|
+
if (fromResourceName != null) {
|
|
16726
|
+
setValueByPath(toObject, ['_url', 'resourceName'], fromResourceName);
|
|
16589
16727
|
}
|
|
16590
16728
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
16591
16729
|
if (fromConfig != null) {
|
|
@@ -16593,17 +16731,13 @@ function getOperationParametersToVertex(fromObject) {
|
|
|
16593
16731
|
}
|
|
16594
16732
|
return toObject;
|
|
16595
16733
|
}
|
|
16596
|
-
function
|
|
16734
|
+
function getOperationParametersToVertex(fromObject) {
|
|
16597
16735
|
const toObject = {};
|
|
16598
16736
|
const fromOperationName = getValueByPath(fromObject, [
|
|
16599
16737
|
'operationName',
|
|
16600
16738
|
]);
|
|
16601
16739
|
if (fromOperationName != null) {
|
|
16602
|
-
setValueByPath(toObject, ['operationName'], fromOperationName);
|
|
16603
|
-
}
|
|
16604
|
-
const fromResourceName = getValueByPath(fromObject, ['resourceName']);
|
|
16605
|
-
if (fromResourceName != null) {
|
|
16606
|
-
setValueByPath(toObject, ['_url', 'resourceName'], fromResourceName);
|
|
16740
|
+
setValueByPath(toObject, ['_url', 'operationName'], fromOperationName);
|
|
16607
16741
|
}
|
|
16608
16742
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
16609
16743
|
if (fromConfig != null) {
|
|
@@ -17690,6 +17824,18 @@ function listTuningJobsParametersToMldev(fromObject) {
|
|
|
17690
17824
|
}
|
|
17691
17825
|
return toObject;
|
|
17692
17826
|
}
|
|
17827
|
+
function cancelTuningJobParametersToMldev(fromObject) {
|
|
17828
|
+
const toObject = {};
|
|
17829
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
17830
|
+
if (fromName != null) {
|
|
17831
|
+
setValueByPath(toObject, ['_url', 'name'], fromName);
|
|
17832
|
+
}
|
|
17833
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
17834
|
+
if (fromConfig != null) {
|
|
17835
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
17836
|
+
}
|
|
17837
|
+
return toObject;
|
|
17838
|
+
}
|
|
17693
17839
|
function tuningExampleToMldev(fromObject) {
|
|
17694
17840
|
const toObject = {};
|
|
17695
17841
|
const fromTextInput = getValueByPath(fromObject, ['textInput']);
|
|
@@ -17827,6 +17973,18 @@ function listTuningJobsParametersToVertex(fromObject) {
|
|
|
17827
17973
|
}
|
|
17828
17974
|
return toObject;
|
|
17829
17975
|
}
|
|
17976
|
+
function cancelTuningJobParametersToVertex(fromObject) {
|
|
17977
|
+
const toObject = {};
|
|
17978
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
17979
|
+
if (fromName != null) {
|
|
17980
|
+
setValueByPath(toObject, ['_url', 'name'], fromName);
|
|
17981
|
+
}
|
|
17982
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
17983
|
+
if (fromConfig != null) {
|
|
17984
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
17985
|
+
}
|
|
17986
|
+
return toObject;
|
|
17987
|
+
}
|
|
17830
17988
|
function tuningDatasetToVertex(fromObject, parentObject) {
|
|
17831
17989
|
const toObject = {};
|
|
17832
17990
|
const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
|
|
@@ -18480,6 +18638,54 @@ class Tunings extends BaseModule {
|
|
|
18480
18638
|
});
|
|
18481
18639
|
}
|
|
18482
18640
|
}
|
|
18641
|
+
/**
|
|
18642
|
+
* Cancels a tuning job.
|
|
18643
|
+
*
|
|
18644
|
+
* @param params - The parameters for the cancel request.
|
|
18645
|
+
* @return The empty response returned by the API.
|
|
18646
|
+
*
|
|
18647
|
+
* @example
|
|
18648
|
+
* ```ts
|
|
18649
|
+
* await ai.tunings.cancel({name: '...'}); // The server-generated resource name.
|
|
18650
|
+
* ```
|
|
18651
|
+
*/
|
|
18652
|
+
async cancel(params) {
|
|
18653
|
+
var _a, _b, _c, _d;
|
|
18654
|
+
let path = '';
|
|
18655
|
+
let queryParams = {};
|
|
18656
|
+
if (this.apiClient.isVertexAI()) {
|
|
18657
|
+
const body = cancelTuningJobParametersToVertex(params);
|
|
18658
|
+
path = formatMap('{name}:cancel', body['_url']);
|
|
18659
|
+
queryParams = body['_query'];
|
|
18660
|
+
delete body['config'];
|
|
18661
|
+
delete body['_url'];
|
|
18662
|
+
delete body['_query'];
|
|
18663
|
+
await this.apiClient.request({
|
|
18664
|
+
path: path,
|
|
18665
|
+
queryParams: queryParams,
|
|
18666
|
+
body: JSON.stringify(body),
|
|
18667
|
+
httpMethod: 'POST',
|
|
18668
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
18669
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
18670
|
+
});
|
|
18671
|
+
}
|
|
18672
|
+
else {
|
|
18673
|
+
const body = cancelTuningJobParametersToMldev(params);
|
|
18674
|
+
path = formatMap('{name}:cancel', body['_url']);
|
|
18675
|
+
queryParams = body['_query'];
|
|
18676
|
+
delete body['config'];
|
|
18677
|
+
delete body['_url'];
|
|
18678
|
+
delete body['_query'];
|
|
18679
|
+
await this.apiClient.request({
|
|
18680
|
+
path: path,
|
|
18681
|
+
queryParams: queryParams,
|
|
18682
|
+
body: JSON.stringify(body),
|
|
18683
|
+
httpMethod: 'POST',
|
|
18684
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
18685
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
18686
|
+
});
|
|
18687
|
+
}
|
|
18688
|
+
}
|
|
18483
18689
|
async tuneInternal(params) {
|
|
18484
18690
|
var _a, _b;
|
|
18485
18691
|
let response;
|