@ai-sdk/google-vertex 4.0.196 → 4.0.198
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 +22 -0
- package/dist/anthropic/edge/index.js +1 -1
- package/dist/anthropic/edge/index.mjs +1 -1
- package/dist/edge/index.d.mts +1 -1
- package/dist/edge/index.d.ts +1 -1
- package/dist/edge/index.js +19 -9
- package/dist/edge/index.js.map +1 -1
- package/dist/edge/index.mjs +19 -9
- package/dist/edge/index.mjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +19 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -9
- package/dist/index.mjs.map +1 -1
- package/dist/maas/edge/index.js +1 -1
- package/dist/maas/edge/index.mjs +1 -1
- package/dist/xai/edge/index.js +1 -1
- package/dist/xai/edge/index.mjs +1 -1
- package/docs/16-google-vertex.mdx +1 -0
- package/package.json +6 -6
- package/src/google-vertex-image-model.ts +29 -10
- package/src/google-vertex-options.ts +1 -0
|
@@ -174,11 +174,24 @@ export class GoogleVertexImageModel implements ImageModelV3 {
|
|
|
174
174
|
fetch: this.config.fetch,
|
|
175
175
|
});
|
|
176
176
|
|
|
177
|
+
const imagePredictions =
|
|
178
|
+
response.predictions?.filter(
|
|
179
|
+
(
|
|
180
|
+
prediction,
|
|
181
|
+
): prediction is {
|
|
182
|
+
bytesBase64Encoded: string;
|
|
183
|
+
mimeType: string;
|
|
184
|
+
prompt?: string | null;
|
|
185
|
+
} => 'bytesBase64Encoded' in prediction,
|
|
186
|
+
) ?? [];
|
|
187
|
+
|
|
177
188
|
return {
|
|
178
|
-
images:
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
189
|
+
images: imagePredictions.map(
|
|
190
|
+
({ bytesBase64Encoded }) => bytesBase64Encoded,
|
|
191
|
+
),
|
|
192
|
+
...(response.predictions?.some(
|
|
193
|
+
prediction => 'raiFilteredReason' in prediction,
|
|
194
|
+
) && { isRetryable: false }),
|
|
182
195
|
warnings,
|
|
183
196
|
response: {
|
|
184
197
|
timestamp: currentDate,
|
|
@@ -188,7 +201,7 @@ export class GoogleVertexImageModel implements ImageModelV3 {
|
|
|
188
201
|
providerMetadata: {
|
|
189
202
|
vertex: {
|
|
190
203
|
images:
|
|
191
|
-
|
|
204
|
+
imagePredictions.map(prediction => {
|
|
192
205
|
const {
|
|
193
206
|
// normalize revised prompt property
|
|
194
207
|
prompt: revisedPrompt,
|
|
@@ -317,6 +330,9 @@ export class GoogleVertexImageModel implements ImageModelV3 {
|
|
|
317
330
|
|
|
318
331
|
return {
|
|
319
332
|
images,
|
|
333
|
+
...(result.finishReason.unified === 'content-filter'
|
|
334
|
+
? { isRetryable: false }
|
|
335
|
+
: {}),
|
|
320
336
|
warnings,
|
|
321
337
|
providerMetadata: {
|
|
322
338
|
vertex: {
|
|
@@ -350,11 +366,14 @@ function isGeminiModel(modelId: string): boolean {
|
|
|
350
366
|
const vertexImageResponseSchema = z.object({
|
|
351
367
|
predictions: z
|
|
352
368
|
.array(
|
|
353
|
-
z.
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
369
|
+
z.union([
|
|
370
|
+
z.object({
|
|
371
|
+
bytesBase64Encoded: z.string(),
|
|
372
|
+
mimeType: z.string(),
|
|
373
|
+
prompt: z.string().nullish(),
|
|
374
|
+
}),
|
|
375
|
+
z.object({ raiFilteredReason: z.string() }),
|
|
376
|
+
]),
|
|
358
377
|
)
|
|
359
378
|
.nullish(),
|
|
360
379
|
});
|