@ai-sdk/google-vertex 5.0.0-beta.62 → 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 +18 -0
- package/dist/anthropic/edge/index.d.ts +10 -5
- package/dist/anthropic/edge/index.js +15 -13
- package/dist/anthropic/edge/index.js.map +1 -1
- package/dist/anthropic/index.d.ts +10 -5
- 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 +190 -153
- package/dist/edge/index.js.map +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.js +192 -155
- package/dist/index.js.map +1 -1
- package/dist/maas/edge/index.d.ts +3 -3
- package/dist/maas/edge/index.js +9 -7
- package/dist/maas/edge/index.js.map +1 -1
- package/dist/maas/index.d.ts +3 -3
- package/dist/maas/index.js +8 -6
- package/dist/maas/index.js.map +1 -1
- package/docs/16-google-vertex.mdx +75 -75
- package/package.json +5 -5
- package/src/anthropic/edge/google-vertex-anthropic-provider-edge.ts +13 -7
- package/src/anthropic/edge/index.ts +6 -2
- package/src/anthropic/google-vertex-anthropic-provider-node.ts +13 -7
- package/src/anthropic/google-vertex-anthropic-provider.ts +5 -5
- package/src/anthropic/index.ts +6 -2
- package/src/edge/google-vertex-provider-edge.ts +6 -6
- package/src/edge/index.ts +8 -1
- package/src/google-vertex-embedding-model.ts +10 -2
- package/src/google-vertex-image-model-options.ts +74 -0
- package/src/google-vertex-image-model.ts +42 -102
- 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 +30 -66
- package/src/index.ts +12 -5
- package/src/maas/edge/google-vertex-maas-provider-edge.ts +3 -3
- package/src/maas/edge/index.ts +6 -2
- package/src/maas/google-vertex-maas-provider-node.ts +3 -3
- package/src/maas/google-vertex-maas-provider.ts +1 -1
- package/src/maas/index.ts +6 -2
- package/src/google-vertex-provider-node.ts +0 -47
- /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({
|
|
@@ -432,17 +506,20 @@ var GoogleVertexImageModel = class _GoogleVertexImageModel {
|
|
|
432
506
|
"*": [/^https?:\/\/.*$/, /^gs:\/\/.*$/]
|
|
433
507
|
})
|
|
434
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
|
+
};
|
|
435
517
|
const result = await languageModel.doGenerate({
|
|
436
518
|
prompt: languageModelPrompt,
|
|
437
519
|
seed,
|
|
438
520
|
providerOptions: {
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
imageConfig: aspectRatio ? {
|
|
442
|
-
aspectRatio
|
|
443
|
-
} : void 0,
|
|
444
|
-
...(_c = providerOptions == null ? void 0 : providerOptions.vertex) != null ? _c : {}
|
|
445
|
-
}
|
|
521
|
+
googleVertex: innerVertexOptions,
|
|
522
|
+
vertex: innerVertexOptions
|
|
446
523
|
},
|
|
447
524
|
headers,
|
|
448
525
|
abortSignal
|
|
@@ -454,13 +531,15 @@ var GoogleVertexImageModel = class _GoogleVertexImageModel {
|
|
|
454
531
|
images.push(convertToBase64(part.data.data));
|
|
455
532
|
}
|
|
456
533
|
}
|
|
534
|
+
const geminiPayload = {
|
|
535
|
+
images: images.map(() => ({}))
|
|
536
|
+
};
|
|
457
537
|
return {
|
|
458
538
|
images,
|
|
459
539
|
warnings,
|
|
460
540
|
providerMetadata: {
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
}
|
|
541
|
+
googleVertex: geminiPayload,
|
|
542
|
+
vertex: geminiPayload
|
|
464
543
|
},
|
|
465
544
|
response: {
|
|
466
545
|
timestamp: currentDate,
|
|
@@ -478,71 +557,15 @@ var GoogleVertexImageModel = class _GoogleVertexImageModel {
|
|
|
478
557
|
function isGeminiModel(modelId) {
|
|
479
558
|
return modelId.startsWith("gemini-");
|
|
480
559
|
}
|
|
481
|
-
var
|
|
482
|
-
predictions:
|
|
483
|
-
|
|
484
|
-
bytesBase64Encoded:
|
|
485
|
-
mimeType:
|
|
486
|
-
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()
|
|
487
566
|
})
|
|
488
567
|
).nullish()
|
|
489
568
|
});
|
|
490
|
-
var googleVertexImageModelOptionsSchema = z4.object({
|
|
491
|
-
negativePrompt: z4.string().nullish(),
|
|
492
|
-
personGeneration: z4.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
|
|
493
|
-
safetySetting: z4.enum([
|
|
494
|
-
"block_low_and_above",
|
|
495
|
-
"block_medium_and_above",
|
|
496
|
-
"block_only_high",
|
|
497
|
-
"block_none"
|
|
498
|
-
]).nullish(),
|
|
499
|
-
addWatermark: z4.boolean().nullish(),
|
|
500
|
-
storageUri: z4.string().nullish(),
|
|
501
|
-
sampleImageSize: z4.enum(["1K", "2K"]).nullish(),
|
|
502
|
-
/**
|
|
503
|
-
* Configuration for image editing operations
|
|
504
|
-
*/
|
|
505
|
-
edit: z4.object({
|
|
506
|
-
/**
|
|
507
|
-
* An integer that represents the number of sampling steps.
|
|
508
|
-
* A higher value offers better image quality, a lower value offers better latency.
|
|
509
|
-
* Try 35 steps to start. If the quality doesn't meet your requirements,
|
|
510
|
-
* increase the value towards an upper limit of 75.
|
|
511
|
-
*/
|
|
512
|
-
baseSteps: z4.number().nullish(),
|
|
513
|
-
// Edit mode options
|
|
514
|
-
// https://cloud.google.com/vertex-ai/generative-ai/docs/image/edit-insert-objects
|
|
515
|
-
mode: z4.enum([
|
|
516
|
-
"EDIT_MODE_INPAINT_INSERTION",
|
|
517
|
-
"EDIT_MODE_INPAINT_REMOVAL",
|
|
518
|
-
"EDIT_MODE_OUTPAINT",
|
|
519
|
-
"EDIT_MODE_CONTROLLED_EDITING",
|
|
520
|
-
"EDIT_MODE_PRODUCT_IMAGE",
|
|
521
|
-
"EDIT_MODE_BGSWAP"
|
|
522
|
-
]).nullish(),
|
|
523
|
-
/**
|
|
524
|
-
* The mask mode to use.
|
|
525
|
-
* - `MASK_MODE_DEFAULT` - Default value for mask mode.
|
|
526
|
-
* - `MASK_MODE_USER_PROVIDED` - User provided mask. No segmentation needed.
|
|
527
|
-
* - `MASK_MODE_DETECTION_BOX` - Mask from detected bounding boxes.
|
|
528
|
-
* - `MASK_MODE_CLOTHING_AREA` - Masks from segmenting the clothing area with open-vocab segmentation.
|
|
529
|
-
* - `MASK_MODE_PARSED_PERSON` - Masks from segmenting the person body and clothing using the person-parsing model.
|
|
530
|
-
*/
|
|
531
|
-
maskMode: z4.enum([
|
|
532
|
-
"MASK_MODE_DEFAULT",
|
|
533
|
-
"MASK_MODE_USER_PROVIDED",
|
|
534
|
-
"MASK_MODE_DETECTION_BOX",
|
|
535
|
-
"MASK_MODE_CLOTHING_AREA",
|
|
536
|
-
"MASK_MODE_PARSED_PERSON"
|
|
537
|
-
]).nullish(),
|
|
538
|
-
/**
|
|
539
|
-
* Optional. A float value between 0 and 1, inclusive, that represents the
|
|
540
|
-
* percentage of the image width to grow the mask by. Using dilation helps
|
|
541
|
-
* compensate for imprecise masks. We recommend a value of 0.01.
|
|
542
|
-
*/
|
|
543
|
-
maskDilation: z4.number().nullish()
|
|
544
|
-
}).nullish()
|
|
545
|
-
});
|
|
546
569
|
function getBase64Data(file) {
|
|
547
570
|
if (file.type === "url") {
|
|
548
571
|
throw new Error(
|
|
@@ -576,13 +599,35 @@ import {
|
|
|
576
599
|
convertUint8ArrayToBase64 as convertUint8ArrayToBase642,
|
|
577
600
|
createJsonResponseHandler as createJsonResponseHandler3,
|
|
578
601
|
delay,
|
|
579
|
-
lazySchema,
|
|
580
602
|
parseProviderOptions as parseProviderOptions3,
|
|
581
603
|
postJsonToApi as postJsonToApi3,
|
|
582
|
-
resolve as resolve3
|
|
583
|
-
zodSchema
|
|
604
|
+
resolve as resolve3
|
|
584
605
|
} from "@ai-sdk/provider-utils";
|
|
585
|
-
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
|
|
586
631
|
var GoogleVertexVideoModel = class {
|
|
587
632
|
constructor(modelId, config) {
|
|
588
633
|
this.modelId = modelId;
|
|
@@ -596,10 +641,14 @@ var GoogleVertexVideoModel = class {
|
|
|
596
641
|
return 4;
|
|
597
642
|
}
|
|
598
643
|
async doGenerate(options) {
|
|
599
|
-
var _a, _b, _c, _d, _e, _f;
|
|
644
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
600
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();
|
|
601
646
|
const warnings = [];
|
|
602
|
-
const
|
|
647
|
+
const googleVertexOptions = (_d = await parseProviderOptions3({
|
|
648
|
+
provider: "googleVertex",
|
|
649
|
+
providerOptions: options.providerOptions,
|
|
650
|
+
schema: googleVertexVideoModelOptionsSchema
|
|
651
|
+
})) != null ? _d : await parseProviderOptions3({
|
|
603
652
|
provider: "vertex",
|
|
604
653
|
providerOptions: options.providerOptions,
|
|
605
654
|
schema: googleVertexVideoModelOptionsSchema
|
|
@@ -624,8 +673,8 @@ var GoogleVertexVideoModel = class {
|
|
|
624
673
|
};
|
|
625
674
|
}
|
|
626
675
|
}
|
|
627
|
-
if ((
|
|
628
|
-
instance.referenceImages =
|
|
676
|
+
if ((googleVertexOptions == null ? void 0 : googleVertexOptions.referenceImages) != null) {
|
|
677
|
+
instance.referenceImages = googleVertexOptions.referenceImages;
|
|
629
678
|
}
|
|
630
679
|
const parameters = {
|
|
631
680
|
sampleCount: options.n
|
|
@@ -647,8 +696,8 @@ var GoogleVertexVideoModel = class {
|
|
|
647
696
|
if (options.seed) {
|
|
648
697
|
parameters.seed = options.seed;
|
|
649
698
|
}
|
|
650
|
-
if (
|
|
651
|
-
const opts =
|
|
699
|
+
if (googleVertexOptions != null) {
|
|
700
|
+
const opts = googleVertexOptions;
|
|
652
701
|
if (opts.personGeneration !== void 0 && opts.personGeneration !== null) {
|
|
653
702
|
parameters.personGeneration = opts.personGeneration;
|
|
654
703
|
}
|
|
@@ -686,7 +735,7 @@ var GoogleVertexVideoModel = class {
|
|
|
686
735
|
parameters
|
|
687
736
|
},
|
|
688
737
|
successfulResponseHandler: createJsonResponseHandler3(
|
|
689
|
-
|
|
738
|
+
googleVertexOperationSchema
|
|
690
739
|
),
|
|
691
740
|
failedResponseHandler: googleVertexFailedResponseHandler,
|
|
692
741
|
abortSignal: options.abortSignal,
|
|
@@ -699,8 +748,8 @@ var GoogleVertexVideoModel = class {
|
|
|
699
748
|
message: "No operation name returned from API"
|
|
700
749
|
});
|
|
701
750
|
}
|
|
702
|
-
const pollIntervalMs = (
|
|
703
|
-
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;
|
|
704
753
|
const startTime = Date.now();
|
|
705
754
|
let finalOperation = operation;
|
|
706
755
|
let responseHeaders;
|
|
@@ -712,7 +761,7 @@ var GoogleVertexVideoModel = class {
|
|
|
712
761
|
});
|
|
713
762
|
}
|
|
714
763
|
await delay(pollIntervalMs);
|
|
715
|
-
if ((
|
|
764
|
+
if ((_g = options.abortSignal) == null ? void 0 : _g.aborted) {
|
|
716
765
|
throw new AISDKError({
|
|
717
766
|
name: "VERTEX_VIDEO_GENERATION_ABORTED",
|
|
718
767
|
message: "Video generation request was aborted"
|
|
@@ -728,7 +777,7 @@ var GoogleVertexVideoModel = class {
|
|
|
728
777
|
operationName
|
|
729
778
|
},
|
|
730
779
|
successfulResponseHandler: createJsonResponseHandler3(
|
|
731
|
-
|
|
780
|
+
googleVertexOperationSchema
|
|
732
781
|
),
|
|
733
782
|
failedResponseHandler: googleVertexFailedResponseHandler,
|
|
734
783
|
abortSignal: options.abortSignal,
|
|
@@ -788,53 +837,39 @@ var GoogleVertexVideoModel = class {
|
|
|
788
837
|
modelId: this.modelId,
|
|
789
838
|
headers: responseHeaders
|
|
790
839
|
},
|
|
791
|
-
providerMetadata: {
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
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
|
+
})()
|
|
796
849
|
};
|
|
797
850
|
}
|
|
798
851
|
};
|
|
799
|
-
var
|
|
800
|
-
name:
|
|
801
|
-
done:
|
|
802
|
-
error:
|
|
803
|
-
code:
|
|
804
|
-
message:
|
|
805
|
-
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()
|
|
806
859
|
}).nullish(),
|
|
807
|
-
response:
|
|
808
|
-
videos:
|
|
809
|
-
|
|
810
|
-
bytesBase64Encoded:
|
|
811
|
-
gcsUri:
|
|
812
|
-
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()
|
|
813
866
|
})
|
|
814
867
|
).nullish(),
|
|
815
|
-
raiMediaFilteredCount:
|
|
868
|
+
raiMediaFilteredCount: z7.number().nullish()
|
|
816
869
|
}).nullish()
|
|
817
870
|
});
|
|
818
|
-
var googleVertexVideoModelOptionsSchema = lazySchema(
|
|
819
|
-
() => zodSchema(
|
|
820
|
-
z5.object({
|
|
821
|
-
pollIntervalMs: z5.number().positive().nullish(),
|
|
822
|
-
pollTimeoutMs: z5.number().positive().nullish(),
|
|
823
|
-
personGeneration: z5.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
|
|
824
|
-
negativePrompt: z5.string().nullish(),
|
|
825
|
-
generateAudio: z5.boolean().nullish(),
|
|
826
|
-
gcsOutputDirectory: z5.string().nullish(),
|
|
827
|
-
referenceImages: z5.array(
|
|
828
|
-
z5.object({
|
|
829
|
-
bytesBase64Encoded: z5.string().nullish(),
|
|
830
|
-
gcsUri: z5.string().nullish()
|
|
831
|
-
})
|
|
832
|
-
).nullish()
|
|
833
|
-
}).passthrough()
|
|
834
|
-
)
|
|
835
|
-
);
|
|
836
871
|
|
|
837
|
-
// src/google-vertex-provider.ts
|
|
872
|
+
// src/google-vertex-provider-base.ts
|
|
838
873
|
var EXPRESS_MODE_BASE_URL = "https://aiplatform.googleapis.com/v1/publishers/google";
|
|
839
874
|
function createExpressModeFetch(apiKey, customFetch) {
|
|
840
875
|
return async (url, init) => {
|
|
@@ -848,18 +883,18 @@ function createExpressModeFetch(apiKey, customFetch) {
|
|
|
848
883
|
return (customFetch != null ? customFetch : fetch)(url.toString(), modifiedInit);
|
|
849
884
|
};
|
|
850
885
|
}
|
|
851
|
-
function
|
|
886
|
+
function createGoogleVertex(options = {}) {
|
|
852
887
|
const apiKey = loadOptionalSetting({
|
|
853
888
|
settingValue: options.apiKey,
|
|
854
889
|
environmentVariableName: "GOOGLE_VERTEX_API_KEY"
|
|
855
890
|
});
|
|
856
|
-
const
|
|
891
|
+
const loadGoogleVertexProject = () => loadSetting({
|
|
857
892
|
settingValue: options.project,
|
|
858
893
|
settingName: "project",
|
|
859
894
|
environmentVariableName: "GOOGLE_VERTEX_PROJECT",
|
|
860
895
|
description: "Google Vertex project"
|
|
861
896
|
});
|
|
862
|
-
const
|
|
897
|
+
const loadGoogleVertexLocation = () => loadSetting({
|
|
863
898
|
settingValue: options.location,
|
|
864
899
|
settingName: "location",
|
|
865
900
|
environmentVariableName: "GOOGLE_VERTEX_LOCATION",
|
|
@@ -870,8 +905,8 @@ function createVertex(options = {}) {
|
|
|
870
905
|
if (apiKey) {
|
|
871
906
|
return (_a = withoutTrailingSlash(options.baseURL)) != null ? _a : EXPRESS_MODE_BASE_URL;
|
|
872
907
|
}
|
|
873
|
-
const region =
|
|
874
|
-
const project =
|
|
908
|
+
const region = loadGoogleVertexLocation();
|
|
909
|
+
const project = loadGoogleVertexProject();
|
|
875
910
|
const baseHost = `${region === "global" ? "" : region + "-"}aiplatform.googleapis.com`;
|
|
876
911
|
return (_b = withoutTrailingSlash(options.baseURL)) != null ? _b : `https://${baseHost}/v1beta1/projects/${project}/locations/${region}/publishers/google`;
|
|
877
912
|
};
|
|
@@ -1053,15 +1088,15 @@ async function generateAuthToken(credentials) {
|
|
|
1053
1088
|
}
|
|
1054
1089
|
|
|
1055
1090
|
// src/edge/google-vertex-provider-edge.ts
|
|
1056
|
-
function
|
|
1091
|
+
function createGoogleVertex2(options = {}) {
|
|
1057
1092
|
const apiKey = loadOptionalSetting3({
|
|
1058
1093
|
settingValue: options.apiKey,
|
|
1059
1094
|
environmentVariableName: "GOOGLE_VERTEX_API_KEY"
|
|
1060
1095
|
});
|
|
1061
1096
|
if (apiKey) {
|
|
1062
|
-
return
|
|
1097
|
+
return createGoogleVertex(options);
|
|
1063
1098
|
}
|
|
1064
|
-
return
|
|
1099
|
+
return createGoogleVertex({
|
|
1065
1100
|
...options,
|
|
1066
1101
|
headers: async () => ({
|
|
1067
1102
|
Authorization: `Bearer ${await generateAuthToken(
|
|
@@ -1071,9 +1106,11 @@ function createVertex2(options = {}) {
|
|
|
1071
1106
|
})
|
|
1072
1107
|
});
|
|
1073
1108
|
}
|
|
1074
|
-
var
|
|
1109
|
+
var googleVertex = createGoogleVertex2();
|
|
1075
1110
|
export {
|
|
1076
|
-
|
|
1077
|
-
|
|
1111
|
+
createGoogleVertex2 as createGoogleVertex,
|
|
1112
|
+
createGoogleVertex2 as createVertex,
|
|
1113
|
+
googleVertex,
|
|
1114
|
+
googleVertex as vertex
|
|
1078
1115
|
};
|
|
1079
1116
|
//# sourceMappingURL=index.js.map
|