@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/index.cjs
CHANGED
|
@@ -165,6 +165,98 @@ function getValueByPath(data, keys, defaultValue = undefined) {
|
|
|
165
165
|
throw error;
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* Moves values from source paths to destination paths.
|
|
170
|
+
*
|
|
171
|
+
* Examples:
|
|
172
|
+
* moveValueByPath(
|
|
173
|
+
* {'requests': [{'content': v1}, {'content': v2}]},
|
|
174
|
+
* {'requests[].*': 'requests[].request.*'}
|
|
175
|
+
* )
|
|
176
|
+
* -> {'requests': [{'request': {'content': v1}}, {'request': {'content': v2}}]}
|
|
177
|
+
*/
|
|
178
|
+
function moveValueByPath(data, paths) {
|
|
179
|
+
for (const [sourcePath, destPath] of Object.entries(paths)) {
|
|
180
|
+
const sourceKeys = sourcePath.split('.');
|
|
181
|
+
const destKeys = destPath.split('.');
|
|
182
|
+
// Determine keys to exclude from wildcard to avoid cyclic references
|
|
183
|
+
const excludeKeys = new Set();
|
|
184
|
+
let wildcardIdx = -1;
|
|
185
|
+
for (let i = 0; i < sourceKeys.length; i++) {
|
|
186
|
+
if (sourceKeys[i] === '*') {
|
|
187
|
+
wildcardIdx = i;
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
if (wildcardIdx !== -1 && destKeys.length > wildcardIdx) {
|
|
192
|
+
// Extract the intermediate key between source and dest paths
|
|
193
|
+
// Example: source=['requests[]', '*'], dest=['requests[]', 'request', '*']
|
|
194
|
+
// We want to exclude 'request'
|
|
195
|
+
for (let i = wildcardIdx; i < destKeys.length; i++) {
|
|
196
|
+
const key = destKeys[i];
|
|
197
|
+
if (key !== '*' && !key.endsWith('[]') && !key.endsWith('[0]')) {
|
|
198
|
+
excludeKeys.add(key);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
_moveValueRecursive(data, sourceKeys, destKeys, 0, excludeKeys);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Recursively moves values from source path to destination path.
|
|
207
|
+
*/
|
|
208
|
+
function _moveValueRecursive(data, sourceKeys, destKeys, keyIdx, excludeKeys) {
|
|
209
|
+
if (keyIdx >= sourceKeys.length) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
if (typeof data !== 'object' || data === null) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
const key = sourceKeys[keyIdx];
|
|
216
|
+
if (key.endsWith('[]')) {
|
|
217
|
+
const keyName = key.slice(0, -2);
|
|
218
|
+
const dataRecord = data;
|
|
219
|
+
if (keyName in dataRecord && Array.isArray(dataRecord[keyName])) {
|
|
220
|
+
for (const item of dataRecord[keyName]) {
|
|
221
|
+
_moveValueRecursive(item, sourceKeys, destKeys, keyIdx + 1, excludeKeys);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
else if (key === '*') {
|
|
226
|
+
// wildcard - move all fields
|
|
227
|
+
if (typeof data === 'object' && data !== null && !Array.isArray(data)) {
|
|
228
|
+
const dataRecord = data;
|
|
229
|
+
const keysToMove = Object.keys(dataRecord).filter((k) => !k.startsWith('_') && !excludeKeys.has(k));
|
|
230
|
+
const valuesToMove = {};
|
|
231
|
+
for (const k of keysToMove) {
|
|
232
|
+
valuesToMove[k] = dataRecord[k];
|
|
233
|
+
}
|
|
234
|
+
// Set values at destination
|
|
235
|
+
for (const [k, v] of Object.entries(valuesToMove)) {
|
|
236
|
+
const newDestKeys = [];
|
|
237
|
+
for (const dk of destKeys.slice(keyIdx)) {
|
|
238
|
+
if (dk === '*') {
|
|
239
|
+
newDestKeys.push(k);
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
newDestKeys.push(dk);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
setValueByPath(dataRecord, newDestKeys, v);
|
|
246
|
+
}
|
|
247
|
+
for (const k of keysToMove) {
|
|
248
|
+
delete dataRecord[k];
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
// Navigate to next level
|
|
254
|
+
const dataRecord = data;
|
|
255
|
+
if (key in dataRecord) {
|
|
256
|
+
_moveValueRecursive(dataRecord[key], sourceKeys, destKeys, keyIdx + 1, excludeKeys);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
168
260
|
|
|
169
261
|
/**
|
|
170
262
|
* @license
|
|
@@ -306,7 +398,7 @@ function generateVideosResponseFromVertex$1(fromObject) {
|
|
|
306
398
|
}
|
|
307
399
|
function generatedVideoFromMldev$1(fromObject) {
|
|
308
400
|
const toObject = {};
|
|
309
|
-
const fromVideo = getValueByPath(fromObject, ['
|
|
401
|
+
const fromVideo = getValueByPath(fromObject, ['video']);
|
|
310
402
|
if (fromVideo != null) {
|
|
311
403
|
setValueByPath(toObject, ['video'], videoFromMldev$1(fromVideo));
|
|
312
404
|
}
|
|
@@ -342,14 +434,11 @@ function getOperationParametersToVertex(fromObject) {
|
|
|
342
434
|
}
|
|
343
435
|
function videoFromMldev$1(fromObject) {
|
|
344
436
|
const toObject = {};
|
|
345
|
-
const fromUri = getValueByPath(fromObject, ['
|
|
437
|
+
const fromUri = getValueByPath(fromObject, ['uri']);
|
|
346
438
|
if (fromUri != null) {
|
|
347
439
|
setValueByPath(toObject, ['uri'], fromUri);
|
|
348
440
|
}
|
|
349
|
-
const fromVideoBytes = getValueByPath(fromObject, [
|
|
350
|
-
'video',
|
|
351
|
-
'encodedVideo',
|
|
352
|
-
]);
|
|
441
|
+
const fromVideoBytes = getValueByPath(fromObject, ['encodedVideo']);
|
|
353
442
|
if (fromVideoBytes != null) {
|
|
354
443
|
setValueByPath(toObject, ['videoBytes'], tBytes$1(fromVideoBytes));
|
|
355
444
|
}
|
|
@@ -415,6 +504,26 @@ exports.Language = void 0;
|
|
|
415
504
|
*/
|
|
416
505
|
Language["PYTHON"] = "PYTHON";
|
|
417
506
|
})(exports.Language || (exports.Language = {}));
|
|
507
|
+
/** Specifies how the response should be scheduled in the conversation. */
|
|
508
|
+
exports.FunctionResponseScheduling = void 0;
|
|
509
|
+
(function (FunctionResponseScheduling) {
|
|
510
|
+
/**
|
|
511
|
+
* This value is unused.
|
|
512
|
+
*/
|
|
513
|
+
FunctionResponseScheduling["SCHEDULING_UNSPECIFIED"] = "SCHEDULING_UNSPECIFIED";
|
|
514
|
+
/**
|
|
515
|
+
* Only add the result to the conversation context, do not interrupt or trigger generation.
|
|
516
|
+
*/
|
|
517
|
+
FunctionResponseScheduling["SILENT"] = "SILENT";
|
|
518
|
+
/**
|
|
519
|
+
* Add the result to the conversation context, and prompt to generate output without interrupting ongoing generation.
|
|
520
|
+
*/
|
|
521
|
+
FunctionResponseScheduling["WHEN_IDLE"] = "WHEN_IDLE";
|
|
522
|
+
/**
|
|
523
|
+
* Add the result to the conversation context, interrupt ongoing generation and prompt to generate output.
|
|
524
|
+
*/
|
|
525
|
+
FunctionResponseScheduling["INTERRUPT"] = "INTERRUPT";
|
|
526
|
+
})(exports.FunctionResponseScheduling || (exports.FunctionResponseScheduling = {}));
|
|
418
527
|
/** Optional. The type of the data. */
|
|
419
528
|
exports.Type = void 0;
|
|
420
529
|
(function (Type) {
|
|
@@ -458,22 +567,22 @@ exports.HarmCategory = void 0;
|
|
|
458
567
|
* The harm category is unspecified.
|
|
459
568
|
*/
|
|
460
569
|
HarmCategory["HARM_CATEGORY_UNSPECIFIED"] = "HARM_CATEGORY_UNSPECIFIED";
|
|
461
|
-
/**
|
|
462
|
-
* The harm category is hate speech.
|
|
463
|
-
*/
|
|
464
|
-
HarmCategory["HARM_CATEGORY_HATE_SPEECH"] = "HARM_CATEGORY_HATE_SPEECH";
|
|
465
|
-
/**
|
|
466
|
-
* The harm category is dangerous content.
|
|
467
|
-
*/
|
|
468
|
-
HarmCategory["HARM_CATEGORY_DANGEROUS_CONTENT"] = "HARM_CATEGORY_DANGEROUS_CONTENT";
|
|
469
570
|
/**
|
|
470
571
|
* The harm category is harassment.
|
|
471
572
|
*/
|
|
472
573
|
HarmCategory["HARM_CATEGORY_HARASSMENT"] = "HARM_CATEGORY_HARASSMENT";
|
|
574
|
+
/**
|
|
575
|
+
* The harm category is hate speech.
|
|
576
|
+
*/
|
|
577
|
+
HarmCategory["HARM_CATEGORY_HATE_SPEECH"] = "HARM_CATEGORY_HATE_SPEECH";
|
|
473
578
|
/**
|
|
474
579
|
* The harm category is sexually explicit content.
|
|
475
580
|
*/
|
|
476
581
|
HarmCategory["HARM_CATEGORY_SEXUALLY_EXPLICIT"] = "HARM_CATEGORY_SEXUALLY_EXPLICIT";
|
|
582
|
+
/**
|
|
583
|
+
* The harm category is dangerous content.
|
|
584
|
+
*/
|
|
585
|
+
HarmCategory["HARM_CATEGORY_DANGEROUS_CONTENT"] = "HARM_CATEGORY_DANGEROUS_CONTENT";
|
|
477
586
|
/**
|
|
478
587
|
* Deprecated: Election filter is not longer supported. The harm category is civic integrity.
|
|
479
588
|
*/
|
|
@@ -494,6 +603,10 @@ exports.HarmCategory = void 0;
|
|
|
494
603
|
* The harm category is image sexually explicit content.
|
|
495
604
|
*/
|
|
496
605
|
HarmCategory["HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT"] = "HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT";
|
|
606
|
+
/**
|
|
607
|
+
* The harm category is for jailbreak prompts.
|
|
608
|
+
*/
|
|
609
|
+
HarmCategory["HARM_CATEGORY_JAILBREAK"] = "HARM_CATEGORY_JAILBREAK";
|
|
497
610
|
})(exports.HarmCategory || (exports.HarmCategory = {}));
|
|
498
611
|
/** Optional. Specify if the threshold is used for probability or severity score. If not specified, the threshold is used for probability score. */
|
|
499
612
|
exports.HarmBlockMethod = void 0;
|
|
@@ -734,33 +847,41 @@ exports.HarmSeverity = void 0;
|
|
|
734
847
|
*/
|
|
735
848
|
HarmSeverity["HARM_SEVERITY_HIGH"] = "HARM_SEVERITY_HIGH";
|
|
736
849
|
})(exports.HarmSeverity || (exports.HarmSeverity = {}));
|
|
737
|
-
/** Output only.
|
|
850
|
+
/** Output only. The reason why the prompt was blocked. */
|
|
738
851
|
exports.BlockedReason = void 0;
|
|
739
852
|
(function (BlockedReason) {
|
|
740
853
|
/**
|
|
741
|
-
*
|
|
854
|
+
* The blocked reason is unspecified.
|
|
742
855
|
*/
|
|
743
856
|
BlockedReason["BLOCKED_REASON_UNSPECIFIED"] = "BLOCKED_REASON_UNSPECIFIED";
|
|
744
857
|
/**
|
|
745
|
-
*
|
|
858
|
+
* The prompt was blocked for safety reasons.
|
|
746
859
|
*/
|
|
747
860
|
BlockedReason["SAFETY"] = "SAFETY";
|
|
748
861
|
/**
|
|
749
|
-
*
|
|
862
|
+
* 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.
|
|
750
863
|
*/
|
|
751
864
|
BlockedReason["OTHER"] = "OTHER";
|
|
752
865
|
/**
|
|
753
|
-
*
|
|
866
|
+
* The prompt was blocked because it contains a term from the terminology blocklist.
|
|
754
867
|
*/
|
|
755
868
|
BlockedReason["BLOCKLIST"] = "BLOCKLIST";
|
|
756
869
|
/**
|
|
757
|
-
*
|
|
870
|
+
* The prompt was blocked because it contains prohibited content.
|
|
758
871
|
*/
|
|
759
872
|
BlockedReason["PROHIBITED_CONTENT"] = "PROHIBITED_CONTENT";
|
|
760
873
|
/**
|
|
761
|
-
*
|
|
874
|
+
* The prompt was blocked because it contains content that is unsafe for image generation.
|
|
762
875
|
*/
|
|
763
876
|
BlockedReason["IMAGE_SAFETY"] = "IMAGE_SAFETY";
|
|
877
|
+
/**
|
|
878
|
+
* The prompt was blocked by Model Armor.
|
|
879
|
+
*/
|
|
880
|
+
BlockedReason["MODEL_ARMOR"] = "MODEL_ARMOR";
|
|
881
|
+
/**
|
|
882
|
+
* The prompt was blocked as a jailbreak attempt.
|
|
883
|
+
*/
|
|
884
|
+
BlockedReason["JAILBREAK"] = "JAILBREAK";
|
|
764
885
|
})(exports.BlockedReason || (exports.BlockedReason = {}));
|
|
765
886
|
/** Output only. Traffic type. This shows whether a request consumes Pay-As-You-Go or Provisioned Throughput quota. */
|
|
766
887
|
exports.TrafficType = void 0;
|
|
@@ -1295,26 +1416,6 @@ exports.TurnCoverage = void 0;
|
|
|
1295
1416
|
*/
|
|
1296
1417
|
TurnCoverage["TURN_INCLUDES_ALL_INPUT"] = "TURN_INCLUDES_ALL_INPUT";
|
|
1297
1418
|
})(exports.TurnCoverage || (exports.TurnCoverage = {}));
|
|
1298
|
-
/** Specifies how the response should be scheduled in the conversation. */
|
|
1299
|
-
exports.FunctionResponseScheduling = void 0;
|
|
1300
|
-
(function (FunctionResponseScheduling) {
|
|
1301
|
-
/**
|
|
1302
|
-
* This value is unused.
|
|
1303
|
-
*/
|
|
1304
|
-
FunctionResponseScheduling["SCHEDULING_UNSPECIFIED"] = "SCHEDULING_UNSPECIFIED";
|
|
1305
|
-
/**
|
|
1306
|
-
* Only add the result to the conversation context, do not interrupt or trigger generation.
|
|
1307
|
-
*/
|
|
1308
|
-
FunctionResponseScheduling["SILENT"] = "SILENT";
|
|
1309
|
-
/**
|
|
1310
|
-
* Add the result to the conversation context, and prompt to generate output without interrupting ongoing generation.
|
|
1311
|
-
*/
|
|
1312
|
-
FunctionResponseScheduling["WHEN_IDLE"] = "WHEN_IDLE";
|
|
1313
|
-
/**
|
|
1314
|
-
* Add the result to the conversation context, interrupt ongoing generation and prompt to generate output.
|
|
1315
|
-
*/
|
|
1316
|
-
FunctionResponseScheduling["INTERRUPT"] = "INTERRUPT";
|
|
1317
|
-
})(exports.FunctionResponseScheduling || (exports.FunctionResponseScheduling = {}));
|
|
1318
1419
|
/** Scale of the generated music. */
|
|
1319
1420
|
exports.Scale = void 0;
|
|
1320
1421
|
(function (Scale) {
|
|
@@ -1612,7 +1713,7 @@ class HttpResponse {
|
|
|
1612
1713
|
return this.responseInternal.json();
|
|
1613
1714
|
}
|
|
1614
1715
|
}
|
|
1615
|
-
/** Content filter results for a prompt sent in the request. */
|
|
1716
|
+
/** 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. */
|
|
1616
1717
|
class GenerateContentResponsePromptFeedback {
|
|
1617
1718
|
}
|
|
1618
1719
|
/** Usage metadata about response(s). */
|
|
@@ -3482,6 +3583,7 @@ function embedContentBatchToMldev(apiClient, fromObject) {
|
|
|
3482
3583
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
3483
3584
|
if (fromConfig != null) {
|
|
3484
3585
|
setValueByPath(toObject, ['_self'], embedContentConfigToMldev$1(fromConfig, toObject));
|
|
3586
|
+
moveValueByPath(toObject, { 'requests[].*': 'requests[].request.*' });
|
|
3485
3587
|
}
|
|
3486
3588
|
return toObject;
|
|
3487
3589
|
}
|
|
@@ -4263,38 +4365,11 @@ class Batches extends BaseModule {
|
|
|
4263
4365
|
* ```
|
|
4264
4366
|
*/
|
|
4265
4367
|
this.createEmbeddings = async (params) => {
|
|
4266
|
-
var _a, _b;
|
|
4267
4368
|
console.warn('batches.createEmbeddings() is experimental and may change without notice.');
|
|
4268
4369
|
if (this.apiClient.isVertexAI()) {
|
|
4269
4370
|
throw new Error('Vertex AI does not support batches.createEmbeddings.');
|
|
4270
4371
|
}
|
|
4271
|
-
|
|
4272
|
-
const src = params.src;
|
|
4273
|
-
const is_inlined = src.inlinedRequests !== undefined;
|
|
4274
|
-
if (!is_inlined) {
|
|
4275
|
-
return this.createEmbeddingsInternal(params); // Fixed typo here
|
|
4276
|
-
}
|
|
4277
|
-
// Inlined embed content requests handling
|
|
4278
|
-
const result = this.createInlinedEmbedContentRequest(params);
|
|
4279
|
-
const path = result.path;
|
|
4280
|
-
const requestBody = result.body;
|
|
4281
|
-
const queryParams = createEmbeddingsBatchJobParametersToMldev(this.apiClient, params)['_query'] || {};
|
|
4282
|
-
const response = this.apiClient
|
|
4283
|
-
.request({
|
|
4284
|
-
path: path,
|
|
4285
|
-
queryParams: queryParams,
|
|
4286
|
-
body: JSON.stringify(requestBody),
|
|
4287
|
-
httpMethod: 'POST',
|
|
4288
|
-
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
4289
|
-
abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
|
|
4290
|
-
})
|
|
4291
|
-
.then((httpResponse) => {
|
|
4292
|
-
return httpResponse.json();
|
|
4293
|
-
});
|
|
4294
|
-
return response.then((apiResponse) => {
|
|
4295
|
-
const resp = batchJobFromMldev(apiResponse);
|
|
4296
|
-
return resp;
|
|
4297
|
-
});
|
|
4372
|
+
return this.createEmbeddingsInternal(params);
|
|
4298
4373
|
};
|
|
4299
4374
|
/**
|
|
4300
4375
|
* Lists batch job configurations.
|
|
@@ -4342,35 +4417,6 @@ class Batches extends BaseModule {
|
|
|
4342
4417
|
delete body['_query'];
|
|
4343
4418
|
return { path, body };
|
|
4344
4419
|
}
|
|
4345
|
-
// Helper function to handle inlined embedding requests
|
|
4346
|
-
createInlinedEmbedContentRequest(params) {
|
|
4347
|
-
const body = createEmbeddingsBatchJobParametersToMldev(this.apiClient, // Use instance apiClient
|
|
4348
|
-
params);
|
|
4349
|
-
const urlParams = body['_url'];
|
|
4350
|
-
const path = formatMap('{model}:asyncBatchEmbedContent', urlParams);
|
|
4351
|
-
const batch = body['batch'];
|
|
4352
|
-
const inputConfig = batch['inputConfig'];
|
|
4353
|
-
const requestsWrapper = inputConfig['requests'];
|
|
4354
|
-
const requests = requestsWrapper['requests'];
|
|
4355
|
-
const newRequests = [];
|
|
4356
|
-
delete requestsWrapper['config']; // Remove top-level config
|
|
4357
|
-
for (const request of requests) {
|
|
4358
|
-
const requestDict = Object.assign({}, request); // Clone
|
|
4359
|
-
const innerRequest = requestDict['request'];
|
|
4360
|
-
for (const key in requestDict) {
|
|
4361
|
-
if (key !== 'request') {
|
|
4362
|
-
innerRequest[key] = requestDict[key];
|
|
4363
|
-
delete requestDict[key];
|
|
4364
|
-
}
|
|
4365
|
-
}
|
|
4366
|
-
newRequests.push(requestDict);
|
|
4367
|
-
}
|
|
4368
|
-
requestsWrapper['requests'] = newRequests;
|
|
4369
|
-
delete body['config'];
|
|
4370
|
-
delete body['_url'];
|
|
4371
|
-
delete body['_query'];
|
|
4372
|
-
return { path, body };
|
|
4373
|
-
}
|
|
4374
4420
|
// Helper function to get the first GCS URI
|
|
4375
4421
|
getGcsUri(src) {
|
|
4376
4422
|
if (typeof src === 'string') {
|
|
@@ -6147,7 +6193,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
6147
6193
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
6148
6194
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
6149
6195
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
6150
|
-
const SDK_VERSION = '1.
|
|
6196
|
+
const SDK_VERSION = '1.26.0'; // x-release-please-version
|
|
6151
6197
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
6152
6198
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
6153
6199
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -7419,6 +7465,10 @@ function generationConfigToVertex$1(fromObject) {
|
|
|
7419
7465
|
if (fromTopP != null) {
|
|
7420
7466
|
setValueByPath(toObject, ['topP'], fromTopP);
|
|
7421
7467
|
}
|
|
7468
|
+
if (getValueByPath(fromObject, ['enableEnhancedCivicAnswers']) !==
|
|
7469
|
+
undefined) {
|
|
7470
|
+
throw new Error('enableEnhancedCivicAnswers parameter is not supported in Vertex AI.');
|
|
7471
|
+
}
|
|
7422
7472
|
return toObject;
|
|
7423
7473
|
}
|
|
7424
7474
|
function googleMapsToMldev$2(fromObject) {
|
|
@@ -9942,7 +9992,7 @@ function generatedImageMaskFromVertex(fromObject) {
|
|
|
9942
9992
|
}
|
|
9943
9993
|
function generatedVideoFromMldev(fromObject) {
|
|
9944
9994
|
const toObject = {};
|
|
9945
|
-
const fromVideo = getValueByPath(fromObject, ['
|
|
9995
|
+
const fromVideo = getValueByPath(fromObject, ['video']);
|
|
9946
9996
|
if (fromVideo != null) {
|
|
9947
9997
|
setValueByPath(toObject, ['video'], videoFromMldev(fromVideo));
|
|
9948
9998
|
}
|
|
@@ -10078,6 +10128,10 @@ function generationConfigToVertex(fromObject) {
|
|
|
10078
10128
|
if (fromTopP != null) {
|
|
10079
10129
|
setValueByPath(toObject, ['topP'], fromTopP);
|
|
10080
10130
|
}
|
|
10131
|
+
if (getValueByPath(fromObject, ['enableEnhancedCivicAnswers']) !==
|
|
10132
|
+
undefined) {
|
|
10133
|
+
throw new Error('enableEnhancedCivicAnswers parameter is not supported in Vertex AI.');
|
|
10134
|
+
}
|
|
10081
10135
|
return toObject;
|
|
10082
10136
|
}
|
|
10083
10137
|
function getModelParametersToMldev(apiClient, fromObject) {
|
|
@@ -11088,14 +11142,11 @@ function upscaleImageResponseFromVertex(fromObject) {
|
|
|
11088
11142
|
}
|
|
11089
11143
|
function videoFromMldev(fromObject) {
|
|
11090
11144
|
const toObject = {};
|
|
11091
|
-
const fromUri = getValueByPath(fromObject, ['
|
|
11145
|
+
const fromUri = getValueByPath(fromObject, ['uri']);
|
|
11092
11146
|
if (fromUri != null) {
|
|
11093
11147
|
setValueByPath(toObject, ['uri'], fromUri);
|
|
11094
11148
|
}
|
|
11095
|
-
const fromVideoBytes = getValueByPath(fromObject, [
|
|
11096
|
-
'video',
|
|
11097
|
-
'encodedVideo',
|
|
11098
|
-
]);
|
|
11149
|
+
const fromVideoBytes = getValueByPath(fromObject, ['encodedVideo']);
|
|
11099
11150
|
if (fromVideoBytes != null) {
|
|
11100
11151
|
setValueByPath(toObject, ['videoBytes'], tBytes(fromVideoBytes));
|
|
11101
11152
|
}
|
|
@@ -11167,11 +11218,11 @@ function videoToMldev(fromObject) {
|
|
|
11167
11218
|
const toObject = {};
|
|
11168
11219
|
const fromUri = getValueByPath(fromObject, ['uri']);
|
|
11169
11220
|
if (fromUri != null) {
|
|
11170
|
-
setValueByPath(toObject, ['
|
|
11221
|
+
setValueByPath(toObject, ['uri'], fromUri);
|
|
11171
11222
|
}
|
|
11172
11223
|
const fromVideoBytes = getValueByPath(fromObject, ['videoBytes']);
|
|
11173
11224
|
if (fromVideoBytes != null) {
|
|
11174
|
-
setValueByPath(toObject, ['
|
|
11225
|
+
setValueByPath(toObject, ['encodedVideo'], tBytes(fromVideoBytes));
|
|
11175
11226
|
}
|
|
11176
11227
|
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
11177
11228
|
if (fromMimeType != null) {
|
|
@@ -12409,9 +12460,26 @@ class Models extends BaseModule {
|
|
|
12409
12460
|
* ```
|
|
12410
12461
|
*/
|
|
12411
12462
|
this.generateVideos = async (params) => {
|
|
12463
|
+
var _a, _b, _c, _d, _e, _f;
|
|
12412
12464
|
if ((params.prompt || params.image || params.video) && params.source) {
|
|
12413
12465
|
throw new Error('Source and prompt/image/video are mutually exclusive. Please only use source.');
|
|
12414
12466
|
}
|
|
12467
|
+
// Gemini API does not support video bytes.
|
|
12468
|
+
if (!this.apiClient.isVertexAI()) {
|
|
12469
|
+
if (((_a = params.video) === null || _a === void 0 ? void 0 : _a.uri) && ((_b = params.video) === null || _b === void 0 ? void 0 : _b.videoBytes)) {
|
|
12470
|
+
params.video = {
|
|
12471
|
+
uri: params.video.uri,
|
|
12472
|
+
mimeType: params.video.mimeType,
|
|
12473
|
+
};
|
|
12474
|
+
}
|
|
12475
|
+
else if (((_d = (_c = params.source) === null || _c === void 0 ? void 0 : _c.video) === null || _d === void 0 ? void 0 : _d.uri) &&
|
|
12476
|
+
((_f = (_e = params.source) === null || _e === void 0 ? void 0 : _e.video) === null || _f === void 0 ? void 0 : _f.videoBytes)) {
|
|
12477
|
+
params.source.video = {
|
|
12478
|
+
uri: params.source.video.uri,
|
|
12479
|
+
mimeType: params.source.video.mimeType,
|
|
12480
|
+
};
|
|
12481
|
+
}
|
|
12482
|
+
}
|
|
12415
12483
|
return await this.generateVideosInternal(params);
|
|
12416
12484
|
};
|
|
12417
12485
|
}
|
|
@@ -14752,46 +14820,6 @@ function tuningJobFromMldev(fromObject) {
|
|
|
14752
14820
|
if (fromTunedModel != null) {
|
|
14753
14821
|
setValueByPath(toObject, ['tunedModel'], tunedModelFromMldev(fromTunedModel));
|
|
14754
14822
|
}
|
|
14755
|
-
const fromCustomBaseModel = getValueByPath(fromObject, [
|
|
14756
|
-
'customBaseModel',
|
|
14757
|
-
]);
|
|
14758
|
-
if (fromCustomBaseModel != null) {
|
|
14759
|
-
setValueByPath(toObject, ['customBaseModel'], fromCustomBaseModel);
|
|
14760
|
-
}
|
|
14761
|
-
const fromExperiment = getValueByPath(fromObject, ['experiment']);
|
|
14762
|
-
if (fromExperiment != null) {
|
|
14763
|
-
setValueByPath(toObject, ['experiment'], fromExperiment);
|
|
14764
|
-
}
|
|
14765
|
-
const fromLabels = getValueByPath(fromObject, ['labels']);
|
|
14766
|
-
if (fromLabels != null) {
|
|
14767
|
-
setValueByPath(toObject, ['labels'], fromLabels);
|
|
14768
|
-
}
|
|
14769
|
-
const fromOutputUri = getValueByPath(fromObject, ['outputUri']);
|
|
14770
|
-
if (fromOutputUri != null) {
|
|
14771
|
-
setValueByPath(toObject, ['outputUri'], fromOutputUri);
|
|
14772
|
-
}
|
|
14773
|
-
const fromPipelineJob = getValueByPath(fromObject, ['pipelineJob']);
|
|
14774
|
-
if (fromPipelineJob != null) {
|
|
14775
|
-
setValueByPath(toObject, ['pipelineJob'], fromPipelineJob);
|
|
14776
|
-
}
|
|
14777
|
-
const fromServiceAccount = getValueByPath(fromObject, [
|
|
14778
|
-
'serviceAccount',
|
|
14779
|
-
]);
|
|
14780
|
-
if (fromServiceAccount != null) {
|
|
14781
|
-
setValueByPath(toObject, ['serviceAccount'], fromServiceAccount);
|
|
14782
|
-
}
|
|
14783
|
-
const fromTunedModelDisplayName = getValueByPath(fromObject, [
|
|
14784
|
-
'tunedModelDisplayName',
|
|
14785
|
-
]);
|
|
14786
|
-
if (fromTunedModelDisplayName != null) {
|
|
14787
|
-
setValueByPath(toObject, ['tunedModelDisplayName'], fromTunedModelDisplayName);
|
|
14788
|
-
}
|
|
14789
|
-
const fromVeoTuningSpec = getValueByPath(fromObject, [
|
|
14790
|
-
'veoTuningSpec',
|
|
14791
|
-
]);
|
|
14792
|
-
if (fromVeoTuningSpec != null) {
|
|
14793
|
-
setValueByPath(toObject, ['veoTuningSpec'], fromVeoTuningSpec);
|
|
14794
|
-
}
|
|
14795
14823
|
return toObject;
|
|
14796
14824
|
}
|
|
14797
14825
|
function tuningJobFromVertex(fromObject) {
|