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