@ai-sdk/google 3.0.114 → 3.0.118
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 +26 -0
- package/dist/index.d.mts +64 -9
- package/dist/index.d.ts +64 -9
- package/dist/index.js +1011 -719
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +948 -648
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +7 -6
- package/dist/internal/index.d.ts +7 -6
- package/dist/internal/index.js +150 -52
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +150 -52
- 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-generative-ai-language-model.ts +99 -39
- 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-
|
|
1
|
+
// src/transcription/google-transcription-model.ts
|
|
2
2
|
import {
|
|
3
|
-
|
|
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
|
|
13
|
-
import {
|
|
14
|
-
TooManyEmbeddingValuesForCallError
|
|
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.118" : "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
|
);
|
|
@@ -1623,6 +1876,7 @@ var configurableSafetySettingCategories = [
|
|
|
1623
1876
|
"HARM_CATEGORY_HARASSMENT",
|
|
1624
1877
|
"HARM_CATEGORY_SEXUALLY_EXPLICIT"
|
|
1625
1878
|
];
|
|
1879
|
+
var gemini25ModelPattern2 = /(^|\/)gemini-2\.5(?:[.-]|$)/i;
|
|
1626
1880
|
var GoogleGenerativeAILanguageModel = class {
|
|
1627
1881
|
constructor(modelId, config) {
|
|
1628
1882
|
this.specificationVersion = "v3";
|
|
@@ -1656,13 +1910,13 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1656
1910
|
var _a, _b, _c;
|
|
1657
1911
|
const warnings = [];
|
|
1658
1912
|
const providerOptionsName = this.config.provider.includes("vertex") ? "vertex" : "google";
|
|
1659
|
-
let googleOptions = await
|
|
1913
|
+
let googleOptions = await parseProviderOptions3({
|
|
1660
1914
|
provider: providerOptionsName,
|
|
1661
1915
|
providerOptions,
|
|
1662
1916
|
schema: googleLanguageModelOptions
|
|
1663
1917
|
});
|
|
1664
1918
|
if (googleOptions == null && providerOptionsName !== "google") {
|
|
1665
|
-
googleOptions = await
|
|
1919
|
+
googleOptions = await parseProviderOptions3({
|
|
1666
1920
|
provider: "google",
|
|
1667
1921
|
providerOptions,
|
|
1668
1922
|
schema: googleLanguageModelOptions
|
|
@@ -1726,6 +1980,19 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1726
1980
|
}
|
|
1727
1981
|
}
|
|
1728
1982
|
const isGemmaModel = this.modelId.toLowerCase().startsWith("gemma-");
|
|
1983
|
+
const isGemini25DeveloperApiModel = !isVertexProvider && gemini25ModelPattern2.test(this.modelId);
|
|
1984
|
+
if (isGemini25DeveloperApiModel && frequencyPenalty != null) {
|
|
1985
|
+
warnings.push({
|
|
1986
|
+
type: "unsupported",
|
|
1987
|
+
feature: "frequencyPenalty"
|
|
1988
|
+
});
|
|
1989
|
+
}
|
|
1990
|
+
if (isGemini25DeveloperApiModel && presencePenalty != null) {
|
|
1991
|
+
warnings.push({
|
|
1992
|
+
type: "unsupported",
|
|
1993
|
+
feature: "presencePenalty"
|
|
1994
|
+
});
|
|
1995
|
+
}
|
|
1729
1996
|
const { usesGemini3Features } = getGoogleModelCapabilities(this.modelId);
|
|
1730
1997
|
const { contents, systemInstruction } = convertToGoogleGenerativeAIMessages(
|
|
1731
1998
|
prompt,
|
|
@@ -1774,8 +2041,8 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1774
2041
|
temperature,
|
|
1775
2042
|
topK,
|
|
1776
2043
|
topP,
|
|
1777
|
-
frequencyPenalty,
|
|
1778
|
-
presencePenalty,
|
|
2044
|
+
frequencyPenalty: isGemini25DeveloperApiModel ? void 0 : frequencyPenalty,
|
|
2045
|
+
presencePenalty: isGemini25DeveloperApiModel ? void 0 : presencePenalty,
|
|
1779
2046
|
stopSequences,
|
|
1780
2047
|
seed,
|
|
1781
2048
|
// response format:
|
|
@@ -1810,10 +2077,10 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1810
2077
|
};
|
|
1811
2078
|
}
|
|
1812
2079
|
async doGenerate(options) {
|
|
1813
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
2080
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
1814
2081
|
const { args, warnings, providerOptionsName, extraHeaders } = await this.getArgs(options);
|
|
1815
|
-
const mergedHeaders =
|
|
1816
|
-
await
|
|
2082
|
+
const mergedHeaders = combineHeaders3(
|
|
2083
|
+
await resolve3(this.config.headers),
|
|
1817
2084
|
options.headers,
|
|
1818
2085
|
extraHeaders
|
|
1819
2086
|
);
|
|
@@ -1821,25 +2088,28 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1821
2088
|
responseHeaders,
|
|
1822
2089
|
value: response,
|
|
1823
2090
|
rawValue: rawResponse
|
|
1824
|
-
} = await
|
|
2091
|
+
} = await postJsonToApi3({
|
|
1825
2092
|
url: `${this.config.baseURL}/${getModelPath(
|
|
1826
2093
|
this.modelId
|
|
1827
2094
|
)}:generateContent`,
|
|
1828
2095
|
headers: mergedHeaders,
|
|
1829
2096
|
body: args,
|
|
1830
2097
|
failedResponseHandler: googleFailedResponseHandler,
|
|
1831
|
-
successfulResponseHandler:
|
|
2098
|
+
successfulResponseHandler: createJsonResponseHandler3(responseSchema),
|
|
1832
2099
|
abortSignal: options.abortSignal,
|
|
1833
2100
|
fetch: this.config.fetch
|
|
1834
2101
|
});
|
|
1835
|
-
const candidate = response.candidates[0];
|
|
2102
|
+
const candidate = (_a = response.candidates) == null ? void 0 : _a[0];
|
|
2103
|
+
const promptBlockReason = (_b = response.promptFeedback) == null ? void 0 : _b.blockReason;
|
|
2104
|
+
const isPromptBlocked = (candidate == null ? void 0 : candidate.finishReason) == null && promptBlockReason != null;
|
|
2105
|
+
const rawFinishReason = (_d = (_c = candidate == null ? void 0 : candidate.finishReason) != null ? _c : promptBlockReason) != null ? _d : void 0;
|
|
1836
2106
|
const content = [];
|
|
1837
|
-
const parts = (
|
|
2107
|
+
const parts = (_f = (_e = candidate == null ? void 0 : candidate.content) == null ? void 0 : _e.parts) != null ? _f : [];
|
|
1838
2108
|
const usageMetadata = response.usageMetadata;
|
|
1839
2109
|
let lastCodeExecutionToolCallId;
|
|
1840
2110
|
let lastServerToolCallId;
|
|
1841
2111
|
for (const part of parts) {
|
|
1842
|
-
if ("executableCode" in part && ((
|
|
2112
|
+
if ("executableCode" in part && ((_g = part.executableCode) == null ? void 0 : _g.code)) {
|
|
1843
2113
|
const toolCallId = this.config.generateId();
|
|
1844
2114
|
lastCodeExecutionToolCallId = toolCallId;
|
|
1845
2115
|
content.push({
|
|
@@ -1857,7 +2127,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1857
2127
|
toolName: "code_execution",
|
|
1858
2128
|
result: {
|
|
1859
2129
|
outcome: part.codeExecutionResult.outcome,
|
|
1860
|
-
output: (
|
|
2130
|
+
output: (_h = part.codeExecutionResult.output) != null ? _h : ""
|
|
1861
2131
|
}
|
|
1862
2132
|
});
|
|
1863
2133
|
} else if ("text" in part && part.text != null) {
|
|
@@ -1881,9 +2151,9 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1881
2151
|
} else if ("functionCall" in part && part.functionCall.name != null) {
|
|
1882
2152
|
content.push({
|
|
1883
2153
|
type: "tool-call",
|
|
1884
|
-
toolCallId: (
|
|
2154
|
+
toolCallId: (_i = part.functionCall.id) != null ? _i : this.config.generateId(),
|
|
1885
2155
|
toolName: part.functionCall.name,
|
|
1886
|
-
input: JSON.stringify((
|
|
2156
|
+
input: JSON.stringify((_j = part.functionCall.args) != null ? _j : {}),
|
|
1887
2157
|
providerMetadata: part.thoughtSignature ? {
|
|
1888
2158
|
[providerOptionsName]: {
|
|
1889
2159
|
thoughtSignature: part.thoughtSignature
|
|
@@ -1905,13 +2175,13 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1905
2175
|
} : void 0
|
|
1906
2176
|
});
|
|
1907
2177
|
} else if ("toolCall" in part && part.toolCall) {
|
|
1908
|
-
const toolCallId = (
|
|
2178
|
+
const toolCallId = (_k = part.toolCall.id) != null ? _k : this.config.generateId();
|
|
1909
2179
|
lastServerToolCallId = toolCallId;
|
|
1910
2180
|
content.push({
|
|
1911
2181
|
type: "tool-call",
|
|
1912
2182
|
toolCallId,
|
|
1913
2183
|
toolName: `server:${part.toolCall.toolType}`,
|
|
1914
|
-
input: JSON.stringify((
|
|
2184
|
+
input: JSON.stringify((_l = part.toolCall.args) != null ? _l : {}),
|
|
1915
2185
|
providerExecuted: true,
|
|
1916
2186
|
dynamic: true,
|
|
1917
2187
|
providerMetadata: part.thoughtSignature ? {
|
|
@@ -1928,12 +2198,12 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1928
2198
|
}
|
|
1929
2199
|
});
|
|
1930
2200
|
} else if ("toolResponse" in part && part.toolResponse) {
|
|
1931
|
-
const responseToolCallId = (
|
|
2201
|
+
const responseToolCallId = (_m = lastServerToolCallId != null ? lastServerToolCallId : part.toolResponse.id) != null ? _m : this.config.generateId();
|
|
1932
2202
|
content.push({
|
|
1933
2203
|
type: "tool-result",
|
|
1934
2204
|
toolCallId: responseToolCallId,
|
|
1935
2205
|
toolName: `server:${part.toolResponse.toolType}`,
|
|
1936
|
-
result: (
|
|
2206
|
+
result: (_n = part.toolResponse.response) != null ? _n : {},
|
|
1937
2207
|
providerMetadata: part.thoughtSignature ? {
|
|
1938
2208
|
[providerOptionsName]: {
|
|
1939
2209
|
thoughtSignature: part.thoughtSignature,
|
|
@@ -1950,42 +2220,42 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1950
2220
|
lastServerToolCallId = void 0;
|
|
1951
2221
|
}
|
|
1952
2222
|
}
|
|
1953
|
-
const sources = (
|
|
1954
|
-
groundingMetadata: candidate.groundingMetadata,
|
|
2223
|
+
const sources = (_o = extractSources({
|
|
2224
|
+
groundingMetadata: candidate == null ? void 0 : candidate.groundingMetadata,
|
|
1955
2225
|
generateId: this.config.generateId
|
|
1956
|
-
})) != null ?
|
|
2226
|
+
})) != null ? _o : [];
|
|
1957
2227
|
for (const source of sources) {
|
|
1958
2228
|
content.push(source);
|
|
1959
2229
|
}
|
|
1960
2230
|
return {
|
|
1961
2231
|
content,
|
|
1962
2232
|
finishReason: {
|
|
1963
|
-
unified: mapGoogleGenerativeAIFinishReason({
|
|
1964
|
-
finishReason:
|
|
2233
|
+
unified: isPromptBlocked ? "content-filter" : mapGoogleGenerativeAIFinishReason({
|
|
2234
|
+
finishReason: rawFinishReason,
|
|
1965
2235
|
// Only count client-executed tool calls for finish reason determination.
|
|
1966
2236
|
hasToolCalls: content.some(
|
|
1967
2237
|
(part) => part.type === "tool-call" && !part.providerExecuted
|
|
1968
2238
|
)
|
|
1969
2239
|
}),
|
|
1970
|
-
raw:
|
|
2240
|
+
raw: rawFinishReason
|
|
1971
2241
|
},
|
|
1972
2242
|
usage: convertGoogleGenerativeAIUsage(usageMetadata),
|
|
1973
2243
|
warnings,
|
|
1974
2244
|
providerMetadata: {
|
|
1975
2245
|
[providerOptionsName]: {
|
|
1976
|
-
promptFeedback: (
|
|
1977
|
-
groundingMetadata: (
|
|
1978
|
-
urlContextMetadata: (
|
|
1979
|
-
safetyRatings: (
|
|
2246
|
+
promptFeedback: (_p = response.promptFeedback) != null ? _p : null,
|
|
2247
|
+
groundingMetadata: (_q = candidate == null ? void 0 : candidate.groundingMetadata) != null ? _q : null,
|
|
2248
|
+
urlContextMetadata: (_r = candidate == null ? void 0 : candidate.urlContextMetadata) != null ? _r : null,
|
|
2249
|
+
safetyRatings: (_s = candidate == null ? void 0 : candidate.safetyRatings) != null ? _s : null,
|
|
1980
2250
|
usageMetadata: usageMetadata != null ? usageMetadata : null,
|
|
1981
|
-
finishMessage: (
|
|
1982
|
-
serviceTier: (
|
|
2251
|
+
finishMessage: (_t = candidate == null ? void 0 : candidate.finishMessage) != null ? _t : null,
|
|
2252
|
+
serviceTier: (_u = usageMetadata == null ? void 0 : usageMetadata.serviceTier) != null ? _u : null
|
|
1983
2253
|
}
|
|
1984
2254
|
},
|
|
1985
2255
|
request: { body: args },
|
|
1986
2256
|
response: {
|
|
1987
2257
|
// TODO timestamp, model id
|
|
1988
|
-
id: (
|
|
2258
|
+
id: (_v = response.responseId) != null ? _v : void 0,
|
|
1989
2259
|
headers: responseHeaders,
|
|
1990
2260
|
body: rawResponse
|
|
1991
2261
|
}
|
|
@@ -1993,12 +2263,12 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1993
2263
|
}
|
|
1994
2264
|
async doStream(options) {
|
|
1995
2265
|
const { args, warnings, providerOptionsName, extraHeaders } = await this.getArgs(options, { isStreaming: true });
|
|
1996
|
-
const headers =
|
|
1997
|
-
await
|
|
2266
|
+
const headers = combineHeaders3(
|
|
2267
|
+
await resolve3(this.config.headers),
|
|
1998
2268
|
options.headers,
|
|
1999
2269
|
extraHeaders
|
|
2000
2270
|
);
|
|
2001
|
-
const { responseHeaders, value: response } = await
|
|
2271
|
+
const { responseHeaders, value: response } = await postJsonToApi3({
|
|
2002
2272
|
url: `${this.config.baseURL}/${getModelPath(
|
|
2003
2273
|
this.modelId
|
|
2004
2274
|
)}:streamGenerateContent?alt=sse`,
|
|
@@ -2062,7 +2332,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2062
2332
|
controller.enqueue({ type: "stream-start", warnings });
|
|
2063
2333
|
},
|
|
2064
2334
|
transform(chunk, controller) {
|
|
2065
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
2335
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
2066
2336
|
if (options.includeRawChunks) {
|
|
2067
2337
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
2068
2338
|
}
|
|
@@ -2084,6 +2354,24 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2084
2354
|
}
|
|
2085
2355
|
const candidate = (_a = value.candidates) == null ? void 0 : _a[0];
|
|
2086
2356
|
if (candidate == null) {
|
|
2357
|
+
const promptBlockReason2 = (_b = value.promptFeedback) == null ? void 0 : _b.blockReason;
|
|
2358
|
+
if (promptBlockReason2 != null) {
|
|
2359
|
+
finishReason = {
|
|
2360
|
+
unified: "content-filter",
|
|
2361
|
+
raw: promptBlockReason2
|
|
2362
|
+
};
|
|
2363
|
+
providerMetadata = {
|
|
2364
|
+
[providerOptionsName]: {
|
|
2365
|
+
promptFeedback: (_c = value.promptFeedback) != null ? _c : null,
|
|
2366
|
+
groundingMetadata: lastGroundingMetadata,
|
|
2367
|
+
urlContextMetadata: lastUrlContextMetadata,
|
|
2368
|
+
safetyRatings: null,
|
|
2369
|
+
usageMetadata: usageMetadata != null ? usageMetadata : null,
|
|
2370
|
+
finishMessage: null,
|
|
2371
|
+
serviceTier: (_d = usage == null ? void 0 : usage.serviceTier) != null ? _d : null
|
|
2372
|
+
}
|
|
2373
|
+
};
|
|
2374
|
+
}
|
|
2087
2375
|
return;
|
|
2088
2376
|
}
|
|
2089
2377
|
const content = candidate.content;
|
|
@@ -2106,9 +2394,9 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2106
2394
|
}
|
|
2107
2395
|
}
|
|
2108
2396
|
if (content != null) {
|
|
2109
|
-
const parts = (
|
|
2397
|
+
const parts = (_e = content.parts) != null ? _e : [];
|
|
2110
2398
|
for (const part of parts) {
|
|
2111
|
-
if ("executableCode" in part && ((
|
|
2399
|
+
if ("executableCode" in part && ((_f = part.executableCode) == null ? void 0 : _f.code)) {
|
|
2112
2400
|
const toolCallId = generateId3();
|
|
2113
2401
|
lastCodeExecutionToolCallId = toolCallId;
|
|
2114
2402
|
controller.enqueue({
|
|
@@ -2127,7 +2415,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2127
2415
|
toolName: "code_execution",
|
|
2128
2416
|
result: {
|
|
2129
2417
|
outcome: part.codeExecutionResult.outcome,
|
|
2130
|
-
output: (
|
|
2418
|
+
output: (_g = part.codeExecutionResult.output) != null ? _g : ""
|
|
2131
2419
|
}
|
|
2132
2420
|
});
|
|
2133
2421
|
}
|
|
@@ -2221,7 +2509,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2221
2509
|
providerMetadata: fileMeta
|
|
2222
2510
|
});
|
|
2223
2511
|
} else if ("toolCall" in part && part.toolCall) {
|
|
2224
|
-
const toolCallId = (
|
|
2512
|
+
const toolCallId = (_h = part.toolCall.id) != null ? _h : generateId3();
|
|
2225
2513
|
lastServerToolCallId = toolCallId;
|
|
2226
2514
|
const serverMeta = {
|
|
2227
2515
|
[providerOptionsName]: {
|
|
@@ -2234,13 +2522,13 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2234
2522
|
type: "tool-call",
|
|
2235
2523
|
toolCallId,
|
|
2236
2524
|
toolName: `server:${part.toolCall.toolType}`,
|
|
2237
|
-
input: JSON.stringify((
|
|
2525
|
+
input: JSON.stringify((_i = part.toolCall.args) != null ? _i : {}),
|
|
2238
2526
|
providerExecuted: true,
|
|
2239
2527
|
dynamic: true,
|
|
2240
2528
|
providerMetadata: serverMeta
|
|
2241
2529
|
});
|
|
2242
2530
|
} else if ("toolResponse" in part && part.toolResponse) {
|
|
2243
|
-
const responseToolCallId = (
|
|
2531
|
+
const responseToolCallId = (_j = lastServerToolCallId != null ? lastServerToolCallId : part.toolResponse.id) != null ? _j : generateId3();
|
|
2244
2532
|
const serverMeta = {
|
|
2245
2533
|
[providerOptionsName]: {
|
|
2246
2534
|
...part.thoughtSignature ? { thoughtSignature: part.thoughtSignature } : {},
|
|
@@ -2252,7 +2540,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2252
2540
|
type: "tool-result",
|
|
2253
2541
|
toolCallId: responseToolCallId,
|
|
2254
2542
|
toolName: `server:${part.toolResponse.toolType}`,
|
|
2255
|
-
result: (
|
|
2543
|
+
result: (_k = part.toolResponse.response) != null ? _k : {},
|
|
2256
2544
|
providerMetadata: serverMeta
|
|
2257
2545
|
});
|
|
2258
2546
|
lastServerToolCallId = void 0;
|
|
@@ -2271,7 +2559,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2271
2559
|
const isNoArgsCompleteCall = part.functionCall.name != null && part.functionCall.args == null && part.functionCall.partialArgs == null && part.functionCall.willContinue !== true;
|
|
2272
2560
|
if (isStreamingChunk) {
|
|
2273
2561
|
if (part.functionCall.name != null) {
|
|
2274
|
-
const toolCallId = (
|
|
2562
|
+
const toolCallId = (_l = part.functionCall.id) != null ? _l : generateId3();
|
|
2275
2563
|
const accumulator = new GoogleJSONAccumulator();
|
|
2276
2564
|
activeStreamingToolCalls.push({
|
|
2277
2565
|
toolCallId,
|
|
@@ -2319,9 +2607,9 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2319
2607
|
} else if (isTerminalChunk && activeStreamingToolCalls.length > 0) {
|
|
2320
2608
|
finishActiveStreamingToolCall(controller);
|
|
2321
2609
|
} else if (isCompleteCall) {
|
|
2322
|
-
const toolCallId = (
|
|
2610
|
+
const toolCallId = (_m = part.functionCall.id) != null ? _m : generateId3();
|
|
2323
2611
|
const toolName = part.functionCall.name;
|
|
2324
|
-
const args2 = typeof part.functionCall.args === "string" ? part.functionCall.args : JSON.stringify((
|
|
2612
|
+
const args2 = typeof part.functionCall.args === "string" ? part.functionCall.args : JSON.stringify((_n = part.functionCall.args) != null ? _n : {});
|
|
2325
2613
|
controller.enqueue({
|
|
2326
2614
|
type: "tool-input-start",
|
|
2327
2615
|
id: toolCallId,
|
|
@@ -2348,7 +2636,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2348
2636
|
});
|
|
2349
2637
|
hasToolCalls = true;
|
|
2350
2638
|
} else if (isNoArgsCompleteCall) {
|
|
2351
|
-
const toolCallId = (
|
|
2639
|
+
const toolCallId = (_o = part.functionCall.id) != null ? _o : generateId3();
|
|
2352
2640
|
const toolName = part.functionCall.name;
|
|
2353
2641
|
controller.enqueue({
|
|
2354
2642
|
type: "tool-input-start",
|
|
@@ -2372,23 +2660,26 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2372
2660
|
}
|
|
2373
2661
|
}
|
|
2374
2662
|
}
|
|
2375
|
-
|
|
2663
|
+
const promptBlockReason = (_p = value.promptFeedback) == null ? void 0 : _p.blockReason;
|
|
2664
|
+
const isPromptBlocked = candidate.finishReason == null && promptBlockReason != null;
|
|
2665
|
+
const rawFinishReason = (_r = (_q = candidate.finishReason) != null ? _q : promptBlockReason) != null ? _r : void 0;
|
|
2666
|
+
if (rawFinishReason != null) {
|
|
2376
2667
|
finishReason = {
|
|
2377
|
-
unified: mapGoogleGenerativeAIFinishReason({
|
|
2378
|
-
finishReason:
|
|
2668
|
+
unified: isPromptBlocked ? "content-filter" : mapGoogleGenerativeAIFinishReason({
|
|
2669
|
+
finishReason: rawFinishReason,
|
|
2379
2670
|
hasToolCalls
|
|
2380
2671
|
}),
|
|
2381
|
-
raw:
|
|
2672
|
+
raw: rawFinishReason
|
|
2382
2673
|
};
|
|
2383
2674
|
providerMetadata = {
|
|
2384
2675
|
[providerOptionsName]: {
|
|
2385
|
-
promptFeedback: (
|
|
2676
|
+
promptFeedback: (_s = value.promptFeedback) != null ? _s : null,
|
|
2386
2677
|
groundingMetadata: lastGroundingMetadata,
|
|
2387
2678
|
urlContextMetadata: lastUrlContextMetadata,
|
|
2388
|
-
safetyRatings: (
|
|
2679
|
+
safetyRatings: (_t = candidate.safetyRatings) != null ? _t : null,
|
|
2389
2680
|
usageMetadata: usageMetadata != null ? usageMetadata : null,
|
|
2390
|
-
finishMessage: (
|
|
2391
|
-
serviceTier: (
|
|
2681
|
+
finishMessage: (_u = candidate.finishMessage) != null ? _u : null,
|
|
2682
|
+
serviceTier: (_v = usage == null ? void 0 : usage.serviceTier) != null ? _v : null
|
|
2392
2683
|
}
|
|
2393
2684
|
};
|
|
2394
2685
|
}
|
|
@@ -2514,192 +2805,192 @@ function extractSources({
|
|
|
2514
2805
|
}
|
|
2515
2806
|
return sources.length > 0 ? sources : void 0;
|
|
2516
2807
|
}
|
|
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:
|
|
2808
|
+
var getGroundingMetadataSchema = () => z7.object({
|
|
2809
|
+
webSearchQueries: z7.array(z7.string()).nullish(),
|
|
2810
|
+
imageSearchQueries: z7.array(z7.string()).nullish(),
|
|
2811
|
+
retrievalQueries: z7.array(z7.string()).nullish(),
|
|
2812
|
+
searchEntryPoint: z7.object({ renderedContent: z7.string() }).nullish(),
|
|
2813
|
+
groundingChunks: z7.array(
|
|
2814
|
+
z7.object({
|
|
2815
|
+
web: z7.object({ uri: z7.string(), title: z7.string().nullish() }).nullish(),
|
|
2816
|
+
image: z7.object({
|
|
2817
|
+
sourceUri: z7.string(),
|
|
2818
|
+
imageUri: z7.string(),
|
|
2819
|
+
title: z7.string().nullish(),
|
|
2820
|
+
domain: z7.string().nullish()
|
|
2530
2821
|
}).nullish(),
|
|
2531
|
-
retrievedContext:
|
|
2532
|
-
uri:
|
|
2533
|
-
title:
|
|
2534
|
-
text:
|
|
2535
|
-
fileSearchStore:
|
|
2822
|
+
retrievedContext: z7.object({
|
|
2823
|
+
uri: z7.string().nullish(),
|
|
2824
|
+
title: z7.string().nullish(),
|
|
2825
|
+
text: z7.string().nullish(),
|
|
2826
|
+
fileSearchStore: z7.string().nullish()
|
|
2536
2827
|
}).nullish(),
|
|
2537
|
-
maps:
|
|
2538
|
-
uri:
|
|
2539
|
-
title:
|
|
2540
|
-
text:
|
|
2541
|
-
placeId:
|
|
2828
|
+
maps: z7.object({
|
|
2829
|
+
uri: z7.string().nullish(),
|
|
2830
|
+
title: z7.string().nullish(),
|
|
2831
|
+
text: z7.string().nullish(),
|
|
2832
|
+
placeId: z7.string().nullish()
|
|
2542
2833
|
}).nullish()
|
|
2543
2834
|
})
|
|
2544
2835
|
).nullish(),
|
|
2545
|
-
groundingSupports:
|
|
2546
|
-
|
|
2547
|
-
segment:
|
|
2548
|
-
startIndex:
|
|
2549
|
-
endIndex:
|
|
2550
|
-
text:
|
|
2836
|
+
groundingSupports: z7.array(
|
|
2837
|
+
z7.object({
|
|
2838
|
+
segment: z7.object({
|
|
2839
|
+
startIndex: z7.number().nullish(),
|
|
2840
|
+
endIndex: z7.number().nullish(),
|
|
2841
|
+
text: z7.string().nullish()
|
|
2551
2842
|
}).nullish(),
|
|
2552
|
-
segment_text:
|
|
2553
|
-
groundingChunkIndices:
|
|
2554
|
-
supportChunkIndices:
|
|
2555
|
-
confidenceScores:
|
|
2556
|
-
confidenceScore:
|
|
2843
|
+
segment_text: z7.string().nullish(),
|
|
2844
|
+
groundingChunkIndices: z7.array(z7.number()).nullish(),
|
|
2845
|
+
supportChunkIndices: z7.array(z7.number()).nullish(),
|
|
2846
|
+
confidenceScores: z7.array(z7.number()).nullish(),
|
|
2847
|
+
confidenceScore: z7.array(z7.number()).nullish()
|
|
2557
2848
|
})
|
|
2558
2849
|
).nullish(),
|
|
2559
|
-
retrievalMetadata:
|
|
2560
|
-
|
|
2561
|
-
webDynamicRetrievalScore:
|
|
2850
|
+
retrievalMetadata: z7.union([
|
|
2851
|
+
z7.object({
|
|
2852
|
+
webDynamicRetrievalScore: z7.number()
|
|
2562
2853
|
}),
|
|
2563
|
-
|
|
2854
|
+
z7.object({})
|
|
2564
2855
|
]).nullish()
|
|
2565
2856
|
});
|
|
2566
|
-
var partialArgSchema =
|
|
2567
|
-
jsonPath:
|
|
2568
|
-
stringValue:
|
|
2569
|
-
numberValue:
|
|
2570
|
-
boolValue:
|
|
2571
|
-
nullValue:
|
|
2572
|
-
willContinue:
|
|
2857
|
+
var partialArgSchema = z7.object({
|
|
2858
|
+
jsonPath: z7.string(),
|
|
2859
|
+
stringValue: z7.string().nullish(),
|
|
2860
|
+
numberValue: z7.number().nullish(),
|
|
2861
|
+
boolValue: z7.boolean().nullish(),
|
|
2862
|
+
nullValue: z7.unknown().nullish(),
|
|
2863
|
+
willContinue: z7.boolean().nullish()
|
|
2573
2864
|
});
|
|
2574
|
-
var getContentSchema = () =>
|
|
2575
|
-
parts:
|
|
2576
|
-
|
|
2865
|
+
var getContentSchema = () => z7.object({
|
|
2866
|
+
parts: z7.array(
|
|
2867
|
+
z7.union([
|
|
2577
2868
|
// note: order matters since text can be fully empty
|
|
2578
|
-
|
|
2579
|
-
functionCall:
|
|
2580
|
-
id:
|
|
2581
|
-
name:
|
|
2582
|
-
args:
|
|
2583
|
-
partialArgs:
|
|
2584
|
-
willContinue:
|
|
2869
|
+
z7.object({
|
|
2870
|
+
functionCall: z7.object({
|
|
2871
|
+
id: z7.string().nullish(),
|
|
2872
|
+
name: z7.string().nullish(),
|
|
2873
|
+
args: z7.unknown().nullish(),
|
|
2874
|
+
partialArgs: z7.array(partialArgSchema).nullish(),
|
|
2875
|
+
willContinue: z7.boolean().nullish()
|
|
2585
2876
|
}),
|
|
2586
|
-
thoughtSignature:
|
|
2877
|
+
thoughtSignature: z7.string().nullish()
|
|
2587
2878
|
}),
|
|
2588
|
-
|
|
2589
|
-
inlineData:
|
|
2590
|
-
mimeType:
|
|
2591
|
-
data:
|
|
2879
|
+
z7.object({
|
|
2880
|
+
inlineData: z7.object({
|
|
2881
|
+
mimeType: z7.string(),
|
|
2882
|
+
data: z7.string()
|
|
2592
2883
|
}),
|
|
2593
|
-
thought:
|
|
2594
|
-
thoughtSignature:
|
|
2884
|
+
thought: z7.boolean().nullish(),
|
|
2885
|
+
thoughtSignature: z7.string().nullish()
|
|
2595
2886
|
}),
|
|
2596
|
-
|
|
2597
|
-
toolCall:
|
|
2598
|
-
toolType:
|
|
2599
|
-
args:
|
|
2600
|
-
id:
|
|
2887
|
+
z7.object({
|
|
2888
|
+
toolCall: z7.object({
|
|
2889
|
+
toolType: z7.string(),
|
|
2890
|
+
args: z7.unknown().nullish(),
|
|
2891
|
+
id: z7.string()
|
|
2601
2892
|
}),
|
|
2602
|
-
thoughtSignature:
|
|
2893
|
+
thoughtSignature: z7.string().nullish()
|
|
2603
2894
|
}),
|
|
2604
|
-
|
|
2605
|
-
toolResponse:
|
|
2606
|
-
toolType:
|
|
2607
|
-
response:
|
|
2608
|
-
id:
|
|
2895
|
+
z7.object({
|
|
2896
|
+
toolResponse: z7.object({
|
|
2897
|
+
toolType: z7.string(),
|
|
2898
|
+
response: z7.unknown().nullish(),
|
|
2899
|
+
id: z7.string()
|
|
2609
2900
|
}),
|
|
2610
|
-
thoughtSignature:
|
|
2901
|
+
thoughtSignature: z7.string().nullish()
|
|
2611
2902
|
}),
|
|
2612
|
-
|
|
2613
|
-
executableCode:
|
|
2614
|
-
language:
|
|
2615
|
-
code:
|
|
2903
|
+
z7.object({
|
|
2904
|
+
executableCode: z7.object({
|
|
2905
|
+
language: z7.string(),
|
|
2906
|
+
code: z7.string()
|
|
2616
2907
|
}).nullish(),
|
|
2617
|
-
codeExecutionResult:
|
|
2618
|
-
outcome:
|
|
2619
|
-
output:
|
|
2908
|
+
codeExecutionResult: z7.object({
|
|
2909
|
+
outcome: z7.string(),
|
|
2910
|
+
output: z7.string().nullish()
|
|
2620
2911
|
}).nullish(),
|
|
2621
|
-
text:
|
|
2622
|
-
thought:
|
|
2623
|
-
thoughtSignature:
|
|
2912
|
+
text: z7.string().nullish(),
|
|
2913
|
+
thought: z7.boolean().nullish(),
|
|
2914
|
+
thoughtSignature: z7.string().nullish()
|
|
2624
2915
|
})
|
|
2625
2916
|
])
|
|
2626
2917
|
).nullish()
|
|
2627
2918
|
});
|
|
2628
|
-
var getSafetyRatingSchema = () =>
|
|
2629
|
-
category:
|
|
2630
|
-
probability:
|
|
2631
|
-
probabilityScore:
|
|
2632
|
-
severity:
|
|
2633
|
-
severityScore:
|
|
2634
|
-
blocked:
|
|
2919
|
+
var getSafetyRatingSchema = () => z7.object({
|
|
2920
|
+
category: z7.string().nullish(),
|
|
2921
|
+
probability: z7.string().nullish(),
|
|
2922
|
+
probabilityScore: z7.number().nullish(),
|
|
2923
|
+
severity: z7.string().nullish(),
|
|
2924
|
+
severityScore: z7.number().nullish(),
|
|
2925
|
+
blocked: z7.boolean().nullish()
|
|
2635
2926
|
});
|
|
2636
|
-
var tokenDetailsSchema =
|
|
2637
|
-
|
|
2638
|
-
modality:
|
|
2639
|
-
tokenCount:
|
|
2927
|
+
var tokenDetailsSchema = z7.array(
|
|
2928
|
+
z7.object({
|
|
2929
|
+
modality: z7.string(),
|
|
2930
|
+
tokenCount: z7.number()
|
|
2640
2931
|
})
|
|
2641
2932
|
).nullish();
|
|
2642
|
-
var usageSchema =
|
|
2643
|
-
cachedContentTokenCount:
|
|
2644
|
-
thoughtsTokenCount:
|
|
2645
|
-
promptTokenCount:
|
|
2646
|
-
candidatesTokenCount:
|
|
2647
|
-
totalTokenCount:
|
|
2933
|
+
var usageSchema = z7.object({
|
|
2934
|
+
cachedContentTokenCount: z7.number().nullish(),
|
|
2935
|
+
thoughtsTokenCount: z7.number().nullish(),
|
|
2936
|
+
promptTokenCount: z7.number().nullish(),
|
|
2937
|
+
candidatesTokenCount: z7.number().nullish(),
|
|
2938
|
+
totalTokenCount: z7.number().nullish(),
|
|
2648
2939
|
// https://cloud.google.com/vertex-ai/generative-ai/docs/reference/rest/v1/GenerateContentResponse#TrafficType
|
|
2649
|
-
trafficType:
|
|
2650
|
-
serviceTier:
|
|
2940
|
+
trafficType: z7.string().nullish(),
|
|
2941
|
+
serviceTier: z7.string().nullish(),
|
|
2651
2942
|
// https://ai.google.dev/api/generate-content#Modality
|
|
2652
2943
|
promptTokensDetails: tokenDetailsSchema,
|
|
2653
2944
|
candidatesTokensDetails: tokenDetailsSchema
|
|
2654
2945
|
});
|
|
2655
|
-
var getUrlContextMetadataSchema = () =>
|
|
2656
|
-
urlMetadata:
|
|
2657
|
-
|
|
2658
|
-
retrievedUrl:
|
|
2659
|
-
urlRetrievalStatus:
|
|
2946
|
+
var getUrlContextMetadataSchema = () => z7.object({
|
|
2947
|
+
urlMetadata: z7.array(
|
|
2948
|
+
z7.object({
|
|
2949
|
+
retrievedUrl: z7.string(),
|
|
2950
|
+
urlRetrievalStatus: z7.string()
|
|
2660
2951
|
})
|
|
2661
2952
|
).nullish()
|
|
2662
2953
|
});
|
|
2663
2954
|
var responseSchema = lazySchema5(
|
|
2664
2955
|
() => zodSchema5(
|
|
2665
|
-
|
|
2666
|
-
responseId:
|
|
2667
|
-
candidates:
|
|
2668
|
-
|
|
2669
|
-
content: getContentSchema().nullish().or(
|
|
2670
|
-
finishReason:
|
|
2671
|
-
finishMessage:
|
|
2672
|
-
safetyRatings:
|
|
2956
|
+
z7.object({
|
|
2957
|
+
responseId: z7.string().nullish(),
|
|
2958
|
+
candidates: z7.array(
|
|
2959
|
+
z7.object({
|
|
2960
|
+
content: getContentSchema().nullish().or(z7.object({}).strict()),
|
|
2961
|
+
finishReason: z7.string().nullish(),
|
|
2962
|
+
finishMessage: z7.string().nullish(),
|
|
2963
|
+
safetyRatings: z7.array(getSafetyRatingSchema()).nullish(),
|
|
2673
2964
|
groundingMetadata: getGroundingMetadataSchema().nullish(),
|
|
2674
2965
|
urlContextMetadata: getUrlContextMetadataSchema().nullish()
|
|
2675
2966
|
})
|
|
2676
|
-
),
|
|
2967
|
+
).nullish(),
|
|
2677
2968
|
usageMetadata: usageSchema.nullish(),
|
|
2678
|
-
promptFeedback:
|
|
2679
|
-
blockReason:
|
|
2680
|
-
safetyRatings:
|
|
2969
|
+
promptFeedback: z7.object({
|
|
2970
|
+
blockReason: z7.string().nullish(),
|
|
2971
|
+
safetyRatings: z7.array(getSafetyRatingSchema()).nullish()
|
|
2681
2972
|
}).nullish()
|
|
2682
2973
|
})
|
|
2683
2974
|
)
|
|
2684
2975
|
);
|
|
2685
2976
|
var chunkSchema = lazySchema5(
|
|
2686
2977
|
() => zodSchema5(
|
|
2687
|
-
|
|
2688
|
-
responseId:
|
|
2689
|
-
candidates:
|
|
2690
|
-
|
|
2978
|
+
z7.object({
|
|
2979
|
+
responseId: z7.string().nullish(),
|
|
2980
|
+
candidates: z7.array(
|
|
2981
|
+
z7.object({
|
|
2691
2982
|
content: getContentSchema().nullish(),
|
|
2692
|
-
finishReason:
|
|
2693
|
-
finishMessage:
|
|
2694
|
-
safetyRatings:
|
|
2983
|
+
finishReason: z7.string().nullish(),
|
|
2984
|
+
finishMessage: z7.string().nullish(),
|
|
2985
|
+
safetyRatings: z7.array(getSafetyRatingSchema()).nullish(),
|
|
2695
2986
|
groundingMetadata: getGroundingMetadataSchema().nullish(),
|
|
2696
2987
|
urlContextMetadata: getUrlContextMetadataSchema().nullish()
|
|
2697
2988
|
})
|
|
2698
2989
|
).nullish(),
|
|
2699
2990
|
usageMetadata: usageSchema.nullish(),
|
|
2700
|
-
promptFeedback:
|
|
2701
|
-
blockReason:
|
|
2702
|
-
safetyRatings:
|
|
2991
|
+
promptFeedback: z7.object({
|
|
2992
|
+
blockReason: z7.string().nullish(),
|
|
2993
|
+
safetyRatings: z7.array(getSafetyRatingSchema()).nullish()
|
|
2703
2994
|
}).nullish()
|
|
2704
2995
|
})
|
|
2705
2996
|
)
|
|
@@ -2707,16 +2998,16 @@ var chunkSchema = lazySchema5(
|
|
|
2707
2998
|
|
|
2708
2999
|
// src/tool/code-execution.ts
|
|
2709
3000
|
import { createProviderToolFactoryWithOutputSchema } from "@ai-sdk/provider-utils";
|
|
2710
|
-
import { z as
|
|
3001
|
+
import { z as z8 } from "zod/v4";
|
|
2711
3002
|
var codeExecution = createProviderToolFactoryWithOutputSchema({
|
|
2712
3003
|
id: "google.code_execution",
|
|
2713
|
-
inputSchema:
|
|
2714
|
-
language:
|
|
2715
|
-
code:
|
|
3004
|
+
inputSchema: z8.object({
|
|
3005
|
+
language: z8.string().describe("The programming language of the code."),
|
|
3006
|
+
code: z8.string().describe("The code to be executed.")
|
|
2716
3007
|
}),
|
|
2717
|
-
outputSchema:
|
|
2718
|
-
outcome:
|
|
2719
|
-
output:
|
|
3008
|
+
outputSchema: z8.object({
|
|
3009
|
+
outcome: z8.string().describe('The outcome of the execution (e.g., "OUTCOME_OK").'),
|
|
3010
|
+
output: z8.string().describe("The output from the code execution.")
|
|
2720
3011
|
})
|
|
2721
3012
|
});
|
|
2722
3013
|
|
|
@@ -2726,10 +3017,10 @@ import {
|
|
|
2726
3017
|
lazySchema as lazySchema6,
|
|
2727
3018
|
zodSchema as zodSchema6
|
|
2728
3019
|
} from "@ai-sdk/provider-utils";
|
|
2729
|
-
import { z as
|
|
3020
|
+
import { z as z9 } from "zod/v4";
|
|
2730
3021
|
var enterpriseWebSearch = createProviderToolFactory({
|
|
2731
3022
|
id: "google.enterprise_web_search",
|
|
2732
|
-
inputSchema: lazySchema6(() => zodSchema6(
|
|
3023
|
+
inputSchema: lazySchema6(() => zodSchema6(z9.object({})))
|
|
2733
3024
|
});
|
|
2734
3025
|
|
|
2735
3026
|
// src/tool/file-search.ts
|
|
@@ -2738,20 +3029,20 @@ import {
|
|
|
2738
3029
|
lazySchema as lazySchema7,
|
|
2739
3030
|
zodSchema as zodSchema7
|
|
2740
3031
|
} from "@ai-sdk/provider-utils";
|
|
2741
|
-
import { z as
|
|
2742
|
-
var fileSearchArgsBaseSchema =
|
|
3032
|
+
import { z as z10 } from "zod/v4";
|
|
3033
|
+
var fileSearchArgsBaseSchema = z10.object({
|
|
2743
3034
|
/** The names of the file_search_stores to retrieve from.
|
|
2744
3035
|
* Example: `fileSearchStores/my-file-search-store-123`
|
|
2745
3036
|
*/
|
|
2746
|
-
fileSearchStoreNames:
|
|
3037
|
+
fileSearchStoreNames: z10.array(z10.string()).describe(
|
|
2747
3038
|
"The names of the file_search_stores to retrieve from. Example: `fileSearchStores/my-file-search-store-123`"
|
|
2748
3039
|
),
|
|
2749
3040
|
/** The number of file search retrieval chunks to retrieve. */
|
|
2750
|
-
topK:
|
|
3041
|
+
topK: z10.number().int().positive().describe("The number of file search retrieval chunks to retrieve.").optional(),
|
|
2751
3042
|
/** Metadata filter to apply to the file search retrieval documents.
|
|
2752
3043
|
* See https://google.aip.dev/160 for the syntax of the filter expression.
|
|
2753
3044
|
*/
|
|
2754
|
-
metadataFilter:
|
|
3045
|
+
metadataFilter: z10.string().describe(
|
|
2755
3046
|
"Metadata filter to apply to the file search retrieval documents. See https://google.aip.dev/160 for the syntax of the filter expression."
|
|
2756
3047
|
).optional()
|
|
2757
3048
|
}).passthrough();
|
|
@@ -2769,10 +3060,10 @@ import {
|
|
|
2769
3060
|
lazySchema as lazySchema8,
|
|
2770
3061
|
zodSchema as zodSchema8
|
|
2771
3062
|
} from "@ai-sdk/provider-utils";
|
|
2772
|
-
import { z as
|
|
3063
|
+
import { z as z11 } from "zod/v4";
|
|
2773
3064
|
var googleMaps = createProviderToolFactory3({
|
|
2774
3065
|
id: "google.google_maps",
|
|
2775
|
-
inputSchema: lazySchema8(() => zodSchema8(
|
|
3066
|
+
inputSchema: lazySchema8(() => zodSchema8(z11.object({})))
|
|
2776
3067
|
});
|
|
2777
3068
|
|
|
2778
3069
|
// src/tool/google-search.ts
|
|
@@ -2781,15 +3072,15 @@ import {
|
|
|
2781
3072
|
lazySchema as lazySchema9,
|
|
2782
3073
|
zodSchema as zodSchema9
|
|
2783
3074
|
} from "@ai-sdk/provider-utils";
|
|
2784
|
-
import { z as
|
|
2785
|
-
var googleSearchToolArgsBaseSchema =
|
|
2786
|
-
searchTypes:
|
|
2787
|
-
webSearch:
|
|
2788
|
-
imageSearch:
|
|
3075
|
+
import { z as z12 } from "zod/v4";
|
|
3076
|
+
var googleSearchToolArgsBaseSchema = z12.object({
|
|
3077
|
+
searchTypes: z12.object({
|
|
3078
|
+
webSearch: z12.object({}).optional(),
|
|
3079
|
+
imageSearch: z12.object({}).optional()
|
|
2789
3080
|
}).optional(),
|
|
2790
|
-
timeRangeFilter:
|
|
2791
|
-
startTime:
|
|
2792
|
-
endTime:
|
|
3081
|
+
timeRangeFilter: z12.object({
|
|
3082
|
+
startTime: z12.string(),
|
|
3083
|
+
endTime: z12.string()
|
|
2793
3084
|
}).optional()
|
|
2794
3085
|
}).passthrough();
|
|
2795
3086
|
var googleSearchToolArgsSchema = lazySchema9(
|
|
@@ -2808,20 +3099,20 @@ import {
|
|
|
2808
3099
|
lazySchema as lazySchema10,
|
|
2809
3100
|
zodSchema as zodSchema10
|
|
2810
3101
|
} from "@ai-sdk/provider-utils";
|
|
2811
|
-
import { z as
|
|
3102
|
+
import { z as z13 } from "zod/v4";
|
|
2812
3103
|
var urlContext = createProviderToolFactory5({
|
|
2813
3104
|
id: "google.url_context",
|
|
2814
|
-
inputSchema: lazySchema10(() => zodSchema10(
|
|
3105
|
+
inputSchema: lazySchema10(() => zodSchema10(z13.object({})))
|
|
2815
3106
|
});
|
|
2816
3107
|
|
|
2817
3108
|
// src/tool/vertex-rag-store.ts
|
|
2818
3109
|
import { createProviderToolFactory as createProviderToolFactory6 } from "@ai-sdk/provider-utils";
|
|
2819
|
-
import { z as
|
|
3110
|
+
import { z as z14 } from "zod/v4";
|
|
2820
3111
|
var vertexRagStore = createProviderToolFactory6({
|
|
2821
3112
|
id: "google.vertex_rag_store",
|
|
2822
|
-
inputSchema:
|
|
2823
|
-
ragCorpus:
|
|
2824
|
-
topK:
|
|
3113
|
+
inputSchema: z14.object({
|
|
3114
|
+
ragCorpus: z14.string(),
|
|
3115
|
+
topK: z14.number().optional()
|
|
2825
3116
|
})
|
|
2826
3117
|
});
|
|
2827
3118
|
|
|
@@ -2887,17 +3178,17 @@ var googleTools = {
|
|
|
2887
3178
|
|
|
2888
3179
|
// src/google-generative-ai-image-model.ts
|
|
2889
3180
|
import {
|
|
2890
|
-
combineHeaders as
|
|
2891
|
-
convertToBase64 as
|
|
2892
|
-
createJsonResponseHandler as
|
|
3181
|
+
combineHeaders as combineHeaders4,
|
|
3182
|
+
convertToBase64 as convertToBase643,
|
|
3183
|
+
createJsonResponseHandler as createJsonResponseHandler4,
|
|
2893
3184
|
generateId as defaultGenerateId,
|
|
2894
3185
|
lazySchema as lazySchema11,
|
|
2895
|
-
parseProviderOptions as
|
|
2896
|
-
postJsonToApi as
|
|
2897
|
-
resolve as
|
|
3186
|
+
parseProviderOptions as parseProviderOptions4,
|
|
3187
|
+
postJsonToApi as postJsonToApi4,
|
|
3188
|
+
resolve as resolve4,
|
|
2898
3189
|
zodSchema as zodSchema11
|
|
2899
3190
|
} from "@ai-sdk/provider-utils";
|
|
2900
|
-
import { z as
|
|
3191
|
+
import { z as z15 } from "zod/v4";
|
|
2901
3192
|
var GoogleGenerativeAIImageModel = class {
|
|
2902
3193
|
constructor(modelId, settings, config) {
|
|
2903
3194
|
this.modelId = modelId;
|
|
@@ -2962,7 +3253,7 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
2962
3253
|
details: "This model does not support the `seed` option through this provider."
|
|
2963
3254
|
});
|
|
2964
3255
|
}
|
|
2965
|
-
const googleOptions = await
|
|
3256
|
+
const googleOptions = await parseProviderOptions4({
|
|
2966
3257
|
provider: "google",
|
|
2967
3258
|
providerOptions,
|
|
2968
3259
|
schema: googleImageModelOptionsSchema
|
|
@@ -2989,12 +3280,12 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
2989
3280
|
instances: [{ prompt }],
|
|
2990
3281
|
parameters
|
|
2991
3282
|
};
|
|
2992
|
-
const { responseHeaders, value: response } = await
|
|
3283
|
+
const { responseHeaders, value: response } = await postJsonToApi4({
|
|
2993
3284
|
url: `${this.config.baseURL}/models/${this.modelId}:predict`,
|
|
2994
|
-
headers:
|
|
3285
|
+
headers: combineHeaders4(await resolve4(this.config.headers), headers),
|
|
2995
3286
|
body,
|
|
2996
3287
|
failedResponseHandler: googleFailedResponseHandler,
|
|
2997
|
-
successfulResponseHandler:
|
|
3288
|
+
successfulResponseHandler: createJsonResponseHandler4(
|
|
2998
3289
|
googleImageResponseSchema
|
|
2999
3290
|
),
|
|
3000
3291
|
abortSignal,
|
|
@@ -3075,7 +3366,7 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
3075
3366
|
const languageModelPrompt = [
|
|
3076
3367
|
{ role: "user", content: userContent }
|
|
3077
3368
|
];
|
|
3078
|
-
const googleImageOptions = await
|
|
3369
|
+
const googleImageOptions = await parseProviderOptions4({
|
|
3079
3370
|
provider: "google",
|
|
3080
3371
|
providerOptions,
|
|
3081
3372
|
schema: googleImageModelOptionsSchema
|
|
@@ -3115,7 +3406,7 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
3115
3406
|
const images = [];
|
|
3116
3407
|
for (const part of result.content) {
|
|
3117
3408
|
if (part.type === "file" && part.mediaType.startsWith("image/")) {
|
|
3118
|
-
images.push(
|
|
3409
|
+
images.push(convertToBase643(part.data));
|
|
3119
3410
|
}
|
|
3120
3411
|
}
|
|
3121
3412
|
const languageModelGoogleMetadata = (_h = (_g = result.providerMetadata) == null ? void 0 : _g.google) != null ? _h : {};
|
|
@@ -3146,16 +3437,16 @@ function isGeminiModel(modelId) {
|
|
|
3146
3437
|
}
|
|
3147
3438
|
var googleImageResponseSchema = lazySchema11(
|
|
3148
3439
|
() => zodSchema11(
|
|
3149
|
-
|
|
3150
|
-
predictions:
|
|
3440
|
+
z15.object({
|
|
3441
|
+
predictions: z15.array(z15.object({ bytesBase64Encoded: z15.string() })).default([])
|
|
3151
3442
|
})
|
|
3152
3443
|
)
|
|
3153
3444
|
);
|
|
3154
3445
|
var googleImageModelOptionsSchema = lazySchema11(
|
|
3155
3446
|
() => zodSchema11(
|
|
3156
|
-
|
|
3157
|
-
personGeneration:
|
|
3158
|
-
aspectRatio:
|
|
3447
|
+
z15.object({
|
|
3448
|
+
personGeneration: z15.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
|
|
3449
|
+
aspectRatio: z15.enum(["1:1", "3:4", "4:3", "9:16", "16:9"]).nullish(),
|
|
3159
3450
|
/**
|
|
3160
3451
|
* Enable Google Search grounding for Gemini image models. The value is
|
|
3161
3452
|
* forwarded as the args of the `google.tools.googleSearch` provider
|
|
@@ -3175,19 +3466,19 @@ import {
|
|
|
3175
3466
|
AISDKError
|
|
3176
3467
|
} from "@ai-sdk/provider";
|
|
3177
3468
|
import {
|
|
3178
|
-
combineHeaders as
|
|
3469
|
+
combineHeaders as combineHeaders5,
|
|
3179
3470
|
convertUint8ArrayToBase64,
|
|
3180
|
-
createJsonResponseHandler as
|
|
3471
|
+
createJsonResponseHandler as createJsonResponseHandler5,
|
|
3181
3472
|
delay,
|
|
3182
3473
|
getFromApi,
|
|
3183
3474
|
isSameOrigin,
|
|
3184
3475
|
lazySchema as lazySchema12,
|
|
3185
|
-
parseProviderOptions as
|
|
3186
|
-
postJsonToApi as
|
|
3187
|
-
resolve as
|
|
3476
|
+
parseProviderOptions as parseProviderOptions5,
|
|
3477
|
+
postJsonToApi as postJsonToApi5,
|
|
3478
|
+
resolve as resolve5,
|
|
3188
3479
|
zodSchema as zodSchema12
|
|
3189
3480
|
} from "@ai-sdk/provider-utils";
|
|
3190
|
-
import { z as
|
|
3481
|
+
import { z as z16 } from "zod/v4";
|
|
3191
3482
|
function getFirstFrameImage(options) {
|
|
3192
3483
|
var _a, _b;
|
|
3193
3484
|
return (_b = (_a = options.frameImages) == null ? void 0 : _a.find((frame) => frame.frameType === "first_frame")) == null ? void 0 : _b.image;
|
|
@@ -3266,7 +3557,7 @@ var GoogleGenerativeAIVideoModel = class {
|
|
|
3266
3557
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
3267
3558
|
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
3559
|
const warnings = [];
|
|
3269
|
-
const googleOptions = await
|
|
3560
|
+
const googleOptions = await parseProviderOptions5({
|
|
3270
3561
|
provider: "google",
|
|
3271
3562
|
providerOptions: options.providerOptions,
|
|
3272
3563
|
schema: googleVideoModelOptionsSchema
|
|
@@ -3341,17 +3632,17 @@ var GoogleGenerativeAIVideoModel = class {
|
|
|
3341
3632
|
}
|
|
3342
3633
|
}
|
|
3343
3634
|
}
|
|
3344
|
-
const { value: operation } = await
|
|
3635
|
+
const { value: operation } = await postJsonToApi5({
|
|
3345
3636
|
url: `${this.config.baseURL}/models/${this.modelId}:predictLongRunning`,
|
|
3346
|
-
headers:
|
|
3347
|
-
await
|
|
3637
|
+
headers: combineHeaders5(
|
|
3638
|
+
await resolve5(this.config.headers),
|
|
3348
3639
|
options.headers
|
|
3349
3640
|
),
|
|
3350
3641
|
body: {
|
|
3351
3642
|
instances,
|
|
3352
3643
|
parameters
|
|
3353
3644
|
},
|
|
3354
|
-
successfulResponseHandler:
|
|
3645
|
+
successfulResponseHandler: createJsonResponseHandler5(
|
|
3355
3646
|
googleOperationSchema
|
|
3356
3647
|
),
|
|
3357
3648
|
failedResponseHandler: googleFailedResponseHandler,
|
|
@@ -3386,11 +3677,11 @@ var GoogleGenerativeAIVideoModel = class {
|
|
|
3386
3677
|
}
|
|
3387
3678
|
const { value: statusOperation, responseHeaders: pollHeaders } = await getFromApi({
|
|
3388
3679
|
url: `${this.config.baseURL}/${operationName}`,
|
|
3389
|
-
headers:
|
|
3390
|
-
await
|
|
3680
|
+
headers: combineHeaders5(
|
|
3681
|
+
await resolve5(this.config.headers),
|
|
3391
3682
|
options.headers
|
|
3392
3683
|
),
|
|
3393
|
-
successfulResponseHandler:
|
|
3684
|
+
successfulResponseHandler: createJsonResponseHandler5(
|
|
3394
3685
|
googleOperationSchema
|
|
3395
3686
|
),
|
|
3396
3687
|
failedResponseHandler: googleFailedResponseHandler,
|
|
@@ -3415,7 +3706,7 @@ var GoogleGenerativeAIVideoModel = class {
|
|
|
3415
3706
|
}
|
|
3416
3707
|
const videos = [];
|
|
3417
3708
|
const videoMetadata = [];
|
|
3418
|
-
const resolvedHeaders = await
|
|
3709
|
+
const resolvedHeaders = await resolve5(this.config.headers);
|
|
3419
3710
|
const apiKey = resolvedHeaders == null ? void 0 : resolvedHeaders["x-goog-api-key"];
|
|
3420
3711
|
for (const generatedSample of response.generateVideoResponse.generatedSamples) {
|
|
3421
3712
|
if ((_h = generatedSample.video) == null ? void 0 : _h.uri) {
|
|
@@ -3452,20 +3743,20 @@ var GoogleGenerativeAIVideoModel = class {
|
|
|
3452
3743
|
};
|
|
3453
3744
|
}
|
|
3454
3745
|
};
|
|
3455
|
-
var googleOperationSchema =
|
|
3456
|
-
name:
|
|
3457
|
-
done:
|
|
3458
|
-
error:
|
|
3459
|
-
code:
|
|
3460
|
-
message:
|
|
3461
|
-
status:
|
|
3746
|
+
var googleOperationSchema = z16.object({
|
|
3747
|
+
name: z16.string().nullish(),
|
|
3748
|
+
done: z16.boolean().nullish(),
|
|
3749
|
+
error: z16.object({
|
|
3750
|
+
code: z16.number().nullish(),
|
|
3751
|
+
message: z16.string(),
|
|
3752
|
+
status: z16.string().nullish()
|
|
3462
3753
|
}).nullish(),
|
|
3463
|
-
response:
|
|
3464
|
-
generateVideoResponse:
|
|
3465
|
-
generatedSamples:
|
|
3466
|
-
|
|
3467
|
-
video:
|
|
3468
|
-
uri:
|
|
3754
|
+
response: z16.object({
|
|
3755
|
+
generateVideoResponse: z16.object({
|
|
3756
|
+
generatedSamples: z16.array(
|
|
3757
|
+
z16.object({
|
|
3758
|
+
video: z16.object({
|
|
3759
|
+
uri: z16.string().nullish()
|
|
3469
3760
|
}).nullish()
|
|
3470
3761
|
})
|
|
3471
3762
|
).nullish()
|
|
@@ -3474,15 +3765,15 @@ var googleOperationSchema = z14.object({
|
|
|
3474
3765
|
});
|
|
3475
3766
|
var googleVideoModelOptionsSchema = lazySchema12(
|
|
3476
3767
|
() => zodSchema12(
|
|
3477
|
-
|
|
3478
|
-
pollIntervalMs:
|
|
3479
|
-
pollTimeoutMs:
|
|
3480
|
-
personGeneration:
|
|
3481
|
-
negativePrompt:
|
|
3482
|
-
referenceImages:
|
|
3483
|
-
|
|
3484
|
-
bytesBase64Encoded:
|
|
3485
|
-
gcsUri:
|
|
3768
|
+
z16.object({
|
|
3769
|
+
pollIntervalMs: z16.number().positive().nullish(),
|
|
3770
|
+
pollTimeoutMs: z16.number().positive().nullish(),
|
|
3771
|
+
personGeneration: z16.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
|
|
3772
|
+
negativePrompt: z16.string().nullish(),
|
|
3773
|
+
referenceImages: z16.array(
|
|
3774
|
+
z16.object({
|
|
3775
|
+
bytesBase64Encoded: z16.string().nullish(),
|
|
3776
|
+
gcsUri: z16.string().nullish()
|
|
3486
3777
|
})
|
|
3487
3778
|
).nullish()
|
|
3488
3779
|
}).passthrough()
|
|
@@ -3491,13 +3782,13 @@ var googleVideoModelOptionsSchema = lazySchema12(
|
|
|
3491
3782
|
|
|
3492
3783
|
// src/interactions/google-interactions-language-model.ts
|
|
3493
3784
|
import {
|
|
3494
|
-
combineHeaders as
|
|
3785
|
+
combineHeaders as combineHeaders7,
|
|
3495
3786
|
createEventSourceResponseHandler as createEventSourceResponseHandler3,
|
|
3496
|
-
createJsonResponseHandler as
|
|
3787
|
+
createJsonResponseHandler as createJsonResponseHandler7,
|
|
3497
3788
|
generateId as defaultGenerateId2,
|
|
3498
|
-
parseProviderOptions as
|
|
3499
|
-
postJsonToApi as
|
|
3500
|
-
resolve as
|
|
3789
|
+
parseProviderOptions as parseProviderOptions6,
|
|
3790
|
+
postJsonToApi as postJsonToApi6,
|
|
3791
|
+
resolve as resolve6
|
|
3501
3792
|
} from "@ai-sdk/provider-utils";
|
|
3502
3793
|
|
|
3503
3794
|
// src/interactions/convert-google-interactions-usage.ts
|
|
@@ -4264,7 +4555,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
4264
4555
|
}
|
|
4265
4556
|
|
|
4266
4557
|
// src/interactions/convert-to-google-interactions-input.ts
|
|
4267
|
-
import { convertToBase64 as
|
|
4558
|
+
import { convertToBase64 as convertToBase644, secureJsonParse as secureJsonParse2 } from "@ai-sdk/provider-utils";
|
|
4268
4559
|
function getTopLevelMediaType(mediaType) {
|
|
4269
4560
|
const slashIndex = mediaType.indexOf("/");
|
|
4270
4561
|
return slashIndex === -1 ? mediaType : mediaType.substring(0, slashIndex);
|
|
@@ -4453,7 +4744,7 @@ function convertFilePartToContent({
|
|
|
4453
4744
|
}
|
|
4454
4745
|
return {
|
|
4455
4746
|
type: kind,
|
|
4456
|
-
data:
|
|
4747
|
+
data: convertToBase644(part.data),
|
|
4457
4748
|
mime_type: part.mediaType,
|
|
4458
4749
|
...resolutionField
|
|
4459
4750
|
};
|
|
@@ -4627,7 +4918,7 @@ function filePartToImageBlock({
|
|
|
4627
4918
|
}
|
|
4628
4919
|
return {
|
|
4629
4920
|
type: "image",
|
|
4630
|
-
data:
|
|
4921
|
+
data: convertToBase644(part.data),
|
|
4631
4922
|
mime_type: part.mediaType
|
|
4632
4923
|
};
|
|
4633
4924
|
}
|
|
@@ -4658,30 +4949,30 @@ import {
|
|
|
4658
4949
|
lazySchema as lazySchema13,
|
|
4659
4950
|
zodSchema as zodSchema13
|
|
4660
4951
|
} from "@ai-sdk/provider-utils";
|
|
4661
|
-
import { z as
|
|
4662
|
-
var tokenByModalitySchema = () =>
|
|
4663
|
-
modality:
|
|
4664
|
-
tokens:
|
|
4952
|
+
import { z as z17 } from "zod/v4";
|
|
4953
|
+
var tokenByModalitySchema = () => z17.object({
|
|
4954
|
+
modality: z17.string().nullish(),
|
|
4955
|
+
tokens: z17.number().nullish()
|
|
4665
4956
|
}).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:
|
|
4957
|
+
var usageSchema2 = () => z17.object({
|
|
4958
|
+
total_input_tokens: z17.number().nullish(),
|
|
4959
|
+
total_output_tokens: z17.number().nullish(),
|
|
4960
|
+
total_thought_tokens: z17.number().nullish(),
|
|
4961
|
+
total_cached_tokens: z17.number().nullish(),
|
|
4962
|
+
total_tool_use_tokens: z17.number().nullish(),
|
|
4963
|
+
total_tokens: z17.number().nullish(),
|
|
4964
|
+
input_tokens_by_modality: z17.array(tokenByModalitySchema()).nullish(),
|
|
4965
|
+
output_tokens_by_modality: z17.array(tokenByModalitySchema()).nullish(),
|
|
4966
|
+
cached_tokens_by_modality: z17.array(tokenByModalitySchema()).nullish(),
|
|
4967
|
+
tool_use_tokens_by_modality: z17.array(tokenByModalitySchema()).nullish(),
|
|
4968
|
+
grounding_tool_count: z17.array(
|
|
4969
|
+
z17.object({
|
|
4970
|
+
type: z17.string().nullish(),
|
|
4971
|
+
count: z17.number().nullish()
|
|
4681
4972
|
}).loose()
|
|
4682
4973
|
).nullish()
|
|
4683
4974
|
}).loose();
|
|
4684
|
-
var interactionStatusSchema = () =>
|
|
4975
|
+
var interactionStatusSchema = () => z17.enum([
|
|
4685
4976
|
"in_progress",
|
|
4686
4977
|
"requires_action",
|
|
4687
4978
|
"completed",
|
|
@@ -4690,69 +4981,69 @@ var interactionStatusSchema = () => z15.enum([
|
|
|
4690
4981
|
"incomplete"
|
|
4691
4982
|
]);
|
|
4692
4983
|
var annotationSchema = () => {
|
|
4693
|
-
const urlCitation =
|
|
4694
|
-
type:
|
|
4695
|
-
url:
|
|
4696
|
-
title:
|
|
4697
|
-
start_index:
|
|
4698
|
-
end_index:
|
|
4984
|
+
const urlCitation = z17.object({
|
|
4985
|
+
type: z17.literal("url_citation"),
|
|
4986
|
+
url: z17.string().nullish(),
|
|
4987
|
+
title: z17.string().nullish(),
|
|
4988
|
+
start_index: z17.number().nullish(),
|
|
4989
|
+
end_index: z17.number().nullish()
|
|
4699
4990
|
}).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:
|
|
4991
|
+
const fileCitation = z17.object({
|
|
4992
|
+
type: z17.literal("file_citation"),
|
|
4993
|
+
file_name: z17.string().nullish(),
|
|
4994
|
+
document_uri: z17.string().nullish(),
|
|
4995
|
+
url: z17.string().nullish(),
|
|
4996
|
+
page_number: z17.number().nullish(),
|
|
4997
|
+
media_id: z17.string().nullish(),
|
|
4998
|
+
start_index: z17.number().nullish(),
|
|
4999
|
+
end_index: z17.number().nullish(),
|
|
5000
|
+
custom_metadata: z17.record(z17.string(), z17.unknown()).nullish()
|
|
4710
5001
|
}).loose();
|
|
4711
|
-
const placeCitation =
|
|
4712
|
-
type:
|
|
4713
|
-
name:
|
|
4714
|
-
url:
|
|
4715
|
-
place_id:
|
|
4716
|
-
start_index:
|
|
4717
|
-
end_index:
|
|
5002
|
+
const placeCitation = z17.object({
|
|
5003
|
+
type: z17.literal("place_citation"),
|
|
5004
|
+
name: z17.string().nullish(),
|
|
5005
|
+
url: z17.string().nullish(),
|
|
5006
|
+
place_id: z17.string().nullish(),
|
|
5007
|
+
start_index: z17.number().nullish(),
|
|
5008
|
+
end_index: z17.number().nullish()
|
|
4718
5009
|
}).loose();
|
|
4719
|
-
return
|
|
5010
|
+
return z17.union([
|
|
4720
5011
|
urlCitation,
|
|
4721
5012
|
fileCitation,
|
|
4722
5013
|
placeCitation,
|
|
4723
|
-
|
|
5014
|
+
z17.object({ type: z17.string() }).loose()
|
|
4724
5015
|
]);
|
|
4725
5016
|
};
|
|
4726
|
-
var thoughtSummaryItemSchema = () =>
|
|
4727
|
-
type:
|
|
4728
|
-
text:
|
|
4729
|
-
data:
|
|
4730
|
-
mime_type:
|
|
5017
|
+
var thoughtSummaryItemSchema = () => z17.object({
|
|
5018
|
+
type: z17.string(),
|
|
5019
|
+
text: z17.string().nullish(),
|
|
5020
|
+
data: z17.string().nullish(),
|
|
5021
|
+
mime_type: z17.string().nullish()
|
|
4731
5022
|
}).loose();
|
|
4732
5023
|
var contentBlockSchema = () => {
|
|
4733
|
-
const textContent =
|
|
4734
|
-
type:
|
|
4735
|
-
text:
|
|
4736
|
-
annotations:
|
|
5024
|
+
const textContent = z17.object({
|
|
5025
|
+
type: z17.literal("text"),
|
|
5026
|
+
text: z17.string(),
|
|
5027
|
+
annotations: z17.array(annotationSchema()).nullish()
|
|
4737
5028
|
}).loose();
|
|
4738
|
-
const imageContent =
|
|
4739
|
-
type:
|
|
4740
|
-
data:
|
|
4741
|
-
mime_type:
|
|
4742
|
-
resolution:
|
|
4743
|
-
uri:
|
|
5029
|
+
const imageContent = z17.object({
|
|
5030
|
+
type: z17.literal("image"),
|
|
5031
|
+
data: z17.string().nullish(),
|
|
5032
|
+
mime_type: z17.string().nullish(),
|
|
5033
|
+
resolution: z17.enum(["low", "medium", "high", "ultra_high"]).nullish(),
|
|
5034
|
+
uri: z17.string().nullish()
|
|
4744
5035
|
}).loose();
|
|
4745
|
-
const videoContent =
|
|
4746
|
-
type:
|
|
4747
|
-
data:
|
|
4748
|
-
mime_type:
|
|
4749
|
-
uri:
|
|
5036
|
+
const videoContent = z17.object({
|
|
5037
|
+
type: z17.literal("video"),
|
|
5038
|
+
data: z17.string().nullish(),
|
|
5039
|
+
mime_type: z17.string().nullish(),
|
|
5040
|
+
uri: z17.string().nullish()
|
|
4750
5041
|
}).loose();
|
|
4751
|
-
return
|
|
5042
|
+
return z17.union([
|
|
4752
5043
|
textContent,
|
|
4753
5044
|
imageContent,
|
|
4754
5045
|
videoContent,
|
|
4755
|
-
|
|
5046
|
+
z17.object({ type: z17.string() }).loose()
|
|
4756
5047
|
]);
|
|
4757
5048
|
};
|
|
4758
5049
|
var BUILTIN_TOOL_CALL_STEP_TYPES = [
|
|
@@ -4772,73 +5063,73 @@ var BUILTIN_TOOL_RESULT_STEP_TYPES = [
|
|
|
4772
5063
|
"mcp_server_tool_result"
|
|
4773
5064
|
];
|
|
4774
5065
|
var stepSchema = () => {
|
|
4775
|
-
const userInputStep =
|
|
4776
|
-
type:
|
|
4777
|
-
content:
|
|
5066
|
+
const userInputStep = z17.object({
|
|
5067
|
+
type: z17.literal("user_input"),
|
|
5068
|
+
content: z17.array(contentBlockSchema()).nullish()
|
|
4778
5069
|
}).loose();
|
|
4779
|
-
const modelOutputStep =
|
|
4780
|
-
type:
|
|
4781
|
-
content:
|
|
5070
|
+
const modelOutputStep = z17.object({
|
|
5071
|
+
type: z17.literal("model_output"),
|
|
5072
|
+
content: z17.array(contentBlockSchema()).nullish()
|
|
4782
5073
|
}).loose();
|
|
4783
|
-
const functionCallStep =
|
|
4784
|
-
type:
|
|
4785
|
-
id:
|
|
4786
|
-
name:
|
|
4787
|
-
arguments:
|
|
4788
|
-
signature:
|
|
5074
|
+
const functionCallStep = z17.object({
|
|
5075
|
+
type: z17.literal("function_call"),
|
|
5076
|
+
id: z17.string(),
|
|
5077
|
+
name: z17.string(),
|
|
5078
|
+
arguments: z17.record(z17.string(), z17.unknown()).nullish(),
|
|
5079
|
+
signature: z17.string().nullish()
|
|
4789
5080
|
}).loose();
|
|
4790
|
-
const thoughtStep =
|
|
4791
|
-
type:
|
|
4792
|
-
signature:
|
|
4793
|
-
summary:
|
|
5081
|
+
const thoughtStep = z17.object({
|
|
5082
|
+
type: z17.literal("thought"),
|
|
5083
|
+
signature: z17.string().nullish(),
|
|
5084
|
+
summary: z17.array(thoughtSummaryItemSchema()).nullish()
|
|
4794
5085
|
}).loose();
|
|
4795
|
-
const builtinToolCallStep =
|
|
4796
|
-
type:
|
|
4797
|
-
id:
|
|
4798
|
-
arguments:
|
|
4799
|
-
name:
|
|
4800
|
-
server_name:
|
|
4801
|
-
search_type:
|
|
4802
|
-
signature:
|
|
5086
|
+
const builtinToolCallStep = z17.object({
|
|
5087
|
+
type: z17.enum(BUILTIN_TOOL_CALL_STEP_TYPES),
|
|
5088
|
+
id: z17.string(),
|
|
5089
|
+
arguments: z17.record(z17.string(), z17.unknown()).nullish(),
|
|
5090
|
+
name: z17.string().nullish(),
|
|
5091
|
+
server_name: z17.string().nullish(),
|
|
5092
|
+
search_type: z17.string().nullish(),
|
|
5093
|
+
signature: z17.string().nullish()
|
|
4803
5094
|
}).loose();
|
|
4804
|
-
const builtinToolResultStep =
|
|
4805
|
-
type:
|
|
4806
|
-
call_id:
|
|
4807
|
-
result:
|
|
4808
|
-
is_error:
|
|
4809
|
-
name:
|
|
4810
|
-
server_name:
|
|
4811
|
-
signature:
|
|
5095
|
+
const builtinToolResultStep = z17.object({
|
|
5096
|
+
type: z17.enum(BUILTIN_TOOL_RESULT_STEP_TYPES),
|
|
5097
|
+
call_id: z17.string(),
|
|
5098
|
+
result: z17.unknown().nullish(),
|
|
5099
|
+
is_error: z17.boolean().nullish(),
|
|
5100
|
+
name: z17.string().nullish(),
|
|
5101
|
+
server_name: z17.string().nullish(),
|
|
5102
|
+
signature: z17.string().nullish()
|
|
4812
5103
|
}).loose();
|
|
4813
|
-
return
|
|
5104
|
+
return z17.union([
|
|
4814
5105
|
userInputStep,
|
|
4815
5106
|
modelOutputStep,
|
|
4816
5107
|
functionCallStep,
|
|
4817
5108
|
thoughtStep,
|
|
4818
5109
|
builtinToolCallStep,
|
|
4819
5110
|
builtinToolResultStep,
|
|
4820
|
-
|
|
5111
|
+
z17.object({ type: z17.string() }).loose()
|
|
4821
5112
|
]);
|
|
4822
5113
|
};
|
|
4823
5114
|
var googleInteractionsResponseSchema = lazySchema13(
|
|
4824
5115
|
() => zodSchema13(
|
|
4825
|
-
|
|
5116
|
+
z17.object({
|
|
4826
5117
|
/*
|
|
4827
5118
|
* `id` is omitted from the response body when `store: false` (fully
|
|
4828
5119
|
* stateless mode) — there is no server-side interaction record for the
|
|
4829
5120
|
* client to reference. `nullish` lets the schema accept that shape.
|
|
4830
5121
|
*/
|
|
4831
|
-
id:
|
|
4832
|
-
created:
|
|
4833
|
-
updated:
|
|
5122
|
+
id: z17.string().nullish(),
|
|
5123
|
+
created: z17.string().nullish(),
|
|
5124
|
+
updated: z17.string().nullish(),
|
|
4834
5125
|
status: interactionStatusSchema(),
|
|
4835
|
-
model:
|
|
4836
|
-
agent:
|
|
4837
|
-
steps:
|
|
5126
|
+
model: z17.string().nullish(),
|
|
5127
|
+
agent: z17.string().nullish(),
|
|
5128
|
+
steps: z17.array(stepSchema()).nullish(),
|
|
4838
5129
|
usage: usageSchema2().nullish(),
|
|
4839
|
-
service_tier:
|
|
4840
|
-
previous_interaction_id:
|
|
4841
|
-
response_modalities:
|
|
5130
|
+
service_tier: z17.string().nullish(),
|
|
5131
|
+
previous_interaction_id: z17.string().nullish(),
|
|
5132
|
+
response_modalities: z17.array(z17.string()).nullish()
|
|
4842
5133
|
}).loose()
|
|
4843
5134
|
)
|
|
4844
5135
|
);
|
|
@@ -4848,82 +5139,82 @@ var googleInteractionsEventSchema = lazySchema13(
|
|
|
4848
5139
|
const status = interactionStatusSchema();
|
|
4849
5140
|
const annotation = annotationSchema();
|
|
4850
5141
|
const thoughtSummaryItem = thoughtSummaryItemSchema();
|
|
4851
|
-
const interactionCreatedEvent =
|
|
4852
|
-
event_type:
|
|
4853
|
-
event_id:
|
|
4854
|
-
interaction:
|
|
5142
|
+
const interactionCreatedEvent = z17.object({
|
|
5143
|
+
event_type: z17.literal("interaction.created"),
|
|
5144
|
+
event_id: z17.string().nullish(),
|
|
5145
|
+
interaction: z17.object({
|
|
4855
5146
|
/*
|
|
4856
5147
|
* `id` is omitted when `store: false` (fully stateless mode);
|
|
4857
5148
|
* see the matching note on `googleInteractionsResponseSchema.id`.
|
|
4858
5149
|
*/
|
|
4859
|
-
id:
|
|
4860
|
-
created:
|
|
4861
|
-
model:
|
|
4862
|
-
agent:
|
|
5150
|
+
id: z17.string().nullish(),
|
|
5151
|
+
created: z17.string().nullish(),
|
|
5152
|
+
model: z17.string().nullish(),
|
|
5153
|
+
agent: z17.string().nullish(),
|
|
4863
5154
|
status: status.nullish()
|
|
4864
5155
|
}).loose()
|
|
4865
5156
|
}).loose();
|
|
4866
|
-
const stepStartEvent =
|
|
4867
|
-
event_type:
|
|
4868
|
-
event_id:
|
|
4869
|
-
index:
|
|
5157
|
+
const stepStartEvent = z17.object({
|
|
5158
|
+
event_type: z17.literal("step.start"),
|
|
5159
|
+
event_id: z17.string().nullish(),
|
|
5160
|
+
index: z17.number(),
|
|
4870
5161
|
step: stepSchema()
|
|
4871
5162
|
}).loose();
|
|
4872
|
-
const stepDeltaText =
|
|
4873
|
-
type:
|
|
4874
|
-
text:
|
|
5163
|
+
const stepDeltaText = z17.object({
|
|
5164
|
+
type: z17.literal("text"),
|
|
5165
|
+
text: z17.string()
|
|
4875
5166
|
}).loose();
|
|
4876
|
-
const stepDeltaThoughtSummary =
|
|
4877
|
-
type:
|
|
5167
|
+
const stepDeltaThoughtSummary = z17.object({
|
|
5168
|
+
type: z17.literal("thought_summary"),
|
|
4878
5169
|
content: thoughtSummaryItem.nullish()
|
|
4879
5170
|
}).loose();
|
|
4880
|
-
const stepDeltaThoughtSignature =
|
|
4881
|
-
type:
|
|
4882
|
-
signature:
|
|
5171
|
+
const stepDeltaThoughtSignature = z17.object({
|
|
5172
|
+
type: z17.literal("thought_signature"),
|
|
5173
|
+
signature: z17.string().nullish()
|
|
4883
5174
|
}).loose();
|
|
4884
|
-
const stepDeltaArgumentsDelta =
|
|
4885
|
-
type:
|
|
4886
|
-
arguments:
|
|
4887
|
-
id:
|
|
4888
|
-
signature:
|
|
5175
|
+
const stepDeltaArgumentsDelta = z17.object({
|
|
5176
|
+
type: z17.literal("arguments_delta"),
|
|
5177
|
+
arguments: z17.string().nullish(),
|
|
5178
|
+
id: z17.string().nullish(),
|
|
5179
|
+
signature: z17.string().nullish()
|
|
4889
5180
|
}).loose();
|
|
4890
|
-
const stepDeltaTextAnnotation =
|
|
4891
|
-
type:
|
|
4892
|
-
annotations:
|
|
5181
|
+
const stepDeltaTextAnnotation = z17.object({
|
|
5182
|
+
type: z17.enum(["text_annotation_delta", "text_annotation"]),
|
|
5183
|
+
annotations: z17.array(annotation).nullish()
|
|
4893
5184
|
}).loose();
|
|
4894
|
-
const stepDeltaImage =
|
|
4895
|
-
type:
|
|
4896
|
-
data:
|
|
4897
|
-
mime_type:
|
|
4898
|
-
resolution:
|
|
4899
|
-
uri:
|
|
5185
|
+
const stepDeltaImage = z17.object({
|
|
5186
|
+
type: z17.literal("image"),
|
|
5187
|
+
data: z17.string().nullish(),
|
|
5188
|
+
mime_type: z17.string().nullish(),
|
|
5189
|
+
resolution: z17.enum(["low", "medium", "high", "ultra_high"]).nullish(),
|
|
5190
|
+
uri: z17.string().nullish()
|
|
4900
5191
|
}).loose();
|
|
4901
|
-
const stepDeltaVideo =
|
|
4902
|
-
type:
|
|
4903
|
-
data:
|
|
4904
|
-
mime_type:
|
|
4905
|
-
uri:
|
|
5192
|
+
const stepDeltaVideo = z17.object({
|
|
5193
|
+
type: z17.literal("video"),
|
|
5194
|
+
data: z17.string().nullish(),
|
|
5195
|
+
mime_type: z17.string().nullish(),
|
|
5196
|
+
uri: z17.string().nullish()
|
|
4906
5197
|
}).loose();
|
|
4907
|
-
const stepDeltaBuiltinToolCall =
|
|
4908
|
-
type:
|
|
4909
|
-
id:
|
|
4910
|
-
arguments:
|
|
4911
|
-
name:
|
|
4912
|
-
server_name:
|
|
4913
|
-
search_type:
|
|
4914
|
-
signature:
|
|
5198
|
+
const stepDeltaBuiltinToolCall = z17.object({
|
|
5199
|
+
type: z17.enum(BUILTIN_TOOL_CALL_STEP_TYPES),
|
|
5200
|
+
id: z17.string().nullish(),
|
|
5201
|
+
arguments: z17.record(z17.string(), z17.unknown()).nullish(),
|
|
5202
|
+
name: z17.string().nullish(),
|
|
5203
|
+
server_name: z17.string().nullish(),
|
|
5204
|
+
search_type: z17.string().nullish(),
|
|
5205
|
+
signature: z17.string().nullish()
|
|
4915
5206
|
}).loose();
|
|
4916
|
-
const stepDeltaBuiltinToolResult =
|
|
4917
|
-
type:
|
|
4918
|
-
call_id:
|
|
4919
|
-
result:
|
|
4920
|
-
is_error:
|
|
4921
|
-
name:
|
|
4922
|
-
server_name:
|
|
4923
|
-
signature:
|
|
5207
|
+
const stepDeltaBuiltinToolResult = z17.object({
|
|
5208
|
+
type: z17.enum(BUILTIN_TOOL_RESULT_STEP_TYPES),
|
|
5209
|
+
call_id: z17.string().nullish(),
|
|
5210
|
+
result: z17.unknown().nullish(),
|
|
5211
|
+
is_error: z17.boolean().nullish(),
|
|
5212
|
+
name: z17.string().nullish(),
|
|
5213
|
+
server_name: z17.string().nullish(),
|
|
5214
|
+
signature: z17.string().nullish()
|
|
4924
5215
|
}).loose();
|
|
4925
|
-
const stepDeltaUnknown =
|
|
4926
|
-
const stepDeltaUnion =
|
|
5216
|
+
const stepDeltaUnknown = z17.object({ type: z17.string() }).loose();
|
|
5217
|
+
const stepDeltaUnion = z17.union([
|
|
4927
5218
|
stepDeltaText,
|
|
4928
5219
|
stepDeltaImage,
|
|
4929
5220
|
stepDeltaVideo,
|
|
@@ -4935,55 +5226,55 @@ var googleInteractionsEventSchema = lazySchema13(
|
|
|
4935
5226
|
stepDeltaBuiltinToolResult,
|
|
4936
5227
|
stepDeltaUnknown
|
|
4937
5228
|
]);
|
|
4938
|
-
const stepDeltaEvent =
|
|
4939
|
-
event_type:
|
|
4940
|
-
event_id:
|
|
4941
|
-
index:
|
|
5229
|
+
const stepDeltaEvent = z17.object({
|
|
5230
|
+
event_type: z17.literal("step.delta"),
|
|
5231
|
+
event_id: z17.string().nullish(),
|
|
5232
|
+
index: z17.number(),
|
|
4942
5233
|
delta: stepDeltaUnion
|
|
4943
5234
|
}).loose();
|
|
4944
|
-
const stepStopEvent =
|
|
4945
|
-
event_type:
|
|
4946
|
-
event_id:
|
|
4947
|
-
index:
|
|
5235
|
+
const stepStopEvent = z17.object({
|
|
5236
|
+
event_type: z17.literal("step.stop"),
|
|
5237
|
+
event_id: z17.string().nullish(),
|
|
5238
|
+
index: z17.number()
|
|
4948
5239
|
}).loose();
|
|
4949
|
-
const interactionStatusUpdateEvent =
|
|
4950
|
-
event_type:
|
|
4951
|
-
event_id:
|
|
4952
|
-
interaction_id:
|
|
5240
|
+
const interactionStatusUpdateEvent = z17.object({
|
|
5241
|
+
event_type: z17.literal("interaction.status_update"),
|
|
5242
|
+
event_id: z17.string().nullish(),
|
|
5243
|
+
interaction_id: z17.string().nullish(),
|
|
4953
5244
|
status: status.nullish()
|
|
4954
5245
|
}).loose();
|
|
4955
|
-
const interactionInProgressEvent =
|
|
4956
|
-
event_type:
|
|
4957
|
-
event_id:
|
|
4958
|
-
interaction_id:
|
|
5246
|
+
const interactionInProgressEvent = z17.object({
|
|
5247
|
+
event_type: z17.literal("interaction.in_progress"),
|
|
5248
|
+
event_id: z17.string().nullish(),
|
|
5249
|
+
interaction_id: z17.string().nullish(),
|
|
4959
5250
|
status: status.nullish()
|
|
4960
5251
|
}).loose();
|
|
4961
|
-
const interactionRequiresActionEvent =
|
|
4962
|
-
event_type:
|
|
4963
|
-
event_id:
|
|
4964
|
-
interaction_id:
|
|
5252
|
+
const interactionRequiresActionEvent = z17.object({
|
|
5253
|
+
event_type: z17.literal("interaction.requires_action"),
|
|
5254
|
+
event_id: z17.string().nullish(),
|
|
5255
|
+
interaction_id: z17.string().nullish(),
|
|
4965
5256
|
status: status.nullish()
|
|
4966
5257
|
}).loose();
|
|
4967
|
-
const interactionCompletedEvent =
|
|
4968
|
-
event_type:
|
|
4969
|
-
event_id:
|
|
4970
|
-
interaction:
|
|
4971
|
-
id:
|
|
5258
|
+
const interactionCompletedEvent = z17.object({
|
|
5259
|
+
event_type: z17.literal("interaction.completed"),
|
|
5260
|
+
event_id: z17.string().nullish(),
|
|
5261
|
+
interaction: z17.object({
|
|
5262
|
+
id: z17.string().nullish(),
|
|
4972
5263
|
status: status.nullish(),
|
|
4973
5264
|
usage: usageSchema2().nullish(),
|
|
4974
|
-
service_tier:
|
|
5265
|
+
service_tier: z17.string().nullish()
|
|
4975
5266
|
}).loose()
|
|
4976
5267
|
}).loose();
|
|
4977
|
-
const errorEvent =
|
|
4978
|
-
event_type:
|
|
4979
|
-
event_id:
|
|
4980
|
-
error:
|
|
4981
|
-
code:
|
|
4982
|
-
message:
|
|
5268
|
+
const errorEvent = z17.object({
|
|
5269
|
+
event_type: z17.literal("error"),
|
|
5270
|
+
event_id: z17.string().nullish(),
|
|
5271
|
+
error: z17.object({
|
|
5272
|
+
code: z17.string().nullish(),
|
|
5273
|
+
message: z17.string().nullish()
|
|
4983
5274
|
}).loose().nullish()
|
|
4984
5275
|
}).loose();
|
|
4985
|
-
const unknownEvent =
|
|
4986
|
-
return
|
|
5276
|
+
const unknownEvent = z17.object({ event_type: z17.string() }).loose();
|
|
5277
|
+
return z17.union([
|
|
4987
5278
|
interactionCreatedEvent,
|
|
4988
5279
|
stepStartEvent,
|
|
4989
5280
|
stepDeltaEvent,
|
|
@@ -5004,26 +5295,26 @@ import {
|
|
|
5004
5295
|
lazySchema as lazySchema14,
|
|
5005
5296
|
zodSchema as zodSchema14
|
|
5006
5297
|
} from "@ai-sdk/provider-utils";
|
|
5007
|
-
import { z as
|
|
5298
|
+
import { z as z18 } from "zod/v4";
|
|
5008
5299
|
var googleInteractionsLanguageModelOptions = lazySchema14(
|
|
5009
5300
|
() => zodSchema14(
|
|
5010
|
-
|
|
5011
|
-
previousInteractionId:
|
|
5012
|
-
store:
|
|
5013
|
-
agent:
|
|
5014
|
-
agentConfig:
|
|
5015
|
-
|
|
5016
|
-
type:
|
|
5301
|
+
z18.object({
|
|
5302
|
+
previousInteractionId: z18.string().nullish(),
|
|
5303
|
+
store: z18.boolean().nullish(),
|
|
5304
|
+
agent: z18.string().nullish(),
|
|
5305
|
+
agentConfig: z18.union([
|
|
5306
|
+
z18.object({
|
|
5307
|
+
type: z18.literal("dynamic")
|
|
5017
5308
|
}).loose(),
|
|
5018
|
-
|
|
5019
|
-
type:
|
|
5020
|
-
thinkingSummaries:
|
|
5021
|
-
visualization:
|
|
5022
|
-
collaborativePlanning:
|
|
5309
|
+
z18.object({
|
|
5310
|
+
type: z18.literal("deep-research"),
|
|
5311
|
+
thinkingSummaries: z18.enum(["auto", "none"]).nullish(),
|
|
5312
|
+
visualization: z18.enum(["off", "auto"]).nullish(),
|
|
5313
|
+
collaborativePlanning: z18.boolean().nullish()
|
|
5023
5314
|
})
|
|
5024
5315
|
]).nullish(),
|
|
5025
|
-
thinkingLevel:
|
|
5026
|
-
thinkingSummaries:
|
|
5316
|
+
thinkingLevel: z18.enum(["minimal", "low", "medium", "high"]).nullish(),
|
|
5317
|
+
thinkingSummaries: z18.enum(["auto", "none"]).nullish(),
|
|
5027
5318
|
/**
|
|
5028
5319
|
* Output-format entries that map directly to the API's `response_format`
|
|
5029
5320
|
* array. Use this to request image, audio, or non-JSON text outputs
|
|
@@ -5033,17 +5324,17 @@ var googleInteractionsLanguageModelOptions = lazySchema14(
|
|
|
5033
5324
|
* type: 'json', schema }` still drives JSON-mode and adds a matching
|
|
5034
5325
|
* text entry automatically; entries listed here are appended.
|
|
5035
5326
|
*/
|
|
5036
|
-
responseFormat:
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
type:
|
|
5040
|
-
mimeType:
|
|
5041
|
-
schema:
|
|
5327
|
+
responseFormat: z18.array(
|
|
5328
|
+
z18.union([
|
|
5329
|
+
z18.object({
|
|
5330
|
+
type: z18.literal("text"),
|
|
5331
|
+
mimeType: z18.string().nullish(),
|
|
5332
|
+
schema: z18.unknown().nullish()
|
|
5042
5333
|
}).loose(),
|
|
5043
|
-
|
|
5044
|
-
type:
|
|
5045
|
-
mimeType:
|
|
5046
|
-
aspectRatio:
|
|
5334
|
+
z18.object({
|
|
5335
|
+
type: z18.literal("image"),
|
|
5336
|
+
mimeType: z18.string().nullish(),
|
|
5337
|
+
aspectRatio: z18.enum([
|
|
5047
5338
|
"1:1",
|
|
5048
5339
|
"2:3",
|
|
5049
5340
|
"3:2",
|
|
@@ -5059,11 +5350,11 @@ var googleInteractionsLanguageModelOptions = lazySchema14(
|
|
|
5059
5350
|
"1:4",
|
|
5060
5351
|
"4:1"
|
|
5061
5352
|
]).nullish(),
|
|
5062
|
-
imageSize:
|
|
5353
|
+
imageSize: z18.enum(["1K", "2K", "4K", "512"]).nullish()
|
|
5063
5354
|
}).loose(),
|
|
5064
|
-
|
|
5065
|
-
type:
|
|
5066
|
-
mimeType:
|
|
5355
|
+
z18.object({
|
|
5356
|
+
type: z18.literal("audio"),
|
|
5357
|
+
mimeType: z18.string().nullish()
|
|
5067
5358
|
}).loose()
|
|
5068
5359
|
])
|
|
5069
5360
|
).nullish(),
|
|
@@ -5073,8 +5364,8 @@ var googleInteractionsLanguageModelOptions = lazySchema14(
|
|
|
5073
5364
|
* translates it into a matching `response_format` image entry and
|
|
5074
5365
|
* emits a warning when set.
|
|
5075
5366
|
*/
|
|
5076
|
-
imageConfig:
|
|
5077
|
-
aspectRatio:
|
|
5367
|
+
imageConfig: z18.object({
|
|
5368
|
+
aspectRatio: z18.enum([
|
|
5078
5369
|
"1:1",
|
|
5079
5370
|
"2:3",
|
|
5080
5371
|
"3:2",
|
|
@@ -5090,35 +5381,35 @@ var googleInteractionsLanguageModelOptions = lazySchema14(
|
|
|
5090
5381
|
"1:4",
|
|
5091
5382
|
"4:1"
|
|
5092
5383
|
]).nullish(),
|
|
5093
|
-
imageSize:
|
|
5384
|
+
imageSize: z18.enum(["1K", "2K", "4K", "512"]).nullish()
|
|
5094
5385
|
}).nullish(),
|
|
5095
|
-
mediaResolution:
|
|
5096
|
-
responseModalities:
|
|
5097
|
-
serviceTier:
|
|
5386
|
+
mediaResolution: z18.enum(["low", "medium", "high", "ultra_high"]).nullish(),
|
|
5387
|
+
responseModalities: z18.array(z18.enum(["text", "image", "audio", "video", "document"])).nullish(),
|
|
5388
|
+
serviceTier: z18.enum(["flex", "standard", "priority"]).nullish(),
|
|
5098
5389
|
/**
|
|
5099
5390
|
* Alternative to AI SDK `system` message. If both are set, the AI SDK
|
|
5100
5391
|
* `system` message wins and a warning is emitted.
|
|
5101
5392
|
*/
|
|
5102
|
-
systemInstruction:
|
|
5393
|
+
systemInstruction: z18.string().nullish(),
|
|
5103
5394
|
/**
|
|
5104
5395
|
* Per-block signature for round-tripping `thought.signature` and
|
|
5105
5396
|
* `function_call.signature` blocks. Set by the SDK on output reasoning /
|
|
5106
5397
|
* tool-call parts; passed back unchanged on input parts so the API
|
|
5107
5398
|
* accepts the prior turn.
|
|
5108
5399
|
*/
|
|
5109
|
-
signature:
|
|
5400
|
+
signature: z18.string().nullish(),
|
|
5110
5401
|
/**
|
|
5111
5402
|
* Set by the SDK on output assistant messages. The converter uses it to
|
|
5112
5403
|
* decide which messages to drop when compacting under
|
|
5113
5404
|
* `previousInteractionId`.
|
|
5114
5405
|
*/
|
|
5115
|
-
interactionId:
|
|
5406
|
+
interactionId: z18.string().nullish(),
|
|
5116
5407
|
/**
|
|
5117
5408
|
* Maximum time, in milliseconds, to poll a background interaction (agent
|
|
5118
5409
|
* call) before giving up. Defaults to 30 minutes. Long-running agents
|
|
5119
5410
|
* such as deep research can take tens of minutes — increase if needed.
|
|
5120
5411
|
*/
|
|
5121
|
-
pollingTimeoutMs:
|
|
5412
|
+
pollingTimeoutMs: z18.number().int().positive().nullish(),
|
|
5122
5413
|
/**
|
|
5123
5414
|
* Run the interaction in the background. Required for agents whose
|
|
5124
5415
|
* server-side workflow cannot complete within a single request/response.
|
|
@@ -5127,7 +5418,7 @@ var googleInteractionsLanguageModelOptions = lazySchema14(
|
|
|
5127
5418
|
* reject `true`; see the agent's documentation for which mode it
|
|
5128
5419
|
* requires.
|
|
5129
5420
|
*/
|
|
5130
|
-
background:
|
|
5421
|
+
background: z18.boolean().nullish(),
|
|
5131
5422
|
/**
|
|
5132
5423
|
* Environment configuration for the agent sandbox. Only applies to agent
|
|
5133
5424
|
* calls (`google.interactions({ agent })`); ignored on model-id calls.
|
|
@@ -5137,36 +5428,36 @@ var googleInteractionsLanguageModelOptions = lazySchema14(
|
|
|
5137
5428
|
* - object: provision a fresh sandbox and optionally preload `sources`
|
|
5138
5429
|
* and/or constrain outbound traffic via `network`.
|
|
5139
5430
|
*/
|
|
5140
|
-
environment:
|
|
5141
|
-
|
|
5142
|
-
|
|
5143
|
-
type:
|
|
5144
|
-
sources:
|
|
5145
|
-
|
|
5146
|
-
|
|
5147
|
-
type:
|
|
5148
|
-
source:
|
|
5149
|
-
target:
|
|
5431
|
+
environment: z18.union([
|
|
5432
|
+
z18.string(),
|
|
5433
|
+
z18.object({
|
|
5434
|
+
type: z18.literal("remote"),
|
|
5435
|
+
sources: z18.array(
|
|
5436
|
+
z18.union([
|
|
5437
|
+
z18.object({
|
|
5438
|
+
type: z18.literal("gcs"),
|
|
5439
|
+
source: z18.string(),
|
|
5440
|
+
target: z18.string().nullish()
|
|
5150
5441
|
}),
|
|
5151
|
-
|
|
5152
|
-
type:
|
|
5153
|
-
source:
|
|
5154
|
-
target:
|
|
5442
|
+
z18.object({
|
|
5443
|
+
type: z18.literal("repository"),
|
|
5444
|
+
source: z18.string(),
|
|
5445
|
+
target: z18.string().nullish()
|
|
5155
5446
|
}),
|
|
5156
|
-
|
|
5157
|
-
type:
|
|
5158
|
-
content:
|
|
5159
|
-
target:
|
|
5447
|
+
z18.object({
|
|
5448
|
+
type: z18.literal("inline"),
|
|
5449
|
+
content: z18.string(),
|
|
5450
|
+
target: z18.string()
|
|
5160
5451
|
})
|
|
5161
5452
|
])
|
|
5162
5453
|
).nullish(),
|
|
5163
|
-
network:
|
|
5164
|
-
|
|
5165
|
-
|
|
5166
|
-
allowlist:
|
|
5167
|
-
|
|
5168
|
-
domain:
|
|
5169
|
-
transform:
|
|
5454
|
+
network: z18.union([
|
|
5455
|
+
z18.literal("disabled"),
|
|
5456
|
+
z18.object({
|
|
5457
|
+
allowlist: z18.array(
|
|
5458
|
+
z18.object({
|
|
5459
|
+
domain: z18.string(),
|
|
5460
|
+
transform: z18.array(z18.record(z18.string(), z18.string())).nullish()
|
|
5170
5461
|
})
|
|
5171
5462
|
)
|
|
5172
5463
|
})
|
|
@@ -5366,7 +5657,7 @@ function parseGoogleInteractionsOutputs({
|
|
|
5366
5657
|
|
|
5367
5658
|
// src/interactions/poll-google-interactions.ts
|
|
5368
5659
|
import {
|
|
5369
|
-
createJsonResponseHandler as
|
|
5660
|
+
createJsonResponseHandler as createJsonResponseHandler6,
|
|
5370
5661
|
delay as delay2,
|
|
5371
5662
|
getFromApi as getFromApi2,
|
|
5372
5663
|
isAbortError
|
|
@@ -5374,7 +5665,7 @@ import {
|
|
|
5374
5665
|
|
|
5375
5666
|
// src/interactions/cancel-google-interaction.ts
|
|
5376
5667
|
import {
|
|
5377
|
-
combineHeaders as
|
|
5668
|
+
combineHeaders as combineHeaders6,
|
|
5378
5669
|
getRuntimeEnvironmentUserAgent,
|
|
5379
5670
|
withUserAgentSuffix
|
|
5380
5671
|
} from "@ai-sdk/provider-utils";
|
|
@@ -5393,7 +5684,7 @@ async function cancelGoogleInteraction({
|
|
|
5393
5684
|
const response = await fetch(url, {
|
|
5394
5685
|
method: "POST",
|
|
5395
5686
|
headers: withUserAgentSuffix(
|
|
5396
|
-
|
|
5687
|
+
combineHeaders6({ "Content-Type": "application/json" }, headers),
|
|
5397
5688
|
getRuntimeEnvironmentUserAgent()
|
|
5398
5689
|
),
|
|
5399
5690
|
body: "{}"
|
|
@@ -5453,7 +5744,7 @@ async function pollGoogleInteractionUntilTerminal({
|
|
|
5453
5744
|
url,
|
|
5454
5745
|
headers,
|
|
5455
5746
|
failedResponseHandler: googleFailedResponseHandler,
|
|
5456
|
-
successfulResponseHandler:
|
|
5747
|
+
successfulResponseHandler: createJsonResponseHandler6(
|
|
5457
5748
|
googleInteractionsResponseSchema
|
|
5458
5749
|
),
|
|
5459
5750
|
abortSignal,
|
|
@@ -5966,7 +6257,7 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5966
6257
|
async getArgs(options) {
|
|
5967
6258
|
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
6259
|
const warnings = [];
|
|
5969
|
-
const opts = await
|
|
6260
|
+
const opts = await parseProviderOptions6({
|
|
5970
6261
|
provider: "google",
|
|
5971
6262
|
providerOptions: options.providerOptions,
|
|
5972
6263
|
schema: googleInteractionsLanguageModelOptions
|
|
@@ -6212,17 +6503,17 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
6212
6503
|
var _a, _b, _c, _d, _e, _f;
|
|
6213
6504
|
const { args, warnings, isAgent, pollingTimeoutMs } = await this.getArgs(options);
|
|
6214
6505
|
const url = `${this.config.baseURL}/interactions`;
|
|
6215
|
-
const mergedHeaders =
|
|
6506
|
+
const mergedHeaders = combineHeaders7(
|
|
6216
6507
|
INTERACTIONS_API_REVISION_HEADER,
|
|
6217
|
-
this.config.headers ? await
|
|
6508
|
+
this.config.headers ? await resolve6(this.config.headers) : void 0,
|
|
6218
6509
|
options.headers
|
|
6219
6510
|
);
|
|
6220
|
-
const postResult = await
|
|
6511
|
+
const postResult = await postJsonToApi6({
|
|
6221
6512
|
url,
|
|
6222
6513
|
headers: mergedHeaders,
|
|
6223
6514
|
body: args,
|
|
6224
6515
|
failedResponseHandler: googleFailedResponseHandler,
|
|
6225
|
-
successfulResponseHandler:
|
|
6516
|
+
successfulResponseHandler: createJsonResponseHandler7(
|
|
6226
6517
|
googleInteractionsResponseSchema
|
|
6227
6518
|
),
|
|
6228
6519
|
abortSignal: options.abortSignal,
|
|
@@ -6297,9 +6588,9 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
6297
6588
|
var _a;
|
|
6298
6589
|
const { args, warnings, isBackground, pollingTimeoutMs } = await this.getArgs(options);
|
|
6299
6590
|
const url = `${this.config.baseURL}/interactions`;
|
|
6300
|
-
const mergedHeaders =
|
|
6591
|
+
const mergedHeaders = combineHeaders7(
|
|
6301
6592
|
INTERACTIONS_API_REVISION_HEADER,
|
|
6302
|
-
this.config.headers ? await
|
|
6593
|
+
this.config.headers ? await resolve6(this.config.headers) : void 0,
|
|
6303
6594
|
options.headers
|
|
6304
6595
|
);
|
|
6305
6596
|
if (isBackground) {
|
|
@@ -6313,7 +6604,7 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
6313
6604
|
});
|
|
6314
6605
|
}
|
|
6315
6606
|
const body = { ...args, stream: true };
|
|
6316
|
-
const { responseHeaders, value: response } = await
|
|
6607
|
+
const { responseHeaders, value: response } = await postJsonToApi6({
|
|
6317
6608
|
url,
|
|
6318
6609
|
headers: mergedHeaders,
|
|
6319
6610
|
body,
|
|
@@ -6364,12 +6655,12 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
6364
6655
|
pollingTimeoutMs
|
|
6365
6656
|
}) {
|
|
6366
6657
|
var _a, _b;
|
|
6367
|
-
const postResult = await
|
|
6658
|
+
const postResult = await postJsonToApi6({
|
|
6368
6659
|
url,
|
|
6369
6660
|
headers: mergedHeaders,
|
|
6370
6661
|
body: args,
|
|
6371
6662
|
failedResponseHandler: googleFailedResponseHandler,
|
|
6372
|
-
successfulResponseHandler:
|
|
6663
|
+
successfulResponseHandler: createJsonResponseHandler7(
|
|
6373
6664
|
googleInteractionsResponseSchema
|
|
6374
6665
|
),
|
|
6375
6666
|
abortSignal: options.abortSignal,
|
|
@@ -6514,6 +6805,12 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
6514
6805
|
headers: getHeaders,
|
|
6515
6806
|
fetch: options.fetch
|
|
6516
6807
|
});
|
|
6808
|
+
const createTranscriptionModel = (modelId) => new GoogleTranscriptionModel(modelId, {
|
|
6809
|
+
provider: `${providerName}.transcription`,
|
|
6810
|
+
baseURL,
|
|
6811
|
+
headers: getHeaders,
|
|
6812
|
+
fetch: options.fetch
|
|
6813
|
+
});
|
|
6517
6814
|
const createVideoModel = (modelId) => {
|
|
6518
6815
|
var _a2;
|
|
6519
6816
|
return new GoogleGenerativeAIVideoModel(modelId, {
|
|
@@ -6555,6 +6852,8 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
6555
6852
|
provider.textEmbeddingModel = createEmbeddingModel;
|
|
6556
6853
|
provider.image = createImageModel;
|
|
6557
6854
|
provider.imageModel = createImageModel;
|
|
6855
|
+
provider.transcription = createTranscriptionModel;
|
|
6856
|
+
provider.transcriptionModel = createTranscriptionModel;
|
|
6558
6857
|
provider.video = createVideoModel;
|
|
6559
6858
|
provider.videoModel = createVideoModel;
|
|
6560
6859
|
provider.interactions = createInteractionsModel;
|
|
@@ -6563,6 +6862,7 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
6563
6862
|
}
|
|
6564
6863
|
var google = createGoogleGenerativeAI();
|
|
6565
6864
|
export {
|
|
6865
|
+
GoogleTranscriptionModel,
|
|
6566
6866
|
VERSION,
|
|
6567
6867
|
createGoogleGenerativeAI,
|
|
6568
6868
|
google
|