@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/web/index.mjs
CHANGED
|
@@ -193,6 +193,98 @@ function getValueByPath(data, keys, defaultValue = undefined) {
|
|
|
193
193
|
throw error;
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
|
+
/**
|
|
197
|
+
* Moves values from source paths to destination paths.
|
|
198
|
+
*
|
|
199
|
+
* Examples:
|
|
200
|
+
* moveValueByPath(
|
|
201
|
+
* {'requests': [{'content': v1}, {'content': v2}]},
|
|
202
|
+
* {'requests[].*': 'requests[].request.*'}
|
|
203
|
+
* )
|
|
204
|
+
* -> {'requests': [{'request': {'content': v1}}, {'request': {'content': v2}}]}
|
|
205
|
+
*/
|
|
206
|
+
function moveValueByPath(data, paths) {
|
|
207
|
+
for (const [sourcePath, destPath] of Object.entries(paths)) {
|
|
208
|
+
const sourceKeys = sourcePath.split('.');
|
|
209
|
+
const destKeys = destPath.split('.');
|
|
210
|
+
// Determine keys to exclude from wildcard to avoid cyclic references
|
|
211
|
+
const excludeKeys = new Set();
|
|
212
|
+
let wildcardIdx = -1;
|
|
213
|
+
for (let i = 0; i < sourceKeys.length; i++) {
|
|
214
|
+
if (sourceKeys[i] === '*') {
|
|
215
|
+
wildcardIdx = i;
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
if (wildcardIdx !== -1 && destKeys.length > wildcardIdx) {
|
|
220
|
+
// Extract the intermediate key between source and dest paths
|
|
221
|
+
// Example: source=['requests[]', '*'], dest=['requests[]', 'request', '*']
|
|
222
|
+
// We want to exclude 'request'
|
|
223
|
+
for (let i = wildcardIdx; i < destKeys.length; i++) {
|
|
224
|
+
const key = destKeys[i];
|
|
225
|
+
if (key !== '*' && !key.endsWith('[]') && !key.endsWith('[0]')) {
|
|
226
|
+
excludeKeys.add(key);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
_moveValueRecursive(data, sourceKeys, destKeys, 0, excludeKeys);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Recursively moves values from source path to destination path.
|
|
235
|
+
*/
|
|
236
|
+
function _moveValueRecursive(data, sourceKeys, destKeys, keyIdx, excludeKeys) {
|
|
237
|
+
if (keyIdx >= sourceKeys.length) {
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
if (typeof data !== 'object' || data === null) {
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
const key = sourceKeys[keyIdx];
|
|
244
|
+
if (key.endsWith('[]')) {
|
|
245
|
+
const keyName = key.slice(0, -2);
|
|
246
|
+
const dataRecord = data;
|
|
247
|
+
if (keyName in dataRecord && Array.isArray(dataRecord[keyName])) {
|
|
248
|
+
for (const item of dataRecord[keyName]) {
|
|
249
|
+
_moveValueRecursive(item, sourceKeys, destKeys, keyIdx + 1, excludeKeys);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
else if (key === '*') {
|
|
254
|
+
// wildcard - move all fields
|
|
255
|
+
if (typeof data === 'object' && data !== null && !Array.isArray(data)) {
|
|
256
|
+
const dataRecord = data;
|
|
257
|
+
const keysToMove = Object.keys(dataRecord).filter((k) => !k.startsWith('_') && !excludeKeys.has(k));
|
|
258
|
+
const valuesToMove = {};
|
|
259
|
+
for (const k of keysToMove) {
|
|
260
|
+
valuesToMove[k] = dataRecord[k];
|
|
261
|
+
}
|
|
262
|
+
// Set values at destination
|
|
263
|
+
for (const [k, v] of Object.entries(valuesToMove)) {
|
|
264
|
+
const newDestKeys = [];
|
|
265
|
+
for (const dk of destKeys.slice(keyIdx)) {
|
|
266
|
+
if (dk === '*') {
|
|
267
|
+
newDestKeys.push(k);
|
|
268
|
+
}
|
|
269
|
+
else {
|
|
270
|
+
newDestKeys.push(dk);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
setValueByPath(dataRecord, newDestKeys, v);
|
|
274
|
+
}
|
|
275
|
+
for (const k of keysToMove) {
|
|
276
|
+
delete dataRecord[k];
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
// Navigate to next level
|
|
282
|
+
const dataRecord = data;
|
|
283
|
+
if (key in dataRecord) {
|
|
284
|
+
_moveValueRecursive(dataRecord[key], sourceKeys, destKeys, keyIdx + 1, excludeKeys);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
196
288
|
|
|
197
289
|
/**
|
|
198
290
|
* @license
|
|
@@ -334,7 +426,7 @@ function generateVideosResponseFromVertex$1(fromObject) {
|
|
|
334
426
|
}
|
|
335
427
|
function generatedVideoFromMldev$1(fromObject) {
|
|
336
428
|
const toObject = {};
|
|
337
|
-
const fromVideo = getValueByPath(fromObject, ['
|
|
429
|
+
const fromVideo = getValueByPath(fromObject, ['video']);
|
|
338
430
|
if (fromVideo != null) {
|
|
339
431
|
setValueByPath(toObject, ['video'], videoFromMldev$1(fromVideo));
|
|
340
432
|
}
|
|
@@ -370,14 +462,11 @@ function getOperationParametersToVertex(fromObject) {
|
|
|
370
462
|
}
|
|
371
463
|
function videoFromMldev$1(fromObject) {
|
|
372
464
|
const toObject = {};
|
|
373
|
-
const fromUri = getValueByPath(fromObject, ['
|
|
465
|
+
const fromUri = getValueByPath(fromObject, ['uri']);
|
|
374
466
|
if (fromUri != null) {
|
|
375
467
|
setValueByPath(toObject, ['uri'], fromUri);
|
|
376
468
|
}
|
|
377
|
-
const fromVideoBytes = getValueByPath(fromObject, [
|
|
378
|
-
'video',
|
|
379
|
-
'encodedVideo',
|
|
380
|
-
]);
|
|
469
|
+
const fromVideoBytes = getValueByPath(fromObject, ['encodedVideo']);
|
|
381
470
|
if (fromVideoBytes != null) {
|
|
382
471
|
setValueByPath(toObject, ['videoBytes'], tBytes$1(fromVideoBytes));
|
|
383
472
|
}
|
|
@@ -443,6 +532,26 @@ var Language;
|
|
|
443
532
|
*/
|
|
444
533
|
Language["PYTHON"] = "PYTHON";
|
|
445
534
|
})(Language || (Language = {}));
|
|
535
|
+
/** Specifies how the response should be scheduled in the conversation. */
|
|
536
|
+
var FunctionResponseScheduling;
|
|
537
|
+
(function (FunctionResponseScheduling) {
|
|
538
|
+
/**
|
|
539
|
+
* This value is unused.
|
|
540
|
+
*/
|
|
541
|
+
FunctionResponseScheduling["SCHEDULING_UNSPECIFIED"] = "SCHEDULING_UNSPECIFIED";
|
|
542
|
+
/**
|
|
543
|
+
* Only add the result to the conversation context, do not interrupt or trigger generation.
|
|
544
|
+
*/
|
|
545
|
+
FunctionResponseScheduling["SILENT"] = "SILENT";
|
|
546
|
+
/**
|
|
547
|
+
* Add the result to the conversation context, and prompt to generate output without interrupting ongoing generation.
|
|
548
|
+
*/
|
|
549
|
+
FunctionResponseScheduling["WHEN_IDLE"] = "WHEN_IDLE";
|
|
550
|
+
/**
|
|
551
|
+
* Add the result to the conversation context, interrupt ongoing generation and prompt to generate output.
|
|
552
|
+
*/
|
|
553
|
+
FunctionResponseScheduling["INTERRUPT"] = "INTERRUPT";
|
|
554
|
+
})(FunctionResponseScheduling || (FunctionResponseScheduling = {}));
|
|
446
555
|
/** Optional. The type of the data. */
|
|
447
556
|
var Type;
|
|
448
557
|
(function (Type) {
|
|
@@ -486,22 +595,22 @@ var HarmCategory;
|
|
|
486
595
|
* The harm category is unspecified.
|
|
487
596
|
*/
|
|
488
597
|
HarmCategory["HARM_CATEGORY_UNSPECIFIED"] = "HARM_CATEGORY_UNSPECIFIED";
|
|
489
|
-
/**
|
|
490
|
-
* The harm category is hate speech.
|
|
491
|
-
*/
|
|
492
|
-
HarmCategory["HARM_CATEGORY_HATE_SPEECH"] = "HARM_CATEGORY_HATE_SPEECH";
|
|
493
|
-
/**
|
|
494
|
-
* The harm category is dangerous content.
|
|
495
|
-
*/
|
|
496
|
-
HarmCategory["HARM_CATEGORY_DANGEROUS_CONTENT"] = "HARM_CATEGORY_DANGEROUS_CONTENT";
|
|
497
598
|
/**
|
|
498
599
|
* The harm category is harassment.
|
|
499
600
|
*/
|
|
500
601
|
HarmCategory["HARM_CATEGORY_HARASSMENT"] = "HARM_CATEGORY_HARASSMENT";
|
|
602
|
+
/**
|
|
603
|
+
* The harm category is hate speech.
|
|
604
|
+
*/
|
|
605
|
+
HarmCategory["HARM_CATEGORY_HATE_SPEECH"] = "HARM_CATEGORY_HATE_SPEECH";
|
|
501
606
|
/**
|
|
502
607
|
* The harm category is sexually explicit content.
|
|
503
608
|
*/
|
|
504
609
|
HarmCategory["HARM_CATEGORY_SEXUALLY_EXPLICIT"] = "HARM_CATEGORY_SEXUALLY_EXPLICIT";
|
|
610
|
+
/**
|
|
611
|
+
* The harm category is dangerous content.
|
|
612
|
+
*/
|
|
613
|
+
HarmCategory["HARM_CATEGORY_DANGEROUS_CONTENT"] = "HARM_CATEGORY_DANGEROUS_CONTENT";
|
|
505
614
|
/**
|
|
506
615
|
* Deprecated: Election filter is not longer supported. The harm category is civic integrity.
|
|
507
616
|
*/
|
|
@@ -522,6 +631,10 @@ var HarmCategory;
|
|
|
522
631
|
* The harm category is image sexually explicit content.
|
|
523
632
|
*/
|
|
524
633
|
HarmCategory["HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT"] = "HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT";
|
|
634
|
+
/**
|
|
635
|
+
* The harm category is for jailbreak prompts.
|
|
636
|
+
*/
|
|
637
|
+
HarmCategory["HARM_CATEGORY_JAILBREAK"] = "HARM_CATEGORY_JAILBREAK";
|
|
525
638
|
})(HarmCategory || (HarmCategory = {}));
|
|
526
639
|
/** Optional. Specify if the threshold is used for probability or severity score. If not specified, the threshold is used for probability score. */
|
|
527
640
|
var HarmBlockMethod;
|
|
@@ -762,33 +875,41 @@ var HarmSeverity;
|
|
|
762
875
|
*/
|
|
763
876
|
HarmSeverity["HARM_SEVERITY_HIGH"] = "HARM_SEVERITY_HIGH";
|
|
764
877
|
})(HarmSeverity || (HarmSeverity = {}));
|
|
765
|
-
/** Output only.
|
|
878
|
+
/** Output only. The reason why the prompt was blocked. */
|
|
766
879
|
var BlockedReason;
|
|
767
880
|
(function (BlockedReason) {
|
|
768
881
|
/**
|
|
769
|
-
*
|
|
882
|
+
* The blocked reason is unspecified.
|
|
770
883
|
*/
|
|
771
884
|
BlockedReason["BLOCKED_REASON_UNSPECIFIED"] = "BLOCKED_REASON_UNSPECIFIED";
|
|
772
885
|
/**
|
|
773
|
-
*
|
|
886
|
+
* The prompt was blocked for safety reasons.
|
|
774
887
|
*/
|
|
775
888
|
BlockedReason["SAFETY"] = "SAFETY";
|
|
776
889
|
/**
|
|
777
|
-
*
|
|
890
|
+
* 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.
|
|
778
891
|
*/
|
|
779
892
|
BlockedReason["OTHER"] = "OTHER";
|
|
780
893
|
/**
|
|
781
|
-
*
|
|
894
|
+
* The prompt was blocked because it contains a term from the terminology blocklist.
|
|
782
895
|
*/
|
|
783
896
|
BlockedReason["BLOCKLIST"] = "BLOCKLIST";
|
|
784
897
|
/**
|
|
785
|
-
*
|
|
898
|
+
* The prompt was blocked because it contains prohibited content.
|
|
786
899
|
*/
|
|
787
900
|
BlockedReason["PROHIBITED_CONTENT"] = "PROHIBITED_CONTENT";
|
|
788
901
|
/**
|
|
789
|
-
*
|
|
902
|
+
* The prompt was blocked because it contains content that is unsafe for image generation.
|
|
790
903
|
*/
|
|
791
904
|
BlockedReason["IMAGE_SAFETY"] = "IMAGE_SAFETY";
|
|
905
|
+
/**
|
|
906
|
+
* The prompt was blocked by Model Armor.
|
|
907
|
+
*/
|
|
908
|
+
BlockedReason["MODEL_ARMOR"] = "MODEL_ARMOR";
|
|
909
|
+
/**
|
|
910
|
+
* The prompt was blocked as a jailbreak attempt.
|
|
911
|
+
*/
|
|
912
|
+
BlockedReason["JAILBREAK"] = "JAILBREAK";
|
|
792
913
|
})(BlockedReason || (BlockedReason = {}));
|
|
793
914
|
/** Output only. Traffic type. This shows whether a request consumes Pay-As-You-Go or Provisioned Throughput quota. */
|
|
794
915
|
var TrafficType;
|
|
@@ -1323,26 +1444,6 @@ var TurnCoverage;
|
|
|
1323
1444
|
*/
|
|
1324
1445
|
TurnCoverage["TURN_INCLUDES_ALL_INPUT"] = "TURN_INCLUDES_ALL_INPUT";
|
|
1325
1446
|
})(TurnCoverage || (TurnCoverage = {}));
|
|
1326
|
-
/** Specifies how the response should be scheduled in the conversation. */
|
|
1327
|
-
var FunctionResponseScheduling;
|
|
1328
|
-
(function (FunctionResponseScheduling) {
|
|
1329
|
-
/**
|
|
1330
|
-
* This value is unused.
|
|
1331
|
-
*/
|
|
1332
|
-
FunctionResponseScheduling["SCHEDULING_UNSPECIFIED"] = "SCHEDULING_UNSPECIFIED";
|
|
1333
|
-
/**
|
|
1334
|
-
* Only add the result to the conversation context, do not interrupt or trigger generation.
|
|
1335
|
-
*/
|
|
1336
|
-
FunctionResponseScheduling["SILENT"] = "SILENT";
|
|
1337
|
-
/**
|
|
1338
|
-
* Add the result to the conversation context, and prompt to generate output without interrupting ongoing generation.
|
|
1339
|
-
*/
|
|
1340
|
-
FunctionResponseScheduling["WHEN_IDLE"] = "WHEN_IDLE";
|
|
1341
|
-
/**
|
|
1342
|
-
* Add the result to the conversation context, interrupt ongoing generation and prompt to generate output.
|
|
1343
|
-
*/
|
|
1344
|
-
FunctionResponseScheduling["INTERRUPT"] = "INTERRUPT";
|
|
1345
|
-
})(FunctionResponseScheduling || (FunctionResponseScheduling = {}));
|
|
1346
1447
|
/** Scale of the generated music. */
|
|
1347
1448
|
var Scale;
|
|
1348
1449
|
(function (Scale) {
|
|
@@ -1640,7 +1741,7 @@ class HttpResponse {
|
|
|
1640
1741
|
return this.responseInternal.json();
|
|
1641
1742
|
}
|
|
1642
1743
|
}
|
|
1643
|
-
/** Content filter results for a prompt sent in the request. */
|
|
1744
|
+
/** 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. */
|
|
1644
1745
|
class GenerateContentResponsePromptFeedback {
|
|
1645
1746
|
}
|
|
1646
1747
|
/** Usage metadata about response(s). */
|
|
@@ -3510,6 +3611,7 @@ function embedContentBatchToMldev(apiClient, fromObject) {
|
|
|
3510
3611
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
3511
3612
|
if (fromConfig != null) {
|
|
3512
3613
|
setValueByPath(toObject, ['_self'], embedContentConfigToMldev$1(fromConfig, toObject));
|
|
3614
|
+
moveValueByPath(toObject, { 'requests[].*': 'requests[].request.*' });
|
|
3513
3615
|
}
|
|
3514
3616
|
return toObject;
|
|
3515
3617
|
}
|
|
@@ -4291,38 +4393,11 @@ class Batches extends BaseModule {
|
|
|
4291
4393
|
* ```
|
|
4292
4394
|
*/
|
|
4293
4395
|
this.createEmbeddings = async (params) => {
|
|
4294
|
-
var _a, _b;
|
|
4295
4396
|
console.warn('batches.createEmbeddings() is experimental and may change without notice.');
|
|
4296
4397
|
if (this.apiClient.isVertexAI()) {
|
|
4297
4398
|
throw new Error('Vertex AI does not support batches.createEmbeddings.');
|
|
4298
4399
|
}
|
|
4299
|
-
|
|
4300
|
-
const src = params.src;
|
|
4301
|
-
const is_inlined = src.inlinedRequests !== undefined;
|
|
4302
|
-
if (!is_inlined) {
|
|
4303
|
-
return this.createEmbeddingsInternal(params); // Fixed typo here
|
|
4304
|
-
}
|
|
4305
|
-
// Inlined embed content requests handling
|
|
4306
|
-
const result = this.createInlinedEmbedContentRequest(params);
|
|
4307
|
-
const path = result.path;
|
|
4308
|
-
const requestBody = result.body;
|
|
4309
|
-
const queryParams = createEmbeddingsBatchJobParametersToMldev(this.apiClient, params)['_query'] || {};
|
|
4310
|
-
const response = this.apiClient
|
|
4311
|
-
.request({
|
|
4312
|
-
path: path,
|
|
4313
|
-
queryParams: queryParams,
|
|
4314
|
-
body: JSON.stringify(requestBody),
|
|
4315
|
-
httpMethod: 'POST',
|
|
4316
|
-
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
4317
|
-
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
4318
|
-
})
|
|
4319
|
-
.then((httpResponse) => {
|
|
4320
|
-
return httpResponse.json();
|
|
4321
|
-
});
|
|
4322
|
-
return response.then((apiResponse) => {
|
|
4323
|
-
const resp = batchJobFromMldev(apiResponse);
|
|
4324
|
-
return resp;
|
|
4325
|
-
});
|
|
4400
|
+
return this.createEmbeddingsInternal(params);
|
|
4326
4401
|
};
|
|
4327
4402
|
/**
|
|
4328
4403
|
* Lists batch job configurations.
|
|
@@ -4370,35 +4445,6 @@ class Batches extends BaseModule {
|
|
|
4370
4445
|
delete body['_query'];
|
|
4371
4446
|
return { path, body };
|
|
4372
4447
|
}
|
|
4373
|
-
// Helper function to handle inlined embedding requests
|
|
4374
|
-
createInlinedEmbedContentRequest(params) {
|
|
4375
|
-
const body = createEmbeddingsBatchJobParametersToMldev(this.apiClient, // Use instance apiClient
|
|
4376
|
-
params);
|
|
4377
|
-
const urlParams = body['_url'];
|
|
4378
|
-
const path = formatMap('{model}:asyncBatchEmbedContent', urlParams);
|
|
4379
|
-
const batch = body['batch'];
|
|
4380
|
-
const inputConfig = batch['inputConfig'];
|
|
4381
|
-
const requestsWrapper = inputConfig['requests'];
|
|
4382
|
-
const requests = requestsWrapper['requests'];
|
|
4383
|
-
const newRequests = [];
|
|
4384
|
-
delete requestsWrapper['config']; // Remove top-level config
|
|
4385
|
-
for (const request of requests) {
|
|
4386
|
-
const requestDict = Object.assign({}, request); // Clone
|
|
4387
|
-
const innerRequest = requestDict['request'];
|
|
4388
|
-
for (const key in requestDict) {
|
|
4389
|
-
if (key !== 'request') {
|
|
4390
|
-
innerRequest[key] = requestDict[key];
|
|
4391
|
-
delete requestDict[key];
|
|
4392
|
-
}
|
|
4393
|
-
}
|
|
4394
|
-
newRequests.push(requestDict);
|
|
4395
|
-
}
|
|
4396
|
-
requestsWrapper['requests'] = newRequests;
|
|
4397
|
-
delete body['config'];
|
|
4398
|
-
delete body['_url'];
|
|
4399
|
-
delete body['_query'];
|
|
4400
|
-
return { path, body };
|
|
4401
|
-
}
|
|
4402
4448
|
// Helper function to get the first GCS URI
|
|
4403
4449
|
getGcsUri(src) {
|
|
4404
4450
|
if (typeof src === 'string') {
|
|
@@ -6750,6 +6796,10 @@ function generationConfigToVertex$1(fromObject) {
|
|
|
6750
6796
|
if (fromTopP != null) {
|
|
6751
6797
|
setValueByPath(toObject, ['topP'], fromTopP);
|
|
6752
6798
|
}
|
|
6799
|
+
if (getValueByPath(fromObject, ['enableEnhancedCivicAnswers']) !==
|
|
6800
|
+
undefined) {
|
|
6801
|
+
throw new Error('enableEnhancedCivicAnswers parameter is not supported in Vertex AI.');
|
|
6802
|
+
}
|
|
6753
6803
|
return toObject;
|
|
6754
6804
|
}
|
|
6755
6805
|
function googleMapsToMldev$2(fromObject) {
|
|
@@ -9273,7 +9323,7 @@ function generatedImageMaskFromVertex(fromObject) {
|
|
|
9273
9323
|
}
|
|
9274
9324
|
function generatedVideoFromMldev(fromObject) {
|
|
9275
9325
|
const toObject = {};
|
|
9276
|
-
const fromVideo = getValueByPath(fromObject, ['
|
|
9326
|
+
const fromVideo = getValueByPath(fromObject, ['video']);
|
|
9277
9327
|
if (fromVideo != null) {
|
|
9278
9328
|
setValueByPath(toObject, ['video'], videoFromMldev(fromVideo));
|
|
9279
9329
|
}
|
|
@@ -9409,6 +9459,10 @@ function generationConfigToVertex(fromObject) {
|
|
|
9409
9459
|
if (fromTopP != null) {
|
|
9410
9460
|
setValueByPath(toObject, ['topP'], fromTopP);
|
|
9411
9461
|
}
|
|
9462
|
+
if (getValueByPath(fromObject, ['enableEnhancedCivicAnswers']) !==
|
|
9463
|
+
undefined) {
|
|
9464
|
+
throw new Error('enableEnhancedCivicAnswers parameter is not supported in Vertex AI.');
|
|
9465
|
+
}
|
|
9412
9466
|
return toObject;
|
|
9413
9467
|
}
|
|
9414
9468
|
function getModelParametersToMldev(apiClient, fromObject) {
|
|
@@ -10419,14 +10473,11 @@ function upscaleImageResponseFromVertex(fromObject) {
|
|
|
10419
10473
|
}
|
|
10420
10474
|
function videoFromMldev(fromObject) {
|
|
10421
10475
|
const toObject = {};
|
|
10422
|
-
const fromUri = getValueByPath(fromObject, ['
|
|
10476
|
+
const fromUri = getValueByPath(fromObject, ['uri']);
|
|
10423
10477
|
if (fromUri != null) {
|
|
10424
10478
|
setValueByPath(toObject, ['uri'], fromUri);
|
|
10425
10479
|
}
|
|
10426
|
-
const fromVideoBytes = getValueByPath(fromObject, [
|
|
10427
|
-
'video',
|
|
10428
|
-
'encodedVideo',
|
|
10429
|
-
]);
|
|
10480
|
+
const fromVideoBytes = getValueByPath(fromObject, ['encodedVideo']);
|
|
10430
10481
|
if (fromVideoBytes != null) {
|
|
10431
10482
|
setValueByPath(toObject, ['videoBytes'], tBytes(fromVideoBytes));
|
|
10432
10483
|
}
|
|
@@ -10498,11 +10549,11 @@ function videoToMldev(fromObject) {
|
|
|
10498
10549
|
const toObject = {};
|
|
10499
10550
|
const fromUri = getValueByPath(fromObject, ['uri']);
|
|
10500
10551
|
if (fromUri != null) {
|
|
10501
|
-
setValueByPath(toObject, ['
|
|
10552
|
+
setValueByPath(toObject, ['uri'], fromUri);
|
|
10502
10553
|
}
|
|
10503
10554
|
const fromVideoBytes = getValueByPath(fromObject, ['videoBytes']);
|
|
10504
10555
|
if (fromVideoBytes != null) {
|
|
10505
|
-
setValueByPath(toObject, ['
|
|
10556
|
+
setValueByPath(toObject, ['encodedVideo'], tBytes(fromVideoBytes));
|
|
10506
10557
|
}
|
|
10507
10558
|
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
10508
10559
|
if (fromMimeType != null) {
|
|
@@ -10536,7 +10587,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
10536
10587
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
10537
10588
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
10538
10589
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
10539
|
-
const SDK_VERSION = '1.
|
|
10590
|
+
const SDK_VERSION = '1.26.0'; // x-release-please-version
|
|
10540
10591
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
10541
10592
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
10542
10593
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -12314,9 +12365,26 @@ class Models extends BaseModule {
|
|
|
12314
12365
|
* ```
|
|
12315
12366
|
*/
|
|
12316
12367
|
this.generateVideos = async (params) => {
|
|
12368
|
+
var _a, _b, _c, _d, _e, _f;
|
|
12317
12369
|
if ((params.prompt || params.image || params.video) && params.source) {
|
|
12318
12370
|
throw new Error('Source and prompt/image/video are mutually exclusive. Please only use source.');
|
|
12319
12371
|
}
|
|
12372
|
+
// Gemini API does not support video bytes.
|
|
12373
|
+
if (!this.apiClient.isVertexAI()) {
|
|
12374
|
+
if (((_a = params.video) === null || _a === void 0 ? void 0 : _a.uri) && ((_b = params.video) === null || _b === void 0 ? void 0 : _b.videoBytes)) {
|
|
12375
|
+
params.video = {
|
|
12376
|
+
uri: params.video.uri,
|
|
12377
|
+
mimeType: params.video.mimeType,
|
|
12378
|
+
};
|
|
12379
|
+
}
|
|
12380
|
+
else if (((_d = (_c = params.source) === null || _c === void 0 ? void 0 : _c.video) === null || _d === void 0 ? void 0 : _d.uri) &&
|
|
12381
|
+
((_f = (_e = params.source) === null || _e === void 0 ? void 0 : _e.video) === null || _f === void 0 ? void 0 : _f.videoBytes)) {
|
|
12382
|
+
params.source.video = {
|
|
12383
|
+
uri: params.source.video.uri,
|
|
12384
|
+
mimeType: params.source.video.mimeType,
|
|
12385
|
+
};
|
|
12386
|
+
}
|
|
12387
|
+
}
|
|
12320
12388
|
return await this.generateVideosInternal(params);
|
|
12321
12389
|
};
|
|
12322
12390
|
}
|
|
@@ -14657,46 +14725,6 @@ function tuningJobFromMldev(fromObject) {
|
|
|
14657
14725
|
if (fromTunedModel != null) {
|
|
14658
14726
|
setValueByPath(toObject, ['tunedModel'], tunedModelFromMldev(fromTunedModel));
|
|
14659
14727
|
}
|
|
14660
|
-
const fromCustomBaseModel = getValueByPath(fromObject, [
|
|
14661
|
-
'customBaseModel',
|
|
14662
|
-
]);
|
|
14663
|
-
if (fromCustomBaseModel != null) {
|
|
14664
|
-
setValueByPath(toObject, ['customBaseModel'], fromCustomBaseModel);
|
|
14665
|
-
}
|
|
14666
|
-
const fromExperiment = getValueByPath(fromObject, ['experiment']);
|
|
14667
|
-
if (fromExperiment != null) {
|
|
14668
|
-
setValueByPath(toObject, ['experiment'], fromExperiment);
|
|
14669
|
-
}
|
|
14670
|
-
const fromLabels = getValueByPath(fromObject, ['labels']);
|
|
14671
|
-
if (fromLabels != null) {
|
|
14672
|
-
setValueByPath(toObject, ['labels'], fromLabels);
|
|
14673
|
-
}
|
|
14674
|
-
const fromOutputUri = getValueByPath(fromObject, ['outputUri']);
|
|
14675
|
-
if (fromOutputUri != null) {
|
|
14676
|
-
setValueByPath(toObject, ['outputUri'], fromOutputUri);
|
|
14677
|
-
}
|
|
14678
|
-
const fromPipelineJob = getValueByPath(fromObject, ['pipelineJob']);
|
|
14679
|
-
if (fromPipelineJob != null) {
|
|
14680
|
-
setValueByPath(toObject, ['pipelineJob'], fromPipelineJob);
|
|
14681
|
-
}
|
|
14682
|
-
const fromServiceAccount = getValueByPath(fromObject, [
|
|
14683
|
-
'serviceAccount',
|
|
14684
|
-
]);
|
|
14685
|
-
if (fromServiceAccount != null) {
|
|
14686
|
-
setValueByPath(toObject, ['serviceAccount'], fromServiceAccount);
|
|
14687
|
-
}
|
|
14688
|
-
const fromTunedModelDisplayName = getValueByPath(fromObject, [
|
|
14689
|
-
'tunedModelDisplayName',
|
|
14690
|
-
]);
|
|
14691
|
-
if (fromTunedModelDisplayName != null) {
|
|
14692
|
-
setValueByPath(toObject, ['tunedModelDisplayName'], fromTunedModelDisplayName);
|
|
14693
|
-
}
|
|
14694
|
-
const fromVeoTuningSpec = getValueByPath(fromObject, [
|
|
14695
|
-
'veoTuningSpec',
|
|
14696
|
-
]);
|
|
14697
|
-
if (fromVeoTuningSpec != null) {
|
|
14698
|
-
setValueByPath(toObject, ['veoTuningSpec'], fromVeoTuningSpec);
|
|
14699
|
-
}
|
|
14700
14728
|
return toObject;
|
|
14701
14729
|
}
|
|
14702
14730
|
function tuningJobFromVertex(fromObject) {
|