@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/web/index.mjs
CHANGED
|
@@ -799,6 +799,10 @@ var FunctionCallingConfigMode;
|
|
|
799
799
|
* Model will not predict any function calls. Model behavior is same as when not passing any function declarations.
|
|
800
800
|
*/
|
|
801
801
|
FunctionCallingConfigMode["NONE"] = "NONE";
|
|
802
|
+
/**
|
|
803
|
+
* Model decides to predict either a function call or a natural language response, but will validate function calls with constrained decoding. If "allowed_function_names" are set, the predicted function call will be limited to any one of "allowed_function_names", else the predicted function call will be any one of the provided "function_declarations".
|
|
804
|
+
*/
|
|
805
|
+
FunctionCallingConfigMode["VALIDATED"] = "VALIDATED";
|
|
802
806
|
})(FunctionCallingConfigMode || (FunctionCallingConfigMode = {}));
|
|
803
807
|
/** Enum that controls the safety filter level for objectionable content. */
|
|
804
808
|
var SafetyFilterLevel;
|
|
@@ -906,6 +910,21 @@ var SegmentMode;
|
|
|
906
910
|
SegmentMode["SEMANTIC"] = "SEMANTIC";
|
|
907
911
|
SegmentMode["INTERACTIVE"] = "INTERACTIVE";
|
|
908
912
|
})(SegmentMode || (SegmentMode = {}));
|
|
913
|
+
/** Enum for the reference type of a video generation reference image. */
|
|
914
|
+
var VideoGenerationReferenceType;
|
|
915
|
+
(function (VideoGenerationReferenceType) {
|
|
916
|
+
/**
|
|
917
|
+
* A reference image that provides assets to the generated video,
|
|
918
|
+
such as the scene, an object, a character, etc.
|
|
919
|
+
*/
|
|
920
|
+
VideoGenerationReferenceType["ASSET"] = "ASSET";
|
|
921
|
+
/**
|
|
922
|
+
* A reference image that provides aesthetics including colors,
|
|
923
|
+
lighting, texture, etc., to be used as the style of the generated video,
|
|
924
|
+
such as 'anime', 'photography', 'origami', etc.
|
|
925
|
+
*/
|
|
926
|
+
VideoGenerationReferenceType["STYLE"] = "STYLE";
|
|
927
|
+
})(VideoGenerationReferenceType || (VideoGenerationReferenceType = {}));
|
|
909
928
|
/** Enum that controls the compression quality of the generated videos. */
|
|
910
929
|
var VideoCompressionQuality;
|
|
911
930
|
(function (VideoCompressionQuality) {
|
|
@@ -1568,6 +1587,65 @@ class ComputeTokensResponse {
|
|
|
1568
1587
|
/** Response with generated videos. */
|
|
1569
1588
|
class GenerateVideosResponse {
|
|
1570
1589
|
}
|
|
1590
|
+
/** A video generation operation. */
|
|
1591
|
+
class GenerateVideosOperation {
|
|
1592
|
+
/**
|
|
1593
|
+
* Instantiates an Operation of the same type as the one being called with the fields set from the API response.
|
|
1594
|
+
* @internal
|
|
1595
|
+
*/
|
|
1596
|
+
_fromAPIResponse({ apiResponse, isVertexAI, }) {
|
|
1597
|
+
const operation = new GenerateVideosOperation();
|
|
1598
|
+
operation.name = apiResponse['name'];
|
|
1599
|
+
operation.metadata = apiResponse['metadata'];
|
|
1600
|
+
operation.done = apiResponse['done'];
|
|
1601
|
+
operation.error = apiResponse['error'];
|
|
1602
|
+
if (isVertexAI) {
|
|
1603
|
+
const response = apiResponse['response'];
|
|
1604
|
+
if (response) {
|
|
1605
|
+
const operationResponse = new GenerateVideosResponse();
|
|
1606
|
+
const responseVideos = response['videos'];
|
|
1607
|
+
operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
|
|
1608
|
+
return {
|
|
1609
|
+
video: {
|
|
1610
|
+
uri: generatedVideo['gcsUri'],
|
|
1611
|
+
videoBytes: generatedVideo['bytesBase64Encoded']
|
|
1612
|
+
? tBytes$1(generatedVideo['bytesBase64Encoded'])
|
|
1613
|
+
: undefined,
|
|
1614
|
+
mimeType: generatedVideo['mimeType'],
|
|
1615
|
+
},
|
|
1616
|
+
};
|
|
1617
|
+
});
|
|
1618
|
+
operationResponse.raiMediaFilteredCount = response['raiMediaFilteredCount'];
|
|
1619
|
+
operationResponse.raiMediaFilteredReasons = response['raiMediaFilteredReasons'];
|
|
1620
|
+
operation.response = operationResponse;
|
|
1621
|
+
}
|
|
1622
|
+
}
|
|
1623
|
+
else {
|
|
1624
|
+
const response = apiResponse['response'];
|
|
1625
|
+
if (response) {
|
|
1626
|
+
const operationResponse = new GenerateVideosResponse();
|
|
1627
|
+
const generatedVideoResponse = response['generateVideoResponse'];
|
|
1628
|
+
const responseVideos = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['generatedSamples'];
|
|
1629
|
+
operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
|
|
1630
|
+
const video = generatedVideo['video'];
|
|
1631
|
+
return {
|
|
1632
|
+
video: {
|
|
1633
|
+
uri: video === null || video === void 0 ? void 0 : video['uri'],
|
|
1634
|
+
videoBytes: (video === null || video === void 0 ? void 0 : video['encodedVideo'])
|
|
1635
|
+
? tBytes$1(video === null || video === void 0 ? void 0 : video['encodedVideo'])
|
|
1636
|
+
: undefined,
|
|
1637
|
+
mimeType: generatedVideo['encoding'],
|
|
1638
|
+
},
|
|
1639
|
+
};
|
|
1640
|
+
});
|
|
1641
|
+
operationResponse.raiMediaFilteredCount = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredCount'];
|
|
1642
|
+
operationResponse.raiMediaFilteredReasons = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredReasons'];
|
|
1643
|
+
operation.response = operationResponse;
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
return operation;
|
|
1647
|
+
}
|
|
1648
|
+
}
|
|
1571
1649
|
/** Response for the list tuning jobs method. */
|
|
1572
1650
|
class ListTuningJobsResponse {
|
|
1573
1651
|
}
|
|
@@ -1759,65 +1837,6 @@ class LiveServerMessage {
|
|
|
1759
1837
|
return data.length > 0 ? btoa(data) : undefined;
|
|
1760
1838
|
}
|
|
1761
1839
|
}
|
|
1762
|
-
/** A video generation long-running operation. */
|
|
1763
|
-
class GenerateVideosOperation {
|
|
1764
|
-
/**
|
|
1765
|
-
* Instantiates an Operation of the same type as the one being called with the fields set from the API response.
|
|
1766
|
-
* @internal
|
|
1767
|
-
*/
|
|
1768
|
-
_fromAPIResponse({ apiResponse, isVertexAI, }) {
|
|
1769
|
-
const operation = new GenerateVideosOperation();
|
|
1770
|
-
operation.name = apiResponse['name'];
|
|
1771
|
-
operation.metadata = apiResponse['metadata'];
|
|
1772
|
-
operation.done = apiResponse['done'];
|
|
1773
|
-
operation.error = apiResponse['error'];
|
|
1774
|
-
if (isVertexAI) {
|
|
1775
|
-
const response = apiResponse['response'];
|
|
1776
|
-
if (response) {
|
|
1777
|
-
const operationResponse = new GenerateVideosResponse();
|
|
1778
|
-
const responseVideos = response['videos'];
|
|
1779
|
-
operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
|
|
1780
|
-
return {
|
|
1781
|
-
video: {
|
|
1782
|
-
uri: generatedVideo['gcsUri'],
|
|
1783
|
-
videoBytes: generatedVideo['bytesBase64Encoded']
|
|
1784
|
-
? tBytes$1(generatedVideo['bytesBase64Encoded'])
|
|
1785
|
-
: undefined,
|
|
1786
|
-
mimeType: generatedVideo['mimeType'],
|
|
1787
|
-
},
|
|
1788
|
-
};
|
|
1789
|
-
});
|
|
1790
|
-
operationResponse.raiMediaFilteredCount = response['raiMediaFilteredCount'];
|
|
1791
|
-
operationResponse.raiMediaFilteredReasons = response['raiMediaFilteredReasons'];
|
|
1792
|
-
operation.response = operationResponse;
|
|
1793
|
-
}
|
|
1794
|
-
}
|
|
1795
|
-
else {
|
|
1796
|
-
const response = apiResponse['response'];
|
|
1797
|
-
if (response) {
|
|
1798
|
-
const operationResponse = new GenerateVideosResponse();
|
|
1799
|
-
const generatedVideoResponse = response['generateVideoResponse'];
|
|
1800
|
-
const responseVideos = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['generatedSamples'];
|
|
1801
|
-
operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
|
|
1802
|
-
const video = generatedVideo['video'];
|
|
1803
|
-
return {
|
|
1804
|
-
video: {
|
|
1805
|
-
uri: video === null || video === void 0 ? void 0 : video['uri'],
|
|
1806
|
-
videoBytes: (video === null || video === void 0 ? void 0 : video['encodedVideo'])
|
|
1807
|
-
? tBytes$1(video === null || video === void 0 ? void 0 : video['encodedVideo'])
|
|
1808
|
-
: undefined,
|
|
1809
|
-
mimeType: generatedVideo['encoding'],
|
|
1810
|
-
},
|
|
1811
|
-
};
|
|
1812
|
-
});
|
|
1813
|
-
operationResponse.raiMediaFilteredCount = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredCount'];
|
|
1814
|
-
operationResponse.raiMediaFilteredReasons = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredReasons'];
|
|
1815
|
-
operation.response = operationResponse;
|
|
1816
|
-
}
|
|
1817
|
-
}
|
|
1818
|
-
return operation;
|
|
1819
|
-
}
|
|
1820
|
-
}
|
|
1821
1840
|
/** Client generated response to a `ToolCall` received from the server.
|
|
1822
1841
|
|
|
1823
1842
|
Individual `FunctionResponse` objects are matched to the respective
|
|
@@ -2464,6 +2483,9 @@ function mcpToGeminiTool(mcpTool, config = {}) {
|
|
|
2464
2483
|
description: mcpToolSchema['description'],
|
|
2465
2484
|
parametersJsonSchema: mcpToolSchema['inputSchema'],
|
|
2466
2485
|
};
|
|
2486
|
+
if (mcpToolSchema['outputSchema']) {
|
|
2487
|
+
functionDeclaration['responseJsonSchema'] = mcpToolSchema['outputSchema'];
|
|
2488
|
+
}
|
|
2467
2489
|
if (config.behavior) {
|
|
2468
2490
|
functionDeclaration['behavior'] = config.behavior;
|
|
2469
2491
|
}
|
|
@@ -5711,8 +5733,14 @@ function cachedContentFromMldev(fromObject) {
|
|
|
5711
5733
|
}
|
|
5712
5734
|
return toObject;
|
|
5713
5735
|
}
|
|
5714
|
-
function deleteCachedContentResponseFromMldev() {
|
|
5736
|
+
function deleteCachedContentResponseFromMldev(fromObject) {
|
|
5715
5737
|
const toObject = {};
|
|
5738
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
5739
|
+
'sdkHttpResponse',
|
|
5740
|
+
]);
|
|
5741
|
+
if (fromSdkHttpResponse != null) {
|
|
5742
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
5743
|
+
}
|
|
5716
5744
|
return toObject;
|
|
5717
5745
|
}
|
|
5718
5746
|
function listCachedContentsResponseFromMldev(fromObject) {
|
|
@@ -5777,8 +5805,14 @@ function cachedContentFromVertex(fromObject) {
|
|
|
5777
5805
|
}
|
|
5778
5806
|
return toObject;
|
|
5779
5807
|
}
|
|
5780
|
-
function deleteCachedContentResponseFromVertex() {
|
|
5808
|
+
function deleteCachedContentResponseFromVertex(fromObject) {
|
|
5781
5809
|
const toObject = {};
|
|
5810
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
5811
|
+
'sdkHttpResponse',
|
|
5812
|
+
]);
|
|
5813
|
+
if (fromSdkHttpResponse != null) {
|
|
5814
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
5815
|
+
}
|
|
5782
5816
|
return toObject;
|
|
5783
5817
|
}
|
|
5784
5818
|
function listCachedContentsResponseFromVertex(fromObject) {
|
|
@@ -6015,10 +6049,16 @@ class Caches extends BaseModule {
|
|
|
6015
6049
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
6016
6050
|
})
|
|
6017
6051
|
.then((httpResponse) => {
|
|
6018
|
-
return httpResponse.json()
|
|
6052
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
6053
|
+
const response = jsonResponse;
|
|
6054
|
+
response.sdkHttpResponse = {
|
|
6055
|
+
headers: httpResponse.headers,
|
|
6056
|
+
};
|
|
6057
|
+
return response;
|
|
6058
|
+
});
|
|
6019
6059
|
});
|
|
6020
|
-
return response.then(() => {
|
|
6021
|
-
const resp = deleteCachedContentResponseFromVertex();
|
|
6060
|
+
return response.then((apiResponse) => {
|
|
6061
|
+
const resp = deleteCachedContentResponseFromVertex(apiResponse);
|
|
6022
6062
|
const typedResp = new DeleteCachedContentResponse();
|
|
6023
6063
|
Object.assign(typedResp, resp);
|
|
6024
6064
|
return typedResp;
|
|
@@ -6041,10 +6081,16 @@ class Caches extends BaseModule {
|
|
|
6041
6081
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
6042
6082
|
})
|
|
6043
6083
|
.then((httpResponse) => {
|
|
6044
|
-
return httpResponse.json()
|
|
6084
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
6085
|
+
const response = jsonResponse;
|
|
6086
|
+
response.sdkHttpResponse = {
|
|
6087
|
+
headers: httpResponse.headers,
|
|
6088
|
+
};
|
|
6089
|
+
return response;
|
|
6090
|
+
});
|
|
6045
6091
|
});
|
|
6046
|
-
return response.then(() => {
|
|
6047
|
-
const resp = deleteCachedContentResponseFromMldev();
|
|
6092
|
+
return response.then((apiResponse) => {
|
|
6093
|
+
const resp = deleteCachedContentResponseFromMldev(apiResponse);
|
|
6048
6094
|
const typedResp = new DeleteCachedContentResponse();
|
|
6049
6095
|
Object.assign(typedResp, resp);
|
|
6050
6096
|
return typedResp;
|
|
@@ -6848,8 +6894,14 @@ function createFileResponseFromMldev(fromObject) {
|
|
|
6848
6894
|
}
|
|
6849
6895
|
return toObject;
|
|
6850
6896
|
}
|
|
6851
|
-
function deleteFileResponseFromMldev() {
|
|
6897
|
+
function deleteFileResponseFromMldev(fromObject) {
|
|
6852
6898
|
const toObject = {};
|
|
6899
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
6900
|
+
'sdkHttpResponse',
|
|
6901
|
+
]);
|
|
6902
|
+
if (fromSdkHttpResponse != null) {
|
|
6903
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
6904
|
+
}
|
|
6853
6905
|
return toObject;
|
|
6854
6906
|
}
|
|
6855
6907
|
|
|
@@ -7118,10 +7170,16 @@ class Files extends BaseModule {
|
|
|
7118
7170
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
7119
7171
|
})
|
|
7120
7172
|
.then((httpResponse) => {
|
|
7121
|
-
return httpResponse.json()
|
|
7173
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
7174
|
+
const response = jsonResponse;
|
|
7175
|
+
response.sdkHttpResponse = {
|
|
7176
|
+
headers: httpResponse.headers,
|
|
7177
|
+
};
|
|
7178
|
+
return response;
|
|
7179
|
+
});
|
|
7122
7180
|
});
|
|
7123
|
-
return response.then(() => {
|
|
7124
|
-
const resp = deleteFileResponseFromMldev();
|
|
7181
|
+
return response.then((apiResponse) => {
|
|
7182
|
+
const resp = deleteFileResponseFromMldev(apiResponse);
|
|
7125
7183
|
const typedResp = new DeleteFileResponse();
|
|
7126
7184
|
Object.assign(typedResp, resp);
|
|
7127
7185
|
return typedResp;
|
|
@@ -10424,6 +10482,21 @@ function imageToMldev(fromObject) {
|
|
|
10424
10482
|
}
|
|
10425
10483
|
return toObject;
|
|
10426
10484
|
}
|
|
10485
|
+
function generateVideosSourceToMldev(fromObject, parentObject) {
|
|
10486
|
+
const toObject = {};
|
|
10487
|
+
const fromPrompt = getValueByPath(fromObject, ['prompt']);
|
|
10488
|
+
if (parentObject !== undefined && fromPrompt != null) {
|
|
10489
|
+
setValueByPath(parentObject, ['instances[0]', 'prompt'], fromPrompt);
|
|
10490
|
+
}
|
|
10491
|
+
const fromImage = getValueByPath(fromObject, ['image']);
|
|
10492
|
+
if (parentObject !== undefined && fromImage != null) {
|
|
10493
|
+
setValueByPath(parentObject, ['instances[0]', 'image'], imageToMldev(fromImage));
|
|
10494
|
+
}
|
|
10495
|
+
if (getValueByPath(fromObject, ['video']) !== undefined) {
|
|
10496
|
+
throw new Error('video parameter is not supported in Gemini API.');
|
|
10497
|
+
}
|
|
10498
|
+
return toObject;
|
|
10499
|
+
}
|
|
10427
10500
|
function generateVideosConfigToMldev(fromObject, parentObject) {
|
|
10428
10501
|
const toObject = {};
|
|
10429
10502
|
const fromNumberOfVideos = getValueByPath(fromObject, [
|
|
@@ -10506,6 +10579,10 @@ function generateVideosParametersToMldev(apiClient, fromObject) {
|
|
|
10506
10579
|
if (getValueByPath(fromObject, ['video']) !== undefined) {
|
|
10507
10580
|
throw new Error('video parameter is not supported in Gemini API.');
|
|
10508
10581
|
}
|
|
10582
|
+
const fromSource = getValueByPath(fromObject, ['source']);
|
|
10583
|
+
if (fromSource != null) {
|
|
10584
|
+
setValueByPath(toObject, ['config'], generateVideosSourceToMldev(fromSource, toObject));
|
|
10585
|
+
}
|
|
10509
10586
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
10510
10587
|
if (fromConfig != null) {
|
|
10511
10588
|
setValueByPath(toObject, ['config'], generateVideosConfigToMldev(fromConfig, toObject));
|
|
@@ -11630,6 +11707,10 @@ function editImageParametersInternalToVertex(apiClient, fromObject) {
|
|
|
11630
11707
|
}
|
|
11631
11708
|
function upscaleImageAPIConfigInternalToVertex(fromObject, parentObject) {
|
|
11632
11709
|
const toObject = {};
|
|
11710
|
+
const fromOutputGcsUri = getValueByPath(fromObject, ['outputGcsUri']);
|
|
11711
|
+
if (parentObject !== undefined && fromOutputGcsUri != null) {
|
|
11712
|
+
setValueByPath(parentObject, ['parameters', 'storageUri'], fromOutputGcsUri);
|
|
11713
|
+
}
|
|
11633
11714
|
const fromIncludeRaiReason = getValueByPath(fromObject, [
|
|
11634
11715
|
'includeRaiReason',
|
|
11635
11716
|
]);
|
|
@@ -11758,6 +11839,10 @@ function recontextImageConfigToVertex(fromObject, parentObject) {
|
|
|
11758
11839
|
if (parentObject !== undefined && fromPersonGeneration != null) {
|
|
11759
11840
|
setValueByPath(parentObject, ['parameters', 'personGeneration'], fromPersonGeneration);
|
|
11760
11841
|
}
|
|
11842
|
+
const fromAddWatermark = getValueByPath(fromObject, ['addWatermark']);
|
|
11843
|
+
if (parentObject !== undefined && fromAddWatermark != null) {
|
|
11844
|
+
setValueByPath(parentObject, ['parameters', 'addWatermark'], fromAddWatermark);
|
|
11845
|
+
}
|
|
11761
11846
|
const fromOutputMimeType = getValueByPath(fromObject, [
|
|
11762
11847
|
'outputMimeType',
|
|
11763
11848
|
]);
|
|
@@ -12034,6 +12119,22 @@ function videoToVertex(fromObject) {
|
|
|
12034
12119
|
}
|
|
12035
12120
|
return toObject;
|
|
12036
12121
|
}
|
|
12122
|
+
function generateVideosSourceToVertex(fromObject, parentObject) {
|
|
12123
|
+
const toObject = {};
|
|
12124
|
+
const fromPrompt = getValueByPath(fromObject, ['prompt']);
|
|
12125
|
+
if (parentObject !== undefined && fromPrompt != null) {
|
|
12126
|
+
setValueByPath(parentObject, ['instances[0]', 'prompt'], fromPrompt);
|
|
12127
|
+
}
|
|
12128
|
+
const fromImage = getValueByPath(fromObject, ['image']);
|
|
12129
|
+
if (parentObject !== undefined && fromImage != null) {
|
|
12130
|
+
setValueByPath(parentObject, ['instances[0]', 'image'], imageToVertex(fromImage));
|
|
12131
|
+
}
|
|
12132
|
+
const fromVideo = getValueByPath(fromObject, ['video']);
|
|
12133
|
+
if (parentObject !== undefined && fromVideo != null) {
|
|
12134
|
+
setValueByPath(parentObject, ['instances[0]', 'video'], videoToVertex(fromVideo));
|
|
12135
|
+
}
|
|
12136
|
+
return toObject;
|
|
12137
|
+
}
|
|
12037
12138
|
function videoGenerationReferenceImageToVertex(fromObject) {
|
|
12038
12139
|
const toObject = {};
|
|
12039
12140
|
const fromImage = getValueByPath(fromObject, ['image']);
|
|
@@ -12152,6 +12253,10 @@ function generateVideosParametersToVertex(apiClient, fromObject) {
|
|
|
12152
12253
|
if (fromVideo != null) {
|
|
12153
12254
|
setValueByPath(toObject, ['instances[0]', 'video'], videoToVertex(fromVideo));
|
|
12154
12255
|
}
|
|
12256
|
+
const fromSource = getValueByPath(fromObject, ['source']);
|
|
12257
|
+
if (fromSource != null) {
|
|
12258
|
+
setValueByPath(toObject, ['config'], generateVideosSourceToVertex(fromSource, toObject));
|
|
12259
|
+
}
|
|
12155
12260
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
12156
12261
|
if (fromConfig != null) {
|
|
12157
12262
|
setValueByPath(toObject, ['config'], generateVideosConfigToVertex(fromConfig, toObject));
|
|
@@ -12602,8 +12707,14 @@ function listModelsResponseFromMldev(fromObject) {
|
|
|
12602
12707
|
}
|
|
12603
12708
|
return toObject;
|
|
12604
12709
|
}
|
|
12605
|
-
function deleteModelResponseFromMldev() {
|
|
12710
|
+
function deleteModelResponseFromMldev(fromObject) {
|
|
12606
12711
|
const toObject = {};
|
|
12712
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
12713
|
+
'sdkHttpResponse',
|
|
12714
|
+
]);
|
|
12715
|
+
if (fromSdkHttpResponse != null) {
|
|
12716
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
12717
|
+
}
|
|
12607
12718
|
return toObject;
|
|
12608
12719
|
}
|
|
12609
12720
|
function countTokensResponseFromMldev(fromObject) {
|
|
@@ -13348,8 +13459,14 @@ function listModelsResponseFromVertex(fromObject) {
|
|
|
13348
13459
|
}
|
|
13349
13460
|
return toObject;
|
|
13350
13461
|
}
|
|
13351
|
-
function deleteModelResponseFromVertex() {
|
|
13462
|
+
function deleteModelResponseFromVertex(fromObject) {
|
|
13352
13463
|
const toObject = {};
|
|
13464
|
+
const fromSdkHttpResponse = getValueByPath(fromObject, [
|
|
13465
|
+
'sdkHttpResponse',
|
|
13466
|
+
]);
|
|
13467
|
+
if (fromSdkHttpResponse != null) {
|
|
13468
|
+
setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
|
|
13469
|
+
}
|
|
13353
13470
|
return toObject;
|
|
13354
13471
|
}
|
|
13355
13472
|
function countTokensResponseFromVertex(fromObject) {
|
|
@@ -13466,7 +13583,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
13466
13583
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
13467
13584
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
13468
13585
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
13469
|
-
const SDK_VERSION = '1.
|
|
13586
|
+
const SDK_VERSION = '1.16.0'; // x-release-please-version
|
|
13470
13587
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
13471
13588
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
13472
13589
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -15238,7 +15355,9 @@ class Models extends BaseModule {
|
|
|
15238
15355
|
* ```ts
|
|
15239
15356
|
* const operation = await ai.models.generateVideos({
|
|
15240
15357
|
* model: 'veo-2.0-generate-001',
|
|
15241
|
-
*
|
|
15358
|
+
* source: {
|
|
15359
|
+
* prompt: 'A neon hologram of a cat driving at top speed',
|
|
15360
|
+
* },
|
|
15242
15361
|
* config: {
|
|
15243
15362
|
* numberOfVideos: 1
|
|
15244
15363
|
* });
|
|
@@ -15252,6 +15371,9 @@ class Models extends BaseModule {
|
|
|
15252
15371
|
* ```
|
|
15253
15372
|
*/
|
|
15254
15373
|
this.generateVideos = async (params) => {
|
|
15374
|
+
if ((params.prompt || params.image || params.video) && params.source) {
|
|
15375
|
+
throw new Error('Source and prompt/image/video are mutually exclusive. Please only use source.');
|
|
15376
|
+
}
|
|
15255
15377
|
return await this.generateVideosInternal(params);
|
|
15256
15378
|
};
|
|
15257
15379
|
}
|
|
@@ -16200,10 +16322,16 @@ class Models extends BaseModule {
|
|
|
16200
16322
|
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
16201
16323
|
})
|
|
16202
16324
|
.then((httpResponse) => {
|
|
16203
|
-
return httpResponse.json()
|
|
16325
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
16326
|
+
const response = jsonResponse;
|
|
16327
|
+
response.sdkHttpResponse = {
|
|
16328
|
+
headers: httpResponse.headers,
|
|
16329
|
+
};
|
|
16330
|
+
return response;
|
|
16331
|
+
});
|
|
16204
16332
|
});
|
|
16205
|
-
return response.then(() => {
|
|
16206
|
-
const resp = deleteModelResponseFromVertex();
|
|
16333
|
+
return response.then((apiResponse) => {
|
|
16334
|
+
const resp = deleteModelResponseFromVertex(apiResponse);
|
|
16207
16335
|
const typedResp = new DeleteModelResponse();
|
|
16208
16336
|
Object.assign(typedResp, resp);
|
|
16209
16337
|
return typedResp;
|
|
@@ -16226,10 +16354,16 @@ class Models extends BaseModule {
|
|
|
16226
16354
|
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
16227
16355
|
})
|
|
16228
16356
|
.then((httpResponse) => {
|
|
16229
|
-
return httpResponse.json()
|
|
16357
|
+
return httpResponse.json().then((jsonResponse) => {
|
|
16358
|
+
const response = jsonResponse;
|
|
16359
|
+
response.sdkHttpResponse = {
|
|
16360
|
+
headers: httpResponse.headers,
|
|
16361
|
+
};
|
|
16362
|
+
return response;
|
|
16363
|
+
});
|
|
16230
16364
|
});
|
|
16231
|
-
return response.then(() => {
|
|
16232
|
-
const resp = deleteModelResponseFromMldev();
|
|
16365
|
+
return response.then((apiResponse) => {
|
|
16366
|
+
const resp = deleteModelResponseFromMldev(apiResponse);
|
|
16233
16367
|
const typedResp = new DeleteModelResponse();
|
|
16234
16368
|
Object.assign(typedResp, resp);
|
|
16235
16369
|
return typedResp;
|
|
@@ -16484,13 +16618,17 @@ function getOperationParametersToMldev(fromObject) {
|
|
|
16484
16618
|
}
|
|
16485
16619
|
return toObject;
|
|
16486
16620
|
}
|
|
16487
|
-
function
|
|
16621
|
+
function fetchPredictOperationParametersToVertex(fromObject) {
|
|
16488
16622
|
const toObject = {};
|
|
16489
16623
|
const fromOperationName = getValueByPath(fromObject, [
|
|
16490
16624
|
'operationName',
|
|
16491
16625
|
]);
|
|
16492
16626
|
if (fromOperationName != null) {
|
|
16493
|
-
setValueByPath(toObject, ['
|
|
16627
|
+
setValueByPath(toObject, ['operationName'], fromOperationName);
|
|
16628
|
+
}
|
|
16629
|
+
const fromResourceName = getValueByPath(fromObject, ['resourceName']);
|
|
16630
|
+
if (fromResourceName != null) {
|
|
16631
|
+
setValueByPath(toObject, ['_url', 'resourceName'], fromResourceName);
|
|
16494
16632
|
}
|
|
16495
16633
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
16496
16634
|
if (fromConfig != null) {
|
|
@@ -16498,17 +16636,13 @@ function getOperationParametersToVertex(fromObject) {
|
|
|
16498
16636
|
}
|
|
16499
16637
|
return toObject;
|
|
16500
16638
|
}
|
|
16501
|
-
function
|
|
16639
|
+
function getOperationParametersToVertex(fromObject) {
|
|
16502
16640
|
const toObject = {};
|
|
16503
16641
|
const fromOperationName = getValueByPath(fromObject, [
|
|
16504
16642
|
'operationName',
|
|
16505
16643
|
]);
|
|
16506
16644
|
if (fromOperationName != null) {
|
|
16507
|
-
setValueByPath(toObject, ['operationName'], fromOperationName);
|
|
16508
|
-
}
|
|
16509
|
-
const fromResourceName = getValueByPath(fromObject, ['resourceName']);
|
|
16510
|
-
if (fromResourceName != null) {
|
|
16511
|
-
setValueByPath(toObject, ['_url', 'resourceName'], fromResourceName);
|
|
16645
|
+
setValueByPath(toObject, ['_url', 'operationName'], fromOperationName);
|
|
16512
16646
|
}
|
|
16513
16647
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
16514
16648
|
if (fromConfig != null) {
|
|
@@ -17595,6 +17729,18 @@ function listTuningJobsParametersToMldev(fromObject) {
|
|
|
17595
17729
|
}
|
|
17596
17730
|
return toObject;
|
|
17597
17731
|
}
|
|
17732
|
+
function cancelTuningJobParametersToMldev(fromObject) {
|
|
17733
|
+
const toObject = {};
|
|
17734
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
17735
|
+
if (fromName != null) {
|
|
17736
|
+
setValueByPath(toObject, ['_url', 'name'], fromName);
|
|
17737
|
+
}
|
|
17738
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
17739
|
+
if (fromConfig != null) {
|
|
17740
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
17741
|
+
}
|
|
17742
|
+
return toObject;
|
|
17743
|
+
}
|
|
17598
17744
|
function tuningExampleToMldev(fromObject) {
|
|
17599
17745
|
const toObject = {};
|
|
17600
17746
|
const fromTextInput = getValueByPath(fromObject, ['textInput']);
|
|
@@ -17732,6 +17878,18 @@ function listTuningJobsParametersToVertex(fromObject) {
|
|
|
17732
17878
|
}
|
|
17733
17879
|
return toObject;
|
|
17734
17880
|
}
|
|
17881
|
+
function cancelTuningJobParametersToVertex(fromObject) {
|
|
17882
|
+
const toObject = {};
|
|
17883
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
17884
|
+
if (fromName != null) {
|
|
17885
|
+
setValueByPath(toObject, ['_url', 'name'], fromName);
|
|
17886
|
+
}
|
|
17887
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
17888
|
+
if (fromConfig != null) {
|
|
17889
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
17890
|
+
}
|
|
17891
|
+
return toObject;
|
|
17892
|
+
}
|
|
17735
17893
|
function tuningDatasetToVertex(fromObject, parentObject) {
|
|
17736
17894
|
const toObject = {};
|
|
17737
17895
|
const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
|
|
@@ -18385,6 +18543,54 @@ class Tunings extends BaseModule {
|
|
|
18385
18543
|
});
|
|
18386
18544
|
}
|
|
18387
18545
|
}
|
|
18546
|
+
/**
|
|
18547
|
+
* Cancels a tuning job.
|
|
18548
|
+
*
|
|
18549
|
+
* @param params - The parameters for the cancel request.
|
|
18550
|
+
* @return The empty response returned by the API.
|
|
18551
|
+
*
|
|
18552
|
+
* @example
|
|
18553
|
+
* ```ts
|
|
18554
|
+
* await ai.tunings.cancel({name: '...'}); // The server-generated resource name.
|
|
18555
|
+
* ```
|
|
18556
|
+
*/
|
|
18557
|
+
async cancel(params) {
|
|
18558
|
+
var _a, _b, _c, _d;
|
|
18559
|
+
let path = '';
|
|
18560
|
+
let queryParams = {};
|
|
18561
|
+
if (this.apiClient.isVertexAI()) {
|
|
18562
|
+
const body = cancelTuningJobParametersToVertex(params);
|
|
18563
|
+
path = formatMap('{name}:cancel', body['_url']);
|
|
18564
|
+
queryParams = body['_query'];
|
|
18565
|
+
delete body['config'];
|
|
18566
|
+
delete body['_url'];
|
|
18567
|
+
delete body['_query'];
|
|
18568
|
+
await this.apiClient.request({
|
|
18569
|
+
path: path,
|
|
18570
|
+
queryParams: queryParams,
|
|
18571
|
+
body: JSON.stringify(body),
|
|
18572
|
+
httpMethod: 'POST',
|
|
18573
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
18574
|
+
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
18575
|
+
});
|
|
18576
|
+
}
|
|
18577
|
+
else {
|
|
18578
|
+
const body = cancelTuningJobParametersToMldev(params);
|
|
18579
|
+
path = formatMap('{name}:cancel', body['_url']);
|
|
18580
|
+
queryParams = body['_query'];
|
|
18581
|
+
delete body['config'];
|
|
18582
|
+
delete body['_url'];
|
|
18583
|
+
delete body['_query'];
|
|
18584
|
+
await this.apiClient.request({
|
|
18585
|
+
path: path,
|
|
18586
|
+
queryParams: queryParams,
|
|
18587
|
+
body: JSON.stringify(body),
|
|
18588
|
+
httpMethod: 'POST',
|
|
18589
|
+
httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
|
|
18590
|
+
abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
|
|
18591
|
+
});
|
|
18592
|
+
}
|
|
18593
|
+
}
|
|
18388
18594
|
async tuneInternal(params) {
|
|
18389
18595
|
var _a, _b;
|
|
18390
18596
|
let response;
|
|
@@ -18713,5 +18919,5 @@ class GoogleGenAI {
|
|
|
18713
18919
|
}
|
|
18714
18920
|
}
|
|
18715
18921
|
|
|
18716
|
-
export { ActivityHandling, AdapterSize, ApiError, ApiSpec, AuthType, Batches, Behavior, BlockedReason, Caches, Chat, Chats, ComputeTokensResponse, ControlReferenceImage, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DeleteModelResponse, DynamicRetrievalConfigMode, EditImageResponse, EditMode, EmbedContentResponse, EndSensitivity, Environment, FeatureSelectionPreference, FileSource, FileState, Files, FinishReason, FunctionCallingConfigMode, FunctionResponse, FunctionResponseScheduling, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GenerateVideosOperation, GenerateVideosResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpResponse, ImagePromptLanguage, InlinedResponse, JobState, Language, ListBatchJobsResponse, ListCachedContentsResponse, ListFilesResponse, ListModelsResponse, ListTuningJobsResponse, Live, LiveClientToolResponse, LiveMusicPlaybackControl, LiveMusicServerMessage, LiveSendToolResponseParameters, LiveServerMessage, MaskReferenceImage, MaskReferenceMode, MediaModality, MediaResolution, Modality, Mode, Models, MusicGenerationMode, Operations, Outcome, PagedItem, Pager, PersonGeneration, RawReferenceImage, RecontextImageResponse, ReplayResponse, SafetyFilterLevel, Scale, SegmentImageResponse, SegmentMode, Session, StartSensitivity, StyleReferenceImage, SubjectReferenceImage, SubjectReferenceType, Tokens, TrafficType, TuningMode, TurnCoverage, Type, UpscaleImageResponse, UrlRetrievalStatus, VideoCompressionQuality, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent, mcpToTool, setDefaultBaseUrls };
|
|
18922
|
+
export { ActivityHandling, AdapterSize, ApiError, ApiSpec, AuthType, Batches, Behavior, BlockedReason, Caches, Chat, Chats, ComputeTokensResponse, ControlReferenceImage, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DeleteModelResponse, DynamicRetrievalConfigMode, EditImageResponse, EditMode, EmbedContentResponse, EndSensitivity, Environment, FeatureSelectionPreference, FileSource, FileState, Files, FinishReason, FunctionCallingConfigMode, FunctionResponse, FunctionResponseScheduling, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GenerateVideosOperation, GenerateVideosResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpResponse, ImagePromptLanguage, InlinedResponse, JobState, Language, ListBatchJobsResponse, ListCachedContentsResponse, ListFilesResponse, ListModelsResponse, ListTuningJobsResponse, Live, LiveClientToolResponse, LiveMusicPlaybackControl, LiveMusicServerMessage, LiveSendToolResponseParameters, LiveServerMessage, MaskReferenceImage, MaskReferenceMode, MediaModality, MediaResolution, Modality, Mode, Models, MusicGenerationMode, Operations, Outcome, PagedItem, Pager, PersonGeneration, RawReferenceImage, RecontextImageResponse, ReplayResponse, SafetyFilterLevel, Scale, SegmentImageResponse, SegmentMode, Session, StartSensitivity, StyleReferenceImage, SubjectReferenceImage, SubjectReferenceType, Tokens, TrafficType, TuningMode, TurnCoverage, Type, UpscaleImageResponse, UrlRetrievalStatus, VideoCompressionQuality, VideoGenerationReferenceType, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent, mcpToTool, setDefaultBaseUrls };
|
|
18717
18923
|
//# sourceMappingURL=index.mjs.map
|