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