@google/genai 1.15.0 → 1.17.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 +169 -149
- package/dist/index.cjs +307 -130
- package/dist/index.mjs +308 -131
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.cjs +308 -131
- package/dist/node/index.mjs +309 -132
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/node.d.ts +169 -149
- package/dist/web/index.mjs +308 -131
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +169 -149
- 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;
|
|
@@ -857,7 +861,7 @@ exports.SubjectReferenceType = void 0;
|
|
|
857
861
|
SubjectReferenceType["SUBJECT_TYPE_ANIMAL"] = "SUBJECT_TYPE_ANIMAL";
|
|
858
862
|
SubjectReferenceType["SUBJECT_TYPE_PRODUCT"] = "SUBJECT_TYPE_PRODUCT";
|
|
859
863
|
})(exports.SubjectReferenceType || (exports.SubjectReferenceType = {}));
|
|
860
|
-
/** Enum representing the
|
|
864
|
+
/** Enum representing the editing mode. */
|
|
861
865
|
exports.EditMode = void 0;
|
|
862
866
|
(function (EditMode) {
|
|
863
867
|
EditMode["EDIT_MODE_DEFAULT"] = "EDIT_MODE_DEFAULT";
|
|
@@ -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.17.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, [
|
|
@@ -11120,8 +11193,9 @@ function generateVideosConfigToMldev(fromObject, parentObject) {
|
|
|
11120
11193
|
if (parentObject !== undefined && fromAspectRatio != null) {
|
|
11121
11194
|
setValueByPath(parentObject, ['parameters', 'aspectRatio'], fromAspectRatio);
|
|
11122
11195
|
}
|
|
11123
|
-
|
|
11124
|
-
|
|
11196
|
+
const fromResolution = getValueByPath(fromObject, ['resolution']);
|
|
11197
|
+
if (parentObject !== undefined && fromResolution != null) {
|
|
11198
|
+
setValueByPath(parentObject, ['parameters', 'resolution'], fromResolution);
|
|
11125
11199
|
}
|
|
11126
11200
|
const fromPersonGeneration = getValueByPath(fromObject, [
|
|
11127
11201
|
'personGeneration',
|
|
@@ -11175,6 +11249,10 @@ function generateVideosParametersToMldev(apiClient, fromObject) {
|
|
|
11175
11249
|
if (getValueByPath(fromObject, ['video']) !== undefined) {
|
|
11176
11250
|
throw new Error('video parameter is not supported in Gemini API.');
|
|
11177
11251
|
}
|
|
11252
|
+
const fromSource = getValueByPath(fromObject, ['source']);
|
|
11253
|
+
if (fromSource != null) {
|
|
11254
|
+
setValueByPath(toObject, ['config'], generateVideosSourceToMldev(fromSource, toObject));
|
|
11255
|
+
}
|
|
11178
11256
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
11179
11257
|
if (fromConfig != null) {
|
|
11180
11258
|
setValueByPath(toObject, ['config'], generateVideosConfigToMldev(fromConfig, toObject));
|
|
@@ -12299,6 +12377,10 @@ function editImageParametersInternalToVertex(apiClient, fromObject) {
|
|
|
12299
12377
|
}
|
|
12300
12378
|
function upscaleImageAPIConfigInternalToVertex(fromObject, parentObject) {
|
|
12301
12379
|
const toObject = {};
|
|
12380
|
+
const fromOutputGcsUri = getValueByPath(fromObject, ['outputGcsUri']);
|
|
12381
|
+
if (parentObject !== undefined && fromOutputGcsUri != null) {
|
|
12382
|
+
setValueByPath(parentObject, ['parameters', 'storageUri'], fromOutputGcsUri);
|
|
12383
|
+
}
|
|
12302
12384
|
const fromIncludeRaiReason = getValueByPath(fromObject, [
|
|
12303
12385
|
'includeRaiReason',
|
|
12304
12386
|
]);
|
|
@@ -12427,6 +12509,10 @@ function recontextImageConfigToVertex(fromObject, parentObject) {
|
|
|
12427
12509
|
if (parentObject !== undefined && fromPersonGeneration != null) {
|
|
12428
12510
|
setValueByPath(parentObject, ['parameters', 'personGeneration'], fromPersonGeneration);
|
|
12429
12511
|
}
|
|
12512
|
+
const fromAddWatermark = getValueByPath(fromObject, ['addWatermark']);
|
|
12513
|
+
if (parentObject !== undefined && fromAddWatermark != null) {
|
|
12514
|
+
setValueByPath(parentObject, ['parameters', 'addWatermark'], fromAddWatermark);
|
|
12515
|
+
}
|
|
12430
12516
|
const fromOutputMimeType = getValueByPath(fromObject, [
|
|
12431
12517
|
'outputMimeType',
|
|
12432
12518
|
]);
|
|
@@ -12703,6 +12789,22 @@ function videoToVertex(fromObject) {
|
|
|
12703
12789
|
}
|
|
12704
12790
|
return toObject;
|
|
12705
12791
|
}
|
|
12792
|
+
function generateVideosSourceToVertex(fromObject, parentObject) {
|
|
12793
|
+
const toObject = {};
|
|
12794
|
+
const fromPrompt = getValueByPath(fromObject, ['prompt']);
|
|
12795
|
+
if (parentObject !== undefined && fromPrompt != null) {
|
|
12796
|
+
setValueByPath(parentObject, ['instances[0]', 'prompt'], fromPrompt);
|
|
12797
|
+
}
|
|
12798
|
+
const fromImage = getValueByPath(fromObject, ['image']);
|
|
12799
|
+
if (parentObject !== undefined && fromImage != null) {
|
|
12800
|
+
setValueByPath(parentObject, ['instances[0]', 'image'], imageToVertex(fromImage));
|
|
12801
|
+
}
|
|
12802
|
+
const fromVideo = getValueByPath(fromObject, ['video']);
|
|
12803
|
+
if (parentObject !== undefined && fromVideo != null) {
|
|
12804
|
+
setValueByPath(parentObject, ['instances[0]', 'video'], videoToVertex(fromVideo));
|
|
12805
|
+
}
|
|
12806
|
+
return toObject;
|
|
12807
|
+
}
|
|
12706
12808
|
function videoGenerationReferenceImageToVertex(fromObject) {
|
|
12707
12809
|
const toObject = {};
|
|
12708
12810
|
const fromImage = getValueByPath(fromObject, ['image']);
|
|
@@ -12821,6 +12923,10 @@ function generateVideosParametersToVertex(apiClient, fromObject) {
|
|
|
12821
12923
|
if (fromVideo != null) {
|
|
12822
12924
|
setValueByPath(toObject, ['instances[0]', 'video'], videoToVertex(fromVideo));
|
|
12823
12925
|
}
|
|
12926
|
+
const fromSource = getValueByPath(fromObject, ['source']);
|
|
12927
|
+
if (fromSource != null) {
|
|
12928
|
+
setValueByPath(toObject, ['config'], generateVideosSourceToVertex(fromSource, toObject));
|
|
12929
|
+
}
|
|
12824
12930
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
12825
12931
|
if (fromConfig != null) {
|
|
12826
12932
|
setValueByPath(toObject, ['config'], generateVideosConfigToVertex(fromConfig, toObject));
|
|
@@ -13271,8 +13377,14 @@ function listModelsResponseFromMldev(fromObject) {
|
|
|
13271
13377
|
}
|
|
13272
13378
|
return toObject;
|
|
13273
13379
|
}
|
|
13274
|
-
function deleteModelResponseFromMldev() {
|
|
13380
|
+
function deleteModelResponseFromMldev(fromObject) {
|
|
13275
13381
|
const toObject = {};
|
|
13382
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
13383
|
+
'sdkHttpResponse',
|
|
13384
|
+
]);
|
|
13385
|
+
if (fromSdkHttpResponse != null) {
|
|
13386
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
13387
|
+
}
|
|
13276
13388
|
return toObject;
|
|
13277
13389
|
}
|
|
13278
13390
|
function countTokensResponseFromMldev(fromObject) {
|
|
@@ -14017,8 +14129,14 @@ function listModelsResponseFromVertex(fromObject) {
|
|
|
14017
14129
|
}
|
|
14018
14130
|
return toObject;
|
|
14019
14131
|
}
|
|
14020
|
-
function deleteModelResponseFromVertex() {
|
|
14132
|
+
function deleteModelResponseFromVertex(fromObject) {
|
|
14021
14133
|
const toObject = {};
|
|
14134
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
14135
|
+
'sdkHttpResponse',
|
|
14136
|
+
]);
|
|
14137
|
+
if (fromSdkHttpResponse != null) {
|
|
14138
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
14139
|
+
}
|
|
14022
14140
|
return toObject;
|
|
14023
14141
|
}
|
|
14024
14142
|
function countTokensResponseFromVertex(fromObject) {
|
|
@@ -15333,7 +15451,9 @@ class Models extends BaseModule {
|
|
|
15333
15451
|
* ```ts
|
|
15334
15452
|
* const operation = await ai.models.generateVideos({
|
|
15335
15453
|
* model: 'veo-2.0-generate-001',
|
|
15336
|
-
*
|
|
15454
|
+
* source: {
|
|
15455
|
+
* prompt: 'A neon hologram of a cat driving at top speed',
|
|
15456
|
+
* },
|
|
15337
15457
|
* config: {
|
|
15338
15458
|
* numberOfVideos: 1
|
|
15339
15459
|
* });
|
|
@@ -15347,6 +15467,9 @@ class Models extends BaseModule {
|
|
|
15347
15467
|
* ```
|
|
15348
15468
|
*/
|
|
15349
15469
|
this.generateVideos = async (params) => {
|
|
15470
|
+
if ((params.prompt || params.image || params.video) && params.source) {
|
|
15471
|
+
throw new Error('Source and prompt/image/video are mutually exclusive. Please only use source.');
|
|
15472
|
+
}
|
|
15350
15473
|
return await this.generateVideosInternal(params);
|
|
15351
15474
|
};
|
|
15352
15475
|
}
|
|
@@ -15761,23 +15884,7 @@ class Models extends BaseModule {
|
|
|
15761
15884
|
}
|
|
15762
15885
|
}
|
|
15763
15886
|
/**
|
|
15764
|
-
*
|
|
15765
|
-
*
|
|
15766
|
-
* @param params - The parameters for generating images.
|
|
15767
|
-
* @return The response from the API.
|
|
15768
|
-
*
|
|
15769
|
-
* @example
|
|
15770
|
-
* ```ts
|
|
15771
|
-
* const response = await ai.models.generateImages({
|
|
15772
|
-
* model: 'imagen-3.0-generate-002',
|
|
15773
|
-
* prompt: 'Robot holding a red skateboard',
|
|
15774
|
-
* config: {
|
|
15775
|
-
* numberOfImages: 1,
|
|
15776
|
-
* includeRaiReason: true,
|
|
15777
|
-
* },
|
|
15778
|
-
* });
|
|
15779
|
-
* console.log(response?.generatedImages?.[0]?.image?.imageBytes);
|
|
15780
|
-
* ```
|
|
15887
|
+
* Private method for generating images.
|
|
15781
15888
|
*/
|
|
15782
15889
|
async generateImagesInternal(params) {
|
|
15783
15890
|
var _a, _b, _c, _d;
|
|
@@ -15849,6 +15956,9 @@ class Models extends BaseModule {
|
|
|
15849
15956
|
});
|
|
15850
15957
|
}
|
|
15851
15958
|
}
|
|
15959
|
+
/**
|
|
15960
|
+
* Private method for editing an image.
|
|
15961
|
+
*/
|
|
15852
15962
|
async editImageInternal(params) {
|
|
15853
15963
|
var _a, _b;
|
|
15854
15964
|
let response;
|
|
@@ -15890,6 +16000,9 @@ class Models extends BaseModule {
|
|
|
15890
16000
|
throw new Error('This method is only supported by the Vertex AI.');
|
|
15891
16001
|
}
|
|
15892
16002
|
}
|
|
16003
|
+
/**
|
|
16004
|
+
* Private method for upscaling an image.
|
|
16005
|
+
*/
|
|
15893
16006
|
async upscaleImageInternal(params) {
|
|
15894
16007
|
var _a, _b;
|
|
15895
16008
|
let response;
|
|
@@ -16295,10 +16408,16 @@ class Models extends BaseModule {
|
|
|
16295
16408
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
16296
16409
|
})
|
|
16297
16410
|
.then((httpResponse) => {
|
|
16298
|
-
return httpResponse.json()
|
|
16411
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
16412
|
+
const response = jsonResponse;
|
|
16413
|
+
response.sdkHttpResponse = {
|
|
16414
|
+
headers: httpResponse.headers,
|
|
16415
|
+
};
|
|
16416
|
+
return response;
|
|
16417
|
+
});
|
|
16299
16418
|
});
|
|
16300
|
-
return response.then(() => {
|
|
16301
|
-
const resp = deleteModelResponseFromVertex();
|
|
16419
|
+
return response.then((apiResponse) => {
|
|
16420
|
+
const resp = deleteModelResponseFromVertex(apiResponse);
|
|
16302
16421
|
const typedResp = new DeleteModelResponse();
|
|
16303
16422
|
Object.assign(typedResp, resp);
|
|
16304
16423
|
return typedResp;
|
|
@@ -16321,10 +16440,16 @@ class Models extends BaseModule {
|
|
|
16321
16440
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
16322
16441
|
})
|
|
16323
16442
|
.then((httpResponse) => {
|
|
16324
|
-
return httpResponse.json()
|
|
16443
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
16444
|
+
const response = jsonResponse;
|
|
16445
|
+
response.sdkHttpResponse = {
|
|
16446
|
+
headers: httpResponse.headers,
|
|
16447
|
+
};
|
|
16448
|
+
return response;
|
|
16449
|
+
});
|
|
16325
16450
|
});
|
|
16326
|
-
return response.then(() => {
|
|
16327
|
-
const resp = deleteModelResponseFromMldev();
|
|
16451
|
+
return response.then((apiResponse) => {
|
|
16452
|
+
const resp = deleteModelResponseFromMldev(apiResponse);
|
|
16328
16453
|
const typedResp = new DeleteModelResponse();
|
|
16329
16454
|
Object.assign(typedResp, resp);
|
|
16330
16455
|
return typedResp;
|
|
@@ -16477,27 +16602,7 @@ class Models extends BaseModule {
|
|
|
16477
16602
|
}
|
|
16478
16603
|
}
|
|
16479
16604
|
/**
|
|
16480
|
-
*
|
|
16481
|
-
*
|
|
16482
|
-
* @param params - The parameters for generating videos.
|
|
16483
|
-
* @return A Promise<GenerateVideosOperation> which allows you to track the progress and eventually retrieve the generated videos using the operations.get method.
|
|
16484
|
-
*
|
|
16485
|
-
* @example
|
|
16486
|
-
* ```ts
|
|
16487
|
-
* const operation = await ai.models.generateVideos({
|
|
16488
|
-
* model: 'veo-2.0-generate-001',
|
|
16489
|
-
* prompt: 'A neon hologram of a cat driving at top speed',
|
|
16490
|
-
* config: {
|
|
16491
|
-
* numberOfVideos: 1
|
|
16492
|
-
* });
|
|
16493
|
-
*
|
|
16494
|
-
* while (!operation.done) {
|
|
16495
|
-
* await new Promise(resolve => setTimeout(resolve, 10000));
|
|
16496
|
-
* operation = await ai.operations.getVideosOperation({operation: operation});
|
|
16497
|
-
* }
|
|
16498
|
-
*
|
|
16499
|
-
* console.log(operation.response?.generatedVideos?.[0]?.video?.uri);
|
|
16500
|
-
* ```
|
|
16605
|
+
* Private method for generating videos.
|
|
16501
16606
|
*/
|
|
16502
16607
|
async generateVideosInternal(params) {
|
|
16503
16608
|
var _a, _b, _c, _d;
|
|
@@ -16579,13 +16684,17 @@ function getOperationParametersToMldev(fromObject) {
|
|
|
16579
16684
|
}
|
|
16580
16685
|
return toObject;
|
|
16581
16686
|
}
|
|
16582
|
-
function
|
|
16687
|
+
function fetchPredictOperationParametersToVertex(fromObject) {
|
|
16583
16688
|
const toObject = {};
|
|
16584
16689
|
const fromOperationName = getValueByPath(fromObject, [
|
|
16585
16690
|
'operationName',
|
|
16586
16691
|
]);
|
|
16587
16692
|
if (fromOperationName != null) {
|
|
16588
|
-
setValueByPath(toObject, ['
|
|
16693
|
+
setValueByPath(toObject, ['operationName'], fromOperationName);
|
|
16694
|
+
}
|
|
16695
|
+
const fromResourceName = getValueByPath(fromObject, ['resourceName']);
|
|
16696
|
+
if (fromResourceName != null) {
|
|
16697
|
+
setValueByPath(toObject, ['_url', 'resourceName'], fromResourceName);
|
|
16589
16698
|
}
|
|
16590
16699
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
16591
16700
|
if (fromConfig != null) {
|
|
@@ -16593,17 +16702,13 @@ function getOperationParametersToVertex(fromObject) {
|
|
|
16593
16702
|
}
|
|
16594
16703
|
return toObject;
|
|
16595
16704
|
}
|
|
16596
|
-
function
|
|
16705
|
+
function getOperationParametersToVertex(fromObject) {
|
|
16597
16706
|
const toObject = {};
|
|
16598
16707
|
const fromOperationName = getValueByPath(fromObject, [
|
|
16599
16708
|
'operationName',
|
|
16600
16709
|
]);
|
|
16601
16710
|
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);
|
|
16711
|
+
setValueByPath(toObject, ['_url', 'operationName'], fromOperationName);
|
|
16607
16712
|
}
|
|
16608
16713
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
16609
16714
|
if (fromConfig != null) {
|
|
@@ -17690,6 +17795,18 @@ function listTuningJobsParametersToMldev(fromObject) {
|
|
|
17690
17795
|
}
|
|
17691
17796
|
return toObject;
|
|
17692
17797
|
}
|
|
17798
|
+
function cancelTuningJobParametersToMldev(fromObject) {
|
|
17799
|
+
const toObject = {};
|
|
17800
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
17801
|
+
if (fromName != null) {
|
|
17802
|
+
setValueByPath(toObject, ['_url', 'name'], fromName);
|
|
17803
|
+
}
|
|
17804
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
17805
|
+
if (fromConfig != null) {
|
|
17806
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
17807
|
+
}
|
|
17808
|
+
return toObject;
|
|
17809
|
+
}
|
|
17693
17810
|
function tuningExampleToMldev(fromObject) {
|
|
17694
17811
|
const toObject = {};
|
|
17695
17812
|
const fromTextInput = getValueByPath(fromObject, ['textInput']);
|
|
@@ -17827,6 +17944,18 @@ function listTuningJobsParametersToVertex(fromObject) {
|
|
|
17827
17944
|
}
|
|
17828
17945
|
return toObject;
|
|
17829
17946
|
}
|
|
17947
|
+
function cancelTuningJobParametersToVertex(fromObject) {
|
|
17948
|
+
const toObject = {};
|
|
17949
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
17950
|
+
if (fromName != null) {
|
|
17951
|
+
setValueByPath(toObject, ['_url', 'name'], fromName);
|
|
17952
|
+
}
|
|
17953
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
17954
|
+
if (fromConfig != null) {
|
|
17955
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
17956
|
+
}
|
|
17957
|
+
return toObject;
|
|
17958
|
+
}
|
|
17830
17959
|
function tuningDatasetToVertex(fromObject, parentObject) {
|
|
17831
17960
|
const toObject = {};
|
|
17832
17961
|
const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
|
|
@@ -18480,6 +18609,54 @@ class Tunings extends BaseModule {
|
|
|
18480
18609
|
});
|
|
18481
18610
|
}
|
|
18482
18611
|
}
|
|
18612
|
+
/**
|
|
18613
|
+
* Cancels a tuning job.
|
|
18614
|
+
*
|
|
18615
|
+
* @param params - The parameters for the cancel request.
|
|
18616
|
+
* @return The empty response returned by the API.
|
|
18617
|
+
*
|
|
18618
|
+
* @example
|
|
18619
|
+
* ```ts
|
|
18620
|
+
* await ai.tunings.cancel({name: '...'}); // The server-generated resource name.
|
|
18621
|
+
* ```
|
|
18622
|
+
*/
|
|
18623
|
+
async cancel(params) {
|
|
18624
|
+
var _a, _b, _c, _d;
|
|
18625
|
+
let path = '';
|
|
18626
|
+
let queryParams = {};
|
|
18627
|
+
if (this.apiClient.isVertexAI()) {
|
|
18628
|
+
const body = cancelTuningJobParametersToVertex(params);
|
|
18629
|
+
path = formatMap('{name}:cancel', body['_url']);
|
|
18630
|
+
queryParams = body['_query'];
|
|
18631
|
+
delete body['config'];
|
|
18632
|
+
delete body['_url'];
|
|
18633
|
+
delete body['_query'];
|
|
18634
|
+
await this.apiClient.request({
|
|
18635
|
+
path: path,
|
|
18636
|
+
queryParams: queryParams,
|
|
18637
|
+
body: JSON.stringify(body),
|
|
18638
|
+
httpMethod: 'POST',
|
|
18639
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
18640
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
18641
|
+
});
|
|
18642
|
+
}
|
|
18643
|
+
else {
|
|
18644
|
+
const body = cancelTuningJobParametersToMldev(params);
|
|
18645
|
+
path = formatMap('{name}:cancel', body['_url']);
|
|
18646
|
+
queryParams = body['_query'];
|
|
18647
|
+
delete body['config'];
|
|
18648
|
+
delete body['_url'];
|
|
18649
|
+
delete body['_query'];
|
|
18650
|
+
await this.apiClient.request({
|
|
18651
|
+
path: path,
|
|
18652
|
+
queryParams: queryParams,
|
|
18653
|
+
body: JSON.stringify(body),
|
|
18654
|
+
httpMethod: 'POST',
|
|
18655
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
18656
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
18657
|
+
});
|
|
18658
|
+
}
|
|
18659
|
+
}
|
|
18483
18660
|
async tuneInternal(params) {
|
|
18484
18661
|
var _a, _b;
|
|
18485
18662
|
let response;
|