@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/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;
|
|
@@ -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, [
|
|
@@ -10534,6 +10607,10 @@ function generateVideosParametersToMldev(apiClient, fromObject) {
|
|
|
10534
10607
|
if (getValueByPath(fromObject, ['video']) !== undefined) {
|
|
10535
10608
|
throw new Error('video parameter is not supported in Gemini API.');
|
|
10536
10609
|
}
|
|
10610
|
+
const fromSource = getValueByPath(fromObject, ['source']);
|
|
10611
|
+
if (fromSource != null) {
|
|
10612
|
+
setValueByPath(toObject, ['config'], generateVideosSourceToMldev(fromSource, toObject));
|
|
10613
|
+
}
|
|
10537
10614
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
10538
10615
|
if (fromConfig != null) {
|
|
10539
10616
|
setValueByPath(toObject, ['config'], generateVideosConfigToMldev(fromConfig, toObject));
|
|
@@ -11658,6 +11735,10 @@ function editImageParametersInternalToVertex(apiClient, fromObject) {
|
|
|
11658
11735
|
}
|
|
11659
11736
|
function upscaleImageAPIConfigInternalToVertex(fromObject, parentObject) {
|
|
11660
11737
|
const toObject = {};
|
|
11738
|
+
const fromOutputGcsUri = getValueByPath(fromObject, ['outputGcsUri']);
|
|
11739
|
+
if (parentObject !== undefined && fromOutputGcsUri != null) {
|
|
11740
|
+
setValueByPath(parentObject, ['parameters', 'storageUri'], fromOutputGcsUri);
|
|
11741
|
+
}
|
|
11661
11742
|
const fromIncludeRaiReason = getValueByPath(fromObject, [
|
|
11662
11743
|
'includeRaiReason',
|
|
11663
11744
|
]);
|
|
@@ -11786,6 +11867,10 @@ function recontextImageConfigToVertex(fromObject, parentObject) {
|
|
|
11786
11867
|
if (parentObject !== undefined && fromPersonGeneration != null) {
|
|
11787
11868
|
setValueByPath(parentObject, ['parameters', 'personGeneration'], fromPersonGeneration);
|
|
11788
11869
|
}
|
|
11870
|
+
const fromAddWatermark = getValueByPath(fromObject, ['addWatermark']);
|
|
11871
|
+
if (parentObject !== undefined && fromAddWatermark != null) {
|
|
11872
|
+
setValueByPath(parentObject, ['parameters', 'addWatermark'], fromAddWatermark);
|
|
11873
|
+
}
|
|
11789
11874
|
const fromOutputMimeType = getValueByPath(fromObject, [
|
|
11790
11875
|
'outputMimeType',
|
|
11791
11876
|
]);
|
|
@@ -12062,6 +12147,22 @@ function videoToVertex(fromObject) {
|
|
|
12062
12147
|
}
|
|
12063
12148
|
return toObject;
|
|
12064
12149
|
}
|
|
12150
|
+
function generateVideosSourceToVertex(fromObject, parentObject) {
|
|
12151
|
+
const toObject = {};
|
|
12152
|
+
const fromPrompt = getValueByPath(fromObject, ['prompt']);
|
|
12153
|
+
if (parentObject !== undefined && fromPrompt != null) {
|
|
12154
|
+
setValueByPath(parentObject, ['instances[0]', 'prompt'], fromPrompt);
|
|
12155
|
+
}
|
|
12156
|
+
const fromImage = getValueByPath(fromObject, ['image']);
|
|
12157
|
+
if (parentObject !== undefined && fromImage != null) {
|
|
12158
|
+
setValueByPath(parentObject, ['instances[0]', 'image'], imageToVertex(fromImage));
|
|
12159
|
+
}
|
|
12160
|
+
const fromVideo = getValueByPath(fromObject, ['video']);
|
|
12161
|
+
if (parentObject !== undefined && fromVideo != null) {
|
|
12162
|
+
setValueByPath(parentObject, ['instances[0]', 'video'], videoToVertex(fromVideo));
|
|
12163
|
+
}
|
|
12164
|
+
return toObject;
|
|
12165
|
+
}
|
|
12065
12166
|
function videoGenerationReferenceImageToVertex(fromObject) {
|
|
12066
12167
|
const toObject = {};
|
|
12067
12168
|
const fromImage = getValueByPath(fromObject, ['image']);
|
|
@@ -12180,6 +12281,10 @@ function generateVideosParametersToVertex(apiClient, fromObject) {
|
|
|
12180
12281
|
if (fromVideo != null) {
|
|
12181
12282
|
setValueByPath(toObject, ['instances[0]', 'video'], videoToVertex(fromVideo));
|
|
12182
12283
|
}
|
|
12284
|
+
const fromSource = getValueByPath(fromObject, ['source']);
|
|
12285
|
+
if (fromSource != null) {
|
|
12286
|
+
setValueByPath(toObject, ['config'], generateVideosSourceToVertex(fromSource, toObject));
|
|
12287
|
+
}
|
|
12183
12288
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
12184
12289
|
if (fromConfig != null) {
|
|
12185
12290
|
setValueByPath(toObject, ['config'], generateVideosConfigToVertex(fromConfig, toObject));
|
|
@@ -12630,8 +12735,14 @@ function listModelsResponseFromMldev(fromObject) {
|
|
|
12630
12735
|
}
|
|
12631
12736
|
return toObject;
|
|
12632
12737
|
}
|
|
12633
|
-
function deleteModelResponseFromMldev() {
|
|
12738
|
+
function deleteModelResponseFromMldev(fromObject) {
|
|
12634
12739
|
const toObject = {};
|
|
12740
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
12741
|
+
'sdkHttpResponse',
|
|
12742
|
+
]);
|
|
12743
|
+
if (fromSdkHttpResponse != null) {
|
|
12744
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
12745
|
+
}
|
|
12635
12746
|
return toObject;
|
|
12636
12747
|
}
|
|
12637
12748
|
function countTokensResponseFromMldev(fromObject) {
|
|
@@ -13376,8 +13487,14 @@ function listModelsResponseFromVertex(fromObject) {
|
|
|
13376
13487
|
}
|
|
13377
13488
|
return toObject;
|
|
13378
13489
|
}
|
|
13379
|
-
function deleteModelResponseFromVertex() {
|
|
13490
|
+
function deleteModelResponseFromVertex(fromObject) {
|
|
13380
13491
|
const toObject = {};
|
|
13492
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
13493
|
+
'sdkHttpResponse',
|
|
13494
|
+
]);
|
|
13495
|
+
if (fromSdkHttpResponse != null) {
|
|
13496
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
13497
|
+
}
|
|
13381
13498
|
return toObject;
|
|
13382
13499
|
}
|
|
13383
13500
|
function countTokensResponseFromVertex(fromObject) {
|
|
@@ -13494,7 +13611,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
13494
13611
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
13495
13612
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
13496
13613
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
13497
|
-
const SDK_VERSION = '1.
|
|
13614
|
+
const SDK_VERSION = '1.16.0'; // x-release-please-version
|
|
13498
13615
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
13499
13616
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
13500
13617
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -15266,7 +15383,9 @@ class Models extends BaseModule {
|
|
|
15266
15383
|
* ```ts
|
|
15267
15384
|
* const operation = await ai.models.generateVideos({
|
|
15268
15385
|
* model: 'veo-2.0-generate-001',
|
|
15269
|
-
*
|
|
15386
|
+
* source: {
|
|
15387
|
+
* prompt: 'A neon hologram of a cat driving at top speed',
|
|
15388
|
+
* },
|
|
15270
15389
|
* config: {
|
|
15271
15390
|
* numberOfVideos: 1
|
|
15272
15391
|
* });
|
|
@@ -15280,6 +15399,9 @@ class Models extends BaseModule {
|
|
|
15280
15399
|
* ```
|
|
15281
15400
|
*/
|
|
15282
15401
|
this.generateVideos = async (params) => {
|
|
15402
|
+
if ((params.prompt || params.image || params.video) && params.source) {
|
|
15403
|
+
throw new Error('Source and prompt/image/video are mutually exclusive. Please only use source.');
|
|
15404
|
+
}
|
|
15283
15405
|
return await this.generateVideosInternal(params);
|
|
15284
15406
|
};
|
|
15285
15407
|
}
|
|
@@ -16228,10 +16350,16 @@ class Models extends BaseModule {
|
|
|
16228
16350
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
16229
16351
|
})
|
|
16230
16352
|
.then((httpResponse) => {
|
|
16231
|
-
return httpResponse.json()
|
|
16353
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
16354
|
+
const response = jsonResponse;
|
|
16355
|
+
response.sdkHttpResponse = {
|
|
16356
|
+
headers: httpResponse.headers,
|
|
16357
|
+
};
|
|
16358
|
+
return response;
|
|
16359
|
+
});
|
|
16232
16360
|
});
|
|
16233
|
-
return response.then(() => {
|
|
16234
|
-
const resp = deleteModelResponseFromVertex();
|
|
16361
|
+
return response.then((apiResponse) => {
|
|
16362
|
+
const resp = deleteModelResponseFromVertex(apiResponse);
|
|
16235
16363
|
const typedResp = new DeleteModelResponse();
|
|
16236
16364
|
Object.assign(typedResp, resp);
|
|
16237
16365
|
return typedResp;
|
|
@@ -16254,10 +16382,16 @@ class Models extends BaseModule {
|
|
|
16254
16382
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
16255
16383
|
})
|
|
16256
16384
|
.then((httpResponse) => {
|
|
16257
|
-
return httpResponse.json()
|
|
16385
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
16386
|
+
const response = jsonResponse;
|
|
16387
|
+
response.sdkHttpResponse = {
|
|
16388
|
+
headers: httpResponse.headers,
|
|
16389
|
+
};
|
|
16390
|
+
return response;
|
|
16391
|
+
});
|
|
16258
16392
|
});
|
|
16259
|
-
return response.then(() => {
|
|
16260
|
-
const resp = deleteModelResponseFromMldev();
|
|
16393
|
+
return response.then((apiResponse) => {
|
|
16394
|
+
const resp = deleteModelResponseFromMldev(apiResponse);
|
|
16261
16395
|
const typedResp = new DeleteModelResponse();
|
|
16262
16396
|
Object.assign(typedResp, resp);
|
|
16263
16397
|
return typedResp;
|
|
@@ -16512,13 +16646,17 @@ function getOperationParametersToMldev(fromObject) {
|
|
|
16512
16646
|
}
|
|
16513
16647
|
return toObject;
|
|
16514
16648
|
}
|
|
16515
|
-
function
|
|
16649
|
+
function fetchPredictOperationParametersToVertex(fromObject) {
|
|
16516
16650
|
const toObject = {};
|
|
16517
16651
|
const fromOperationName = getValueByPath(fromObject, [
|
|
16518
16652
|
'operationName',
|
|
16519
16653
|
]);
|
|
16520
16654
|
if (fromOperationName != null) {
|
|
16521
|
-
setValueByPath(toObject, ['
|
|
16655
|
+
setValueByPath(toObject, ['operationName'], fromOperationName);
|
|
16656
|
+
}
|
|
16657
|
+
const fromResourceName = getValueByPath(fromObject, ['resourceName']);
|
|
16658
|
+
if (fromResourceName != null) {
|
|
16659
|
+
setValueByPath(toObject, ['_url', 'resourceName'], fromResourceName);
|
|
16522
16660
|
}
|
|
16523
16661
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
16524
16662
|
if (fromConfig != null) {
|
|
@@ -16526,17 +16664,13 @@ function getOperationParametersToVertex(fromObject) {
|
|
|
16526
16664
|
}
|
|
16527
16665
|
return toObject;
|
|
16528
16666
|
}
|
|
16529
|
-
function
|
|
16667
|
+
function getOperationParametersToVertex(fromObject) {
|
|
16530
16668
|
const toObject = {};
|
|
16531
16669
|
const fromOperationName = getValueByPath(fromObject, [
|
|
16532
16670
|
'operationName',
|
|
16533
16671
|
]);
|
|
16534
16672
|
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);
|
|
16673
|
+
setValueByPath(toObject, ['_url', 'operationName'], fromOperationName);
|
|
16540
16674
|
}
|
|
16541
16675
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
16542
16676
|
if (fromConfig != null) {
|
|
@@ -17797,6 +17931,18 @@ function listTuningJobsParametersToMldev(fromObject) {
|
|
|
17797
17931
|
}
|
|
17798
17932
|
return toObject;
|
|
17799
17933
|
}
|
|
17934
|
+
function cancelTuningJobParametersToMldev(fromObject) {
|
|
17935
|
+
const toObject = {};
|
|
17936
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
17937
|
+
if (fromName != null) {
|
|
17938
|
+
setValueByPath(toObject, ['_url', 'name'], fromName);
|
|
17939
|
+
}
|
|
17940
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
17941
|
+
if (fromConfig != null) {
|
|
17942
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
17943
|
+
}
|
|
17944
|
+
return toObject;
|
|
17945
|
+
}
|
|
17800
17946
|
function tuningExampleToMldev(fromObject) {
|
|
17801
17947
|
const toObject = {};
|
|
17802
17948
|
const fromTextInput = getValueByPath(fromObject, ['textInput']);
|
|
@@ -17934,6 +18080,18 @@ function listTuningJobsParametersToVertex(fromObject) {
|
|
|
17934
18080
|
}
|
|
17935
18081
|
return toObject;
|
|
17936
18082
|
}
|
|
18083
|
+
function cancelTuningJobParametersToVertex(fromObject) {
|
|
18084
|
+
const toObject = {};
|
|
18085
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
18086
|
+
if (fromName != null) {
|
|
18087
|
+
setValueByPath(toObject, ['_url', 'name'], fromName);
|
|
18088
|
+
}
|
|
18089
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
18090
|
+
if (fromConfig != null) {
|
|
18091
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
18092
|
+
}
|
|
18093
|
+
return toObject;
|
|
18094
|
+
}
|
|
17937
18095
|
function tuningDatasetToVertex(fromObject, parentObject) {
|
|
17938
18096
|
const toObject = {};
|
|
17939
18097
|
const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
|
|
@@ -18587,6 +18745,54 @@ class Tunings extends BaseModule {
|
|
|
18587
18745
|
});
|
|
18588
18746
|
}
|
|
18589
18747
|
}
|
|
18748
|
+
/**
|
|
18749
|
+
* Cancels a tuning job.
|
|
18750
|
+
*
|
|
18751
|
+
* @param params - The parameters for the cancel request.
|
|
18752
|
+
* @return The empty response returned by the API.
|
|
18753
|
+
*
|
|
18754
|
+
* @example
|
|
18755
|
+
* ```ts
|
|
18756
|
+
* await ai.tunings.cancel({name: '...'}); // The server-generated resource name.
|
|
18757
|
+
* ```
|
|
18758
|
+
*/
|
|
18759
|
+
async cancel(params) {
|
|
18760
|
+
var _a, _b, _c, _d;
|
|
18761
|
+
let path = '';
|
|
18762
|
+
let queryParams = {};
|
|
18763
|
+
if (this.apiClient.isVertexAI()) {
|
|
18764
|
+
const body = cancelTuningJobParametersToVertex(params);
|
|
18765
|
+
path = formatMap('{name}:cancel', body['_url']);
|
|
18766
|
+
queryParams = body['_query'];
|
|
18767
|
+
delete body['config'];
|
|
18768
|
+
delete body['_url'];
|
|
18769
|
+
delete body['_query'];
|
|
18770
|
+
await this.apiClient.request({
|
|
18771
|
+
path: path,
|
|
18772
|
+
queryParams: queryParams,
|
|
18773
|
+
body: JSON.stringify(body),
|
|
18774
|
+
httpMethod: 'POST',
|
|
18775
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
18776
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
18777
|
+
});
|
|
18778
|
+
}
|
|
18779
|
+
else {
|
|
18780
|
+
const body = cancelTuningJobParametersToMldev(params);
|
|
18781
|
+
path = formatMap('{name}:cancel', body['_url']);
|
|
18782
|
+
queryParams = body['_query'];
|
|
18783
|
+
delete body['config'];
|
|
18784
|
+
delete body['_url'];
|
|
18785
|
+
delete body['_query'];
|
|
18786
|
+
await this.apiClient.request({
|
|
18787
|
+
path: path,
|
|
18788
|
+
queryParams: queryParams,
|
|
18789
|
+
body: JSON.stringify(body),
|
|
18790
|
+
httpMethod: 'POST',
|
|
18791
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
18792
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
18793
|
+
});
|
|
18794
|
+
}
|
|
18795
|
+
}
|
|
18590
18796
|
async tuneInternal(params) {
|
|
18591
18797
|
var _a, _b;
|
|
18592
18798
|
let response;
|
|
@@ -19070,7 +19276,7 @@ function getApiKeyFromEnv() {
|
|
|
19070
19276
|
if (envGoogleApiKey && envGeminiApiKey) {
|
|
19071
19277
|
console.warn('Both GOOGLE_API_KEY and GEMINI_API_KEY are set. Using GOOGLE_API_KEY.');
|
|
19072
19278
|
}
|
|
19073
|
-
return envGoogleApiKey || envGeminiApiKey;
|
|
19279
|
+
return envGoogleApiKey || envGeminiApiKey || undefined;
|
|
19074
19280
|
}
|
|
19075
19281
|
|
|
19076
19282
|
exports.ApiError = ApiError;
|