@google/genai 1.24.0 → 1.26.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 +61 -40
- package/dist/index.cjs +176 -148
- package/dist/index.mjs +176 -148
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.cjs +178 -150
- package/dist/node/index.mjs +178 -150
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/node.d.ts +61 -40
- package/dist/web/index.mjs +176 -148
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +61 -40
- package/package.json +8 -3
package/dist/node/index.cjs
CHANGED
|
@@ -221,6 +221,98 @@ function getValueByPath(data, keys, defaultValue = undefined) {
|
|
|
221
221
|
throw error;
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
|
+
/**
|
|
225
|
+
* Moves values from source paths to destination paths.
|
|
226
|
+
*
|
|
227
|
+
* Examples:
|
|
228
|
+
* moveValueByPath(
|
|
229
|
+
* {'requests': [{'content': v1}, {'content': v2}]},
|
|
230
|
+
* {'requests[].*': 'requests[].request.*'}
|
|
231
|
+
* )
|
|
232
|
+
* -> {'requests': [{'request': {'content': v1}}, {'request': {'content': v2}}]}
|
|
233
|
+
*/
|
|
234
|
+
function moveValueByPath(data, paths) {
|
|
235
|
+
for (const [sourcePath, destPath] of Object.entries(paths)) {
|
|
236
|
+
const sourceKeys = sourcePath.split('.');
|
|
237
|
+
const destKeys = destPath.split('.');
|
|
238
|
+
// Determine keys to exclude from wildcard to avoid cyclic references
|
|
239
|
+
const excludeKeys = new Set();
|
|
240
|
+
let wildcardIdx = -1;
|
|
241
|
+
for (let i = 0; i < sourceKeys.length; i++) {
|
|
242
|
+
if (sourceKeys[i] === '*') {
|
|
243
|
+
wildcardIdx = i;
|
|
244
|
+
break;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
if (wildcardIdx !== -1 && destKeys.length > wildcardIdx) {
|
|
248
|
+
// Extract the intermediate key between source and dest paths
|
|
249
|
+
// Example: source=['requests[]', '*'], dest=['requests[]', 'request', '*']
|
|
250
|
+
// We want to exclude 'request'
|
|
251
|
+
for (let i = wildcardIdx; i < destKeys.length; i++) {
|
|
252
|
+
const key = destKeys[i];
|
|
253
|
+
if (key !== '*' && !key.endsWith('[]') && !key.endsWith('[0]')) {
|
|
254
|
+
excludeKeys.add(key);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
_moveValueRecursive(data, sourceKeys, destKeys, 0, excludeKeys);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Recursively moves values from source path to destination path.
|
|
263
|
+
*/
|
|
264
|
+
function _moveValueRecursive(data, sourceKeys, destKeys, keyIdx, excludeKeys) {
|
|
265
|
+
if (keyIdx >= sourceKeys.length) {
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
if (typeof data !== 'object' || data === null) {
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
const key = sourceKeys[keyIdx];
|
|
272
|
+
if (key.endsWith('[]')) {
|
|
273
|
+
const keyName = key.slice(0, -2);
|
|
274
|
+
const dataRecord = data;
|
|
275
|
+
if (keyName in dataRecord && Array.isArray(dataRecord[keyName])) {
|
|
276
|
+
for (const item of dataRecord[keyName]) {
|
|
277
|
+
_moveValueRecursive(item, sourceKeys, destKeys, keyIdx + 1, excludeKeys);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
else if (key === '*') {
|
|
282
|
+
// wildcard - move all fields
|
|
283
|
+
if (typeof data === 'object' && data !== null && !Array.isArray(data)) {
|
|
284
|
+
const dataRecord = data;
|
|
285
|
+
const keysToMove = Object.keys(dataRecord).filter((k) => !k.startsWith('_') && !excludeKeys.has(k));
|
|
286
|
+
const valuesToMove = {};
|
|
287
|
+
for (const k of keysToMove) {
|
|
288
|
+
valuesToMove[k] = dataRecord[k];
|
|
289
|
+
}
|
|
290
|
+
// Set values at destination
|
|
291
|
+
for (const [k, v] of Object.entries(valuesToMove)) {
|
|
292
|
+
const newDestKeys = [];
|
|
293
|
+
for (const dk of destKeys.slice(keyIdx)) {
|
|
294
|
+
if (dk === '*') {
|
|
295
|
+
newDestKeys.push(k);
|
|
296
|
+
}
|
|
297
|
+
else {
|
|
298
|
+
newDestKeys.push(dk);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
setValueByPath(dataRecord, newDestKeys, v);
|
|
302
|
+
}
|
|
303
|
+
for (const k of keysToMove) {
|
|
304
|
+
delete dataRecord[k];
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
// Navigate to next level
|
|
310
|
+
const dataRecord = data;
|
|
311
|
+
if (key in dataRecord) {
|
|
312
|
+
_moveValueRecursive(dataRecord[key], sourceKeys, destKeys, keyIdx + 1, excludeKeys);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
224
316
|
|
|
225
317
|
/**
|
|
226
318
|
* @license
|
|
@@ -362,7 +454,7 @@ function generateVideosResponseFromVertex$1(fromObject) {
|
|
|
362
454
|
}
|
|
363
455
|
function generatedVideoFromMldev$1(fromObject) {
|
|
364
456
|
const toObject = {};
|
|
365
|
-
const fromVideo = getValueByPath(fromObject, ['
|
|
457
|
+
const fromVideo = getValueByPath(fromObject, ['video']);
|
|
366
458
|
if (fromVideo != null) {
|
|
367
459
|
setValueByPath(toObject, ['video'], videoFromMldev$1(fromVideo));
|
|
368
460
|
}
|
|
@@ -398,14 +490,11 @@ function getOperationParametersToVertex(fromObject) {
|
|
|
398
490
|
}
|
|
399
491
|
function videoFromMldev$1(fromObject) {
|
|
400
492
|
const toObject = {};
|
|
401
|
-
const fromUri = getValueByPath(fromObject, ['
|
|
493
|
+
const fromUri = getValueByPath(fromObject, ['uri']);
|
|
402
494
|
if (fromUri != null) {
|
|
403
495
|
setValueByPath(toObject, ['uri'], fromUri);
|
|
404
496
|
}
|
|
405
|
-
const fromVideoBytes = getValueByPath(fromObject, [
|
|
406
|
-
'video',
|
|
407
|
-
'encodedVideo',
|
|
408
|
-
]);
|
|
497
|
+
const fromVideoBytes = getValueByPath(fromObject, ['encodedVideo']);
|
|
409
498
|
if (fromVideoBytes != null) {
|
|
410
499
|
setValueByPath(toObject, ['videoBytes'], tBytes$1(fromVideoBytes));
|
|
411
500
|
}
|
|
@@ -471,6 +560,26 @@ exports.Language = void 0;
|
|
|
471
560
|
*/
|
|
472
561
|
Language["PYTHON"] = "PYTHON";
|
|
473
562
|
})(exports.Language || (exports.Language = {}));
|
|
563
|
+
/** Specifies how the response should be scheduled in the conversation. */
|
|
564
|
+
exports.FunctionResponseScheduling = void 0;
|
|
565
|
+
(function (FunctionResponseScheduling) {
|
|
566
|
+
/**
|
|
567
|
+
* This value is unused.
|
|
568
|
+
*/
|
|
569
|
+
FunctionResponseScheduling["SCHEDULING_UNSPECIFIED"] = "SCHEDULING_UNSPECIFIED";
|
|
570
|
+
/**
|
|
571
|
+
* Only add the result to the conversation context, do not interrupt or trigger generation.
|
|
572
|
+
*/
|
|
573
|
+
FunctionResponseScheduling["SILENT"] = "SILENT";
|
|
574
|
+
/**
|
|
575
|
+
* Add the result to the conversation context, and prompt to generate output without interrupting ongoing generation.
|
|
576
|
+
*/
|
|
577
|
+
FunctionResponseScheduling["WHEN_IDLE"] = "WHEN_IDLE";
|
|
578
|
+
/**
|
|
579
|
+
* Add the result to the conversation context, interrupt ongoing generation and prompt to generate output.
|
|
580
|
+
*/
|
|
581
|
+
FunctionResponseScheduling["INTERRUPT"] = "INTERRUPT";
|
|
582
|
+
})(exports.FunctionResponseScheduling || (exports.FunctionResponseScheduling = {}));
|
|
474
583
|
/** Optional. The type of the data. */
|
|
475
584
|
exports.Type = void 0;
|
|
476
585
|
(function (Type) {
|
|
@@ -514,22 +623,22 @@ exports.HarmCategory = void 0;
|
|
|
514
623
|
* The harm category is unspecified.
|
|
515
624
|
*/
|
|
516
625
|
HarmCategory["HARM_CATEGORY_UNSPECIFIED"] = "HARM_CATEGORY_UNSPECIFIED";
|
|
517
|
-
/**
|
|
518
|
-
* The harm category is hate speech.
|
|
519
|
-
*/
|
|
520
|
-
HarmCategory["HARM_CATEGORY_HATE_SPEECH"] = "HARM_CATEGORY_HATE_SPEECH";
|
|
521
|
-
/**
|
|
522
|
-
* The harm category is dangerous content.
|
|
523
|
-
*/
|
|
524
|
-
HarmCategory["HARM_CATEGORY_DANGEROUS_CONTENT"] = "HARM_CATEGORY_DANGEROUS_CONTENT";
|
|
525
626
|
/**
|
|
526
627
|
* The harm category is harassment.
|
|
527
628
|
*/
|
|
528
629
|
HarmCategory["HARM_CATEGORY_HARASSMENT"] = "HARM_CATEGORY_HARASSMENT";
|
|
630
|
+
/**
|
|
631
|
+
* The harm category is hate speech.
|
|
632
|
+
*/
|
|
633
|
+
HarmCategory["HARM_CATEGORY_HATE_SPEECH"] = "HARM_CATEGORY_HATE_SPEECH";
|
|
529
634
|
/**
|
|
530
635
|
* The harm category is sexually explicit content.
|
|
531
636
|
*/
|
|
532
637
|
HarmCategory["HARM_CATEGORY_SEXUALLY_EXPLICIT"] = "HARM_CATEGORY_SEXUALLY_EXPLICIT";
|
|
638
|
+
/**
|
|
639
|
+
* The harm category is dangerous content.
|
|
640
|
+
*/
|
|
641
|
+
HarmCategory["HARM_CATEGORY_DANGEROUS_CONTENT"] = "HARM_CATEGORY_DANGEROUS_CONTENT";
|
|
533
642
|
/**
|
|
534
643
|
* Deprecated: Election filter is not longer supported. The harm category is civic integrity.
|
|
535
644
|
*/
|
|
@@ -550,6 +659,10 @@ exports.HarmCategory = void 0;
|
|
|
550
659
|
* The harm category is image sexually explicit content.
|
|
551
660
|
*/
|
|
552
661
|
HarmCategory["HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT"] = "HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT";
|
|
662
|
+
/**
|
|
663
|
+
* The harm category is for jailbreak prompts.
|
|
664
|
+
*/
|
|
665
|
+
HarmCategory["HARM_CATEGORY_JAILBREAK"] = "HARM_CATEGORY_JAILBREAK";
|
|
553
666
|
})(exports.HarmCategory || (exports.HarmCategory = {}));
|
|
554
667
|
/** Optional. Specify if the threshold is used for probability or severity score. If not specified, the threshold is used for probability score. */
|
|
555
668
|
exports.HarmBlockMethod = void 0;
|
|
@@ -790,33 +903,41 @@ exports.HarmSeverity = void 0;
|
|
|
790
903
|
*/
|
|
791
904
|
HarmSeverity["HARM_SEVERITY_HIGH"] = "HARM_SEVERITY_HIGH";
|
|
792
905
|
})(exports.HarmSeverity || (exports.HarmSeverity = {}));
|
|
793
|
-
/** Output only.
|
|
906
|
+
/** Output only. The reason why the prompt was blocked. */
|
|
794
907
|
exports.BlockedReason = void 0;
|
|
795
908
|
(function (BlockedReason) {
|
|
796
909
|
/**
|
|
797
|
-
*
|
|
910
|
+
* The blocked reason is unspecified.
|
|
798
911
|
*/
|
|
799
912
|
BlockedReason["BLOCKED_REASON_UNSPECIFIED"] = "BLOCKED_REASON_UNSPECIFIED";
|
|
800
913
|
/**
|
|
801
|
-
*
|
|
914
|
+
* The prompt was blocked for safety reasons.
|
|
802
915
|
*/
|
|
803
916
|
BlockedReason["SAFETY"] = "SAFETY";
|
|
804
917
|
/**
|
|
805
|
-
*
|
|
918
|
+
* The prompt was blocked for other reasons. For example, it may be due to the prompt's language, or because it contains other harmful content.
|
|
806
919
|
*/
|
|
807
920
|
BlockedReason["OTHER"] = "OTHER";
|
|
808
921
|
/**
|
|
809
|
-
*
|
|
922
|
+
* The prompt was blocked because it contains a term from the terminology blocklist.
|
|
810
923
|
*/
|
|
811
924
|
BlockedReason["BLOCKLIST"] = "BLOCKLIST";
|
|
812
925
|
/**
|
|
813
|
-
*
|
|
926
|
+
* The prompt was blocked because it contains prohibited content.
|
|
814
927
|
*/
|
|
815
928
|
BlockedReason["PROHIBITED_CONTENT"] = "PROHIBITED_CONTENT";
|
|
816
929
|
/**
|
|
817
|
-
*
|
|
930
|
+
* The prompt was blocked because it contains content that is unsafe for image generation.
|
|
818
931
|
*/
|
|
819
932
|
BlockedReason["IMAGE_SAFETY"] = "IMAGE_SAFETY";
|
|
933
|
+
/**
|
|
934
|
+
* The prompt was blocked by Model Armor.
|
|
935
|
+
*/
|
|
936
|
+
BlockedReason["MODEL_ARMOR"] = "MODEL_ARMOR";
|
|
937
|
+
/**
|
|
938
|
+
* The prompt was blocked as a jailbreak attempt.
|
|
939
|
+
*/
|
|
940
|
+
BlockedReason["JAILBREAK"] = "JAILBREAK";
|
|
820
941
|
})(exports.BlockedReason || (exports.BlockedReason = {}));
|
|
821
942
|
/** Output only. Traffic type. This shows whether a request consumes Pay-As-You-Go or Provisioned Throughput quota. */
|
|
822
943
|
exports.TrafficType = void 0;
|
|
@@ -1351,26 +1472,6 @@ exports.TurnCoverage = void 0;
|
|
|
1351
1472
|
*/
|
|
1352
1473
|
TurnCoverage["TURN_INCLUDES_ALL_INPUT"] = "TURN_INCLUDES_ALL_INPUT";
|
|
1353
1474
|
})(exports.TurnCoverage || (exports.TurnCoverage = {}));
|
|
1354
|
-
/** Specifies how the response should be scheduled in the conversation. */
|
|
1355
|
-
exports.FunctionResponseScheduling = void 0;
|
|
1356
|
-
(function (FunctionResponseScheduling) {
|
|
1357
|
-
/**
|
|
1358
|
-
* This value is unused.
|
|
1359
|
-
*/
|
|
1360
|
-
FunctionResponseScheduling["SCHEDULING_UNSPECIFIED"] = "SCHEDULING_UNSPECIFIED";
|
|
1361
|
-
/**
|
|
1362
|
-
* Only add the result to the conversation context, do not interrupt or trigger generation.
|
|
1363
|
-
*/
|
|
1364
|
-
FunctionResponseScheduling["SILENT"] = "SILENT";
|
|
1365
|
-
/**
|
|
1366
|
-
* Add the result to the conversation context, and prompt to generate output without interrupting ongoing generation.
|
|
1367
|
-
*/
|
|
1368
|
-
FunctionResponseScheduling["WHEN_IDLE"] = "WHEN_IDLE";
|
|
1369
|
-
/**
|
|
1370
|
-
* Add the result to the conversation context, interrupt ongoing generation and prompt to generate output.
|
|
1371
|
-
*/
|
|
1372
|
-
FunctionResponseScheduling["INTERRUPT"] = "INTERRUPT";
|
|
1373
|
-
})(exports.FunctionResponseScheduling || (exports.FunctionResponseScheduling = {}));
|
|
1374
1475
|
/** Scale of the generated music. */
|
|
1375
1476
|
exports.Scale = void 0;
|
|
1376
1477
|
(function (Scale) {
|
|
@@ -1668,7 +1769,7 @@ class HttpResponse {
|
|
|
1668
1769
|
return this.responseInternal.json();
|
|
1669
1770
|
}
|
|
1670
1771
|
}
|
|
1671
|
-
/** Content filter results for a prompt sent in the request. */
|
|
1772
|
+
/** Content filter results for a prompt sent in the request. Note: This is sent only in the first stream chunk and only if no candidates were generated due to content violations. */
|
|
1672
1773
|
class GenerateContentResponsePromptFeedback {
|
|
1673
1774
|
}
|
|
1674
1775
|
/** Usage metadata about response(s). */
|
|
@@ -3538,6 +3639,7 @@ function embedContentBatchToMldev(apiClient, fromObject) {
|
|
|
3538
3639
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
3539
3640
|
if (fromConfig != null) {
|
|
3540
3641
|
setValueByPath(toObject, ['_self'], embedContentConfigToMldev$1(fromConfig, toObject));
|
|
3642
|
+
moveValueByPath(toObject, { 'requests[].*': 'requests[].request.*' });
|
|
3541
3643
|
}
|
|
3542
3644
|
return toObject;
|
|
3543
3645
|
}
|
|
@@ -4319,38 +4421,11 @@ class Batches extends BaseModule {
|
|
|
4319
4421
|
* ```
|
|
4320
4422
|
*/
|
|
4321
4423
|
this.createEmbeddings = async (params) => {
|
|
4322
|
-
var _a, _b;
|
|
4323
4424
|
console.warn('batches.createEmbeddings() is experimental and may change without notice.');
|
|
4324
4425
|
if (this.apiClient.isVertexAI()) {
|
|
4325
4426
|
throw new Error('Vertex AI does not support batches.createEmbeddings.');
|
|
4326
4427
|
}
|
|
4327
|
-
|
|
4328
|
-
const src = params.src;
|
|
4329
|
-
const is_inlined = src.inlinedRequests !== undefined;
|
|
4330
|
-
if (!is_inlined) {
|
|
4331
|
-
return this.createEmbeddingsInternal(params); // Fixed typo here
|
|
4332
|
-
}
|
|
4333
|
-
// Inlined embed content requests handling
|
|
4334
|
-
const result = this.createInlinedEmbedContentRequest(params);
|
|
4335
|
-
const path = result.path;
|
|
4336
|
-
const requestBody = result.body;
|
|
4337
|
-
const queryParams = createEmbeddingsBatchJobParametersToMldev(this.apiClient, params)['_query'] || {};
|
|
4338
|
-
const response = this.apiClient
|
|
4339
|
-
.request({
|
|
4340
|
-
path: path,
|
|
4341
|
-
queryParams: queryParams,
|
|
4342
|
-
body: JSON.stringify(requestBody),
|
|
4343
|
-
httpMethod: 'POST',
|
|
4344
|
-
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
4345
|
-
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
4346
|
-
})
|
|
4347
|
-
.then((httpResponse) => {
|
|
4348
|
-
return httpResponse.json();
|
|
4349
|
-
});
|
|
4350
|
-
return response.then((apiResponse) => {
|
|
4351
|
-
const resp = batchJobFromMldev(apiResponse);
|
|
4352
|
-
return resp;
|
|
4353
|
-
});
|
|
4428
|
+
return this.createEmbeddingsInternal(params);
|
|
4354
4429
|
};
|
|
4355
4430
|
/**
|
|
4356
4431
|
* Lists batch job configurations.
|
|
@@ -4398,35 +4473,6 @@ class Batches extends BaseModule {
|
|
|
4398
4473
|
delete body['_query'];
|
|
4399
4474
|
return { path, body };
|
|
4400
4475
|
}
|
|
4401
|
-
// Helper function to handle inlined embedding requests
|
|
4402
|
-
createInlinedEmbedContentRequest(params) {
|
|
4403
|
-
const body = createEmbeddingsBatchJobParametersToMldev(this.apiClient, // Use instance apiClient
|
|
4404
|
-
params);
|
|
4405
|
-
const urlParams = body['_url'];
|
|
4406
|
-
const path = formatMap('{model}:asyncBatchEmbedContent', urlParams);
|
|
4407
|
-
const batch = body['batch'];
|
|
4408
|
-
const inputConfig = batch['inputConfig'];
|
|
4409
|
-
const requestsWrapper = inputConfig['requests'];
|
|
4410
|
-
const requests = requestsWrapper['requests'];
|
|
4411
|
-
const newRequests = [];
|
|
4412
|
-
delete requestsWrapper['config']; // Remove top-level config
|
|
4413
|
-
for (const request of requests) {
|
|
4414
|
-
const requestDict = Object.assign({}, request); // Clone
|
|
4415
|
-
const innerRequest = requestDict['request'];
|
|
4416
|
-
for (const key in requestDict) {
|
|
4417
|
-
if (key !== 'request') {
|
|
4418
|
-
innerRequest[key] = requestDict[key];
|
|
4419
|
-
delete requestDict[key];
|
|
4420
|
-
}
|
|
4421
|
-
}
|
|
4422
|
-
newRequests.push(requestDict);
|
|
4423
|
-
}
|
|
4424
|
-
requestsWrapper['requests'] = newRequests;
|
|
4425
|
-
delete body['config'];
|
|
4426
|
-
delete body['_url'];
|
|
4427
|
-
delete body['_query'];
|
|
4428
|
-
return { path, body };
|
|
4429
|
-
}
|
|
4430
4476
|
// Helper function to get the first GCS URI
|
|
4431
4477
|
getGcsUri(src) {
|
|
4432
4478
|
if (typeof src === 'string') {
|
|
@@ -6778,6 +6824,10 @@ function generationConfigToVertex$1(fromObject) {
|
|
|
6778
6824
|
if (fromTopP != null) {
|
|
6779
6825
|
setValueByPath(toObject, ['topP'], fromTopP);
|
|
6780
6826
|
}
|
|
6827
|
+
if (getValueByPath(fromObject, ['enableEnhancedCivicAnswers']) !==
|
|
6828
|
+
undefined) {
|
|
6829
|
+
throw new Error('enableEnhancedCivicAnswers parameter is not supported in Vertex AI.');
|
|
6830
|
+
}
|
|
6781
6831
|
return toObject;
|
|
6782
6832
|
}
|
|
6783
6833
|
function googleMapsToMldev$2(fromObject) {
|
|
@@ -9301,7 +9351,7 @@ function generatedImageMaskFromVertex(fromObject) {
|
|
|
9301
9351
|
}
|
|
9302
9352
|
function generatedVideoFromMldev(fromObject) {
|
|
9303
9353
|
const toObject = {};
|
|
9304
|
-
const fromVideo = getValueByPath(fromObject, ['
|
|
9354
|
+
const fromVideo = getValueByPath(fromObject, ['video']);
|
|
9305
9355
|
if (fromVideo != null) {
|
|
9306
9356
|
setValueByPath(toObject, ['video'], videoFromMldev(fromVideo));
|
|
9307
9357
|
}
|
|
@@ -9437,6 +9487,10 @@ function generationConfigToVertex(fromObject) {
|
|
|
9437
9487
|
if (fromTopP != null) {
|
|
9438
9488
|
setValueByPath(toObject, ['topP'], fromTopP);
|
|
9439
9489
|
}
|
|
9490
|
+
if (getValueByPath(fromObject, ['enableEnhancedCivicAnswers']) !==
|
|
9491
|
+
undefined) {
|
|
9492
|
+
throw new Error('enableEnhancedCivicAnswers parameter is not supported in Vertex AI.');
|
|
9493
|
+
}
|
|
9440
9494
|
return toObject;
|
|
9441
9495
|
}
|
|
9442
9496
|
function getModelParametersToMldev(apiClient, fromObject) {
|
|
@@ -10447,14 +10501,11 @@ function upscaleImageResponseFromVertex(fromObject) {
|
|
|
10447
10501
|
}
|
|
10448
10502
|
function videoFromMldev(fromObject) {
|
|
10449
10503
|
const toObject = {};
|
|
10450
|
-
const fromUri = getValueByPath(fromObject, ['
|
|
10504
|
+
const fromUri = getValueByPath(fromObject, ['uri']);
|
|
10451
10505
|
if (fromUri != null) {
|
|
10452
10506
|
setValueByPath(toObject, ['uri'], fromUri);
|
|
10453
10507
|
}
|
|
10454
|
-
const fromVideoBytes = getValueByPath(fromObject, [
|
|
10455
|
-
'video',
|
|
10456
|
-
'encodedVideo',
|
|
10457
|
-
]);
|
|
10508
|
+
const fromVideoBytes = getValueByPath(fromObject, ['encodedVideo']);
|
|
10458
10509
|
if (fromVideoBytes != null) {
|
|
10459
10510
|
setValueByPath(toObject, ['videoBytes'], tBytes(fromVideoBytes));
|
|
10460
10511
|
}
|
|
@@ -10526,11 +10577,11 @@ function videoToMldev(fromObject) {
|
|
|
10526
10577
|
const toObject = {};
|
|
10527
10578
|
const fromUri = getValueByPath(fromObject, ['uri']);
|
|
10528
10579
|
if (fromUri != null) {
|
|
10529
|
-
setValueByPath(toObject, ['
|
|
10580
|
+
setValueByPath(toObject, ['uri'], fromUri);
|
|
10530
10581
|
}
|
|
10531
10582
|
const fromVideoBytes = getValueByPath(fromObject, ['videoBytes']);
|
|
10532
10583
|
if (fromVideoBytes != null) {
|
|
10533
|
-
setValueByPath(toObject, ['
|
|
10584
|
+
setValueByPath(toObject, ['encodedVideo'], tBytes(fromVideoBytes));
|
|
10534
10585
|
}
|
|
10535
10586
|
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
10536
10587
|
if (fromMimeType != null) {
|
|
@@ -10564,7 +10615,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
10564
10615
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
10565
10616
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
10566
10617
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
10567
|
-
const SDK_VERSION = '1.
|
|
10618
|
+
const SDK_VERSION = '1.26.0'; // x-release-please-version
|
|
10568
10619
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
10569
10620
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
10570
10621
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -12342,9 +12393,26 @@ class Models extends BaseModule {
|
|
|
12342
12393
|
* ```
|
|
12343
12394
|
*/
|
|
12344
12395
|
this.generateVideos = async (params) => {
|
|
12396
|
+
var _a, _b, _c, _d, _e, _f;
|
|
12345
12397
|
if ((params.prompt || params.image || params.video) && params.source) {
|
|
12346
12398
|
throw new Error('Source and prompt/image/video are mutually exclusive. Please only use source.');
|
|
12347
12399
|
}
|
|
12400
|
+
// Gemini API does not support video bytes.
|
|
12401
|
+
if (!this.apiClient.isVertexAI()) {
|
|
12402
|
+
if (((_a = params.video) === null || _a === void 0 ? void 0 : _a.uri) && ((_b = params.video) === null || _b === void 0 ? void 0 : _b.videoBytes)) {
|
|
12403
|
+
params.video = {
|
|
12404
|
+
uri: params.video.uri,
|
|
12405
|
+
mimeType: params.video.mimeType,
|
|
12406
|
+
};
|
|
12407
|
+
}
|
|
12408
|
+
else if (((_d = (_c = params.source) === null || _c === void 0 ? void 0 : _c.video) === null || _d === void 0 ? void 0 : _d.uri) &&
|
|
12409
|
+
((_f = (_e = params.source) === null || _e === void 0 ? void 0 : _e.video) === null || _f === void 0 ? void 0 : _f.videoBytes)) {
|
|
12410
|
+
params.source.video = {
|
|
12411
|
+
uri: params.source.video.uri,
|
|
12412
|
+
mimeType: params.source.video.mimeType,
|
|
12413
|
+
};
|
|
12414
|
+
}
|
|
12415
|
+
}
|
|
12348
12416
|
return await this.generateVideosInternal(params);
|
|
12349
12417
|
};
|
|
12350
12418
|
}
|
|
@@ -14347,11 +14415,11 @@ class NodeAuth {
|
|
|
14347
14415
|
throw new Error('Trying to set google-auth headers but googleAuth is unset');
|
|
14348
14416
|
}
|
|
14349
14417
|
const authHeaders = await this.googleAuth.getRequestHeaders();
|
|
14350
|
-
for (const key
|
|
14418
|
+
for (const [key, value] of Object.entries(authHeaders)) {
|
|
14351
14419
|
if (headers.get(key) !== null) {
|
|
14352
14420
|
continue;
|
|
14353
14421
|
}
|
|
14354
|
-
headers.append(key,
|
|
14422
|
+
headers.append(key, value);
|
|
14355
14423
|
}
|
|
14356
14424
|
}
|
|
14357
14425
|
}
|
|
@@ -14859,46 +14927,6 @@ function tuningJobFromMldev(fromObject) {
|
|
|
14859
14927
|
if (fromTunedModel != null) {
|
|
14860
14928
|
setValueByPath(toObject, ['tunedModel'], tunedModelFromMldev(fromTunedModel));
|
|
14861
14929
|
}
|
|
14862
|
-
const fromCustomBaseModel = getValueByPath(fromObject, [
|
|
14863
|
-
'customBaseModel',
|
|
14864
|
-
]);
|
|
14865
|
-
if (fromCustomBaseModel != null) {
|
|
14866
|
-
setValueByPath(toObject, ['customBaseModel'], fromCustomBaseModel);
|
|
14867
|
-
}
|
|
14868
|
-
const fromExperiment = getValueByPath(fromObject, ['experiment']);
|
|
14869
|
-
if (fromExperiment != null) {
|
|
14870
|
-
setValueByPath(toObject, ['experiment'], fromExperiment);
|
|
14871
|
-
}
|
|
14872
|
-
const fromLabels = getValueByPath(fromObject, ['labels']);
|
|
14873
|
-
if (fromLabels != null) {
|
|
14874
|
-
setValueByPath(toObject, ['labels'], fromLabels);
|
|
14875
|
-
}
|
|
14876
|
-
const fromOutputUri = getValueByPath(fromObject, ['outputUri']);
|
|
14877
|
-
if (fromOutputUri != null) {
|
|
14878
|
-
setValueByPath(toObject, ['outputUri'], fromOutputUri);
|
|
14879
|
-
}
|
|
14880
|
-
const fromPipelineJob = getValueByPath(fromObject, ['pipelineJob']);
|
|
14881
|
-
if (fromPipelineJob != null) {
|
|
14882
|
-
setValueByPath(toObject, ['pipelineJob'], fromPipelineJob);
|
|
14883
|
-
}
|
|
14884
|
-
const fromServiceAccount = getValueByPath(fromObject, [
|
|
14885
|
-
'serviceAccount',
|
|
14886
|
-
]);
|
|
14887
|
-
if (fromServiceAccount != null) {
|
|
14888
|
-
setValueByPath(toObject, ['serviceAccount'], fromServiceAccount);
|
|
14889
|
-
}
|
|
14890
|
-
const fromTunedModelDisplayName = getValueByPath(fromObject, [
|
|
14891
|
-
'tunedModelDisplayName',
|
|
14892
|
-
]);
|
|
14893
|
-
if (fromTunedModelDisplayName != null) {
|
|
14894
|
-
setValueByPath(toObject, ['tunedModelDisplayName'], fromTunedModelDisplayName);
|
|
14895
|
-
}
|
|
14896
|
-
const fromVeoTuningSpec = getValueByPath(fromObject, [
|
|
14897
|
-
'veoTuningSpec',
|
|
14898
|
-
]);
|
|
14899
|
-
if (fromVeoTuningSpec != null) {
|
|
14900
|
-
setValueByPath(toObject, ['veoTuningSpec'], fromVeoTuningSpec);
|
|
14901
|
-
}
|
|
14902
14930
|
return toObject;
|
|
14903
14931
|
}
|
|
14904
14932
|
function tuningJobFromVertex(fromObject) {
|