@ai-sdk/google-vertex 5.0.0-beta.61 → 5.0.0-beta.63
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/CHANGELOG.md +33 -0
- package/dist/anthropic/edge/index.d.ts +14 -9
- package/dist/anthropic/edge/index.js +15 -13
- package/dist/anthropic/edge/index.js.map +1 -1
- package/dist/anthropic/index.d.ts +14 -9
- package/dist/anthropic/index.js +14 -12
- package/dist/anthropic/index.js.map +1 -1
- package/dist/edge/index.d.ts +3 -3
- package/dist/edge/index.js +197 -157
- package/dist/edge/index.js.map +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.js +199 -159
- package/dist/index.js.map +1 -1
- package/dist/maas/edge/index.d.ts +3 -3
- package/dist/maas/edge/index.js +12 -8
- package/dist/maas/edge/index.js.map +1 -1
- package/dist/maas/index.d.ts +3 -3
- package/dist/maas/index.js +11 -7
- package/dist/maas/index.js.map +1 -1
- package/docs/16-google-vertex.mdx +77 -77
- package/package.json +7 -7
- package/src/anthropic/edge/google-vertex-anthropic-provider-edge.ts +16 -11
- package/src/anthropic/edge/index.ts +6 -2
- package/src/anthropic/google-vertex-anthropic-provider-node.ts +16 -11
- package/src/anthropic/google-vertex-anthropic-provider.ts +10 -10
- package/src/anthropic/index.ts +6 -2
- package/src/edge/google-vertex-provider-edge.ts +9 -10
- package/src/edge/index.ts +8 -1
- package/src/google-vertex-auth-google-auth-library.ts +1 -2
- package/src/google-vertex-config.ts +1 -1
- package/src/google-vertex-embedding-model.ts +13 -5
- package/src/google-vertex-image-model-options.ts +74 -0
- package/src/google-vertex-image-model.ts +66 -113
- package/src/google-vertex-provider-base.ts +245 -0
- package/src/google-vertex-provider.ts +35 -233
- package/src/google-vertex-video-model-options.ts +49 -0
- package/src/google-vertex-video-model.ts +32 -68
- package/src/index.ts +12 -5
- package/src/maas/edge/google-vertex-maas-provider-edge.ts +7 -8
- package/src/maas/edge/index.ts +6 -2
- package/src/maas/google-vertex-maas-provider-node.ts +7 -8
- package/src/maas/google-vertex-maas-provider.ts +7 -5
- package/src/maas/index.ts +6 -2
- package/src/google-vertex-provider-node.ts +0 -48
- /package/src/{google-vertex-embedding-options.ts → google-vertex-embedding-model-options.ts} +0 -0
package/dist/edge/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/edge/google-vertex-provider-edge.ts
|
|
2
2
|
import { loadOptionalSetting as loadOptionalSetting3, resolve as resolve5 } from "@ai-sdk/provider-utils";
|
|
3
3
|
|
|
4
|
-
// src/google-vertex-provider.ts
|
|
4
|
+
// src/google-vertex-provider-base.ts
|
|
5
5
|
import { GoogleLanguageModel as GoogleLanguageModel2 } from "@ai-sdk/google/internal";
|
|
6
6
|
import {
|
|
7
7
|
generateId,
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
} from "@ai-sdk/provider-utils";
|
|
15
15
|
|
|
16
16
|
// src/version.ts
|
|
17
|
-
var VERSION = true ? "5.0.0-beta.
|
|
17
|
+
var VERSION = true ? "5.0.0-beta.63" : "0.0.0-test";
|
|
18
18
|
|
|
19
19
|
// src/google-vertex-embedding-model.ts
|
|
20
20
|
import {
|
|
@@ -49,7 +49,7 @@ var googleVertexFailedResponseHandler = createJsonErrorResponseHandler(
|
|
|
49
49
|
}
|
|
50
50
|
);
|
|
51
51
|
|
|
52
|
-
// src/google-vertex-embedding-options.ts
|
|
52
|
+
// src/google-vertex-embedding-model-options.ts
|
|
53
53
|
import { z as z2 } from "zod/v4";
|
|
54
54
|
var googleVertexEmbeddingModelOptions = z2.object({
|
|
55
55
|
/**
|
|
@@ -120,10 +120,17 @@ var GoogleVertexEmbeddingModel = class _GoogleVertexEmbeddingModel {
|
|
|
120
120
|
providerOptions
|
|
121
121
|
}) {
|
|
122
122
|
let googleOptions = await parseProviderOptions({
|
|
123
|
-
provider: "
|
|
123
|
+
provider: "googleVertex",
|
|
124
124
|
providerOptions,
|
|
125
125
|
schema: googleVertexEmbeddingModelOptions
|
|
126
126
|
});
|
|
127
|
+
if (googleOptions == null) {
|
|
128
|
+
googleOptions = await parseProviderOptions({
|
|
129
|
+
provider: "vertex",
|
|
130
|
+
providerOptions,
|
|
131
|
+
schema: googleVertexEmbeddingModelOptions
|
|
132
|
+
});
|
|
133
|
+
}
|
|
127
134
|
if (googleOptions == null) {
|
|
128
135
|
googleOptions = await parseProviderOptions({
|
|
129
136
|
provider: "google",
|
|
@@ -213,7 +220,68 @@ import {
|
|
|
213
220
|
WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE2,
|
|
214
221
|
WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE2
|
|
215
222
|
} from "@ai-sdk/provider-utils";
|
|
223
|
+
import { z as z5 } from "zod/v4";
|
|
224
|
+
|
|
225
|
+
// src/google-vertex-image-model-options.ts
|
|
216
226
|
import { z as z4 } from "zod/v4";
|
|
227
|
+
var googleVertexImageModelOptionsSchema = z4.object({
|
|
228
|
+
negativePrompt: z4.string().nullish(),
|
|
229
|
+
personGeneration: z4.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
|
|
230
|
+
safetySetting: z4.enum([
|
|
231
|
+
"block_low_and_above",
|
|
232
|
+
"block_medium_and_above",
|
|
233
|
+
"block_only_high",
|
|
234
|
+
"block_none"
|
|
235
|
+
]).nullish(),
|
|
236
|
+
addWatermark: z4.boolean().nullish(),
|
|
237
|
+
storageUri: z4.string().nullish(),
|
|
238
|
+
sampleImageSize: z4.enum(["1K", "2K"]).nullish(),
|
|
239
|
+
/**
|
|
240
|
+
* Configuration for image editing operations
|
|
241
|
+
*/
|
|
242
|
+
edit: z4.object({
|
|
243
|
+
/**
|
|
244
|
+
* An integer that represents the number of sampling steps.
|
|
245
|
+
* A higher value offers better image quality, a lower value offers better latency.
|
|
246
|
+
* Try 35 steps to start. If the quality doesn't meet your requirements,
|
|
247
|
+
* increase the value towards an upper limit of 75.
|
|
248
|
+
*/
|
|
249
|
+
baseSteps: z4.number().nullish(),
|
|
250
|
+
// Edit mode options
|
|
251
|
+
// https://cloud.google.com/vertex-ai/generative-ai/docs/image/edit-insert-objects
|
|
252
|
+
mode: z4.enum([
|
|
253
|
+
"EDIT_MODE_INPAINT_INSERTION",
|
|
254
|
+
"EDIT_MODE_INPAINT_REMOVAL",
|
|
255
|
+
"EDIT_MODE_OUTPAINT",
|
|
256
|
+
"EDIT_MODE_CONTROLLED_EDITING",
|
|
257
|
+
"EDIT_MODE_PRODUCT_IMAGE",
|
|
258
|
+
"EDIT_MODE_BGSWAP"
|
|
259
|
+
]).nullish(),
|
|
260
|
+
/**
|
|
261
|
+
* The mask mode to use.
|
|
262
|
+
* - `MASK_MODE_DEFAULT` - Default value for mask mode.
|
|
263
|
+
* - `MASK_MODE_USER_PROVIDED` - User provided mask. No segmentation needed.
|
|
264
|
+
* - `MASK_MODE_DETECTION_BOX` - Mask from detected bounding boxes.
|
|
265
|
+
* - `MASK_MODE_CLOTHING_AREA` - Masks from segmenting the clothing area with open-vocab segmentation.
|
|
266
|
+
* - `MASK_MODE_PARSED_PERSON` - Masks from segmenting the person body and clothing using the person-parsing model.
|
|
267
|
+
*/
|
|
268
|
+
maskMode: z4.enum([
|
|
269
|
+
"MASK_MODE_DEFAULT",
|
|
270
|
+
"MASK_MODE_USER_PROVIDED",
|
|
271
|
+
"MASK_MODE_DETECTION_BOX",
|
|
272
|
+
"MASK_MODE_CLOTHING_AREA",
|
|
273
|
+
"MASK_MODE_PARSED_PERSON"
|
|
274
|
+
]).nullish(),
|
|
275
|
+
/**
|
|
276
|
+
* Optional. A float value between 0 and 1, inclusive, that represents the
|
|
277
|
+
* percentage of the image width to grow the mask by. Using dilation helps
|
|
278
|
+
* compensate for imprecise masks. We recommend a value of 0.01.
|
|
279
|
+
*/
|
|
280
|
+
maskDilation: z4.number().nullish()
|
|
281
|
+
}).nullish()
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
// src/google-vertex-image-model.ts
|
|
217
285
|
var GoogleVertexImageModel = class _GoogleVertexImageModel {
|
|
218
286
|
constructor(modelId, config) {
|
|
219
287
|
this.modelId = modelId;
|
|
@@ -256,7 +324,7 @@ var GoogleVertexImageModel = class _GoogleVertexImageModel {
|
|
|
256
324
|
files,
|
|
257
325
|
mask
|
|
258
326
|
}) {
|
|
259
|
-
var _a, _b, _c, _d, _e, _f
|
|
327
|
+
var _a, _b, _c, _d, _e, _f;
|
|
260
328
|
const warnings = [];
|
|
261
329
|
if (size != null) {
|
|
262
330
|
warnings.push({
|
|
@@ -265,12 +333,16 @@ var GoogleVertexImageModel = class _GoogleVertexImageModel {
|
|
|
265
333
|
details: "This model does not support the `size` option. Use `aspectRatio` instead."
|
|
266
334
|
});
|
|
267
335
|
}
|
|
268
|
-
const
|
|
336
|
+
const googleVertexImageOptions = (_a = await parseProviderOptions2({
|
|
337
|
+
provider: "googleVertex",
|
|
338
|
+
providerOptions,
|
|
339
|
+
schema: googleVertexImageModelOptionsSchema
|
|
340
|
+
})) != null ? _a : await parseProviderOptions2({
|
|
269
341
|
provider: "vertex",
|
|
270
342
|
providerOptions,
|
|
271
343
|
schema: googleVertexImageModelOptionsSchema
|
|
272
344
|
});
|
|
273
|
-
const { edit, ...otherOptions } =
|
|
345
|
+
const { edit, ...otherOptions } = googleVertexImageOptions != null ? googleVertexImageOptions : {};
|
|
274
346
|
const { mode: editMode, baseSteps, maskMode, maskDilation } = edit != null ? edit : {};
|
|
275
347
|
const isEditMode = files != null && files.length > 0;
|
|
276
348
|
let body;
|
|
@@ -326,7 +398,7 @@ var GoogleVertexImageModel = class _GoogleVertexImageModel {
|
|
|
326
398
|
}
|
|
327
399
|
};
|
|
328
400
|
}
|
|
329
|
-
const currentDate = (
|
|
401
|
+
const currentDate = (_d = (_c = (_b = this.config._internal) == null ? void 0 : _b.currentDate) == null ? void 0 : _c.call(_b)) != null ? _d : /* @__PURE__ */ new Date();
|
|
330
402
|
const { value: response, responseHeaders } = await postJsonToApi2({
|
|
331
403
|
url: `${this.config.baseURL}/models/${this.modelId}:predict`,
|
|
332
404
|
headers: combineHeaders2(
|
|
@@ -336,32 +408,34 @@ var GoogleVertexImageModel = class _GoogleVertexImageModel {
|
|
|
336
408
|
body,
|
|
337
409
|
failedResponseHandler: googleVertexFailedResponseHandler,
|
|
338
410
|
successfulResponseHandler: createJsonResponseHandler2(
|
|
339
|
-
|
|
411
|
+
googleVertexImageResponseSchema
|
|
340
412
|
),
|
|
341
413
|
abortSignal,
|
|
342
414
|
fetch: this.config.fetch
|
|
343
415
|
});
|
|
344
416
|
return {
|
|
345
|
-
images: (
|
|
417
|
+
images: (_f = (_e = response.predictions) == null ? void 0 : _e.map(
|
|
346
418
|
({ bytesBase64Encoded }) => bytesBase64Encoded
|
|
347
|
-
)) != null ?
|
|
419
|
+
)) != null ? _f : [],
|
|
348
420
|
warnings,
|
|
349
421
|
response: {
|
|
350
422
|
timestamp: currentDate,
|
|
351
423
|
modelId: this.modelId,
|
|
352
424
|
headers: responseHeaders
|
|
353
425
|
},
|
|
354
|
-
providerMetadata: {
|
|
355
|
-
|
|
356
|
-
|
|
426
|
+
providerMetadata: (() => {
|
|
427
|
+
var _a2, _b2;
|
|
428
|
+
const payload = {
|
|
429
|
+
images: (_b2 = (_a2 = response.predictions) == null ? void 0 : _a2.map((prediction) => {
|
|
357
430
|
const {
|
|
358
431
|
// normalize revised prompt property
|
|
359
432
|
prompt: revisedPrompt
|
|
360
433
|
} = prediction;
|
|
361
434
|
return { ...revisedPrompt != null && { revisedPrompt } };
|
|
362
|
-
})) != null ?
|
|
363
|
-
}
|
|
364
|
-
|
|
435
|
+
})) != null ? _b2 : []
|
|
436
|
+
};
|
|
437
|
+
return { googleVertex: payload, vertex: payload };
|
|
438
|
+
})()
|
|
365
439
|
};
|
|
366
440
|
}
|
|
367
441
|
async doGenerateGemini({
|
|
@@ -404,13 +478,16 @@ var GoogleVertexImageModel = class _GoogleVertexImageModel {
|
|
|
404
478
|
if (file.type === "url") {
|
|
405
479
|
userContent.push({
|
|
406
480
|
type: "file",
|
|
407
|
-
data: new URL(file.url),
|
|
481
|
+
data: { type: "url", url: new URL(file.url) },
|
|
408
482
|
mediaType: "image/*"
|
|
409
483
|
});
|
|
410
484
|
} else {
|
|
411
485
|
userContent.push({
|
|
412
486
|
type: "file",
|
|
413
|
-
data:
|
|
487
|
+
data: {
|
|
488
|
+
type: "data",
|
|
489
|
+
data: typeof file.data === "string" ? file.data : new Uint8Array(file.data)
|
|
490
|
+
},
|
|
414
491
|
mediaType: file.mediaType
|
|
415
492
|
});
|
|
416
493
|
}
|
|
@@ -429,17 +506,20 @@ var GoogleVertexImageModel = class _GoogleVertexImageModel {
|
|
|
429
506
|
"*": [/^https?:\/\/.*$/, /^gs:\/\/.*$/]
|
|
430
507
|
})
|
|
431
508
|
});
|
|
509
|
+
const userVertexOptions = (_c = providerOptions == null ? void 0 : providerOptions.googleVertex) != null ? _c : providerOptions == null ? void 0 : providerOptions.vertex;
|
|
510
|
+
const innerVertexOptions = {
|
|
511
|
+
responseModalities: ["IMAGE"],
|
|
512
|
+
imageConfig: aspectRatio ? {
|
|
513
|
+
aspectRatio
|
|
514
|
+
} : void 0,
|
|
515
|
+
...userVertexOptions != null ? userVertexOptions : {}
|
|
516
|
+
};
|
|
432
517
|
const result = await languageModel.doGenerate({
|
|
433
518
|
prompt: languageModelPrompt,
|
|
434
519
|
seed,
|
|
435
520
|
providerOptions: {
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
imageConfig: aspectRatio ? {
|
|
439
|
-
aspectRatio
|
|
440
|
-
} : void 0,
|
|
441
|
-
...(_c = providerOptions == null ? void 0 : providerOptions.vertex) != null ? _c : {}
|
|
442
|
-
}
|
|
521
|
+
googleVertex: innerVertexOptions,
|
|
522
|
+
vertex: innerVertexOptions
|
|
443
523
|
},
|
|
444
524
|
headers,
|
|
445
525
|
abortSignal
|
|
@@ -447,17 +527,19 @@ var GoogleVertexImageModel = class _GoogleVertexImageModel {
|
|
|
447
527
|
const currentDate = (_f = (_e = (_d = this.config._internal) == null ? void 0 : _d.currentDate) == null ? void 0 : _e.call(_d)) != null ? _f : /* @__PURE__ */ new Date();
|
|
448
528
|
const images = [];
|
|
449
529
|
for (const part of result.content) {
|
|
450
|
-
if (part.type === "file" && part.mediaType.startsWith("image/")) {
|
|
451
|
-
images.push(convertToBase64(part.data));
|
|
530
|
+
if (part.type === "file" && part.mediaType.startsWith("image/") && part.data.type === "data") {
|
|
531
|
+
images.push(convertToBase64(part.data.data));
|
|
452
532
|
}
|
|
453
533
|
}
|
|
534
|
+
const geminiPayload = {
|
|
535
|
+
images: images.map(() => ({}))
|
|
536
|
+
};
|
|
454
537
|
return {
|
|
455
538
|
images,
|
|
456
539
|
warnings,
|
|
457
540
|
providerMetadata: {
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
}
|
|
541
|
+
googleVertex: geminiPayload,
|
|
542
|
+
vertex: geminiPayload
|
|
461
543
|
},
|
|
462
544
|
response: {
|
|
463
545
|
timestamp: currentDate,
|
|
@@ -475,71 +557,15 @@ var GoogleVertexImageModel = class _GoogleVertexImageModel {
|
|
|
475
557
|
function isGeminiModel(modelId) {
|
|
476
558
|
return modelId.startsWith("gemini-");
|
|
477
559
|
}
|
|
478
|
-
var
|
|
479
|
-
predictions:
|
|
480
|
-
|
|
481
|
-
bytesBase64Encoded:
|
|
482
|
-
mimeType:
|
|
483
|
-
prompt:
|
|
560
|
+
var googleVertexImageResponseSchema = z5.object({
|
|
561
|
+
predictions: z5.array(
|
|
562
|
+
z5.object({
|
|
563
|
+
bytesBase64Encoded: z5.string(),
|
|
564
|
+
mimeType: z5.string(),
|
|
565
|
+
prompt: z5.string().nullish()
|
|
484
566
|
})
|
|
485
567
|
).nullish()
|
|
486
568
|
});
|
|
487
|
-
var googleVertexImageModelOptionsSchema = z4.object({
|
|
488
|
-
negativePrompt: z4.string().nullish(),
|
|
489
|
-
personGeneration: z4.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
|
|
490
|
-
safetySetting: z4.enum([
|
|
491
|
-
"block_low_and_above",
|
|
492
|
-
"block_medium_and_above",
|
|
493
|
-
"block_only_high",
|
|
494
|
-
"block_none"
|
|
495
|
-
]).nullish(),
|
|
496
|
-
addWatermark: z4.boolean().nullish(),
|
|
497
|
-
storageUri: z4.string().nullish(),
|
|
498
|
-
sampleImageSize: z4.enum(["1K", "2K"]).nullish(),
|
|
499
|
-
/**
|
|
500
|
-
* Configuration for image editing operations
|
|
501
|
-
*/
|
|
502
|
-
edit: z4.object({
|
|
503
|
-
/**
|
|
504
|
-
* An integer that represents the number of sampling steps.
|
|
505
|
-
* A higher value offers better image quality, a lower value offers better latency.
|
|
506
|
-
* Try 35 steps to start. If the quality doesn't meet your requirements,
|
|
507
|
-
* increase the value towards an upper limit of 75.
|
|
508
|
-
*/
|
|
509
|
-
baseSteps: z4.number().nullish(),
|
|
510
|
-
// Edit mode options
|
|
511
|
-
// https://cloud.google.com/vertex-ai/generative-ai/docs/image/edit-insert-objects
|
|
512
|
-
mode: z4.enum([
|
|
513
|
-
"EDIT_MODE_INPAINT_INSERTION",
|
|
514
|
-
"EDIT_MODE_INPAINT_REMOVAL",
|
|
515
|
-
"EDIT_MODE_OUTPAINT",
|
|
516
|
-
"EDIT_MODE_CONTROLLED_EDITING",
|
|
517
|
-
"EDIT_MODE_PRODUCT_IMAGE",
|
|
518
|
-
"EDIT_MODE_BGSWAP"
|
|
519
|
-
]).nullish(),
|
|
520
|
-
/**
|
|
521
|
-
* The mask mode to use.
|
|
522
|
-
* - `MASK_MODE_DEFAULT` - Default value for mask mode.
|
|
523
|
-
* - `MASK_MODE_USER_PROVIDED` - User provided mask. No segmentation needed.
|
|
524
|
-
* - `MASK_MODE_DETECTION_BOX` - Mask from detected bounding boxes.
|
|
525
|
-
* - `MASK_MODE_CLOTHING_AREA` - Masks from segmenting the clothing area with open-vocab segmentation.
|
|
526
|
-
* - `MASK_MODE_PARSED_PERSON` - Masks from segmenting the person body and clothing using the person-parsing model.
|
|
527
|
-
*/
|
|
528
|
-
maskMode: z4.enum([
|
|
529
|
-
"MASK_MODE_DEFAULT",
|
|
530
|
-
"MASK_MODE_USER_PROVIDED",
|
|
531
|
-
"MASK_MODE_DETECTION_BOX",
|
|
532
|
-
"MASK_MODE_CLOTHING_AREA",
|
|
533
|
-
"MASK_MODE_PARSED_PERSON"
|
|
534
|
-
]).nullish(),
|
|
535
|
-
/**
|
|
536
|
-
* Optional. A float value between 0 and 1, inclusive, that represents the
|
|
537
|
-
* percentage of the image width to grow the mask by. Using dilation helps
|
|
538
|
-
* compensate for imprecise masks. We recommend a value of 0.01.
|
|
539
|
-
*/
|
|
540
|
-
maskDilation: z4.number().nullish()
|
|
541
|
-
}).nullish()
|
|
542
|
-
});
|
|
543
569
|
function getBase64Data(file) {
|
|
544
570
|
if (file.type === "url") {
|
|
545
571
|
throw new Error(
|
|
@@ -573,13 +599,35 @@ import {
|
|
|
573
599
|
convertUint8ArrayToBase64 as convertUint8ArrayToBase642,
|
|
574
600
|
createJsonResponseHandler as createJsonResponseHandler3,
|
|
575
601
|
delay,
|
|
576
|
-
lazySchema,
|
|
577
602
|
parseProviderOptions as parseProviderOptions3,
|
|
578
603
|
postJsonToApi as postJsonToApi3,
|
|
579
|
-
resolve as resolve3
|
|
580
|
-
zodSchema
|
|
604
|
+
resolve as resolve3
|
|
581
605
|
} from "@ai-sdk/provider-utils";
|
|
582
|
-
import { z as
|
|
606
|
+
import { z as z7 } from "zod/v4";
|
|
607
|
+
|
|
608
|
+
// src/google-vertex-video-model-options.ts
|
|
609
|
+
import { lazySchema, zodSchema } from "@ai-sdk/provider-utils";
|
|
610
|
+
import { z as z6 } from "zod/v4";
|
|
611
|
+
var googleVertexVideoModelOptionsSchema = lazySchema(
|
|
612
|
+
() => zodSchema(
|
|
613
|
+
z6.object({
|
|
614
|
+
pollIntervalMs: z6.number().positive().nullish(),
|
|
615
|
+
pollTimeoutMs: z6.number().positive().nullish(),
|
|
616
|
+
personGeneration: z6.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
|
|
617
|
+
negativePrompt: z6.string().nullish(),
|
|
618
|
+
generateAudio: z6.boolean().nullish(),
|
|
619
|
+
gcsOutputDirectory: z6.string().nullish(),
|
|
620
|
+
referenceImages: z6.array(
|
|
621
|
+
z6.object({
|
|
622
|
+
bytesBase64Encoded: z6.string().nullish(),
|
|
623
|
+
gcsUri: z6.string().nullish()
|
|
624
|
+
})
|
|
625
|
+
).nullish()
|
|
626
|
+
}).passthrough()
|
|
627
|
+
)
|
|
628
|
+
);
|
|
629
|
+
|
|
630
|
+
// src/google-vertex-video-model.ts
|
|
583
631
|
var GoogleVertexVideoModel = class {
|
|
584
632
|
constructor(modelId, config) {
|
|
585
633
|
this.modelId = modelId;
|
|
@@ -593,10 +641,14 @@ var GoogleVertexVideoModel = class {
|
|
|
593
641
|
return 4;
|
|
594
642
|
}
|
|
595
643
|
async doGenerate(options) {
|
|
596
|
-
var _a, _b, _c, _d, _e, _f;
|
|
644
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
597
645
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
598
646
|
const warnings = [];
|
|
599
|
-
const
|
|
647
|
+
const googleVertexOptions = (_d = await parseProviderOptions3({
|
|
648
|
+
provider: "googleVertex",
|
|
649
|
+
providerOptions: options.providerOptions,
|
|
650
|
+
schema: googleVertexVideoModelOptionsSchema
|
|
651
|
+
})) != null ? _d : await parseProviderOptions3({
|
|
600
652
|
provider: "vertex",
|
|
601
653
|
providerOptions: options.providerOptions,
|
|
602
654
|
schema: googleVertexVideoModelOptionsSchema
|
|
@@ -621,8 +673,8 @@ var GoogleVertexVideoModel = class {
|
|
|
621
673
|
};
|
|
622
674
|
}
|
|
623
675
|
}
|
|
624
|
-
if ((
|
|
625
|
-
instance.referenceImages =
|
|
676
|
+
if ((googleVertexOptions == null ? void 0 : googleVertexOptions.referenceImages) != null) {
|
|
677
|
+
instance.referenceImages = googleVertexOptions.referenceImages;
|
|
626
678
|
}
|
|
627
679
|
const parameters = {
|
|
628
680
|
sampleCount: options.n
|
|
@@ -644,8 +696,8 @@ var GoogleVertexVideoModel = class {
|
|
|
644
696
|
if (options.seed) {
|
|
645
697
|
parameters.seed = options.seed;
|
|
646
698
|
}
|
|
647
|
-
if (
|
|
648
|
-
const opts =
|
|
699
|
+
if (googleVertexOptions != null) {
|
|
700
|
+
const opts = googleVertexOptions;
|
|
649
701
|
if (opts.personGeneration !== void 0 && opts.personGeneration !== null) {
|
|
650
702
|
parameters.personGeneration = opts.personGeneration;
|
|
651
703
|
}
|
|
@@ -683,7 +735,7 @@ var GoogleVertexVideoModel = class {
|
|
|
683
735
|
parameters
|
|
684
736
|
},
|
|
685
737
|
successfulResponseHandler: createJsonResponseHandler3(
|
|
686
|
-
|
|
738
|
+
googleVertexOperationSchema
|
|
687
739
|
),
|
|
688
740
|
failedResponseHandler: googleVertexFailedResponseHandler,
|
|
689
741
|
abortSignal: options.abortSignal,
|
|
@@ -696,8 +748,8 @@ var GoogleVertexVideoModel = class {
|
|
|
696
748
|
message: "No operation name returned from API"
|
|
697
749
|
});
|
|
698
750
|
}
|
|
699
|
-
const pollIntervalMs = (
|
|
700
|
-
const pollTimeoutMs = (
|
|
751
|
+
const pollIntervalMs = (_e = googleVertexOptions == null ? void 0 : googleVertexOptions.pollIntervalMs) != null ? _e : 1e4;
|
|
752
|
+
const pollTimeoutMs = (_f = googleVertexOptions == null ? void 0 : googleVertexOptions.pollTimeoutMs) != null ? _f : 6e5;
|
|
701
753
|
const startTime = Date.now();
|
|
702
754
|
let finalOperation = operation;
|
|
703
755
|
let responseHeaders;
|
|
@@ -709,7 +761,7 @@ var GoogleVertexVideoModel = class {
|
|
|
709
761
|
});
|
|
710
762
|
}
|
|
711
763
|
await delay(pollIntervalMs);
|
|
712
|
-
if ((
|
|
764
|
+
if ((_g = options.abortSignal) == null ? void 0 : _g.aborted) {
|
|
713
765
|
throw new AISDKError({
|
|
714
766
|
name: "VERTEX_VIDEO_GENERATION_ABORTED",
|
|
715
767
|
message: "Video generation request was aborted"
|
|
@@ -725,7 +777,7 @@ var GoogleVertexVideoModel = class {
|
|
|
725
777
|
operationName
|
|
726
778
|
},
|
|
727
779
|
successfulResponseHandler: createJsonResponseHandler3(
|
|
728
|
-
|
|
780
|
+
googleVertexOperationSchema
|
|
729
781
|
),
|
|
730
782
|
failedResponseHandler: googleVertexFailedResponseHandler,
|
|
731
783
|
abortSignal: options.abortSignal,
|
|
@@ -785,53 +837,39 @@ var GoogleVertexVideoModel = class {
|
|
|
785
837
|
modelId: this.modelId,
|
|
786
838
|
headers: responseHeaders
|
|
787
839
|
},
|
|
788
|
-
providerMetadata: {
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
840
|
+
providerMetadata: /* @__PURE__ */ (() => {
|
|
841
|
+
const payload = { videos: videoMetadata };
|
|
842
|
+
return {
|
|
843
|
+
googleVertex: payload,
|
|
844
|
+
// Legacy keys preserved for backward compatibility.
|
|
845
|
+
"google-vertex": payload,
|
|
846
|
+
vertex: payload
|
|
847
|
+
};
|
|
848
|
+
})()
|
|
793
849
|
};
|
|
794
850
|
}
|
|
795
851
|
};
|
|
796
|
-
var
|
|
797
|
-
name:
|
|
798
|
-
done:
|
|
799
|
-
error:
|
|
800
|
-
code:
|
|
801
|
-
message:
|
|
802
|
-
status:
|
|
852
|
+
var googleVertexOperationSchema = z7.object({
|
|
853
|
+
name: z7.string().nullish(),
|
|
854
|
+
done: z7.boolean().nullish(),
|
|
855
|
+
error: z7.object({
|
|
856
|
+
code: z7.number().nullish(),
|
|
857
|
+
message: z7.string(),
|
|
858
|
+
status: z7.string().nullish()
|
|
803
859
|
}).nullish(),
|
|
804
|
-
response:
|
|
805
|
-
videos:
|
|
806
|
-
|
|
807
|
-
bytesBase64Encoded:
|
|
808
|
-
gcsUri:
|
|
809
|
-
mimeType:
|
|
860
|
+
response: z7.object({
|
|
861
|
+
videos: z7.array(
|
|
862
|
+
z7.object({
|
|
863
|
+
bytesBase64Encoded: z7.string().nullish(),
|
|
864
|
+
gcsUri: z7.string().nullish(),
|
|
865
|
+
mimeType: z7.string().nullish()
|
|
810
866
|
})
|
|
811
867
|
).nullish(),
|
|
812
|
-
raiMediaFilteredCount:
|
|
868
|
+
raiMediaFilteredCount: z7.number().nullish()
|
|
813
869
|
}).nullish()
|
|
814
870
|
});
|
|
815
|
-
var googleVertexVideoModelOptionsSchema = lazySchema(
|
|
816
|
-
() => zodSchema(
|
|
817
|
-
z5.object({
|
|
818
|
-
pollIntervalMs: z5.number().positive().nullish(),
|
|
819
|
-
pollTimeoutMs: z5.number().positive().nullish(),
|
|
820
|
-
personGeneration: z5.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
|
|
821
|
-
negativePrompt: z5.string().nullish(),
|
|
822
|
-
generateAudio: z5.boolean().nullish(),
|
|
823
|
-
gcsOutputDirectory: z5.string().nullish(),
|
|
824
|
-
referenceImages: z5.array(
|
|
825
|
-
z5.object({
|
|
826
|
-
bytesBase64Encoded: z5.string().nullish(),
|
|
827
|
-
gcsUri: z5.string().nullish()
|
|
828
|
-
})
|
|
829
|
-
).nullish()
|
|
830
|
-
}).passthrough()
|
|
831
|
-
)
|
|
832
|
-
);
|
|
833
871
|
|
|
834
|
-
// src/google-vertex-provider.ts
|
|
872
|
+
// src/google-vertex-provider-base.ts
|
|
835
873
|
var EXPRESS_MODE_BASE_URL = "https://aiplatform.googleapis.com/v1/publishers/google";
|
|
836
874
|
function createExpressModeFetch(apiKey, customFetch) {
|
|
837
875
|
return async (url, init) => {
|
|
@@ -845,18 +883,18 @@ function createExpressModeFetch(apiKey, customFetch) {
|
|
|
845
883
|
return (customFetch != null ? customFetch : fetch)(url.toString(), modifiedInit);
|
|
846
884
|
};
|
|
847
885
|
}
|
|
848
|
-
function
|
|
886
|
+
function createGoogleVertex(options = {}) {
|
|
849
887
|
const apiKey = loadOptionalSetting({
|
|
850
888
|
settingValue: options.apiKey,
|
|
851
889
|
environmentVariableName: "GOOGLE_VERTEX_API_KEY"
|
|
852
890
|
});
|
|
853
|
-
const
|
|
891
|
+
const loadGoogleVertexProject = () => loadSetting({
|
|
854
892
|
settingValue: options.project,
|
|
855
893
|
settingName: "project",
|
|
856
894
|
environmentVariableName: "GOOGLE_VERTEX_PROJECT",
|
|
857
895
|
description: "Google Vertex project"
|
|
858
896
|
});
|
|
859
|
-
const
|
|
897
|
+
const loadGoogleVertexLocation = () => loadSetting({
|
|
860
898
|
settingValue: options.location,
|
|
861
899
|
settingName: "location",
|
|
862
900
|
environmentVariableName: "GOOGLE_VERTEX_LOCATION",
|
|
@@ -867,8 +905,8 @@ function createVertex(options = {}) {
|
|
|
867
905
|
if (apiKey) {
|
|
868
906
|
return (_a = withoutTrailingSlash(options.baseURL)) != null ? _a : EXPRESS_MODE_BASE_URL;
|
|
869
907
|
}
|
|
870
|
-
const region =
|
|
871
|
-
const project =
|
|
908
|
+
const region = loadGoogleVertexLocation();
|
|
909
|
+
const project = loadGoogleVertexProject();
|
|
872
910
|
const baseHost = `${region === "global" ? "" : region + "-"}aiplatform.googleapis.com`;
|
|
873
911
|
return (_b = withoutTrailingSlash(options.baseURL)) != null ? _b : `https://${baseHost}/v1beta1/projects/${project}/locations/${region}/publishers/google`;
|
|
874
912
|
};
|
|
@@ -1050,15 +1088,15 @@ async function generateAuthToken(credentials) {
|
|
|
1050
1088
|
}
|
|
1051
1089
|
|
|
1052
1090
|
// src/edge/google-vertex-provider-edge.ts
|
|
1053
|
-
function
|
|
1091
|
+
function createGoogleVertex2(options = {}) {
|
|
1054
1092
|
const apiKey = loadOptionalSetting3({
|
|
1055
1093
|
settingValue: options.apiKey,
|
|
1056
1094
|
environmentVariableName: "GOOGLE_VERTEX_API_KEY"
|
|
1057
1095
|
});
|
|
1058
1096
|
if (apiKey) {
|
|
1059
|
-
return
|
|
1097
|
+
return createGoogleVertex(options);
|
|
1060
1098
|
}
|
|
1061
|
-
return
|
|
1099
|
+
return createGoogleVertex({
|
|
1062
1100
|
...options,
|
|
1063
1101
|
headers: async () => ({
|
|
1064
1102
|
Authorization: `Bearer ${await generateAuthToken(
|
|
@@ -1068,9 +1106,11 @@ function createVertex2(options = {}) {
|
|
|
1068
1106
|
})
|
|
1069
1107
|
});
|
|
1070
1108
|
}
|
|
1071
|
-
var
|
|
1109
|
+
var googleVertex = createGoogleVertex2();
|
|
1072
1110
|
export {
|
|
1073
|
-
|
|
1074
|
-
|
|
1111
|
+
createGoogleVertex2 as createGoogleVertex,
|
|
1112
|
+
createGoogleVertex2 as createVertex,
|
|
1113
|
+
googleVertex,
|
|
1114
|
+
googleVertex as vertex
|
|
1075
1115
|
};
|
|
1076
1116
|
//# sourceMappingURL=index.js.map
|