@ai-sdk/google-vertex 4.0.218 → 4.0.220
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
package/dist/index.js
CHANGED
|
@@ -29,19 +29,23 @@ module.exports = __toCommonJS(index_exports);
|
|
|
29
29
|
|
|
30
30
|
// src/gemini-transcription/google-vertex-gemini-transcription-model.ts
|
|
31
31
|
var import_provider = require("@ai-sdk/provider");
|
|
32
|
-
var
|
|
32
|
+
var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
|
33
33
|
var import_v43 = require("zod/v4");
|
|
34
34
|
|
|
35
35
|
// src/google-vertex-error.ts
|
|
36
36
|
var import_provider_utils = require("@ai-sdk/provider-utils");
|
|
37
37
|
var import_v4 = require("zod/v4");
|
|
38
|
-
var googleVertexErrorDataSchema =
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
var googleVertexErrorDataSchema = (0, import_provider_utils.lazySchema)(
|
|
39
|
+
() => (0, import_provider_utils.zodSchema)(
|
|
40
|
+
import_v4.z.object({
|
|
41
|
+
error: import_v4.z.object({
|
|
42
|
+
code: import_v4.z.number().nullable(),
|
|
43
|
+
message: import_v4.z.string(),
|
|
44
|
+
status: import_v4.z.string()
|
|
45
|
+
})
|
|
46
|
+
})
|
|
47
|
+
)
|
|
48
|
+
);
|
|
45
49
|
var googleVertexFailedResponseHandler = (0, import_provider_utils.createJsonErrorResponseHandler)(
|
|
46
50
|
{
|
|
47
51
|
errorSchema: googleVertexErrorDataSchema,
|
|
@@ -50,37 +54,42 @@ var googleVertexFailedResponseHandler = (0, import_provider_utils.createJsonErro
|
|
|
50
54
|
);
|
|
51
55
|
|
|
52
56
|
// src/gemini-transcription/google-vertex-gemini-transcription-model-options.ts
|
|
57
|
+
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
53
58
|
var import_v42 = require("zod/v4");
|
|
54
|
-
var googleVertexGeminiTranscriptionModelOptions =
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
59
|
+
var googleVertexGeminiTranscriptionModelOptions = (0, import_provider_utils2.lazySchema)(
|
|
60
|
+
() => (0, import_provider_utils2.zodSchema)(
|
|
61
|
+
import_v42.z.object({
|
|
62
|
+
/**
|
|
63
|
+
* BCP-47 language codes providing hints about the languages present in the
|
|
64
|
+
* audio. If omitted or empty, defaults to automatic language detection.
|
|
65
|
+
*/
|
|
66
|
+
languageCodes: import_v42.z.array(import_v42.z.string()).optional(),
|
|
67
|
+
/**
|
|
68
|
+
* Custom vocabulary phrases, which bias the speech recognition model
|
|
69
|
+
* toward recognizing specific terms.
|
|
70
|
+
*/
|
|
71
|
+
customVocabulary: import_v42.z.array(import_v42.z.string()).optional(),
|
|
72
|
+
/**
|
|
73
|
+
* Enables word-level timestamp generation.
|
|
74
|
+
*/
|
|
75
|
+
wordTimestamp: import_v42.z.boolean().optional(),
|
|
76
|
+
/**
|
|
77
|
+
* Enables speaker diarization.
|
|
78
|
+
*/
|
|
79
|
+
diarization: import_v42.z.boolean().optional(),
|
|
80
|
+
/**
|
|
81
|
+
* Transcription output formatting mode.
|
|
82
|
+
*
|
|
83
|
+
* - `VERBATIM` (default): exact literal transcript preserving filler
|
|
84
|
+
* words, repetitions, and false starts.
|
|
85
|
+
* - `SMART`: cleans up and structures the transcript in real time —
|
|
86
|
+
* disfluency removal, inline self-corrections, structured formatting
|
|
87
|
+
* (lists, numbers, dates, paragraph breaks), and grammar/casing polish.
|
|
88
|
+
*/
|
|
89
|
+
mode: import_v42.z.enum(["SMART", "VERBATIM"]).optional()
|
|
90
|
+
})
|
|
91
|
+
)
|
|
92
|
+
);
|
|
84
93
|
|
|
85
94
|
// src/gemini-transcription/google-vertex-gemini-transcription-model.ts
|
|
86
95
|
function isLiveTranscriptionModelId(modelId) {
|
|
@@ -97,7 +106,7 @@ var GoogleVertexGeminiTranscriptionModel = class {
|
|
|
97
106
|
}
|
|
98
107
|
async parseOptions(providerOptions) {
|
|
99
108
|
for (const provider of ["googleVertex", "vertex", "google"]) {
|
|
100
|
-
const parsed = await (0,
|
|
109
|
+
const parsed = await (0, import_provider_utils3.parseProviderOptions)({
|
|
101
110
|
provider,
|
|
102
111
|
providerOptions,
|
|
103
112
|
schema: googleVertexGeminiTranscriptionModelOptions
|
|
@@ -126,7 +135,7 @@ var GoogleVertexGeminiTranscriptionModel = class {
|
|
|
126
135
|
{
|
|
127
136
|
inlineData: {
|
|
128
137
|
mimeType: options.mediaType,
|
|
129
|
-
data: (0,
|
|
138
|
+
data: (0, import_provider_utils3.convertToBase64)(options.audio)
|
|
130
139
|
}
|
|
131
140
|
}
|
|
132
141
|
]
|
|
@@ -138,15 +147,15 @@ var GoogleVertexGeminiTranscriptionModel = class {
|
|
|
138
147
|
value: response,
|
|
139
148
|
responseHeaders,
|
|
140
149
|
rawValue: rawResponse
|
|
141
|
-
} = await (0,
|
|
150
|
+
} = await (0, import_provider_utils3.postJsonToApi)({
|
|
142
151
|
url: `${this.config.baseURL}/models/${this.modelId}:generateContent`,
|
|
143
|
-
headers: (0,
|
|
144
|
-
this.config.headers ? await (0,
|
|
152
|
+
headers: (0, import_provider_utils3.combineHeaders)(
|
|
153
|
+
this.config.headers ? await (0, import_provider_utils3.resolve)(this.config.headers) : void 0,
|
|
145
154
|
options.headers
|
|
146
155
|
),
|
|
147
156
|
body: requestBody,
|
|
148
157
|
failedResponseHandler: googleVertexFailedResponseHandler,
|
|
149
|
-
successfulResponseHandler: (0,
|
|
158
|
+
successfulResponseHandler: (0, import_provider_utils3.createJsonResponseHandler)(
|
|
150
159
|
googleVertexGeminiTranscriptionResponseSchema
|
|
151
160
|
),
|
|
152
161
|
abortSignal: options.abortSignal,
|
|
@@ -222,34 +231,38 @@ function parseOffsetSeconds(offset) {
|
|
|
222
231
|
const parsed = Number.parseFloat(offset);
|
|
223
232
|
return Number.isFinite(parsed) ? parsed : void 0;
|
|
224
233
|
}
|
|
225
|
-
var googleVertexGeminiTranscriptionWordSchema = import_v43.z.object({
|
|
234
|
+
var googleVertexGeminiTranscriptionWordSchema = () => import_v43.z.object({
|
|
226
235
|
word: import_v43.z.string().nullish(),
|
|
227
236
|
startOffset: import_v43.z.string().nullish(),
|
|
228
237
|
endOffset: import_v43.z.string().nullish()
|
|
229
238
|
});
|
|
230
|
-
var googleVertexGeminiTranscriptionResponseSchema =
|
|
231
|
-
|
|
239
|
+
var googleVertexGeminiTranscriptionResponseSchema = (0, import_provider_utils3.lazySchema)(
|
|
240
|
+
() => (0, import_provider_utils3.zodSchema)(
|
|
232
241
|
import_v43.z.object({
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
import_v43.z.object({
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
242
|
+
candidates: import_v43.z.array(
|
|
243
|
+
import_v43.z.object({
|
|
244
|
+
content: import_v43.z.object({
|
|
245
|
+
parts: import_v43.z.array(
|
|
246
|
+
import_v43.z.object({
|
|
247
|
+
text: import_v43.z.string().nullish(),
|
|
248
|
+
audioTranscription: import_v43.z.object({
|
|
249
|
+
text: import_v43.z.string().nullish(),
|
|
250
|
+
languageCode: import_v43.z.string().nullish(),
|
|
251
|
+
speakerLabel: import_v43.z.string().nullish(),
|
|
252
|
+
words: import_v43.z.array(googleVertexGeminiTranscriptionWordSchema()).nullish()
|
|
253
|
+
}).nullish()
|
|
254
|
+
})
|
|
255
|
+
).nullish()
|
|
256
|
+
}).nullish()
|
|
257
|
+
})
|
|
258
|
+
).nullish(),
|
|
259
|
+
usageMetadata: import_v43.z.record(import_v43.z.string(), import_v43.z.unknown()).nullish()
|
|
246
260
|
})
|
|
247
|
-
)
|
|
248
|
-
|
|
249
|
-
});
|
|
261
|
+
)
|
|
262
|
+
);
|
|
250
263
|
|
|
251
264
|
// src/google-vertex-provider-node.ts
|
|
252
|
-
var
|
|
265
|
+
var import_provider_utils11 = require("@ai-sdk/provider-utils");
|
|
253
266
|
|
|
254
267
|
// src/google-vertex-auth-google-auth-library.ts
|
|
255
268
|
var import_google_auth_library = require("google-auth-library");
|
|
@@ -268,58 +281,63 @@ function createAuthTokenGenerator(options) {
|
|
|
268
281
|
|
|
269
282
|
// src/google-vertex-provider.ts
|
|
270
283
|
var import_internal3 = require("@ai-sdk/google/internal");
|
|
271
|
-
var
|
|
284
|
+
var import_provider_utils10 = require("@ai-sdk/provider-utils");
|
|
272
285
|
|
|
273
286
|
// src/version.ts
|
|
274
|
-
var VERSION = true ? "4.0.
|
|
287
|
+
var VERSION = true ? "4.0.220" : "0.0.0-test";
|
|
275
288
|
|
|
276
289
|
// src/google-vertex-embedding-model.ts
|
|
277
290
|
var import_provider2 = require("@ai-sdk/provider");
|
|
278
|
-
var
|
|
291
|
+
var import_provider_utils5 = require("@ai-sdk/provider-utils");
|
|
279
292
|
var import_v45 = require("zod/v4");
|
|
280
293
|
|
|
281
294
|
// src/google-vertex-embedding-options.ts
|
|
295
|
+
var import_provider_utils4 = require("@ai-sdk/provider-utils");
|
|
282
296
|
var import_v44 = require("zod/v4");
|
|
283
|
-
var googleVertexEmbeddingModelOptions =
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
297
|
+
var googleVertexEmbeddingModelOptions = (0, import_provider_utils4.lazySchema)(
|
|
298
|
+
() => (0, import_provider_utils4.zodSchema)(
|
|
299
|
+
import_v44.z.object({
|
|
300
|
+
/**
|
|
301
|
+
* Optional. Optional reduced dimension for the output embedding.
|
|
302
|
+
* If set, excessive values in the output embedding are truncated from the end.
|
|
303
|
+
*/
|
|
304
|
+
outputDimensionality: import_v44.z.number().optional(),
|
|
305
|
+
/**
|
|
306
|
+
* Optional. Specifies the task type for generating embeddings.
|
|
307
|
+
* Supported task types:
|
|
308
|
+
* - SEMANTIC_SIMILARITY: Optimized for text similarity.
|
|
309
|
+
* - CLASSIFICATION: Optimized for text classification.
|
|
310
|
+
* - CLUSTERING: Optimized for clustering texts based on similarity.
|
|
311
|
+
* - RETRIEVAL_DOCUMENT: Optimized for document retrieval.
|
|
312
|
+
* - RETRIEVAL_QUERY: Optimized for query-based retrieval.
|
|
313
|
+
* - QUESTION_ANSWERING: Optimized for answering questions.
|
|
314
|
+
* - FACT_VERIFICATION: Optimized for verifying factual information.
|
|
315
|
+
* - CODE_RETRIEVAL_QUERY: Optimized for retrieving code blocks based on natural language queries.
|
|
316
|
+
*/
|
|
317
|
+
taskType: import_v44.z.enum([
|
|
318
|
+
"SEMANTIC_SIMILARITY",
|
|
319
|
+
"CLASSIFICATION",
|
|
320
|
+
"CLUSTERING",
|
|
321
|
+
"RETRIEVAL_DOCUMENT",
|
|
322
|
+
"RETRIEVAL_QUERY",
|
|
323
|
+
"QUESTION_ANSWERING",
|
|
324
|
+
"FACT_VERIFICATION",
|
|
325
|
+
"CODE_RETRIEVAL_QUERY"
|
|
326
|
+
]).optional(),
|
|
327
|
+
/**
|
|
328
|
+
* Optional. The title of the document being embedded.
|
|
329
|
+
* Only valid when task_type is set to 'RETRIEVAL_DOCUMENT'.
|
|
330
|
+
* Helps the model produce better embeddings by providing additional context.
|
|
331
|
+
*/
|
|
332
|
+
title: import_v44.z.string().optional(),
|
|
333
|
+
/**
|
|
334
|
+
* Optional. When set to true, input text will be truncated. When set to false,
|
|
335
|
+
* an error is returned if the input text is longer than the maximum length supported by the model. Defaults to true.
|
|
336
|
+
*/
|
|
337
|
+
autoTruncate: import_v44.z.boolean().optional()
|
|
338
|
+
})
|
|
339
|
+
)
|
|
340
|
+
);
|
|
323
341
|
|
|
324
342
|
// src/google-vertex-embedding-model.ts
|
|
325
343
|
var GoogleVertexEmbeddingModel = class {
|
|
@@ -344,13 +362,13 @@ var GoogleVertexEmbeddingModel = class {
|
|
|
344
362
|
providerOptions
|
|
345
363
|
}) {
|
|
346
364
|
var _a;
|
|
347
|
-
let googleOptions = await (0,
|
|
365
|
+
let googleOptions = await (0, import_provider_utils5.parseProviderOptions)({
|
|
348
366
|
provider: "vertex",
|
|
349
367
|
providerOptions,
|
|
350
368
|
schema: googleVertexEmbeddingModelOptions
|
|
351
369
|
});
|
|
352
370
|
if (googleOptions == null) {
|
|
353
|
-
googleOptions = await (0,
|
|
371
|
+
googleOptions = await (0, import_provider_utils5.parseProviderOptions)({
|
|
354
372
|
provider: "google",
|
|
355
373
|
providerOptions,
|
|
356
374
|
schema: googleVertexEmbeddingModelOptions
|
|
@@ -365,8 +383,8 @@ var GoogleVertexEmbeddingModel = class {
|
|
|
365
383
|
values
|
|
366
384
|
});
|
|
367
385
|
}
|
|
368
|
-
const mergedHeaders = (0,
|
|
369
|
-
await (0,
|
|
386
|
+
const mergedHeaders = (0, import_provider_utils5.combineHeaders)(
|
|
387
|
+
await (0, import_provider_utils5.resolve)(this.config.headers),
|
|
370
388
|
headers
|
|
371
389
|
);
|
|
372
390
|
if (usesEmbedContentEndpoint(this.modelId)) {
|
|
@@ -374,7 +392,7 @@ var GoogleVertexEmbeddingModel = class {
|
|
|
374
392
|
responseHeaders: responseHeaders2,
|
|
375
393
|
value: response2,
|
|
376
394
|
rawValue: rawValue2
|
|
377
|
-
} = await (0,
|
|
395
|
+
} = await (0, import_provider_utils5.postJsonToApi)({
|
|
378
396
|
url: `${this.config.baseURL}/models/${this.modelId}:embedContent`,
|
|
379
397
|
headers: mergedHeaders,
|
|
380
398
|
body: {
|
|
@@ -387,7 +405,7 @@ var GoogleVertexEmbeddingModel = class {
|
|
|
387
405
|
}
|
|
388
406
|
},
|
|
389
407
|
failedResponseHandler: googleVertexFailedResponseHandler,
|
|
390
|
-
successfulResponseHandler: (0,
|
|
408
|
+
successfulResponseHandler: (0, import_provider_utils5.createJsonResponseHandler)(
|
|
391
409
|
googleVertexEmbedContentResponseSchema
|
|
392
410
|
),
|
|
393
411
|
abortSignal,
|
|
@@ -405,7 +423,7 @@ var GoogleVertexEmbeddingModel = class {
|
|
|
405
423
|
responseHeaders,
|
|
406
424
|
value: response,
|
|
407
425
|
rawValue
|
|
408
|
-
} = await (0,
|
|
426
|
+
} = await (0, import_provider_utils5.postJsonToApi)({
|
|
409
427
|
url,
|
|
410
428
|
headers: mergedHeaders,
|
|
411
429
|
body: {
|
|
@@ -420,7 +438,7 @@ var GoogleVertexEmbeddingModel = class {
|
|
|
420
438
|
}
|
|
421
439
|
},
|
|
422
440
|
failedResponseHandler: googleVertexFailedResponseHandler,
|
|
423
|
-
successfulResponseHandler: (0,
|
|
441
|
+
successfulResponseHandler: (0, import_provider_utils5.createJsonResponseHandler)(
|
|
424
442
|
googleVertexTextEmbeddingResponseSchema
|
|
425
443
|
),
|
|
426
444
|
abortSignal,
|
|
@@ -441,33 +459,41 @@ var GoogleVertexEmbeddingModel = class {
|
|
|
441
459
|
};
|
|
442
460
|
}
|
|
443
461
|
};
|
|
444
|
-
var googleVertexTextEmbeddingResponseSchema =
|
|
445
|
-
|
|
462
|
+
var googleVertexTextEmbeddingResponseSchema = (0, import_provider_utils5.lazySchema)(
|
|
463
|
+
() => (0, import_provider_utils5.zodSchema)(
|
|
446
464
|
import_v45.z.object({
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
465
|
+
predictions: import_v45.z.array(
|
|
466
|
+
import_v45.z.object({
|
|
467
|
+
embeddings: import_v45.z.object({
|
|
468
|
+
values: import_v45.z.array(import_v45.z.number()),
|
|
469
|
+
statistics: import_v45.z.object({
|
|
470
|
+
token_count: import_v45.z.number()
|
|
471
|
+
})
|
|
472
|
+
})
|
|
451
473
|
})
|
|
452
|
-
|
|
474
|
+
)
|
|
453
475
|
})
|
|
454
476
|
)
|
|
455
|
-
|
|
456
|
-
var googleVertexEmbedContentResponseSchema =
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
477
|
+
);
|
|
478
|
+
var googleVertexEmbedContentResponseSchema = (0, import_provider_utils5.lazySchema)(
|
|
479
|
+
() => (0, import_provider_utils5.zodSchema)(
|
|
480
|
+
import_v45.z.object({
|
|
481
|
+
embedding: import_v45.z.object({
|
|
482
|
+
values: import_v45.z.array(import_v45.z.number())
|
|
483
|
+
}),
|
|
484
|
+
usageMetadata: import_v45.z.object({
|
|
485
|
+
promptTokenCount: import_v45.z.number().nullish()
|
|
486
|
+
}).nullish()
|
|
487
|
+
})
|
|
488
|
+
)
|
|
489
|
+
);
|
|
464
490
|
function usesEmbedContentEndpoint(modelId) {
|
|
465
491
|
return modelId === "gemini-embedding-2" || modelId === "gemini-embedding-2-preview";
|
|
466
492
|
}
|
|
467
493
|
|
|
468
494
|
// src/google-vertex-image-model.ts
|
|
469
495
|
var import_internal = require("@ai-sdk/google/internal");
|
|
470
|
-
var
|
|
496
|
+
var import_provider_utils6 = require("@ai-sdk/provider-utils");
|
|
471
497
|
var import_v46 = require("zod/v4");
|
|
472
498
|
var GoogleVertexImageModel = class {
|
|
473
499
|
constructor(modelId, config) {
|
|
@@ -511,7 +537,7 @@ var GoogleVertexImageModel = class {
|
|
|
511
537
|
details: "This model does not support the `size` option. Use `aspectRatio` instead."
|
|
512
538
|
});
|
|
513
539
|
}
|
|
514
|
-
const vertexImageOptions = await (0,
|
|
540
|
+
const vertexImageOptions = await (0, import_provider_utils6.parseProviderOptions)({
|
|
515
541
|
provider: "vertex",
|
|
516
542
|
providerOptions,
|
|
517
543
|
schema: googleVertexImageModelOptionsSchema
|
|
@@ -573,12 +599,12 @@ var GoogleVertexImageModel = class {
|
|
|
573
599
|
};
|
|
574
600
|
}
|
|
575
601
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
576
|
-
const { value: response, responseHeaders } = await (0,
|
|
602
|
+
const { value: response, responseHeaders } = await (0, import_provider_utils6.postJsonToApi)({
|
|
577
603
|
url: `${this.config.baseURL}/models/${this.modelId}:predict`,
|
|
578
|
-
headers: (0,
|
|
604
|
+
headers: (0, import_provider_utils6.combineHeaders)(await (0, import_provider_utils6.resolve)(this.config.headers), headers),
|
|
579
605
|
body,
|
|
580
606
|
failedResponseHandler: googleVertexFailedResponseHandler,
|
|
581
|
-
successfulResponseHandler: (0,
|
|
607
|
+
successfulResponseHandler: (0, import_provider_utils6.createJsonResponseHandler)(
|
|
582
608
|
vertexImageResponseSchema
|
|
583
609
|
),
|
|
584
610
|
abortSignal,
|
|
@@ -673,7 +699,7 @@ var GoogleVertexImageModel = class {
|
|
|
673
699
|
baseURL: this.config.baseURL,
|
|
674
700
|
headers: (_a = this.config.headers) != null ? _a : {},
|
|
675
701
|
fetch: this.config.fetch,
|
|
676
|
-
generateId: (_b = this.config.generateId) != null ? _b :
|
|
702
|
+
generateId: (_b = this.config.generateId) != null ? _b : import_provider_utils6.generateId,
|
|
677
703
|
supportedUrls: () => ({
|
|
678
704
|
"*": [/^https?:\/\/.*$/, /^gs:\/\/.*$/]
|
|
679
705
|
})
|
|
@@ -697,7 +723,7 @@ var GoogleVertexImageModel = class {
|
|
|
697
723
|
const images = [];
|
|
698
724
|
for (const part of result.content) {
|
|
699
725
|
if (part.type === "file" && part.mediaType.startsWith("image/")) {
|
|
700
|
-
images.push((0,
|
|
726
|
+
images.push((0, import_provider_utils6.convertToBase64)(part.data));
|
|
701
727
|
}
|
|
702
728
|
}
|
|
703
729
|
return {
|
|
@@ -725,74 +751,82 @@ var GoogleVertexImageModel = class {
|
|
|
725
751
|
function isGeminiModel(modelId) {
|
|
726
752
|
return modelId.startsWith("gemini-");
|
|
727
753
|
}
|
|
728
|
-
var vertexImageResponseSchema =
|
|
729
|
-
|
|
730
|
-
import_v46.z.
|
|
731
|
-
import_v46.z.
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
754
|
+
var vertexImageResponseSchema = (0, import_provider_utils6.lazySchema)(
|
|
755
|
+
() => (0, import_provider_utils6.zodSchema)(
|
|
756
|
+
import_v46.z.object({
|
|
757
|
+
predictions: import_v46.z.array(
|
|
758
|
+
import_v46.z.union([
|
|
759
|
+
import_v46.z.object({
|
|
760
|
+
bytesBase64Encoded: import_v46.z.string(),
|
|
761
|
+
mimeType: import_v46.z.string(),
|
|
762
|
+
prompt: import_v46.z.string().nullish()
|
|
763
|
+
}),
|
|
764
|
+
import_v46.z.object({ raiFilteredReason: import_v46.z.string() })
|
|
765
|
+
])
|
|
766
|
+
).nullish()
|
|
767
|
+
})
|
|
768
|
+
)
|
|
769
|
+
);
|
|
770
|
+
var googleVertexImageModelOptionsSchema = (0, import_provider_utils6.lazySchema)(
|
|
771
|
+
() => (0, import_provider_utils6.zodSchema)(
|
|
772
|
+
import_v46.z.object({
|
|
773
|
+
negativePrompt: import_v46.z.string().nullish(),
|
|
774
|
+
personGeneration: import_v46.z.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
|
|
775
|
+
safetySetting: import_v46.z.enum([
|
|
776
|
+
"block_low_and_above",
|
|
777
|
+
"block_medium_and_above",
|
|
778
|
+
"block_only_high",
|
|
779
|
+
"block_none"
|
|
780
|
+
]).nullish(),
|
|
781
|
+
addWatermark: import_v46.z.boolean().nullish(),
|
|
782
|
+
storageUri: import_v46.z.string().nullish(),
|
|
783
|
+
sampleImageSize: import_v46.z.enum(["1K", "2K"]).nullish(),
|
|
784
|
+
/**
|
|
785
|
+
* Configuration for image editing operations
|
|
786
|
+
*/
|
|
787
|
+
edit: import_v46.z.object({
|
|
788
|
+
/**
|
|
789
|
+
* An integer that represents the number of sampling steps.
|
|
790
|
+
* A higher value offers better image quality, a lower value offers better latency.
|
|
791
|
+
* Try 35 steps to start. If the quality doesn't meet your requirements,
|
|
792
|
+
* increase the value towards an upper limit of 75.
|
|
793
|
+
*/
|
|
794
|
+
baseSteps: import_v46.z.number().nullish(),
|
|
795
|
+
// Edit mode options
|
|
796
|
+
// https://cloud.google.com/vertex-ai/generative-ai/docs/image/edit-insert-objects
|
|
797
|
+
mode: import_v46.z.enum([
|
|
798
|
+
"EDIT_MODE_INPAINT_INSERTION",
|
|
799
|
+
"EDIT_MODE_INPAINT_REMOVAL",
|
|
800
|
+
"EDIT_MODE_OUTPAINT",
|
|
801
|
+
"EDIT_MODE_CONTROLLED_EDITING",
|
|
802
|
+
"EDIT_MODE_PRODUCT_IMAGE",
|
|
803
|
+
"EDIT_MODE_BGSWAP"
|
|
804
|
+
]).nullish(),
|
|
805
|
+
/**
|
|
806
|
+
* The mask mode to use.
|
|
807
|
+
* - `MASK_MODE_DEFAULT` - Default value for mask mode.
|
|
808
|
+
* - `MASK_MODE_USER_PROVIDED` - User provided mask. No segmentation needed.
|
|
809
|
+
* - `MASK_MODE_DETECTION_BOX` - Mask from detected bounding boxes.
|
|
810
|
+
* - `MASK_MODE_CLOTHING_AREA` - Masks from segmenting the clothing area with open-vocab segmentation.
|
|
811
|
+
* - `MASK_MODE_PARSED_PERSON` - Masks from segmenting the person body and clothing using the person-parsing model.
|
|
812
|
+
*/
|
|
813
|
+
maskMode: import_v46.z.enum([
|
|
814
|
+
"MASK_MODE_DEFAULT",
|
|
815
|
+
"MASK_MODE_USER_PROVIDED",
|
|
816
|
+
"MASK_MODE_DETECTION_BOX",
|
|
817
|
+
"MASK_MODE_CLOTHING_AREA",
|
|
818
|
+
"MASK_MODE_PARSED_PERSON"
|
|
819
|
+
]).nullish(),
|
|
820
|
+
/**
|
|
821
|
+
* Optional. A float value between 0 and 1, inclusive, that represents the
|
|
822
|
+
* percentage of the image width to grow the mask by. Using dilation helps
|
|
823
|
+
* compensate for imprecise masks. We recommend a value of 0.01.
|
|
824
|
+
*/
|
|
825
|
+
maskDilation: import_v46.z.number().nullish()
|
|
826
|
+
}).nullish()
|
|
827
|
+
})
|
|
828
|
+
)
|
|
829
|
+
);
|
|
796
830
|
function getBase64Data(file) {
|
|
797
831
|
if (file.type === "url") {
|
|
798
832
|
throw new Error(
|
|
@@ -802,7 +836,7 @@ function getBase64Data(file) {
|
|
|
802
836
|
if (typeof file.data === "string") {
|
|
803
837
|
return file.data;
|
|
804
838
|
}
|
|
805
|
-
return (0,
|
|
839
|
+
return (0, import_provider_utils6.convertUint8ArrayToBase64)(file.data);
|
|
806
840
|
}
|
|
807
841
|
|
|
808
842
|
// src/google-vertex-tools.ts
|
|
@@ -818,40 +852,45 @@ var googleVertexTools = {
|
|
|
818
852
|
};
|
|
819
853
|
|
|
820
854
|
// src/google-vertex-transcription-model.ts
|
|
821
|
-
var
|
|
855
|
+
var import_provider_utils8 = require("@ai-sdk/provider-utils");
|
|
822
856
|
var import_v48 = require("zod/v4");
|
|
823
857
|
|
|
824
858
|
// src/google-vertex-transcription-model-options.ts
|
|
859
|
+
var import_provider_utils7 = require("@ai-sdk/provider-utils");
|
|
825
860
|
var import_v47 = require("zod/v4");
|
|
826
|
-
var googleVertexTranscriptionProviderOptionsSchema =
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
861
|
+
var googleVertexTranscriptionProviderOptionsSchema = (0, import_provider_utils7.lazySchema)(
|
|
862
|
+
() => (0, import_provider_utils7.zodSchema)(
|
|
863
|
+
import_v47.z.object({
|
|
864
|
+
/**
|
|
865
|
+
* BCP-47 language codes to recognize (e.g. `['en-US']`), or `['auto']` to let
|
|
866
|
+
* Chirp auto-detect the spoken language. Defaults to `['auto']`. For
|
|
867
|
+
* `telephony`, pass a supported explicit language code.
|
|
868
|
+
*/
|
|
869
|
+
languageCodes: import_v47.z.array(import_v47.z.string()).optional(),
|
|
870
|
+
/**
|
|
871
|
+
* Whether to add punctuation to the transcript. Defaults to `true`.
|
|
872
|
+
*/
|
|
873
|
+
enableAutomaticPunctuation: import_v47.z.boolean().optional(),
|
|
874
|
+
/**
|
|
875
|
+
* Whether to include word-level timestamps. Defaults to `true` so the
|
|
876
|
+
* transcription result can include segments.
|
|
877
|
+
*
|
|
878
|
+
* Enabling word-level timestamps can reduce transcription quality and speed
|
|
879
|
+
* for Chirp models.
|
|
880
|
+
*/
|
|
881
|
+
enableWordTimeOffsets: import_v47.z.boolean().optional(),
|
|
882
|
+
/**
|
|
883
|
+
* The Cloud Speech-to-Text region for the request (e.g. `'us'`, `'eu'`,
|
|
884
|
+
* `'us-central1'`). Defaults to the provider `location`.
|
|
885
|
+
*
|
|
886
|
+
* Note: Speech-to-Text regions differ from Vertex AI regions. Chirp is only
|
|
887
|
+
* available in specific Speech-to-Text regions and is not available in the
|
|
888
|
+
* `global` location.
|
|
889
|
+
*/
|
|
890
|
+
region: import_v47.z.string().optional()
|
|
891
|
+
})
|
|
892
|
+
)
|
|
893
|
+
);
|
|
855
894
|
|
|
856
895
|
// src/google-vertex-transcription-model.ts
|
|
857
896
|
function parseDurationSeconds(value) {
|
|
@@ -887,7 +926,7 @@ var GoogleVertexTranscriptionModel = class {
|
|
|
887
926
|
const warnings = [];
|
|
888
927
|
let googleOptions;
|
|
889
928
|
for (const provider of ["googleVertex", "vertex", "google"]) {
|
|
890
|
-
googleOptions = await (0,
|
|
929
|
+
googleOptions = await (0, import_provider_utils8.parseProviderOptions)({
|
|
891
930
|
provider,
|
|
892
931
|
providerOptions: options.providerOptions,
|
|
893
932
|
schema: googleVertexTranscriptionProviderOptionsSchema
|
|
@@ -898,7 +937,7 @@ var GoogleVertexTranscriptionModel = class {
|
|
|
898
937
|
}
|
|
899
938
|
const region = (_d = googleOptions == null ? void 0 : googleOptions.region) != null ? _d : this.config.location;
|
|
900
939
|
const languageCodes = (_e = googleOptions == null ? void 0 : googleOptions.languageCodes) != null ? _e : ["auto"];
|
|
901
|
-
const content = typeof options.audio === "string" ? options.audio : (0,
|
|
940
|
+
const content = typeof options.audio === "string" ? options.audio : (0, import_provider_utils8.convertUint8ArrayToBase64)(options.audio);
|
|
902
941
|
const requestBody = {
|
|
903
942
|
config: {
|
|
904
943
|
model: this.modelId,
|
|
@@ -919,15 +958,15 @@ var GoogleVertexTranscriptionModel = class {
|
|
|
919
958
|
value: response,
|
|
920
959
|
responseHeaders,
|
|
921
960
|
rawValue: rawResponse
|
|
922
|
-
} = await (0,
|
|
961
|
+
} = await (0, import_provider_utils8.postJsonToApi)({
|
|
923
962
|
url,
|
|
924
|
-
headers: (0,
|
|
925
|
-
this.config.headers ? await (0,
|
|
963
|
+
headers: (0, import_provider_utils8.combineHeaders)(
|
|
964
|
+
this.config.headers ? await (0, import_provider_utils8.resolve)(this.config.headers) : void 0,
|
|
926
965
|
options.headers
|
|
927
966
|
),
|
|
928
967
|
body: requestBody,
|
|
929
968
|
failedResponseHandler: googleVertexFailedResponseHandler,
|
|
930
|
-
successfulResponseHandler: (0,
|
|
969
|
+
successfulResponseHandler: (0, import_provider_utils8.createJsonResponseHandler)(
|
|
931
970
|
googleVertexTranscriptionResponseSchema
|
|
932
971
|
),
|
|
933
972
|
abortSignal: options.abortSignal,
|
|
@@ -966,32 +1005,36 @@ var GoogleVertexTranscriptionModel = class {
|
|
|
966
1005
|
};
|
|
967
1006
|
}
|
|
968
1007
|
};
|
|
969
|
-
var googleVertexTranscriptionResponseSchema =
|
|
970
|
-
|
|
1008
|
+
var googleVertexTranscriptionResponseSchema = (0, import_provider_utils8.lazySchema)(
|
|
1009
|
+
() => (0, import_provider_utils8.zodSchema)(
|
|
971
1010
|
import_v48.z.object({
|
|
972
|
-
|
|
1011
|
+
results: import_v48.z.array(
|
|
973
1012
|
import_v48.z.object({
|
|
974
|
-
|
|
975
|
-
words: import_v48.z.array(
|
|
1013
|
+
alternatives: import_v48.z.array(
|
|
976
1014
|
import_v48.z.object({
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
1015
|
+
transcript: import_v48.z.string().nullish(),
|
|
1016
|
+
words: import_v48.z.array(
|
|
1017
|
+
import_v48.z.object({
|
|
1018
|
+
word: import_v48.z.string().nullish(),
|
|
1019
|
+
startOffset: import_v48.z.string().nullish(),
|
|
1020
|
+
endOffset: import_v48.z.string().nullish()
|
|
1021
|
+
})
|
|
1022
|
+
).nullish()
|
|
980
1023
|
})
|
|
981
|
-
).nullish()
|
|
1024
|
+
).nullish(),
|
|
1025
|
+
languageCode: import_v48.z.string().nullish()
|
|
982
1026
|
})
|
|
983
1027
|
).nullish(),
|
|
984
|
-
|
|
1028
|
+
metadata: import_v48.z.object({
|
|
1029
|
+
totalBilledDuration: import_v48.z.string().nullish()
|
|
1030
|
+
}).nullish()
|
|
985
1031
|
})
|
|
986
|
-
)
|
|
987
|
-
|
|
988
|
-
totalBilledDuration: import_v48.z.string().nullish()
|
|
989
|
-
}).nullish()
|
|
990
|
-
});
|
|
1032
|
+
)
|
|
1033
|
+
);
|
|
991
1034
|
|
|
992
1035
|
// src/google-vertex-video-model.ts
|
|
993
1036
|
var import_provider3 = require("@ai-sdk/provider");
|
|
994
|
-
var
|
|
1037
|
+
var import_provider_utils9 = require("@ai-sdk/provider-utils");
|
|
995
1038
|
var import_v49 = require("zod/v4");
|
|
996
1039
|
function getFirstFrameImage(options) {
|
|
997
1040
|
var _a, _b;
|
|
@@ -1026,7 +1069,7 @@ function convertFileToVertexImage(file, warnings) {
|
|
|
1026
1069
|
});
|
|
1027
1070
|
return void 0;
|
|
1028
1071
|
}
|
|
1029
|
-
const base64Data = typeof file.data === "string" ? file.data : (0,
|
|
1072
|
+
const base64Data = typeof file.data === "string" ? file.data : (0, import_provider_utils9.convertUint8ArrayToBase64)(file.data);
|
|
1030
1073
|
return {
|
|
1031
1074
|
bytesBase64Encoded: base64Data,
|
|
1032
1075
|
mimeType: file.mediaType || "image/png"
|
|
@@ -1052,7 +1095,7 @@ var GoogleVertexVideoModel = class {
|
|
|
1052
1095
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
1053
1096
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
1054
1097
|
const warnings = [];
|
|
1055
|
-
const vertexOptions = await (0,
|
|
1098
|
+
const vertexOptions = await (0, import_provider_utils9.parseProviderOptions)({
|
|
1056
1099
|
provider: "vertex",
|
|
1057
1100
|
providerOptions: options.providerOptions,
|
|
1058
1101
|
schema: googleVertexVideoModelOptionsSchema
|
|
@@ -1134,17 +1177,17 @@ var GoogleVertexVideoModel = class {
|
|
|
1134
1177
|
}
|
|
1135
1178
|
}
|
|
1136
1179
|
}
|
|
1137
|
-
const { value: operation } = await (0,
|
|
1180
|
+
const { value: operation } = await (0, import_provider_utils9.postJsonToApi)({
|
|
1138
1181
|
url: `${this.config.baseURL}/models/${this.modelId}:predictLongRunning`,
|
|
1139
|
-
headers: (0,
|
|
1140
|
-
await (0,
|
|
1182
|
+
headers: (0, import_provider_utils9.combineHeaders)(
|
|
1183
|
+
await (0, import_provider_utils9.resolve)(this.config.headers),
|
|
1141
1184
|
options.headers
|
|
1142
1185
|
),
|
|
1143
1186
|
body: {
|
|
1144
1187
|
instances,
|
|
1145
1188
|
parameters
|
|
1146
1189
|
},
|
|
1147
|
-
successfulResponseHandler: (0,
|
|
1190
|
+
successfulResponseHandler: (0, import_provider_utils9.createJsonResponseHandler)(
|
|
1148
1191
|
vertexOperationSchema
|
|
1149
1192
|
),
|
|
1150
1193
|
failedResponseHandler: googleVertexFailedResponseHandler,
|
|
@@ -1170,23 +1213,23 @@ var GoogleVertexVideoModel = class {
|
|
|
1170
1213
|
message: `Video generation timed out after ${pollTimeoutMs}ms`
|
|
1171
1214
|
});
|
|
1172
1215
|
}
|
|
1173
|
-
await (0,
|
|
1216
|
+
await (0, import_provider_utils9.delay)(pollIntervalMs);
|
|
1174
1217
|
if ((_g = options.abortSignal) == null ? void 0 : _g.aborted) {
|
|
1175
1218
|
throw new import_provider3.AISDKError({
|
|
1176
1219
|
name: "VERTEX_VIDEO_GENERATION_ABORTED",
|
|
1177
1220
|
message: "Video generation request was aborted"
|
|
1178
1221
|
});
|
|
1179
1222
|
}
|
|
1180
|
-
const { value: statusOperation, responseHeaders: pollHeaders } = await (0,
|
|
1223
|
+
const { value: statusOperation, responseHeaders: pollHeaders } = await (0, import_provider_utils9.postJsonToApi)({
|
|
1181
1224
|
url: `${this.config.baseURL}/models/${this.modelId}:fetchPredictOperation`,
|
|
1182
|
-
headers: (0,
|
|
1183
|
-
await (0,
|
|
1225
|
+
headers: (0, import_provider_utils9.combineHeaders)(
|
|
1226
|
+
await (0, import_provider_utils9.resolve)(this.config.headers),
|
|
1184
1227
|
options.headers
|
|
1185
1228
|
),
|
|
1186
1229
|
body: {
|
|
1187
1230
|
operationName
|
|
1188
1231
|
},
|
|
1189
|
-
successfulResponseHandler: (0,
|
|
1232
|
+
successfulResponseHandler: (0, import_provider_utils9.createJsonResponseHandler)(
|
|
1190
1233
|
vertexOperationSchema
|
|
1191
1234
|
),
|
|
1192
1235
|
failedResponseHandler: googleVertexFailedResponseHandler,
|
|
@@ -1255,27 +1298,31 @@ var GoogleVertexVideoModel = class {
|
|
|
1255
1298
|
};
|
|
1256
1299
|
}
|
|
1257
1300
|
};
|
|
1258
|
-
var vertexOperationSchema =
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
import_v49.z.object({
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1301
|
+
var vertexOperationSchema = (0, import_provider_utils9.lazySchema)(
|
|
1302
|
+
() => (0, import_provider_utils9.zodSchema)(
|
|
1303
|
+
import_v49.z.object({
|
|
1304
|
+
name: import_v49.z.string().nullish(),
|
|
1305
|
+
done: import_v49.z.boolean().nullish(),
|
|
1306
|
+
error: import_v49.z.object({
|
|
1307
|
+
code: import_v49.z.number().nullish(),
|
|
1308
|
+
message: import_v49.z.string(),
|
|
1309
|
+
status: import_v49.z.string().nullish()
|
|
1310
|
+
}).nullish(),
|
|
1311
|
+
response: import_v49.z.object({
|
|
1312
|
+
videos: import_v49.z.array(
|
|
1313
|
+
import_v49.z.object({
|
|
1314
|
+
bytesBase64Encoded: import_v49.z.string().nullish(),
|
|
1315
|
+
gcsUri: import_v49.z.string().nullish(),
|
|
1316
|
+
mimeType: import_v49.z.string().nullish()
|
|
1317
|
+
})
|
|
1318
|
+
).nullish(),
|
|
1319
|
+
raiMediaFilteredCount: import_v49.z.number().nullish()
|
|
1320
|
+
}).nullish()
|
|
1321
|
+
})
|
|
1322
|
+
)
|
|
1323
|
+
);
|
|
1324
|
+
var googleVertexVideoModelOptionsSchema = (0, import_provider_utils9.lazySchema)(
|
|
1325
|
+
() => (0, import_provider_utils9.zodSchema)(
|
|
1279
1326
|
import_v49.z.object({
|
|
1280
1327
|
pollIntervalMs: import_v49.z.number().positive().nullish(),
|
|
1281
1328
|
pollTimeoutMs: import_v49.z.number().positive().nullish(),
|
|
@@ -1300,7 +1347,7 @@ function createExpressModeFetch(apiKey, customFetch) {
|
|
|
1300
1347
|
const modifiedInit = {
|
|
1301
1348
|
...init,
|
|
1302
1349
|
headers: {
|
|
1303
|
-
...(init == null ? void 0 : init.headers) ? (0,
|
|
1350
|
+
...(init == null ? void 0 : init.headers) ? (0, import_provider_utils10.normalizeHeaders)(init.headers) : {},
|
|
1304
1351
|
"x-goog-api-key": apiKey
|
|
1305
1352
|
}
|
|
1306
1353
|
};
|
|
@@ -1308,17 +1355,17 @@ function createExpressModeFetch(apiKey, customFetch) {
|
|
|
1308
1355
|
};
|
|
1309
1356
|
}
|
|
1310
1357
|
function createVertex(options = {}) {
|
|
1311
|
-
const apiKey = (0,
|
|
1358
|
+
const apiKey = (0, import_provider_utils10.loadOptionalSetting)({
|
|
1312
1359
|
settingValue: options.apiKey,
|
|
1313
1360
|
environmentVariableName: "GOOGLE_VERTEX_API_KEY"
|
|
1314
1361
|
});
|
|
1315
|
-
const loadVertexProject = () => (0,
|
|
1362
|
+
const loadVertexProject = () => (0, import_provider_utils10.loadSetting)({
|
|
1316
1363
|
settingValue: options.project,
|
|
1317
1364
|
settingName: "project",
|
|
1318
1365
|
environmentVariableName: "GOOGLE_VERTEX_PROJECT",
|
|
1319
1366
|
description: "Google Vertex project"
|
|
1320
1367
|
});
|
|
1321
|
-
const loadVertexLocation = () => (0,
|
|
1368
|
+
const loadVertexLocation = () => (0, import_provider_utils10.loadSetting)({
|
|
1322
1369
|
settingValue: options.location,
|
|
1323
1370
|
settingName: "location",
|
|
1324
1371
|
environmentVariableName: "GOOGLE_VERTEX_LOCATION",
|
|
@@ -1327,7 +1374,7 @@ function createVertex(options = {}) {
|
|
|
1327
1374
|
const loadBaseURL = ({ endpoint = false } = {}) => {
|
|
1328
1375
|
var _a, _b;
|
|
1329
1376
|
if (apiKey) {
|
|
1330
|
-
return (_a = (0,
|
|
1377
|
+
return (_a = (0, import_provider_utils10.withoutTrailingSlash)(options.baseURL)) != null ? _a : EXPRESS_MODE_BASE_URL;
|
|
1331
1378
|
}
|
|
1332
1379
|
const region = loadVertexLocation();
|
|
1333
1380
|
const project = loadVertexProject();
|
|
@@ -1340,13 +1387,13 @@ function createVertex(options = {}) {
|
|
|
1340
1387
|
return `${region}-aiplatform.googleapis.com`;
|
|
1341
1388
|
}
|
|
1342
1389
|
};
|
|
1343
|
-
return (_b = (0,
|
|
1390
|
+
return (_b = (0, import_provider_utils10.withoutTrailingSlash)(options.baseURL)) != null ? _b : `https://${getHost()}/v1beta1/projects/${project}/locations/${region}${endpoint ? "" : "/publishers/google"}`;
|
|
1344
1391
|
};
|
|
1345
1392
|
const createConfig = (name, { endpoint = false } = {}) => {
|
|
1346
1393
|
const getHeaders = async () => {
|
|
1347
1394
|
var _a;
|
|
1348
|
-
const originalHeaders = await (0,
|
|
1349
|
-
return (0,
|
|
1395
|
+
const originalHeaders = await (0, import_provider_utils10.resolve)((_a = options.headers) != null ? _a : {});
|
|
1396
|
+
return (0, import_provider_utils10.withUserAgentSuffix)(
|
|
1350
1397
|
originalHeaders,
|
|
1351
1398
|
`ai-sdk/google-vertex/${VERSION}`
|
|
1352
1399
|
);
|
|
@@ -1362,7 +1409,7 @@ function createVertex(options = {}) {
|
|
|
1362
1409
|
var _a;
|
|
1363
1410
|
return new import_internal3.GoogleGenerativeAILanguageModel(modelId, {
|
|
1364
1411
|
...createConfig("chat"),
|
|
1365
|
-
generateId: (_a = options.generateId) != null ? _a :
|
|
1412
|
+
generateId: (_a = options.generateId) != null ? _a : import_provider_utils10.generateId,
|
|
1366
1413
|
supportedUrls: () => ({
|
|
1367
1414
|
"*": [
|
|
1368
1415
|
// HTTP URLs:
|
|
@@ -1388,7 +1435,7 @@ function createVertex(options = {}) {
|
|
|
1388
1435
|
// endpoint-style base URL without the `/publishers/google` suffix that
|
|
1389
1436
|
// the base-model paths carry.
|
|
1390
1437
|
...createConfig("interactions", { endpoint: true }),
|
|
1391
|
-
generateId: (_a = options.generateId) != null ? _a :
|
|
1438
|
+
generateId: (_a = options.generateId) != null ? _a : import_provider_utils10.generateId
|
|
1392
1439
|
}
|
|
1393
1440
|
);
|
|
1394
1441
|
};
|
|
@@ -1397,14 +1444,14 @@ function createVertex(options = {}) {
|
|
|
1397
1444
|
var _a;
|
|
1398
1445
|
return new GoogleVertexImageModel(modelId, {
|
|
1399
1446
|
...createConfig("image"),
|
|
1400
|
-
generateId: (_a = options.generateId) != null ? _a :
|
|
1447
|
+
generateId: (_a = options.generateId) != null ? _a : import_provider_utils10.generateId
|
|
1401
1448
|
});
|
|
1402
1449
|
};
|
|
1403
1450
|
const createVideoModel = (modelId) => {
|
|
1404
1451
|
var _a;
|
|
1405
1452
|
return new GoogleVertexVideoModel(modelId, {
|
|
1406
1453
|
...createConfig("video"),
|
|
1407
|
-
generateId: (_a = options.generateId) != null ? _a :
|
|
1454
|
+
generateId: (_a = options.generateId) != null ? _a : import_provider_utils10.generateId
|
|
1408
1455
|
});
|
|
1409
1456
|
};
|
|
1410
1457
|
const createTranscriptionModel = (modelId) => {
|
|
@@ -1455,7 +1502,7 @@ function createVertex(options = {}) {
|
|
|
1455
1502
|
|
|
1456
1503
|
// src/google-vertex-provider-node.ts
|
|
1457
1504
|
function createVertex2(options = {}) {
|
|
1458
|
-
const apiKey = (0,
|
|
1505
|
+
const apiKey = (0, import_provider_utils11.loadOptionalSetting)({
|
|
1459
1506
|
settingValue: options.apiKey,
|
|
1460
1507
|
environmentVariableName: "GOOGLE_VERTEX_API_KEY"
|
|
1461
1508
|
});
|
|
@@ -1471,7 +1518,7 @@ function createVertex2(options = {}) {
|
|
|
1471
1518
|
...options,
|
|
1472
1519
|
headers: async () => ({
|
|
1473
1520
|
Authorization: `Bearer ${await generateAuthToken()}`,
|
|
1474
|
-
...await (0,
|
|
1521
|
+
...await (0, import_provider_utils11.resolve)(options.headers)
|
|
1475
1522
|
})
|
|
1476
1523
|
});
|
|
1477
1524
|
}
|