@ai-sdk/google 3.0.114 → 3.0.116
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 +14 -0
- package/dist/index.d.mts +57 -3
- package/dist/index.d.ts +57 -3
- package/dist/index.js +926 -672
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +863 -601
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +65 -5
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +65 -5
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/convert-json-schema-to-openapi-schema.ts +123 -7
- package/src/google-provider.ts +24 -0
- package/src/index.ts +5 -0
- package/src/transcription/google-transcription-model-options.ts +51 -0
- package/src/transcription/google-transcription-model.ts +243 -0
package/dist/index.mjs
CHANGED
|
@@ -1,26 +1,14 @@
|
|
|
1
|
-
// src/google-
|
|
2
|
-
import {
|
|
3
|
-
generateId as generateId2,
|
|
4
|
-
loadApiKey,
|
|
5
|
-
withoutTrailingSlash,
|
|
6
|
-
withUserAgentSuffix as withUserAgentSuffix2
|
|
7
|
-
} from "@ai-sdk/provider-utils";
|
|
8
|
-
|
|
9
|
-
// src/version.ts
|
|
10
|
-
var VERSION = true ? "3.0.114" : "0.0.0-test";
|
|
11
|
-
|
|
12
|
-
// src/google-generative-ai-embedding-model.ts
|
|
1
|
+
// src/transcription/google-transcription-model.ts
|
|
13
2
|
import {
|
|
14
|
-
|
|
3
|
+
InvalidArgumentError
|
|
15
4
|
} from "@ai-sdk/provider";
|
|
16
5
|
import {
|
|
17
6
|
combineHeaders,
|
|
7
|
+
convertToBase64,
|
|
18
8
|
createJsonResponseHandler,
|
|
19
|
-
lazySchema as lazySchema3,
|
|
20
9
|
parseProviderOptions,
|
|
21
10
|
postJsonToApi,
|
|
22
|
-
resolve
|
|
23
|
-
zodSchema as zodSchema3
|
|
11
|
+
resolve
|
|
24
12
|
} from "@ai-sdk/provider-utils";
|
|
25
13
|
import { z as z3 } from "zod/v4";
|
|
26
14
|
|
|
@@ -48,35 +36,240 @@ var googleFailedResponseHandler = createJsonErrorResponseHandler({
|
|
|
48
36
|
errorToMessage: (data) => data.error.message
|
|
49
37
|
});
|
|
50
38
|
|
|
39
|
+
// src/transcription/google-transcription-model-options.ts
|
|
40
|
+
import { z as z2 } from "zod/v4";
|
|
41
|
+
var googleTranscriptionModelOptions = z2.object({
|
|
42
|
+
/**
|
|
43
|
+
* BCP-47 language codes providing hints about the languages present in the
|
|
44
|
+
* audio. If omitted or empty, defaults to automatic language detection.
|
|
45
|
+
*/
|
|
46
|
+
languageCodes: z2.array(z2.string()).optional(),
|
|
47
|
+
/**
|
|
48
|
+
* Custom vocabulary phrases, which bias the speech recognition model
|
|
49
|
+
* toward recognizing specific terms.
|
|
50
|
+
*/
|
|
51
|
+
customVocabulary: z2.array(z2.string()).optional(),
|
|
52
|
+
/**
|
|
53
|
+
* Enables word-level timestamp generation.
|
|
54
|
+
*/
|
|
55
|
+
wordTimestamp: z2.boolean().optional(),
|
|
56
|
+
/**
|
|
57
|
+
* Enables speaker diarization.
|
|
58
|
+
*/
|
|
59
|
+
diarization: z2.boolean().optional(),
|
|
60
|
+
/**
|
|
61
|
+
* Transcription output formatting mode.
|
|
62
|
+
*
|
|
63
|
+
* - `VERBATIM` (default): exact literal transcript preserving filler
|
|
64
|
+
* words, repetitions, and false starts.
|
|
65
|
+
* - `SMART`: cleans up and structures the transcript in real time —
|
|
66
|
+
* disfluency removal, inline self-corrections, structured formatting
|
|
67
|
+
* (lists, numbers, dates, paragraph breaks), and grammar/casing polish.
|
|
68
|
+
*/
|
|
69
|
+
mode: z2.enum(["SMART", "VERBATIM"]).optional()
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// src/transcription/google-transcription-model.ts
|
|
73
|
+
function isLiveTranscriptionModelId(modelId) {
|
|
74
|
+
return modelId.includes("-live");
|
|
75
|
+
}
|
|
76
|
+
var GoogleTranscriptionModel = class {
|
|
77
|
+
constructor(modelId, config) {
|
|
78
|
+
this.modelId = modelId;
|
|
79
|
+
this.config = config;
|
|
80
|
+
this.specificationVersion = "v3";
|
|
81
|
+
}
|
|
82
|
+
get provider() {
|
|
83
|
+
return this.config.provider;
|
|
84
|
+
}
|
|
85
|
+
async parseOptions(providerOptions) {
|
|
86
|
+
return parseProviderOptions({
|
|
87
|
+
provider: "google",
|
|
88
|
+
providerOptions,
|
|
89
|
+
schema: googleTranscriptionModelOptions
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
async doGenerate(options) {
|
|
93
|
+
var _a, _b, _c, _d, _e, _f;
|
|
94
|
+
if (isLiveTranscriptionModelId(this.modelId)) {
|
|
95
|
+
throw new InvalidArgumentError({
|
|
96
|
+
argument: "modelId",
|
|
97
|
+
message: `Model '${this.modelId}' only supports streaming transcription, which requires AI SDK v7. Use a unary model such as 'gemini-3.5-transcribe'.`
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
101
|
+
const warnings = [];
|
|
102
|
+
const googleOptions = await this.parseOptions(options.providerOptions);
|
|
103
|
+
const transcriptionConfig = buildTranscriptionConfig(googleOptions);
|
|
104
|
+
const requestBody = {
|
|
105
|
+
model: this.modelId,
|
|
106
|
+
input: [
|
|
107
|
+
{
|
|
108
|
+
type: "audio",
|
|
109
|
+
data: convertToBase64(options.audio),
|
|
110
|
+
mime_type: options.mediaType
|
|
111
|
+
}
|
|
112
|
+
],
|
|
113
|
+
...transcriptionConfig != null ? { generation_config: { transcription_config: transcriptionConfig } } : {}
|
|
114
|
+
};
|
|
115
|
+
const {
|
|
116
|
+
value: response,
|
|
117
|
+
responseHeaders,
|
|
118
|
+
rawValue: rawResponse
|
|
119
|
+
} = await postJsonToApi({
|
|
120
|
+
url: `${this.config.baseURL}/interactions`,
|
|
121
|
+
headers: combineHeaders(
|
|
122
|
+
this.config.headers ? await resolve(this.config.headers) : void 0,
|
|
123
|
+
options.headers
|
|
124
|
+
),
|
|
125
|
+
body: requestBody,
|
|
126
|
+
failedResponseHandler: googleFailedResponseHandler,
|
|
127
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
128
|
+
googleInteractionsTranscriptionResponseSchema
|
|
129
|
+
),
|
|
130
|
+
abortSignal: options.abortSignal,
|
|
131
|
+
fetch: this.config.fetch
|
|
132
|
+
});
|
|
133
|
+
let text = "";
|
|
134
|
+
const segments = [];
|
|
135
|
+
for (const step of (_d = response.steps) != null ? _d : []) {
|
|
136
|
+
for (const content of (_e = step.content) != null ? _e : []) {
|
|
137
|
+
if (content.type !== "text" || content.text == null) continue;
|
|
138
|
+
text += content.text;
|
|
139
|
+
for (const annotation of (_f = content.annotations) != null ? _f : []) {
|
|
140
|
+
if (annotation.type !== "word_info") continue;
|
|
141
|
+
const startSecond = parseOffsetSeconds(annotation.start_offset);
|
|
142
|
+
const endSecond = parseOffsetSeconds(annotation.end_offset);
|
|
143
|
+
if (annotation.text == null || startSecond == null || endSecond == null) {
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
segments.push({ text: annotation.text, startSecond, endSecond });
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return {
|
|
151
|
+
text,
|
|
152
|
+
segments,
|
|
153
|
+
language: void 0,
|
|
154
|
+
durationInSeconds: void 0,
|
|
155
|
+
warnings,
|
|
156
|
+
response: {
|
|
157
|
+
timestamp: currentDate,
|
|
158
|
+
modelId: this.modelId,
|
|
159
|
+
headers: responseHeaders,
|
|
160
|
+
body: rawResponse
|
|
161
|
+
},
|
|
162
|
+
...response.usage != null ? {
|
|
163
|
+
providerMetadata: {
|
|
164
|
+
google: { usage: response.usage }
|
|
165
|
+
}
|
|
166
|
+
} : {}
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
function buildTranscriptionConfig(options) {
|
|
171
|
+
var _a;
|
|
172
|
+
if (options == null) return void 0;
|
|
173
|
+
const config = {};
|
|
174
|
+
if (options.languageCodes != null) {
|
|
175
|
+
config.language_codes = options.languageCodes;
|
|
176
|
+
}
|
|
177
|
+
if (options.customVocabulary != null) {
|
|
178
|
+
config.custom_vocabulary = options.customVocabulary;
|
|
179
|
+
}
|
|
180
|
+
if (options.mode != null || options.diarization === true || options.wordTimestamp === true) {
|
|
181
|
+
config.mode = {
|
|
182
|
+
type: ((_a = options.mode) != null ? _a : "VERBATIM").toLowerCase(),
|
|
183
|
+
...options.diarization === true ? { diarization_mode: "speaker" } : {},
|
|
184
|
+
...options.wordTimestamp === true ? { timestamp_granularities: ["word"] } : {}
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
return Object.keys(config).length > 0 ? config : void 0;
|
|
188
|
+
}
|
|
189
|
+
function parseOffsetSeconds(offset) {
|
|
190
|
+
if (offset == null) return void 0;
|
|
191
|
+
const parsed = Number.parseFloat(offset);
|
|
192
|
+
return Number.isFinite(parsed) ? parsed : void 0;
|
|
193
|
+
}
|
|
194
|
+
var googleInteractionsWordAnnotationSchema = z3.object({
|
|
195
|
+
type: z3.string().nullish(),
|
|
196
|
+
text: z3.string().nullish(),
|
|
197
|
+
speaker: z3.string().nullish(),
|
|
198
|
+
start_offset: z3.string().nullish(),
|
|
199
|
+
end_offset: z3.string().nullish()
|
|
200
|
+
});
|
|
201
|
+
var googleInteractionsTranscriptionResponseSchema = z3.object({
|
|
202
|
+
status: z3.string().nullish(),
|
|
203
|
+
steps: z3.array(
|
|
204
|
+
z3.object({
|
|
205
|
+
type: z3.string().nullish(),
|
|
206
|
+
content: z3.array(
|
|
207
|
+
z3.object({
|
|
208
|
+
type: z3.string().nullish(),
|
|
209
|
+
text: z3.string().nullish(),
|
|
210
|
+
annotations: z3.array(googleInteractionsWordAnnotationSchema).nullish()
|
|
211
|
+
})
|
|
212
|
+
).nullish()
|
|
213
|
+
})
|
|
214
|
+
).nullish(),
|
|
215
|
+
usage: z3.record(z3.string(), z3.unknown()).nullish()
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
// src/google-provider.ts
|
|
219
|
+
import {
|
|
220
|
+
generateId as generateId2,
|
|
221
|
+
loadApiKey,
|
|
222
|
+
withoutTrailingSlash,
|
|
223
|
+
withUserAgentSuffix as withUserAgentSuffix2
|
|
224
|
+
} from "@ai-sdk/provider-utils";
|
|
225
|
+
|
|
226
|
+
// src/version.ts
|
|
227
|
+
var VERSION = true ? "3.0.116" : "0.0.0-test";
|
|
228
|
+
|
|
229
|
+
// src/google-generative-ai-embedding-model.ts
|
|
230
|
+
import {
|
|
231
|
+
TooManyEmbeddingValuesForCallError
|
|
232
|
+
} from "@ai-sdk/provider";
|
|
233
|
+
import {
|
|
234
|
+
combineHeaders as combineHeaders2,
|
|
235
|
+
createJsonResponseHandler as createJsonResponseHandler2,
|
|
236
|
+
lazySchema as lazySchema3,
|
|
237
|
+
parseProviderOptions as parseProviderOptions2,
|
|
238
|
+
postJsonToApi as postJsonToApi2,
|
|
239
|
+
resolve as resolve2,
|
|
240
|
+
zodSchema as zodSchema3
|
|
241
|
+
} from "@ai-sdk/provider-utils";
|
|
242
|
+
import { z as z5 } from "zod/v4";
|
|
243
|
+
|
|
51
244
|
// src/google-generative-ai-embedding-options.ts
|
|
52
245
|
import {
|
|
53
246
|
lazySchema as lazySchema2,
|
|
54
247
|
zodSchema as zodSchema2
|
|
55
248
|
} from "@ai-sdk/provider-utils";
|
|
56
|
-
import { z as
|
|
57
|
-
var googleEmbeddingContentPartSchema =
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
inlineData:
|
|
61
|
-
mimeType:
|
|
62
|
-
data:
|
|
249
|
+
import { z as z4 } from "zod/v4";
|
|
250
|
+
var googleEmbeddingContentPartSchema = z4.union([
|
|
251
|
+
z4.object({ text: z4.string() }),
|
|
252
|
+
z4.object({
|
|
253
|
+
inlineData: z4.object({
|
|
254
|
+
mimeType: z4.string(),
|
|
255
|
+
data: z4.string()
|
|
63
256
|
})
|
|
64
257
|
}),
|
|
65
|
-
|
|
66
|
-
fileData:
|
|
67
|
-
fileUri:
|
|
68
|
-
mimeType:
|
|
258
|
+
z4.object({
|
|
259
|
+
fileData: z4.object({
|
|
260
|
+
fileUri: z4.string(),
|
|
261
|
+
mimeType: z4.string()
|
|
69
262
|
})
|
|
70
263
|
})
|
|
71
264
|
]);
|
|
72
265
|
var googleEmbeddingModelOptions = lazySchema2(
|
|
73
266
|
() => zodSchema2(
|
|
74
|
-
|
|
267
|
+
z4.object({
|
|
75
268
|
/**
|
|
76
269
|
* Optional. Optional reduced dimension for the output embedding.
|
|
77
270
|
* If set, excessive values in the output embedding are truncated from the end.
|
|
78
271
|
*/
|
|
79
|
-
outputDimensionality:
|
|
272
|
+
outputDimensionality: z4.number().optional(),
|
|
80
273
|
/**
|
|
81
274
|
* Optional. Specifies the task type for generating embeddings.
|
|
82
275
|
* Supported task types:
|
|
@@ -89,7 +282,7 @@ var googleEmbeddingModelOptions = lazySchema2(
|
|
|
89
282
|
* - FACT_VERIFICATION: Optimized for verifying factual information.
|
|
90
283
|
* - CODE_RETRIEVAL_QUERY: Optimized for retrieving code blocks based on natural language queries.
|
|
91
284
|
*/
|
|
92
|
-
taskType:
|
|
285
|
+
taskType: z4.enum([
|
|
93
286
|
"SEMANTIC_SIMILARITY",
|
|
94
287
|
"CLASSIFICATION",
|
|
95
288
|
"CLUSTERING",
|
|
@@ -108,7 +301,7 @@ var googleEmbeddingModelOptions = lazySchema2(
|
|
|
108
301
|
* The array length must match the number of values being embedded. In
|
|
109
302
|
* the case of a single embedding, the array length must be 1.
|
|
110
303
|
*/
|
|
111
|
-
content:
|
|
304
|
+
content: z4.array(z4.array(googleEmbeddingContentPartSchema).min(1).nullable()).optional()
|
|
112
305
|
})
|
|
113
306
|
)
|
|
114
307
|
);
|
|
@@ -131,7 +324,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
131
324
|
abortSignal,
|
|
132
325
|
providerOptions
|
|
133
326
|
}) {
|
|
134
|
-
const googleOptions = await
|
|
327
|
+
const googleOptions = await parseProviderOptions2({
|
|
135
328
|
provider: "google",
|
|
136
329
|
providerOptions,
|
|
137
330
|
schema: googleEmbeddingModelOptions
|
|
@@ -144,8 +337,8 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
144
337
|
values
|
|
145
338
|
});
|
|
146
339
|
}
|
|
147
|
-
const mergedHeaders =
|
|
148
|
-
await
|
|
340
|
+
const mergedHeaders = combineHeaders2(
|
|
341
|
+
await resolve2(this.config.headers),
|
|
149
342
|
headers
|
|
150
343
|
);
|
|
151
344
|
const multimodalContent = googleOptions == null ? void 0 : googleOptions.content;
|
|
@@ -162,7 +355,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
162
355
|
responseHeaders: responseHeaders2,
|
|
163
356
|
value: response2,
|
|
164
357
|
rawValue: rawValue2
|
|
165
|
-
} = await
|
|
358
|
+
} = await postJsonToApi2({
|
|
166
359
|
url: `${this.config.baseURL}/models/${this.modelId}:embedContent`,
|
|
167
360
|
headers: mergedHeaders,
|
|
168
361
|
body: {
|
|
@@ -174,7 +367,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
174
367
|
taskType: googleOptions == null ? void 0 : googleOptions.taskType
|
|
175
368
|
},
|
|
176
369
|
failedResponseHandler: googleFailedResponseHandler,
|
|
177
|
-
successfulResponseHandler:
|
|
370
|
+
successfulResponseHandler: createJsonResponseHandler2(
|
|
178
371
|
googleGenerativeAISingleEmbeddingResponseSchema
|
|
179
372
|
),
|
|
180
373
|
abortSignal,
|
|
@@ -191,7 +384,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
191
384
|
responseHeaders,
|
|
192
385
|
value: response,
|
|
193
386
|
rawValue
|
|
194
|
-
} = await
|
|
387
|
+
} = await postJsonToApi2({
|
|
195
388
|
url: `${this.config.baseURL}/models/${this.modelId}:batchEmbedContents`,
|
|
196
389
|
headers: mergedHeaders,
|
|
197
390
|
body: {
|
|
@@ -210,7 +403,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
210
403
|
})
|
|
211
404
|
},
|
|
212
405
|
failedResponseHandler: googleFailedResponseHandler,
|
|
213
|
-
successfulResponseHandler:
|
|
406
|
+
successfulResponseHandler: createJsonResponseHandler2(
|
|
214
407
|
googleGenerativeAITextEmbeddingResponseSchema
|
|
215
408
|
),
|
|
216
409
|
abortSignal,
|
|
@@ -226,32 +419,32 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
226
419
|
};
|
|
227
420
|
var googleGenerativeAITextEmbeddingResponseSchema = lazySchema3(
|
|
228
421
|
() => zodSchema3(
|
|
229
|
-
|
|
230
|
-
embeddings:
|
|
422
|
+
z5.object({
|
|
423
|
+
embeddings: z5.array(z5.object({ values: z5.array(z5.number()) }))
|
|
231
424
|
})
|
|
232
425
|
)
|
|
233
426
|
);
|
|
234
427
|
var googleGenerativeAISingleEmbeddingResponseSchema = lazySchema3(
|
|
235
428
|
() => zodSchema3(
|
|
236
|
-
|
|
237
|
-
embedding:
|
|
429
|
+
z5.object({
|
|
430
|
+
embedding: z5.object({ values: z5.array(z5.number()) })
|
|
238
431
|
})
|
|
239
432
|
)
|
|
240
433
|
);
|
|
241
434
|
|
|
242
435
|
// src/google-generative-ai-language-model.ts
|
|
243
436
|
import {
|
|
244
|
-
combineHeaders as
|
|
437
|
+
combineHeaders as combineHeaders3,
|
|
245
438
|
createEventSourceResponseHandler,
|
|
246
|
-
createJsonResponseHandler as
|
|
439
|
+
createJsonResponseHandler as createJsonResponseHandler3,
|
|
247
440
|
generateId,
|
|
248
441
|
lazySchema as lazySchema5,
|
|
249
|
-
parseProviderOptions as
|
|
250
|
-
postJsonToApi as
|
|
251
|
-
resolve as
|
|
442
|
+
parseProviderOptions as parseProviderOptions3,
|
|
443
|
+
postJsonToApi as postJsonToApi3,
|
|
444
|
+
resolve as resolve3,
|
|
252
445
|
zodSchema as zodSchema5
|
|
253
446
|
} from "@ai-sdk/provider-utils";
|
|
254
|
-
import { z as
|
|
447
|
+
import { z as z7 } from "zod/v4";
|
|
255
448
|
|
|
256
449
|
// src/convert-google-generative-ai-usage.ts
|
|
257
450
|
function convertGoogleGenerativeAIUsage(usage) {
|
|
@@ -350,9 +543,6 @@ function convertJSONSchemaDefinition(jsonSchema, isRoot, referenceContext) {
|
|
|
350
543
|
if (description) result.description = description;
|
|
351
544
|
if (required) result.required = required;
|
|
352
545
|
if (format) result.format = format;
|
|
353
|
-
if (constValue !== void 0) {
|
|
354
|
-
result.enum = [constValue];
|
|
355
|
-
}
|
|
356
546
|
if (type) {
|
|
357
547
|
if (Array.isArray(type)) {
|
|
358
548
|
const hasNull = type.includes("null");
|
|
@@ -369,8 +559,9 @@ function convertJSONSchemaDefinition(jsonSchema, isRoot, referenceContext) {
|
|
|
369
559
|
result.type = type;
|
|
370
560
|
}
|
|
371
561
|
}
|
|
372
|
-
|
|
373
|
-
|
|
562
|
+
const values = enumValues != null ? enumValues : constValue !== void 0 ? [constValue] : void 0;
|
|
563
|
+
if (values !== void 0) {
|
|
564
|
+
addEnumToSchema({ values, type, result });
|
|
374
565
|
}
|
|
375
566
|
if (properties != null) {
|
|
376
567
|
result.properties = Object.entries(properties).reduce(
|
|
@@ -430,6 +621,68 @@ function convertJSONSchemaDefinition(jsonSchema, isRoot, referenceContext) {
|
|
|
430
621
|
}
|
|
431
622
|
return result;
|
|
432
623
|
}
|
|
624
|
+
function addEnumToSchema({
|
|
625
|
+
values,
|
|
626
|
+
type,
|
|
627
|
+
result
|
|
628
|
+
}) {
|
|
629
|
+
const nullable = Array.isArray(type) && type.includes("null") || type === void 0 && values.includes(null);
|
|
630
|
+
const enumValues = nullable ? values.filter((value) => value !== null) : values;
|
|
631
|
+
if (values.length > 0 && values.every((value) => value === null)) {
|
|
632
|
+
const typeAllowsNull = type === void 0 || type === "null" || Array.isArray(type) && type.includes("null");
|
|
633
|
+
if (typeAllowsNull) {
|
|
634
|
+
result.type = "null";
|
|
635
|
+
if (Array.isArray(type)) {
|
|
636
|
+
delete result.anyOf;
|
|
637
|
+
}
|
|
638
|
+
return;
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
const enumType = getEnumType({ values: enumValues, type });
|
|
642
|
+
if (enumType === void 0) {
|
|
643
|
+
throw new UnsupportedFunctionalityError({
|
|
644
|
+
functionality: "JSON Schema enum with mixed or unsupported values",
|
|
645
|
+
message: "Google does not support this JSON Schema enum. Enum values must share one supported primitive type and match the schema type."
|
|
646
|
+
});
|
|
647
|
+
}
|
|
648
|
+
result.type = enumType;
|
|
649
|
+
if (Array.isArray(type)) {
|
|
650
|
+
delete result.anyOf;
|
|
651
|
+
}
|
|
652
|
+
if (nullable) {
|
|
653
|
+
result.nullable = true;
|
|
654
|
+
}
|
|
655
|
+
if (enumType === "string") {
|
|
656
|
+
result.enum = enumValues;
|
|
657
|
+
} else {
|
|
658
|
+
result.format = "enum";
|
|
659
|
+
result.enum = enumValues.map(String);
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
function getEnumType({
|
|
663
|
+
values,
|
|
664
|
+
type
|
|
665
|
+
}) {
|
|
666
|
+
if (values.length === 0) {
|
|
667
|
+
return void 0;
|
|
668
|
+
}
|
|
669
|
+
const typeAllows = (enumType) => type === void 0 || type === enumType || Array.isArray(type) && type.includes(enumType);
|
|
670
|
+
if (typeAllows("string") && values.every((value) => typeof value === "string")) {
|
|
671
|
+
return "string";
|
|
672
|
+
}
|
|
673
|
+
if ((typeAllows("number") || typeAllows("integer")) && values.every((value) => typeof value === "number" && Number.isFinite(value))) {
|
|
674
|
+
if (typeAllows("number")) {
|
|
675
|
+
return "number";
|
|
676
|
+
}
|
|
677
|
+
if (values.every((value) => Number.isInteger(value))) {
|
|
678
|
+
return "integer";
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
if (typeAllows("boolean") && values.every((value) => typeof value === "boolean")) {
|
|
682
|
+
return "boolean";
|
|
683
|
+
}
|
|
684
|
+
return void 0;
|
|
685
|
+
}
|
|
433
686
|
function convertJSONSchemaReference({
|
|
434
687
|
jsonSchema,
|
|
435
688
|
reference,
|
|
@@ -508,7 +761,7 @@ function isEmptyObjectSchema(jsonSchema) {
|
|
|
508
761
|
import {
|
|
509
762
|
UnsupportedFunctionalityError as UnsupportedFunctionalityError2
|
|
510
763
|
} from "@ai-sdk/provider";
|
|
511
|
-
import { convertToBase64, secureJsonParse } from "@ai-sdk/provider-utils";
|
|
764
|
+
import { convertToBase64 as convertToBase642, secureJsonParse } from "@ai-sdk/provider-utils";
|
|
512
765
|
var SKIP_THOUGHT_SIGNATURE_VALIDATOR = "skip_thought_signature_validator";
|
|
513
766
|
function getGoogleProviderOptions(providerOptions, providerOptionsName) {
|
|
514
767
|
const namespaces = [
|
|
@@ -684,7 +937,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
684
937
|
} : {
|
|
685
938
|
inlineData: {
|
|
686
939
|
mimeType: mediaType,
|
|
687
|
-
data:
|
|
940
|
+
data: convertToBase642(part.data)
|
|
688
941
|
}
|
|
689
942
|
}
|
|
690
943
|
);
|
|
@@ -729,7 +982,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
729
982
|
return {
|
|
730
983
|
inlineData: {
|
|
731
984
|
mimeType: part.mediaType,
|
|
732
|
-
data:
|
|
985
|
+
data: convertToBase642(part.data)
|
|
733
986
|
},
|
|
734
987
|
...(providerOpts == null ? void 0 : providerOpts.thought) === true ? { thought: true } : {},
|
|
735
988
|
thoughtSignature
|
|
@@ -886,23 +1139,23 @@ import {
|
|
|
886
1139
|
lazySchema as lazySchema4,
|
|
887
1140
|
zodSchema as zodSchema4
|
|
888
1141
|
} from "@ai-sdk/provider-utils";
|
|
889
|
-
import { z as
|
|
1142
|
+
import { z as z6 } from "zod/v4";
|
|
890
1143
|
var googleLanguageModelOptions = lazySchema4(
|
|
891
1144
|
() => zodSchema4(
|
|
892
|
-
|
|
893
|
-
responseModalities:
|
|
894
|
-
thinkingConfig:
|
|
895
|
-
thinkingBudget:
|
|
896
|
-
includeThoughts:
|
|
1145
|
+
z6.object({
|
|
1146
|
+
responseModalities: z6.array(z6.enum(["TEXT", "IMAGE"])).optional(),
|
|
1147
|
+
thinkingConfig: z6.object({
|
|
1148
|
+
thinkingBudget: z6.number().optional(),
|
|
1149
|
+
includeThoughts: z6.boolean().optional(),
|
|
897
1150
|
// https://ai.google.dev/gemini-api/docs/gemini-3?thinking=high#thinking_level
|
|
898
|
-
thinkingLevel:
|
|
1151
|
+
thinkingLevel: z6.enum(["minimal", "low", "medium", "high"]).optional()
|
|
899
1152
|
}).optional(),
|
|
900
1153
|
/**
|
|
901
1154
|
* Optional.
|
|
902
1155
|
* The name of the cached content used as context to serve the prediction.
|
|
903
1156
|
* Format: cachedContents/{cachedContent}
|
|
904
1157
|
*/
|
|
905
|
-
cachedContent:
|
|
1158
|
+
cachedContent: z6.string().optional(),
|
|
906
1159
|
/**
|
|
907
1160
|
* Optional. Enable structured output. Default is true.
|
|
908
1161
|
*
|
|
@@ -911,13 +1164,13 @@ var googleLanguageModelOptions = lazySchema4(
|
|
|
911
1164
|
* Google Generative AI uses. You can use this to disable
|
|
912
1165
|
* structured outputs if you need to.
|
|
913
1166
|
*/
|
|
914
|
-
structuredOutputs:
|
|
1167
|
+
structuredOutputs: z6.boolean().optional(),
|
|
915
1168
|
/**
|
|
916
1169
|
* Optional. A list of unique safety settings for blocking unsafe content.
|
|
917
1170
|
*/
|
|
918
|
-
safetySettings:
|
|
919
|
-
|
|
920
|
-
category:
|
|
1171
|
+
safetySettings: z6.array(
|
|
1172
|
+
z6.object({
|
|
1173
|
+
category: z6.enum([
|
|
921
1174
|
"HARM_CATEGORY_UNSPECIFIED",
|
|
922
1175
|
"HARM_CATEGORY_HATE_SPEECH",
|
|
923
1176
|
"HARM_CATEGORY_DANGEROUS_CONTENT",
|
|
@@ -925,7 +1178,7 @@ var googleLanguageModelOptions = lazySchema4(
|
|
|
925
1178
|
"HARM_CATEGORY_SEXUALLY_EXPLICIT",
|
|
926
1179
|
"HARM_CATEGORY_CIVIC_INTEGRITY"
|
|
927
1180
|
]),
|
|
928
|
-
threshold:
|
|
1181
|
+
threshold: z6.enum([
|
|
929
1182
|
"HARM_BLOCK_THRESHOLD_UNSPECIFIED",
|
|
930
1183
|
"BLOCK_LOW_AND_ABOVE",
|
|
931
1184
|
"BLOCK_MEDIUM_AND_ABOVE",
|
|
@@ -935,7 +1188,7 @@ var googleLanguageModelOptions = lazySchema4(
|
|
|
935
1188
|
])
|
|
936
1189
|
})
|
|
937
1190
|
).optional(),
|
|
938
|
-
threshold:
|
|
1191
|
+
threshold: z6.enum([
|
|
939
1192
|
"HARM_BLOCK_THRESHOLD_UNSPECIFIED",
|
|
940
1193
|
"BLOCK_LOW_AND_ABOVE",
|
|
941
1194
|
"BLOCK_MEDIUM_AND_ABOVE",
|
|
@@ -948,19 +1201,19 @@ var googleLanguageModelOptions = lazySchema4(
|
|
|
948
1201
|
*
|
|
949
1202
|
* https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/audio-understanding
|
|
950
1203
|
*/
|
|
951
|
-
audioTimestamp:
|
|
1204
|
+
audioTimestamp: z6.boolean().optional(),
|
|
952
1205
|
/**
|
|
953
1206
|
* Optional. Defines labels used in billing reports. Available on Vertex AI only.
|
|
954
1207
|
*
|
|
955
1208
|
* https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/add-labels-to-api-calls
|
|
956
1209
|
*/
|
|
957
|
-
labels:
|
|
1210
|
+
labels: z6.record(z6.string(), z6.string()).optional(),
|
|
958
1211
|
/**
|
|
959
1212
|
* Optional. If specified, the media resolution specified will be used.
|
|
960
1213
|
*
|
|
961
1214
|
* https://ai.google.dev/api/generate-content#MediaResolution
|
|
962
1215
|
*/
|
|
963
|
-
mediaResolution:
|
|
1216
|
+
mediaResolution: z6.enum([
|
|
964
1217
|
"MEDIA_RESOLUTION_UNSPECIFIED",
|
|
965
1218
|
"MEDIA_RESOLUTION_LOW",
|
|
966
1219
|
"MEDIA_RESOLUTION_MEDIUM",
|
|
@@ -971,8 +1224,8 @@ var googleLanguageModelOptions = lazySchema4(
|
|
|
971
1224
|
*
|
|
972
1225
|
* https://ai.google.dev/gemini-api/docs/image-generation#aspect_ratios
|
|
973
1226
|
*/
|
|
974
|
-
imageConfig:
|
|
975
|
-
aspectRatio:
|
|
1227
|
+
imageConfig: z6.object({
|
|
1228
|
+
aspectRatio: z6.enum([
|
|
976
1229
|
"1:1",
|
|
977
1230
|
"2:3",
|
|
978
1231
|
"3:2",
|
|
@@ -988,12 +1241,12 @@ var googleLanguageModelOptions = lazySchema4(
|
|
|
988
1241
|
"1:4",
|
|
989
1242
|
"4:1"
|
|
990
1243
|
]).optional(),
|
|
991
|
-
imageSize:
|
|
1244
|
+
imageSize: z6.enum(["1K", "2K", "4K", "512"]).optional(),
|
|
992
1245
|
/**
|
|
993
1246
|
* Optional. Controls the generation of people in images.
|
|
994
1247
|
* Vertex AI only.
|
|
995
1248
|
*/
|
|
996
|
-
personGeneration:
|
|
1249
|
+
personGeneration: z6.enum([
|
|
997
1250
|
"PERSON_GENERATION_UNSPECIFIED",
|
|
998
1251
|
"ALLOW_ALL",
|
|
999
1252
|
"ALLOW_ADULT",
|
|
@@ -1007,7 +1260,7 @@ var googleLanguageModelOptions = lazySchema4(
|
|
|
1007
1260
|
*
|
|
1008
1261
|
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/reference/rest/v1/GenerationConfig
|
|
1009
1262
|
*/
|
|
1010
|
-
prominentPeople:
|
|
1263
|
+
prominentPeople: z6.enum([
|
|
1011
1264
|
"PROMINENT_PEOPLE_UNSPECIFIED",
|
|
1012
1265
|
"ALLOW_PROMINENT_PEOPLE",
|
|
1013
1266
|
"BLOCK_PROMINENT_PEOPLE"
|
|
@@ -1016,9 +1269,9 @@ var googleLanguageModelOptions = lazySchema4(
|
|
|
1016
1269
|
* Optional. The image output format for generated images.
|
|
1017
1270
|
* Vertex AI only.
|
|
1018
1271
|
*/
|
|
1019
|
-
imageOutputOptions:
|
|
1020
|
-
mimeType:
|
|
1021
|
-
compressionQuality:
|
|
1272
|
+
imageOutputOptions: z6.object({
|
|
1273
|
+
mimeType: z6.enum(["image/jpeg", "image/png"]).optional(),
|
|
1274
|
+
compressionQuality: z6.number().optional()
|
|
1022
1275
|
}).optional()
|
|
1023
1276
|
}).optional(),
|
|
1024
1277
|
/**
|
|
@@ -1027,10 +1280,10 @@ var googleLanguageModelOptions = lazySchema4(
|
|
|
1027
1280
|
*
|
|
1028
1281
|
* https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/grounding-with-google-maps
|
|
1029
1282
|
*/
|
|
1030
|
-
retrievalConfig:
|
|
1031
|
-
latLng:
|
|
1032
|
-
latitude:
|
|
1033
|
-
longitude:
|
|
1283
|
+
retrievalConfig: z6.object({
|
|
1284
|
+
latLng: z6.object({
|
|
1285
|
+
latitude: z6.number(),
|
|
1286
|
+
longitude: z6.number()
|
|
1034
1287
|
}).optional()
|
|
1035
1288
|
}).optional(),
|
|
1036
1289
|
/**
|
|
@@ -1043,12 +1296,12 @@ var googleLanguageModelOptions = lazySchema4(
|
|
|
1043
1296
|
*
|
|
1044
1297
|
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/multimodal/function-calling#streaming-fc
|
|
1045
1298
|
*/
|
|
1046
|
-
streamFunctionCallArguments:
|
|
1299
|
+
streamFunctionCallArguments: z6.boolean().optional(),
|
|
1047
1300
|
/**
|
|
1048
1301
|
* Optional. The service tier to use for the request. Sent as the
|
|
1049
1302
|
* `serviceTier` body field. Gemini API only.
|
|
1050
1303
|
*/
|
|
1051
|
-
serviceTier:
|
|
1304
|
+
serviceTier: z6.enum(["standard", "flex", "priority"]).optional(),
|
|
1052
1305
|
/**
|
|
1053
1306
|
* Optional. Vertex AI only. Sent as the
|
|
1054
1307
|
* `X-Vertex-AI-LLM-Shared-Request-Type` request header to select a
|
|
@@ -1059,7 +1312,7 @@ var googleLanguageModelOptions = lazySchema4(
|
|
|
1059
1312
|
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/priority-paygo
|
|
1060
1313
|
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/flex-paygo
|
|
1061
1314
|
*/
|
|
1062
|
-
sharedRequestType:
|
|
1315
|
+
sharedRequestType: z6.enum(["priority", "flex", "standard"]).optional(),
|
|
1063
1316
|
/**
|
|
1064
1317
|
* Optional. Vertex AI only. Sent as the `X-Vertex-AI-LLM-Request-Type`
|
|
1065
1318
|
* request header. Set to `'shared'` together with `sharedRequestType`
|
|
@@ -1067,7 +1320,7 @@ var googleLanguageModelOptions = lazySchema4(
|
|
|
1067
1320
|
*
|
|
1068
1321
|
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/priority-paygo
|
|
1069
1322
|
*/
|
|
1070
|
-
requestType:
|
|
1323
|
+
requestType: z6.enum(["shared"]).optional()
|
|
1071
1324
|
})
|
|
1072
1325
|
)
|
|
1073
1326
|
);
|
|
@@ -1656,13 +1909,13 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1656
1909
|
var _a, _b, _c;
|
|
1657
1910
|
const warnings = [];
|
|
1658
1911
|
const providerOptionsName = this.config.provider.includes("vertex") ? "vertex" : "google";
|
|
1659
|
-
let googleOptions = await
|
|
1912
|
+
let googleOptions = await parseProviderOptions3({
|
|
1660
1913
|
provider: providerOptionsName,
|
|
1661
1914
|
providerOptions,
|
|
1662
1915
|
schema: googleLanguageModelOptions
|
|
1663
1916
|
});
|
|
1664
1917
|
if (googleOptions == null && providerOptionsName !== "google") {
|
|
1665
|
-
googleOptions = await
|
|
1918
|
+
googleOptions = await parseProviderOptions3({
|
|
1666
1919
|
provider: "google",
|
|
1667
1920
|
providerOptions,
|
|
1668
1921
|
schema: googleLanguageModelOptions
|
|
@@ -1812,8 +2065,8 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1812
2065
|
async doGenerate(options) {
|
|
1813
2066
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
1814
2067
|
const { args, warnings, providerOptionsName, extraHeaders } = await this.getArgs(options);
|
|
1815
|
-
const mergedHeaders =
|
|
1816
|
-
await
|
|
2068
|
+
const mergedHeaders = combineHeaders3(
|
|
2069
|
+
await resolve3(this.config.headers),
|
|
1817
2070
|
options.headers,
|
|
1818
2071
|
extraHeaders
|
|
1819
2072
|
);
|
|
@@ -1821,14 +2074,14 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1821
2074
|
responseHeaders,
|
|
1822
2075
|
value: response,
|
|
1823
2076
|
rawValue: rawResponse
|
|
1824
|
-
} = await
|
|
2077
|
+
} = await postJsonToApi3({
|
|
1825
2078
|
url: `${this.config.baseURL}/${getModelPath(
|
|
1826
2079
|
this.modelId
|
|
1827
2080
|
)}:generateContent`,
|
|
1828
2081
|
headers: mergedHeaders,
|
|
1829
2082
|
body: args,
|
|
1830
2083
|
failedResponseHandler: googleFailedResponseHandler,
|
|
1831
|
-
successfulResponseHandler:
|
|
2084
|
+
successfulResponseHandler: createJsonResponseHandler3(responseSchema),
|
|
1832
2085
|
abortSignal: options.abortSignal,
|
|
1833
2086
|
fetch: this.config.fetch
|
|
1834
2087
|
});
|
|
@@ -1993,12 +2246,12 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1993
2246
|
}
|
|
1994
2247
|
async doStream(options) {
|
|
1995
2248
|
const { args, warnings, providerOptionsName, extraHeaders } = await this.getArgs(options, { isStreaming: true });
|
|
1996
|
-
const headers =
|
|
1997
|
-
await
|
|
2249
|
+
const headers = combineHeaders3(
|
|
2250
|
+
await resolve3(this.config.headers),
|
|
1998
2251
|
options.headers,
|
|
1999
2252
|
extraHeaders
|
|
2000
2253
|
);
|
|
2001
|
-
const { responseHeaders, value: response } = await
|
|
2254
|
+
const { responseHeaders, value: response } = await postJsonToApi3({
|
|
2002
2255
|
url: `${this.config.baseURL}/${getModelPath(
|
|
2003
2256
|
this.modelId
|
|
2004
2257
|
)}:streamGenerateContent?alt=sse`,
|
|
@@ -2514,192 +2767,192 @@ function extractSources({
|
|
|
2514
2767
|
}
|
|
2515
2768
|
return sources.length > 0 ? sources : void 0;
|
|
2516
2769
|
}
|
|
2517
|
-
var getGroundingMetadataSchema = () =>
|
|
2518
|
-
webSearchQueries:
|
|
2519
|
-
imageSearchQueries:
|
|
2520
|
-
retrievalQueries:
|
|
2521
|
-
searchEntryPoint:
|
|
2522
|
-
groundingChunks:
|
|
2523
|
-
|
|
2524
|
-
web:
|
|
2525
|
-
image:
|
|
2526
|
-
sourceUri:
|
|
2527
|
-
imageUri:
|
|
2528
|
-
title:
|
|
2529
|
-
domain:
|
|
2770
|
+
var getGroundingMetadataSchema = () => z7.object({
|
|
2771
|
+
webSearchQueries: z7.array(z7.string()).nullish(),
|
|
2772
|
+
imageSearchQueries: z7.array(z7.string()).nullish(),
|
|
2773
|
+
retrievalQueries: z7.array(z7.string()).nullish(),
|
|
2774
|
+
searchEntryPoint: z7.object({ renderedContent: z7.string() }).nullish(),
|
|
2775
|
+
groundingChunks: z7.array(
|
|
2776
|
+
z7.object({
|
|
2777
|
+
web: z7.object({ uri: z7.string(), title: z7.string().nullish() }).nullish(),
|
|
2778
|
+
image: z7.object({
|
|
2779
|
+
sourceUri: z7.string(),
|
|
2780
|
+
imageUri: z7.string(),
|
|
2781
|
+
title: z7.string().nullish(),
|
|
2782
|
+
domain: z7.string().nullish()
|
|
2530
2783
|
}).nullish(),
|
|
2531
|
-
retrievedContext:
|
|
2532
|
-
uri:
|
|
2533
|
-
title:
|
|
2534
|
-
text:
|
|
2535
|
-
fileSearchStore:
|
|
2784
|
+
retrievedContext: z7.object({
|
|
2785
|
+
uri: z7.string().nullish(),
|
|
2786
|
+
title: z7.string().nullish(),
|
|
2787
|
+
text: z7.string().nullish(),
|
|
2788
|
+
fileSearchStore: z7.string().nullish()
|
|
2536
2789
|
}).nullish(),
|
|
2537
|
-
maps:
|
|
2538
|
-
uri:
|
|
2539
|
-
title:
|
|
2540
|
-
text:
|
|
2541
|
-
placeId:
|
|
2790
|
+
maps: z7.object({
|
|
2791
|
+
uri: z7.string().nullish(),
|
|
2792
|
+
title: z7.string().nullish(),
|
|
2793
|
+
text: z7.string().nullish(),
|
|
2794
|
+
placeId: z7.string().nullish()
|
|
2542
2795
|
}).nullish()
|
|
2543
2796
|
})
|
|
2544
2797
|
).nullish(),
|
|
2545
|
-
groundingSupports:
|
|
2546
|
-
|
|
2547
|
-
segment:
|
|
2548
|
-
startIndex:
|
|
2549
|
-
endIndex:
|
|
2550
|
-
text:
|
|
2798
|
+
groundingSupports: z7.array(
|
|
2799
|
+
z7.object({
|
|
2800
|
+
segment: z7.object({
|
|
2801
|
+
startIndex: z7.number().nullish(),
|
|
2802
|
+
endIndex: z7.number().nullish(),
|
|
2803
|
+
text: z7.string().nullish()
|
|
2551
2804
|
}).nullish(),
|
|
2552
|
-
segment_text:
|
|
2553
|
-
groundingChunkIndices:
|
|
2554
|
-
supportChunkIndices:
|
|
2555
|
-
confidenceScores:
|
|
2556
|
-
confidenceScore:
|
|
2805
|
+
segment_text: z7.string().nullish(),
|
|
2806
|
+
groundingChunkIndices: z7.array(z7.number()).nullish(),
|
|
2807
|
+
supportChunkIndices: z7.array(z7.number()).nullish(),
|
|
2808
|
+
confidenceScores: z7.array(z7.number()).nullish(),
|
|
2809
|
+
confidenceScore: z7.array(z7.number()).nullish()
|
|
2557
2810
|
})
|
|
2558
2811
|
).nullish(),
|
|
2559
|
-
retrievalMetadata:
|
|
2560
|
-
|
|
2561
|
-
webDynamicRetrievalScore:
|
|
2812
|
+
retrievalMetadata: z7.union([
|
|
2813
|
+
z7.object({
|
|
2814
|
+
webDynamicRetrievalScore: z7.number()
|
|
2562
2815
|
}),
|
|
2563
|
-
|
|
2816
|
+
z7.object({})
|
|
2564
2817
|
]).nullish()
|
|
2565
2818
|
});
|
|
2566
|
-
var partialArgSchema =
|
|
2567
|
-
jsonPath:
|
|
2568
|
-
stringValue:
|
|
2569
|
-
numberValue:
|
|
2570
|
-
boolValue:
|
|
2571
|
-
nullValue:
|
|
2572
|
-
willContinue:
|
|
2819
|
+
var partialArgSchema = z7.object({
|
|
2820
|
+
jsonPath: z7.string(),
|
|
2821
|
+
stringValue: z7.string().nullish(),
|
|
2822
|
+
numberValue: z7.number().nullish(),
|
|
2823
|
+
boolValue: z7.boolean().nullish(),
|
|
2824
|
+
nullValue: z7.unknown().nullish(),
|
|
2825
|
+
willContinue: z7.boolean().nullish()
|
|
2573
2826
|
});
|
|
2574
|
-
var getContentSchema = () =>
|
|
2575
|
-
parts:
|
|
2576
|
-
|
|
2827
|
+
var getContentSchema = () => z7.object({
|
|
2828
|
+
parts: z7.array(
|
|
2829
|
+
z7.union([
|
|
2577
2830
|
// note: order matters since text can be fully empty
|
|
2578
|
-
|
|
2579
|
-
functionCall:
|
|
2580
|
-
id:
|
|
2581
|
-
name:
|
|
2582
|
-
args:
|
|
2583
|
-
partialArgs:
|
|
2584
|
-
willContinue:
|
|
2831
|
+
z7.object({
|
|
2832
|
+
functionCall: z7.object({
|
|
2833
|
+
id: z7.string().nullish(),
|
|
2834
|
+
name: z7.string().nullish(),
|
|
2835
|
+
args: z7.unknown().nullish(),
|
|
2836
|
+
partialArgs: z7.array(partialArgSchema).nullish(),
|
|
2837
|
+
willContinue: z7.boolean().nullish()
|
|
2585
2838
|
}),
|
|
2586
|
-
thoughtSignature:
|
|
2839
|
+
thoughtSignature: z7.string().nullish()
|
|
2587
2840
|
}),
|
|
2588
|
-
|
|
2589
|
-
inlineData:
|
|
2590
|
-
mimeType:
|
|
2591
|
-
data:
|
|
2841
|
+
z7.object({
|
|
2842
|
+
inlineData: z7.object({
|
|
2843
|
+
mimeType: z7.string(),
|
|
2844
|
+
data: z7.string()
|
|
2592
2845
|
}),
|
|
2593
|
-
thought:
|
|
2594
|
-
thoughtSignature:
|
|
2846
|
+
thought: z7.boolean().nullish(),
|
|
2847
|
+
thoughtSignature: z7.string().nullish()
|
|
2595
2848
|
}),
|
|
2596
|
-
|
|
2597
|
-
toolCall:
|
|
2598
|
-
toolType:
|
|
2599
|
-
args:
|
|
2600
|
-
id:
|
|
2849
|
+
z7.object({
|
|
2850
|
+
toolCall: z7.object({
|
|
2851
|
+
toolType: z7.string(),
|
|
2852
|
+
args: z7.unknown().nullish(),
|
|
2853
|
+
id: z7.string()
|
|
2601
2854
|
}),
|
|
2602
|
-
thoughtSignature:
|
|
2855
|
+
thoughtSignature: z7.string().nullish()
|
|
2603
2856
|
}),
|
|
2604
|
-
|
|
2605
|
-
toolResponse:
|
|
2606
|
-
toolType:
|
|
2607
|
-
response:
|
|
2608
|
-
id:
|
|
2857
|
+
z7.object({
|
|
2858
|
+
toolResponse: z7.object({
|
|
2859
|
+
toolType: z7.string(),
|
|
2860
|
+
response: z7.unknown().nullish(),
|
|
2861
|
+
id: z7.string()
|
|
2609
2862
|
}),
|
|
2610
|
-
thoughtSignature:
|
|
2863
|
+
thoughtSignature: z7.string().nullish()
|
|
2611
2864
|
}),
|
|
2612
|
-
|
|
2613
|
-
executableCode:
|
|
2614
|
-
language:
|
|
2615
|
-
code:
|
|
2865
|
+
z7.object({
|
|
2866
|
+
executableCode: z7.object({
|
|
2867
|
+
language: z7.string(),
|
|
2868
|
+
code: z7.string()
|
|
2616
2869
|
}).nullish(),
|
|
2617
|
-
codeExecutionResult:
|
|
2618
|
-
outcome:
|
|
2619
|
-
output:
|
|
2870
|
+
codeExecutionResult: z7.object({
|
|
2871
|
+
outcome: z7.string(),
|
|
2872
|
+
output: z7.string().nullish()
|
|
2620
2873
|
}).nullish(),
|
|
2621
|
-
text:
|
|
2622
|
-
thought:
|
|
2623
|
-
thoughtSignature:
|
|
2874
|
+
text: z7.string().nullish(),
|
|
2875
|
+
thought: z7.boolean().nullish(),
|
|
2876
|
+
thoughtSignature: z7.string().nullish()
|
|
2624
2877
|
})
|
|
2625
2878
|
])
|
|
2626
2879
|
).nullish()
|
|
2627
2880
|
});
|
|
2628
|
-
var getSafetyRatingSchema = () =>
|
|
2629
|
-
category:
|
|
2630
|
-
probability:
|
|
2631
|
-
probabilityScore:
|
|
2632
|
-
severity:
|
|
2633
|
-
severityScore:
|
|
2634
|
-
blocked:
|
|
2881
|
+
var getSafetyRatingSchema = () => z7.object({
|
|
2882
|
+
category: z7.string().nullish(),
|
|
2883
|
+
probability: z7.string().nullish(),
|
|
2884
|
+
probabilityScore: z7.number().nullish(),
|
|
2885
|
+
severity: z7.string().nullish(),
|
|
2886
|
+
severityScore: z7.number().nullish(),
|
|
2887
|
+
blocked: z7.boolean().nullish()
|
|
2635
2888
|
});
|
|
2636
|
-
var tokenDetailsSchema =
|
|
2637
|
-
|
|
2638
|
-
modality:
|
|
2639
|
-
tokenCount:
|
|
2889
|
+
var tokenDetailsSchema = z7.array(
|
|
2890
|
+
z7.object({
|
|
2891
|
+
modality: z7.string(),
|
|
2892
|
+
tokenCount: z7.number()
|
|
2640
2893
|
})
|
|
2641
2894
|
).nullish();
|
|
2642
|
-
var usageSchema =
|
|
2643
|
-
cachedContentTokenCount:
|
|
2644
|
-
thoughtsTokenCount:
|
|
2645
|
-
promptTokenCount:
|
|
2646
|
-
candidatesTokenCount:
|
|
2647
|
-
totalTokenCount:
|
|
2895
|
+
var usageSchema = z7.object({
|
|
2896
|
+
cachedContentTokenCount: z7.number().nullish(),
|
|
2897
|
+
thoughtsTokenCount: z7.number().nullish(),
|
|
2898
|
+
promptTokenCount: z7.number().nullish(),
|
|
2899
|
+
candidatesTokenCount: z7.number().nullish(),
|
|
2900
|
+
totalTokenCount: z7.number().nullish(),
|
|
2648
2901
|
// https://cloud.google.com/vertex-ai/generative-ai/docs/reference/rest/v1/GenerateContentResponse#TrafficType
|
|
2649
|
-
trafficType:
|
|
2650
|
-
serviceTier:
|
|
2902
|
+
trafficType: z7.string().nullish(),
|
|
2903
|
+
serviceTier: z7.string().nullish(),
|
|
2651
2904
|
// https://ai.google.dev/api/generate-content#Modality
|
|
2652
2905
|
promptTokensDetails: tokenDetailsSchema,
|
|
2653
2906
|
candidatesTokensDetails: tokenDetailsSchema
|
|
2654
2907
|
});
|
|
2655
|
-
var getUrlContextMetadataSchema = () =>
|
|
2656
|
-
urlMetadata:
|
|
2657
|
-
|
|
2658
|
-
retrievedUrl:
|
|
2659
|
-
urlRetrievalStatus:
|
|
2908
|
+
var getUrlContextMetadataSchema = () => z7.object({
|
|
2909
|
+
urlMetadata: z7.array(
|
|
2910
|
+
z7.object({
|
|
2911
|
+
retrievedUrl: z7.string(),
|
|
2912
|
+
urlRetrievalStatus: z7.string()
|
|
2660
2913
|
})
|
|
2661
2914
|
).nullish()
|
|
2662
2915
|
});
|
|
2663
2916
|
var responseSchema = lazySchema5(
|
|
2664
2917
|
() => zodSchema5(
|
|
2665
|
-
|
|
2666
|
-
responseId:
|
|
2667
|
-
candidates:
|
|
2668
|
-
|
|
2669
|
-
content: getContentSchema().nullish().or(
|
|
2670
|
-
finishReason:
|
|
2671
|
-
finishMessage:
|
|
2672
|
-
safetyRatings:
|
|
2918
|
+
z7.object({
|
|
2919
|
+
responseId: z7.string().nullish(),
|
|
2920
|
+
candidates: z7.array(
|
|
2921
|
+
z7.object({
|
|
2922
|
+
content: getContentSchema().nullish().or(z7.object({}).strict()),
|
|
2923
|
+
finishReason: z7.string().nullish(),
|
|
2924
|
+
finishMessage: z7.string().nullish(),
|
|
2925
|
+
safetyRatings: z7.array(getSafetyRatingSchema()).nullish(),
|
|
2673
2926
|
groundingMetadata: getGroundingMetadataSchema().nullish(),
|
|
2674
2927
|
urlContextMetadata: getUrlContextMetadataSchema().nullish()
|
|
2675
2928
|
})
|
|
2676
2929
|
),
|
|
2677
2930
|
usageMetadata: usageSchema.nullish(),
|
|
2678
|
-
promptFeedback:
|
|
2679
|
-
blockReason:
|
|
2680
|
-
safetyRatings:
|
|
2931
|
+
promptFeedback: z7.object({
|
|
2932
|
+
blockReason: z7.string().nullish(),
|
|
2933
|
+
safetyRatings: z7.array(getSafetyRatingSchema()).nullish()
|
|
2681
2934
|
}).nullish()
|
|
2682
2935
|
})
|
|
2683
2936
|
)
|
|
2684
2937
|
);
|
|
2685
2938
|
var chunkSchema = lazySchema5(
|
|
2686
2939
|
() => zodSchema5(
|
|
2687
|
-
|
|
2688
|
-
responseId:
|
|
2689
|
-
candidates:
|
|
2690
|
-
|
|
2940
|
+
z7.object({
|
|
2941
|
+
responseId: z7.string().nullish(),
|
|
2942
|
+
candidates: z7.array(
|
|
2943
|
+
z7.object({
|
|
2691
2944
|
content: getContentSchema().nullish(),
|
|
2692
|
-
finishReason:
|
|
2693
|
-
finishMessage:
|
|
2694
|
-
safetyRatings:
|
|
2945
|
+
finishReason: z7.string().nullish(),
|
|
2946
|
+
finishMessage: z7.string().nullish(),
|
|
2947
|
+
safetyRatings: z7.array(getSafetyRatingSchema()).nullish(),
|
|
2695
2948
|
groundingMetadata: getGroundingMetadataSchema().nullish(),
|
|
2696
2949
|
urlContextMetadata: getUrlContextMetadataSchema().nullish()
|
|
2697
2950
|
})
|
|
2698
2951
|
).nullish(),
|
|
2699
2952
|
usageMetadata: usageSchema.nullish(),
|
|
2700
|
-
promptFeedback:
|
|
2701
|
-
blockReason:
|
|
2702
|
-
safetyRatings:
|
|
2953
|
+
promptFeedback: z7.object({
|
|
2954
|
+
blockReason: z7.string().nullish(),
|
|
2955
|
+
safetyRatings: z7.array(getSafetyRatingSchema()).nullish()
|
|
2703
2956
|
}).nullish()
|
|
2704
2957
|
})
|
|
2705
2958
|
)
|
|
@@ -2707,16 +2960,16 @@ var chunkSchema = lazySchema5(
|
|
|
2707
2960
|
|
|
2708
2961
|
// src/tool/code-execution.ts
|
|
2709
2962
|
import { createProviderToolFactoryWithOutputSchema } from "@ai-sdk/provider-utils";
|
|
2710
|
-
import { z as
|
|
2963
|
+
import { z as z8 } from "zod/v4";
|
|
2711
2964
|
var codeExecution = createProviderToolFactoryWithOutputSchema({
|
|
2712
2965
|
id: "google.code_execution",
|
|
2713
|
-
inputSchema:
|
|
2714
|
-
language:
|
|
2715
|
-
code:
|
|
2966
|
+
inputSchema: z8.object({
|
|
2967
|
+
language: z8.string().describe("The programming language of the code."),
|
|
2968
|
+
code: z8.string().describe("The code to be executed.")
|
|
2716
2969
|
}),
|
|
2717
|
-
outputSchema:
|
|
2718
|
-
outcome:
|
|
2719
|
-
output:
|
|
2970
|
+
outputSchema: z8.object({
|
|
2971
|
+
outcome: z8.string().describe('The outcome of the execution (e.g., "OUTCOME_OK").'),
|
|
2972
|
+
output: z8.string().describe("The output from the code execution.")
|
|
2720
2973
|
})
|
|
2721
2974
|
});
|
|
2722
2975
|
|
|
@@ -2726,10 +2979,10 @@ import {
|
|
|
2726
2979
|
lazySchema as lazySchema6,
|
|
2727
2980
|
zodSchema as zodSchema6
|
|
2728
2981
|
} from "@ai-sdk/provider-utils";
|
|
2729
|
-
import { z as
|
|
2982
|
+
import { z as z9 } from "zod/v4";
|
|
2730
2983
|
var enterpriseWebSearch = createProviderToolFactory({
|
|
2731
2984
|
id: "google.enterprise_web_search",
|
|
2732
|
-
inputSchema: lazySchema6(() => zodSchema6(
|
|
2985
|
+
inputSchema: lazySchema6(() => zodSchema6(z9.object({})))
|
|
2733
2986
|
});
|
|
2734
2987
|
|
|
2735
2988
|
// src/tool/file-search.ts
|
|
@@ -2738,20 +2991,20 @@ import {
|
|
|
2738
2991
|
lazySchema as lazySchema7,
|
|
2739
2992
|
zodSchema as zodSchema7
|
|
2740
2993
|
} from "@ai-sdk/provider-utils";
|
|
2741
|
-
import { z as
|
|
2742
|
-
var fileSearchArgsBaseSchema =
|
|
2994
|
+
import { z as z10 } from "zod/v4";
|
|
2995
|
+
var fileSearchArgsBaseSchema = z10.object({
|
|
2743
2996
|
/** The names of the file_search_stores to retrieve from.
|
|
2744
2997
|
* Example: `fileSearchStores/my-file-search-store-123`
|
|
2745
2998
|
*/
|
|
2746
|
-
fileSearchStoreNames:
|
|
2999
|
+
fileSearchStoreNames: z10.array(z10.string()).describe(
|
|
2747
3000
|
"The names of the file_search_stores to retrieve from. Example: `fileSearchStores/my-file-search-store-123`"
|
|
2748
3001
|
),
|
|
2749
3002
|
/** The number of file search retrieval chunks to retrieve. */
|
|
2750
|
-
topK:
|
|
3003
|
+
topK: z10.number().int().positive().describe("The number of file search retrieval chunks to retrieve.").optional(),
|
|
2751
3004
|
/** Metadata filter to apply to the file search retrieval documents.
|
|
2752
3005
|
* See https://google.aip.dev/160 for the syntax of the filter expression.
|
|
2753
3006
|
*/
|
|
2754
|
-
metadataFilter:
|
|
3007
|
+
metadataFilter: z10.string().describe(
|
|
2755
3008
|
"Metadata filter to apply to the file search retrieval documents. See https://google.aip.dev/160 for the syntax of the filter expression."
|
|
2756
3009
|
).optional()
|
|
2757
3010
|
}).passthrough();
|
|
@@ -2769,10 +3022,10 @@ import {
|
|
|
2769
3022
|
lazySchema as lazySchema8,
|
|
2770
3023
|
zodSchema as zodSchema8
|
|
2771
3024
|
} from "@ai-sdk/provider-utils";
|
|
2772
|
-
import { z as
|
|
3025
|
+
import { z as z11 } from "zod/v4";
|
|
2773
3026
|
var googleMaps = createProviderToolFactory3({
|
|
2774
3027
|
id: "google.google_maps",
|
|
2775
|
-
inputSchema: lazySchema8(() => zodSchema8(
|
|
3028
|
+
inputSchema: lazySchema8(() => zodSchema8(z11.object({})))
|
|
2776
3029
|
});
|
|
2777
3030
|
|
|
2778
3031
|
// src/tool/google-search.ts
|
|
@@ -2781,15 +3034,15 @@ import {
|
|
|
2781
3034
|
lazySchema as lazySchema9,
|
|
2782
3035
|
zodSchema as zodSchema9
|
|
2783
3036
|
} from "@ai-sdk/provider-utils";
|
|
2784
|
-
import { z as
|
|
2785
|
-
var googleSearchToolArgsBaseSchema =
|
|
2786
|
-
searchTypes:
|
|
2787
|
-
webSearch:
|
|
2788
|
-
imageSearch:
|
|
3037
|
+
import { z as z12 } from "zod/v4";
|
|
3038
|
+
var googleSearchToolArgsBaseSchema = z12.object({
|
|
3039
|
+
searchTypes: z12.object({
|
|
3040
|
+
webSearch: z12.object({}).optional(),
|
|
3041
|
+
imageSearch: z12.object({}).optional()
|
|
2789
3042
|
}).optional(),
|
|
2790
|
-
timeRangeFilter:
|
|
2791
|
-
startTime:
|
|
2792
|
-
endTime:
|
|
3043
|
+
timeRangeFilter: z12.object({
|
|
3044
|
+
startTime: z12.string(),
|
|
3045
|
+
endTime: z12.string()
|
|
2793
3046
|
}).optional()
|
|
2794
3047
|
}).passthrough();
|
|
2795
3048
|
var googleSearchToolArgsSchema = lazySchema9(
|
|
@@ -2808,20 +3061,20 @@ import {
|
|
|
2808
3061
|
lazySchema as lazySchema10,
|
|
2809
3062
|
zodSchema as zodSchema10
|
|
2810
3063
|
} from "@ai-sdk/provider-utils";
|
|
2811
|
-
import { z as
|
|
3064
|
+
import { z as z13 } from "zod/v4";
|
|
2812
3065
|
var urlContext = createProviderToolFactory5({
|
|
2813
3066
|
id: "google.url_context",
|
|
2814
|
-
inputSchema: lazySchema10(() => zodSchema10(
|
|
3067
|
+
inputSchema: lazySchema10(() => zodSchema10(z13.object({})))
|
|
2815
3068
|
});
|
|
2816
3069
|
|
|
2817
3070
|
// src/tool/vertex-rag-store.ts
|
|
2818
3071
|
import { createProviderToolFactory as createProviderToolFactory6 } from "@ai-sdk/provider-utils";
|
|
2819
|
-
import { z as
|
|
3072
|
+
import { z as z14 } from "zod/v4";
|
|
2820
3073
|
var vertexRagStore = createProviderToolFactory6({
|
|
2821
3074
|
id: "google.vertex_rag_store",
|
|
2822
|
-
inputSchema:
|
|
2823
|
-
ragCorpus:
|
|
2824
|
-
topK:
|
|
3075
|
+
inputSchema: z14.object({
|
|
3076
|
+
ragCorpus: z14.string(),
|
|
3077
|
+
topK: z14.number().optional()
|
|
2825
3078
|
})
|
|
2826
3079
|
});
|
|
2827
3080
|
|
|
@@ -2887,17 +3140,17 @@ var googleTools = {
|
|
|
2887
3140
|
|
|
2888
3141
|
// src/google-generative-ai-image-model.ts
|
|
2889
3142
|
import {
|
|
2890
|
-
combineHeaders as
|
|
2891
|
-
convertToBase64 as
|
|
2892
|
-
createJsonResponseHandler as
|
|
3143
|
+
combineHeaders as combineHeaders4,
|
|
3144
|
+
convertToBase64 as convertToBase643,
|
|
3145
|
+
createJsonResponseHandler as createJsonResponseHandler4,
|
|
2893
3146
|
generateId as defaultGenerateId,
|
|
2894
3147
|
lazySchema as lazySchema11,
|
|
2895
|
-
parseProviderOptions as
|
|
2896
|
-
postJsonToApi as
|
|
2897
|
-
resolve as
|
|
3148
|
+
parseProviderOptions as parseProviderOptions4,
|
|
3149
|
+
postJsonToApi as postJsonToApi4,
|
|
3150
|
+
resolve as resolve4,
|
|
2898
3151
|
zodSchema as zodSchema11
|
|
2899
3152
|
} from "@ai-sdk/provider-utils";
|
|
2900
|
-
import { z as
|
|
3153
|
+
import { z as z15 } from "zod/v4";
|
|
2901
3154
|
var GoogleGenerativeAIImageModel = class {
|
|
2902
3155
|
constructor(modelId, settings, config) {
|
|
2903
3156
|
this.modelId = modelId;
|
|
@@ -2962,7 +3215,7 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
2962
3215
|
details: "This model does not support the `seed` option through this provider."
|
|
2963
3216
|
});
|
|
2964
3217
|
}
|
|
2965
|
-
const googleOptions = await
|
|
3218
|
+
const googleOptions = await parseProviderOptions4({
|
|
2966
3219
|
provider: "google",
|
|
2967
3220
|
providerOptions,
|
|
2968
3221
|
schema: googleImageModelOptionsSchema
|
|
@@ -2989,12 +3242,12 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
2989
3242
|
instances: [{ prompt }],
|
|
2990
3243
|
parameters
|
|
2991
3244
|
};
|
|
2992
|
-
const { responseHeaders, value: response } = await
|
|
3245
|
+
const { responseHeaders, value: response } = await postJsonToApi4({
|
|
2993
3246
|
url: `${this.config.baseURL}/models/${this.modelId}:predict`,
|
|
2994
|
-
headers:
|
|
3247
|
+
headers: combineHeaders4(await resolve4(this.config.headers), headers),
|
|
2995
3248
|
body,
|
|
2996
3249
|
failedResponseHandler: googleFailedResponseHandler,
|
|
2997
|
-
successfulResponseHandler:
|
|
3250
|
+
successfulResponseHandler: createJsonResponseHandler4(
|
|
2998
3251
|
googleImageResponseSchema
|
|
2999
3252
|
),
|
|
3000
3253
|
abortSignal,
|
|
@@ -3075,7 +3328,7 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
3075
3328
|
const languageModelPrompt = [
|
|
3076
3329
|
{ role: "user", content: userContent }
|
|
3077
3330
|
];
|
|
3078
|
-
const googleImageOptions = await
|
|
3331
|
+
const googleImageOptions = await parseProviderOptions4({
|
|
3079
3332
|
provider: "google",
|
|
3080
3333
|
providerOptions,
|
|
3081
3334
|
schema: googleImageModelOptionsSchema
|
|
@@ -3115,7 +3368,7 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
3115
3368
|
const images = [];
|
|
3116
3369
|
for (const part of result.content) {
|
|
3117
3370
|
if (part.type === "file" && part.mediaType.startsWith("image/")) {
|
|
3118
|
-
images.push(
|
|
3371
|
+
images.push(convertToBase643(part.data));
|
|
3119
3372
|
}
|
|
3120
3373
|
}
|
|
3121
3374
|
const languageModelGoogleMetadata = (_h = (_g = result.providerMetadata) == null ? void 0 : _g.google) != null ? _h : {};
|
|
@@ -3146,16 +3399,16 @@ function isGeminiModel(modelId) {
|
|
|
3146
3399
|
}
|
|
3147
3400
|
var googleImageResponseSchema = lazySchema11(
|
|
3148
3401
|
() => zodSchema11(
|
|
3149
|
-
|
|
3150
|
-
predictions:
|
|
3402
|
+
z15.object({
|
|
3403
|
+
predictions: z15.array(z15.object({ bytesBase64Encoded: z15.string() })).default([])
|
|
3151
3404
|
})
|
|
3152
3405
|
)
|
|
3153
3406
|
);
|
|
3154
3407
|
var googleImageModelOptionsSchema = lazySchema11(
|
|
3155
3408
|
() => zodSchema11(
|
|
3156
|
-
|
|
3157
|
-
personGeneration:
|
|
3158
|
-
aspectRatio:
|
|
3409
|
+
z15.object({
|
|
3410
|
+
personGeneration: z15.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
|
|
3411
|
+
aspectRatio: z15.enum(["1:1", "3:4", "4:3", "9:16", "16:9"]).nullish(),
|
|
3159
3412
|
/**
|
|
3160
3413
|
* Enable Google Search grounding for Gemini image models. The value is
|
|
3161
3414
|
* forwarded as the args of the `google.tools.googleSearch` provider
|
|
@@ -3175,19 +3428,19 @@ import {
|
|
|
3175
3428
|
AISDKError
|
|
3176
3429
|
} from "@ai-sdk/provider";
|
|
3177
3430
|
import {
|
|
3178
|
-
combineHeaders as
|
|
3431
|
+
combineHeaders as combineHeaders5,
|
|
3179
3432
|
convertUint8ArrayToBase64,
|
|
3180
|
-
createJsonResponseHandler as
|
|
3433
|
+
createJsonResponseHandler as createJsonResponseHandler5,
|
|
3181
3434
|
delay,
|
|
3182
3435
|
getFromApi,
|
|
3183
3436
|
isSameOrigin,
|
|
3184
3437
|
lazySchema as lazySchema12,
|
|
3185
|
-
parseProviderOptions as
|
|
3186
|
-
postJsonToApi as
|
|
3187
|
-
resolve as
|
|
3438
|
+
parseProviderOptions as parseProviderOptions5,
|
|
3439
|
+
postJsonToApi as postJsonToApi5,
|
|
3440
|
+
resolve as resolve5,
|
|
3188
3441
|
zodSchema as zodSchema12
|
|
3189
3442
|
} from "@ai-sdk/provider-utils";
|
|
3190
|
-
import { z as
|
|
3443
|
+
import { z as z16 } from "zod/v4";
|
|
3191
3444
|
function getFirstFrameImage(options) {
|
|
3192
3445
|
var _a, _b;
|
|
3193
3446
|
return (_b = (_a = options.frameImages) == null ? void 0 : _a.find((frame) => frame.frameType === "first_frame")) == null ? void 0 : _b.image;
|
|
@@ -3266,7 +3519,7 @@ var GoogleGenerativeAIVideoModel = class {
|
|
|
3266
3519
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
3267
3520
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
3268
3521
|
const warnings = [];
|
|
3269
|
-
const googleOptions = await
|
|
3522
|
+
const googleOptions = await parseProviderOptions5({
|
|
3270
3523
|
provider: "google",
|
|
3271
3524
|
providerOptions: options.providerOptions,
|
|
3272
3525
|
schema: googleVideoModelOptionsSchema
|
|
@@ -3341,17 +3594,17 @@ var GoogleGenerativeAIVideoModel = class {
|
|
|
3341
3594
|
}
|
|
3342
3595
|
}
|
|
3343
3596
|
}
|
|
3344
|
-
const { value: operation } = await
|
|
3597
|
+
const { value: operation } = await postJsonToApi5({
|
|
3345
3598
|
url: `${this.config.baseURL}/models/${this.modelId}:predictLongRunning`,
|
|
3346
|
-
headers:
|
|
3347
|
-
await
|
|
3599
|
+
headers: combineHeaders5(
|
|
3600
|
+
await resolve5(this.config.headers),
|
|
3348
3601
|
options.headers
|
|
3349
3602
|
),
|
|
3350
3603
|
body: {
|
|
3351
3604
|
instances,
|
|
3352
3605
|
parameters
|
|
3353
3606
|
},
|
|
3354
|
-
successfulResponseHandler:
|
|
3607
|
+
successfulResponseHandler: createJsonResponseHandler5(
|
|
3355
3608
|
googleOperationSchema
|
|
3356
3609
|
),
|
|
3357
3610
|
failedResponseHandler: googleFailedResponseHandler,
|
|
@@ -3386,11 +3639,11 @@ var GoogleGenerativeAIVideoModel = class {
|
|
|
3386
3639
|
}
|
|
3387
3640
|
const { value: statusOperation, responseHeaders: pollHeaders } = await getFromApi({
|
|
3388
3641
|
url: `${this.config.baseURL}/${operationName}`,
|
|
3389
|
-
headers:
|
|
3390
|
-
await
|
|
3642
|
+
headers: combineHeaders5(
|
|
3643
|
+
await resolve5(this.config.headers),
|
|
3391
3644
|
options.headers
|
|
3392
3645
|
),
|
|
3393
|
-
successfulResponseHandler:
|
|
3646
|
+
successfulResponseHandler: createJsonResponseHandler5(
|
|
3394
3647
|
googleOperationSchema
|
|
3395
3648
|
),
|
|
3396
3649
|
failedResponseHandler: googleFailedResponseHandler,
|
|
@@ -3415,7 +3668,7 @@ var GoogleGenerativeAIVideoModel = class {
|
|
|
3415
3668
|
}
|
|
3416
3669
|
const videos = [];
|
|
3417
3670
|
const videoMetadata = [];
|
|
3418
|
-
const resolvedHeaders = await
|
|
3671
|
+
const resolvedHeaders = await resolve5(this.config.headers);
|
|
3419
3672
|
const apiKey = resolvedHeaders == null ? void 0 : resolvedHeaders["x-goog-api-key"];
|
|
3420
3673
|
for (const generatedSample of response.generateVideoResponse.generatedSamples) {
|
|
3421
3674
|
if ((_h = generatedSample.video) == null ? void 0 : _h.uri) {
|
|
@@ -3452,20 +3705,20 @@ var GoogleGenerativeAIVideoModel = class {
|
|
|
3452
3705
|
};
|
|
3453
3706
|
}
|
|
3454
3707
|
};
|
|
3455
|
-
var googleOperationSchema =
|
|
3456
|
-
name:
|
|
3457
|
-
done:
|
|
3458
|
-
error:
|
|
3459
|
-
code:
|
|
3460
|
-
message:
|
|
3461
|
-
status:
|
|
3708
|
+
var googleOperationSchema = z16.object({
|
|
3709
|
+
name: z16.string().nullish(),
|
|
3710
|
+
done: z16.boolean().nullish(),
|
|
3711
|
+
error: z16.object({
|
|
3712
|
+
code: z16.number().nullish(),
|
|
3713
|
+
message: z16.string(),
|
|
3714
|
+
status: z16.string().nullish()
|
|
3462
3715
|
}).nullish(),
|
|
3463
|
-
response:
|
|
3464
|
-
generateVideoResponse:
|
|
3465
|
-
generatedSamples:
|
|
3466
|
-
|
|
3467
|
-
video:
|
|
3468
|
-
uri:
|
|
3716
|
+
response: z16.object({
|
|
3717
|
+
generateVideoResponse: z16.object({
|
|
3718
|
+
generatedSamples: z16.array(
|
|
3719
|
+
z16.object({
|
|
3720
|
+
video: z16.object({
|
|
3721
|
+
uri: z16.string().nullish()
|
|
3469
3722
|
}).nullish()
|
|
3470
3723
|
})
|
|
3471
3724
|
).nullish()
|
|
@@ -3474,15 +3727,15 @@ var googleOperationSchema = z14.object({
|
|
|
3474
3727
|
});
|
|
3475
3728
|
var googleVideoModelOptionsSchema = lazySchema12(
|
|
3476
3729
|
() => zodSchema12(
|
|
3477
|
-
|
|
3478
|
-
pollIntervalMs:
|
|
3479
|
-
pollTimeoutMs:
|
|
3480
|
-
personGeneration:
|
|
3481
|
-
negativePrompt:
|
|
3482
|
-
referenceImages:
|
|
3483
|
-
|
|
3484
|
-
bytesBase64Encoded:
|
|
3485
|
-
gcsUri:
|
|
3730
|
+
z16.object({
|
|
3731
|
+
pollIntervalMs: z16.number().positive().nullish(),
|
|
3732
|
+
pollTimeoutMs: z16.number().positive().nullish(),
|
|
3733
|
+
personGeneration: z16.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
|
|
3734
|
+
negativePrompt: z16.string().nullish(),
|
|
3735
|
+
referenceImages: z16.array(
|
|
3736
|
+
z16.object({
|
|
3737
|
+
bytesBase64Encoded: z16.string().nullish(),
|
|
3738
|
+
gcsUri: z16.string().nullish()
|
|
3486
3739
|
})
|
|
3487
3740
|
).nullish()
|
|
3488
3741
|
}).passthrough()
|
|
@@ -3491,13 +3744,13 @@ var googleVideoModelOptionsSchema = lazySchema12(
|
|
|
3491
3744
|
|
|
3492
3745
|
// src/interactions/google-interactions-language-model.ts
|
|
3493
3746
|
import {
|
|
3494
|
-
combineHeaders as
|
|
3747
|
+
combineHeaders as combineHeaders7,
|
|
3495
3748
|
createEventSourceResponseHandler as createEventSourceResponseHandler3,
|
|
3496
|
-
createJsonResponseHandler as
|
|
3749
|
+
createJsonResponseHandler as createJsonResponseHandler7,
|
|
3497
3750
|
generateId as defaultGenerateId2,
|
|
3498
|
-
parseProviderOptions as
|
|
3499
|
-
postJsonToApi as
|
|
3500
|
-
resolve as
|
|
3751
|
+
parseProviderOptions as parseProviderOptions6,
|
|
3752
|
+
postJsonToApi as postJsonToApi6,
|
|
3753
|
+
resolve as resolve6
|
|
3501
3754
|
} from "@ai-sdk/provider-utils";
|
|
3502
3755
|
|
|
3503
3756
|
// src/interactions/convert-google-interactions-usage.ts
|
|
@@ -4264,7 +4517,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
4264
4517
|
}
|
|
4265
4518
|
|
|
4266
4519
|
// src/interactions/convert-to-google-interactions-input.ts
|
|
4267
|
-
import { convertToBase64 as
|
|
4520
|
+
import { convertToBase64 as convertToBase644, secureJsonParse as secureJsonParse2 } from "@ai-sdk/provider-utils";
|
|
4268
4521
|
function getTopLevelMediaType(mediaType) {
|
|
4269
4522
|
const slashIndex = mediaType.indexOf("/");
|
|
4270
4523
|
return slashIndex === -1 ? mediaType : mediaType.substring(0, slashIndex);
|
|
@@ -4453,7 +4706,7 @@ function convertFilePartToContent({
|
|
|
4453
4706
|
}
|
|
4454
4707
|
return {
|
|
4455
4708
|
type: kind,
|
|
4456
|
-
data:
|
|
4709
|
+
data: convertToBase644(part.data),
|
|
4457
4710
|
mime_type: part.mediaType,
|
|
4458
4711
|
...resolutionField
|
|
4459
4712
|
};
|
|
@@ -4627,7 +4880,7 @@ function filePartToImageBlock({
|
|
|
4627
4880
|
}
|
|
4628
4881
|
return {
|
|
4629
4882
|
type: "image",
|
|
4630
|
-
data:
|
|
4883
|
+
data: convertToBase644(part.data),
|
|
4631
4884
|
mime_type: part.mediaType
|
|
4632
4885
|
};
|
|
4633
4886
|
}
|
|
@@ -4658,30 +4911,30 @@ import {
|
|
|
4658
4911
|
lazySchema as lazySchema13,
|
|
4659
4912
|
zodSchema as zodSchema13
|
|
4660
4913
|
} from "@ai-sdk/provider-utils";
|
|
4661
|
-
import { z as
|
|
4662
|
-
var tokenByModalitySchema = () =>
|
|
4663
|
-
modality:
|
|
4664
|
-
tokens:
|
|
4914
|
+
import { z as z17 } from "zod/v4";
|
|
4915
|
+
var tokenByModalitySchema = () => z17.object({
|
|
4916
|
+
modality: z17.string().nullish(),
|
|
4917
|
+
tokens: z17.number().nullish()
|
|
4665
4918
|
}).loose();
|
|
4666
|
-
var usageSchema2 = () =>
|
|
4667
|
-
total_input_tokens:
|
|
4668
|
-
total_output_tokens:
|
|
4669
|
-
total_thought_tokens:
|
|
4670
|
-
total_cached_tokens:
|
|
4671
|
-
total_tool_use_tokens:
|
|
4672
|
-
total_tokens:
|
|
4673
|
-
input_tokens_by_modality:
|
|
4674
|
-
output_tokens_by_modality:
|
|
4675
|
-
cached_tokens_by_modality:
|
|
4676
|
-
tool_use_tokens_by_modality:
|
|
4677
|
-
grounding_tool_count:
|
|
4678
|
-
|
|
4679
|
-
type:
|
|
4680
|
-
count:
|
|
4919
|
+
var usageSchema2 = () => z17.object({
|
|
4920
|
+
total_input_tokens: z17.number().nullish(),
|
|
4921
|
+
total_output_tokens: z17.number().nullish(),
|
|
4922
|
+
total_thought_tokens: z17.number().nullish(),
|
|
4923
|
+
total_cached_tokens: z17.number().nullish(),
|
|
4924
|
+
total_tool_use_tokens: z17.number().nullish(),
|
|
4925
|
+
total_tokens: z17.number().nullish(),
|
|
4926
|
+
input_tokens_by_modality: z17.array(tokenByModalitySchema()).nullish(),
|
|
4927
|
+
output_tokens_by_modality: z17.array(tokenByModalitySchema()).nullish(),
|
|
4928
|
+
cached_tokens_by_modality: z17.array(tokenByModalitySchema()).nullish(),
|
|
4929
|
+
tool_use_tokens_by_modality: z17.array(tokenByModalitySchema()).nullish(),
|
|
4930
|
+
grounding_tool_count: z17.array(
|
|
4931
|
+
z17.object({
|
|
4932
|
+
type: z17.string().nullish(),
|
|
4933
|
+
count: z17.number().nullish()
|
|
4681
4934
|
}).loose()
|
|
4682
4935
|
).nullish()
|
|
4683
4936
|
}).loose();
|
|
4684
|
-
var interactionStatusSchema = () =>
|
|
4937
|
+
var interactionStatusSchema = () => z17.enum([
|
|
4685
4938
|
"in_progress",
|
|
4686
4939
|
"requires_action",
|
|
4687
4940
|
"completed",
|
|
@@ -4690,69 +4943,69 @@ var interactionStatusSchema = () => z15.enum([
|
|
|
4690
4943
|
"incomplete"
|
|
4691
4944
|
]);
|
|
4692
4945
|
var annotationSchema = () => {
|
|
4693
|
-
const urlCitation =
|
|
4694
|
-
type:
|
|
4695
|
-
url:
|
|
4696
|
-
title:
|
|
4697
|
-
start_index:
|
|
4698
|
-
end_index:
|
|
4946
|
+
const urlCitation = z17.object({
|
|
4947
|
+
type: z17.literal("url_citation"),
|
|
4948
|
+
url: z17.string().nullish(),
|
|
4949
|
+
title: z17.string().nullish(),
|
|
4950
|
+
start_index: z17.number().nullish(),
|
|
4951
|
+
end_index: z17.number().nullish()
|
|
4699
4952
|
}).loose();
|
|
4700
|
-
const fileCitation =
|
|
4701
|
-
type:
|
|
4702
|
-
file_name:
|
|
4703
|
-
document_uri:
|
|
4704
|
-
url:
|
|
4705
|
-
page_number:
|
|
4706
|
-
media_id:
|
|
4707
|
-
start_index:
|
|
4708
|
-
end_index:
|
|
4709
|
-
custom_metadata:
|
|
4953
|
+
const fileCitation = z17.object({
|
|
4954
|
+
type: z17.literal("file_citation"),
|
|
4955
|
+
file_name: z17.string().nullish(),
|
|
4956
|
+
document_uri: z17.string().nullish(),
|
|
4957
|
+
url: z17.string().nullish(),
|
|
4958
|
+
page_number: z17.number().nullish(),
|
|
4959
|
+
media_id: z17.string().nullish(),
|
|
4960
|
+
start_index: z17.number().nullish(),
|
|
4961
|
+
end_index: z17.number().nullish(),
|
|
4962
|
+
custom_metadata: z17.record(z17.string(), z17.unknown()).nullish()
|
|
4710
4963
|
}).loose();
|
|
4711
|
-
const placeCitation =
|
|
4712
|
-
type:
|
|
4713
|
-
name:
|
|
4714
|
-
url:
|
|
4715
|
-
place_id:
|
|
4716
|
-
start_index:
|
|
4717
|
-
end_index:
|
|
4964
|
+
const placeCitation = z17.object({
|
|
4965
|
+
type: z17.literal("place_citation"),
|
|
4966
|
+
name: z17.string().nullish(),
|
|
4967
|
+
url: z17.string().nullish(),
|
|
4968
|
+
place_id: z17.string().nullish(),
|
|
4969
|
+
start_index: z17.number().nullish(),
|
|
4970
|
+
end_index: z17.number().nullish()
|
|
4718
4971
|
}).loose();
|
|
4719
|
-
return
|
|
4972
|
+
return z17.union([
|
|
4720
4973
|
urlCitation,
|
|
4721
4974
|
fileCitation,
|
|
4722
4975
|
placeCitation,
|
|
4723
|
-
|
|
4976
|
+
z17.object({ type: z17.string() }).loose()
|
|
4724
4977
|
]);
|
|
4725
4978
|
};
|
|
4726
|
-
var thoughtSummaryItemSchema = () =>
|
|
4727
|
-
type:
|
|
4728
|
-
text:
|
|
4729
|
-
data:
|
|
4730
|
-
mime_type:
|
|
4979
|
+
var thoughtSummaryItemSchema = () => z17.object({
|
|
4980
|
+
type: z17.string(),
|
|
4981
|
+
text: z17.string().nullish(),
|
|
4982
|
+
data: z17.string().nullish(),
|
|
4983
|
+
mime_type: z17.string().nullish()
|
|
4731
4984
|
}).loose();
|
|
4732
4985
|
var contentBlockSchema = () => {
|
|
4733
|
-
const textContent =
|
|
4734
|
-
type:
|
|
4735
|
-
text:
|
|
4736
|
-
annotations:
|
|
4986
|
+
const textContent = z17.object({
|
|
4987
|
+
type: z17.literal("text"),
|
|
4988
|
+
text: z17.string(),
|
|
4989
|
+
annotations: z17.array(annotationSchema()).nullish()
|
|
4737
4990
|
}).loose();
|
|
4738
|
-
const imageContent =
|
|
4739
|
-
type:
|
|
4740
|
-
data:
|
|
4741
|
-
mime_type:
|
|
4742
|
-
resolution:
|
|
4743
|
-
uri:
|
|
4991
|
+
const imageContent = z17.object({
|
|
4992
|
+
type: z17.literal("image"),
|
|
4993
|
+
data: z17.string().nullish(),
|
|
4994
|
+
mime_type: z17.string().nullish(),
|
|
4995
|
+
resolution: z17.enum(["low", "medium", "high", "ultra_high"]).nullish(),
|
|
4996
|
+
uri: z17.string().nullish()
|
|
4744
4997
|
}).loose();
|
|
4745
|
-
const videoContent =
|
|
4746
|
-
type:
|
|
4747
|
-
data:
|
|
4748
|
-
mime_type:
|
|
4749
|
-
uri:
|
|
4998
|
+
const videoContent = z17.object({
|
|
4999
|
+
type: z17.literal("video"),
|
|
5000
|
+
data: z17.string().nullish(),
|
|
5001
|
+
mime_type: z17.string().nullish(),
|
|
5002
|
+
uri: z17.string().nullish()
|
|
4750
5003
|
}).loose();
|
|
4751
|
-
return
|
|
5004
|
+
return z17.union([
|
|
4752
5005
|
textContent,
|
|
4753
5006
|
imageContent,
|
|
4754
5007
|
videoContent,
|
|
4755
|
-
|
|
5008
|
+
z17.object({ type: z17.string() }).loose()
|
|
4756
5009
|
]);
|
|
4757
5010
|
};
|
|
4758
5011
|
var BUILTIN_TOOL_CALL_STEP_TYPES = [
|
|
@@ -4772,73 +5025,73 @@ var BUILTIN_TOOL_RESULT_STEP_TYPES = [
|
|
|
4772
5025
|
"mcp_server_tool_result"
|
|
4773
5026
|
];
|
|
4774
5027
|
var stepSchema = () => {
|
|
4775
|
-
const userInputStep =
|
|
4776
|
-
type:
|
|
4777
|
-
content:
|
|
5028
|
+
const userInputStep = z17.object({
|
|
5029
|
+
type: z17.literal("user_input"),
|
|
5030
|
+
content: z17.array(contentBlockSchema()).nullish()
|
|
4778
5031
|
}).loose();
|
|
4779
|
-
const modelOutputStep =
|
|
4780
|
-
type:
|
|
4781
|
-
content:
|
|
5032
|
+
const modelOutputStep = z17.object({
|
|
5033
|
+
type: z17.literal("model_output"),
|
|
5034
|
+
content: z17.array(contentBlockSchema()).nullish()
|
|
4782
5035
|
}).loose();
|
|
4783
|
-
const functionCallStep =
|
|
4784
|
-
type:
|
|
4785
|
-
id:
|
|
4786
|
-
name:
|
|
4787
|
-
arguments:
|
|
4788
|
-
signature:
|
|
5036
|
+
const functionCallStep = z17.object({
|
|
5037
|
+
type: z17.literal("function_call"),
|
|
5038
|
+
id: z17.string(),
|
|
5039
|
+
name: z17.string(),
|
|
5040
|
+
arguments: z17.record(z17.string(), z17.unknown()).nullish(),
|
|
5041
|
+
signature: z17.string().nullish()
|
|
4789
5042
|
}).loose();
|
|
4790
|
-
const thoughtStep =
|
|
4791
|
-
type:
|
|
4792
|
-
signature:
|
|
4793
|
-
summary:
|
|
5043
|
+
const thoughtStep = z17.object({
|
|
5044
|
+
type: z17.literal("thought"),
|
|
5045
|
+
signature: z17.string().nullish(),
|
|
5046
|
+
summary: z17.array(thoughtSummaryItemSchema()).nullish()
|
|
4794
5047
|
}).loose();
|
|
4795
|
-
const builtinToolCallStep =
|
|
4796
|
-
type:
|
|
4797
|
-
id:
|
|
4798
|
-
arguments:
|
|
4799
|
-
name:
|
|
4800
|
-
server_name:
|
|
4801
|
-
search_type:
|
|
4802
|
-
signature:
|
|
5048
|
+
const builtinToolCallStep = z17.object({
|
|
5049
|
+
type: z17.enum(BUILTIN_TOOL_CALL_STEP_TYPES),
|
|
5050
|
+
id: z17.string(),
|
|
5051
|
+
arguments: z17.record(z17.string(), z17.unknown()).nullish(),
|
|
5052
|
+
name: z17.string().nullish(),
|
|
5053
|
+
server_name: z17.string().nullish(),
|
|
5054
|
+
search_type: z17.string().nullish(),
|
|
5055
|
+
signature: z17.string().nullish()
|
|
4803
5056
|
}).loose();
|
|
4804
|
-
const builtinToolResultStep =
|
|
4805
|
-
type:
|
|
4806
|
-
call_id:
|
|
4807
|
-
result:
|
|
4808
|
-
is_error:
|
|
4809
|
-
name:
|
|
4810
|
-
server_name:
|
|
4811
|
-
signature:
|
|
5057
|
+
const builtinToolResultStep = z17.object({
|
|
5058
|
+
type: z17.enum(BUILTIN_TOOL_RESULT_STEP_TYPES),
|
|
5059
|
+
call_id: z17.string(),
|
|
5060
|
+
result: z17.unknown().nullish(),
|
|
5061
|
+
is_error: z17.boolean().nullish(),
|
|
5062
|
+
name: z17.string().nullish(),
|
|
5063
|
+
server_name: z17.string().nullish(),
|
|
5064
|
+
signature: z17.string().nullish()
|
|
4812
5065
|
}).loose();
|
|
4813
|
-
return
|
|
5066
|
+
return z17.union([
|
|
4814
5067
|
userInputStep,
|
|
4815
5068
|
modelOutputStep,
|
|
4816
5069
|
functionCallStep,
|
|
4817
5070
|
thoughtStep,
|
|
4818
5071
|
builtinToolCallStep,
|
|
4819
5072
|
builtinToolResultStep,
|
|
4820
|
-
|
|
5073
|
+
z17.object({ type: z17.string() }).loose()
|
|
4821
5074
|
]);
|
|
4822
5075
|
};
|
|
4823
5076
|
var googleInteractionsResponseSchema = lazySchema13(
|
|
4824
5077
|
() => zodSchema13(
|
|
4825
|
-
|
|
5078
|
+
z17.object({
|
|
4826
5079
|
/*
|
|
4827
5080
|
* `id` is omitted from the response body when `store: false` (fully
|
|
4828
5081
|
* stateless mode) — there is no server-side interaction record for the
|
|
4829
5082
|
* client to reference. `nullish` lets the schema accept that shape.
|
|
4830
5083
|
*/
|
|
4831
|
-
id:
|
|
4832
|
-
created:
|
|
4833
|
-
updated:
|
|
5084
|
+
id: z17.string().nullish(),
|
|
5085
|
+
created: z17.string().nullish(),
|
|
5086
|
+
updated: z17.string().nullish(),
|
|
4834
5087
|
status: interactionStatusSchema(),
|
|
4835
|
-
model:
|
|
4836
|
-
agent:
|
|
4837
|
-
steps:
|
|
5088
|
+
model: z17.string().nullish(),
|
|
5089
|
+
agent: z17.string().nullish(),
|
|
5090
|
+
steps: z17.array(stepSchema()).nullish(),
|
|
4838
5091
|
usage: usageSchema2().nullish(),
|
|
4839
|
-
service_tier:
|
|
4840
|
-
previous_interaction_id:
|
|
4841
|
-
response_modalities:
|
|
5092
|
+
service_tier: z17.string().nullish(),
|
|
5093
|
+
previous_interaction_id: z17.string().nullish(),
|
|
5094
|
+
response_modalities: z17.array(z17.string()).nullish()
|
|
4842
5095
|
}).loose()
|
|
4843
5096
|
)
|
|
4844
5097
|
);
|
|
@@ -4848,82 +5101,82 @@ var googleInteractionsEventSchema = lazySchema13(
|
|
|
4848
5101
|
const status = interactionStatusSchema();
|
|
4849
5102
|
const annotation = annotationSchema();
|
|
4850
5103
|
const thoughtSummaryItem = thoughtSummaryItemSchema();
|
|
4851
|
-
const interactionCreatedEvent =
|
|
4852
|
-
event_type:
|
|
4853
|
-
event_id:
|
|
4854
|
-
interaction:
|
|
5104
|
+
const interactionCreatedEvent = z17.object({
|
|
5105
|
+
event_type: z17.literal("interaction.created"),
|
|
5106
|
+
event_id: z17.string().nullish(),
|
|
5107
|
+
interaction: z17.object({
|
|
4855
5108
|
/*
|
|
4856
5109
|
* `id` is omitted when `store: false` (fully stateless mode);
|
|
4857
5110
|
* see the matching note on `googleInteractionsResponseSchema.id`.
|
|
4858
5111
|
*/
|
|
4859
|
-
id:
|
|
4860
|
-
created:
|
|
4861
|
-
model:
|
|
4862
|
-
agent:
|
|
5112
|
+
id: z17.string().nullish(),
|
|
5113
|
+
created: z17.string().nullish(),
|
|
5114
|
+
model: z17.string().nullish(),
|
|
5115
|
+
agent: z17.string().nullish(),
|
|
4863
5116
|
status: status.nullish()
|
|
4864
5117
|
}).loose()
|
|
4865
5118
|
}).loose();
|
|
4866
|
-
const stepStartEvent =
|
|
4867
|
-
event_type:
|
|
4868
|
-
event_id:
|
|
4869
|
-
index:
|
|
5119
|
+
const stepStartEvent = z17.object({
|
|
5120
|
+
event_type: z17.literal("step.start"),
|
|
5121
|
+
event_id: z17.string().nullish(),
|
|
5122
|
+
index: z17.number(),
|
|
4870
5123
|
step: stepSchema()
|
|
4871
5124
|
}).loose();
|
|
4872
|
-
const stepDeltaText =
|
|
4873
|
-
type:
|
|
4874
|
-
text:
|
|
5125
|
+
const stepDeltaText = z17.object({
|
|
5126
|
+
type: z17.literal("text"),
|
|
5127
|
+
text: z17.string()
|
|
4875
5128
|
}).loose();
|
|
4876
|
-
const stepDeltaThoughtSummary =
|
|
4877
|
-
type:
|
|
5129
|
+
const stepDeltaThoughtSummary = z17.object({
|
|
5130
|
+
type: z17.literal("thought_summary"),
|
|
4878
5131
|
content: thoughtSummaryItem.nullish()
|
|
4879
5132
|
}).loose();
|
|
4880
|
-
const stepDeltaThoughtSignature =
|
|
4881
|
-
type:
|
|
4882
|
-
signature:
|
|
5133
|
+
const stepDeltaThoughtSignature = z17.object({
|
|
5134
|
+
type: z17.literal("thought_signature"),
|
|
5135
|
+
signature: z17.string().nullish()
|
|
4883
5136
|
}).loose();
|
|
4884
|
-
const stepDeltaArgumentsDelta =
|
|
4885
|
-
type:
|
|
4886
|
-
arguments:
|
|
4887
|
-
id:
|
|
4888
|
-
signature:
|
|
5137
|
+
const stepDeltaArgumentsDelta = z17.object({
|
|
5138
|
+
type: z17.literal("arguments_delta"),
|
|
5139
|
+
arguments: z17.string().nullish(),
|
|
5140
|
+
id: z17.string().nullish(),
|
|
5141
|
+
signature: z17.string().nullish()
|
|
4889
5142
|
}).loose();
|
|
4890
|
-
const stepDeltaTextAnnotation =
|
|
4891
|
-
type:
|
|
4892
|
-
annotations:
|
|
5143
|
+
const stepDeltaTextAnnotation = z17.object({
|
|
5144
|
+
type: z17.enum(["text_annotation_delta", "text_annotation"]),
|
|
5145
|
+
annotations: z17.array(annotation).nullish()
|
|
4893
5146
|
}).loose();
|
|
4894
|
-
const stepDeltaImage =
|
|
4895
|
-
type:
|
|
4896
|
-
data:
|
|
4897
|
-
mime_type:
|
|
4898
|
-
resolution:
|
|
4899
|
-
uri:
|
|
5147
|
+
const stepDeltaImage = z17.object({
|
|
5148
|
+
type: z17.literal("image"),
|
|
5149
|
+
data: z17.string().nullish(),
|
|
5150
|
+
mime_type: z17.string().nullish(),
|
|
5151
|
+
resolution: z17.enum(["low", "medium", "high", "ultra_high"]).nullish(),
|
|
5152
|
+
uri: z17.string().nullish()
|
|
4900
5153
|
}).loose();
|
|
4901
|
-
const stepDeltaVideo =
|
|
4902
|
-
type:
|
|
4903
|
-
data:
|
|
4904
|
-
mime_type:
|
|
4905
|
-
uri:
|
|
5154
|
+
const stepDeltaVideo = z17.object({
|
|
5155
|
+
type: z17.literal("video"),
|
|
5156
|
+
data: z17.string().nullish(),
|
|
5157
|
+
mime_type: z17.string().nullish(),
|
|
5158
|
+
uri: z17.string().nullish()
|
|
4906
5159
|
}).loose();
|
|
4907
|
-
const stepDeltaBuiltinToolCall =
|
|
4908
|
-
type:
|
|
4909
|
-
id:
|
|
4910
|
-
arguments:
|
|
4911
|
-
name:
|
|
4912
|
-
server_name:
|
|
4913
|
-
search_type:
|
|
4914
|
-
signature:
|
|
5160
|
+
const stepDeltaBuiltinToolCall = z17.object({
|
|
5161
|
+
type: z17.enum(BUILTIN_TOOL_CALL_STEP_TYPES),
|
|
5162
|
+
id: z17.string().nullish(),
|
|
5163
|
+
arguments: z17.record(z17.string(), z17.unknown()).nullish(),
|
|
5164
|
+
name: z17.string().nullish(),
|
|
5165
|
+
server_name: z17.string().nullish(),
|
|
5166
|
+
search_type: z17.string().nullish(),
|
|
5167
|
+
signature: z17.string().nullish()
|
|
4915
5168
|
}).loose();
|
|
4916
|
-
const stepDeltaBuiltinToolResult =
|
|
4917
|
-
type:
|
|
4918
|
-
call_id:
|
|
4919
|
-
result:
|
|
4920
|
-
is_error:
|
|
4921
|
-
name:
|
|
4922
|
-
server_name:
|
|
4923
|
-
signature:
|
|
5169
|
+
const stepDeltaBuiltinToolResult = z17.object({
|
|
5170
|
+
type: z17.enum(BUILTIN_TOOL_RESULT_STEP_TYPES),
|
|
5171
|
+
call_id: z17.string().nullish(),
|
|
5172
|
+
result: z17.unknown().nullish(),
|
|
5173
|
+
is_error: z17.boolean().nullish(),
|
|
5174
|
+
name: z17.string().nullish(),
|
|
5175
|
+
server_name: z17.string().nullish(),
|
|
5176
|
+
signature: z17.string().nullish()
|
|
4924
5177
|
}).loose();
|
|
4925
|
-
const stepDeltaUnknown =
|
|
4926
|
-
const stepDeltaUnion =
|
|
5178
|
+
const stepDeltaUnknown = z17.object({ type: z17.string() }).loose();
|
|
5179
|
+
const stepDeltaUnion = z17.union([
|
|
4927
5180
|
stepDeltaText,
|
|
4928
5181
|
stepDeltaImage,
|
|
4929
5182
|
stepDeltaVideo,
|
|
@@ -4935,55 +5188,55 @@ var googleInteractionsEventSchema = lazySchema13(
|
|
|
4935
5188
|
stepDeltaBuiltinToolResult,
|
|
4936
5189
|
stepDeltaUnknown
|
|
4937
5190
|
]);
|
|
4938
|
-
const stepDeltaEvent =
|
|
4939
|
-
event_type:
|
|
4940
|
-
event_id:
|
|
4941
|
-
index:
|
|
5191
|
+
const stepDeltaEvent = z17.object({
|
|
5192
|
+
event_type: z17.literal("step.delta"),
|
|
5193
|
+
event_id: z17.string().nullish(),
|
|
5194
|
+
index: z17.number(),
|
|
4942
5195
|
delta: stepDeltaUnion
|
|
4943
5196
|
}).loose();
|
|
4944
|
-
const stepStopEvent =
|
|
4945
|
-
event_type:
|
|
4946
|
-
event_id:
|
|
4947
|
-
index:
|
|
5197
|
+
const stepStopEvent = z17.object({
|
|
5198
|
+
event_type: z17.literal("step.stop"),
|
|
5199
|
+
event_id: z17.string().nullish(),
|
|
5200
|
+
index: z17.number()
|
|
4948
5201
|
}).loose();
|
|
4949
|
-
const interactionStatusUpdateEvent =
|
|
4950
|
-
event_type:
|
|
4951
|
-
event_id:
|
|
4952
|
-
interaction_id:
|
|
5202
|
+
const interactionStatusUpdateEvent = z17.object({
|
|
5203
|
+
event_type: z17.literal("interaction.status_update"),
|
|
5204
|
+
event_id: z17.string().nullish(),
|
|
5205
|
+
interaction_id: z17.string().nullish(),
|
|
4953
5206
|
status: status.nullish()
|
|
4954
5207
|
}).loose();
|
|
4955
|
-
const interactionInProgressEvent =
|
|
4956
|
-
event_type:
|
|
4957
|
-
event_id:
|
|
4958
|
-
interaction_id:
|
|
5208
|
+
const interactionInProgressEvent = z17.object({
|
|
5209
|
+
event_type: z17.literal("interaction.in_progress"),
|
|
5210
|
+
event_id: z17.string().nullish(),
|
|
5211
|
+
interaction_id: z17.string().nullish(),
|
|
4959
5212
|
status: status.nullish()
|
|
4960
5213
|
}).loose();
|
|
4961
|
-
const interactionRequiresActionEvent =
|
|
4962
|
-
event_type:
|
|
4963
|
-
event_id:
|
|
4964
|
-
interaction_id:
|
|
5214
|
+
const interactionRequiresActionEvent = z17.object({
|
|
5215
|
+
event_type: z17.literal("interaction.requires_action"),
|
|
5216
|
+
event_id: z17.string().nullish(),
|
|
5217
|
+
interaction_id: z17.string().nullish(),
|
|
4965
5218
|
status: status.nullish()
|
|
4966
5219
|
}).loose();
|
|
4967
|
-
const interactionCompletedEvent =
|
|
4968
|
-
event_type:
|
|
4969
|
-
event_id:
|
|
4970
|
-
interaction:
|
|
4971
|
-
id:
|
|
5220
|
+
const interactionCompletedEvent = z17.object({
|
|
5221
|
+
event_type: z17.literal("interaction.completed"),
|
|
5222
|
+
event_id: z17.string().nullish(),
|
|
5223
|
+
interaction: z17.object({
|
|
5224
|
+
id: z17.string().nullish(),
|
|
4972
5225
|
status: status.nullish(),
|
|
4973
5226
|
usage: usageSchema2().nullish(),
|
|
4974
|
-
service_tier:
|
|
5227
|
+
service_tier: z17.string().nullish()
|
|
4975
5228
|
}).loose()
|
|
4976
5229
|
}).loose();
|
|
4977
|
-
const errorEvent =
|
|
4978
|
-
event_type:
|
|
4979
|
-
event_id:
|
|
4980
|
-
error:
|
|
4981
|
-
code:
|
|
4982
|
-
message:
|
|
5230
|
+
const errorEvent = z17.object({
|
|
5231
|
+
event_type: z17.literal("error"),
|
|
5232
|
+
event_id: z17.string().nullish(),
|
|
5233
|
+
error: z17.object({
|
|
5234
|
+
code: z17.string().nullish(),
|
|
5235
|
+
message: z17.string().nullish()
|
|
4983
5236
|
}).loose().nullish()
|
|
4984
5237
|
}).loose();
|
|
4985
|
-
const unknownEvent =
|
|
4986
|
-
return
|
|
5238
|
+
const unknownEvent = z17.object({ event_type: z17.string() }).loose();
|
|
5239
|
+
return z17.union([
|
|
4987
5240
|
interactionCreatedEvent,
|
|
4988
5241
|
stepStartEvent,
|
|
4989
5242
|
stepDeltaEvent,
|
|
@@ -5004,26 +5257,26 @@ import {
|
|
|
5004
5257
|
lazySchema as lazySchema14,
|
|
5005
5258
|
zodSchema as zodSchema14
|
|
5006
5259
|
} from "@ai-sdk/provider-utils";
|
|
5007
|
-
import { z as
|
|
5260
|
+
import { z as z18 } from "zod/v4";
|
|
5008
5261
|
var googleInteractionsLanguageModelOptions = lazySchema14(
|
|
5009
5262
|
() => zodSchema14(
|
|
5010
|
-
|
|
5011
|
-
previousInteractionId:
|
|
5012
|
-
store:
|
|
5013
|
-
agent:
|
|
5014
|
-
agentConfig:
|
|
5015
|
-
|
|
5016
|
-
type:
|
|
5263
|
+
z18.object({
|
|
5264
|
+
previousInteractionId: z18.string().nullish(),
|
|
5265
|
+
store: z18.boolean().nullish(),
|
|
5266
|
+
agent: z18.string().nullish(),
|
|
5267
|
+
agentConfig: z18.union([
|
|
5268
|
+
z18.object({
|
|
5269
|
+
type: z18.literal("dynamic")
|
|
5017
5270
|
}).loose(),
|
|
5018
|
-
|
|
5019
|
-
type:
|
|
5020
|
-
thinkingSummaries:
|
|
5021
|
-
visualization:
|
|
5022
|
-
collaborativePlanning:
|
|
5271
|
+
z18.object({
|
|
5272
|
+
type: z18.literal("deep-research"),
|
|
5273
|
+
thinkingSummaries: z18.enum(["auto", "none"]).nullish(),
|
|
5274
|
+
visualization: z18.enum(["off", "auto"]).nullish(),
|
|
5275
|
+
collaborativePlanning: z18.boolean().nullish()
|
|
5023
5276
|
})
|
|
5024
5277
|
]).nullish(),
|
|
5025
|
-
thinkingLevel:
|
|
5026
|
-
thinkingSummaries:
|
|
5278
|
+
thinkingLevel: z18.enum(["minimal", "low", "medium", "high"]).nullish(),
|
|
5279
|
+
thinkingSummaries: z18.enum(["auto", "none"]).nullish(),
|
|
5027
5280
|
/**
|
|
5028
5281
|
* Output-format entries that map directly to the API's `response_format`
|
|
5029
5282
|
* array. Use this to request image, audio, or non-JSON text outputs
|
|
@@ -5033,17 +5286,17 @@ var googleInteractionsLanguageModelOptions = lazySchema14(
|
|
|
5033
5286
|
* type: 'json', schema }` still drives JSON-mode and adds a matching
|
|
5034
5287
|
* text entry automatically; entries listed here are appended.
|
|
5035
5288
|
*/
|
|
5036
|
-
responseFormat:
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
type:
|
|
5040
|
-
mimeType:
|
|
5041
|
-
schema:
|
|
5289
|
+
responseFormat: z18.array(
|
|
5290
|
+
z18.union([
|
|
5291
|
+
z18.object({
|
|
5292
|
+
type: z18.literal("text"),
|
|
5293
|
+
mimeType: z18.string().nullish(),
|
|
5294
|
+
schema: z18.unknown().nullish()
|
|
5042
5295
|
}).loose(),
|
|
5043
|
-
|
|
5044
|
-
type:
|
|
5045
|
-
mimeType:
|
|
5046
|
-
aspectRatio:
|
|
5296
|
+
z18.object({
|
|
5297
|
+
type: z18.literal("image"),
|
|
5298
|
+
mimeType: z18.string().nullish(),
|
|
5299
|
+
aspectRatio: z18.enum([
|
|
5047
5300
|
"1:1",
|
|
5048
5301
|
"2:3",
|
|
5049
5302
|
"3:2",
|
|
@@ -5059,11 +5312,11 @@ var googleInteractionsLanguageModelOptions = lazySchema14(
|
|
|
5059
5312
|
"1:4",
|
|
5060
5313
|
"4:1"
|
|
5061
5314
|
]).nullish(),
|
|
5062
|
-
imageSize:
|
|
5315
|
+
imageSize: z18.enum(["1K", "2K", "4K", "512"]).nullish()
|
|
5063
5316
|
}).loose(),
|
|
5064
|
-
|
|
5065
|
-
type:
|
|
5066
|
-
mimeType:
|
|
5317
|
+
z18.object({
|
|
5318
|
+
type: z18.literal("audio"),
|
|
5319
|
+
mimeType: z18.string().nullish()
|
|
5067
5320
|
}).loose()
|
|
5068
5321
|
])
|
|
5069
5322
|
).nullish(),
|
|
@@ -5073,8 +5326,8 @@ var googleInteractionsLanguageModelOptions = lazySchema14(
|
|
|
5073
5326
|
* translates it into a matching `response_format` image entry and
|
|
5074
5327
|
* emits a warning when set.
|
|
5075
5328
|
*/
|
|
5076
|
-
imageConfig:
|
|
5077
|
-
aspectRatio:
|
|
5329
|
+
imageConfig: z18.object({
|
|
5330
|
+
aspectRatio: z18.enum([
|
|
5078
5331
|
"1:1",
|
|
5079
5332
|
"2:3",
|
|
5080
5333
|
"3:2",
|
|
@@ -5090,35 +5343,35 @@ var googleInteractionsLanguageModelOptions = lazySchema14(
|
|
|
5090
5343
|
"1:4",
|
|
5091
5344
|
"4:1"
|
|
5092
5345
|
]).nullish(),
|
|
5093
|
-
imageSize:
|
|
5346
|
+
imageSize: z18.enum(["1K", "2K", "4K", "512"]).nullish()
|
|
5094
5347
|
}).nullish(),
|
|
5095
|
-
mediaResolution:
|
|
5096
|
-
responseModalities:
|
|
5097
|
-
serviceTier:
|
|
5348
|
+
mediaResolution: z18.enum(["low", "medium", "high", "ultra_high"]).nullish(),
|
|
5349
|
+
responseModalities: z18.array(z18.enum(["text", "image", "audio", "video", "document"])).nullish(),
|
|
5350
|
+
serviceTier: z18.enum(["flex", "standard", "priority"]).nullish(),
|
|
5098
5351
|
/**
|
|
5099
5352
|
* Alternative to AI SDK `system` message. If both are set, the AI SDK
|
|
5100
5353
|
* `system` message wins and a warning is emitted.
|
|
5101
5354
|
*/
|
|
5102
|
-
systemInstruction:
|
|
5355
|
+
systemInstruction: z18.string().nullish(),
|
|
5103
5356
|
/**
|
|
5104
5357
|
* Per-block signature for round-tripping `thought.signature` and
|
|
5105
5358
|
* `function_call.signature` blocks. Set by the SDK on output reasoning /
|
|
5106
5359
|
* tool-call parts; passed back unchanged on input parts so the API
|
|
5107
5360
|
* accepts the prior turn.
|
|
5108
5361
|
*/
|
|
5109
|
-
signature:
|
|
5362
|
+
signature: z18.string().nullish(),
|
|
5110
5363
|
/**
|
|
5111
5364
|
* Set by the SDK on output assistant messages. The converter uses it to
|
|
5112
5365
|
* decide which messages to drop when compacting under
|
|
5113
5366
|
* `previousInteractionId`.
|
|
5114
5367
|
*/
|
|
5115
|
-
interactionId:
|
|
5368
|
+
interactionId: z18.string().nullish(),
|
|
5116
5369
|
/**
|
|
5117
5370
|
* Maximum time, in milliseconds, to poll a background interaction (agent
|
|
5118
5371
|
* call) before giving up. Defaults to 30 minutes. Long-running agents
|
|
5119
5372
|
* such as deep research can take tens of minutes — increase if needed.
|
|
5120
5373
|
*/
|
|
5121
|
-
pollingTimeoutMs:
|
|
5374
|
+
pollingTimeoutMs: z18.number().int().positive().nullish(),
|
|
5122
5375
|
/**
|
|
5123
5376
|
* Run the interaction in the background. Required for agents whose
|
|
5124
5377
|
* server-side workflow cannot complete within a single request/response.
|
|
@@ -5127,7 +5380,7 @@ var googleInteractionsLanguageModelOptions = lazySchema14(
|
|
|
5127
5380
|
* reject `true`; see the agent's documentation for which mode it
|
|
5128
5381
|
* requires.
|
|
5129
5382
|
*/
|
|
5130
|
-
background:
|
|
5383
|
+
background: z18.boolean().nullish(),
|
|
5131
5384
|
/**
|
|
5132
5385
|
* Environment configuration for the agent sandbox. Only applies to agent
|
|
5133
5386
|
* calls (`google.interactions({ agent })`); ignored on model-id calls.
|
|
@@ -5137,36 +5390,36 @@ var googleInteractionsLanguageModelOptions = lazySchema14(
|
|
|
5137
5390
|
* - object: provision a fresh sandbox and optionally preload `sources`
|
|
5138
5391
|
* and/or constrain outbound traffic via `network`.
|
|
5139
5392
|
*/
|
|
5140
|
-
environment:
|
|
5141
|
-
|
|
5142
|
-
|
|
5143
|
-
type:
|
|
5144
|
-
sources:
|
|
5145
|
-
|
|
5146
|
-
|
|
5147
|
-
type:
|
|
5148
|
-
source:
|
|
5149
|
-
target:
|
|
5393
|
+
environment: z18.union([
|
|
5394
|
+
z18.string(),
|
|
5395
|
+
z18.object({
|
|
5396
|
+
type: z18.literal("remote"),
|
|
5397
|
+
sources: z18.array(
|
|
5398
|
+
z18.union([
|
|
5399
|
+
z18.object({
|
|
5400
|
+
type: z18.literal("gcs"),
|
|
5401
|
+
source: z18.string(),
|
|
5402
|
+
target: z18.string().nullish()
|
|
5150
5403
|
}),
|
|
5151
|
-
|
|
5152
|
-
type:
|
|
5153
|
-
source:
|
|
5154
|
-
target:
|
|
5404
|
+
z18.object({
|
|
5405
|
+
type: z18.literal("repository"),
|
|
5406
|
+
source: z18.string(),
|
|
5407
|
+
target: z18.string().nullish()
|
|
5155
5408
|
}),
|
|
5156
|
-
|
|
5157
|
-
type:
|
|
5158
|
-
content:
|
|
5159
|
-
target:
|
|
5409
|
+
z18.object({
|
|
5410
|
+
type: z18.literal("inline"),
|
|
5411
|
+
content: z18.string(),
|
|
5412
|
+
target: z18.string()
|
|
5160
5413
|
})
|
|
5161
5414
|
])
|
|
5162
5415
|
).nullish(),
|
|
5163
|
-
network:
|
|
5164
|
-
|
|
5165
|
-
|
|
5166
|
-
allowlist:
|
|
5167
|
-
|
|
5168
|
-
domain:
|
|
5169
|
-
transform:
|
|
5416
|
+
network: z18.union([
|
|
5417
|
+
z18.literal("disabled"),
|
|
5418
|
+
z18.object({
|
|
5419
|
+
allowlist: z18.array(
|
|
5420
|
+
z18.object({
|
|
5421
|
+
domain: z18.string(),
|
|
5422
|
+
transform: z18.array(z18.record(z18.string(), z18.string())).nullish()
|
|
5170
5423
|
})
|
|
5171
5424
|
)
|
|
5172
5425
|
})
|
|
@@ -5366,7 +5619,7 @@ function parseGoogleInteractionsOutputs({
|
|
|
5366
5619
|
|
|
5367
5620
|
// src/interactions/poll-google-interactions.ts
|
|
5368
5621
|
import {
|
|
5369
|
-
createJsonResponseHandler as
|
|
5622
|
+
createJsonResponseHandler as createJsonResponseHandler6,
|
|
5370
5623
|
delay as delay2,
|
|
5371
5624
|
getFromApi as getFromApi2,
|
|
5372
5625
|
isAbortError
|
|
@@ -5374,7 +5627,7 @@ import {
|
|
|
5374
5627
|
|
|
5375
5628
|
// src/interactions/cancel-google-interaction.ts
|
|
5376
5629
|
import {
|
|
5377
|
-
combineHeaders as
|
|
5630
|
+
combineHeaders as combineHeaders6,
|
|
5378
5631
|
getRuntimeEnvironmentUserAgent,
|
|
5379
5632
|
withUserAgentSuffix
|
|
5380
5633
|
} from "@ai-sdk/provider-utils";
|
|
@@ -5393,7 +5646,7 @@ async function cancelGoogleInteraction({
|
|
|
5393
5646
|
const response = await fetch(url, {
|
|
5394
5647
|
method: "POST",
|
|
5395
5648
|
headers: withUserAgentSuffix(
|
|
5396
|
-
|
|
5649
|
+
combineHeaders6({ "Content-Type": "application/json" }, headers),
|
|
5397
5650
|
getRuntimeEnvironmentUserAgent()
|
|
5398
5651
|
),
|
|
5399
5652
|
body: "{}"
|
|
@@ -5453,7 +5706,7 @@ async function pollGoogleInteractionUntilTerminal({
|
|
|
5453
5706
|
url,
|
|
5454
5707
|
headers,
|
|
5455
5708
|
failedResponseHandler: googleFailedResponseHandler,
|
|
5456
|
-
successfulResponseHandler:
|
|
5709
|
+
successfulResponseHandler: createJsonResponseHandler6(
|
|
5457
5710
|
googleInteractionsResponseSchema
|
|
5458
5711
|
),
|
|
5459
5712
|
abortSignal,
|
|
@@ -5966,7 +6219,7 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5966
6219
|
async getArgs(options) {
|
|
5967
6220
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A;
|
|
5968
6221
|
const warnings = [];
|
|
5969
|
-
const opts = await
|
|
6222
|
+
const opts = await parseProviderOptions6({
|
|
5970
6223
|
provider: "google",
|
|
5971
6224
|
providerOptions: options.providerOptions,
|
|
5972
6225
|
schema: googleInteractionsLanguageModelOptions
|
|
@@ -6212,17 +6465,17 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
6212
6465
|
var _a, _b, _c, _d, _e, _f;
|
|
6213
6466
|
const { args, warnings, isAgent, pollingTimeoutMs } = await this.getArgs(options);
|
|
6214
6467
|
const url = `${this.config.baseURL}/interactions`;
|
|
6215
|
-
const mergedHeaders =
|
|
6468
|
+
const mergedHeaders = combineHeaders7(
|
|
6216
6469
|
INTERACTIONS_API_REVISION_HEADER,
|
|
6217
|
-
this.config.headers ? await
|
|
6470
|
+
this.config.headers ? await resolve6(this.config.headers) : void 0,
|
|
6218
6471
|
options.headers
|
|
6219
6472
|
);
|
|
6220
|
-
const postResult = await
|
|
6473
|
+
const postResult = await postJsonToApi6({
|
|
6221
6474
|
url,
|
|
6222
6475
|
headers: mergedHeaders,
|
|
6223
6476
|
body: args,
|
|
6224
6477
|
failedResponseHandler: googleFailedResponseHandler,
|
|
6225
|
-
successfulResponseHandler:
|
|
6478
|
+
successfulResponseHandler: createJsonResponseHandler7(
|
|
6226
6479
|
googleInteractionsResponseSchema
|
|
6227
6480
|
),
|
|
6228
6481
|
abortSignal: options.abortSignal,
|
|
@@ -6297,9 +6550,9 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
6297
6550
|
var _a;
|
|
6298
6551
|
const { args, warnings, isBackground, pollingTimeoutMs } = await this.getArgs(options);
|
|
6299
6552
|
const url = `${this.config.baseURL}/interactions`;
|
|
6300
|
-
const mergedHeaders =
|
|
6553
|
+
const mergedHeaders = combineHeaders7(
|
|
6301
6554
|
INTERACTIONS_API_REVISION_HEADER,
|
|
6302
|
-
this.config.headers ? await
|
|
6555
|
+
this.config.headers ? await resolve6(this.config.headers) : void 0,
|
|
6303
6556
|
options.headers
|
|
6304
6557
|
);
|
|
6305
6558
|
if (isBackground) {
|
|
@@ -6313,7 +6566,7 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
6313
6566
|
});
|
|
6314
6567
|
}
|
|
6315
6568
|
const body = { ...args, stream: true };
|
|
6316
|
-
const { responseHeaders, value: response } = await
|
|
6569
|
+
const { responseHeaders, value: response } = await postJsonToApi6({
|
|
6317
6570
|
url,
|
|
6318
6571
|
headers: mergedHeaders,
|
|
6319
6572
|
body,
|
|
@@ -6364,12 +6617,12 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
6364
6617
|
pollingTimeoutMs
|
|
6365
6618
|
}) {
|
|
6366
6619
|
var _a, _b;
|
|
6367
|
-
const postResult = await
|
|
6620
|
+
const postResult = await postJsonToApi6({
|
|
6368
6621
|
url,
|
|
6369
6622
|
headers: mergedHeaders,
|
|
6370
6623
|
body: args,
|
|
6371
6624
|
failedResponseHandler: googleFailedResponseHandler,
|
|
6372
|
-
successfulResponseHandler:
|
|
6625
|
+
successfulResponseHandler: createJsonResponseHandler7(
|
|
6373
6626
|
googleInteractionsResponseSchema
|
|
6374
6627
|
),
|
|
6375
6628
|
abortSignal: options.abortSignal,
|
|
@@ -6514,6 +6767,12 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
6514
6767
|
headers: getHeaders,
|
|
6515
6768
|
fetch: options.fetch
|
|
6516
6769
|
});
|
|
6770
|
+
const createTranscriptionModel = (modelId) => new GoogleTranscriptionModel(modelId, {
|
|
6771
|
+
provider: `${providerName}.transcription`,
|
|
6772
|
+
baseURL,
|
|
6773
|
+
headers: getHeaders,
|
|
6774
|
+
fetch: options.fetch
|
|
6775
|
+
});
|
|
6517
6776
|
const createVideoModel = (modelId) => {
|
|
6518
6777
|
var _a2;
|
|
6519
6778
|
return new GoogleGenerativeAIVideoModel(modelId, {
|
|
@@ -6555,6 +6814,8 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
6555
6814
|
provider.textEmbeddingModel = createEmbeddingModel;
|
|
6556
6815
|
provider.image = createImageModel;
|
|
6557
6816
|
provider.imageModel = createImageModel;
|
|
6817
|
+
provider.transcription = createTranscriptionModel;
|
|
6818
|
+
provider.transcriptionModel = createTranscriptionModel;
|
|
6558
6819
|
provider.video = createVideoModel;
|
|
6559
6820
|
provider.videoModel = createVideoModel;
|
|
6560
6821
|
provider.interactions = createInteractionsModel;
|
|
@@ -6563,6 +6824,7 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
6563
6824
|
}
|
|
6564
6825
|
var google = createGoogleGenerativeAI();
|
|
6565
6826
|
export {
|
|
6827
|
+
GoogleTranscriptionModel,
|
|
6566
6828
|
VERSION,
|
|
6567
6829
|
createGoogleGenerativeAI,
|
|
6568
6830
|
google
|