@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.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
|
}
|
|
@@ -449,6 +538,26 @@ var Language;
|
|
|
449
538
|
*/
|
|
450
539
|
Language["PYTHON"] = "PYTHON";
|
|
451
540
|
})(Language || (Language = {}));
|
|
541
|
+
/** Specifies how the response should be scheduled in the conversation. */
|
|
542
|
+
var FunctionResponseScheduling;
|
|
543
|
+
(function (FunctionResponseScheduling) {
|
|
544
|
+
/**
|
|
545
|
+
* This value is unused.
|
|
546
|
+
*/
|
|
547
|
+
FunctionResponseScheduling["SCHEDULING_UNSPECIFIED"] = "SCHEDULING_UNSPECIFIED";
|
|
548
|
+
/**
|
|
549
|
+
* Only add the result to the conversation context, do not interrupt or trigger generation.
|
|
550
|
+
*/
|
|
551
|
+
FunctionResponseScheduling["SILENT"] = "SILENT";
|
|
552
|
+
/**
|
|
553
|
+
* Add the result to the conversation context, and prompt to generate output without interrupting ongoing generation.
|
|
554
|
+
*/
|
|
555
|
+
FunctionResponseScheduling["WHEN_IDLE"] = "WHEN_IDLE";
|
|
556
|
+
/**
|
|
557
|
+
* Add the result to the conversation context, interrupt ongoing generation and prompt to generate output.
|
|
558
|
+
*/
|
|
559
|
+
FunctionResponseScheduling["INTERRUPT"] = "INTERRUPT";
|
|
560
|
+
})(FunctionResponseScheduling || (FunctionResponseScheduling = {}));
|
|
452
561
|
/** Optional. The type of the data. */
|
|
453
562
|
var Type;
|
|
454
563
|
(function (Type) {
|
|
@@ -492,22 +601,22 @@ var HarmCategory;
|
|
|
492
601
|
* The harm category is unspecified.
|
|
493
602
|
*/
|
|
494
603
|
HarmCategory["HARM_CATEGORY_UNSPECIFIED"] = "HARM_CATEGORY_UNSPECIFIED";
|
|
495
|
-
/**
|
|
496
|
-
* The harm category is hate speech.
|
|
497
|
-
*/
|
|
498
|
-
HarmCategory["HARM_CATEGORY_HATE_SPEECH"] = "HARM_CATEGORY_HATE_SPEECH";
|
|
499
|
-
/**
|
|
500
|
-
* The harm category is dangerous content.
|
|
501
|
-
*/
|
|
502
|
-
HarmCategory["HARM_CATEGORY_DANGEROUS_CONTENT"] = "HARM_CATEGORY_DANGEROUS_CONTENT";
|
|
503
604
|
/**
|
|
504
605
|
* The harm category is harassment.
|
|
505
606
|
*/
|
|
506
607
|
HarmCategory["HARM_CATEGORY_HARASSMENT"] = "HARM_CATEGORY_HARASSMENT";
|
|
608
|
+
/**
|
|
609
|
+
* The harm category is hate speech.
|
|
610
|
+
*/
|
|
611
|
+
HarmCategory["HARM_CATEGORY_HATE_SPEECH"] = "HARM_CATEGORY_HATE_SPEECH";
|
|
507
612
|
/**
|
|
508
613
|
* The harm category is sexually explicit content.
|
|
509
614
|
*/
|
|
510
615
|
HarmCategory["HARM_CATEGORY_SEXUALLY_EXPLICIT"] = "HARM_CATEGORY_SEXUALLY_EXPLICIT";
|
|
616
|
+
/**
|
|
617
|
+
* The harm category is dangerous content.
|
|
618
|
+
*/
|
|
619
|
+
HarmCategory["HARM_CATEGORY_DANGEROUS_CONTENT"] = "HARM_CATEGORY_DANGEROUS_CONTENT";
|
|
511
620
|
/**
|
|
512
621
|
* Deprecated: Election filter is not longer supported. The harm category is civic integrity.
|
|
513
622
|
*/
|
|
@@ -528,6 +637,10 @@ var HarmCategory;
|
|
|
528
637
|
* The harm category is image sexually explicit content.
|
|
529
638
|
*/
|
|
530
639
|
HarmCategory["HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT"] = "HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT";
|
|
640
|
+
/**
|
|
641
|
+
* The harm category is for jailbreak prompts.
|
|
642
|
+
*/
|
|
643
|
+
HarmCategory["HARM_CATEGORY_JAILBREAK"] = "HARM_CATEGORY_JAILBREAK";
|
|
531
644
|
})(HarmCategory || (HarmCategory = {}));
|
|
532
645
|
/** Optional. Specify if the threshold is used for probability or severity score. If not specified, the threshold is used for probability score. */
|
|
533
646
|
var HarmBlockMethod;
|
|
@@ -768,33 +881,41 @@ var HarmSeverity;
|
|
|
768
881
|
*/
|
|
769
882
|
HarmSeverity["HARM_SEVERITY_HIGH"] = "HARM_SEVERITY_HIGH";
|
|
770
883
|
})(HarmSeverity || (HarmSeverity = {}));
|
|
771
|
-
/** Output only.
|
|
884
|
+
/** Output only. The reason why the prompt was blocked. */
|
|
772
885
|
var BlockedReason;
|
|
773
886
|
(function (BlockedReason) {
|
|
774
887
|
/**
|
|
775
|
-
*
|
|
888
|
+
* The blocked reason is unspecified.
|
|
776
889
|
*/
|
|
777
890
|
BlockedReason["BLOCKED_REASON_UNSPECIFIED"] = "BLOCKED_REASON_UNSPECIFIED";
|
|
778
891
|
/**
|
|
779
|
-
*
|
|
892
|
+
* The prompt was blocked for safety reasons.
|
|
780
893
|
*/
|
|
781
894
|
BlockedReason["SAFETY"] = "SAFETY";
|
|
782
895
|
/**
|
|
783
|
-
*
|
|
896
|
+
* 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.
|
|
784
897
|
*/
|
|
785
898
|
BlockedReason["OTHER"] = "OTHER";
|
|
786
899
|
/**
|
|
787
|
-
*
|
|
900
|
+
* The prompt was blocked because it contains a term from the terminology blocklist.
|
|
788
901
|
*/
|
|
789
902
|
BlockedReason["BLOCKLIST"] = "BLOCKLIST";
|
|
790
903
|
/**
|
|
791
|
-
*
|
|
904
|
+
* The prompt was blocked because it contains prohibited content.
|
|
792
905
|
*/
|
|
793
906
|
BlockedReason["PROHIBITED_CONTENT"] = "PROHIBITED_CONTENT";
|
|
794
907
|
/**
|
|
795
|
-
*
|
|
908
|
+
* The prompt was blocked because it contains content that is unsafe for image generation.
|
|
796
909
|
*/
|
|
797
910
|
BlockedReason["IMAGE_SAFETY"] = "IMAGE_SAFETY";
|
|
911
|
+
/**
|
|
912
|
+
* The prompt was blocked by Model Armor.
|
|
913
|
+
*/
|
|
914
|
+
BlockedReason["MODEL_ARMOR"] = "MODEL_ARMOR";
|
|
915
|
+
/**
|
|
916
|
+
* The prompt was blocked as a jailbreak attempt.
|
|
917
|
+
*/
|
|
918
|
+
BlockedReason["JAILBREAK"] = "JAILBREAK";
|
|
798
919
|
})(BlockedReason || (BlockedReason = {}));
|
|
799
920
|
/** Output only. Traffic type. This shows whether a request consumes Pay-As-You-Go or Provisioned Throughput quota. */
|
|
800
921
|
var TrafficType;
|
|
@@ -1329,26 +1450,6 @@ var TurnCoverage;
|
|
|
1329
1450
|
*/
|
|
1330
1451
|
TurnCoverage["TURN_INCLUDES_ALL_INPUT"] = "TURN_INCLUDES_ALL_INPUT";
|
|
1331
1452
|
})(TurnCoverage || (TurnCoverage = {}));
|
|
1332
|
-
/** Specifies how the response should be scheduled in the conversation. */
|
|
1333
|
-
var FunctionResponseScheduling;
|
|
1334
|
-
(function (FunctionResponseScheduling) {
|
|
1335
|
-
/**
|
|
1336
|
-
* This value is unused.
|
|
1337
|
-
*/
|
|
1338
|
-
FunctionResponseScheduling["SCHEDULING_UNSPECIFIED"] = "SCHEDULING_UNSPECIFIED";
|
|
1339
|
-
/**
|
|
1340
|
-
* Only add the result to the conversation context, do not interrupt or trigger generation.
|
|
1341
|
-
*/
|
|
1342
|
-
FunctionResponseScheduling["SILENT"] = "SILENT";
|
|
1343
|
-
/**
|
|
1344
|
-
* Add the result to the conversation context, and prompt to generate output without interrupting ongoing generation.
|
|
1345
|
-
*/
|
|
1346
|
-
FunctionResponseScheduling["WHEN_IDLE"] = "WHEN_IDLE";
|
|
1347
|
-
/**
|
|
1348
|
-
* Add the result to the conversation context, interrupt ongoing generation and prompt to generate output.
|
|
1349
|
-
*/
|
|
1350
|
-
FunctionResponseScheduling["INTERRUPT"] = "INTERRUPT";
|
|
1351
|
-
})(FunctionResponseScheduling || (FunctionResponseScheduling = {}));
|
|
1352
1453
|
/** Scale of the generated music. */
|
|
1353
1454
|
var Scale;
|
|
1354
1455
|
(function (Scale) {
|
|
@@ -1646,7 +1747,7 @@ class HttpResponse {
|
|
|
1646
1747
|
return this.responseInternal.json();
|
|
1647
1748
|
}
|
|
1648
1749
|
}
|
|
1649
|
-
/** Content filter results for a prompt sent in the request. */
|
|
1750
|
+
/** 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. */
|
|
1650
1751
|
class GenerateContentResponsePromptFeedback {
|
|
1651
1752
|
}
|
|
1652
1753
|
/** Usage metadata about response(s). */
|
|
@@ -3516,6 +3617,7 @@ function embedContentBatchToMldev(apiClient, fromObject) {
|
|
|
3516
3617
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
3517
3618
|
if (fromConfig != null) {
|
|
3518
3619
|
setValueByPath(toObject, ['_self'], embedContentConfigToMldev$1(fromConfig, toObject));
|
|
3620
|
+
moveValueByPath(toObject, { 'requests[].*': 'requests[].request.*' });
|
|
3519
3621
|
}
|
|
3520
3622
|
return toObject;
|
|
3521
3623
|
}
|
|
@@ -4297,38 +4399,11 @@ class Batches extends BaseModule {
|
|
|
4297
4399
|
* ```
|
|
4298
4400
|
*/
|
|
4299
4401
|
this.createEmbeddings = async (params) => {
|
|
4300
|
-
var _a, _b;
|
|
4301
4402
|
console.warn('batches.createEmbeddings() is experimental and may change without notice.');
|
|
4302
4403
|
if (this.apiClient.isVertexAI()) {
|
|
4303
4404
|
throw new Error('Vertex AI does not support batches.createEmbeddings.');
|
|
4304
4405
|
}
|
|
4305
|
-
|
|
4306
|
-
const src = params.src;
|
|
4307
|
-
const is_inlined = src.inlinedRequests !== undefined;
|
|
4308
|
-
if (!is_inlined) {
|
|
4309
|
-
return this.createEmbeddingsInternal(params); // Fixed typo here
|
|
4310
|
-
}
|
|
4311
|
-
// Inlined embed content requests handling
|
|
4312
|
-
const result = this.createInlinedEmbedContentRequest(params);
|
|
4313
|
-
const path = result.path;
|
|
4314
|
-
const requestBody = result.body;
|
|
4315
|
-
const queryParams = createEmbeddingsBatchJobParametersToMldev(this.apiClient, params)['_query'] || {};
|
|
4316
|
-
const response = this.apiClient
|
|
4317
|
-
.request({
|
|
4318
|
-
path: path,
|
|
4319
|
-
queryParams: queryParams,
|
|
4320
|
-
body: JSON.stringify(requestBody),
|
|
4321
|
-
httpMethod: 'POST',
|
|
4322
|
-
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
4323
|
-
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
4324
|
-
})
|
|
4325
|
-
.then((httpResponse) => {
|
|
4326
|
-
return httpResponse.json();
|
|
4327
|
-
});
|
|
4328
|
-
return response.then((apiResponse) => {
|
|
4329
|
-
const resp = batchJobFromMldev(apiResponse);
|
|
4330
|
-
return resp;
|
|
4331
|
-
});
|
|
4406
|
+
return this.createEmbeddingsInternal(params);
|
|
4332
4407
|
};
|
|
4333
4408
|
/**
|
|
4334
4409
|
* Lists batch job configurations.
|
|
@@ -4376,35 +4451,6 @@ class Batches extends BaseModule {
|
|
|
4376
4451
|
delete body['_query'];
|
|
4377
4452
|
return { path, body };
|
|
4378
4453
|
}
|
|
4379
|
-
// Helper function to handle inlined embedding requests
|
|
4380
|
-
createInlinedEmbedContentRequest(params) {
|
|
4381
|
-
const body = createEmbeddingsBatchJobParametersToMldev(this.apiClient, // Use instance apiClient
|
|
4382
|
-
params);
|
|
4383
|
-
const urlParams = body['_url'];
|
|
4384
|
-
const path = formatMap('{model}:asyncBatchEmbedContent', urlParams);
|
|
4385
|
-
const batch = body['batch'];
|
|
4386
|
-
const inputConfig = batch['inputConfig'];
|
|
4387
|
-
const requestsWrapper = inputConfig['requests'];
|
|
4388
|
-
const requests = requestsWrapper['requests'];
|
|
4389
|
-
const newRequests = [];
|
|
4390
|
-
delete requestsWrapper['config']; // Remove top-level config
|
|
4391
|
-
for (const request of requests) {
|
|
4392
|
-
const requestDict = Object.assign({}, request); // Clone
|
|
4393
|
-
const innerRequest = requestDict['request'];
|
|
4394
|
-
for (const key in requestDict) {
|
|
4395
|
-
if (key !== 'request') {
|
|
4396
|
-
innerRequest[key] = requestDict[key];
|
|
4397
|
-
delete requestDict[key];
|
|
4398
|
-
}
|
|
4399
|
-
}
|
|
4400
|
-
newRequests.push(requestDict);
|
|
4401
|
-
}
|
|
4402
|
-
requestsWrapper['requests'] = newRequests;
|
|
4403
|
-
delete body['config'];
|
|
4404
|
-
delete body['_url'];
|
|
4405
|
-
delete body['_query'];
|
|
4406
|
-
return { path, body };
|
|
4407
|
-
}
|
|
4408
4454
|
// Helper function to get the first GCS URI
|
|
4409
4455
|
getGcsUri(src) {
|
|
4410
4456
|
if (typeof src === 'string') {
|
|
@@ -6756,6 +6802,10 @@ function generationConfigToVertex$1(fromObject) {
|
|
|
6756
6802
|
if (fromTopP != null) {
|
|
6757
6803
|
setValueByPath(toObject, ['topP'], fromTopP);
|
|
6758
6804
|
}
|
|
6805
|
+
if (getValueByPath(fromObject, ['enableEnhancedCivicAnswers']) !==
|
|
6806
|
+
undefined) {
|
|
6807
|
+
throw new Error('enableEnhancedCivicAnswers parameter is not supported in Vertex AI.');
|
|
6808
|
+
}
|
|
6759
6809
|
return toObject;
|
|
6760
6810
|
}
|
|
6761
6811
|
function googleMapsToMldev$2(fromObject) {
|
|
@@ -9279,7 +9329,7 @@ function generatedImageMaskFromVertex(fromObject) {
|
|
|
9279
9329
|
}
|
|
9280
9330
|
function generatedVideoFromMldev(fromObject) {
|
|
9281
9331
|
const toObject = {};
|
|
9282
|
-
const fromVideo = getValueByPath(fromObject, ['
|
|
9332
|
+
const fromVideo = getValueByPath(fromObject, ['video']);
|
|
9283
9333
|
if (fromVideo != null) {
|
|
9284
9334
|
setValueByPath(toObject, ['video'], videoFromMldev(fromVideo));
|
|
9285
9335
|
}
|
|
@@ -9415,6 +9465,10 @@ function generationConfigToVertex(fromObject) {
|
|
|
9415
9465
|
if (fromTopP != null) {
|
|
9416
9466
|
setValueByPath(toObject, ['topP'], fromTopP);
|
|
9417
9467
|
}
|
|
9468
|
+
if (getValueByPath(fromObject, ['enableEnhancedCivicAnswers']) !==
|
|
9469
|
+
undefined) {
|
|
9470
|
+
throw new Error('enableEnhancedCivicAnswers parameter is not supported in Vertex AI.');
|
|
9471
|
+
}
|
|
9418
9472
|
return toObject;
|
|
9419
9473
|
}
|
|
9420
9474
|
function getModelParametersToMldev(apiClient, fromObject) {
|
|
@@ -10425,14 +10479,11 @@ function upscaleImageResponseFromVertex(fromObject) {
|
|
|
10425
10479
|
}
|
|
10426
10480
|
function videoFromMldev(fromObject) {
|
|
10427
10481
|
const toObject = {};
|
|
10428
|
-
const fromUri = getValueByPath(fromObject, ['
|
|
10482
|
+
const fromUri = getValueByPath(fromObject, ['uri']);
|
|
10429
10483
|
if (fromUri != null) {
|
|
10430
10484
|
setValueByPath(toObject, ['uri'], fromUri);
|
|
10431
10485
|
}
|
|
10432
|
-
const fromVideoBytes = getValueByPath(fromObject, [
|
|
10433
|
-
'video',
|
|
10434
|
-
'encodedVideo',
|
|
10435
|
-
]);
|
|
10486
|
+
const fromVideoBytes = getValueByPath(fromObject, ['encodedVideo']);
|
|
10436
10487
|
if (fromVideoBytes != null) {
|
|
10437
10488
|
setValueByPath(toObject, ['videoBytes'], tBytes(fromVideoBytes));
|
|
10438
10489
|
}
|
|
@@ -10504,11 +10555,11 @@ function videoToMldev(fromObject) {
|
|
|
10504
10555
|
const toObject = {};
|
|
10505
10556
|
const fromUri = getValueByPath(fromObject, ['uri']);
|
|
10506
10557
|
if (fromUri != null) {
|
|
10507
|
-
setValueByPath(toObject, ['
|
|
10558
|
+
setValueByPath(toObject, ['uri'], fromUri);
|
|
10508
10559
|
}
|
|
10509
10560
|
const fromVideoBytes = getValueByPath(fromObject, ['videoBytes']);
|
|
10510
10561
|
if (fromVideoBytes != null) {
|
|
10511
|
-
setValueByPath(toObject, ['
|
|
10562
|
+
setValueByPath(toObject, ['encodedVideo'], tBytes(fromVideoBytes));
|
|
10512
10563
|
}
|
|
10513
10564
|
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
10514
10565
|
if (fromMimeType != null) {
|
|
@@ -10542,7 +10593,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
10542
10593
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
10543
10594
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
10544
10595
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
10545
|
-
const SDK_VERSION = '1.
|
|
10596
|
+
const SDK_VERSION = '1.26.0'; // x-release-please-version
|
|
10546
10597
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
10547
10598
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
10548
10599
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -12320,9 +12371,26 @@ class Models extends BaseModule {
|
|
|
12320
12371
|
* ```
|
|
12321
12372
|
*/
|
|
12322
12373
|
this.generateVideos = async (params) => {
|
|
12374
|
+
var _a, _b, _c, _d, _e, _f;
|
|
12323
12375
|
if ((params.prompt || params.image || params.video) && params.source) {
|
|
12324
12376
|
throw new Error('Source and prompt/image/video are mutually exclusive. Please only use source.');
|
|
12325
12377
|
}
|
|
12378
|
+
// Gemini API does not support video bytes.
|
|
12379
|
+
if (!this.apiClient.isVertexAI()) {
|
|
12380
|
+
if (((_a = params.video) === null || _a === void 0 ? void 0 : _a.uri) && ((_b = params.video) === null || _b === void 0 ? void 0 : _b.videoBytes)) {
|
|
12381
|
+
params.video = {
|
|
12382
|
+
uri: params.video.uri,
|
|
12383
|
+
mimeType: params.video.mimeType,
|
|
12384
|
+
};
|
|
12385
|
+
}
|
|
12386
|
+
else if (((_d = (_c = params.source) === null || _c === void 0 ? void 0 : _c.video) === null || _d === void 0 ? void 0 : _d.uri) &&
|
|
12387
|
+
((_f = (_e = params.source) === null || _e === void 0 ? void 0 : _e.video) === null || _f === void 0 ? void 0 : _f.videoBytes)) {
|
|
12388
|
+
params.source.video = {
|
|
12389
|
+
uri: params.source.video.uri,
|
|
12390
|
+
mimeType: params.source.video.mimeType,
|
|
12391
|
+
};
|
|
12392
|
+
}
|
|
12393
|
+
}
|
|
12326
12394
|
return await this.generateVideosInternal(params);
|
|
12327
12395
|
};
|
|
12328
12396
|
}
|
|
@@ -14325,11 +14393,11 @@ class NodeAuth {
|
|
|
14325
14393
|
throw new Error('Trying to set google-auth headers but googleAuth is unset');
|
|
14326
14394
|
}
|
|
14327
14395
|
const authHeaders = await this.googleAuth.getRequestHeaders();
|
|
14328
|
-
for (const key
|
|
14396
|
+
for (const [key, value] of Object.entries(authHeaders)) {
|
|
14329
14397
|
if (headers.get(key) !== null) {
|
|
14330
14398
|
continue;
|
|
14331
14399
|
}
|
|
14332
|
-
headers.append(key,
|
|
14400
|
+
headers.append(key, value);
|
|
14333
14401
|
}
|
|
14334
14402
|
}
|
|
14335
14403
|
}
|
|
@@ -14837,46 +14905,6 @@ function tuningJobFromMldev(fromObject) {
|
|
|
14837
14905
|
if (fromTunedModel != null) {
|
|
14838
14906
|
setValueByPath(toObject, ['tunedModel'], tunedModelFromMldev(fromTunedModel));
|
|
14839
14907
|
}
|
|
14840
|
-
const fromCustomBaseModel = getValueByPath(fromObject, [
|
|
14841
|
-
'customBaseModel',
|
|
14842
|
-
]);
|
|
14843
|
-
if (fromCustomBaseModel != null) {
|
|
14844
|
-
setValueByPath(toObject, ['customBaseModel'], fromCustomBaseModel);
|
|
14845
|
-
}
|
|
14846
|
-
const fromExperiment = getValueByPath(fromObject, ['experiment']);
|
|
14847
|
-
if (fromExperiment != null) {
|
|
14848
|
-
setValueByPath(toObject, ['experiment'], fromExperiment);
|
|
14849
|
-
}
|
|
14850
|
-
const fromLabels = getValueByPath(fromObject, ['labels']);
|
|
14851
|
-
if (fromLabels != null) {
|
|
14852
|
-
setValueByPath(toObject, ['labels'], fromLabels);
|
|
14853
|
-
}
|
|
14854
|
-
const fromOutputUri = getValueByPath(fromObject, ['outputUri']);
|
|
14855
|
-
if (fromOutputUri != null) {
|
|
14856
|
-
setValueByPath(toObject, ['outputUri'], fromOutputUri);
|
|
14857
|
-
}
|
|
14858
|
-
const fromPipelineJob = getValueByPath(fromObject, ['pipelineJob']);
|
|
14859
|
-
if (fromPipelineJob != null) {
|
|
14860
|
-
setValueByPath(toObject, ['pipelineJob'], fromPipelineJob);
|
|
14861
|
-
}
|
|
14862
|
-
const fromServiceAccount = getValueByPath(fromObject, [
|
|
14863
|
-
'serviceAccount',
|
|
14864
|
-
]);
|
|
14865
|
-
if (fromServiceAccount != null) {
|
|
14866
|
-
setValueByPath(toObject, ['serviceAccount'], fromServiceAccount);
|
|
14867
|
-
}
|
|
14868
|
-
const fromTunedModelDisplayName = getValueByPath(fromObject, [
|
|
14869
|
-
'tunedModelDisplayName',
|
|
14870
|
-
]);
|
|
14871
|
-
if (fromTunedModelDisplayName != null) {
|
|
14872
|
-
setValueByPath(toObject, ['tunedModelDisplayName'], fromTunedModelDisplayName);
|
|
14873
|
-
}
|
|
14874
|
-
const fromVeoTuningSpec = getValueByPath(fromObject, [
|
|
14875
|
-
'veoTuningSpec',
|
|
14876
|
-
]);
|
|
14877
|
-
if (fromVeoTuningSpec != null) {
|
|
14878
|
-
setValueByPath(toObject, ['veoTuningSpec'], fromVeoTuningSpec);
|
|
14879
|
-
}
|
|
14880
14908
|
return toObject;
|
|
14881
14909
|
}
|
|
14882
14910
|
function tuningJobFromVertex(fromObject) {
|