@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/edge/index.js
CHANGED
|
@@ -26,30 +26,34 @@ __export(index_exports, {
|
|
|
26
26
|
module.exports = __toCommonJS(index_exports);
|
|
27
27
|
|
|
28
28
|
// src/edge/google-vertex-provider-edge.ts
|
|
29
|
-
var
|
|
29
|
+
var import_provider_utils12 = require("@ai-sdk/provider-utils");
|
|
30
30
|
|
|
31
31
|
// src/google-vertex-provider.ts
|
|
32
32
|
var import_internal3 = require("@ai-sdk/google/internal");
|
|
33
|
-
var
|
|
33
|
+
var import_provider_utils10 = require("@ai-sdk/provider-utils");
|
|
34
34
|
|
|
35
35
|
// src/version.ts
|
|
36
|
-
var VERSION = true ? "4.0.
|
|
36
|
+
var VERSION = true ? "4.0.220" : "0.0.0-test";
|
|
37
37
|
|
|
38
38
|
// src/google-vertex-embedding-model.ts
|
|
39
39
|
var import_provider = require("@ai-sdk/provider");
|
|
40
|
-
var
|
|
40
|
+
var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
|
41
41
|
var import_v43 = require("zod/v4");
|
|
42
42
|
|
|
43
43
|
// src/google-vertex-error.ts
|
|
44
44
|
var import_provider_utils = require("@ai-sdk/provider-utils");
|
|
45
45
|
var import_v4 = require("zod/v4");
|
|
46
|
-
var googleVertexErrorDataSchema =
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
46
|
+
var googleVertexErrorDataSchema = (0, import_provider_utils.lazySchema)(
|
|
47
|
+
() => (0, import_provider_utils.zodSchema)(
|
|
48
|
+
import_v4.z.object({
|
|
49
|
+
error: import_v4.z.object({
|
|
50
|
+
code: import_v4.z.number().nullable(),
|
|
51
|
+
message: import_v4.z.string(),
|
|
52
|
+
status: import_v4.z.string()
|
|
53
|
+
})
|
|
54
|
+
})
|
|
55
|
+
)
|
|
56
|
+
);
|
|
53
57
|
var googleVertexFailedResponseHandler = (0, import_provider_utils.createJsonErrorResponseHandler)(
|
|
54
58
|
{
|
|
55
59
|
errorSchema: googleVertexErrorDataSchema,
|
|
@@ -58,47 +62,52 @@ var googleVertexFailedResponseHandler = (0, import_provider_utils.createJsonErro
|
|
|
58
62
|
);
|
|
59
63
|
|
|
60
64
|
// src/google-vertex-embedding-options.ts
|
|
65
|
+
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
61
66
|
var import_v42 = require("zod/v4");
|
|
62
|
-
var googleVertexEmbeddingModelOptions =
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
67
|
+
var googleVertexEmbeddingModelOptions = (0, import_provider_utils2.lazySchema)(
|
|
68
|
+
() => (0, import_provider_utils2.zodSchema)(
|
|
69
|
+
import_v42.z.object({
|
|
70
|
+
/**
|
|
71
|
+
* Optional. Optional reduced dimension for the output embedding.
|
|
72
|
+
* If set, excessive values in the output embedding are truncated from the end.
|
|
73
|
+
*/
|
|
74
|
+
outputDimensionality: import_v42.z.number().optional(),
|
|
75
|
+
/**
|
|
76
|
+
* Optional. Specifies the task type for generating embeddings.
|
|
77
|
+
* Supported task types:
|
|
78
|
+
* - SEMANTIC_SIMILARITY: Optimized for text similarity.
|
|
79
|
+
* - CLASSIFICATION: Optimized for text classification.
|
|
80
|
+
* - CLUSTERING: Optimized for clustering texts based on similarity.
|
|
81
|
+
* - RETRIEVAL_DOCUMENT: Optimized for document retrieval.
|
|
82
|
+
* - RETRIEVAL_QUERY: Optimized for query-based retrieval.
|
|
83
|
+
* - QUESTION_ANSWERING: Optimized for answering questions.
|
|
84
|
+
* - FACT_VERIFICATION: Optimized for verifying factual information.
|
|
85
|
+
* - CODE_RETRIEVAL_QUERY: Optimized for retrieving code blocks based on natural language queries.
|
|
86
|
+
*/
|
|
87
|
+
taskType: import_v42.z.enum([
|
|
88
|
+
"SEMANTIC_SIMILARITY",
|
|
89
|
+
"CLASSIFICATION",
|
|
90
|
+
"CLUSTERING",
|
|
91
|
+
"RETRIEVAL_DOCUMENT",
|
|
92
|
+
"RETRIEVAL_QUERY",
|
|
93
|
+
"QUESTION_ANSWERING",
|
|
94
|
+
"FACT_VERIFICATION",
|
|
95
|
+
"CODE_RETRIEVAL_QUERY"
|
|
96
|
+
]).optional(),
|
|
97
|
+
/**
|
|
98
|
+
* Optional. The title of the document being embedded.
|
|
99
|
+
* Only valid when task_type is set to 'RETRIEVAL_DOCUMENT'.
|
|
100
|
+
* Helps the model produce better embeddings by providing additional context.
|
|
101
|
+
*/
|
|
102
|
+
title: import_v42.z.string().optional(),
|
|
103
|
+
/**
|
|
104
|
+
* Optional. When set to true, input text will be truncated. When set to false,
|
|
105
|
+
* an error is returned if the input text is longer than the maximum length supported by the model. Defaults to true.
|
|
106
|
+
*/
|
|
107
|
+
autoTruncate: import_v42.z.boolean().optional()
|
|
108
|
+
})
|
|
109
|
+
)
|
|
110
|
+
);
|
|
102
111
|
|
|
103
112
|
// src/google-vertex-embedding-model.ts
|
|
104
113
|
var GoogleVertexEmbeddingModel = class {
|
|
@@ -123,13 +132,13 @@ var GoogleVertexEmbeddingModel = class {
|
|
|
123
132
|
providerOptions
|
|
124
133
|
}) {
|
|
125
134
|
var _a;
|
|
126
|
-
let googleOptions = await (0,
|
|
135
|
+
let googleOptions = await (0, import_provider_utils3.parseProviderOptions)({
|
|
127
136
|
provider: "vertex",
|
|
128
137
|
providerOptions,
|
|
129
138
|
schema: googleVertexEmbeddingModelOptions
|
|
130
139
|
});
|
|
131
140
|
if (googleOptions == null) {
|
|
132
|
-
googleOptions = await (0,
|
|
141
|
+
googleOptions = await (0, import_provider_utils3.parseProviderOptions)({
|
|
133
142
|
provider: "google",
|
|
134
143
|
providerOptions,
|
|
135
144
|
schema: googleVertexEmbeddingModelOptions
|
|
@@ -144,8 +153,8 @@ var GoogleVertexEmbeddingModel = class {
|
|
|
144
153
|
values
|
|
145
154
|
});
|
|
146
155
|
}
|
|
147
|
-
const mergedHeaders = (0,
|
|
148
|
-
await (0,
|
|
156
|
+
const mergedHeaders = (0, import_provider_utils3.combineHeaders)(
|
|
157
|
+
await (0, import_provider_utils3.resolve)(this.config.headers),
|
|
149
158
|
headers
|
|
150
159
|
);
|
|
151
160
|
if (usesEmbedContentEndpoint(this.modelId)) {
|
|
@@ -153,7 +162,7 @@ var GoogleVertexEmbeddingModel = class {
|
|
|
153
162
|
responseHeaders: responseHeaders2,
|
|
154
163
|
value: response2,
|
|
155
164
|
rawValue: rawValue2
|
|
156
|
-
} = await (0,
|
|
165
|
+
} = await (0, import_provider_utils3.postJsonToApi)({
|
|
157
166
|
url: `${this.config.baseURL}/models/${this.modelId}:embedContent`,
|
|
158
167
|
headers: mergedHeaders,
|
|
159
168
|
body: {
|
|
@@ -166,7 +175,7 @@ var GoogleVertexEmbeddingModel = class {
|
|
|
166
175
|
}
|
|
167
176
|
},
|
|
168
177
|
failedResponseHandler: googleVertexFailedResponseHandler,
|
|
169
|
-
successfulResponseHandler: (0,
|
|
178
|
+
successfulResponseHandler: (0, import_provider_utils3.createJsonResponseHandler)(
|
|
170
179
|
googleVertexEmbedContentResponseSchema
|
|
171
180
|
),
|
|
172
181
|
abortSignal,
|
|
@@ -184,7 +193,7 @@ var GoogleVertexEmbeddingModel = class {
|
|
|
184
193
|
responseHeaders,
|
|
185
194
|
value: response,
|
|
186
195
|
rawValue
|
|
187
|
-
} = await (0,
|
|
196
|
+
} = await (0, import_provider_utils3.postJsonToApi)({
|
|
188
197
|
url,
|
|
189
198
|
headers: mergedHeaders,
|
|
190
199
|
body: {
|
|
@@ -199,7 +208,7 @@ var GoogleVertexEmbeddingModel = class {
|
|
|
199
208
|
}
|
|
200
209
|
},
|
|
201
210
|
failedResponseHandler: googleVertexFailedResponseHandler,
|
|
202
|
-
successfulResponseHandler: (0,
|
|
211
|
+
successfulResponseHandler: (0, import_provider_utils3.createJsonResponseHandler)(
|
|
203
212
|
googleVertexTextEmbeddingResponseSchema
|
|
204
213
|
),
|
|
205
214
|
abortSignal,
|
|
@@ -220,33 +229,41 @@ var GoogleVertexEmbeddingModel = class {
|
|
|
220
229
|
};
|
|
221
230
|
}
|
|
222
231
|
};
|
|
223
|
-
var googleVertexTextEmbeddingResponseSchema =
|
|
224
|
-
|
|
232
|
+
var googleVertexTextEmbeddingResponseSchema = (0, import_provider_utils3.lazySchema)(
|
|
233
|
+
() => (0, import_provider_utils3.zodSchema)(
|
|
225
234
|
import_v43.z.object({
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
235
|
+
predictions: import_v43.z.array(
|
|
236
|
+
import_v43.z.object({
|
|
237
|
+
embeddings: import_v43.z.object({
|
|
238
|
+
values: import_v43.z.array(import_v43.z.number()),
|
|
239
|
+
statistics: import_v43.z.object({
|
|
240
|
+
token_count: import_v43.z.number()
|
|
241
|
+
})
|
|
242
|
+
})
|
|
230
243
|
})
|
|
231
|
-
|
|
244
|
+
)
|
|
232
245
|
})
|
|
233
246
|
)
|
|
234
|
-
|
|
235
|
-
var googleVertexEmbedContentResponseSchema =
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
247
|
+
);
|
|
248
|
+
var googleVertexEmbedContentResponseSchema = (0, import_provider_utils3.lazySchema)(
|
|
249
|
+
() => (0, import_provider_utils3.zodSchema)(
|
|
250
|
+
import_v43.z.object({
|
|
251
|
+
embedding: import_v43.z.object({
|
|
252
|
+
values: import_v43.z.array(import_v43.z.number())
|
|
253
|
+
}),
|
|
254
|
+
usageMetadata: import_v43.z.object({
|
|
255
|
+
promptTokenCount: import_v43.z.number().nullish()
|
|
256
|
+
}).nullish()
|
|
257
|
+
})
|
|
258
|
+
)
|
|
259
|
+
);
|
|
243
260
|
function usesEmbedContentEndpoint(modelId) {
|
|
244
261
|
return modelId === "gemini-embedding-2" || modelId === "gemini-embedding-2-preview";
|
|
245
262
|
}
|
|
246
263
|
|
|
247
264
|
// src/google-vertex-image-model.ts
|
|
248
265
|
var import_internal = require("@ai-sdk/google/internal");
|
|
249
|
-
var
|
|
266
|
+
var import_provider_utils4 = require("@ai-sdk/provider-utils");
|
|
250
267
|
var import_v44 = require("zod/v4");
|
|
251
268
|
var GoogleVertexImageModel = class {
|
|
252
269
|
constructor(modelId, config) {
|
|
@@ -290,7 +307,7 @@ var GoogleVertexImageModel = class {
|
|
|
290
307
|
details: "This model does not support the `size` option. Use `aspectRatio` instead."
|
|
291
308
|
});
|
|
292
309
|
}
|
|
293
|
-
const vertexImageOptions = await (0,
|
|
310
|
+
const vertexImageOptions = await (0, import_provider_utils4.parseProviderOptions)({
|
|
294
311
|
provider: "vertex",
|
|
295
312
|
providerOptions,
|
|
296
313
|
schema: googleVertexImageModelOptionsSchema
|
|
@@ -352,12 +369,12 @@ var GoogleVertexImageModel = class {
|
|
|
352
369
|
};
|
|
353
370
|
}
|
|
354
371
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
355
|
-
const { value: response, responseHeaders } = await (0,
|
|
372
|
+
const { value: response, responseHeaders } = await (0, import_provider_utils4.postJsonToApi)({
|
|
356
373
|
url: `${this.config.baseURL}/models/${this.modelId}:predict`,
|
|
357
|
-
headers: (0,
|
|
374
|
+
headers: (0, import_provider_utils4.combineHeaders)(await (0, import_provider_utils4.resolve)(this.config.headers), headers),
|
|
358
375
|
body,
|
|
359
376
|
failedResponseHandler: googleVertexFailedResponseHandler,
|
|
360
|
-
successfulResponseHandler: (0,
|
|
377
|
+
successfulResponseHandler: (0, import_provider_utils4.createJsonResponseHandler)(
|
|
361
378
|
vertexImageResponseSchema
|
|
362
379
|
),
|
|
363
380
|
abortSignal,
|
|
@@ -452,7 +469,7 @@ var GoogleVertexImageModel = class {
|
|
|
452
469
|
baseURL: this.config.baseURL,
|
|
453
470
|
headers: (_a = this.config.headers) != null ? _a : {},
|
|
454
471
|
fetch: this.config.fetch,
|
|
455
|
-
generateId: (_b = this.config.generateId) != null ? _b :
|
|
472
|
+
generateId: (_b = this.config.generateId) != null ? _b : import_provider_utils4.generateId,
|
|
456
473
|
supportedUrls: () => ({
|
|
457
474
|
"*": [/^https?:\/\/.*$/, /^gs:\/\/.*$/]
|
|
458
475
|
})
|
|
@@ -476,7 +493,7 @@ var GoogleVertexImageModel = class {
|
|
|
476
493
|
const images = [];
|
|
477
494
|
for (const part of result.content) {
|
|
478
495
|
if (part.type === "file" && part.mediaType.startsWith("image/")) {
|
|
479
|
-
images.push((0,
|
|
496
|
+
images.push((0, import_provider_utils4.convertToBase64)(part.data));
|
|
480
497
|
}
|
|
481
498
|
}
|
|
482
499
|
return {
|
|
@@ -504,74 +521,82 @@ var GoogleVertexImageModel = class {
|
|
|
504
521
|
function isGeminiModel(modelId) {
|
|
505
522
|
return modelId.startsWith("gemini-");
|
|
506
523
|
}
|
|
507
|
-
var vertexImageResponseSchema =
|
|
508
|
-
|
|
509
|
-
import_v44.z.
|
|
510
|
-
import_v44.z.
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
524
|
+
var vertexImageResponseSchema = (0, import_provider_utils4.lazySchema)(
|
|
525
|
+
() => (0, import_provider_utils4.zodSchema)(
|
|
526
|
+
import_v44.z.object({
|
|
527
|
+
predictions: import_v44.z.array(
|
|
528
|
+
import_v44.z.union([
|
|
529
|
+
import_v44.z.object({
|
|
530
|
+
bytesBase64Encoded: import_v44.z.string(),
|
|
531
|
+
mimeType: import_v44.z.string(),
|
|
532
|
+
prompt: import_v44.z.string().nullish()
|
|
533
|
+
}),
|
|
534
|
+
import_v44.z.object({ raiFilteredReason: import_v44.z.string() })
|
|
535
|
+
])
|
|
536
|
+
).nullish()
|
|
537
|
+
})
|
|
538
|
+
)
|
|
539
|
+
);
|
|
540
|
+
var googleVertexImageModelOptionsSchema = (0, import_provider_utils4.lazySchema)(
|
|
541
|
+
() => (0, import_provider_utils4.zodSchema)(
|
|
542
|
+
import_v44.z.object({
|
|
543
|
+
negativePrompt: import_v44.z.string().nullish(),
|
|
544
|
+
personGeneration: import_v44.z.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
|
|
545
|
+
safetySetting: import_v44.z.enum([
|
|
546
|
+
"block_low_and_above",
|
|
547
|
+
"block_medium_and_above",
|
|
548
|
+
"block_only_high",
|
|
549
|
+
"block_none"
|
|
550
|
+
]).nullish(),
|
|
551
|
+
addWatermark: import_v44.z.boolean().nullish(),
|
|
552
|
+
storageUri: import_v44.z.string().nullish(),
|
|
553
|
+
sampleImageSize: import_v44.z.enum(["1K", "2K"]).nullish(),
|
|
554
|
+
/**
|
|
555
|
+
* Configuration for image editing operations
|
|
556
|
+
*/
|
|
557
|
+
edit: import_v44.z.object({
|
|
558
|
+
/**
|
|
559
|
+
* An integer that represents the number of sampling steps.
|
|
560
|
+
* A higher value offers better image quality, a lower value offers better latency.
|
|
561
|
+
* Try 35 steps to start. If the quality doesn't meet your requirements,
|
|
562
|
+
* increase the value towards an upper limit of 75.
|
|
563
|
+
*/
|
|
564
|
+
baseSteps: import_v44.z.number().nullish(),
|
|
565
|
+
// Edit mode options
|
|
566
|
+
// https://cloud.google.com/vertex-ai/generative-ai/docs/image/edit-insert-objects
|
|
567
|
+
mode: import_v44.z.enum([
|
|
568
|
+
"EDIT_MODE_INPAINT_INSERTION",
|
|
569
|
+
"EDIT_MODE_INPAINT_REMOVAL",
|
|
570
|
+
"EDIT_MODE_OUTPAINT",
|
|
571
|
+
"EDIT_MODE_CONTROLLED_EDITING",
|
|
572
|
+
"EDIT_MODE_PRODUCT_IMAGE",
|
|
573
|
+
"EDIT_MODE_BGSWAP"
|
|
574
|
+
]).nullish(),
|
|
575
|
+
/**
|
|
576
|
+
* The mask mode to use.
|
|
577
|
+
* - `MASK_MODE_DEFAULT` - Default value for mask mode.
|
|
578
|
+
* - `MASK_MODE_USER_PROVIDED` - User provided mask. No segmentation needed.
|
|
579
|
+
* - `MASK_MODE_DETECTION_BOX` - Mask from detected bounding boxes.
|
|
580
|
+
* - `MASK_MODE_CLOTHING_AREA` - Masks from segmenting the clothing area with open-vocab segmentation.
|
|
581
|
+
* - `MASK_MODE_PARSED_PERSON` - Masks from segmenting the person body and clothing using the person-parsing model.
|
|
582
|
+
*/
|
|
583
|
+
maskMode: import_v44.z.enum([
|
|
584
|
+
"MASK_MODE_DEFAULT",
|
|
585
|
+
"MASK_MODE_USER_PROVIDED",
|
|
586
|
+
"MASK_MODE_DETECTION_BOX",
|
|
587
|
+
"MASK_MODE_CLOTHING_AREA",
|
|
588
|
+
"MASK_MODE_PARSED_PERSON"
|
|
589
|
+
]).nullish(),
|
|
590
|
+
/**
|
|
591
|
+
* Optional. A float value between 0 and 1, inclusive, that represents the
|
|
592
|
+
* percentage of the image width to grow the mask by. Using dilation helps
|
|
593
|
+
* compensate for imprecise masks. We recommend a value of 0.01.
|
|
594
|
+
*/
|
|
595
|
+
maskDilation: import_v44.z.number().nullish()
|
|
596
|
+
}).nullish()
|
|
597
|
+
})
|
|
598
|
+
)
|
|
599
|
+
);
|
|
575
600
|
function getBase64Data(file) {
|
|
576
601
|
if (file.type === "url") {
|
|
577
602
|
throw new Error(
|
|
@@ -581,7 +606,7 @@ function getBase64Data(file) {
|
|
|
581
606
|
if (typeof file.data === "string") {
|
|
582
607
|
return file.data;
|
|
583
608
|
}
|
|
584
|
-
return (0,
|
|
609
|
+
return (0, import_provider_utils4.convertUint8ArrayToBase64)(file.data);
|
|
585
610
|
}
|
|
586
611
|
|
|
587
612
|
// src/google-vertex-tools.ts
|
|
@@ -597,40 +622,45 @@ var googleVertexTools = {
|
|
|
597
622
|
};
|
|
598
623
|
|
|
599
624
|
// src/google-vertex-transcription-model.ts
|
|
600
|
-
var
|
|
625
|
+
var import_provider_utils6 = require("@ai-sdk/provider-utils");
|
|
601
626
|
var import_v46 = require("zod/v4");
|
|
602
627
|
|
|
603
628
|
// src/google-vertex-transcription-model-options.ts
|
|
629
|
+
var import_provider_utils5 = require("@ai-sdk/provider-utils");
|
|
604
630
|
var import_v45 = require("zod/v4");
|
|
605
|
-
var googleVertexTranscriptionProviderOptionsSchema =
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
631
|
+
var googleVertexTranscriptionProviderOptionsSchema = (0, import_provider_utils5.lazySchema)(
|
|
632
|
+
() => (0, import_provider_utils5.zodSchema)(
|
|
633
|
+
import_v45.z.object({
|
|
634
|
+
/**
|
|
635
|
+
* BCP-47 language codes to recognize (e.g. `['en-US']`), or `['auto']` to let
|
|
636
|
+
* Chirp auto-detect the spoken language. Defaults to `['auto']`. For
|
|
637
|
+
* `telephony`, pass a supported explicit language code.
|
|
638
|
+
*/
|
|
639
|
+
languageCodes: import_v45.z.array(import_v45.z.string()).optional(),
|
|
640
|
+
/**
|
|
641
|
+
* Whether to add punctuation to the transcript. Defaults to `true`.
|
|
642
|
+
*/
|
|
643
|
+
enableAutomaticPunctuation: import_v45.z.boolean().optional(),
|
|
644
|
+
/**
|
|
645
|
+
* Whether to include word-level timestamps. Defaults to `true` so the
|
|
646
|
+
* transcription result can include segments.
|
|
647
|
+
*
|
|
648
|
+
* Enabling word-level timestamps can reduce transcription quality and speed
|
|
649
|
+
* for Chirp models.
|
|
650
|
+
*/
|
|
651
|
+
enableWordTimeOffsets: import_v45.z.boolean().optional(),
|
|
652
|
+
/**
|
|
653
|
+
* The Cloud Speech-to-Text region for the request (e.g. `'us'`, `'eu'`,
|
|
654
|
+
* `'us-central1'`). Defaults to the provider `location`.
|
|
655
|
+
*
|
|
656
|
+
* Note: Speech-to-Text regions differ from Vertex AI regions. Chirp is only
|
|
657
|
+
* available in specific Speech-to-Text regions and is not available in the
|
|
658
|
+
* `global` location.
|
|
659
|
+
*/
|
|
660
|
+
region: import_v45.z.string().optional()
|
|
661
|
+
})
|
|
662
|
+
)
|
|
663
|
+
);
|
|
634
664
|
|
|
635
665
|
// src/google-vertex-transcription-model.ts
|
|
636
666
|
function parseDurationSeconds(value) {
|
|
@@ -666,7 +696,7 @@ var GoogleVertexTranscriptionModel = class {
|
|
|
666
696
|
const warnings = [];
|
|
667
697
|
let googleOptions;
|
|
668
698
|
for (const provider of ["googleVertex", "vertex", "google"]) {
|
|
669
|
-
googleOptions = await (0,
|
|
699
|
+
googleOptions = await (0, import_provider_utils6.parseProviderOptions)({
|
|
670
700
|
provider,
|
|
671
701
|
providerOptions: options.providerOptions,
|
|
672
702
|
schema: googleVertexTranscriptionProviderOptionsSchema
|
|
@@ -677,7 +707,7 @@ var GoogleVertexTranscriptionModel = class {
|
|
|
677
707
|
}
|
|
678
708
|
const region = (_d = googleOptions == null ? void 0 : googleOptions.region) != null ? _d : this.config.location;
|
|
679
709
|
const languageCodes = (_e = googleOptions == null ? void 0 : googleOptions.languageCodes) != null ? _e : ["auto"];
|
|
680
|
-
const content = typeof options.audio === "string" ? options.audio : (0,
|
|
710
|
+
const content = typeof options.audio === "string" ? options.audio : (0, import_provider_utils6.convertUint8ArrayToBase64)(options.audio);
|
|
681
711
|
const requestBody = {
|
|
682
712
|
config: {
|
|
683
713
|
model: this.modelId,
|
|
@@ -698,15 +728,15 @@ var GoogleVertexTranscriptionModel = class {
|
|
|
698
728
|
value: response,
|
|
699
729
|
responseHeaders,
|
|
700
730
|
rawValue: rawResponse
|
|
701
|
-
} = await (0,
|
|
731
|
+
} = await (0, import_provider_utils6.postJsonToApi)({
|
|
702
732
|
url,
|
|
703
|
-
headers: (0,
|
|
704
|
-
this.config.headers ? await (0,
|
|
733
|
+
headers: (0, import_provider_utils6.combineHeaders)(
|
|
734
|
+
this.config.headers ? await (0, import_provider_utils6.resolve)(this.config.headers) : void 0,
|
|
705
735
|
options.headers
|
|
706
736
|
),
|
|
707
737
|
body: requestBody,
|
|
708
738
|
failedResponseHandler: googleVertexFailedResponseHandler,
|
|
709
|
-
successfulResponseHandler: (0,
|
|
739
|
+
successfulResponseHandler: (0, import_provider_utils6.createJsonResponseHandler)(
|
|
710
740
|
googleVertexTranscriptionResponseSchema
|
|
711
741
|
),
|
|
712
742
|
abortSignal: options.abortSignal,
|
|
@@ -745,66 +775,75 @@ var GoogleVertexTranscriptionModel = class {
|
|
|
745
775
|
};
|
|
746
776
|
}
|
|
747
777
|
};
|
|
748
|
-
var googleVertexTranscriptionResponseSchema =
|
|
749
|
-
|
|
778
|
+
var googleVertexTranscriptionResponseSchema = (0, import_provider_utils6.lazySchema)(
|
|
779
|
+
() => (0, import_provider_utils6.zodSchema)(
|
|
750
780
|
import_v46.z.object({
|
|
751
|
-
|
|
781
|
+
results: import_v46.z.array(
|
|
752
782
|
import_v46.z.object({
|
|
753
|
-
|
|
754
|
-
words: import_v46.z.array(
|
|
783
|
+
alternatives: import_v46.z.array(
|
|
755
784
|
import_v46.z.object({
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
785
|
+
transcript: import_v46.z.string().nullish(),
|
|
786
|
+
words: import_v46.z.array(
|
|
787
|
+
import_v46.z.object({
|
|
788
|
+
word: import_v46.z.string().nullish(),
|
|
789
|
+
startOffset: import_v46.z.string().nullish(),
|
|
790
|
+
endOffset: import_v46.z.string().nullish()
|
|
791
|
+
})
|
|
792
|
+
).nullish()
|
|
759
793
|
})
|
|
760
|
-
).nullish()
|
|
794
|
+
).nullish(),
|
|
795
|
+
languageCode: import_v46.z.string().nullish()
|
|
761
796
|
})
|
|
762
797
|
).nullish(),
|
|
763
|
-
|
|
798
|
+
metadata: import_v46.z.object({
|
|
799
|
+
totalBilledDuration: import_v46.z.string().nullish()
|
|
800
|
+
}).nullish()
|
|
764
801
|
})
|
|
765
|
-
)
|
|
766
|
-
|
|
767
|
-
totalBilledDuration: import_v46.z.string().nullish()
|
|
768
|
-
}).nullish()
|
|
769
|
-
});
|
|
802
|
+
)
|
|
803
|
+
);
|
|
770
804
|
|
|
771
805
|
// src/gemini-transcription/google-vertex-gemini-transcription-model.ts
|
|
772
806
|
var import_provider2 = require("@ai-sdk/provider");
|
|
773
|
-
var
|
|
807
|
+
var import_provider_utils8 = require("@ai-sdk/provider-utils");
|
|
774
808
|
var import_v48 = require("zod/v4");
|
|
775
809
|
|
|
776
810
|
// src/gemini-transcription/google-vertex-gemini-transcription-model-options.ts
|
|
811
|
+
var import_provider_utils7 = require("@ai-sdk/provider-utils");
|
|
777
812
|
var import_v47 = require("zod/v4");
|
|
778
|
-
var googleVertexGeminiTranscriptionModelOptions =
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
813
|
+
var googleVertexGeminiTranscriptionModelOptions = (0, import_provider_utils7.lazySchema)(
|
|
814
|
+
() => (0, import_provider_utils7.zodSchema)(
|
|
815
|
+
import_v47.z.object({
|
|
816
|
+
/**
|
|
817
|
+
* BCP-47 language codes providing hints about the languages present in the
|
|
818
|
+
* audio. If omitted or empty, defaults to automatic language detection.
|
|
819
|
+
*/
|
|
820
|
+
languageCodes: import_v47.z.array(import_v47.z.string()).optional(),
|
|
821
|
+
/**
|
|
822
|
+
* Custom vocabulary phrases, which bias the speech recognition model
|
|
823
|
+
* toward recognizing specific terms.
|
|
824
|
+
*/
|
|
825
|
+
customVocabulary: import_v47.z.array(import_v47.z.string()).optional(),
|
|
826
|
+
/**
|
|
827
|
+
* Enables word-level timestamp generation.
|
|
828
|
+
*/
|
|
829
|
+
wordTimestamp: import_v47.z.boolean().optional(),
|
|
830
|
+
/**
|
|
831
|
+
* Enables speaker diarization.
|
|
832
|
+
*/
|
|
833
|
+
diarization: import_v47.z.boolean().optional(),
|
|
834
|
+
/**
|
|
835
|
+
* Transcription output formatting mode.
|
|
836
|
+
*
|
|
837
|
+
* - `VERBATIM` (default): exact literal transcript preserving filler
|
|
838
|
+
* words, repetitions, and false starts.
|
|
839
|
+
* - `SMART`: cleans up and structures the transcript in real time —
|
|
840
|
+
* disfluency removal, inline self-corrections, structured formatting
|
|
841
|
+
* (lists, numbers, dates, paragraph breaks), and grammar/casing polish.
|
|
842
|
+
*/
|
|
843
|
+
mode: import_v47.z.enum(["SMART", "VERBATIM"]).optional()
|
|
844
|
+
})
|
|
845
|
+
)
|
|
846
|
+
);
|
|
808
847
|
|
|
809
848
|
// src/gemini-transcription/google-vertex-gemini-transcription-model.ts
|
|
810
849
|
function isLiveTranscriptionModelId(modelId) {
|
|
@@ -821,7 +860,7 @@ var GoogleVertexGeminiTranscriptionModel = class {
|
|
|
821
860
|
}
|
|
822
861
|
async parseOptions(providerOptions) {
|
|
823
862
|
for (const provider of ["googleVertex", "vertex", "google"]) {
|
|
824
|
-
const parsed = await (0,
|
|
863
|
+
const parsed = await (0, import_provider_utils8.parseProviderOptions)({
|
|
825
864
|
provider,
|
|
826
865
|
providerOptions,
|
|
827
866
|
schema: googleVertexGeminiTranscriptionModelOptions
|
|
@@ -850,7 +889,7 @@ var GoogleVertexGeminiTranscriptionModel = class {
|
|
|
850
889
|
{
|
|
851
890
|
inlineData: {
|
|
852
891
|
mimeType: options.mediaType,
|
|
853
|
-
data: (0,
|
|
892
|
+
data: (0, import_provider_utils8.convertToBase64)(options.audio)
|
|
854
893
|
}
|
|
855
894
|
}
|
|
856
895
|
]
|
|
@@ -862,15 +901,15 @@ var GoogleVertexGeminiTranscriptionModel = class {
|
|
|
862
901
|
value: response,
|
|
863
902
|
responseHeaders,
|
|
864
903
|
rawValue: rawResponse
|
|
865
|
-
} = await (0,
|
|
904
|
+
} = await (0, import_provider_utils8.postJsonToApi)({
|
|
866
905
|
url: `${this.config.baseURL}/models/${this.modelId}:generateContent`,
|
|
867
|
-
headers: (0,
|
|
868
|
-
this.config.headers ? await (0,
|
|
906
|
+
headers: (0, import_provider_utils8.combineHeaders)(
|
|
907
|
+
this.config.headers ? await (0, import_provider_utils8.resolve)(this.config.headers) : void 0,
|
|
869
908
|
options.headers
|
|
870
909
|
),
|
|
871
910
|
body: requestBody,
|
|
872
911
|
failedResponseHandler: googleVertexFailedResponseHandler,
|
|
873
|
-
successfulResponseHandler: (0,
|
|
912
|
+
successfulResponseHandler: (0, import_provider_utils8.createJsonResponseHandler)(
|
|
874
913
|
googleVertexGeminiTranscriptionResponseSchema
|
|
875
914
|
),
|
|
876
915
|
abortSignal: options.abortSignal,
|
|
@@ -946,35 +985,39 @@ function parseOffsetSeconds(offset) {
|
|
|
946
985
|
const parsed = Number.parseFloat(offset);
|
|
947
986
|
return Number.isFinite(parsed) ? parsed : void 0;
|
|
948
987
|
}
|
|
949
|
-
var googleVertexGeminiTranscriptionWordSchema = import_v48.z.object({
|
|
988
|
+
var googleVertexGeminiTranscriptionWordSchema = () => import_v48.z.object({
|
|
950
989
|
word: import_v48.z.string().nullish(),
|
|
951
990
|
startOffset: import_v48.z.string().nullish(),
|
|
952
991
|
endOffset: import_v48.z.string().nullish()
|
|
953
992
|
});
|
|
954
|
-
var googleVertexGeminiTranscriptionResponseSchema =
|
|
955
|
-
|
|
993
|
+
var googleVertexGeminiTranscriptionResponseSchema = (0, import_provider_utils8.lazySchema)(
|
|
994
|
+
() => (0, import_provider_utils8.zodSchema)(
|
|
956
995
|
import_v48.z.object({
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
import_v48.z.object({
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
996
|
+
candidates: import_v48.z.array(
|
|
997
|
+
import_v48.z.object({
|
|
998
|
+
content: import_v48.z.object({
|
|
999
|
+
parts: import_v48.z.array(
|
|
1000
|
+
import_v48.z.object({
|
|
1001
|
+
text: import_v48.z.string().nullish(),
|
|
1002
|
+
audioTranscription: import_v48.z.object({
|
|
1003
|
+
text: import_v48.z.string().nullish(),
|
|
1004
|
+
languageCode: import_v48.z.string().nullish(),
|
|
1005
|
+
speakerLabel: import_v48.z.string().nullish(),
|
|
1006
|
+
words: import_v48.z.array(googleVertexGeminiTranscriptionWordSchema()).nullish()
|
|
1007
|
+
}).nullish()
|
|
1008
|
+
})
|
|
1009
|
+
).nullish()
|
|
1010
|
+
}).nullish()
|
|
1011
|
+
})
|
|
1012
|
+
).nullish(),
|
|
1013
|
+
usageMetadata: import_v48.z.record(import_v48.z.string(), import_v48.z.unknown()).nullish()
|
|
970
1014
|
})
|
|
971
|
-
)
|
|
972
|
-
|
|
973
|
-
});
|
|
1015
|
+
)
|
|
1016
|
+
);
|
|
974
1017
|
|
|
975
1018
|
// src/google-vertex-video-model.ts
|
|
976
1019
|
var import_provider3 = require("@ai-sdk/provider");
|
|
977
|
-
var
|
|
1020
|
+
var import_provider_utils9 = require("@ai-sdk/provider-utils");
|
|
978
1021
|
var import_v49 = require("zod/v4");
|
|
979
1022
|
function getFirstFrameImage(options) {
|
|
980
1023
|
var _a, _b;
|
|
@@ -1009,7 +1052,7 @@ function convertFileToVertexImage(file, warnings) {
|
|
|
1009
1052
|
});
|
|
1010
1053
|
return void 0;
|
|
1011
1054
|
}
|
|
1012
|
-
const base64Data = typeof file.data === "string" ? file.data : (0,
|
|
1055
|
+
const base64Data = typeof file.data === "string" ? file.data : (0, import_provider_utils9.convertUint8ArrayToBase64)(file.data);
|
|
1013
1056
|
return {
|
|
1014
1057
|
bytesBase64Encoded: base64Data,
|
|
1015
1058
|
mimeType: file.mediaType || "image/png"
|
|
@@ -1035,7 +1078,7 @@ var GoogleVertexVideoModel = class {
|
|
|
1035
1078
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
1036
1079
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
1037
1080
|
const warnings = [];
|
|
1038
|
-
const vertexOptions = await (0,
|
|
1081
|
+
const vertexOptions = await (0, import_provider_utils9.parseProviderOptions)({
|
|
1039
1082
|
provider: "vertex",
|
|
1040
1083
|
providerOptions: options.providerOptions,
|
|
1041
1084
|
schema: googleVertexVideoModelOptionsSchema
|
|
@@ -1117,17 +1160,17 @@ var GoogleVertexVideoModel = class {
|
|
|
1117
1160
|
}
|
|
1118
1161
|
}
|
|
1119
1162
|
}
|
|
1120
|
-
const { value: operation } = await (0,
|
|
1163
|
+
const { value: operation } = await (0, import_provider_utils9.postJsonToApi)({
|
|
1121
1164
|
url: `${this.config.baseURL}/models/${this.modelId}:predictLongRunning`,
|
|
1122
|
-
headers: (0,
|
|
1123
|
-
await (0,
|
|
1165
|
+
headers: (0, import_provider_utils9.combineHeaders)(
|
|
1166
|
+
await (0, import_provider_utils9.resolve)(this.config.headers),
|
|
1124
1167
|
options.headers
|
|
1125
1168
|
),
|
|
1126
1169
|
body: {
|
|
1127
1170
|
instances,
|
|
1128
1171
|
parameters
|
|
1129
1172
|
},
|
|
1130
|
-
successfulResponseHandler: (0,
|
|
1173
|
+
successfulResponseHandler: (0, import_provider_utils9.createJsonResponseHandler)(
|
|
1131
1174
|
vertexOperationSchema
|
|
1132
1175
|
),
|
|
1133
1176
|
failedResponseHandler: googleVertexFailedResponseHandler,
|
|
@@ -1153,23 +1196,23 @@ var GoogleVertexVideoModel = class {
|
|
|
1153
1196
|
message: `Video generation timed out after ${pollTimeoutMs}ms`
|
|
1154
1197
|
});
|
|
1155
1198
|
}
|
|
1156
|
-
await (0,
|
|
1199
|
+
await (0, import_provider_utils9.delay)(pollIntervalMs);
|
|
1157
1200
|
if ((_g = options.abortSignal) == null ? void 0 : _g.aborted) {
|
|
1158
1201
|
throw new import_provider3.AISDKError({
|
|
1159
1202
|
name: "VERTEX_VIDEO_GENERATION_ABORTED",
|
|
1160
1203
|
message: "Video generation request was aborted"
|
|
1161
1204
|
});
|
|
1162
1205
|
}
|
|
1163
|
-
const { value: statusOperation, responseHeaders: pollHeaders } = await (0,
|
|
1206
|
+
const { value: statusOperation, responseHeaders: pollHeaders } = await (0, import_provider_utils9.postJsonToApi)({
|
|
1164
1207
|
url: `${this.config.baseURL}/models/${this.modelId}:fetchPredictOperation`,
|
|
1165
|
-
headers: (0,
|
|
1166
|
-
await (0,
|
|
1208
|
+
headers: (0, import_provider_utils9.combineHeaders)(
|
|
1209
|
+
await (0, import_provider_utils9.resolve)(this.config.headers),
|
|
1167
1210
|
options.headers
|
|
1168
1211
|
),
|
|
1169
1212
|
body: {
|
|
1170
1213
|
operationName
|
|
1171
1214
|
},
|
|
1172
|
-
successfulResponseHandler: (0,
|
|
1215
|
+
successfulResponseHandler: (0, import_provider_utils9.createJsonResponseHandler)(
|
|
1173
1216
|
vertexOperationSchema
|
|
1174
1217
|
),
|
|
1175
1218
|
failedResponseHandler: googleVertexFailedResponseHandler,
|
|
@@ -1238,27 +1281,31 @@ var GoogleVertexVideoModel = class {
|
|
|
1238
1281
|
};
|
|
1239
1282
|
}
|
|
1240
1283
|
};
|
|
1241
|
-
var vertexOperationSchema =
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
import_v49.z.object({
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1284
|
+
var vertexOperationSchema = (0, import_provider_utils9.lazySchema)(
|
|
1285
|
+
() => (0, import_provider_utils9.zodSchema)(
|
|
1286
|
+
import_v49.z.object({
|
|
1287
|
+
name: import_v49.z.string().nullish(),
|
|
1288
|
+
done: import_v49.z.boolean().nullish(),
|
|
1289
|
+
error: import_v49.z.object({
|
|
1290
|
+
code: import_v49.z.number().nullish(),
|
|
1291
|
+
message: import_v49.z.string(),
|
|
1292
|
+
status: import_v49.z.string().nullish()
|
|
1293
|
+
}).nullish(),
|
|
1294
|
+
response: import_v49.z.object({
|
|
1295
|
+
videos: import_v49.z.array(
|
|
1296
|
+
import_v49.z.object({
|
|
1297
|
+
bytesBase64Encoded: import_v49.z.string().nullish(),
|
|
1298
|
+
gcsUri: import_v49.z.string().nullish(),
|
|
1299
|
+
mimeType: import_v49.z.string().nullish()
|
|
1300
|
+
})
|
|
1301
|
+
).nullish(),
|
|
1302
|
+
raiMediaFilteredCount: import_v49.z.number().nullish()
|
|
1303
|
+
}).nullish()
|
|
1304
|
+
})
|
|
1305
|
+
)
|
|
1306
|
+
);
|
|
1307
|
+
var googleVertexVideoModelOptionsSchema = (0, import_provider_utils9.lazySchema)(
|
|
1308
|
+
() => (0, import_provider_utils9.zodSchema)(
|
|
1262
1309
|
import_v49.z.object({
|
|
1263
1310
|
pollIntervalMs: import_v49.z.number().positive().nullish(),
|
|
1264
1311
|
pollTimeoutMs: import_v49.z.number().positive().nullish(),
|
|
@@ -1283,7 +1330,7 @@ function createExpressModeFetch(apiKey, customFetch) {
|
|
|
1283
1330
|
const modifiedInit = {
|
|
1284
1331
|
...init,
|
|
1285
1332
|
headers: {
|
|
1286
|
-
...(init == null ? void 0 : init.headers) ? (0,
|
|
1333
|
+
...(init == null ? void 0 : init.headers) ? (0, import_provider_utils10.normalizeHeaders)(init.headers) : {},
|
|
1287
1334
|
"x-goog-api-key": apiKey
|
|
1288
1335
|
}
|
|
1289
1336
|
};
|
|
@@ -1291,17 +1338,17 @@ function createExpressModeFetch(apiKey, customFetch) {
|
|
|
1291
1338
|
};
|
|
1292
1339
|
}
|
|
1293
1340
|
function createVertex(options = {}) {
|
|
1294
|
-
const apiKey = (0,
|
|
1341
|
+
const apiKey = (0, import_provider_utils10.loadOptionalSetting)({
|
|
1295
1342
|
settingValue: options.apiKey,
|
|
1296
1343
|
environmentVariableName: "GOOGLE_VERTEX_API_KEY"
|
|
1297
1344
|
});
|
|
1298
|
-
const loadVertexProject = () => (0,
|
|
1345
|
+
const loadVertexProject = () => (0, import_provider_utils10.loadSetting)({
|
|
1299
1346
|
settingValue: options.project,
|
|
1300
1347
|
settingName: "project",
|
|
1301
1348
|
environmentVariableName: "GOOGLE_VERTEX_PROJECT",
|
|
1302
1349
|
description: "Google Vertex project"
|
|
1303
1350
|
});
|
|
1304
|
-
const loadVertexLocation = () => (0,
|
|
1351
|
+
const loadVertexLocation = () => (0, import_provider_utils10.loadSetting)({
|
|
1305
1352
|
settingValue: options.location,
|
|
1306
1353
|
settingName: "location",
|
|
1307
1354
|
environmentVariableName: "GOOGLE_VERTEX_LOCATION",
|
|
@@ -1310,7 +1357,7 @@ function createVertex(options = {}) {
|
|
|
1310
1357
|
const loadBaseURL = ({ endpoint = false } = {}) => {
|
|
1311
1358
|
var _a, _b;
|
|
1312
1359
|
if (apiKey) {
|
|
1313
|
-
return (_a = (0,
|
|
1360
|
+
return (_a = (0, import_provider_utils10.withoutTrailingSlash)(options.baseURL)) != null ? _a : EXPRESS_MODE_BASE_URL;
|
|
1314
1361
|
}
|
|
1315
1362
|
const region = loadVertexLocation();
|
|
1316
1363
|
const project = loadVertexProject();
|
|
@@ -1323,13 +1370,13 @@ function createVertex(options = {}) {
|
|
|
1323
1370
|
return `${region}-aiplatform.googleapis.com`;
|
|
1324
1371
|
}
|
|
1325
1372
|
};
|
|
1326
|
-
return (_b = (0,
|
|
1373
|
+
return (_b = (0, import_provider_utils10.withoutTrailingSlash)(options.baseURL)) != null ? _b : `https://${getHost()}/v1beta1/projects/${project}/locations/${region}${endpoint ? "" : "/publishers/google"}`;
|
|
1327
1374
|
};
|
|
1328
1375
|
const createConfig = (name, { endpoint = false } = {}) => {
|
|
1329
1376
|
const getHeaders = async () => {
|
|
1330
1377
|
var _a;
|
|
1331
|
-
const originalHeaders = await (0,
|
|
1332
|
-
return (0,
|
|
1378
|
+
const originalHeaders = await (0, import_provider_utils10.resolve)((_a = options.headers) != null ? _a : {});
|
|
1379
|
+
return (0, import_provider_utils10.withUserAgentSuffix)(
|
|
1333
1380
|
originalHeaders,
|
|
1334
1381
|
`ai-sdk/google-vertex/${VERSION}`
|
|
1335
1382
|
);
|
|
@@ -1345,7 +1392,7 @@ function createVertex(options = {}) {
|
|
|
1345
1392
|
var _a;
|
|
1346
1393
|
return new import_internal3.GoogleGenerativeAILanguageModel(modelId, {
|
|
1347
1394
|
...createConfig("chat"),
|
|
1348
|
-
generateId: (_a = options.generateId) != null ? _a :
|
|
1395
|
+
generateId: (_a = options.generateId) != null ? _a : import_provider_utils10.generateId,
|
|
1349
1396
|
supportedUrls: () => ({
|
|
1350
1397
|
"*": [
|
|
1351
1398
|
// HTTP URLs:
|
|
@@ -1371,7 +1418,7 @@ function createVertex(options = {}) {
|
|
|
1371
1418
|
// endpoint-style base URL without the `/publishers/google` suffix that
|
|
1372
1419
|
// the base-model paths carry.
|
|
1373
1420
|
...createConfig("interactions", { endpoint: true }),
|
|
1374
|
-
generateId: (_a = options.generateId) != null ? _a :
|
|
1421
|
+
generateId: (_a = options.generateId) != null ? _a : import_provider_utils10.generateId
|
|
1375
1422
|
}
|
|
1376
1423
|
);
|
|
1377
1424
|
};
|
|
@@ -1380,14 +1427,14 @@ function createVertex(options = {}) {
|
|
|
1380
1427
|
var _a;
|
|
1381
1428
|
return new GoogleVertexImageModel(modelId, {
|
|
1382
1429
|
...createConfig("image"),
|
|
1383
|
-
generateId: (_a = options.generateId) != null ? _a :
|
|
1430
|
+
generateId: (_a = options.generateId) != null ? _a : import_provider_utils10.generateId
|
|
1384
1431
|
});
|
|
1385
1432
|
};
|
|
1386
1433
|
const createVideoModel = (modelId) => {
|
|
1387
1434
|
var _a;
|
|
1388
1435
|
return new GoogleVertexVideoModel(modelId, {
|
|
1389
1436
|
...createConfig("video"),
|
|
1390
|
-
generateId: (_a = options.generateId) != null ? _a :
|
|
1437
|
+
generateId: (_a = options.generateId) != null ? _a : import_provider_utils10.generateId
|
|
1391
1438
|
});
|
|
1392
1439
|
};
|
|
1393
1440
|
const createTranscriptionModel = (modelId) => {
|
|
@@ -1437,23 +1484,23 @@ function createVertex(options = {}) {
|
|
|
1437
1484
|
}
|
|
1438
1485
|
|
|
1439
1486
|
// src/edge/google-vertex-auth-edge.ts
|
|
1440
|
-
var
|
|
1487
|
+
var import_provider_utils11 = require("@ai-sdk/provider-utils");
|
|
1441
1488
|
var loadCredentials = async () => {
|
|
1442
1489
|
try {
|
|
1443
1490
|
return {
|
|
1444
|
-
clientEmail: (0,
|
|
1491
|
+
clientEmail: (0, import_provider_utils11.loadSetting)({
|
|
1445
1492
|
settingValue: void 0,
|
|
1446
1493
|
settingName: "clientEmail",
|
|
1447
1494
|
environmentVariableName: "GOOGLE_CLIENT_EMAIL",
|
|
1448
1495
|
description: "Google client email"
|
|
1449
1496
|
}),
|
|
1450
|
-
privateKey: (0,
|
|
1497
|
+
privateKey: (0, import_provider_utils11.loadSetting)({
|
|
1451
1498
|
settingValue: void 0,
|
|
1452
1499
|
settingName: "privateKey",
|
|
1453
1500
|
environmentVariableName: "GOOGLE_PRIVATE_KEY",
|
|
1454
1501
|
description: "Google private key"
|
|
1455
1502
|
}),
|
|
1456
|
-
privateKeyId: (0,
|
|
1503
|
+
privateKeyId: (0, import_provider_utils11.loadOptionalSetting)({
|
|
1457
1504
|
settingValue: void 0,
|
|
1458
1505
|
environmentVariableName: "GOOGLE_PRIVATE_KEY_ID"
|
|
1459
1506
|
})
|
|
@@ -1521,10 +1568,10 @@ async function generateAuthToken(credentials) {
|
|
|
1521
1568
|
const jwt = await buildJwt(creds);
|
|
1522
1569
|
const response = await fetch("https://oauth2.googleapis.com/token", {
|
|
1523
1570
|
method: "POST",
|
|
1524
|
-
headers: (0,
|
|
1571
|
+
headers: (0, import_provider_utils11.withUserAgentSuffix)(
|
|
1525
1572
|
{ "Content-Type": "application/x-www-form-urlencoded" },
|
|
1526
1573
|
`ai-sdk/google-vertex/${VERSION}`,
|
|
1527
|
-
(0,
|
|
1574
|
+
(0, import_provider_utils11.getRuntimeEnvironmentUserAgent)()
|
|
1528
1575
|
),
|
|
1529
1576
|
body: new URLSearchParams({
|
|
1530
1577
|
grant_type: "urn:ietf:params:oauth:grant-type:jwt-bearer",
|
|
@@ -1540,7 +1587,7 @@ async function generateAuthToken(credentials) {
|
|
|
1540
1587
|
|
|
1541
1588
|
// src/edge/google-vertex-provider-edge.ts
|
|
1542
1589
|
function createVertex2(options = {}) {
|
|
1543
|
-
const apiKey = (0,
|
|
1590
|
+
const apiKey = (0, import_provider_utils12.loadOptionalSetting)({
|
|
1544
1591
|
settingValue: options.apiKey,
|
|
1545
1592
|
environmentVariableName: "GOOGLE_VERTEX_API_KEY"
|
|
1546
1593
|
});
|
|
@@ -1553,7 +1600,7 @@ function createVertex2(options = {}) {
|
|
|
1553
1600
|
Authorization: `Bearer ${await generateAuthToken(
|
|
1554
1601
|
options.googleCredentials
|
|
1555
1602
|
)}`,
|
|
1556
|
-
...await (0,
|
|
1603
|
+
...await (0, import_provider_utils12.resolve)(options.headers)
|
|
1557
1604
|
})
|
|
1558
1605
|
});
|
|
1559
1606
|
}
|