@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/node/index.mjs
CHANGED
|
@@ -199,6 +199,98 @@ function getValueByPath(data, keys, defaultValue = undefined) {
|
|
|
199
199
|
throw error;
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
|
+
/**
|
|
203
|
+
* Moves values from source paths to destination paths.
|
|
204
|
+
*
|
|
205
|
+
* Examples:
|
|
206
|
+
* moveValueByPath(
|
|
207
|
+
* {'requests': [{'content': v1}, {'content': v2}]},
|
|
208
|
+
* {'requests[].*': 'requests[].request.*'}
|
|
209
|
+
* )
|
|
210
|
+
* -> {'requests': [{'request': {'content': v1}}, {'request': {'content': v2}}]}
|
|
211
|
+
*/
|
|
212
|
+
function moveValueByPath(data, paths) {
|
|
213
|
+
for (const [sourcePath, destPath] of Object.entries(paths)) {
|
|
214
|
+
const sourceKeys = sourcePath.split('.');
|
|
215
|
+
const destKeys = destPath.split('.');
|
|
216
|
+
// Determine keys to exclude from wildcard to avoid cyclic references
|
|
217
|
+
const excludeKeys = new Set();
|
|
218
|
+
let wildcardIdx = -1;
|
|
219
|
+
for (let i = 0; i < sourceKeys.length; i++) {
|
|
220
|
+
if (sourceKeys[i] === '*') {
|
|
221
|
+
wildcardIdx = i;
|
|
222
|
+
break;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
if (wildcardIdx !== -1 && destKeys.length > wildcardIdx) {
|
|
226
|
+
// Extract the intermediate key between source and dest paths
|
|
227
|
+
// Example: source=['requests[]', '*'], dest=['requests[]', 'request', '*']
|
|
228
|
+
// We want to exclude 'request'
|
|
229
|
+
for (let i = wildcardIdx; i < destKeys.length; i++) {
|
|
230
|
+
const key = destKeys[i];
|
|
231
|
+
if (key !== '*' && !key.endsWith('[]') && !key.endsWith('[0]')) {
|
|
232
|
+
excludeKeys.add(key);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
_moveValueRecursive(data, sourceKeys, destKeys, 0, excludeKeys);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Recursively moves values from source path to destination path.
|
|
241
|
+
*/
|
|
242
|
+
function _moveValueRecursive(data, sourceKeys, destKeys, keyIdx, excludeKeys) {
|
|
243
|
+
if (keyIdx >= sourceKeys.length) {
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
if (typeof data !== 'object' || data === null) {
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
const key = sourceKeys[keyIdx];
|
|
250
|
+
if (key.endsWith('[]')) {
|
|
251
|
+
const keyName = key.slice(0, -2);
|
|
252
|
+
const dataRecord = data;
|
|
253
|
+
if (keyName in dataRecord && Array.isArray(dataRecord[keyName])) {
|
|
254
|
+
for (const item of dataRecord[keyName]) {
|
|
255
|
+
_moveValueRecursive(item, sourceKeys, destKeys, keyIdx + 1, excludeKeys);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
else if (key === '*') {
|
|
260
|
+
// wildcard - move all fields
|
|
261
|
+
if (typeof data === 'object' && data !== null && !Array.isArray(data)) {
|
|
262
|
+
const dataRecord = data;
|
|
263
|
+
const keysToMove = Object.keys(dataRecord).filter((k) => !k.startsWith('_') && !excludeKeys.has(k));
|
|
264
|
+
const valuesToMove = {};
|
|
265
|
+
for (const k of keysToMove) {
|
|
266
|
+
valuesToMove[k] = dataRecord[k];
|
|
267
|
+
}
|
|
268
|
+
// Set values at destination
|
|
269
|
+
for (const [k, v] of Object.entries(valuesToMove)) {
|
|
270
|
+
const newDestKeys = [];
|
|
271
|
+
for (const dk of destKeys.slice(keyIdx)) {
|
|
272
|
+
if (dk === '*') {
|
|
273
|
+
newDestKeys.push(k);
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
newDestKeys.push(dk);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
setValueByPath(dataRecord, newDestKeys, v);
|
|
280
|
+
}
|
|
281
|
+
for (const k of keysToMove) {
|
|
282
|
+
delete dataRecord[k];
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
// Navigate to next level
|
|
288
|
+
const dataRecord = data;
|
|
289
|
+
if (key in dataRecord) {
|
|
290
|
+
_moveValueRecursive(dataRecord[key], sourceKeys, destKeys, keyIdx + 1, excludeKeys);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
202
294
|
|
|
203
295
|
/**
|
|
204
296
|
* @license
|
|
@@ -340,7 +432,7 @@ function generateVideosResponseFromVertex$1(fromObject) {
|
|
|
340
432
|
}
|
|
341
433
|
function generatedVideoFromMldev$1(fromObject) {
|
|
342
434
|
const toObject = {};
|
|
343
|
-
const fromVideo = getValueByPath(fromObject, ['
|
|
435
|
+
const fromVideo = getValueByPath(fromObject, ['video']);
|
|
344
436
|
if (fromVideo != null) {
|
|
345
437
|
setValueByPath(toObject, ['video'], videoFromMldev$1(fromVideo));
|
|
346
438
|
}
|
|
@@ -376,14 +468,11 @@ function getOperationParametersToVertex(fromObject) {
|
|
|
376
468
|
}
|
|
377
469
|
function videoFromMldev$1(fromObject) {
|
|
378
470
|
const toObject = {};
|
|
379
|
-
const fromUri = getValueByPath(fromObject, ['
|
|
471
|
+
const fromUri = getValueByPath(fromObject, ['uri']);
|
|
380
472
|
if (fromUri != null) {
|
|
381
473
|
setValueByPath(toObject, ['uri'], fromUri);
|
|
382
474
|
}
|
|
383
|
-
const fromVideoBytes = getValueByPath(fromObject, [
|
|
384
|
-
'video',
|
|
385
|
-
'encodedVideo',
|
|
386
|
-
]);
|
|
475
|
+
const fromVideoBytes = getValueByPath(fromObject, ['encodedVideo']);
|
|
387
476
|
if (fromVideoBytes != null) {
|
|
388
477
|
setValueByPath(toObject, ['videoBytes'], tBytes$1(fromVideoBytes));
|
|
389
478
|
}
|
|
@@ -3516,6 +3605,7 @@ function embedContentBatchToMldev(apiClient, fromObject) {
|
|
|
3516
3605
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
3517
3606
|
if (fromConfig != null) {
|
|
3518
3607
|
setValueByPath(toObject, ['_self'], embedContentConfigToMldev$1(fromConfig, toObject));
|
|
3608
|
+
moveValueByPath(toObject, { 'requests[].*': 'requests[].request.*' });
|
|
3519
3609
|
}
|
|
3520
3610
|
return toObject;
|
|
3521
3611
|
}
|
|
@@ -3782,6 +3872,17 @@ function getBatchJobParametersToVertex(apiClient, fromObject) {
|
|
|
3782
3872
|
}
|
|
3783
3873
|
return toObject;
|
|
3784
3874
|
}
|
|
3875
|
+
function googleMapsToMldev$4(fromObject) {
|
|
3876
|
+
const toObject = {};
|
|
3877
|
+
if (getValueByPath(fromObject, ['authConfig']) !== undefined) {
|
|
3878
|
+
throw new Error('authConfig parameter is not supported in Gemini API.');
|
|
3879
|
+
}
|
|
3880
|
+
const fromEnableWidget = getValueByPath(fromObject, ['enableWidget']);
|
|
3881
|
+
if (fromEnableWidget != null) {
|
|
3882
|
+
setValueByPath(toObject, ['enableWidget'], fromEnableWidget);
|
|
3883
|
+
}
|
|
3884
|
+
return toObject;
|
|
3885
|
+
}
|
|
3785
3886
|
function googleSearchToMldev$4(fromObject) {
|
|
3786
3887
|
const toObject = {};
|
|
3787
3888
|
const fromTimeRangeFilter = getValueByPath(fromObject, [
|
|
@@ -3811,6 +3912,10 @@ function inlinedRequestToMldev(apiClient, fromObject) {
|
|
|
3811
3912
|
}
|
|
3812
3913
|
setValueByPath(toObject, ['request', 'contents'], transformedList);
|
|
3813
3914
|
}
|
|
3915
|
+
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
3916
|
+
if (fromMetadata != null) {
|
|
3917
|
+
setValueByPath(toObject, ['metadata'], fromMetadata);
|
|
3918
|
+
}
|
|
3814
3919
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
3815
3920
|
if (fromConfig != null) {
|
|
3816
3921
|
setValueByPath(toObject, ['request', 'generationConfig'], generateContentConfigToMldev$1(apiClient, fromConfig, getValueByPath(toObject, ['request'], {})));
|
|
@@ -4029,8 +4134,9 @@ function toolToMldev$4(fromObject) {
|
|
|
4029
4134
|
if (getValueByPath(fromObject, ['enterpriseWebSearch']) !== undefined) {
|
|
4030
4135
|
throw new Error('enterpriseWebSearch parameter is not supported in Gemini API.');
|
|
4031
4136
|
}
|
|
4032
|
-
|
|
4033
|
-
|
|
4137
|
+
const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
|
|
4138
|
+
if (fromGoogleMaps != null) {
|
|
4139
|
+
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev$4(fromGoogleMaps));
|
|
4034
4140
|
}
|
|
4035
4141
|
const fromUrlContext = getValueByPath(fromObject, ['urlContext']);
|
|
4036
4142
|
if (fromUrlContext != null) {
|
|
@@ -4281,38 +4387,11 @@ class Batches extends BaseModule {
|
|
|
4281
4387
|
* ```
|
|
4282
4388
|
*/
|
|
4283
4389
|
this.createEmbeddings = async (params) => {
|
|
4284
|
-
var _a, _b;
|
|
4285
4390
|
console.warn('batches.createEmbeddings() is experimental and may change without notice.');
|
|
4286
4391
|
if (this.apiClient.isVertexAI()) {
|
|
4287
4392
|
throw new Error('Vertex AI does not support batches.createEmbeddings.');
|
|
4288
4393
|
}
|
|
4289
|
-
|
|
4290
|
-
const src = params.src;
|
|
4291
|
-
const is_inlined = src.inlinedRequests !== undefined;
|
|
4292
|
-
if (!is_inlined) {
|
|
4293
|
-
return this.createEmbeddingsInternal(params); // Fixed typo here
|
|
4294
|
-
}
|
|
4295
|
-
// Inlined embed content requests handling
|
|
4296
|
-
const result = this.createInlinedEmbedContentRequest(params);
|
|
4297
|
-
const path = result.path;
|
|
4298
|
-
const requestBody = result.body;
|
|
4299
|
-
const queryParams = createEmbeddingsBatchJobParametersToMldev(this.apiClient, params)['_query'] || {};
|
|
4300
|
-
const response = this.apiClient
|
|
4301
|
-
.request({
|
|
4302
|
-
path: path,
|
|
4303
|
-
queryParams: queryParams,
|
|
4304
|
-
body: JSON.stringify(requestBody),
|
|
4305
|
-
httpMethod: 'POST',
|
|
4306
|
-
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
4307
|
-
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
4308
|
-
})
|
|
4309
|
-
.then((httpResponse) => {
|
|
4310
|
-
return httpResponse.json();
|
|
4311
|
-
});
|
|
4312
|
-
return response.then((apiResponse) => {
|
|
4313
|
-
const resp = batchJobFromMldev(apiResponse);
|
|
4314
|
-
return resp;
|
|
4315
|
-
});
|
|
4394
|
+
return this.createEmbeddingsInternal(params);
|
|
4316
4395
|
};
|
|
4317
4396
|
/**
|
|
4318
4397
|
* Lists batch job configurations.
|
|
@@ -4360,35 +4439,6 @@ class Batches extends BaseModule {
|
|
|
4360
4439
|
delete body['_query'];
|
|
4361
4440
|
return { path, body };
|
|
4362
4441
|
}
|
|
4363
|
-
// Helper function to handle inlined embedding requests
|
|
4364
|
-
createInlinedEmbedContentRequest(params) {
|
|
4365
|
-
const body = createEmbeddingsBatchJobParametersToMldev(this.apiClient, // Use instance apiClient
|
|
4366
|
-
params);
|
|
4367
|
-
const urlParams = body['_url'];
|
|
4368
|
-
const path = formatMap('{model}:asyncBatchEmbedContent', urlParams);
|
|
4369
|
-
const batch = body['batch'];
|
|
4370
|
-
const inputConfig = batch['inputConfig'];
|
|
4371
|
-
const requestsWrapper = inputConfig['requests'];
|
|
4372
|
-
const requests = requestsWrapper['requests'];
|
|
4373
|
-
const newRequests = [];
|
|
4374
|
-
delete requestsWrapper['config']; // Remove top-level config
|
|
4375
|
-
for (const request of requests) {
|
|
4376
|
-
const requestDict = Object.assign({}, request); // Clone
|
|
4377
|
-
const innerRequest = requestDict['request'];
|
|
4378
|
-
for (const key in requestDict) {
|
|
4379
|
-
if (key !== 'request') {
|
|
4380
|
-
innerRequest[key] = requestDict[key];
|
|
4381
|
-
delete requestDict[key];
|
|
4382
|
-
}
|
|
4383
|
-
}
|
|
4384
|
-
newRequests.push(requestDict);
|
|
4385
|
-
}
|
|
4386
|
-
requestsWrapper['requests'] = newRequests;
|
|
4387
|
-
delete body['config'];
|
|
4388
|
-
delete body['_url'];
|
|
4389
|
-
delete body['_query'];
|
|
4390
|
-
return { path, body };
|
|
4391
|
-
}
|
|
4392
4442
|
// Helper function to get the first GCS URI
|
|
4393
4443
|
getGcsUri(src) {
|
|
4394
4444
|
if (typeof src === 'string') {
|
|
@@ -5053,6 +5103,17 @@ function getCachedContentParametersToVertex(apiClient, fromObject) {
|
|
|
5053
5103
|
}
|
|
5054
5104
|
return toObject;
|
|
5055
5105
|
}
|
|
5106
|
+
function googleMapsToMldev$3(fromObject) {
|
|
5107
|
+
const toObject = {};
|
|
5108
|
+
if (getValueByPath(fromObject, ['authConfig']) !== undefined) {
|
|
5109
|
+
throw new Error('authConfig parameter is not supported in Gemini API.');
|
|
5110
|
+
}
|
|
5111
|
+
const fromEnableWidget = getValueByPath(fromObject, ['enableWidget']);
|
|
5112
|
+
if (fromEnableWidget != null) {
|
|
5113
|
+
setValueByPath(toObject, ['enableWidget'], fromEnableWidget);
|
|
5114
|
+
}
|
|
5115
|
+
return toObject;
|
|
5116
|
+
}
|
|
5056
5117
|
function googleSearchToMldev$3(fromObject) {
|
|
5057
5118
|
const toObject = {};
|
|
5058
5119
|
const fromTimeRangeFilter = getValueByPath(fromObject, [
|
|
@@ -5246,8 +5307,9 @@ function toolToMldev$3(fromObject) {
|
|
|
5246
5307
|
if (getValueByPath(fromObject, ['enterpriseWebSearch']) !== undefined) {
|
|
5247
5308
|
throw new Error('enterpriseWebSearch parameter is not supported in Gemini API.');
|
|
5248
5309
|
}
|
|
5249
|
-
|
|
5250
|
-
|
|
5310
|
+
const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
|
|
5311
|
+
if (fromGoogleMaps != null) {
|
|
5312
|
+
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev$3(fromGoogleMaps));
|
|
5251
5313
|
}
|
|
5252
5314
|
const fromUrlContext = getValueByPath(fromObject, ['urlContext']);
|
|
5253
5315
|
if (fromUrlContext != null) {
|
|
@@ -6730,6 +6792,17 @@ function generationConfigToVertex$1(fromObject) {
|
|
|
6730
6792
|
}
|
|
6731
6793
|
return toObject;
|
|
6732
6794
|
}
|
|
6795
|
+
function googleMapsToMldev$2(fromObject) {
|
|
6796
|
+
const toObject = {};
|
|
6797
|
+
if (getValueByPath(fromObject, ['authConfig']) !== undefined) {
|
|
6798
|
+
throw new Error('authConfig parameter is not supported in Gemini API.');
|
|
6799
|
+
}
|
|
6800
|
+
const fromEnableWidget = getValueByPath(fromObject, ['enableWidget']);
|
|
6801
|
+
if (fromEnableWidget != null) {
|
|
6802
|
+
setValueByPath(toObject, ['enableWidget'], fromEnableWidget);
|
|
6803
|
+
}
|
|
6804
|
+
return toObject;
|
|
6805
|
+
}
|
|
6733
6806
|
function googleSearchToMldev$2(fromObject) {
|
|
6734
6807
|
const toObject = {};
|
|
6735
6808
|
const fromTimeRangeFilter = getValueByPath(fromObject, [
|
|
@@ -7249,8 +7322,9 @@ function toolToMldev$2(fromObject) {
|
|
|
7249
7322
|
if (getValueByPath(fromObject, ['enterpriseWebSearch']) !== undefined) {
|
|
7250
7323
|
throw new Error('enterpriseWebSearch parameter is not supported in Gemini API.');
|
|
7251
7324
|
}
|
|
7252
|
-
|
|
7253
|
-
|
|
7325
|
+
const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
|
|
7326
|
+
if (fromGoogleMaps != null) {
|
|
7327
|
+
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev$2(fromGoogleMaps));
|
|
7254
7328
|
}
|
|
7255
7329
|
const fromUrlContext = getValueByPath(fromObject, ['urlContext']);
|
|
7256
7330
|
if (fromUrlContext != null) {
|
|
@@ -9239,7 +9313,7 @@ function generatedImageMaskFromVertex(fromObject) {
|
|
|
9239
9313
|
}
|
|
9240
9314
|
function generatedVideoFromMldev(fromObject) {
|
|
9241
9315
|
const toObject = {};
|
|
9242
|
-
const fromVideo = getValueByPath(fromObject, ['
|
|
9316
|
+
const fromVideo = getValueByPath(fromObject, ['video']);
|
|
9243
9317
|
if (fromVideo != null) {
|
|
9244
9318
|
setValueByPath(toObject, ['video'], videoFromMldev(fromVideo));
|
|
9245
9319
|
}
|
|
@@ -9393,6 +9467,17 @@ function getModelParametersToVertex(apiClient, fromObject) {
|
|
|
9393
9467
|
}
|
|
9394
9468
|
return toObject;
|
|
9395
9469
|
}
|
|
9470
|
+
function googleMapsToMldev$1(fromObject) {
|
|
9471
|
+
const toObject = {};
|
|
9472
|
+
if (getValueByPath(fromObject, ['authConfig']) !== undefined) {
|
|
9473
|
+
throw new Error('authConfig parameter is not supported in Gemini API.');
|
|
9474
|
+
}
|
|
9475
|
+
const fromEnableWidget = getValueByPath(fromObject, ['enableWidget']);
|
|
9476
|
+
if (fromEnableWidget != null) {
|
|
9477
|
+
setValueByPath(toObject, ['enableWidget'], fromEnableWidget);
|
|
9478
|
+
}
|
|
9479
|
+
return toObject;
|
|
9480
|
+
}
|
|
9396
9481
|
function googleSearchToMldev$1(fromObject) {
|
|
9397
9482
|
const toObject = {};
|
|
9398
9483
|
const fromTimeRangeFilter = getValueByPath(fromObject, [
|
|
@@ -10107,8 +10192,9 @@ function toolToMldev$1(fromObject) {
|
|
|
10107
10192
|
if (getValueByPath(fromObject, ['enterpriseWebSearch']) !== undefined) {
|
|
10108
10193
|
throw new Error('enterpriseWebSearch parameter is not supported in Gemini API.');
|
|
10109
10194
|
}
|
|
10110
|
-
|
|
10111
|
-
|
|
10195
|
+
const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
|
|
10196
|
+
if (fromGoogleMaps != null) {
|
|
10197
|
+
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev$1(fromGoogleMaps));
|
|
10112
10198
|
}
|
|
10113
10199
|
const fromUrlContext = getValueByPath(fromObject, ['urlContext']);
|
|
10114
10200
|
if (fromUrlContext != null) {
|
|
@@ -10373,14 +10459,11 @@ function upscaleImageResponseFromVertex(fromObject) {
|
|
|
10373
10459
|
}
|
|
10374
10460
|
function videoFromMldev(fromObject) {
|
|
10375
10461
|
const toObject = {};
|
|
10376
|
-
const fromUri = getValueByPath(fromObject, ['
|
|
10462
|
+
const fromUri = getValueByPath(fromObject, ['uri']);
|
|
10377
10463
|
if (fromUri != null) {
|
|
10378
10464
|
setValueByPath(toObject, ['uri'], fromUri);
|
|
10379
10465
|
}
|
|
10380
|
-
const fromVideoBytes = getValueByPath(fromObject, [
|
|
10381
|
-
'video',
|
|
10382
|
-
'encodedVideo',
|
|
10383
|
-
]);
|
|
10466
|
+
const fromVideoBytes = getValueByPath(fromObject, ['encodedVideo']);
|
|
10384
10467
|
if (fromVideoBytes != null) {
|
|
10385
10468
|
setValueByPath(toObject, ['videoBytes'], tBytes(fromVideoBytes));
|
|
10386
10469
|
}
|
|
@@ -10452,11 +10535,11 @@ function videoToMldev(fromObject) {
|
|
|
10452
10535
|
const toObject = {};
|
|
10453
10536
|
const fromUri = getValueByPath(fromObject, ['uri']);
|
|
10454
10537
|
if (fromUri != null) {
|
|
10455
|
-
setValueByPath(toObject, ['
|
|
10538
|
+
setValueByPath(toObject, ['uri'], fromUri);
|
|
10456
10539
|
}
|
|
10457
10540
|
const fromVideoBytes = getValueByPath(fromObject, ['videoBytes']);
|
|
10458
10541
|
if (fromVideoBytes != null) {
|
|
10459
|
-
setValueByPath(toObject, ['
|
|
10542
|
+
setValueByPath(toObject, ['encodedVideo'], tBytes(fromVideoBytes));
|
|
10460
10543
|
}
|
|
10461
10544
|
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
10462
10545
|
if (fromMimeType != null) {
|
|
@@ -10490,7 +10573,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
10490
10573
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
10491
10574
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
10492
10575
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
10493
|
-
const SDK_VERSION = '1.
|
|
10576
|
+
const SDK_VERSION = '1.25.0'; // x-release-please-version
|
|
10494
10577
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
10495
10578
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
10496
10579
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -12268,9 +12351,26 @@ class Models extends BaseModule {
|
|
|
12268
12351
|
* ```
|
|
12269
12352
|
*/
|
|
12270
12353
|
this.generateVideos = async (params) => {
|
|
12354
|
+
var _a, _b, _c, _d, _e, _f;
|
|
12271
12355
|
if ((params.prompt || params.image || params.video) && params.source) {
|
|
12272
12356
|
throw new Error('Source and prompt/image/video are mutually exclusive. Please only use source.');
|
|
12273
12357
|
}
|
|
12358
|
+
// Gemini API does not support video bytes.
|
|
12359
|
+
if (!this.apiClient.isVertexAI()) {
|
|
12360
|
+
if (((_a = params.video) === null || _a === void 0 ? void 0 : _a.uri) && ((_b = params.video) === null || _b === void 0 ? void 0 : _b.videoBytes)) {
|
|
12361
|
+
params.video = {
|
|
12362
|
+
uri: params.video.uri,
|
|
12363
|
+
mimeType: params.video.mimeType,
|
|
12364
|
+
};
|
|
12365
|
+
}
|
|
12366
|
+
else if (((_d = (_c = params.source) === null || _c === void 0 ? void 0 : _c.video) === null || _d === void 0 ? void 0 : _d.uri) &&
|
|
12367
|
+
((_f = (_e = params.source) === null || _e === void 0 ? void 0 : _e.video) === null || _f === void 0 ? void 0 : _f.videoBytes)) {
|
|
12368
|
+
params.source.video = {
|
|
12369
|
+
uri: params.source.video.uri,
|
|
12370
|
+
mimeType: params.source.video.mimeType,
|
|
12371
|
+
};
|
|
12372
|
+
}
|
|
12373
|
+
}
|
|
12274
12374
|
return await this.generateVideosInternal(params);
|
|
12275
12375
|
};
|
|
12276
12376
|
}
|
|
@@ -13696,6 +13796,17 @@ function fileDataToMldev(fromObject) {
|
|
|
13696
13796
|
}
|
|
13697
13797
|
return toObject;
|
|
13698
13798
|
}
|
|
13799
|
+
function googleMapsToMldev(fromObject) {
|
|
13800
|
+
const toObject = {};
|
|
13801
|
+
if (getValueByPath(fromObject, ['authConfig']) !== undefined) {
|
|
13802
|
+
throw new Error('authConfig parameter is not supported in Gemini API.');
|
|
13803
|
+
}
|
|
13804
|
+
const fromEnableWidget = getValueByPath(fromObject, ['enableWidget']);
|
|
13805
|
+
if (fromEnableWidget != null) {
|
|
13806
|
+
setValueByPath(toObject, ['enableWidget'], fromEnableWidget);
|
|
13807
|
+
}
|
|
13808
|
+
return toObject;
|
|
13809
|
+
}
|
|
13699
13810
|
function googleSearchToMldev(fromObject) {
|
|
13700
13811
|
const toObject = {};
|
|
13701
13812
|
const fromTimeRangeFilter = getValueByPath(fromObject, [
|
|
@@ -13926,8 +14037,9 @@ function toolToMldev(fromObject) {
|
|
|
13926
14037
|
if (getValueByPath(fromObject, ['enterpriseWebSearch']) !== undefined) {
|
|
13927
14038
|
throw new Error('enterpriseWebSearch parameter is not supported in Gemini API.');
|
|
13928
14039
|
}
|
|
13929
|
-
|
|
13930
|
-
|
|
14040
|
+
const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
|
|
14041
|
+
if (fromGoogleMaps != null) {
|
|
14042
|
+
setValueByPath(toObject, ['googleMaps'], googleMapsToMldev(fromGoogleMaps));
|
|
13931
14043
|
}
|
|
13932
14044
|
const fromUrlContext = getValueByPath(fromObject, ['urlContext']);
|
|
13933
14045
|
if (fromUrlContext != null) {
|