@ai-sdk/google-vertex 4.0.219 → 4.0.221
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 +23 -0
- package/dist/anthropic/edge/index.js +1 -1
- package/dist/anthropic/edge/index.mjs +1 -1
- package/dist/edge/index.js +358 -311
- package/dist/edge/index.js.map +1 -1
- package/dist/edge/index.mjs +317 -249
- package/dist/edge/index.mjs.map +1 -1
- package/dist/index.d.mts +39 -77
- package/dist/index.d.ts +39 -77
- package/dist/index.js +352 -305
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +317 -249
- 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/package.json +5 -5
- package/src/gemini-transcription/google-vertex-gemini-transcription-model-options.ts +40 -31
- package/src/gemini-transcription/google-vertex-gemini-transcription-model.ts +40 -33
- package/src/google-vertex-embedding-model.ts +28 -18
- package/src/google-vertex-embedding-options.ts +52 -43
- package/src/google-vertex-error.ts +20 -9
- package/src/google-vertex-image-model.ts +90 -79
- package/src/google-vertex-transcription-model-options.ts +39 -30
- package/src/google-vertex-transcription-model.ts +36 -30
- package/src/google-vertex-video-model.ts +28 -24
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import {
|
|
2
|
+
lazySchema,
|
|
3
|
+
zodSchema,
|
|
4
|
+
type InferSchema,
|
|
5
|
+
} from '@ai-sdk/provider-utils';
|
|
1
6
|
import { z } from 'zod/v4';
|
|
2
7
|
|
|
3
8
|
export type GoogleVertexGeminiTranscriptionModelId =
|
|
@@ -11,41 +16,45 @@ export type GoogleVertexGeminiTranscriptionModelId =
|
|
|
11
16
|
* The live variant (`gemini-3.5-transcribe-live`) requires streaming
|
|
12
17
|
* transcription, which is only available in AI SDK v7.
|
|
13
18
|
*/
|
|
14
|
-
export const googleVertexGeminiTranscriptionModelOptions =
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
export const googleVertexGeminiTranscriptionModelOptions = lazySchema(() =>
|
|
20
|
+
zodSchema(
|
|
21
|
+
z.object({
|
|
22
|
+
/**
|
|
23
|
+
* BCP-47 language codes providing hints about the languages present in the
|
|
24
|
+
* audio. If omitted or empty, defaults to automatic language detection.
|
|
25
|
+
*/
|
|
26
|
+
languageCodes: z.array(z.string()).optional(),
|
|
20
27
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Custom vocabulary phrases, which bias the speech recognition model
|
|
30
|
+
* toward recognizing specific terms.
|
|
31
|
+
*/
|
|
32
|
+
customVocabulary: z.array(z.string()).optional(),
|
|
26
33
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Enables word-level timestamp generation.
|
|
36
|
+
*/
|
|
37
|
+
wordTimestamp: z.boolean().optional(),
|
|
31
38
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Enables speaker diarization.
|
|
41
|
+
*/
|
|
42
|
+
diarization: z.boolean().optional(),
|
|
36
43
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
})
|
|
44
|
+
/**
|
|
45
|
+
* Transcription output formatting mode.
|
|
46
|
+
*
|
|
47
|
+
* - `VERBATIM` (default): exact literal transcript preserving filler
|
|
48
|
+
* words, repetitions, and false starts.
|
|
49
|
+
* - `SMART`: cleans up and structures the transcript in real time —
|
|
50
|
+
* disfluency removal, inline self-corrections, structured formatting
|
|
51
|
+
* (lists, numbers, dates, paragraph breaks), and grammar/casing polish.
|
|
52
|
+
*/
|
|
53
|
+
mode: z.enum(['SMART', 'VERBATIM']).optional(),
|
|
54
|
+
}),
|
|
55
|
+
),
|
|
56
|
+
);
|
|
48
57
|
|
|
49
|
-
export type GoogleVertexTranscriptionModelGeminiOptions =
|
|
58
|
+
export type GoogleVertexTranscriptionModelGeminiOptions = InferSchema<
|
|
50
59
|
typeof googleVertexGeminiTranscriptionModelOptions
|
|
51
60
|
>;
|
|
@@ -5,6 +5,8 @@ import {
|
|
|
5
5
|
type TranscriptionModelV3,
|
|
6
6
|
} from '@ai-sdk/provider';
|
|
7
7
|
import {
|
|
8
|
+
lazySchema,
|
|
9
|
+
zodSchema,
|
|
8
10
|
combineHeaders,
|
|
9
11
|
convertToBase64,
|
|
10
12
|
createJsonResponseHandler,
|
|
@@ -215,39 +217,44 @@ function parseOffsetSeconds(
|
|
|
215
217
|
return Number.isFinite(parsed) ? parsed : undefined;
|
|
216
218
|
}
|
|
217
219
|
|
|
218
|
-
const googleVertexGeminiTranscriptionWordSchema =
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
.object({
|
|
220
|
+
const googleVertexGeminiTranscriptionWordSchema = () =>
|
|
221
|
+
z.object({
|
|
222
|
+
word: z.string().nullish(),
|
|
223
|
+
startOffset: z.string().nullish(),
|
|
224
|
+
endOffset: z.string().nullish(),
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
const googleVertexGeminiTranscriptionResponseSchema = lazySchema(() =>
|
|
228
|
+
zodSchema(
|
|
229
|
+
z.object({
|
|
230
|
+
candidates: z
|
|
231
|
+
.array(
|
|
232
|
+
z.object({
|
|
233
|
+
content: z
|
|
234
|
+
.object({
|
|
235
|
+
parts: z
|
|
236
|
+
.array(
|
|
237
|
+
z.object({
|
|
236
238
|
text: z.string().nullish(),
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
239
|
+
audioTranscription: z
|
|
240
|
+
.object({
|
|
241
|
+
text: z.string().nullish(),
|
|
242
|
+
languageCode: z.string().nullish(),
|
|
243
|
+
speakerLabel: z.string().nullish(),
|
|
244
|
+
words: z
|
|
245
|
+
.array(googleVertexGeminiTranscriptionWordSchema())
|
|
246
|
+
.nullish(),
|
|
247
|
+
})
|
|
241
248
|
.nullish(),
|
|
242
|
-
})
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
)
|
|
249
|
+
}),
|
|
250
|
+
)
|
|
251
|
+
.nullish(),
|
|
252
|
+
})
|
|
246
253
|
.nullish(),
|
|
247
|
-
})
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
+
}),
|
|
255
|
+
)
|
|
256
|
+
.nullish(),
|
|
257
|
+
usageMetadata: z.record(z.string(), z.unknown()).nullish(),
|
|
258
|
+
}),
|
|
259
|
+
),
|
|
260
|
+
);
|
|
@@ -3,6 +3,8 @@ import {
|
|
|
3
3
|
type EmbeddingModelV3,
|
|
4
4
|
} from '@ai-sdk/provider';
|
|
5
5
|
import {
|
|
6
|
+
lazySchema,
|
|
7
|
+
zodSchema,
|
|
6
8
|
combineHeaders,
|
|
7
9
|
createJsonResponseHandler,
|
|
8
10
|
postJsonToApi,
|
|
@@ -162,29 +164,37 @@ export class GoogleVertexEmbeddingModel implements EmbeddingModelV3 {
|
|
|
162
164
|
|
|
163
165
|
// minimal version of the schema, focussed on what is needed for the implementation
|
|
164
166
|
// this approach limits breakages when the API changes and increases efficiency
|
|
165
|
-
const googleVertexTextEmbeddingResponseSchema =
|
|
166
|
-
|
|
167
|
+
const googleVertexTextEmbeddingResponseSchema = lazySchema(() =>
|
|
168
|
+
zodSchema(
|
|
167
169
|
z.object({
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
170
|
+
predictions: z.array(
|
|
171
|
+
z.object({
|
|
172
|
+
embeddings: z.object({
|
|
173
|
+
values: z.array(z.number()),
|
|
174
|
+
statistics: z.object({
|
|
175
|
+
token_count: z.number(),
|
|
176
|
+
}),
|
|
177
|
+
}),
|
|
172
178
|
}),
|
|
179
|
+
),
|
|
180
|
+
}),
|
|
181
|
+
),
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
const googleVertexEmbedContentResponseSchema = lazySchema(() =>
|
|
185
|
+
zodSchema(
|
|
186
|
+
z.object({
|
|
187
|
+
embedding: z.object({
|
|
188
|
+
values: z.array(z.number()),
|
|
173
189
|
}),
|
|
190
|
+
usageMetadata: z
|
|
191
|
+
.object({
|
|
192
|
+
promptTokenCount: z.number().nullish(),
|
|
193
|
+
})
|
|
194
|
+
.nullish(),
|
|
174
195
|
}),
|
|
175
196
|
),
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
const googleVertexEmbedContentResponseSchema = z.object({
|
|
179
|
-
embedding: z.object({
|
|
180
|
-
values: z.array(z.number()),
|
|
181
|
-
}),
|
|
182
|
-
usageMetadata: z
|
|
183
|
-
.object({
|
|
184
|
-
promptTokenCount: z.number().nullish(),
|
|
185
|
-
})
|
|
186
|
-
.nullish(),
|
|
187
|
-
});
|
|
197
|
+
);
|
|
188
198
|
|
|
189
199
|
function usesEmbedContentEndpoint(modelId: GoogleVertexEmbeddingModelId) {
|
|
190
200
|
return (
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import {
|
|
2
|
+
lazySchema,
|
|
3
|
+
zodSchema,
|
|
4
|
+
type InferSchema,
|
|
5
|
+
} from '@ai-sdk/provider-utils';
|
|
1
6
|
import { z } from 'zod/v4';
|
|
2
7
|
|
|
3
8
|
// https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/text-embeddings-api
|
|
@@ -14,52 +19,56 @@ export type GoogleVertexEmbeddingModelId =
|
|
|
14
19
|
| 'gemini-embedding-2-preview'
|
|
15
20
|
| (string & {});
|
|
16
21
|
|
|
17
|
-
export const googleVertexEmbeddingModelOptions =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
export const googleVertexEmbeddingModelOptions = lazySchema(() =>
|
|
23
|
+
zodSchema(
|
|
24
|
+
z.object({
|
|
25
|
+
/**
|
|
26
|
+
* Optional. Optional reduced dimension for the output embedding.
|
|
27
|
+
* If set, excessive values in the output embedding are truncated from the end.
|
|
28
|
+
*/
|
|
29
|
+
outputDimensionality: z.number().optional(),
|
|
23
30
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Optional. Specifies the task type for generating embeddings.
|
|
33
|
+
* Supported task types:
|
|
34
|
+
* - SEMANTIC_SIMILARITY: Optimized for text similarity.
|
|
35
|
+
* - CLASSIFICATION: Optimized for text classification.
|
|
36
|
+
* - CLUSTERING: Optimized for clustering texts based on similarity.
|
|
37
|
+
* - RETRIEVAL_DOCUMENT: Optimized for document retrieval.
|
|
38
|
+
* - RETRIEVAL_QUERY: Optimized for query-based retrieval.
|
|
39
|
+
* - QUESTION_ANSWERING: Optimized for answering questions.
|
|
40
|
+
* - FACT_VERIFICATION: Optimized for verifying factual information.
|
|
41
|
+
* - CODE_RETRIEVAL_QUERY: Optimized for retrieving code blocks based on natural language queries.
|
|
42
|
+
*/
|
|
43
|
+
taskType: z
|
|
44
|
+
.enum([
|
|
45
|
+
'SEMANTIC_SIMILARITY',
|
|
46
|
+
'CLASSIFICATION',
|
|
47
|
+
'CLUSTERING',
|
|
48
|
+
'RETRIEVAL_DOCUMENT',
|
|
49
|
+
'RETRIEVAL_QUERY',
|
|
50
|
+
'QUESTION_ANSWERING',
|
|
51
|
+
'FACT_VERIFICATION',
|
|
52
|
+
'CODE_RETRIEVAL_QUERY',
|
|
53
|
+
])
|
|
54
|
+
.optional(),
|
|
48
55
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Optional. The title of the document being embedded.
|
|
58
|
+
* Only valid when task_type is set to 'RETRIEVAL_DOCUMENT'.
|
|
59
|
+
* Helps the model produce better embeddings by providing additional context.
|
|
60
|
+
*/
|
|
61
|
+
title: z.string().optional(),
|
|
55
62
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
})
|
|
63
|
+
/**
|
|
64
|
+
* Optional. When set to true, input text will be truncated. When set to false,
|
|
65
|
+
* an error is returned if the input text is longer than the maximum length supported by the model. Defaults to true.
|
|
66
|
+
*/
|
|
67
|
+
autoTruncate: z.boolean().optional(),
|
|
68
|
+
}),
|
|
69
|
+
),
|
|
70
|
+
);
|
|
62
71
|
|
|
63
|
-
export type GoogleVertexEmbeddingModelOptions =
|
|
72
|
+
export type GoogleVertexEmbeddingModelOptions = InferSchema<
|
|
64
73
|
typeof googleVertexEmbeddingModelOptions
|
|
65
74
|
>;
|
|
@@ -1,15 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
lazySchema,
|
|
3
|
+
zodSchema,
|
|
4
|
+
type InferSchema,
|
|
5
|
+
createJsonErrorResponseHandler,
|
|
6
|
+
} from '@ai-sdk/provider-utils';
|
|
2
7
|
import { z } from 'zod/v4';
|
|
3
8
|
|
|
4
|
-
const googleVertexErrorDataSchema =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
const googleVertexErrorDataSchema = lazySchema(() =>
|
|
10
|
+
zodSchema(
|
|
11
|
+
z.object({
|
|
12
|
+
error: z.object({
|
|
13
|
+
code: z.number().nullable(),
|
|
14
|
+
message: z.string(),
|
|
15
|
+
status: z.string(),
|
|
16
|
+
}),
|
|
17
|
+
}),
|
|
18
|
+
),
|
|
19
|
+
);
|
|
11
20
|
|
|
12
|
-
export type GoogleVertexErrorData =
|
|
21
|
+
export type GoogleVertexErrorData = InferSchema<
|
|
22
|
+
typeof googleVertexErrorDataSchema
|
|
23
|
+
>;
|
|
13
24
|
|
|
14
25
|
export const googleVertexFailedResponseHandler = createJsonErrorResponseHandler(
|
|
15
26
|
{
|
|
@@ -7,6 +7,9 @@ import type {
|
|
|
7
7
|
SharedV3Warning,
|
|
8
8
|
} from '@ai-sdk/provider';
|
|
9
9
|
import {
|
|
10
|
+
lazySchema,
|
|
11
|
+
zodSchema,
|
|
12
|
+
type InferSchema,
|
|
10
13
|
combineHeaders,
|
|
11
14
|
convertToBase64,
|
|
12
15
|
convertUint8ArrayToBase64,
|
|
@@ -363,91 +366,99 @@ function isGeminiModel(modelId: string): boolean {
|
|
|
363
366
|
|
|
364
367
|
// minimal version of the schema, focussed on what is needed for the implementation
|
|
365
368
|
// this approach limits breakages when the API changes and increases efficiency
|
|
366
|
-
const vertexImageResponseSchema =
|
|
367
|
-
|
|
368
|
-
.
|
|
369
|
-
z
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
const googleVertexImageModelOptionsSchema = z.object({
|
|
382
|
-
negativePrompt: z.string().nullish(),
|
|
383
|
-
personGeneration: z
|
|
384
|
-
.enum(['dont_allow', 'allow_adult', 'allow_all'])
|
|
385
|
-
.nullish(),
|
|
386
|
-
safetySetting: z
|
|
387
|
-
.enum([
|
|
388
|
-
'block_low_and_above',
|
|
389
|
-
'block_medium_and_above',
|
|
390
|
-
'block_only_high',
|
|
391
|
-
'block_none',
|
|
392
|
-
])
|
|
393
|
-
.nullish(),
|
|
394
|
-
addWatermark: z.boolean().nullish(),
|
|
395
|
-
storageUri: z.string().nullish(),
|
|
396
|
-
sampleImageSize: z.enum(['1K', '2K']).nullish(),
|
|
397
|
-
/**
|
|
398
|
-
* Configuration for image editing operations
|
|
399
|
-
*/
|
|
400
|
-
edit: z
|
|
401
|
-
.object({
|
|
402
|
-
/**
|
|
403
|
-
* An integer that represents the number of sampling steps.
|
|
404
|
-
* A higher value offers better image quality, a lower value offers better latency.
|
|
405
|
-
* Try 35 steps to start. If the quality doesn't meet your requirements,
|
|
406
|
-
* increase the value towards an upper limit of 75.
|
|
407
|
-
*/
|
|
408
|
-
baseSteps: z.number().nullish(),
|
|
409
|
-
|
|
410
|
-
// Edit mode options
|
|
411
|
-
// https://cloud.google.com/vertex-ai/generative-ai/docs/image/edit-insert-objects
|
|
412
|
-
mode: z
|
|
413
|
-
.enum([
|
|
414
|
-
'EDIT_MODE_INPAINT_INSERTION',
|
|
415
|
-
'EDIT_MODE_INPAINT_REMOVAL',
|
|
416
|
-
'EDIT_MODE_OUTPAINT',
|
|
417
|
-
'EDIT_MODE_CONTROLLED_EDITING',
|
|
418
|
-
'EDIT_MODE_PRODUCT_IMAGE',
|
|
419
|
-
'EDIT_MODE_BGSWAP',
|
|
420
|
-
])
|
|
369
|
+
const vertexImageResponseSchema = lazySchema(() =>
|
|
370
|
+
zodSchema(
|
|
371
|
+
z.object({
|
|
372
|
+
predictions: z
|
|
373
|
+
.array(
|
|
374
|
+
z.union([
|
|
375
|
+
z.object({
|
|
376
|
+
bytesBase64Encoded: z.string(),
|
|
377
|
+
mimeType: z.string(),
|
|
378
|
+
prompt: z.string().nullish(),
|
|
379
|
+
}),
|
|
380
|
+
z.object({ raiFilteredReason: z.string() }),
|
|
381
|
+
]),
|
|
382
|
+
)
|
|
421
383
|
.nullish(),
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
384
|
+
}),
|
|
385
|
+
),
|
|
386
|
+
);
|
|
387
|
+
|
|
388
|
+
const googleVertexImageModelOptionsSchema = lazySchema(() =>
|
|
389
|
+
zodSchema(
|
|
390
|
+
z.object({
|
|
391
|
+
negativePrompt: z.string().nullish(),
|
|
392
|
+
personGeneration: z
|
|
393
|
+
.enum(['dont_allow', 'allow_adult', 'allow_all'])
|
|
394
|
+
.nullish(),
|
|
395
|
+
safetySetting: z
|
|
432
396
|
.enum([
|
|
433
|
-
'
|
|
434
|
-
'
|
|
435
|
-
'
|
|
436
|
-
'
|
|
437
|
-
'MASK_MODE_PARSED_PERSON',
|
|
397
|
+
'block_low_and_above',
|
|
398
|
+
'block_medium_and_above',
|
|
399
|
+
'block_only_high',
|
|
400
|
+
'block_none',
|
|
438
401
|
])
|
|
439
402
|
.nullish(),
|
|
440
|
-
|
|
403
|
+
addWatermark: z.boolean().nullish(),
|
|
404
|
+
storageUri: z.string().nullish(),
|
|
405
|
+
sampleImageSize: z.enum(['1K', '2K']).nullish(),
|
|
441
406
|
/**
|
|
442
|
-
*
|
|
443
|
-
* percentage of the image width to grow the mask by. Using dilation helps
|
|
444
|
-
* compensate for imprecise masks. We recommend a value of 0.01.
|
|
407
|
+
* Configuration for image editing operations
|
|
445
408
|
*/
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
409
|
+
edit: z
|
|
410
|
+
.object({
|
|
411
|
+
/**
|
|
412
|
+
* An integer that represents the number of sampling steps.
|
|
413
|
+
* A higher value offers better image quality, a lower value offers better latency.
|
|
414
|
+
* Try 35 steps to start. If the quality doesn't meet your requirements,
|
|
415
|
+
* increase the value towards an upper limit of 75.
|
|
416
|
+
*/
|
|
417
|
+
baseSteps: z.number().nullish(),
|
|
418
|
+
|
|
419
|
+
// Edit mode options
|
|
420
|
+
// https://cloud.google.com/vertex-ai/generative-ai/docs/image/edit-insert-objects
|
|
421
|
+
mode: z
|
|
422
|
+
.enum([
|
|
423
|
+
'EDIT_MODE_INPAINT_INSERTION',
|
|
424
|
+
'EDIT_MODE_INPAINT_REMOVAL',
|
|
425
|
+
'EDIT_MODE_OUTPAINT',
|
|
426
|
+
'EDIT_MODE_CONTROLLED_EDITING',
|
|
427
|
+
'EDIT_MODE_PRODUCT_IMAGE',
|
|
428
|
+
'EDIT_MODE_BGSWAP',
|
|
429
|
+
])
|
|
430
|
+
.nullish(),
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* The mask mode to use.
|
|
434
|
+
* - `MASK_MODE_DEFAULT` - Default value for mask mode.
|
|
435
|
+
* - `MASK_MODE_USER_PROVIDED` - User provided mask. No segmentation needed.
|
|
436
|
+
* - `MASK_MODE_DETECTION_BOX` - Mask from detected bounding boxes.
|
|
437
|
+
* - `MASK_MODE_CLOTHING_AREA` - Masks from segmenting the clothing area with open-vocab segmentation.
|
|
438
|
+
* - `MASK_MODE_PARSED_PERSON` - Masks from segmenting the person body and clothing using the person-parsing model.
|
|
439
|
+
*/
|
|
440
|
+
maskMode: z
|
|
441
|
+
.enum([
|
|
442
|
+
'MASK_MODE_DEFAULT',
|
|
443
|
+
'MASK_MODE_USER_PROVIDED',
|
|
444
|
+
'MASK_MODE_DETECTION_BOX',
|
|
445
|
+
'MASK_MODE_CLOTHING_AREA',
|
|
446
|
+
'MASK_MODE_PARSED_PERSON',
|
|
447
|
+
])
|
|
448
|
+
.nullish(),
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* Optional. A float value between 0 and 1, inclusive, that represents the
|
|
452
|
+
* percentage of the image width to grow the mask by. Using dilation helps
|
|
453
|
+
* compensate for imprecise masks. We recommend a value of 0.01.
|
|
454
|
+
*/
|
|
455
|
+
maskDilation: z.number().nullish(),
|
|
456
|
+
})
|
|
457
|
+
.nullish(),
|
|
458
|
+
}),
|
|
459
|
+
),
|
|
460
|
+
);
|
|
461
|
+
export type GoogleVertexImageModelOptions = InferSchema<
|
|
451
462
|
typeof googleVertexImageModelOptionsSchema
|
|
452
463
|
>;
|
|
453
464
|
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import {
|
|
2
|
+
lazySchema,
|
|
3
|
+
zodSchema,
|
|
4
|
+
type InferSchema,
|
|
5
|
+
} from '@ai-sdk/provider-utils';
|
|
1
6
|
import { z } from 'zod/v4';
|
|
2
7
|
|
|
3
8
|
// Google Cloud Speech-to-Text transcription models (Speech-to-Text v2).
|
|
@@ -8,39 +13,43 @@ export type GoogleVertexTranscriptionModelId =
|
|
|
8
13
|
| 'telephony'
|
|
9
14
|
| (string & {});
|
|
10
15
|
|
|
11
|
-
export const googleVertexTranscriptionProviderOptionsSchema =
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
export const googleVertexTranscriptionProviderOptionsSchema = lazySchema(() =>
|
|
17
|
+
zodSchema(
|
|
18
|
+
z.object({
|
|
19
|
+
/**
|
|
20
|
+
* BCP-47 language codes to recognize (e.g. `['en-US']`), or `['auto']` to let
|
|
21
|
+
* Chirp auto-detect the spoken language. Defaults to `['auto']`. For
|
|
22
|
+
* `telephony`, pass a supported explicit language code.
|
|
23
|
+
*/
|
|
24
|
+
languageCodes: z.array(z.string()).optional(),
|
|
18
25
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Whether to add punctuation to the transcript. Defaults to `true`.
|
|
28
|
+
*/
|
|
29
|
+
enableAutomaticPunctuation: z.boolean().optional(),
|
|
23
30
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Whether to include word-level timestamps. Defaults to `true` so the
|
|
33
|
+
* transcription result can include segments.
|
|
34
|
+
*
|
|
35
|
+
* Enabling word-level timestamps can reduce transcription quality and speed
|
|
36
|
+
* for Chirp models.
|
|
37
|
+
*/
|
|
38
|
+
enableWordTimeOffsets: z.boolean().optional(),
|
|
32
39
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
})
|
|
40
|
+
/**
|
|
41
|
+
* The Cloud Speech-to-Text region for the request (e.g. `'us'`, `'eu'`,
|
|
42
|
+
* `'us-central1'`). Defaults to the provider `location`.
|
|
43
|
+
*
|
|
44
|
+
* Note: Speech-to-Text regions differ from Vertex AI regions. Chirp is only
|
|
45
|
+
* available in specific Speech-to-Text regions and is not available in the
|
|
46
|
+
* `global` location.
|
|
47
|
+
*/
|
|
48
|
+
region: z.string().optional(),
|
|
49
|
+
}),
|
|
50
|
+
),
|
|
51
|
+
);
|
|
43
52
|
|
|
44
|
-
export type GoogleVertexTranscriptionModelOptions =
|
|
53
|
+
export type GoogleVertexTranscriptionModelOptions = InferSchema<
|
|
45
54
|
typeof googleVertexTranscriptionProviderOptionsSchema
|
|
46
55
|
>;
|