@ai-sdk/google-vertex 4.0.189 → 4.0.191
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 +19 -0
- package/dist/anthropic/edge/index.js +1 -1
- package/dist/anthropic/edge/index.mjs +1 -1
- package/dist/edge/index.js +280 -68
- package/dist/edge/index.js.map +1 -1
- package/dist/edge/index.mjs +266 -45
- package/dist/edge/index.mjs.map +1 -1
- package/dist/index.d.mts +47 -4
- package/dist/index.d.ts +47 -4
- package/dist/index.js +380 -166
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +377 -155
- 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 +51 -0
- package/src/gemini-transcription/google-vertex-gemini-transcription-model.ts +253 -0
- package/src/google-vertex-provider.ts +14 -0
- package/src/index.ts +5 -0
package/dist/index.js
CHANGED
|
@@ -20,14 +20,236 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
GoogleVertexGeminiTranscriptionModel: () => GoogleVertexGeminiTranscriptionModel,
|
|
23
24
|
VERSION: () => VERSION,
|
|
24
25
|
createVertex: () => createVertex2,
|
|
25
26
|
vertex: () => vertex
|
|
26
27
|
});
|
|
27
28
|
module.exports = __toCommonJS(index_exports);
|
|
28
29
|
|
|
30
|
+
// src/gemini-transcription/google-vertex-gemini-transcription-model.ts
|
|
31
|
+
var import_provider = require("@ai-sdk/provider");
|
|
32
|
+
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
33
|
+
var import_v43 = require("zod/v4");
|
|
34
|
+
|
|
35
|
+
// src/google-vertex-error.ts
|
|
36
|
+
var import_provider_utils = require("@ai-sdk/provider-utils");
|
|
37
|
+
var import_v4 = require("zod/v4");
|
|
38
|
+
var googleVertexErrorDataSchema = import_v4.z.object({
|
|
39
|
+
error: import_v4.z.object({
|
|
40
|
+
code: import_v4.z.number().nullable(),
|
|
41
|
+
message: import_v4.z.string(),
|
|
42
|
+
status: import_v4.z.string()
|
|
43
|
+
})
|
|
44
|
+
});
|
|
45
|
+
var googleVertexFailedResponseHandler = (0, import_provider_utils.createJsonErrorResponseHandler)(
|
|
46
|
+
{
|
|
47
|
+
errorSchema: googleVertexErrorDataSchema,
|
|
48
|
+
errorToMessage: (data) => data.error.message
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
// src/gemini-transcription/google-vertex-gemini-transcription-model-options.ts
|
|
53
|
+
var import_v42 = require("zod/v4");
|
|
54
|
+
var googleVertexGeminiTranscriptionModelOptions = import_v42.z.object({
|
|
55
|
+
/**
|
|
56
|
+
* BCP-47 language codes providing hints about the languages present in the
|
|
57
|
+
* audio. If omitted or empty, defaults to automatic language detection.
|
|
58
|
+
*/
|
|
59
|
+
languageCodes: import_v42.z.array(import_v42.z.string()).optional(),
|
|
60
|
+
/**
|
|
61
|
+
* Custom vocabulary phrases, which bias the speech recognition model
|
|
62
|
+
* toward recognizing specific terms.
|
|
63
|
+
*/
|
|
64
|
+
customVocabulary: import_v42.z.array(import_v42.z.string()).optional(),
|
|
65
|
+
/**
|
|
66
|
+
* Enables word-level timestamp generation.
|
|
67
|
+
*/
|
|
68
|
+
wordTimestamp: import_v42.z.boolean().optional(),
|
|
69
|
+
/**
|
|
70
|
+
* Enables speaker diarization.
|
|
71
|
+
*/
|
|
72
|
+
diarization: import_v42.z.boolean().optional(),
|
|
73
|
+
/**
|
|
74
|
+
* Transcription output formatting mode.
|
|
75
|
+
*
|
|
76
|
+
* - `VERBATIM` (default): exact literal transcript preserving filler
|
|
77
|
+
* words, repetitions, and false starts.
|
|
78
|
+
* - `SMART`: cleans up and structures the transcript in real time —
|
|
79
|
+
* disfluency removal, inline self-corrections, structured formatting
|
|
80
|
+
* (lists, numbers, dates, paragraph breaks), and grammar/casing polish.
|
|
81
|
+
*/
|
|
82
|
+
mode: import_v42.z.enum(["SMART", "VERBATIM"]).optional()
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// src/gemini-transcription/google-vertex-gemini-transcription-model.ts
|
|
86
|
+
function isLiveTranscriptionModelId(modelId) {
|
|
87
|
+
return modelId.includes("-live");
|
|
88
|
+
}
|
|
89
|
+
var GoogleVertexGeminiTranscriptionModel = class {
|
|
90
|
+
constructor(modelId, config) {
|
|
91
|
+
this.modelId = modelId;
|
|
92
|
+
this.config = config;
|
|
93
|
+
this.specificationVersion = "v3";
|
|
94
|
+
}
|
|
95
|
+
get provider() {
|
|
96
|
+
return this.config.provider;
|
|
97
|
+
}
|
|
98
|
+
async parseOptions(providerOptions) {
|
|
99
|
+
for (const provider of ["googleVertex", "vertex", "google"]) {
|
|
100
|
+
const parsed = await (0, import_provider_utils2.parseProviderOptions)({
|
|
101
|
+
provider,
|
|
102
|
+
providerOptions,
|
|
103
|
+
schema: googleVertexGeminiTranscriptionModelOptions
|
|
104
|
+
});
|
|
105
|
+
if (parsed != null) return parsed;
|
|
106
|
+
}
|
|
107
|
+
return void 0;
|
|
108
|
+
}
|
|
109
|
+
async doGenerate(options) {
|
|
110
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
111
|
+
if (isLiveTranscriptionModelId(this.modelId)) {
|
|
112
|
+
throw new import_provider.InvalidArgumentError({
|
|
113
|
+
argument: "modelId",
|
|
114
|
+
message: `Model '${this.modelId}' only supports streaming transcription, which requires AI SDK v7. Use a unary model such as 'gemini-3.5-transcribe'.`
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
118
|
+
const warnings = [];
|
|
119
|
+
const googleOptions = await this.parseOptions(options.providerOptions);
|
|
120
|
+
const audioTranscriptionConfig = buildAudioTranscriptionConfig(googleOptions);
|
|
121
|
+
const requestBody = {
|
|
122
|
+
contents: [
|
|
123
|
+
{
|
|
124
|
+
role: "user",
|
|
125
|
+
parts: [
|
|
126
|
+
{
|
|
127
|
+
inlineData: {
|
|
128
|
+
mimeType: options.mediaType,
|
|
129
|
+
data: (0, import_provider_utils2.convertToBase64)(options.audio)
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
]
|
|
133
|
+
}
|
|
134
|
+
],
|
|
135
|
+
...audioTranscriptionConfig != null ? { generationConfig: { audioTranscriptionConfig } } : {}
|
|
136
|
+
};
|
|
137
|
+
const {
|
|
138
|
+
value: response,
|
|
139
|
+
responseHeaders,
|
|
140
|
+
rawValue: rawResponse
|
|
141
|
+
} = await (0, import_provider_utils2.postJsonToApi)({
|
|
142
|
+
url: `${this.config.baseURL}/models/${this.modelId}:generateContent`,
|
|
143
|
+
headers: (0, import_provider_utils2.combineHeaders)(
|
|
144
|
+
this.config.headers ? await (0, import_provider_utils2.resolve)(this.config.headers) : void 0,
|
|
145
|
+
options.headers
|
|
146
|
+
),
|
|
147
|
+
body: requestBody,
|
|
148
|
+
failedResponseHandler: googleVertexFailedResponseHandler,
|
|
149
|
+
successfulResponseHandler: (0, import_provider_utils2.createJsonResponseHandler)(
|
|
150
|
+
googleVertexGeminiTranscriptionResponseSchema
|
|
151
|
+
),
|
|
152
|
+
abortSignal: options.abortSignal,
|
|
153
|
+
fetch: this.config.fetch
|
|
154
|
+
});
|
|
155
|
+
const parts = (_g = (_f = (_e = (_d = response.candidates) == null ? void 0 : _d[0]) == null ? void 0 : _e.content) == null ? void 0 : _f.parts) != null ? _g : [];
|
|
156
|
+
const plainText = parts.map((part) => {
|
|
157
|
+
var _a2;
|
|
158
|
+
return (_a2 = part.text) != null ? _a2 : "";
|
|
159
|
+
}).join("");
|
|
160
|
+
const transcriptionText = parts.map((part) => {
|
|
161
|
+
var _a2, _b2;
|
|
162
|
+
return (_b2 = (_a2 = part.audioTranscription) == null ? void 0 : _a2.text) != null ? _b2 : "";
|
|
163
|
+
}).join("");
|
|
164
|
+
const text = plainText !== "" ? plainText : transcriptionText;
|
|
165
|
+
let language;
|
|
166
|
+
const segments = [];
|
|
167
|
+
for (const part of parts) {
|
|
168
|
+
const transcription = part.audioTranscription;
|
|
169
|
+
if (transcription == null) continue;
|
|
170
|
+
language != null ? language : language = (_h = transcription.languageCode) != null ? _h : void 0;
|
|
171
|
+
for (const word of (_i = transcription.words) != null ? _i : []) {
|
|
172
|
+
const startSecond = parseOffsetSeconds(word.startOffset);
|
|
173
|
+
const endSecond = parseOffsetSeconds(word.endOffset);
|
|
174
|
+
if (word.word == null || startSecond == null || endSecond == null) {
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
segments.push({ text: word.word, startSecond, endSecond });
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return {
|
|
181
|
+
text,
|
|
182
|
+
segments,
|
|
183
|
+
language,
|
|
184
|
+
durationInSeconds: void 0,
|
|
185
|
+
warnings,
|
|
186
|
+
response: {
|
|
187
|
+
timestamp: currentDate,
|
|
188
|
+
modelId: this.modelId,
|
|
189
|
+
headers: responseHeaders,
|
|
190
|
+
body: rawResponse
|
|
191
|
+
},
|
|
192
|
+
...response.usageMetadata != null ? {
|
|
193
|
+
providerMetadata: {
|
|
194
|
+
google: { usageMetadata: response.usageMetadata }
|
|
195
|
+
}
|
|
196
|
+
} : {}
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
function buildAudioTranscriptionConfig(options) {
|
|
201
|
+
if (options == null) return void 0;
|
|
202
|
+
const config = {};
|
|
203
|
+
if (options.languageCodes != null) {
|
|
204
|
+
config.languageCodes = options.languageCodes;
|
|
205
|
+
}
|
|
206
|
+
if (options.customVocabulary != null) {
|
|
207
|
+
config.customVocabulary = options.customVocabulary;
|
|
208
|
+
}
|
|
209
|
+
if (options.wordTimestamp != null) {
|
|
210
|
+
config.wordTimestamp = options.wordTimestamp;
|
|
211
|
+
}
|
|
212
|
+
if (options.diarization != null) {
|
|
213
|
+
config.diarization = options.diarization;
|
|
214
|
+
}
|
|
215
|
+
if (options.mode != null) {
|
|
216
|
+
config.mode = options.mode;
|
|
217
|
+
}
|
|
218
|
+
return Object.keys(config).length > 0 ? config : void 0;
|
|
219
|
+
}
|
|
220
|
+
function parseOffsetSeconds(offset) {
|
|
221
|
+
if (offset == null) return void 0;
|
|
222
|
+
const parsed = Number.parseFloat(offset);
|
|
223
|
+
return Number.isFinite(parsed) ? parsed : void 0;
|
|
224
|
+
}
|
|
225
|
+
var googleVertexGeminiTranscriptionWordSchema = import_v43.z.object({
|
|
226
|
+
word: import_v43.z.string().nullish(),
|
|
227
|
+
startOffset: import_v43.z.string().nullish(),
|
|
228
|
+
endOffset: import_v43.z.string().nullish()
|
|
229
|
+
});
|
|
230
|
+
var googleVertexGeminiTranscriptionResponseSchema = import_v43.z.object({
|
|
231
|
+
candidates: import_v43.z.array(
|
|
232
|
+
import_v43.z.object({
|
|
233
|
+
content: import_v43.z.object({
|
|
234
|
+
parts: import_v43.z.array(
|
|
235
|
+
import_v43.z.object({
|
|
236
|
+
text: import_v43.z.string().nullish(),
|
|
237
|
+
audioTranscription: import_v43.z.object({
|
|
238
|
+
text: import_v43.z.string().nullish(),
|
|
239
|
+
languageCode: import_v43.z.string().nullish(),
|
|
240
|
+
speakerLabel: import_v43.z.string().nullish(),
|
|
241
|
+
words: import_v43.z.array(googleVertexGeminiTranscriptionWordSchema).nullish()
|
|
242
|
+
}).nullish()
|
|
243
|
+
})
|
|
244
|
+
).nullish()
|
|
245
|
+
}).nullish()
|
|
246
|
+
})
|
|
247
|
+
).nullish(),
|
|
248
|
+
usageMetadata: import_v43.z.record(import_v43.z.string(), import_v43.z.unknown()).nullish()
|
|
249
|
+
});
|
|
250
|
+
|
|
29
251
|
// src/google-vertex-provider-node.ts
|
|
30
|
-
var
|
|
252
|
+
var import_provider_utils8 = require("@ai-sdk/provider-utils");
|
|
31
253
|
|
|
32
254
|
// src/google-vertex-auth-google-auth-library.ts
|
|
33
255
|
var import_google_auth_library = require("google-auth-library");
|
|
@@ -46,41 +268,24 @@ function createAuthTokenGenerator(options) {
|
|
|
46
268
|
|
|
47
269
|
// src/google-vertex-provider.ts
|
|
48
270
|
var import_internal3 = require("@ai-sdk/google/internal");
|
|
49
|
-
var
|
|
271
|
+
var import_provider_utils7 = require("@ai-sdk/provider-utils");
|
|
50
272
|
|
|
51
273
|
// src/version.ts
|
|
52
|
-
var VERSION = true ? "4.0.
|
|
274
|
+
var VERSION = true ? "4.0.191" : "0.0.0-test";
|
|
53
275
|
|
|
54
276
|
// src/google-vertex-embedding-model.ts
|
|
55
|
-
var
|
|
56
|
-
var
|
|
57
|
-
var
|
|
58
|
-
|
|
59
|
-
// src/google-vertex-error.ts
|
|
60
|
-
var import_provider_utils = require("@ai-sdk/provider-utils");
|
|
61
|
-
var import_v4 = require("zod/v4");
|
|
62
|
-
var googleVertexErrorDataSchema = import_v4.z.object({
|
|
63
|
-
error: import_v4.z.object({
|
|
64
|
-
code: import_v4.z.number().nullable(),
|
|
65
|
-
message: import_v4.z.string(),
|
|
66
|
-
status: import_v4.z.string()
|
|
67
|
-
})
|
|
68
|
-
});
|
|
69
|
-
var googleVertexFailedResponseHandler = (0, import_provider_utils.createJsonErrorResponseHandler)(
|
|
70
|
-
{
|
|
71
|
-
errorSchema: googleVertexErrorDataSchema,
|
|
72
|
-
errorToMessage: (data) => data.error.message
|
|
73
|
-
}
|
|
74
|
-
);
|
|
277
|
+
var import_provider2 = require("@ai-sdk/provider");
|
|
278
|
+
var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
|
279
|
+
var import_v45 = require("zod/v4");
|
|
75
280
|
|
|
76
281
|
// src/google-vertex-embedding-options.ts
|
|
77
|
-
var
|
|
78
|
-
var googleVertexEmbeddingModelOptions =
|
|
282
|
+
var import_v44 = require("zod/v4");
|
|
283
|
+
var googleVertexEmbeddingModelOptions = import_v44.z.object({
|
|
79
284
|
/**
|
|
80
285
|
* Optional. Optional reduced dimension for the output embedding.
|
|
81
286
|
* If set, excessive values in the output embedding are truncated from the end.
|
|
82
287
|
*/
|
|
83
|
-
outputDimensionality:
|
|
288
|
+
outputDimensionality: import_v44.z.number().optional(),
|
|
84
289
|
/**
|
|
85
290
|
* Optional. Specifies the task type for generating embeddings.
|
|
86
291
|
* Supported task types:
|
|
@@ -93,7 +298,7 @@ var googleVertexEmbeddingModelOptions = import_v42.z.object({
|
|
|
93
298
|
* - FACT_VERIFICATION: Optimized for verifying factual information.
|
|
94
299
|
* - CODE_RETRIEVAL_QUERY: Optimized for retrieving code blocks based on natural language queries.
|
|
95
300
|
*/
|
|
96
|
-
taskType:
|
|
301
|
+
taskType: import_v44.z.enum([
|
|
97
302
|
"SEMANTIC_SIMILARITY",
|
|
98
303
|
"CLASSIFICATION",
|
|
99
304
|
"CLUSTERING",
|
|
@@ -108,12 +313,12 @@ var googleVertexEmbeddingModelOptions = import_v42.z.object({
|
|
|
108
313
|
* Only valid when task_type is set to 'RETRIEVAL_DOCUMENT'.
|
|
109
314
|
* Helps the model produce better embeddings by providing additional context.
|
|
110
315
|
*/
|
|
111
|
-
title:
|
|
316
|
+
title: import_v44.z.string().optional(),
|
|
112
317
|
/**
|
|
113
318
|
* Optional. When set to true, input text will be truncated. When set to false,
|
|
114
319
|
* an error is returned if the input text is longer than the maximum length supported by the model. Defaults to true.
|
|
115
320
|
*/
|
|
116
|
-
autoTruncate:
|
|
321
|
+
autoTruncate: import_v44.z.boolean().optional()
|
|
117
322
|
});
|
|
118
323
|
|
|
119
324
|
// src/google-vertex-embedding-model.ts
|
|
@@ -139,13 +344,13 @@ var GoogleVertexEmbeddingModel = class {
|
|
|
139
344
|
providerOptions
|
|
140
345
|
}) {
|
|
141
346
|
var _a;
|
|
142
|
-
let googleOptions = await (0,
|
|
347
|
+
let googleOptions = await (0, import_provider_utils3.parseProviderOptions)({
|
|
143
348
|
provider: "vertex",
|
|
144
349
|
providerOptions,
|
|
145
350
|
schema: googleVertexEmbeddingModelOptions
|
|
146
351
|
});
|
|
147
352
|
if (googleOptions == null) {
|
|
148
|
-
googleOptions = await (0,
|
|
353
|
+
googleOptions = await (0, import_provider_utils3.parseProviderOptions)({
|
|
149
354
|
provider: "google",
|
|
150
355
|
providerOptions,
|
|
151
356
|
schema: googleVertexEmbeddingModelOptions
|
|
@@ -153,15 +358,15 @@ var GoogleVertexEmbeddingModel = class {
|
|
|
153
358
|
}
|
|
154
359
|
googleOptions = googleOptions != null ? googleOptions : {};
|
|
155
360
|
if (values.length > this.maxEmbeddingsPerCall) {
|
|
156
|
-
throw new
|
|
361
|
+
throw new import_provider2.TooManyEmbeddingValuesForCallError({
|
|
157
362
|
provider: this.provider,
|
|
158
363
|
modelId: this.modelId,
|
|
159
364
|
maxEmbeddingsPerCall: this.maxEmbeddingsPerCall,
|
|
160
365
|
values
|
|
161
366
|
});
|
|
162
367
|
}
|
|
163
|
-
const mergedHeaders = (0,
|
|
164
|
-
await (0,
|
|
368
|
+
const mergedHeaders = (0, import_provider_utils3.combineHeaders)(
|
|
369
|
+
await (0, import_provider_utils3.resolve)(this.config.headers),
|
|
165
370
|
headers
|
|
166
371
|
);
|
|
167
372
|
if (usesEmbedContentEndpoint(this.modelId)) {
|
|
@@ -169,7 +374,7 @@ var GoogleVertexEmbeddingModel = class {
|
|
|
169
374
|
responseHeaders: responseHeaders2,
|
|
170
375
|
value: response2,
|
|
171
376
|
rawValue: rawValue2
|
|
172
|
-
} = await (0,
|
|
377
|
+
} = await (0, import_provider_utils3.postJsonToApi)({
|
|
173
378
|
url: `${this.config.baseURL}/models/${this.modelId}:embedContent`,
|
|
174
379
|
headers: mergedHeaders,
|
|
175
380
|
body: {
|
|
@@ -182,7 +387,7 @@ var GoogleVertexEmbeddingModel = class {
|
|
|
182
387
|
}
|
|
183
388
|
},
|
|
184
389
|
failedResponseHandler: googleVertexFailedResponseHandler,
|
|
185
|
-
successfulResponseHandler: (0,
|
|
390
|
+
successfulResponseHandler: (0, import_provider_utils3.createJsonResponseHandler)(
|
|
186
391
|
googleVertexEmbedContentResponseSchema
|
|
187
392
|
),
|
|
188
393
|
abortSignal,
|
|
@@ -200,7 +405,7 @@ var GoogleVertexEmbeddingModel = class {
|
|
|
200
405
|
responseHeaders,
|
|
201
406
|
value: response,
|
|
202
407
|
rawValue
|
|
203
|
-
} = await (0,
|
|
408
|
+
} = await (0, import_provider_utils3.postJsonToApi)({
|
|
204
409
|
url,
|
|
205
410
|
headers: mergedHeaders,
|
|
206
411
|
body: {
|
|
@@ -215,7 +420,7 @@ var GoogleVertexEmbeddingModel = class {
|
|
|
215
420
|
}
|
|
216
421
|
},
|
|
217
422
|
failedResponseHandler: googleVertexFailedResponseHandler,
|
|
218
|
-
successfulResponseHandler: (0,
|
|
423
|
+
successfulResponseHandler: (0, import_provider_utils3.createJsonResponseHandler)(
|
|
219
424
|
googleVertexTextEmbeddingResponseSchema
|
|
220
425
|
),
|
|
221
426
|
abortSignal,
|
|
@@ -236,24 +441,24 @@ var GoogleVertexEmbeddingModel = class {
|
|
|
236
441
|
};
|
|
237
442
|
}
|
|
238
443
|
};
|
|
239
|
-
var googleVertexTextEmbeddingResponseSchema =
|
|
240
|
-
predictions:
|
|
241
|
-
|
|
242
|
-
embeddings:
|
|
243
|
-
values:
|
|
244
|
-
statistics:
|
|
245
|
-
token_count:
|
|
444
|
+
var googleVertexTextEmbeddingResponseSchema = import_v45.z.object({
|
|
445
|
+
predictions: import_v45.z.array(
|
|
446
|
+
import_v45.z.object({
|
|
447
|
+
embeddings: import_v45.z.object({
|
|
448
|
+
values: import_v45.z.array(import_v45.z.number()),
|
|
449
|
+
statistics: import_v45.z.object({
|
|
450
|
+
token_count: import_v45.z.number()
|
|
246
451
|
})
|
|
247
452
|
})
|
|
248
453
|
})
|
|
249
454
|
)
|
|
250
455
|
});
|
|
251
|
-
var googleVertexEmbedContentResponseSchema =
|
|
252
|
-
embedding:
|
|
253
|
-
values:
|
|
456
|
+
var googleVertexEmbedContentResponseSchema = import_v45.z.object({
|
|
457
|
+
embedding: import_v45.z.object({
|
|
458
|
+
values: import_v45.z.array(import_v45.z.number())
|
|
254
459
|
}),
|
|
255
|
-
usageMetadata:
|
|
256
|
-
promptTokenCount:
|
|
460
|
+
usageMetadata: import_v45.z.object({
|
|
461
|
+
promptTokenCount: import_v45.z.number().nullish()
|
|
257
462
|
}).nullish()
|
|
258
463
|
});
|
|
259
464
|
function usesEmbedContentEndpoint(modelId) {
|
|
@@ -262,8 +467,8 @@ function usesEmbedContentEndpoint(modelId) {
|
|
|
262
467
|
|
|
263
468
|
// src/google-vertex-image-model.ts
|
|
264
469
|
var import_internal = require("@ai-sdk/google/internal");
|
|
265
|
-
var
|
|
266
|
-
var
|
|
470
|
+
var import_provider_utils4 = require("@ai-sdk/provider-utils");
|
|
471
|
+
var import_v46 = require("zod/v4");
|
|
267
472
|
var GoogleVertexImageModel = class {
|
|
268
473
|
constructor(modelId, config) {
|
|
269
474
|
this.modelId = modelId;
|
|
@@ -306,7 +511,7 @@ var GoogleVertexImageModel = class {
|
|
|
306
511
|
details: "This model does not support the `size` option. Use `aspectRatio` instead."
|
|
307
512
|
});
|
|
308
513
|
}
|
|
309
|
-
const vertexImageOptions = await (0,
|
|
514
|
+
const vertexImageOptions = await (0, import_provider_utils4.parseProviderOptions)({
|
|
310
515
|
provider: "vertex",
|
|
311
516
|
providerOptions,
|
|
312
517
|
schema: googleVertexImageModelOptionsSchema
|
|
@@ -368,12 +573,12 @@ var GoogleVertexImageModel = class {
|
|
|
368
573
|
};
|
|
369
574
|
}
|
|
370
575
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
371
|
-
const { value: response, responseHeaders } = await (0,
|
|
576
|
+
const { value: response, responseHeaders } = await (0, import_provider_utils4.postJsonToApi)({
|
|
372
577
|
url: `${this.config.baseURL}/models/${this.modelId}:predict`,
|
|
373
|
-
headers: (0,
|
|
578
|
+
headers: (0, import_provider_utils4.combineHeaders)(await (0, import_provider_utils4.resolve)(this.config.headers), headers),
|
|
374
579
|
body,
|
|
375
580
|
failedResponseHandler: googleVertexFailedResponseHandler,
|
|
376
|
-
successfulResponseHandler: (0,
|
|
581
|
+
successfulResponseHandler: (0, import_provider_utils4.createJsonResponseHandler)(
|
|
377
582
|
vertexImageResponseSchema
|
|
378
583
|
),
|
|
379
584
|
abortSignal,
|
|
@@ -462,7 +667,7 @@ var GoogleVertexImageModel = class {
|
|
|
462
667
|
baseURL: this.config.baseURL,
|
|
463
668
|
headers: (_a = this.config.headers) != null ? _a : {},
|
|
464
669
|
fetch: this.config.fetch,
|
|
465
|
-
generateId: (_b = this.config.generateId) != null ? _b :
|
|
670
|
+
generateId: (_b = this.config.generateId) != null ? _b : import_provider_utils4.generateId,
|
|
466
671
|
supportedUrls: () => ({
|
|
467
672
|
"*": [/^https?:\/\/.*$/, /^gs:\/\/.*$/]
|
|
468
673
|
})
|
|
@@ -486,7 +691,7 @@ var GoogleVertexImageModel = class {
|
|
|
486
691
|
const images = [];
|
|
487
692
|
for (const part of result.content) {
|
|
488
693
|
if (part.type === "file" && part.mediaType.startsWith("image/")) {
|
|
489
|
-
images.push((0,
|
|
694
|
+
images.push((0, import_provider_utils4.convertToBase64)(part.data));
|
|
490
695
|
}
|
|
491
696
|
}
|
|
492
697
|
return {
|
|
@@ -513,41 +718,41 @@ var GoogleVertexImageModel = class {
|
|
|
513
718
|
function isGeminiModel(modelId) {
|
|
514
719
|
return modelId.startsWith("gemini-");
|
|
515
720
|
}
|
|
516
|
-
var vertexImageResponseSchema =
|
|
517
|
-
predictions:
|
|
518
|
-
|
|
519
|
-
bytesBase64Encoded:
|
|
520
|
-
mimeType:
|
|
521
|
-
prompt:
|
|
721
|
+
var vertexImageResponseSchema = import_v46.z.object({
|
|
722
|
+
predictions: import_v46.z.array(
|
|
723
|
+
import_v46.z.object({
|
|
724
|
+
bytesBase64Encoded: import_v46.z.string(),
|
|
725
|
+
mimeType: import_v46.z.string(),
|
|
726
|
+
prompt: import_v46.z.string().nullish()
|
|
522
727
|
})
|
|
523
728
|
).nullish()
|
|
524
729
|
});
|
|
525
|
-
var googleVertexImageModelOptionsSchema =
|
|
526
|
-
negativePrompt:
|
|
527
|
-
personGeneration:
|
|
528
|
-
safetySetting:
|
|
730
|
+
var googleVertexImageModelOptionsSchema = import_v46.z.object({
|
|
731
|
+
negativePrompt: import_v46.z.string().nullish(),
|
|
732
|
+
personGeneration: import_v46.z.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
|
|
733
|
+
safetySetting: import_v46.z.enum([
|
|
529
734
|
"block_low_and_above",
|
|
530
735
|
"block_medium_and_above",
|
|
531
736
|
"block_only_high",
|
|
532
737
|
"block_none"
|
|
533
738
|
]).nullish(),
|
|
534
|
-
addWatermark:
|
|
535
|
-
storageUri:
|
|
536
|
-
sampleImageSize:
|
|
739
|
+
addWatermark: import_v46.z.boolean().nullish(),
|
|
740
|
+
storageUri: import_v46.z.string().nullish(),
|
|
741
|
+
sampleImageSize: import_v46.z.enum(["1K", "2K"]).nullish(),
|
|
537
742
|
/**
|
|
538
743
|
* Configuration for image editing operations
|
|
539
744
|
*/
|
|
540
|
-
edit:
|
|
745
|
+
edit: import_v46.z.object({
|
|
541
746
|
/**
|
|
542
747
|
* An integer that represents the number of sampling steps.
|
|
543
748
|
* A higher value offers better image quality, a lower value offers better latency.
|
|
544
749
|
* Try 35 steps to start. If the quality doesn't meet your requirements,
|
|
545
750
|
* increase the value towards an upper limit of 75.
|
|
546
751
|
*/
|
|
547
|
-
baseSteps:
|
|
752
|
+
baseSteps: import_v46.z.number().nullish(),
|
|
548
753
|
// Edit mode options
|
|
549
754
|
// https://cloud.google.com/vertex-ai/generative-ai/docs/image/edit-insert-objects
|
|
550
|
-
mode:
|
|
755
|
+
mode: import_v46.z.enum([
|
|
551
756
|
"EDIT_MODE_INPAINT_INSERTION",
|
|
552
757
|
"EDIT_MODE_INPAINT_REMOVAL",
|
|
553
758
|
"EDIT_MODE_OUTPAINT",
|
|
@@ -563,7 +768,7 @@ var googleVertexImageModelOptionsSchema = import_v44.z.object({
|
|
|
563
768
|
* - `MASK_MODE_CLOTHING_AREA` - Masks from segmenting the clothing area with open-vocab segmentation.
|
|
564
769
|
* - `MASK_MODE_PARSED_PERSON` - Masks from segmenting the person body and clothing using the person-parsing model.
|
|
565
770
|
*/
|
|
566
|
-
maskMode:
|
|
771
|
+
maskMode: import_v46.z.enum([
|
|
567
772
|
"MASK_MODE_DEFAULT",
|
|
568
773
|
"MASK_MODE_USER_PROVIDED",
|
|
569
774
|
"MASK_MODE_DETECTION_BOX",
|
|
@@ -575,7 +780,7 @@ var googleVertexImageModelOptionsSchema = import_v44.z.object({
|
|
|
575
780
|
* percentage of the image width to grow the mask by. Using dilation helps
|
|
576
781
|
* compensate for imprecise masks. We recommend a value of 0.01.
|
|
577
782
|
*/
|
|
578
|
-
maskDilation:
|
|
783
|
+
maskDilation: import_v46.z.number().nullish()
|
|
579
784
|
}).nullish()
|
|
580
785
|
});
|
|
581
786
|
function getBase64Data(file) {
|
|
@@ -587,7 +792,7 @@ function getBase64Data(file) {
|
|
|
587
792
|
if (typeof file.data === "string") {
|
|
588
793
|
return file.data;
|
|
589
794
|
}
|
|
590
|
-
return (0,
|
|
795
|
+
return (0, import_provider_utils4.convertUint8ArrayToBase64)(file.data);
|
|
591
796
|
}
|
|
592
797
|
|
|
593
798
|
// src/google-vertex-tools.ts
|
|
@@ -603,22 +808,22 @@ var googleVertexTools = {
|
|
|
603
808
|
};
|
|
604
809
|
|
|
605
810
|
// src/google-vertex-transcription-model.ts
|
|
606
|
-
var
|
|
607
|
-
var
|
|
811
|
+
var import_provider_utils5 = require("@ai-sdk/provider-utils");
|
|
812
|
+
var import_v48 = require("zod/v4");
|
|
608
813
|
|
|
609
814
|
// src/google-vertex-transcription-model-options.ts
|
|
610
|
-
var
|
|
611
|
-
var googleVertexTranscriptionProviderOptionsSchema =
|
|
815
|
+
var import_v47 = require("zod/v4");
|
|
816
|
+
var googleVertexTranscriptionProviderOptionsSchema = import_v47.z.object({
|
|
612
817
|
/**
|
|
613
818
|
* BCP-47 language codes to recognize (e.g. `['en-US']`), or `['auto']` to let
|
|
614
819
|
* Chirp auto-detect the spoken language. Defaults to `['auto']`. For
|
|
615
820
|
* `telephony`, pass a supported explicit language code.
|
|
616
821
|
*/
|
|
617
|
-
languageCodes:
|
|
822
|
+
languageCodes: import_v47.z.array(import_v47.z.string()).optional(),
|
|
618
823
|
/**
|
|
619
824
|
* Whether to add punctuation to the transcript. Defaults to `true`.
|
|
620
825
|
*/
|
|
621
|
-
enableAutomaticPunctuation:
|
|
826
|
+
enableAutomaticPunctuation: import_v47.z.boolean().optional(),
|
|
622
827
|
/**
|
|
623
828
|
* Whether to include word-level timestamps. Defaults to `true` so the
|
|
624
829
|
* transcription result can include segments.
|
|
@@ -626,7 +831,7 @@ var googleVertexTranscriptionProviderOptionsSchema = import_v45.z.object({
|
|
|
626
831
|
* Enabling word-level timestamps can reduce transcription quality and speed
|
|
627
832
|
* for Chirp models.
|
|
628
833
|
*/
|
|
629
|
-
enableWordTimeOffsets:
|
|
834
|
+
enableWordTimeOffsets: import_v47.z.boolean().optional(),
|
|
630
835
|
/**
|
|
631
836
|
* The Cloud Speech-to-Text region for the request (e.g. `'us'`, `'eu'`,
|
|
632
837
|
* `'us-central1'`). Defaults to the provider `location`.
|
|
@@ -635,7 +840,7 @@ var googleVertexTranscriptionProviderOptionsSchema = import_v45.z.object({
|
|
|
635
840
|
* available in specific Speech-to-Text regions and is not available in the
|
|
636
841
|
* `global` location.
|
|
637
842
|
*/
|
|
638
|
-
region:
|
|
843
|
+
region: import_v47.z.string().optional()
|
|
639
844
|
});
|
|
640
845
|
|
|
641
846
|
// src/google-vertex-transcription-model.ts
|
|
@@ -672,7 +877,7 @@ var GoogleVertexTranscriptionModel = class {
|
|
|
672
877
|
const warnings = [];
|
|
673
878
|
let googleOptions;
|
|
674
879
|
for (const provider of ["googleVertex", "vertex", "google"]) {
|
|
675
|
-
googleOptions = await (0,
|
|
880
|
+
googleOptions = await (0, import_provider_utils5.parseProviderOptions)({
|
|
676
881
|
provider,
|
|
677
882
|
providerOptions: options.providerOptions,
|
|
678
883
|
schema: googleVertexTranscriptionProviderOptionsSchema
|
|
@@ -683,7 +888,7 @@ var GoogleVertexTranscriptionModel = class {
|
|
|
683
888
|
}
|
|
684
889
|
const region = (_d = googleOptions == null ? void 0 : googleOptions.region) != null ? _d : this.config.location;
|
|
685
890
|
const languageCodes = (_e = googleOptions == null ? void 0 : googleOptions.languageCodes) != null ? _e : ["auto"];
|
|
686
|
-
const content = typeof options.audio === "string" ? options.audio : (0,
|
|
891
|
+
const content = typeof options.audio === "string" ? options.audio : (0, import_provider_utils5.convertUint8ArrayToBase64)(options.audio);
|
|
687
892
|
const requestBody = {
|
|
688
893
|
config: {
|
|
689
894
|
model: this.modelId,
|
|
@@ -704,15 +909,15 @@ var GoogleVertexTranscriptionModel = class {
|
|
|
704
909
|
value: response,
|
|
705
910
|
responseHeaders,
|
|
706
911
|
rawValue: rawResponse
|
|
707
|
-
} = await (0,
|
|
912
|
+
} = await (0, import_provider_utils5.postJsonToApi)({
|
|
708
913
|
url,
|
|
709
|
-
headers: (0,
|
|
710
|
-
this.config.headers ? await (0,
|
|
914
|
+
headers: (0, import_provider_utils5.combineHeaders)(
|
|
915
|
+
this.config.headers ? await (0, import_provider_utils5.resolve)(this.config.headers) : void 0,
|
|
711
916
|
options.headers
|
|
712
917
|
),
|
|
713
918
|
body: requestBody,
|
|
714
919
|
failedResponseHandler: googleVertexFailedResponseHandler,
|
|
715
|
-
successfulResponseHandler: (0,
|
|
920
|
+
successfulResponseHandler: (0, import_provider_utils5.createJsonResponseHandler)(
|
|
716
921
|
googleVertexTranscriptionResponseSchema
|
|
717
922
|
),
|
|
718
923
|
abortSignal: options.abortSignal,
|
|
@@ -751,33 +956,33 @@ var GoogleVertexTranscriptionModel = class {
|
|
|
751
956
|
};
|
|
752
957
|
}
|
|
753
958
|
};
|
|
754
|
-
var googleVertexTranscriptionResponseSchema =
|
|
755
|
-
results:
|
|
756
|
-
|
|
757
|
-
alternatives:
|
|
758
|
-
|
|
759
|
-
transcript:
|
|
760
|
-
words:
|
|
761
|
-
|
|
762
|
-
word:
|
|
763
|
-
startOffset:
|
|
764
|
-
endOffset:
|
|
959
|
+
var googleVertexTranscriptionResponseSchema = import_v48.z.object({
|
|
960
|
+
results: import_v48.z.array(
|
|
961
|
+
import_v48.z.object({
|
|
962
|
+
alternatives: import_v48.z.array(
|
|
963
|
+
import_v48.z.object({
|
|
964
|
+
transcript: import_v48.z.string().nullish(),
|
|
965
|
+
words: import_v48.z.array(
|
|
966
|
+
import_v48.z.object({
|
|
967
|
+
word: import_v48.z.string().nullish(),
|
|
968
|
+
startOffset: import_v48.z.string().nullish(),
|
|
969
|
+
endOffset: import_v48.z.string().nullish()
|
|
765
970
|
})
|
|
766
971
|
).nullish()
|
|
767
972
|
})
|
|
768
973
|
).nullish(),
|
|
769
|
-
languageCode:
|
|
974
|
+
languageCode: import_v48.z.string().nullish()
|
|
770
975
|
})
|
|
771
976
|
).nullish(),
|
|
772
|
-
metadata:
|
|
773
|
-
totalBilledDuration:
|
|
977
|
+
metadata: import_v48.z.object({
|
|
978
|
+
totalBilledDuration: import_v48.z.string().nullish()
|
|
774
979
|
}).nullish()
|
|
775
980
|
});
|
|
776
981
|
|
|
777
982
|
// src/google-vertex-video-model.ts
|
|
778
|
-
var
|
|
779
|
-
var
|
|
780
|
-
var
|
|
983
|
+
var import_provider3 = require("@ai-sdk/provider");
|
|
984
|
+
var import_provider_utils6 = require("@ai-sdk/provider-utils");
|
|
985
|
+
var import_v49 = require("zod/v4");
|
|
781
986
|
function getFirstFrameImage(options) {
|
|
782
987
|
var _a, _b;
|
|
783
988
|
return (_b = (_a = options.frameImages) == null ? void 0 : _a.find((frame) => frame.frameType === "first_frame")) == null ? void 0 : _b.image;
|
|
@@ -811,7 +1016,7 @@ function convertFileToVertexImage(file, warnings) {
|
|
|
811
1016
|
});
|
|
812
1017
|
return void 0;
|
|
813
1018
|
}
|
|
814
|
-
const base64Data = typeof file.data === "string" ? file.data : (0,
|
|
1019
|
+
const base64Data = typeof file.data === "string" ? file.data : (0, import_provider_utils6.convertUint8ArrayToBase64)(file.data);
|
|
815
1020
|
return {
|
|
816
1021
|
bytesBase64Encoded: base64Data,
|
|
817
1022
|
mimeType: file.mediaType || "image/png"
|
|
@@ -837,7 +1042,7 @@ var GoogleVertexVideoModel = class {
|
|
|
837
1042
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
838
1043
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
839
1044
|
const warnings = [];
|
|
840
|
-
const vertexOptions = await (0,
|
|
1045
|
+
const vertexOptions = await (0, import_provider_utils6.parseProviderOptions)({
|
|
841
1046
|
provider: "vertex",
|
|
842
1047
|
providerOptions: options.providerOptions,
|
|
843
1048
|
schema: googleVertexVideoModelOptionsSchema
|
|
@@ -919,17 +1124,17 @@ var GoogleVertexVideoModel = class {
|
|
|
919
1124
|
}
|
|
920
1125
|
}
|
|
921
1126
|
}
|
|
922
|
-
const { value: operation } = await (0,
|
|
1127
|
+
const { value: operation } = await (0, import_provider_utils6.postJsonToApi)({
|
|
923
1128
|
url: `${this.config.baseURL}/models/${this.modelId}:predictLongRunning`,
|
|
924
|
-
headers: (0,
|
|
925
|
-
await (0,
|
|
1129
|
+
headers: (0, import_provider_utils6.combineHeaders)(
|
|
1130
|
+
await (0, import_provider_utils6.resolve)(this.config.headers),
|
|
926
1131
|
options.headers
|
|
927
1132
|
),
|
|
928
1133
|
body: {
|
|
929
1134
|
instances,
|
|
930
1135
|
parameters
|
|
931
1136
|
},
|
|
932
|
-
successfulResponseHandler: (0,
|
|
1137
|
+
successfulResponseHandler: (0, import_provider_utils6.createJsonResponseHandler)(
|
|
933
1138
|
vertexOperationSchema
|
|
934
1139
|
),
|
|
935
1140
|
failedResponseHandler: googleVertexFailedResponseHandler,
|
|
@@ -938,7 +1143,7 @@ var GoogleVertexVideoModel = class {
|
|
|
938
1143
|
});
|
|
939
1144
|
const operationName = operation.name;
|
|
940
1145
|
if (!operationName) {
|
|
941
|
-
throw new
|
|
1146
|
+
throw new import_provider3.AISDKError({
|
|
942
1147
|
name: "VERTEX_VIDEO_GENERATION_ERROR",
|
|
943
1148
|
message: "No operation name returned from API"
|
|
944
1149
|
});
|
|
@@ -950,28 +1155,28 @@ var GoogleVertexVideoModel = class {
|
|
|
950
1155
|
let responseHeaders;
|
|
951
1156
|
while (!finalOperation.done) {
|
|
952
1157
|
if (Date.now() - startTime > pollTimeoutMs) {
|
|
953
|
-
throw new
|
|
1158
|
+
throw new import_provider3.AISDKError({
|
|
954
1159
|
name: "VERTEX_VIDEO_GENERATION_TIMEOUT",
|
|
955
1160
|
message: `Video generation timed out after ${pollTimeoutMs}ms`
|
|
956
1161
|
});
|
|
957
1162
|
}
|
|
958
|
-
await (0,
|
|
1163
|
+
await (0, import_provider_utils6.delay)(pollIntervalMs);
|
|
959
1164
|
if ((_g = options.abortSignal) == null ? void 0 : _g.aborted) {
|
|
960
|
-
throw new
|
|
1165
|
+
throw new import_provider3.AISDKError({
|
|
961
1166
|
name: "VERTEX_VIDEO_GENERATION_ABORTED",
|
|
962
1167
|
message: "Video generation request was aborted"
|
|
963
1168
|
});
|
|
964
1169
|
}
|
|
965
|
-
const { value: statusOperation, responseHeaders: pollHeaders } = await (0,
|
|
1170
|
+
const { value: statusOperation, responseHeaders: pollHeaders } = await (0, import_provider_utils6.postJsonToApi)({
|
|
966
1171
|
url: `${this.config.baseURL}/models/${this.modelId}:fetchPredictOperation`,
|
|
967
|
-
headers: (0,
|
|
968
|
-
await (0,
|
|
1172
|
+
headers: (0, import_provider_utils6.combineHeaders)(
|
|
1173
|
+
await (0, import_provider_utils6.resolve)(this.config.headers),
|
|
969
1174
|
options.headers
|
|
970
1175
|
),
|
|
971
1176
|
body: {
|
|
972
1177
|
operationName
|
|
973
1178
|
},
|
|
974
|
-
successfulResponseHandler: (0,
|
|
1179
|
+
successfulResponseHandler: (0, import_provider_utils6.createJsonResponseHandler)(
|
|
975
1180
|
vertexOperationSchema
|
|
976
1181
|
),
|
|
977
1182
|
failedResponseHandler: googleVertexFailedResponseHandler,
|
|
@@ -982,14 +1187,14 @@ var GoogleVertexVideoModel = class {
|
|
|
982
1187
|
responseHeaders = pollHeaders;
|
|
983
1188
|
}
|
|
984
1189
|
if (finalOperation.error) {
|
|
985
|
-
throw new
|
|
1190
|
+
throw new import_provider3.AISDKError({
|
|
986
1191
|
name: "VERTEX_VIDEO_GENERATION_FAILED",
|
|
987
1192
|
message: `Video generation failed: ${finalOperation.error.message}`
|
|
988
1193
|
});
|
|
989
1194
|
}
|
|
990
1195
|
const response = finalOperation.response;
|
|
991
1196
|
if (!(response == null ? void 0 : response.videos) || response.videos.length === 0) {
|
|
992
|
-
throw new
|
|
1197
|
+
throw new import_provider3.AISDKError({
|
|
993
1198
|
name: "VERTEX_VIDEO_GENERATION_ERROR",
|
|
994
1199
|
message: `No videos in response. Response: ${JSON.stringify(finalOperation)}`
|
|
995
1200
|
});
|
|
@@ -1019,7 +1224,7 @@ var GoogleVertexVideoModel = class {
|
|
|
1019
1224
|
}
|
|
1020
1225
|
}
|
|
1021
1226
|
if (videos.length === 0) {
|
|
1022
|
-
throw new
|
|
1227
|
+
throw new import_provider3.AISDKError({
|
|
1023
1228
|
name: "VERTEX_VIDEO_GENERATION_ERROR",
|
|
1024
1229
|
message: "No valid videos in response"
|
|
1025
1230
|
});
|
|
@@ -1040,38 +1245,38 @@ var GoogleVertexVideoModel = class {
|
|
|
1040
1245
|
};
|
|
1041
1246
|
}
|
|
1042
1247
|
};
|
|
1043
|
-
var vertexOperationSchema =
|
|
1044
|
-
name:
|
|
1045
|
-
done:
|
|
1046
|
-
error:
|
|
1047
|
-
code:
|
|
1048
|
-
message:
|
|
1049
|
-
status:
|
|
1248
|
+
var vertexOperationSchema = import_v49.z.object({
|
|
1249
|
+
name: import_v49.z.string().nullish(),
|
|
1250
|
+
done: import_v49.z.boolean().nullish(),
|
|
1251
|
+
error: import_v49.z.object({
|
|
1252
|
+
code: import_v49.z.number().nullish(),
|
|
1253
|
+
message: import_v49.z.string(),
|
|
1254
|
+
status: import_v49.z.string().nullish()
|
|
1050
1255
|
}).nullish(),
|
|
1051
|
-
response:
|
|
1052
|
-
videos:
|
|
1053
|
-
|
|
1054
|
-
bytesBase64Encoded:
|
|
1055
|
-
gcsUri:
|
|
1056
|
-
mimeType:
|
|
1256
|
+
response: import_v49.z.object({
|
|
1257
|
+
videos: import_v49.z.array(
|
|
1258
|
+
import_v49.z.object({
|
|
1259
|
+
bytesBase64Encoded: import_v49.z.string().nullish(),
|
|
1260
|
+
gcsUri: import_v49.z.string().nullish(),
|
|
1261
|
+
mimeType: import_v49.z.string().nullish()
|
|
1057
1262
|
})
|
|
1058
1263
|
).nullish(),
|
|
1059
|
-
raiMediaFilteredCount:
|
|
1264
|
+
raiMediaFilteredCount: import_v49.z.number().nullish()
|
|
1060
1265
|
}).nullish()
|
|
1061
1266
|
});
|
|
1062
|
-
var googleVertexVideoModelOptionsSchema = (0,
|
|
1063
|
-
() => (0,
|
|
1064
|
-
|
|
1065
|
-
pollIntervalMs:
|
|
1066
|
-
pollTimeoutMs:
|
|
1067
|
-
personGeneration:
|
|
1068
|
-
negativePrompt:
|
|
1069
|
-
generateAudio:
|
|
1070
|
-
gcsOutputDirectory:
|
|
1071
|
-
referenceImages:
|
|
1072
|
-
|
|
1073
|
-
bytesBase64Encoded:
|
|
1074
|
-
gcsUri:
|
|
1267
|
+
var googleVertexVideoModelOptionsSchema = (0, import_provider_utils6.lazySchema)(
|
|
1268
|
+
() => (0, import_provider_utils6.zodSchema)(
|
|
1269
|
+
import_v49.z.object({
|
|
1270
|
+
pollIntervalMs: import_v49.z.number().positive().nullish(),
|
|
1271
|
+
pollTimeoutMs: import_v49.z.number().positive().nullish(),
|
|
1272
|
+
personGeneration: import_v49.z.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
|
|
1273
|
+
negativePrompt: import_v49.z.string().nullish(),
|
|
1274
|
+
generateAudio: import_v49.z.boolean().nullish(),
|
|
1275
|
+
gcsOutputDirectory: import_v49.z.string().nullish(),
|
|
1276
|
+
referenceImages: import_v49.z.array(
|
|
1277
|
+
import_v49.z.object({
|
|
1278
|
+
bytesBase64Encoded: import_v49.z.string().nullish(),
|
|
1279
|
+
gcsUri: import_v49.z.string().nullish()
|
|
1075
1280
|
})
|
|
1076
1281
|
).nullish()
|
|
1077
1282
|
}).passthrough()
|
|
@@ -1085,7 +1290,7 @@ function createExpressModeFetch(apiKey, customFetch) {
|
|
|
1085
1290
|
const modifiedInit = {
|
|
1086
1291
|
...init,
|
|
1087
1292
|
headers: {
|
|
1088
|
-
...(init == null ? void 0 : init.headers) ? (0,
|
|
1293
|
+
...(init == null ? void 0 : init.headers) ? (0, import_provider_utils7.normalizeHeaders)(init.headers) : {},
|
|
1089
1294
|
"x-goog-api-key": apiKey
|
|
1090
1295
|
}
|
|
1091
1296
|
};
|
|
@@ -1093,17 +1298,17 @@ function createExpressModeFetch(apiKey, customFetch) {
|
|
|
1093
1298
|
};
|
|
1094
1299
|
}
|
|
1095
1300
|
function createVertex(options = {}) {
|
|
1096
|
-
const apiKey = (0,
|
|
1301
|
+
const apiKey = (0, import_provider_utils7.loadOptionalSetting)({
|
|
1097
1302
|
settingValue: options.apiKey,
|
|
1098
1303
|
environmentVariableName: "GOOGLE_VERTEX_API_KEY"
|
|
1099
1304
|
});
|
|
1100
|
-
const loadVertexProject = () => (0,
|
|
1305
|
+
const loadVertexProject = () => (0, import_provider_utils7.loadSetting)({
|
|
1101
1306
|
settingValue: options.project,
|
|
1102
1307
|
settingName: "project",
|
|
1103
1308
|
environmentVariableName: "GOOGLE_VERTEX_PROJECT",
|
|
1104
1309
|
description: "Google Vertex project"
|
|
1105
1310
|
});
|
|
1106
|
-
const loadVertexLocation = () => (0,
|
|
1311
|
+
const loadVertexLocation = () => (0, import_provider_utils7.loadSetting)({
|
|
1107
1312
|
settingValue: options.location,
|
|
1108
1313
|
settingName: "location",
|
|
1109
1314
|
environmentVariableName: "GOOGLE_VERTEX_LOCATION",
|
|
@@ -1112,7 +1317,7 @@ function createVertex(options = {}) {
|
|
|
1112
1317
|
const loadBaseURL = ({ endpoint = false } = {}) => {
|
|
1113
1318
|
var _a, _b;
|
|
1114
1319
|
if (apiKey) {
|
|
1115
|
-
return (_a = (0,
|
|
1320
|
+
return (_a = (0, import_provider_utils7.withoutTrailingSlash)(options.baseURL)) != null ? _a : EXPRESS_MODE_BASE_URL;
|
|
1116
1321
|
}
|
|
1117
1322
|
const region = loadVertexLocation();
|
|
1118
1323
|
const project = loadVertexProject();
|
|
@@ -1125,13 +1330,13 @@ function createVertex(options = {}) {
|
|
|
1125
1330
|
return `${region}-aiplatform.googleapis.com`;
|
|
1126
1331
|
}
|
|
1127
1332
|
};
|
|
1128
|
-
return (_b = (0,
|
|
1333
|
+
return (_b = (0, import_provider_utils7.withoutTrailingSlash)(options.baseURL)) != null ? _b : `https://${getHost()}/v1beta1/projects/${project}/locations/${region}${endpoint ? "" : "/publishers/google"}`;
|
|
1129
1334
|
};
|
|
1130
1335
|
const createConfig = (name, { endpoint = false } = {}) => {
|
|
1131
1336
|
const getHeaders = async () => {
|
|
1132
1337
|
var _a;
|
|
1133
|
-
const originalHeaders = await (0,
|
|
1134
|
-
return (0,
|
|
1338
|
+
const originalHeaders = await (0, import_provider_utils7.resolve)((_a = options.headers) != null ? _a : {});
|
|
1339
|
+
return (0, import_provider_utils7.withUserAgentSuffix)(
|
|
1135
1340
|
originalHeaders,
|
|
1136
1341
|
`ai-sdk/google-vertex/${VERSION}`
|
|
1137
1342
|
);
|
|
@@ -1147,7 +1352,7 @@ function createVertex(options = {}) {
|
|
|
1147
1352
|
var _a;
|
|
1148
1353
|
return new import_internal3.GoogleGenerativeAILanguageModel(modelId, {
|
|
1149
1354
|
...createConfig("chat"),
|
|
1150
|
-
generateId: (_a = options.generateId) != null ? _a :
|
|
1355
|
+
generateId: (_a = options.generateId) != null ? _a : import_provider_utils7.generateId,
|
|
1151
1356
|
supportedUrls: () => ({
|
|
1152
1357
|
"*": [
|
|
1153
1358
|
// HTTP URLs:
|
|
@@ -1173,7 +1378,7 @@ function createVertex(options = {}) {
|
|
|
1173
1378
|
// endpoint-style base URL without the `/publishers/google` suffix that
|
|
1174
1379
|
// the base-model paths carry.
|
|
1175
1380
|
...createConfig("interactions", { endpoint: true }),
|
|
1176
|
-
generateId: (_a = options.generateId) != null ? _a :
|
|
1381
|
+
generateId: (_a = options.generateId) != null ? _a : import_provider_utils7.generateId
|
|
1177
1382
|
}
|
|
1178
1383
|
);
|
|
1179
1384
|
};
|
|
@@ -1182,14 +1387,14 @@ function createVertex(options = {}) {
|
|
|
1182
1387
|
var _a;
|
|
1183
1388
|
return new GoogleVertexImageModel(modelId, {
|
|
1184
1389
|
...createConfig("image"),
|
|
1185
|
-
generateId: (_a = options.generateId) != null ? _a :
|
|
1390
|
+
generateId: (_a = options.generateId) != null ? _a : import_provider_utils7.generateId
|
|
1186
1391
|
});
|
|
1187
1392
|
};
|
|
1188
1393
|
const createVideoModel = (modelId) => {
|
|
1189
1394
|
var _a;
|
|
1190
1395
|
return new GoogleVertexVideoModel(modelId, {
|
|
1191
1396
|
...createConfig("video"),
|
|
1192
|
-
generateId: (_a = options.generateId) != null ? _a :
|
|
1397
|
+
generateId: (_a = options.generateId) != null ? _a : import_provider_utils7.generateId
|
|
1193
1398
|
});
|
|
1194
1399
|
};
|
|
1195
1400
|
const createTranscriptionModel = (modelId) => {
|
|
@@ -1199,6 +1404,14 @@ function createVertex(options = {}) {
|
|
|
1199
1404
|
);
|
|
1200
1405
|
}
|
|
1201
1406
|
const config = createConfig("transcription");
|
|
1407
|
+
if (modelId.startsWith("gemini")) {
|
|
1408
|
+
return new GoogleVertexGeminiTranscriptionModel(modelId, {
|
|
1409
|
+
provider: config.provider,
|
|
1410
|
+
baseURL: loadBaseURL(),
|
|
1411
|
+
headers: config.headers,
|
|
1412
|
+
fetch: config.fetch
|
|
1413
|
+
});
|
|
1414
|
+
}
|
|
1202
1415
|
return new GoogleVertexTranscriptionModel(modelId, {
|
|
1203
1416
|
provider: config.provider,
|
|
1204
1417
|
headers: config.headers,
|
|
@@ -1232,7 +1445,7 @@ function createVertex(options = {}) {
|
|
|
1232
1445
|
|
|
1233
1446
|
// src/google-vertex-provider-node.ts
|
|
1234
1447
|
function createVertex2(options = {}) {
|
|
1235
|
-
const apiKey = (0,
|
|
1448
|
+
const apiKey = (0, import_provider_utils8.loadOptionalSetting)({
|
|
1236
1449
|
settingValue: options.apiKey,
|
|
1237
1450
|
environmentVariableName: "GOOGLE_VERTEX_API_KEY"
|
|
1238
1451
|
});
|
|
@@ -1248,13 +1461,14 @@ function createVertex2(options = {}) {
|
|
|
1248
1461
|
...options,
|
|
1249
1462
|
headers: async () => ({
|
|
1250
1463
|
Authorization: `Bearer ${await generateAuthToken()}`,
|
|
1251
|
-
...await (0,
|
|
1464
|
+
...await (0, import_provider_utils8.resolve)(options.headers)
|
|
1252
1465
|
})
|
|
1253
1466
|
});
|
|
1254
1467
|
}
|
|
1255
1468
|
var vertex = createVertex2();
|
|
1256
1469
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1257
1470
|
0 && (module.exports = {
|
|
1471
|
+
GoogleVertexGeminiTranscriptionModel,
|
|
1258
1472
|
VERSION,
|
|
1259
1473
|
createVertex,
|
|
1260
1474
|
vertex
|