@google/genai 1.23.0 → 1.25.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 +19 -1
- package/dist/index.cjs +194 -82
- package/dist/index.mjs +194 -82
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.cjs +194 -82
- package/dist/node/index.mjs +194 -82
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/node.d.ts +19 -1
- package/dist/web/index.mjs +194 -82
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +19 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -163,6 +163,98 @@ function getValueByPath(data, keys, defaultValue = undefined) {
|
|
|
163
163
|
throw error;
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
|
+
/**
|
|
167
|
+
* Moves values from source paths to destination paths.
|
|
168
|
+
*
|
|
169
|
+
* Examples:
|
|
170
|
+
* moveValueByPath(
|
|
171
|
+
* {'requests': [{'content': v1}, {'content': v2}]},
|
|
172
|
+
* {'requests[].*': 'requests[].request.*'}
|
|
173
|
+
* )
|
|
174
|
+
* -> {'requests': [{'request': {'content': v1}}, {'request': {'content': v2}}]}
|
|
175
|
+
*/
|
|
176
|
+
function moveValueByPath(data, paths) {
|
|
177
|
+
for (const [sourcePath, destPath] of Object.entries(paths)) {
|
|
178
|
+
const sourceKeys = sourcePath.split('.');
|
|
179
|
+
const destKeys = destPath.split('.');
|
|
180
|
+
// Determine keys to exclude from wildcard to avoid cyclic references
|
|
181
|
+
const excludeKeys = new Set();
|
|
182
|
+
let wildcardIdx = -1;
|
|
183
|
+
for (let i = 0; i < sourceKeys.length; i++) {
|
|
184
|
+
if (sourceKeys[i] === '*') {
|
|
185
|
+
wildcardIdx = i;
|
|
186
|
+
break;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
if (wildcardIdx !== -1 && destKeys.length > wildcardIdx) {
|
|
190
|
+
// Extract the intermediate key between source and dest paths
|
|
191
|
+
// Example: source=['requests[]', '*'], dest=['requests[]', 'request', '*']
|
|
192
|
+
// We want to exclude 'request'
|
|
193
|
+
for (let i = wildcardIdx; i < destKeys.length; i++) {
|
|
194
|
+
const key = destKeys[i];
|
|
195
|
+
if (key !== '*' && !key.endsWith('[]') && !key.endsWith('[0]')) {
|
|
196
|
+
excludeKeys.add(key);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
_moveValueRecursive(data, sourceKeys, destKeys, 0, excludeKeys);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Recursively moves values from source path to destination path.
|
|
205
|
+
*/
|
|
206
|
+
function _moveValueRecursive(data, sourceKeys, destKeys, keyIdx, excludeKeys) {
|
|
207
|
+
if (keyIdx >= sourceKeys.length) {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
if (typeof data !== 'object' || data === null) {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
const key = sourceKeys[keyIdx];
|
|
214
|
+
if (key.endsWith('[]')) {
|
|
215
|
+
const keyName = key.slice(0, -2);
|
|
216
|
+
const dataRecord = data;
|
|
217
|
+
if (keyName in dataRecord && Array.isArray(dataRecord[keyName])) {
|
|
218
|
+
for (const item of dataRecord[keyName]) {
|
|
219
|
+
_moveValueRecursive(item, sourceKeys, destKeys, keyIdx + 1, excludeKeys);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
else if (key === '*') {
|
|
224
|
+
// wildcard - move all fields
|
|
225
|
+
if (typeof data === 'object' && data !== null && !Array.isArray(data)) {
|
|
226
|
+
const dataRecord = data;
|
|
227
|
+
const keysToMove = Object.keys(dataRecord).filter((k) => !k.startsWith('_') && !excludeKeys.has(k));
|
|
228
|
+
const valuesToMove = {};
|
|
229
|
+
for (const k of keysToMove) {
|
|
230
|
+
valuesToMove[k] = dataRecord[k];
|
|
231
|
+
}
|
|
232
|
+
// Set values at destination
|
|
233
|
+
for (const [k, v] of Object.entries(valuesToMove)) {
|
|
234
|
+
const newDestKeys = [];
|
|
235
|
+
for (const dk of destKeys.slice(keyIdx)) {
|
|
236
|
+
if (dk === '*') {
|
|
237
|
+
newDestKeys.push(k);
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
newDestKeys.push(dk);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
setValueByPath(dataRecord, newDestKeys, v);
|
|
244
|
+
}
|
|
245
|
+
for (const k of keysToMove) {
|
|
246
|
+
delete dataRecord[k];
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
// Navigate to next level
|
|
252
|
+
const dataRecord = data;
|
|
253
|
+
if (key in dataRecord) {
|
|
254
|
+
_moveValueRecursive(dataRecord[key], sourceKeys, destKeys, keyIdx + 1, excludeKeys);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
166
258
|
|
|
167
259
|
/**
|
|
168
260
|
* @license
|
|
@@ -304,7 +396,7 @@ function generateVideosResponseFromVertex$1(fromObject) {
|
|
|
304
396
|
}
|
|
305
397
|
function generatedVideoFromMldev$1(fromObject) {
|
|
306
398
|
const toObject = {};
|
|
307
|
-
const fromVideo = getValueByPath(fromObject, ['
|
|
399
|
+
const fromVideo = getValueByPath(fromObject, ['video']);
|
|
308
400
|
if (fromVideo != null) {
|
|
309
401
|
setValueByPath(toObject, ['video'], videoFromMldev$1(fromVideo));
|
|
310
402
|
}
|
|
@@ -340,14 +432,11 @@ function getOperationParametersToVertex(fromObject) {
|
|
|
340
432
|
}
|
|
341
433
|
function videoFromMldev$1(fromObject) {
|
|
342
434
|
const toObject = {};
|
|
343
|
-
const fromUri = getValueByPath(fromObject, ['
|
|
435
|
+
const fromUri = getValueByPath(fromObject, ['uri']);
|
|
344
436
|
if (fromUri != null) {
|
|
345
437
|
setValueByPath(toObject, ['uri'], fromUri);
|
|
346
438
|
}
|
|
347
|
-
const fromVideoBytes = getValueByPath(fromObject, [
|
|
348
|
-
'video',
|
|
349
|
-
'encodedVideo',
|
|
350
|
-
]);
|
|
439
|
+
const fromVideoBytes = getValueByPath(fromObject, ['encodedVideo']);
|
|
351
440
|
if (fromVideoBytes != null) {
|
|
352
441
|
setValueByPath(toObject, ['videoBytes'], tBytes$1(fromVideoBytes));
|
|
353
442
|
}
|
|
@@ -3480,6 +3569,7 @@ function embedContentBatchToMldev(apiClient, fromObject) {
|
|
|
3480
3569
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
3481
3570
|
if (fromConfig != null) {
|
|
3482
3571
|
setValueByPath(toObject, ['_self'], embedContentConfigToMldev$1(fromConfig, toObject));
|
|
3572
|
+
moveValueByPath(toObject, { 'requests[].*': 'requests[].request.*' });
|
|
3483
3573
|
}
|
|
3484
3574
|
return toObject;
|
|
3485
3575
|
}
|
|
@@ -3746,6 +3836,17 @@ function getBatchJobParametersToVertex(apiClient, fromObject) {
|
|
|
3746
3836
|
}
|
|
3747
3837
|
return toObject;
|
|
3748
3838
|
}
|
|
3839
|
+
function googleMapsToMldev$4(fromObject) {
|
|
3840
|
+
const toObject = {};
|
|
3841
|
+
if (getValueByPath(fromObject, ['authConfig']) !== undefined) {
|
|
3842
|
+
throw new Error('authConfig parameter is not supported in Gemini API.');
|
|
3843
|
+
}
|
|
3844
|
+
const fromEnableWidget = getValueByPath(fromObject, ['enableWidget']);
|
|
3845
|
+
if (fromEnableWidget != null) {
|
|
3846
|
+
setValueByPath(toObject, ['enableWidget'], fromEnableWidget);
|
|
3847
|
+
}
|
|
3848
|
+
return toObject;
|
|
3849
|
+
}
|
|
3749
3850
|
function googleSearchToMldev$4(fromObject) {
|
|
3750
3851
|
const toObject = {};
|
|
3751
3852
|
const fromTimeRangeFilter = getValueByPath(fromObject, [
|
|
@@ -3775,6 +3876,10 @@ function inlinedRequestToMldev(apiClient, fromObject) {
|
|
|
3775
3876
|
}
|
|
3776
3877
|
setValueByPath(toObject, ['request', 'contents'], transformedList);
|
|
3777
3878
|
}
|
|
3879
|
+
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
3880
|
+
if (fromMetadata != null) {
|
|
3881
|
+
setValueByPath(toObject, ['metadata'], fromMetadata);
|
|
3882
|
+
}
|
|
3778
3883
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
3779
3884
|
if (fromConfig != null) {
|
|
3780
3885
|
setValueByPath(toObject, ['request', 'generationConfig'], generateContentConfigToMldev$1(apiClient, fromConfig, getValueByPath(toObject, ['request'], {})));
|
|
@@ -3993,8 +4098,9 @@ function toolToMldev$4(fromObject) {
|
|
|
3993
4098
|
if (getValueByPath(fromObject, ['enterpriseWebSearch']) !== undefined) {
|
|
3994
4099
|
throw new Error('enterpriseWebSearch parameter is not supported in Gemini API.');
|
|
3995
4100
|
}
|
|
3996
|
-
|
|
3997
|
-
|
|
4101
|
+
const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
|
|
4102
|
+
if (fromGoogleMaps != null) {
|
|
4103
|
+
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev$4(fromGoogleMaps));
|
|
3998
4104
|
}
|
|
3999
4105
|
const fromUrlContext = getValueByPath(fromObject, ['urlContext']);
|
|
4000
4106
|
if (fromUrlContext != null) {
|
|
@@ -4245,38 +4351,11 @@ class Batches extends BaseModule {
|
|
|
4245
4351
|
* ```
|
|
4246
4352
|
*/
|
|
4247
4353
|
this.createEmbeddings = async (params) => {
|
|
4248
|
-
var _a, _b;
|
|
4249
4354
|
console.warn('batches.createEmbeddings() is experimental and may change without notice.');
|
|
4250
4355
|
if (this.apiClient.isVertexAI()) {
|
|
4251
4356
|
throw new Error('Vertex AI does not support batches.createEmbeddings.');
|
|
4252
4357
|
}
|
|
4253
|
-
|
|
4254
|
-
const src = params.src;
|
|
4255
|
-
const is_inlined = src.inlinedRequests !== undefined;
|
|
4256
|
-
if (!is_inlined) {
|
|
4257
|
-
return this.createEmbeddingsInternal(params); // Fixed typo here
|
|
4258
|
-
}
|
|
4259
|
-
// Inlined embed content requests handling
|
|
4260
|
-
const result = this.createInlinedEmbedContentRequest(params);
|
|
4261
|
-
const path = result.path;
|
|
4262
|
-
const requestBody = result.body;
|
|
4263
|
-
const queryParams = createEmbeddingsBatchJobParametersToMldev(this.apiClient, params)['_query'] || {};
|
|
4264
|
-
const response = this.apiClient
|
|
4265
|
-
.request({
|
|
4266
|
-
path: path,
|
|
4267
|
-
queryParams: queryParams,
|
|
4268
|
-
body: JSON.stringify(requestBody),
|
|
4269
|
-
httpMethod: 'POST',
|
|
4270
|
-
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
4271
|
-
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
4272
|
-
})
|
|
4273
|
-
.then((httpResponse) => {
|
|
4274
|
-
return httpResponse.json();
|
|
4275
|
-
});
|
|
4276
|
-
return response.then((apiResponse) => {
|
|
4277
|
-
const resp = batchJobFromMldev(apiResponse);
|
|
4278
|
-
return resp;
|
|
4279
|
-
});
|
|
4358
|
+
return this.createEmbeddingsInternal(params);
|
|
4280
4359
|
};
|
|
4281
4360
|
/**
|
|
4282
4361
|
* Lists batch job configurations.
|
|
@@ -4324,35 +4403,6 @@ class Batches extends BaseModule {
|
|
|
4324
4403
|
delete body['_query'];
|
|
4325
4404
|
return { path, body };
|
|
4326
4405
|
}
|
|
4327
|
-
// Helper function to handle inlined embedding requests
|
|
4328
|
-
createInlinedEmbedContentRequest(params) {
|
|
4329
|
-
const body = createEmbeddingsBatchJobParametersToMldev(this.apiClient, // Use instance apiClient
|
|
4330
|
-
params);
|
|
4331
|
-
const urlParams = body['_url'];
|
|
4332
|
-
const path = formatMap('{model}:asyncBatchEmbedContent', urlParams);
|
|
4333
|
-
const batch = body['batch'];
|
|
4334
|
-
const inputConfig = batch['inputConfig'];
|
|
4335
|
-
const requestsWrapper = inputConfig['requests'];
|
|
4336
|
-
const requests = requestsWrapper['requests'];
|
|
4337
|
-
const newRequests = [];
|
|
4338
|
-
delete requestsWrapper['config']; // Remove top-level config
|
|
4339
|
-
for (const request of requests) {
|
|
4340
|
-
const requestDict = Object.assign({}, request); // Clone
|
|
4341
|
-
const innerRequest = requestDict['request'];
|
|
4342
|
-
for (const key in requestDict) {
|
|
4343
|
-
if (key !== 'request') {
|
|
4344
|
-
innerRequest[key] = requestDict[key];
|
|
4345
|
-
delete requestDict[key];
|
|
4346
|
-
}
|
|
4347
|
-
}
|
|
4348
|
-
newRequests.push(requestDict);
|
|
4349
|
-
}
|
|
4350
|
-
requestsWrapper['requests'] = newRequests;
|
|
4351
|
-
delete body['config'];
|
|
4352
|
-
delete body['_url'];
|
|
4353
|
-
delete body['_query'];
|
|
4354
|
-
return { path, body };
|
|
4355
|
-
}
|
|
4356
4406
|
// Helper function to get the first GCS URI
|
|
4357
4407
|
getGcsUri(src) {
|
|
4358
4408
|
if (typeof src === 'string') {
|
|
@@ -5017,6 +5067,17 @@ function getCachedContentParametersToVertex(apiClient, fromObject) {
|
|
|
5017
5067
|
}
|
|
5018
5068
|
return toObject;
|
|
5019
5069
|
}
|
|
5070
|
+
function googleMapsToMldev$3(fromObject) {
|
|
5071
|
+
const toObject = {};
|
|
5072
|
+
if (getValueByPath(fromObject, ['authConfig']) !== undefined) {
|
|
5073
|
+
throw new Error('authConfig parameter is not supported in Gemini API.');
|
|
5074
|
+
}
|
|
5075
|
+
const fromEnableWidget = getValueByPath(fromObject, ['enableWidget']);
|
|
5076
|
+
if (fromEnableWidget != null) {
|
|
5077
|
+
setValueByPath(toObject, ['enableWidget'], fromEnableWidget);
|
|
5078
|
+
}
|
|
5079
|
+
return toObject;
|
|
5080
|
+
}
|
|
5020
5081
|
function googleSearchToMldev$3(fromObject) {
|
|
5021
5082
|
const toObject = {};
|
|
5022
5083
|
const fromTimeRangeFilter = getValueByPath(fromObject, [
|
|
@@ -5210,8 +5271,9 @@ function toolToMldev$3(fromObject) {
|
|
|
5210
5271
|
if (getValueByPath(fromObject, ['enterpriseWebSearch']) !== undefined) {
|
|
5211
5272
|
throw new Error('enterpriseWebSearch parameter is not supported in Gemini API.');
|
|
5212
5273
|
}
|
|
5213
|
-
|
|
5214
|
-
|
|
5274
|
+
const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
|
|
5275
|
+
if (fromGoogleMaps != null) {
|
|
5276
|
+
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev$3(fromGoogleMaps));
|
|
5215
5277
|
}
|
|
5216
5278
|
const fromUrlContext = getValueByPath(fromObject, ['urlContext']);
|
|
5217
5279
|
if (fromUrlContext != null) {
|
|
@@ -6117,7 +6179,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
6117
6179
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
6118
6180
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
6119
6181
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
6120
|
-
const SDK_VERSION = '1.
|
|
6182
|
+
const SDK_VERSION = '1.25.0'; // x-release-please-version
|
|
6121
6183
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
6122
6184
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
6123
6185
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -7391,6 +7453,17 @@ function generationConfigToVertex$1(fromObject) {
|
|
|
7391
7453
|
}
|
|
7392
7454
|
return toObject;
|
|
7393
7455
|
}
|
|
7456
|
+
function googleMapsToMldev$2(fromObject) {
|
|
7457
|
+
const toObject = {};
|
|
7458
|
+
if (getValueByPath(fromObject, ['authConfig']) !== undefined) {
|
|
7459
|
+
throw new Error('authConfig parameter is not supported in Gemini API.');
|
|
7460
|
+
}
|
|
7461
|
+
const fromEnableWidget = getValueByPath(fromObject, ['enableWidget']);
|
|
7462
|
+
if (fromEnableWidget != null) {
|
|
7463
|
+
setValueByPath(toObject, ['enableWidget'], fromEnableWidget);
|
|
7464
|
+
}
|
|
7465
|
+
return toObject;
|
|
7466
|
+
}
|
|
7394
7467
|
function googleSearchToMldev$2(fromObject) {
|
|
7395
7468
|
const toObject = {};
|
|
7396
7469
|
const fromTimeRangeFilter = getValueByPath(fromObject, [
|
|
@@ -7910,8 +7983,9 @@ function toolToMldev$2(fromObject) {
|
|
|
7910
7983
|
if (getValueByPath(fromObject, ['enterpriseWebSearch']) !== undefined) {
|
|
7911
7984
|
throw new Error('enterpriseWebSearch parameter is not supported in Gemini API.');
|
|
7912
7985
|
}
|
|
7913
|
-
|
|
7914
|
-
|
|
7986
|
+
const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
|
|
7987
|
+
if (fromGoogleMaps != null) {
|
|
7988
|
+
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev$2(fromGoogleMaps));
|
|
7915
7989
|
}
|
|
7916
7990
|
const fromUrlContext = getValueByPath(fromObject, ['urlContext']);
|
|
7917
7991
|
if (fromUrlContext != null) {
|
|
@@ -9900,7 +9974,7 @@ function generatedImageMaskFromVertex(fromObject) {
|
|
|
9900
9974
|
}
|
|
9901
9975
|
function generatedVideoFromMldev(fromObject) {
|
|
9902
9976
|
const toObject = {};
|
|
9903
|
-
const fromVideo = getValueByPath(fromObject, ['
|
|
9977
|
+
const fromVideo = getValueByPath(fromObject, ['video']);
|
|
9904
9978
|
if (fromVideo != null) {
|
|
9905
9979
|
setValueByPath(toObject, ['video'], videoFromMldev(fromVideo));
|
|
9906
9980
|
}
|
|
@@ -10054,6 +10128,17 @@ function getModelParametersToVertex(apiClient, fromObject) {
|
|
|
10054
10128
|
}
|
|
10055
10129
|
return toObject;
|
|
10056
10130
|
}
|
|
10131
|
+
function googleMapsToMldev$1(fromObject) {
|
|
10132
|
+
const toObject = {};
|
|
10133
|
+
if (getValueByPath(fromObject, ['authConfig']) !== undefined) {
|
|
10134
|
+
throw new Error('authConfig parameter is not supported in Gemini API.');
|
|
10135
|
+
}
|
|
10136
|
+
const fromEnableWidget = getValueByPath(fromObject, ['enableWidget']);
|
|
10137
|
+
if (fromEnableWidget != null) {
|
|
10138
|
+
setValueByPath(toObject, ['enableWidget'], fromEnableWidget);
|
|
10139
|
+
}
|
|
10140
|
+
return toObject;
|
|
10141
|
+
}
|
|
10057
10142
|
function googleSearchToMldev$1(fromObject) {
|
|
10058
10143
|
const toObject = {};
|
|
10059
10144
|
const fromTimeRangeFilter = getValueByPath(fromObject, [
|
|
@@ -10768,8 +10853,9 @@ function toolToMldev$1(fromObject) {
|
|
|
10768
10853
|
if (getValueByPath(fromObject, ['enterpriseWebSearch']) !== undefined) {
|
|
10769
10854
|
throw new Error('enterpriseWebSearch parameter is not supported in Gemini API.');
|
|
10770
10855
|
}
|
|
10771
|
-
|
|
10772
|
-
|
|
10856
|
+
const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
|
|
10857
|
+
if (fromGoogleMaps != null) {
|
|
10858
|
+
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev$1(fromGoogleMaps));
|
|
10773
10859
|
}
|
|
10774
10860
|
const fromUrlContext = getValueByPath(fromObject, ['urlContext']);
|
|
10775
10861
|
if (fromUrlContext != null) {
|
|
@@ -11034,14 +11120,11 @@ function upscaleImageResponseFromVertex(fromObject) {
|
|
|
11034
11120
|
}
|
|
11035
11121
|
function videoFromMldev(fromObject) {
|
|
11036
11122
|
const toObject = {};
|
|
11037
|
-
const fromUri = getValueByPath(fromObject, ['
|
|
11123
|
+
const fromUri = getValueByPath(fromObject, ['uri']);
|
|
11038
11124
|
if (fromUri != null) {
|
|
11039
11125
|
setValueByPath(toObject, ['uri'], fromUri);
|
|
11040
11126
|
}
|
|
11041
|
-
const fromVideoBytes = getValueByPath(fromObject, [
|
|
11042
|
-
'video',
|
|
11043
|
-
'encodedVideo',
|
|
11044
|
-
]);
|
|
11127
|
+
const fromVideoBytes = getValueByPath(fromObject, ['encodedVideo']);
|
|
11045
11128
|
if (fromVideoBytes != null) {
|
|
11046
11129
|
setValueByPath(toObject, ['videoBytes'], tBytes(fromVideoBytes));
|
|
11047
11130
|
}
|
|
@@ -11113,11 +11196,11 @@ function videoToMldev(fromObject) {
|
|
|
11113
11196
|
const toObject = {};
|
|
11114
11197
|
const fromUri = getValueByPath(fromObject, ['uri']);
|
|
11115
11198
|
if (fromUri != null) {
|
|
11116
|
-
setValueByPath(toObject, ['
|
|
11199
|
+
setValueByPath(toObject, ['uri'], fromUri);
|
|
11117
11200
|
}
|
|
11118
11201
|
const fromVideoBytes = getValueByPath(fromObject, ['videoBytes']);
|
|
11119
11202
|
if (fromVideoBytes != null) {
|
|
11120
|
-
setValueByPath(toObject, ['
|
|
11203
|
+
setValueByPath(toObject, ['encodedVideo'], tBytes(fromVideoBytes));
|
|
11121
11204
|
}
|
|
11122
11205
|
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
11123
11206
|
if (fromMimeType != null) {
|
|
@@ -12355,9 +12438,26 @@ class Models extends BaseModule {
|
|
|
12355
12438
|
* ```
|
|
12356
12439
|
*/
|
|
12357
12440
|
this.generateVideos = async (params) => {
|
|
12441
|
+
var _a, _b, _c, _d, _e, _f;
|
|
12358
12442
|
if ((params.prompt || params.image || params.video) && params.source) {
|
|
12359
12443
|
throw new Error('Source and prompt/image/video are mutually exclusive. Please only use source.');
|
|
12360
12444
|
}
|
|
12445
|
+
// Gemini API does not support video bytes.
|
|
12446
|
+
if (!this.apiClient.isVertexAI()) {
|
|
12447
|
+
if (((_a = params.video) === null || _a === void 0 ? void 0 : _a.uri) && ((_b = params.video) === null || _b === void 0 ? void 0 : _b.videoBytes)) {
|
|
12448
|
+
params.video = {
|
|
12449
|
+
uri: params.video.uri,
|
|
12450
|
+
mimeType: params.video.mimeType,
|
|
12451
|
+
};
|
|
12452
|
+
}
|
|
12453
|
+
else if (((_d = (_c = params.source) === null || _c === void 0 ? void 0 : _c.video) === null || _d === void 0 ? void 0 : _d.uri) &&
|
|
12454
|
+
((_f = (_e = params.source) === null || _e === void 0 ? void 0 : _e.video) === null || _f === void 0 ? void 0 : _f.videoBytes)) {
|
|
12455
|
+
params.source.video = {
|
|
12456
|
+
uri: params.source.video.uri,
|
|
12457
|
+
mimeType: params.source.video.mimeType,
|
|
12458
|
+
};
|
|
12459
|
+
}
|
|
12460
|
+
}
|
|
12361
12461
|
return await this.generateVideosInternal(params);
|
|
12362
12462
|
};
|
|
12363
12463
|
}
|
|
@@ -13783,6 +13883,17 @@ function fileDataToMldev(fromObject) {
|
|
|
13783
13883
|
}
|
|
13784
13884
|
return toObject;
|
|
13785
13885
|
}
|
|
13886
|
+
function googleMapsToMldev(fromObject) {
|
|
13887
|
+
const toObject = {};
|
|
13888
|
+
if (getValueByPath(fromObject, ['authConfig']) !== undefined) {
|
|
13889
|
+
throw new Error('authConfig parameter is not supported in Gemini API.');
|
|
13890
|
+
}
|
|
13891
|
+
const fromEnableWidget = getValueByPath(fromObject, ['enableWidget']);
|
|
13892
|
+
if (fromEnableWidget != null) {
|
|
13893
|
+
setValueByPath(toObject, ['enableWidget'], fromEnableWidget);
|
|
13894
|
+
}
|
|
13895
|
+
return toObject;
|
|
13896
|
+
}
|
|
13786
13897
|
function googleSearchToMldev(fromObject) {
|
|
13787
13898
|
const toObject = {};
|
|
13788
13899
|
const fromTimeRangeFilter = getValueByPath(fromObject, [
|
|
@@ -14013,8 +14124,9 @@ function toolToMldev(fromObject) {
|
|
|
14013
14124
|
if (getValueByPath(fromObject, ['enterpriseWebSearch']) !== undefined) {
|
|
14014
14125
|
throw new Error('enterpriseWebSearch parameter is not supported in Gemini API.');
|
|
14015
14126
|
}
|
|
14016
|
-
|
|
14017
|
-
|
|
14127
|
+
const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
|
|
14128
|
+
if (fromGoogleMaps != null) {
|
|
14129
|
+
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev(fromGoogleMaps));
|
|
14018
14130
|
}
|
|
14019
14131
|
const fromUrlContext = getValueByPath(fromObject, ['urlContext']);
|
|
14020
14132
|
if (fromUrlContext != null) {
|