@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/node/index.cjs
CHANGED
|
@@ -827,6 +827,10 @@ exports.FunctionCallingConfigMode = void 0;
|
|
|
827
827
|
* Model will not predict any function calls. Model behavior is same as when not passing any function declarations.
|
|
828
828
|
*/
|
|
829
829
|
FunctionCallingConfigMode["NONE"] = "NONE";
|
|
830
|
+
/**
|
|
831
|
+
* 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".
|
|
832
|
+
*/
|
|
833
|
+
FunctionCallingConfigMode["VALIDATED"] = "VALIDATED";
|
|
830
834
|
})(exports.FunctionCallingConfigMode || (exports.FunctionCallingConfigMode = {}));
|
|
831
835
|
/** Enum that controls the safety filter level for objectionable content. */
|
|
832
836
|
exports.SafetyFilterLevel = void 0;
|
|
@@ -913,7 +917,7 @@ exports.SubjectReferenceType = void 0;
|
|
|
913
917
|
SubjectReferenceType["SUBJECT_TYPE_ANIMAL"] = "SUBJECT_TYPE_ANIMAL";
|
|
914
918
|
SubjectReferenceType["SUBJECT_TYPE_PRODUCT"] = "SUBJECT_TYPE_PRODUCT";
|
|
915
919
|
})(exports.SubjectReferenceType || (exports.SubjectReferenceType = {}));
|
|
916
|
-
/** Enum representing the
|
|
920
|
+
/** Enum representing the editing mode. */
|
|
917
921
|
exports.EditMode = void 0;
|
|
918
922
|
(function (EditMode) {
|
|
919
923
|
EditMode["EDIT_MODE_DEFAULT"] = "EDIT_MODE_DEFAULT";
|
|
@@ -934,6 +938,21 @@ exports.SegmentMode = void 0;
|
|
|
934
938
|
SegmentMode["SEMANTIC"] = "SEMANTIC";
|
|
935
939
|
SegmentMode["INTERACTIVE"] = "INTERACTIVE";
|
|
936
940
|
})(exports.SegmentMode || (exports.SegmentMode = {}));
|
|
941
|
+
/** Enum for the reference type of a video generation reference image. */
|
|
942
|
+
exports.VideoGenerationReferenceType = void 0;
|
|
943
|
+
(function (VideoGenerationReferenceType) {
|
|
944
|
+
/**
|
|
945
|
+
* A reference image that provides assets to the generated video,
|
|
946
|
+
such as the scene, an object, a character, etc.
|
|
947
|
+
*/
|
|
948
|
+
VideoGenerationReferenceType["ASSET"] = "ASSET";
|
|
949
|
+
/**
|
|
950
|
+
* A reference image that provides aesthetics including colors,
|
|
951
|
+
lighting, texture, etc., to be used as the style of the generated video,
|
|
952
|
+
such as 'anime', 'photography', 'origami', etc.
|
|
953
|
+
*/
|
|
954
|
+
VideoGenerationReferenceType["STYLE"] = "STYLE";
|
|
955
|
+
})(exports.VideoGenerationReferenceType || (exports.VideoGenerationReferenceType = {}));
|
|
937
956
|
/** Enum that controls the compression quality of the generated videos. */
|
|
938
957
|
exports.VideoCompressionQuality = void 0;
|
|
939
958
|
(function (VideoCompressionQuality) {
|
|
@@ -1596,6 +1615,65 @@ class ComputeTokensResponse {
|
|
|
1596
1615
|
/** Response with generated videos. */
|
|
1597
1616
|
class GenerateVideosResponse {
|
|
1598
1617
|
}
|
|
1618
|
+
/** A video generation operation. */
|
|
1619
|
+
class GenerateVideosOperation {
|
|
1620
|
+
/**
|
|
1621
|
+
* Instantiates an Operation of the same type as the one being called with the fields set from the API response.
|
|
1622
|
+
* @internal
|
|
1623
|
+
*/
|
|
1624
|
+
_fromAPIResponse({ apiResponse, isVertexAI, }) {
|
|
1625
|
+
const operation = new GenerateVideosOperation();
|
|
1626
|
+
operation.name = apiResponse['name'];
|
|
1627
|
+
operation.metadata = apiResponse['metadata'];
|
|
1628
|
+
operation.done = apiResponse['done'];
|
|
1629
|
+
operation.error = apiResponse['error'];
|
|
1630
|
+
if (isVertexAI) {
|
|
1631
|
+
const response = apiResponse['response'];
|
|
1632
|
+
if (response) {
|
|
1633
|
+
const operationResponse = new GenerateVideosResponse();
|
|
1634
|
+
const responseVideos = response['videos'];
|
|
1635
|
+
operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
|
|
1636
|
+
return {
|
|
1637
|
+
video: {
|
|
1638
|
+
uri: generatedVideo['gcsUri'],
|
|
1639
|
+
videoBytes: generatedVideo['bytesBase64Encoded']
|
|
1640
|
+
? tBytes$1(generatedVideo['bytesBase64Encoded'])
|
|
1641
|
+
: undefined,
|
|
1642
|
+
mimeType: generatedVideo['mimeType'],
|
|
1643
|
+
},
|
|
1644
|
+
};
|
|
1645
|
+
});
|
|
1646
|
+
operationResponse.raiMediaFilteredCount = response['raiMediaFilteredCount'];
|
|
1647
|
+
operationResponse.raiMediaFilteredReasons = response['raiMediaFilteredReasons'];
|
|
1648
|
+
operation.response = operationResponse;
|
|
1649
|
+
}
|
|
1650
|
+
}
|
|
1651
|
+
else {
|
|
1652
|
+
const response = apiResponse['response'];
|
|
1653
|
+
if (response) {
|
|
1654
|
+
const operationResponse = new GenerateVideosResponse();
|
|
1655
|
+
const generatedVideoResponse = response['generateVideoResponse'];
|
|
1656
|
+
const responseVideos = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['generatedSamples'];
|
|
1657
|
+
operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
|
|
1658
|
+
const video = generatedVideo['video'];
|
|
1659
|
+
return {
|
|
1660
|
+
video: {
|
|
1661
|
+
uri: video === null || video === void 0 ? void 0 : video['uri'],
|
|
1662
|
+
videoBytes: (video === null || video === void 0 ? void 0 : video['encodedVideo'])
|
|
1663
|
+
? tBytes$1(video === null || video === void 0 ? void 0 : video['encodedVideo'])
|
|
1664
|
+
: undefined,
|
|
1665
|
+
mimeType: generatedVideo['encoding'],
|
|
1666
|
+
},
|
|
1667
|
+
};
|
|
1668
|
+
});
|
|
1669
|
+
operationResponse.raiMediaFilteredCount = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredCount'];
|
|
1670
|
+
operationResponse.raiMediaFilteredReasons = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredReasons'];
|
|
1671
|
+
operation.response = operationResponse;
|
|
1672
|
+
}
|
|
1673
|
+
}
|
|
1674
|
+
return operation;
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1599
1677
|
/** Response for the list tuning jobs method. */
|
|
1600
1678
|
class ListTuningJobsResponse {
|
|
1601
1679
|
}
|
|
@@ -1787,65 +1865,6 @@ class LiveServerMessage {
|
|
|
1787
1865
|
return data.length > 0 ? btoa(data) : undefined;
|
|
1788
1866
|
}
|
|
1789
1867
|
}
|
|
1790
|
-
/** A video generation long-running operation. */
|
|
1791
|
-
class GenerateVideosOperation {
|
|
1792
|
-
/**
|
|
1793
|
-
* Instantiates an Operation of the same type as the one being called with the fields set from the API response.
|
|
1794
|
-
* @internal
|
|
1795
|
-
*/
|
|
1796
|
-
_fromAPIResponse({ apiResponse, isVertexAI, }) {
|
|
1797
|
-
const operation = new GenerateVideosOperation();
|
|
1798
|
-
operation.name = apiResponse['name'];
|
|
1799
|
-
operation.metadata = apiResponse['metadata'];
|
|
1800
|
-
operation.done = apiResponse['done'];
|
|
1801
|
-
operation.error = apiResponse['error'];
|
|
1802
|
-
if (isVertexAI) {
|
|
1803
|
-
const response = apiResponse['response'];
|
|
1804
|
-
if (response) {
|
|
1805
|
-
const operationResponse = new GenerateVideosResponse();
|
|
1806
|
-
const responseVideos = response['videos'];
|
|
1807
|
-
operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
|
|
1808
|
-
return {
|
|
1809
|
-
video: {
|
|
1810
|
-
uri: generatedVideo['gcsUri'],
|
|
1811
|
-
videoBytes: generatedVideo['bytesBase64Encoded']
|
|
1812
|
-
? tBytes$1(generatedVideo['bytesBase64Encoded'])
|
|
1813
|
-
: undefined,
|
|
1814
|
-
mimeType: generatedVideo['mimeType'],
|
|
1815
|
-
},
|
|
1816
|
-
};
|
|
1817
|
-
});
|
|
1818
|
-
operationResponse.raiMediaFilteredCount = response['raiMediaFilteredCount'];
|
|
1819
|
-
operationResponse.raiMediaFilteredReasons = response['raiMediaFilteredReasons'];
|
|
1820
|
-
operation.response = operationResponse;
|
|
1821
|
-
}
|
|
1822
|
-
}
|
|
1823
|
-
else {
|
|
1824
|
-
const response = apiResponse['response'];
|
|
1825
|
-
if (response) {
|
|
1826
|
-
const operationResponse = new GenerateVideosResponse();
|
|
1827
|
-
const generatedVideoResponse = response['generateVideoResponse'];
|
|
1828
|
-
const responseVideos = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['generatedSamples'];
|
|
1829
|
-
operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
|
|
1830
|
-
const video = generatedVideo['video'];
|
|
1831
|
-
return {
|
|
1832
|
-
video: {
|
|
1833
|
-
uri: video === null || video === void 0 ? void 0 : video['uri'],
|
|
1834
|
-
videoBytes: (video === null || video === void 0 ? void 0 : video['encodedVideo'])
|
|
1835
|
-
? tBytes$1(video === null || video === void 0 ? void 0 : video['encodedVideo'])
|
|
1836
|
-
: undefined,
|
|
1837
|
-
mimeType: generatedVideo['encoding'],
|
|
1838
|
-
},
|
|
1839
|
-
};
|
|
1840
|
-
});
|
|
1841
|
-
operationResponse.raiMediaFilteredCount = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredCount'];
|
|
1842
|
-
operationResponse.raiMediaFilteredReasons = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredReasons'];
|
|
1843
|
-
operation.response = operationResponse;
|
|
1844
|
-
}
|
|
1845
|
-
}
|
|
1846
|
-
return operation;
|
|
1847
|
-
}
|
|
1848
|
-
}
|
|
1849
1868
|
/** Client generated response to a `ToolCall` received from the server.
|
|
1850
1869
|
|
|
1851
1870
|
Individual `FunctionResponse` objects are matched to the respective
|
|
@@ -2492,6 +2511,9 @@ function mcpToGeminiTool(mcpTool, config = {}) {
|
|
|
2492
2511
|
description: mcpToolSchema['description'],
|
|
2493
2512
|
parametersJsonSchema: mcpToolSchema['inputSchema'],
|
|
2494
2513
|
};
|
|
2514
|
+
if (mcpToolSchema['outputSchema']) {
|
|
2515
|
+
functionDeclaration['responseJsonSchema'] = mcpToolSchema['outputSchema'];
|
|
2516
|
+
}
|
|
2495
2517
|
if (config.behavior) {
|
|
2496
2518
|
functionDeclaration['behavior'] = config.behavior;
|
|
2497
2519
|
}
|
|
@@ -5739,8 +5761,14 @@ function cachedContentFromMldev(fromObject) {
|
|
|
5739
5761
|
}
|
|
5740
5762
|
return toObject;
|
|
5741
5763
|
}
|
|
5742
|
-
function deleteCachedContentResponseFromMldev() {
|
|
5764
|
+
function deleteCachedContentResponseFromMldev(fromObject) {
|
|
5743
5765
|
const toObject = {};
|
|
5766
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
5767
|
+
'sdkHttpResponse',
|
|
5768
|
+
]);
|
|
5769
|
+
if (fromSdkHttpResponse != null) {
|
|
5770
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
5771
|
+
}
|
|
5744
5772
|
return toObject;
|
|
5745
5773
|
}
|
|
5746
5774
|
function listCachedContentsResponseFromMldev(fromObject) {
|
|
@@ -5805,8 +5833,14 @@ function cachedContentFromVertex(fromObject) {
|
|
|
5805
5833
|
}
|
|
5806
5834
|
return toObject;
|
|
5807
5835
|
}
|
|
5808
|
-
function deleteCachedContentResponseFromVertex() {
|
|
5836
|
+
function deleteCachedContentResponseFromVertex(fromObject) {
|
|
5809
5837
|
const toObject = {};
|
|
5838
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
5839
|
+
'sdkHttpResponse',
|
|
5840
|
+
]);
|
|
5841
|
+
if (fromSdkHttpResponse != null) {
|
|
5842
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
5843
|
+
}
|
|
5810
5844
|
return toObject;
|
|
5811
5845
|
}
|
|
5812
5846
|
function listCachedContentsResponseFromVertex(fromObject) {
|
|
@@ -6043,10 +6077,16 @@ class Caches extends BaseModule {
|
|
|
6043
6077
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
6044
6078
|
})
|
|
6045
6079
|
.then((httpResponse) => {
|
|
6046
|
-
return httpResponse.json()
|
|
6080
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
6081
|
+
const response = jsonResponse;
|
|
6082
|
+
response.sdkHttpResponse = {
|
|
6083
|
+
headers: httpResponse.headers,
|
|
6084
|
+
};
|
|
6085
|
+
return response;
|
|
6086
|
+
});
|
|
6047
6087
|
});
|
|
6048
|
-
return response.then(() => {
|
|
6049
|
-
const resp = deleteCachedContentResponseFromVertex();
|
|
6088
|
+
return response.then((apiResponse) => {
|
|
6089
|
+
const resp = deleteCachedContentResponseFromVertex(apiResponse);
|
|
6050
6090
|
const typedResp = new DeleteCachedContentResponse();
|
|
6051
6091
|
Object.assign(typedResp, resp);
|
|
6052
6092
|
return typedResp;
|
|
@@ -6069,10 +6109,16 @@ class Caches extends BaseModule {
|
|
|
6069
6109
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
6070
6110
|
})
|
|
6071
6111
|
.then((httpResponse) => {
|
|
6072
|
-
return httpResponse.json()
|
|
6112
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
6113
|
+
const response = jsonResponse;
|
|
6114
|
+
response.sdkHttpResponse = {
|
|
6115
|
+
headers: httpResponse.headers,
|
|
6116
|
+
};
|
|
6117
|
+
return response;
|
|
6118
|
+
});
|
|
6073
6119
|
});
|
|
6074
|
-
return response.then(() => {
|
|
6075
|
-
const resp = deleteCachedContentResponseFromMldev();
|
|
6120
|
+
return response.then((apiResponse) => {
|
|
6121
|
+
const resp = deleteCachedContentResponseFromMldev(apiResponse);
|
|
6076
6122
|
const typedResp = new DeleteCachedContentResponse();
|
|
6077
6123
|
Object.assign(typedResp, resp);
|
|
6078
6124
|
return typedResp;
|
|
@@ -6876,8 +6922,14 @@ function createFileResponseFromMldev(fromObject) {
|
|
|
6876
6922
|
}
|
|
6877
6923
|
return toObject;
|
|
6878
6924
|
}
|
|
6879
|
-
function deleteFileResponseFromMldev() {
|
|
6925
|
+
function deleteFileResponseFromMldev(fromObject) {
|
|
6880
6926
|
const toObject = {};
|
|
6927
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
6928
|
+
'sdkHttpResponse',
|
|
6929
|
+
]);
|
|
6930
|
+
if (fromSdkHttpResponse != null) {
|
|
6931
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
6932
|
+
}
|
|
6881
6933
|
return toObject;
|
|
6882
6934
|
}
|
|
6883
6935
|
|
|
@@ -7146,10 +7198,16 @@ class Files extends BaseModule {
|
|
|
7146
7198
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
7147
7199
|
})
|
|
7148
7200
|
.then((httpResponse) => {
|
|
7149
|
-
return httpResponse.json()
|
|
7201
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
7202
|
+
const response = jsonResponse;
|
|
7203
|
+
response.sdkHttpResponse = {
|
|
7204
|
+
headers: httpResponse.headers,
|
|
7205
|
+
};
|
|
7206
|
+
return response;
|
|
7207
|
+
});
|
|
7150
7208
|
});
|
|
7151
|
-
return response.then(() => {
|
|
7152
|
-
const resp = deleteFileResponseFromMldev();
|
|
7209
|
+
return response.then((apiResponse) => {
|
|
7210
|
+
const resp = deleteFileResponseFromMldev(apiResponse);
|
|
7153
7211
|
const typedResp = new DeleteFileResponse();
|
|
7154
7212
|
Object.assign(typedResp, resp);
|
|
7155
7213
|
return typedResp;
|
|
@@ -10452,6 +10510,21 @@ function imageToMldev(fromObject) {
|
|
|
10452
10510
|
}
|
|
10453
10511
|
return toObject;
|
|
10454
10512
|
}
|
|
10513
|
+
function generateVideosSourceToMldev(fromObject, parentObject) {
|
|
10514
|
+
const toObject = {};
|
|
10515
|
+
const fromPrompt = getValueByPath(fromObject, ['prompt']);
|
|
10516
|
+
if (parentObject !== undefined && fromPrompt != null) {
|
|
10517
|
+
setValueByPath(parentObject, ['instances[0]', 'prompt'], fromPrompt);
|
|
10518
|
+
}
|
|
10519
|
+
const fromImage = getValueByPath(fromObject, ['image']);
|
|
10520
|
+
if (parentObject !== undefined && fromImage != null) {
|
|
10521
|
+
setValueByPath(parentObject, ['instances[0]', 'image'], imageToMldev(fromImage));
|
|
10522
|
+
}
|
|
10523
|
+
if (getValueByPath(fromObject, ['video']) !== undefined) {
|
|
10524
|
+
throw new Error('video parameter is not supported in Gemini API.');
|
|
10525
|
+
}
|
|
10526
|
+
return toObject;
|
|
10527
|
+
}
|
|
10455
10528
|
function generateVideosConfigToMldev(fromObject, parentObject) {
|
|
10456
10529
|
const toObject = {};
|
|
10457
10530
|
const fromNumberOfVideos = getValueByPath(fromObject, [
|
|
@@ -10479,8 +10552,9 @@ function generateVideosConfigToMldev(fromObject, parentObject) {
|
|
|
10479
10552
|
if (parentObject !== undefined && fromAspectRatio != null) {
|
|
10480
10553
|
setValueByPath(parentObject, ['parameters', 'aspectRatio'], fromAspectRatio);
|
|
10481
10554
|
}
|
|
10482
|
-
|
|
10483
|
-
|
|
10555
|
+
const fromResolution = getValueByPath(fromObject, ['resolution']);
|
|
10556
|
+
if (parentObject !== undefined && fromResolution != null) {
|
|
10557
|
+
setValueByPath(parentObject, ['parameters', 'resolution'], fromResolution);
|
|
10484
10558
|
}
|
|
10485
10559
|
const fromPersonGeneration = getValueByPath(fromObject, [
|
|
10486
10560
|
'personGeneration',
|
|
@@ -10534,6 +10608,10 @@ function generateVideosParametersToMldev(apiClient, fromObject) {
|
|
|
10534
10608
|
if (getValueByPath(fromObject, ['video']) !== undefined) {
|
|
10535
10609
|
throw new Error('video parameter is not supported in Gemini API.');
|
|
10536
10610
|
}
|
|
10611
|
+
const fromSource = getValueByPath(fromObject, ['source']);
|
|
10612
|
+
if (fromSource != null) {
|
|
10613
|
+
setValueByPath(toObject, ['config'], generateVideosSourceToMldev(fromSource, toObject));
|
|
10614
|
+
}
|
|
10537
10615
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
10538
10616
|
if (fromConfig != null) {
|
|
10539
10617
|
setValueByPath(toObject, ['config'], generateVideosConfigToMldev(fromConfig, toObject));
|
|
@@ -11658,6 +11736,10 @@ function editImageParametersInternalToVertex(apiClient, fromObject) {
|
|
|
11658
11736
|
}
|
|
11659
11737
|
function upscaleImageAPIConfigInternalToVertex(fromObject, parentObject) {
|
|
11660
11738
|
const toObject = {};
|
|
11739
|
+
const fromOutputGcsUri = getValueByPath(fromObject, ['outputGcsUri']);
|
|
11740
|
+
if (parentObject !== undefined && fromOutputGcsUri != null) {
|
|
11741
|
+
setValueByPath(parentObject, ['parameters', 'storageUri'], fromOutputGcsUri);
|
|
11742
|
+
}
|
|
11661
11743
|
const fromIncludeRaiReason = getValueByPath(fromObject, [
|
|
11662
11744
|
'includeRaiReason',
|
|
11663
11745
|
]);
|
|
@@ -11786,6 +11868,10 @@ function recontextImageConfigToVertex(fromObject, parentObject) {
|
|
|
11786
11868
|
if (parentObject !== undefined && fromPersonGeneration != null) {
|
|
11787
11869
|
setValueByPath(parentObject, ['parameters', 'personGeneration'], fromPersonGeneration);
|
|
11788
11870
|
}
|
|
11871
|
+
const fromAddWatermark = getValueByPath(fromObject, ['addWatermark']);
|
|
11872
|
+
if (parentObject !== undefined && fromAddWatermark != null) {
|
|
11873
|
+
setValueByPath(parentObject, ['parameters', 'addWatermark'], fromAddWatermark);
|
|
11874
|
+
}
|
|
11789
11875
|
const fromOutputMimeType = getValueByPath(fromObject, [
|
|
11790
11876
|
'outputMimeType',
|
|
11791
11877
|
]);
|
|
@@ -12062,6 +12148,22 @@ function videoToVertex(fromObject) {
|
|
|
12062
12148
|
}
|
|
12063
12149
|
return toObject;
|
|
12064
12150
|
}
|
|
12151
|
+
function generateVideosSourceToVertex(fromObject, parentObject) {
|
|
12152
|
+
const toObject = {};
|
|
12153
|
+
const fromPrompt = getValueByPath(fromObject, ['prompt']);
|
|
12154
|
+
if (parentObject !== undefined && fromPrompt != null) {
|
|
12155
|
+
setValueByPath(parentObject, ['instances[0]', 'prompt'], fromPrompt);
|
|
12156
|
+
}
|
|
12157
|
+
const fromImage = getValueByPath(fromObject, ['image']);
|
|
12158
|
+
if (parentObject !== undefined && fromImage != null) {
|
|
12159
|
+
setValueByPath(parentObject, ['instances[0]', 'image'], imageToVertex(fromImage));
|
|
12160
|
+
}
|
|
12161
|
+
const fromVideo = getValueByPath(fromObject, ['video']);
|
|
12162
|
+
if (parentObject !== undefined && fromVideo != null) {
|
|
12163
|
+
setValueByPath(parentObject, ['instances[0]', 'video'], videoToVertex(fromVideo));
|
|
12164
|
+
}
|
|
12165
|
+
return toObject;
|
|
12166
|
+
}
|
|
12065
12167
|
function videoGenerationReferenceImageToVertex(fromObject) {
|
|
12066
12168
|
const toObject = {};
|
|
12067
12169
|
const fromImage = getValueByPath(fromObject, ['image']);
|
|
@@ -12180,6 +12282,10 @@ function generateVideosParametersToVertex(apiClient, fromObject) {
|
|
|
12180
12282
|
if (fromVideo != null) {
|
|
12181
12283
|
setValueByPath(toObject, ['instances[0]', 'video'], videoToVertex(fromVideo));
|
|
12182
12284
|
}
|
|
12285
|
+
const fromSource = getValueByPath(fromObject, ['source']);
|
|
12286
|
+
if (fromSource != null) {
|
|
12287
|
+
setValueByPath(toObject, ['config'], generateVideosSourceToVertex(fromSource, toObject));
|
|
12288
|
+
}
|
|
12183
12289
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
12184
12290
|
if (fromConfig != null) {
|
|
12185
12291
|
setValueByPath(toObject, ['config'], generateVideosConfigToVertex(fromConfig, toObject));
|
|
@@ -12630,8 +12736,14 @@ function listModelsResponseFromMldev(fromObject) {
|
|
|
12630
12736
|
}
|
|
12631
12737
|
return toObject;
|
|
12632
12738
|
}
|
|
12633
|
-
function deleteModelResponseFromMldev() {
|
|
12739
|
+
function deleteModelResponseFromMldev(fromObject) {
|
|
12634
12740
|
const toObject = {};
|
|
12741
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
12742
|
+
'sdkHttpResponse',
|
|
12743
|
+
]);
|
|
12744
|
+
if (fromSdkHttpResponse != null) {
|
|
12745
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
12746
|
+
}
|
|
12635
12747
|
return toObject;
|
|
12636
12748
|
}
|
|
12637
12749
|
function countTokensResponseFromMldev(fromObject) {
|
|
@@ -13376,8 +13488,14 @@ function listModelsResponseFromVertex(fromObject) {
|
|
|
13376
13488
|
}
|
|
13377
13489
|
return toObject;
|
|
13378
13490
|
}
|
|
13379
|
-
function deleteModelResponseFromVertex() {
|
|
13491
|
+
function deleteModelResponseFromVertex(fromObject) {
|
|
13380
13492
|
const toObject = {};
|
|
13493
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
13494
|
+
'sdkHttpResponse',
|
|
13495
|
+
]);
|
|
13496
|
+
if (fromSdkHttpResponse != null) {
|
|
13497
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
13498
|
+
}
|
|
13381
13499
|
return toObject;
|
|
13382
13500
|
}
|
|
13383
13501
|
function countTokensResponseFromVertex(fromObject) {
|
|
@@ -13494,7 +13612,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
13494
13612
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
13495
13613
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
13496
13614
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
13497
|
-
const SDK_VERSION = '1.
|
|
13615
|
+
const SDK_VERSION = '1.17.0'; // x-release-please-version
|
|
13498
13616
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
13499
13617
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
13500
13618
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -15266,7 +15384,9 @@ class Models extends BaseModule {
|
|
|
15266
15384
|
* ```ts
|
|
15267
15385
|
* const operation = await ai.models.generateVideos({
|
|
15268
15386
|
* model: 'veo-2.0-generate-001',
|
|
15269
|
-
*
|
|
15387
|
+
* source: {
|
|
15388
|
+
* prompt: 'A neon hologram of a cat driving at top speed',
|
|
15389
|
+
* },
|
|
15270
15390
|
* config: {
|
|
15271
15391
|
* numberOfVideos: 1
|
|
15272
15392
|
* });
|
|
@@ -15280,6 +15400,9 @@ class Models extends BaseModule {
|
|
|
15280
15400
|
* ```
|
|
15281
15401
|
*/
|
|
15282
15402
|
this.generateVideos = async (params) => {
|
|
15403
|
+
if ((params.prompt || params.image || params.video) && params.source) {
|
|
15404
|
+
throw new Error('Source and prompt/image/video are mutually exclusive. Please only use source.');
|
|
15405
|
+
}
|
|
15283
15406
|
return await this.generateVideosInternal(params);
|
|
15284
15407
|
};
|
|
15285
15408
|
}
|
|
@@ -15694,23 +15817,7 @@ class Models extends BaseModule {
|
|
|
15694
15817
|
}
|
|
15695
15818
|
}
|
|
15696
15819
|
/**
|
|
15697
|
-
*
|
|
15698
|
-
*
|
|
15699
|
-
* @param params - The parameters for generating images.
|
|
15700
|
-
* @return The response from the API.
|
|
15701
|
-
*
|
|
15702
|
-
* @example
|
|
15703
|
-
* ```ts
|
|
15704
|
-
* const response = await ai.models.generateImages({
|
|
15705
|
-
* model: 'imagen-3.0-generate-002',
|
|
15706
|
-
* prompt: 'Robot holding a red skateboard',
|
|
15707
|
-
* config: {
|
|
15708
|
-
* numberOfImages: 1,
|
|
15709
|
-
* includeRaiReason: true,
|
|
15710
|
-
* },
|
|
15711
|
-
* });
|
|
15712
|
-
* console.log(response?.generatedImages?.[0]?.image?.imageBytes);
|
|
15713
|
-
* ```
|
|
15820
|
+
* Private method for generating images.
|
|
15714
15821
|
*/
|
|
15715
15822
|
async generateImagesInternal(params) {
|
|
15716
15823
|
var _a, _b, _c, _d;
|
|
@@ -15782,6 +15889,9 @@ class Models extends BaseModule {
|
|
|
15782
15889
|
});
|
|
15783
15890
|
}
|
|
15784
15891
|
}
|
|
15892
|
+
/**
|
|
15893
|
+
* Private method for editing an image.
|
|
15894
|
+
*/
|
|
15785
15895
|
async editImageInternal(params) {
|
|
15786
15896
|
var _a, _b;
|
|
15787
15897
|
let response;
|
|
@@ -15823,6 +15933,9 @@ class Models extends BaseModule {
|
|
|
15823
15933
|
throw new Error('This method is only supported by the Vertex AI.');
|
|
15824
15934
|
}
|
|
15825
15935
|
}
|
|
15936
|
+
/**
|
|
15937
|
+
* Private method for upscaling an image.
|
|
15938
|
+
*/
|
|
15826
15939
|
async upscaleImageInternal(params) {
|
|
15827
15940
|
var _a, _b;
|
|
15828
15941
|
let response;
|
|
@@ -16228,10 +16341,16 @@ class Models extends BaseModule {
|
|
|
16228
16341
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
16229
16342
|
})
|
|
16230
16343
|
.then((httpResponse) => {
|
|
16231
|
-
return httpResponse.json()
|
|
16344
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
16345
|
+
const response = jsonResponse;
|
|
16346
|
+
response.sdkHttpResponse = {
|
|
16347
|
+
headers: httpResponse.headers,
|
|
16348
|
+
};
|
|
16349
|
+
return response;
|
|
16350
|
+
});
|
|
16232
16351
|
});
|
|
16233
|
-
return response.then(() => {
|
|
16234
|
-
const resp = deleteModelResponseFromVertex();
|
|
16352
|
+
return response.then((apiResponse) => {
|
|
16353
|
+
const resp = deleteModelResponseFromVertex(apiResponse);
|
|
16235
16354
|
const typedResp = new DeleteModelResponse();
|
|
16236
16355
|
Object.assign(typedResp, resp);
|
|
16237
16356
|
return typedResp;
|
|
@@ -16254,10 +16373,16 @@ class Models extends BaseModule {
|
|
|
16254
16373
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
16255
16374
|
})
|
|
16256
16375
|
.then((httpResponse) => {
|
|
16257
|
-
return httpResponse.json()
|
|
16376
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
16377
|
+
const response = jsonResponse;
|
|
16378
|
+
response.sdkHttpResponse = {
|
|
16379
|
+
headers: httpResponse.headers,
|
|
16380
|
+
};
|
|
16381
|
+
return response;
|
|
16382
|
+
});
|
|
16258
16383
|
});
|
|
16259
|
-
return response.then(() => {
|
|
16260
|
-
const resp = deleteModelResponseFromMldev();
|
|
16384
|
+
return response.then((apiResponse) => {
|
|
16385
|
+
const resp = deleteModelResponseFromMldev(apiResponse);
|
|
16261
16386
|
const typedResp = new DeleteModelResponse();
|
|
16262
16387
|
Object.assign(typedResp, resp);
|
|
16263
16388
|
return typedResp;
|
|
@@ -16410,27 +16535,7 @@ class Models extends BaseModule {
|
|
|
16410
16535
|
}
|
|
16411
16536
|
}
|
|
16412
16537
|
/**
|
|
16413
|
-
*
|
|
16414
|
-
*
|
|
16415
|
-
* @param params - The parameters for generating videos.
|
|
16416
|
-
* @return A Promise<GenerateVideosOperation> which allows you to track the progress and eventually retrieve the generated videos using the operations.get method.
|
|
16417
|
-
*
|
|
16418
|
-
* @example
|
|
16419
|
-
* ```ts
|
|
16420
|
-
* const operation = await ai.models.generateVideos({
|
|
16421
|
-
* model: 'veo-2.0-generate-001',
|
|
16422
|
-
* prompt: 'A neon hologram of a cat driving at top speed',
|
|
16423
|
-
* config: {
|
|
16424
|
-
* numberOfVideos: 1
|
|
16425
|
-
* });
|
|
16426
|
-
*
|
|
16427
|
-
* while (!operation.done) {
|
|
16428
|
-
* await new Promise(resolve => setTimeout(resolve, 10000));
|
|
16429
|
-
* operation = await ai.operations.getVideosOperation({operation: operation});
|
|
16430
|
-
* }
|
|
16431
|
-
*
|
|
16432
|
-
* console.log(operation.response?.generatedVideos?.[0]?.video?.uri);
|
|
16433
|
-
* ```
|
|
16538
|
+
* Private method for generating videos.
|
|
16434
16539
|
*/
|
|
16435
16540
|
async generateVideosInternal(params) {
|
|
16436
16541
|
var _a, _b, _c, _d;
|
|
@@ -16512,13 +16617,17 @@ function getOperationParametersToMldev(fromObject) {
|
|
|
16512
16617
|
}
|
|
16513
16618
|
return toObject;
|
|
16514
16619
|
}
|
|
16515
|
-
function
|
|
16620
|
+
function fetchPredictOperationParametersToVertex(fromObject) {
|
|
16516
16621
|
const toObject = {};
|
|
16517
16622
|
const fromOperationName = getValueByPath(fromObject, [
|
|
16518
16623
|
'operationName',
|
|
16519
16624
|
]);
|
|
16520
16625
|
if (fromOperationName != null) {
|
|
16521
|
-
setValueByPath(toObject, ['
|
|
16626
|
+
setValueByPath(toObject, ['operationName'], fromOperationName);
|
|
16627
|
+
}
|
|
16628
|
+
const fromResourceName = getValueByPath(fromObject, ['resourceName']);
|
|
16629
|
+
if (fromResourceName != null) {
|
|
16630
|
+
setValueByPath(toObject, ['_url', 'resourceName'], fromResourceName);
|
|
16522
16631
|
}
|
|
16523
16632
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
16524
16633
|
if (fromConfig != null) {
|
|
@@ -16526,17 +16635,13 @@ function getOperationParametersToVertex(fromObject) {
|
|
|
16526
16635
|
}
|
|
16527
16636
|
return toObject;
|
|
16528
16637
|
}
|
|
16529
|
-
function
|
|
16638
|
+
function getOperationParametersToVertex(fromObject) {
|
|
16530
16639
|
const toObject = {};
|
|
16531
16640
|
const fromOperationName = getValueByPath(fromObject, [
|
|
16532
16641
|
'operationName',
|
|
16533
16642
|
]);
|
|
16534
16643
|
if (fromOperationName != null) {
|
|
16535
|
-
setValueByPath(toObject, ['operationName'], fromOperationName);
|
|
16536
|
-
}
|
|
16537
|
-
const fromResourceName = getValueByPath(fromObject, ['resourceName']);
|
|
16538
|
-
if (fromResourceName != null) {
|
|
16539
|
-
setValueByPath(toObject, ['_url', 'resourceName'], fromResourceName);
|
|
16644
|
+
setValueByPath(toObject, ['_url', 'operationName'], fromOperationName);
|
|
16540
16645
|
}
|
|
16541
16646
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
16542
16647
|
if (fromConfig != null) {
|
|
@@ -17797,6 +17902,18 @@ function listTuningJobsParametersToMldev(fromObject) {
|
|
|
17797
17902
|
}
|
|
17798
17903
|
return toObject;
|
|
17799
17904
|
}
|
|
17905
|
+
function cancelTuningJobParametersToMldev(fromObject) {
|
|
17906
|
+
const toObject = {};
|
|
17907
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
17908
|
+
if (fromName != null) {
|
|
17909
|
+
setValueByPath(toObject, ['_url', 'name'], fromName);
|
|
17910
|
+
}
|
|
17911
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
17912
|
+
if (fromConfig != null) {
|
|
17913
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
17914
|
+
}
|
|
17915
|
+
return toObject;
|
|
17916
|
+
}
|
|
17800
17917
|
function tuningExampleToMldev(fromObject) {
|
|
17801
17918
|
const toObject = {};
|
|
17802
17919
|
const fromTextInput = getValueByPath(fromObject, ['textInput']);
|
|
@@ -17934,6 +18051,18 @@ function listTuningJobsParametersToVertex(fromObject) {
|
|
|
17934
18051
|
}
|
|
17935
18052
|
return toObject;
|
|
17936
18053
|
}
|
|
18054
|
+
function cancelTuningJobParametersToVertex(fromObject) {
|
|
18055
|
+
const toObject = {};
|
|
18056
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
18057
|
+
if (fromName != null) {
|
|
18058
|
+
setValueByPath(toObject, ['_url', 'name'], fromName);
|
|
18059
|
+
}
|
|
18060
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
18061
|
+
if (fromConfig != null) {
|
|
18062
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
18063
|
+
}
|
|
18064
|
+
return toObject;
|
|
18065
|
+
}
|
|
17937
18066
|
function tuningDatasetToVertex(fromObject, parentObject) {
|
|
17938
18067
|
const toObject = {};
|
|
17939
18068
|
const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
|
|
@@ -18587,6 +18716,54 @@ class Tunings extends BaseModule {
|
|
|
18587
18716
|
});
|
|
18588
18717
|
}
|
|
18589
18718
|
}
|
|
18719
|
+
/**
|
|
18720
|
+
* Cancels a tuning job.
|
|
18721
|
+
*
|
|
18722
|
+
* @param params - The parameters for the cancel request.
|
|
18723
|
+
* @return The empty response returned by the API.
|
|
18724
|
+
*
|
|
18725
|
+
* @example
|
|
18726
|
+
* ```ts
|
|
18727
|
+
* await ai.tunings.cancel({name: '...'}); // The server-generated resource name.
|
|
18728
|
+
* ```
|
|
18729
|
+
*/
|
|
18730
|
+
async cancel(params) {
|
|
18731
|
+
var _a, _b, _c, _d;
|
|
18732
|
+
let path = '';
|
|
18733
|
+
let queryParams = {};
|
|
18734
|
+
if (this.apiClient.isVertexAI()) {
|
|
18735
|
+
const body = cancelTuningJobParametersToVertex(params);
|
|
18736
|
+
path = formatMap('{name}:cancel', body['_url']);
|
|
18737
|
+
queryParams = body['_query'];
|
|
18738
|
+
delete body['config'];
|
|
18739
|
+
delete body['_url'];
|
|
18740
|
+
delete body['_query'];
|
|
18741
|
+
await this.apiClient.request({
|
|
18742
|
+
path: path,
|
|
18743
|
+
queryParams: queryParams,
|
|
18744
|
+
body: JSON.stringify(body),
|
|
18745
|
+
httpMethod: 'POST',
|
|
18746
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
18747
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
18748
|
+
});
|
|
18749
|
+
}
|
|
18750
|
+
else {
|
|
18751
|
+
const body = cancelTuningJobParametersToMldev(params);
|
|
18752
|
+
path = formatMap('{name}:cancel', body['_url']);
|
|
18753
|
+
queryParams = body['_query'];
|
|
18754
|
+
delete body['config'];
|
|
18755
|
+
delete body['_url'];
|
|
18756
|
+
delete body['_query'];
|
|
18757
|
+
await this.apiClient.request({
|
|
18758
|
+
path: path,
|
|
18759
|
+
queryParams: queryParams,
|
|
18760
|
+
body: JSON.stringify(body),
|
|
18761
|
+
httpMethod: 'POST',
|
|
18762
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
18763
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
18764
|
+
});
|
|
18765
|
+
}
|
|
18766
|
+
}
|
|
18590
18767
|
async tuneInternal(params) {
|
|
18591
18768
|
var _a, _b;
|
|
18592
18769
|
let response;
|
|
@@ -19070,7 +19247,7 @@ function getApiKeyFromEnv() {
|
|
|
19070
19247
|
if (envGoogleApiKey && envGeminiApiKey) {
|
|
19071
19248
|
console.warn('Both GOOGLE_API_KEY and GEMINI_API_KEY are set. Using GOOGLE_API_KEY.');
|
|
19072
19249
|
}
|
|
19073
|
-
return envGoogleApiKey || envGeminiApiKey;
|
|
19250
|
+
return envGoogleApiKey || envGeminiApiKey || undefined;
|
|
19074
19251
|
}
|
|
19075
19252
|
|
|
19076
19253
|
exports.ApiError = ApiError;
|