@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/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// src/google-vertex-provider
|
|
1
|
+
// src/google-vertex-provider.ts
|
|
2
2
|
import { loadOptionalSetting as loadOptionalSetting2, resolve as resolve5 } from "@ai-sdk/provider-utils";
|
|
3
3
|
|
|
4
4
|
// src/google-vertex-auth-google-auth-library.ts
|
|
@@ -22,7 +22,7 @@ async function generateAuthToken(options) {
|
|
|
22
22
|
return (token == null ? void 0 : token.token) || null;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
// src/google-vertex-provider.ts
|
|
25
|
+
// src/google-vertex-provider-base.ts
|
|
26
26
|
import { GoogleLanguageModel as GoogleLanguageModel2 } from "@ai-sdk/google/internal";
|
|
27
27
|
import {
|
|
28
28
|
generateId,
|
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
} from "@ai-sdk/provider-utils";
|
|
36
36
|
|
|
37
37
|
// src/version.ts
|
|
38
|
-
var VERSION = true ? "5.0.0-beta.
|
|
38
|
+
var VERSION = true ? "5.0.0-beta.63" : "0.0.0-test";
|
|
39
39
|
|
|
40
40
|
// src/google-vertex-embedding-model.ts
|
|
41
41
|
import {
|
|
@@ -70,7 +70,7 @@ var googleVertexFailedResponseHandler = createJsonErrorResponseHandler(
|
|
|
70
70
|
}
|
|
71
71
|
);
|
|
72
72
|
|
|
73
|
-
// src/google-vertex-embedding-options.ts
|
|
73
|
+
// src/google-vertex-embedding-model-options.ts
|
|
74
74
|
import { z as z2 } from "zod/v4";
|
|
75
75
|
var googleVertexEmbeddingModelOptions = z2.object({
|
|
76
76
|
/**
|
|
@@ -141,10 +141,17 @@ var GoogleVertexEmbeddingModel = class _GoogleVertexEmbeddingModel {
|
|
|
141
141
|
providerOptions
|
|
142
142
|
}) {
|
|
143
143
|
let googleOptions = await parseProviderOptions({
|
|
144
|
-
provider: "
|
|
144
|
+
provider: "googleVertex",
|
|
145
145
|
providerOptions,
|
|
146
146
|
schema: googleVertexEmbeddingModelOptions
|
|
147
147
|
});
|
|
148
|
+
if (googleOptions == null) {
|
|
149
|
+
googleOptions = await parseProviderOptions({
|
|
150
|
+
provider: "vertex",
|
|
151
|
+
providerOptions,
|
|
152
|
+
schema: googleVertexEmbeddingModelOptions
|
|
153
|
+
});
|
|
154
|
+
}
|
|
148
155
|
if (googleOptions == null) {
|
|
149
156
|
googleOptions = await parseProviderOptions({
|
|
150
157
|
provider: "google",
|
|
@@ -234,7 +241,68 @@ import {
|
|
|
234
241
|
WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE2,
|
|
235
242
|
WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE2
|
|
236
243
|
} from "@ai-sdk/provider-utils";
|
|
244
|
+
import { z as z5 } from "zod/v4";
|
|
245
|
+
|
|
246
|
+
// src/google-vertex-image-model-options.ts
|
|
237
247
|
import { z as z4 } from "zod/v4";
|
|
248
|
+
var googleVertexImageModelOptionsSchema = z4.object({
|
|
249
|
+
negativePrompt: z4.string().nullish(),
|
|
250
|
+
personGeneration: z4.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
|
|
251
|
+
safetySetting: z4.enum([
|
|
252
|
+
"block_low_and_above",
|
|
253
|
+
"block_medium_and_above",
|
|
254
|
+
"block_only_high",
|
|
255
|
+
"block_none"
|
|
256
|
+
]).nullish(),
|
|
257
|
+
addWatermark: z4.boolean().nullish(),
|
|
258
|
+
storageUri: z4.string().nullish(),
|
|
259
|
+
sampleImageSize: z4.enum(["1K", "2K"]).nullish(),
|
|
260
|
+
/**
|
|
261
|
+
* Configuration for image editing operations
|
|
262
|
+
*/
|
|
263
|
+
edit: z4.object({
|
|
264
|
+
/**
|
|
265
|
+
* An integer that represents the number of sampling steps.
|
|
266
|
+
* A higher value offers better image quality, a lower value offers better latency.
|
|
267
|
+
* Try 35 steps to start. If the quality doesn't meet your requirements,
|
|
268
|
+
* increase the value towards an upper limit of 75.
|
|
269
|
+
*/
|
|
270
|
+
baseSteps: z4.number().nullish(),
|
|
271
|
+
// Edit mode options
|
|
272
|
+
// https://cloud.google.com/vertex-ai/generative-ai/docs/image/edit-insert-objects
|
|
273
|
+
mode: z4.enum([
|
|
274
|
+
"EDIT_MODE_INPAINT_INSERTION",
|
|
275
|
+
"EDIT_MODE_INPAINT_REMOVAL",
|
|
276
|
+
"EDIT_MODE_OUTPAINT",
|
|
277
|
+
"EDIT_MODE_CONTROLLED_EDITING",
|
|
278
|
+
"EDIT_MODE_PRODUCT_IMAGE",
|
|
279
|
+
"EDIT_MODE_BGSWAP"
|
|
280
|
+
]).nullish(),
|
|
281
|
+
/**
|
|
282
|
+
* The mask mode to use.
|
|
283
|
+
* - `MASK_MODE_DEFAULT` - Default value for mask mode.
|
|
284
|
+
* - `MASK_MODE_USER_PROVIDED` - User provided mask. No segmentation needed.
|
|
285
|
+
* - `MASK_MODE_DETECTION_BOX` - Mask from detected bounding boxes.
|
|
286
|
+
* - `MASK_MODE_CLOTHING_AREA` - Masks from segmenting the clothing area with open-vocab segmentation.
|
|
287
|
+
* - `MASK_MODE_PARSED_PERSON` - Masks from segmenting the person body and clothing using the person-parsing model.
|
|
288
|
+
*/
|
|
289
|
+
maskMode: z4.enum([
|
|
290
|
+
"MASK_MODE_DEFAULT",
|
|
291
|
+
"MASK_MODE_USER_PROVIDED",
|
|
292
|
+
"MASK_MODE_DETECTION_BOX",
|
|
293
|
+
"MASK_MODE_CLOTHING_AREA",
|
|
294
|
+
"MASK_MODE_PARSED_PERSON"
|
|
295
|
+
]).nullish(),
|
|
296
|
+
/**
|
|
297
|
+
* Optional. A float value between 0 and 1, inclusive, that represents the
|
|
298
|
+
* percentage of the image width to grow the mask by. Using dilation helps
|
|
299
|
+
* compensate for imprecise masks. We recommend a value of 0.01.
|
|
300
|
+
*/
|
|
301
|
+
maskDilation: z4.number().nullish()
|
|
302
|
+
}).nullish()
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
// src/google-vertex-image-model.ts
|
|
238
306
|
var GoogleVertexImageModel = class _GoogleVertexImageModel {
|
|
239
307
|
constructor(modelId, config) {
|
|
240
308
|
this.modelId = modelId;
|
|
@@ -277,7 +345,7 @@ var GoogleVertexImageModel = class _GoogleVertexImageModel {
|
|
|
277
345
|
files,
|
|
278
346
|
mask
|
|
279
347
|
}) {
|
|
280
|
-
var _a, _b, _c, _d, _e, _f
|
|
348
|
+
var _a, _b, _c, _d, _e, _f;
|
|
281
349
|
const warnings = [];
|
|
282
350
|
if (size != null) {
|
|
283
351
|
warnings.push({
|
|
@@ -286,12 +354,16 @@ var GoogleVertexImageModel = class _GoogleVertexImageModel {
|
|
|
286
354
|
details: "This model does not support the `size` option. Use `aspectRatio` instead."
|
|
287
355
|
});
|
|
288
356
|
}
|
|
289
|
-
const
|
|
357
|
+
const googleVertexImageOptions = (_a = await parseProviderOptions2({
|
|
358
|
+
provider: "googleVertex",
|
|
359
|
+
providerOptions,
|
|
360
|
+
schema: googleVertexImageModelOptionsSchema
|
|
361
|
+
})) != null ? _a : await parseProviderOptions2({
|
|
290
362
|
provider: "vertex",
|
|
291
363
|
providerOptions,
|
|
292
364
|
schema: googleVertexImageModelOptionsSchema
|
|
293
365
|
});
|
|
294
|
-
const { edit, ...otherOptions } =
|
|
366
|
+
const { edit, ...otherOptions } = googleVertexImageOptions != null ? googleVertexImageOptions : {};
|
|
295
367
|
const { mode: editMode, baseSteps, maskMode, maskDilation } = edit != null ? edit : {};
|
|
296
368
|
const isEditMode = files != null && files.length > 0;
|
|
297
369
|
let body;
|
|
@@ -347,7 +419,7 @@ var GoogleVertexImageModel = class _GoogleVertexImageModel {
|
|
|
347
419
|
}
|
|
348
420
|
};
|
|
349
421
|
}
|
|
350
|
-
const currentDate = (
|
|
422
|
+
const currentDate = (_d = (_c = (_b = this.config._internal) == null ? void 0 : _b.currentDate) == null ? void 0 : _c.call(_b)) != null ? _d : /* @__PURE__ */ new Date();
|
|
351
423
|
const { value: response, responseHeaders } = await postJsonToApi2({
|
|
352
424
|
url: `${this.config.baseURL}/models/${this.modelId}:predict`,
|
|
353
425
|
headers: combineHeaders2(
|
|
@@ -357,32 +429,34 @@ var GoogleVertexImageModel = class _GoogleVertexImageModel {
|
|
|
357
429
|
body,
|
|
358
430
|
failedResponseHandler: googleVertexFailedResponseHandler,
|
|
359
431
|
successfulResponseHandler: createJsonResponseHandler2(
|
|
360
|
-
|
|
432
|
+
googleVertexImageResponseSchema
|
|
361
433
|
),
|
|
362
434
|
abortSignal,
|
|
363
435
|
fetch: this.config.fetch
|
|
364
436
|
});
|
|
365
437
|
return {
|
|
366
|
-
images: (
|
|
438
|
+
images: (_f = (_e = response.predictions) == null ? void 0 : _e.map(
|
|
367
439
|
({ bytesBase64Encoded }) => bytesBase64Encoded
|
|
368
|
-
)) != null ?
|
|
440
|
+
)) != null ? _f : [],
|
|
369
441
|
warnings,
|
|
370
442
|
response: {
|
|
371
443
|
timestamp: currentDate,
|
|
372
444
|
modelId: this.modelId,
|
|
373
445
|
headers: responseHeaders
|
|
374
446
|
},
|
|
375
|
-
providerMetadata: {
|
|
376
|
-
|
|
377
|
-
|
|
447
|
+
providerMetadata: (() => {
|
|
448
|
+
var _a2, _b2;
|
|
449
|
+
const payload = {
|
|
450
|
+
images: (_b2 = (_a2 = response.predictions) == null ? void 0 : _a2.map((prediction) => {
|
|
378
451
|
const {
|
|
379
452
|
// normalize revised prompt property
|
|
380
453
|
prompt: revisedPrompt
|
|
381
454
|
} = prediction;
|
|
382
455
|
return { ...revisedPrompt != null && { revisedPrompt } };
|
|
383
|
-
})) != null ?
|
|
384
|
-
}
|
|
385
|
-
|
|
456
|
+
})) != null ? _b2 : []
|
|
457
|
+
};
|
|
458
|
+
return { googleVertex: payload, vertex: payload };
|
|
459
|
+
})()
|
|
386
460
|
};
|
|
387
461
|
}
|
|
388
462
|
async doGenerateGemini({
|
|
@@ -425,13 +499,16 @@ var GoogleVertexImageModel = class _GoogleVertexImageModel {
|
|
|
425
499
|
if (file.type === "url") {
|
|
426
500
|
userContent.push({
|
|
427
501
|
type: "file",
|
|
428
|
-
data: new URL(file.url),
|
|
502
|
+
data: { type: "url", url: new URL(file.url) },
|
|
429
503
|
mediaType: "image/*"
|
|
430
504
|
});
|
|
431
505
|
} else {
|
|
432
506
|
userContent.push({
|
|
433
507
|
type: "file",
|
|
434
|
-
data:
|
|
508
|
+
data: {
|
|
509
|
+
type: "data",
|
|
510
|
+
data: typeof file.data === "string" ? file.data : new Uint8Array(file.data)
|
|
511
|
+
},
|
|
435
512
|
mediaType: file.mediaType
|
|
436
513
|
});
|
|
437
514
|
}
|
|
@@ -450,17 +527,20 @@ var GoogleVertexImageModel = class _GoogleVertexImageModel {
|
|
|
450
527
|
"*": [/^https?:\/\/.*$/, /^gs:\/\/.*$/]
|
|
451
528
|
})
|
|
452
529
|
});
|
|
530
|
+
const userVertexOptions = (_c = providerOptions == null ? void 0 : providerOptions.googleVertex) != null ? _c : providerOptions == null ? void 0 : providerOptions.vertex;
|
|
531
|
+
const innerVertexOptions = {
|
|
532
|
+
responseModalities: ["IMAGE"],
|
|
533
|
+
imageConfig: aspectRatio ? {
|
|
534
|
+
aspectRatio
|
|
535
|
+
} : void 0,
|
|
536
|
+
...userVertexOptions != null ? userVertexOptions : {}
|
|
537
|
+
};
|
|
453
538
|
const result = await languageModel.doGenerate({
|
|
454
539
|
prompt: languageModelPrompt,
|
|
455
540
|
seed,
|
|
456
541
|
providerOptions: {
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
imageConfig: aspectRatio ? {
|
|
460
|
-
aspectRatio
|
|
461
|
-
} : void 0,
|
|
462
|
-
...(_c = providerOptions == null ? void 0 : providerOptions.vertex) != null ? _c : {}
|
|
463
|
-
}
|
|
542
|
+
googleVertex: innerVertexOptions,
|
|
543
|
+
vertex: innerVertexOptions
|
|
464
544
|
},
|
|
465
545
|
headers,
|
|
466
546
|
abortSignal
|
|
@@ -468,17 +548,19 @@ var GoogleVertexImageModel = class _GoogleVertexImageModel {
|
|
|
468
548
|
const currentDate = (_f = (_e = (_d = this.config._internal) == null ? void 0 : _d.currentDate) == null ? void 0 : _e.call(_d)) != null ? _f : /* @__PURE__ */ new Date();
|
|
469
549
|
const images = [];
|
|
470
550
|
for (const part of result.content) {
|
|
471
|
-
if (part.type === "file" && part.mediaType.startsWith("image/")) {
|
|
472
|
-
images.push(convertToBase64(part.data));
|
|
551
|
+
if (part.type === "file" && part.mediaType.startsWith("image/") && part.data.type === "data") {
|
|
552
|
+
images.push(convertToBase64(part.data.data));
|
|
473
553
|
}
|
|
474
554
|
}
|
|
555
|
+
const geminiPayload = {
|
|
556
|
+
images: images.map(() => ({}))
|
|
557
|
+
};
|
|
475
558
|
return {
|
|
476
559
|
images,
|
|
477
560
|
warnings,
|
|
478
561
|
providerMetadata: {
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
}
|
|
562
|
+
googleVertex: geminiPayload,
|
|
563
|
+
vertex: geminiPayload
|
|
482
564
|
},
|
|
483
565
|
response: {
|
|
484
566
|
timestamp: currentDate,
|
|
@@ -496,71 +578,15 @@ var GoogleVertexImageModel = class _GoogleVertexImageModel {
|
|
|
496
578
|
function isGeminiModel(modelId) {
|
|
497
579
|
return modelId.startsWith("gemini-");
|
|
498
580
|
}
|
|
499
|
-
var
|
|
500
|
-
predictions:
|
|
501
|
-
|
|
502
|
-
bytesBase64Encoded:
|
|
503
|
-
mimeType:
|
|
504
|
-
prompt:
|
|
581
|
+
var googleVertexImageResponseSchema = z5.object({
|
|
582
|
+
predictions: z5.array(
|
|
583
|
+
z5.object({
|
|
584
|
+
bytesBase64Encoded: z5.string(),
|
|
585
|
+
mimeType: z5.string(),
|
|
586
|
+
prompt: z5.string().nullish()
|
|
505
587
|
})
|
|
506
588
|
).nullish()
|
|
507
589
|
});
|
|
508
|
-
var googleVertexImageModelOptionsSchema = z4.object({
|
|
509
|
-
negativePrompt: z4.string().nullish(),
|
|
510
|
-
personGeneration: z4.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
|
|
511
|
-
safetySetting: z4.enum([
|
|
512
|
-
"block_low_and_above",
|
|
513
|
-
"block_medium_and_above",
|
|
514
|
-
"block_only_high",
|
|
515
|
-
"block_none"
|
|
516
|
-
]).nullish(),
|
|
517
|
-
addWatermark: z4.boolean().nullish(),
|
|
518
|
-
storageUri: z4.string().nullish(),
|
|
519
|
-
sampleImageSize: z4.enum(["1K", "2K"]).nullish(),
|
|
520
|
-
/**
|
|
521
|
-
* Configuration for image editing operations
|
|
522
|
-
*/
|
|
523
|
-
edit: z4.object({
|
|
524
|
-
/**
|
|
525
|
-
* An integer that represents the number of sampling steps.
|
|
526
|
-
* A higher value offers better image quality, a lower value offers better latency.
|
|
527
|
-
* Try 35 steps to start. If the quality doesn't meet your requirements,
|
|
528
|
-
* increase the value towards an upper limit of 75.
|
|
529
|
-
*/
|
|
530
|
-
baseSteps: z4.number().nullish(),
|
|
531
|
-
// Edit mode options
|
|
532
|
-
// https://cloud.google.com/vertex-ai/generative-ai/docs/image/edit-insert-objects
|
|
533
|
-
mode: z4.enum([
|
|
534
|
-
"EDIT_MODE_INPAINT_INSERTION",
|
|
535
|
-
"EDIT_MODE_INPAINT_REMOVAL",
|
|
536
|
-
"EDIT_MODE_OUTPAINT",
|
|
537
|
-
"EDIT_MODE_CONTROLLED_EDITING",
|
|
538
|
-
"EDIT_MODE_PRODUCT_IMAGE",
|
|
539
|
-
"EDIT_MODE_BGSWAP"
|
|
540
|
-
]).nullish(),
|
|
541
|
-
/**
|
|
542
|
-
* The mask mode to use.
|
|
543
|
-
* - `MASK_MODE_DEFAULT` - Default value for mask mode.
|
|
544
|
-
* - `MASK_MODE_USER_PROVIDED` - User provided mask. No segmentation needed.
|
|
545
|
-
* - `MASK_MODE_DETECTION_BOX` - Mask from detected bounding boxes.
|
|
546
|
-
* - `MASK_MODE_CLOTHING_AREA` - Masks from segmenting the clothing area with open-vocab segmentation.
|
|
547
|
-
* - `MASK_MODE_PARSED_PERSON` - Masks from segmenting the person body and clothing using the person-parsing model.
|
|
548
|
-
*/
|
|
549
|
-
maskMode: z4.enum([
|
|
550
|
-
"MASK_MODE_DEFAULT",
|
|
551
|
-
"MASK_MODE_USER_PROVIDED",
|
|
552
|
-
"MASK_MODE_DETECTION_BOX",
|
|
553
|
-
"MASK_MODE_CLOTHING_AREA",
|
|
554
|
-
"MASK_MODE_PARSED_PERSON"
|
|
555
|
-
]).nullish(),
|
|
556
|
-
/**
|
|
557
|
-
* Optional. A float value between 0 and 1, inclusive, that represents the
|
|
558
|
-
* percentage of the image width to grow the mask by. Using dilation helps
|
|
559
|
-
* compensate for imprecise masks. We recommend a value of 0.01.
|
|
560
|
-
*/
|
|
561
|
-
maskDilation: z4.number().nullish()
|
|
562
|
-
}).nullish()
|
|
563
|
-
});
|
|
564
590
|
function getBase64Data(file) {
|
|
565
591
|
if (file.type === "url") {
|
|
566
592
|
throw new Error(
|
|
@@ -594,13 +620,35 @@ import {
|
|
|
594
620
|
convertUint8ArrayToBase64 as convertUint8ArrayToBase642,
|
|
595
621
|
createJsonResponseHandler as createJsonResponseHandler3,
|
|
596
622
|
delay,
|
|
597
|
-
lazySchema,
|
|
598
623
|
parseProviderOptions as parseProviderOptions3,
|
|
599
624
|
postJsonToApi as postJsonToApi3,
|
|
600
|
-
resolve as resolve3
|
|
601
|
-
zodSchema
|
|
625
|
+
resolve as resolve3
|
|
602
626
|
} from "@ai-sdk/provider-utils";
|
|
603
|
-
import { z as
|
|
627
|
+
import { z as z7 } from "zod/v4";
|
|
628
|
+
|
|
629
|
+
// src/google-vertex-video-model-options.ts
|
|
630
|
+
import { lazySchema, zodSchema } from "@ai-sdk/provider-utils";
|
|
631
|
+
import { z as z6 } from "zod/v4";
|
|
632
|
+
var googleVertexVideoModelOptionsSchema = lazySchema(
|
|
633
|
+
() => zodSchema(
|
|
634
|
+
z6.object({
|
|
635
|
+
pollIntervalMs: z6.number().positive().nullish(),
|
|
636
|
+
pollTimeoutMs: z6.number().positive().nullish(),
|
|
637
|
+
personGeneration: z6.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
|
|
638
|
+
negativePrompt: z6.string().nullish(),
|
|
639
|
+
generateAudio: z6.boolean().nullish(),
|
|
640
|
+
gcsOutputDirectory: z6.string().nullish(),
|
|
641
|
+
referenceImages: z6.array(
|
|
642
|
+
z6.object({
|
|
643
|
+
bytesBase64Encoded: z6.string().nullish(),
|
|
644
|
+
gcsUri: z6.string().nullish()
|
|
645
|
+
})
|
|
646
|
+
).nullish()
|
|
647
|
+
}).passthrough()
|
|
648
|
+
)
|
|
649
|
+
);
|
|
650
|
+
|
|
651
|
+
// src/google-vertex-video-model.ts
|
|
604
652
|
var GoogleVertexVideoModel = class {
|
|
605
653
|
constructor(modelId, config) {
|
|
606
654
|
this.modelId = modelId;
|
|
@@ -614,10 +662,14 @@ var GoogleVertexVideoModel = class {
|
|
|
614
662
|
return 4;
|
|
615
663
|
}
|
|
616
664
|
async doGenerate(options) {
|
|
617
|
-
var _a, _b, _c, _d, _e, _f;
|
|
665
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
618
666
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
619
667
|
const warnings = [];
|
|
620
|
-
const
|
|
668
|
+
const googleVertexOptions = (_d = await parseProviderOptions3({
|
|
669
|
+
provider: "googleVertex",
|
|
670
|
+
providerOptions: options.providerOptions,
|
|
671
|
+
schema: googleVertexVideoModelOptionsSchema
|
|
672
|
+
})) != null ? _d : await parseProviderOptions3({
|
|
621
673
|
provider: "vertex",
|
|
622
674
|
providerOptions: options.providerOptions,
|
|
623
675
|
schema: googleVertexVideoModelOptionsSchema
|
|
@@ -642,8 +694,8 @@ var GoogleVertexVideoModel = class {
|
|
|
642
694
|
};
|
|
643
695
|
}
|
|
644
696
|
}
|
|
645
|
-
if ((
|
|
646
|
-
instance.referenceImages =
|
|
697
|
+
if ((googleVertexOptions == null ? void 0 : googleVertexOptions.referenceImages) != null) {
|
|
698
|
+
instance.referenceImages = googleVertexOptions.referenceImages;
|
|
647
699
|
}
|
|
648
700
|
const parameters = {
|
|
649
701
|
sampleCount: options.n
|
|
@@ -665,8 +717,8 @@ var GoogleVertexVideoModel = class {
|
|
|
665
717
|
if (options.seed) {
|
|
666
718
|
parameters.seed = options.seed;
|
|
667
719
|
}
|
|
668
|
-
if (
|
|
669
|
-
const opts =
|
|
720
|
+
if (googleVertexOptions != null) {
|
|
721
|
+
const opts = googleVertexOptions;
|
|
670
722
|
if (opts.personGeneration !== void 0 && opts.personGeneration !== null) {
|
|
671
723
|
parameters.personGeneration = opts.personGeneration;
|
|
672
724
|
}
|
|
@@ -704,7 +756,7 @@ var GoogleVertexVideoModel = class {
|
|
|
704
756
|
parameters
|
|
705
757
|
},
|
|
706
758
|
successfulResponseHandler: createJsonResponseHandler3(
|
|
707
|
-
|
|
759
|
+
googleVertexOperationSchema
|
|
708
760
|
),
|
|
709
761
|
failedResponseHandler: googleVertexFailedResponseHandler,
|
|
710
762
|
abortSignal: options.abortSignal,
|
|
@@ -717,8 +769,8 @@ var GoogleVertexVideoModel = class {
|
|
|
717
769
|
message: "No operation name returned from API"
|
|
718
770
|
});
|
|
719
771
|
}
|
|
720
|
-
const pollIntervalMs = (
|
|
721
|
-
const pollTimeoutMs = (
|
|
772
|
+
const pollIntervalMs = (_e = googleVertexOptions == null ? void 0 : googleVertexOptions.pollIntervalMs) != null ? _e : 1e4;
|
|
773
|
+
const pollTimeoutMs = (_f = googleVertexOptions == null ? void 0 : googleVertexOptions.pollTimeoutMs) != null ? _f : 6e5;
|
|
722
774
|
const startTime = Date.now();
|
|
723
775
|
let finalOperation = operation;
|
|
724
776
|
let responseHeaders;
|
|
@@ -730,7 +782,7 @@ var GoogleVertexVideoModel = class {
|
|
|
730
782
|
});
|
|
731
783
|
}
|
|
732
784
|
await delay(pollIntervalMs);
|
|
733
|
-
if ((
|
|
785
|
+
if ((_g = options.abortSignal) == null ? void 0 : _g.aborted) {
|
|
734
786
|
throw new AISDKError({
|
|
735
787
|
name: "VERTEX_VIDEO_GENERATION_ABORTED",
|
|
736
788
|
message: "Video generation request was aborted"
|
|
@@ -746,7 +798,7 @@ var GoogleVertexVideoModel = class {
|
|
|
746
798
|
operationName
|
|
747
799
|
},
|
|
748
800
|
successfulResponseHandler: createJsonResponseHandler3(
|
|
749
|
-
|
|
801
|
+
googleVertexOperationSchema
|
|
750
802
|
),
|
|
751
803
|
failedResponseHandler: googleVertexFailedResponseHandler,
|
|
752
804
|
abortSignal: options.abortSignal,
|
|
@@ -806,53 +858,39 @@ var GoogleVertexVideoModel = class {
|
|
|
806
858
|
modelId: this.modelId,
|
|
807
859
|
headers: responseHeaders
|
|
808
860
|
},
|
|
809
|
-
providerMetadata: {
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
861
|
+
providerMetadata: /* @__PURE__ */ (() => {
|
|
862
|
+
const payload = { videos: videoMetadata };
|
|
863
|
+
return {
|
|
864
|
+
googleVertex: payload,
|
|
865
|
+
// Legacy keys preserved for backward compatibility.
|
|
866
|
+
"google-vertex": payload,
|
|
867
|
+
vertex: payload
|
|
868
|
+
};
|
|
869
|
+
})()
|
|
814
870
|
};
|
|
815
871
|
}
|
|
816
872
|
};
|
|
817
|
-
var
|
|
818
|
-
name:
|
|
819
|
-
done:
|
|
820
|
-
error:
|
|
821
|
-
code:
|
|
822
|
-
message:
|
|
823
|
-
status:
|
|
873
|
+
var googleVertexOperationSchema = z7.object({
|
|
874
|
+
name: z7.string().nullish(),
|
|
875
|
+
done: z7.boolean().nullish(),
|
|
876
|
+
error: z7.object({
|
|
877
|
+
code: z7.number().nullish(),
|
|
878
|
+
message: z7.string(),
|
|
879
|
+
status: z7.string().nullish()
|
|
824
880
|
}).nullish(),
|
|
825
|
-
response:
|
|
826
|
-
videos:
|
|
827
|
-
|
|
828
|
-
bytesBase64Encoded:
|
|
829
|
-
gcsUri:
|
|
830
|
-
mimeType:
|
|
881
|
+
response: z7.object({
|
|
882
|
+
videos: z7.array(
|
|
883
|
+
z7.object({
|
|
884
|
+
bytesBase64Encoded: z7.string().nullish(),
|
|
885
|
+
gcsUri: z7.string().nullish(),
|
|
886
|
+
mimeType: z7.string().nullish()
|
|
831
887
|
})
|
|
832
888
|
).nullish(),
|
|
833
|
-
raiMediaFilteredCount:
|
|
889
|
+
raiMediaFilteredCount: z7.number().nullish()
|
|
834
890
|
}).nullish()
|
|
835
891
|
});
|
|
836
|
-
var googleVertexVideoModelOptionsSchema = lazySchema(
|
|
837
|
-
() => zodSchema(
|
|
838
|
-
z5.object({
|
|
839
|
-
pollIntervalMs: z5.number().positive().nullish(),
|
|
840
|
-
pollTimeoutMs: z5.number().positive().nullish(),
|
|
841
|
-
personGeneration: z5.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
|
|
842
|
-
negativePrompt: z5.string().nullish(),
|
|
843
|
-
generateAudio: z5.boolean().nullish(),
|
|
844
|
-
gcsOutputDirectory: z5.string().nullish(),
|
|
845
|
-
referenceImages: z5.array(
|
|
846
|
-
z5.object({
|
|
847
|
-
bytesBase64Encoded: z5.string().nullish(),
|
|
848
|
-
gcsUri: z5.string().nullish()
|
|
849
|
-
})
|
|
850
|
-
).nullish()
|
|
851
|
-
}).passthrough()
|
|
852
|
-
)
|
|
853
|
-
);
|
|
854
892
|
|
|
855
|
-
// src/google-vertex-provider.ts
|
|
893
|
+
// src/google-vertex-provider-base.ts
|
|
856
894
|
var EXPRESS_MODE_BASE_URL = "https://aiplatform.googleapis.com/v1/publishers/google";
|
|
857
895
|
function createExpressModeFetch(apiKey, customFetch) {
|
|
858
896
|
return async (url, init) => {
|
|
@@ -866,18 +904,18 @@ function createExpressModeFetch(apiKey, customFetch) {
|
|
|
866
904
|
return (customFetch != null ? customFetch : fetch)(url.toString(), modifiedInit);
|
|
867
905
|
};
|
|
868
906
|
}
|
|
869
|
-
function
|
|
907
|
+
function createGoogleVertex(options = {}) {
|
|
870
908
|
const apiKey = loadOptionalSetting({
|
|
871
909
|
settingValue: options.apiKey,
|
|
872
910
|
environmentVariableName: "GOOGLE_VERTEX_API_KEY"
|
|
873
911
|
});
|
|
874
|
-
const
|
|
912
|
+
const loadGoogleVertexProject = () => loadSetting({
|
|
875
913
|
settingValue: options.project,
|
|
876
914
|
settingName: "project",
|
|
877
915
|
environmentVariableName: "GOOGLE_VERTEX_PROJECT",
|
|
878
916
|
description: "Google Vertex project"
|
|
879
917
|
});
|
|
880
|
-
const
|
|
918
|
+
const loadGoogleVertexLocation = () => loadSetting({
|
|
881
919
|
settingValue: options.location,
|
|
882
920
|
settingName: "location",
|
|
883
921
|
environmentVariableName: "GOOGLE_VERTEX_LOCATION",
|
|
@@ -888,8 +926,8 @@ function createVertex(options = {}) {
|
|
|
888
926
|
if (apiKey) {
|
|
889
927
|
return (_a = withoutTrailingSlash(options.baseURL)) != null ? _a : EXPRESS_MODE_BASE_URL;
|
|
890
928
|
}
|
|
891
|
-
const region =
|
|
892
|
-
const project =
|
|
929
|
+
const region = loadGoogleVertexLocation();
|
|
930
|
+
const project = loadGoogleVertexProject();
|
|
893
931
|
const baseHost = `${region === "global" ? "" : region + "-"}aiplatform.googleapis.com`;
|
|
894
932
|
return (_b = withoutTrailingSlash(options.baseURL)) != null ? _b : `https://${baseHost}/v1beta1/projects/${project}/locations/${region}/publishers/google`;
|
|
895
933
|
};
|
|
@@ -959,16 +997,16 @@ function createVertex(options = {}) {
|
|
|
959
997
|
return provider;
|
|
960
998
|
}
|
|
961
999
|
|
|
962
|
-
// src/google-vertex-provider
|
|
963
|
-
function
|
|
1000
|
+
// src/google-vertex-provider.ts
|
|
1001
|
+
function createGoogleVertex2(options = {}) {
|
|
964
1002
|
const apiKey = loadOptionalSetting2({
|
|
965
1003
|
settingValue: options.apiKey,
|
|
966
1004
|
environmentVariableName: "GOOGLE_VERTEX_API_KEY"
|
|
967
1005
|
});
|
|
968
1006
|
if (apiKey) {
|
|
969
|
-
return
|
|
1007
|
+
return createGoogleVertex(options);
|
|
970
1008
|
}
|
|
971
|
-
return
|
|
1009
|
+
return createGoogleVertex({
|
|
972
1010
|
...options,
|
|
973
1011
|
headers: async () => ({
|
|
974
1012
|
Authorization: `Bearer ${await generateAuthToken(
|
|
@@ -978,10 +1016,12 @@ function createVertex2(options = {}) {
|
|
|
978
1016
|
})
|
|
979
1017
|
});
|
|
980
1018
|
}
|
|
981
|
-
var
|
|
1019
|
+
var googleVertex = createGoogleVertex2();
|
|
982
1020
|
export {
|
|
983
1021
|
VERSION,
|
|
984
|
-
|
|
985
|
-
|
|
1022
|
+
createGoogleVertex2 as createGoogleVertex,
|
|
1023
|
+
createGoogleVertex2 as createVertex,
|
|
1024
|
+
googleVertex,
|
|
1025
|
+
googleVertex as vertex
|
|
986
1026
|
};
|
|
987
1027
|
//# sourceMappingURL=index.js.map
|