@ai-sdk/google 3.0.135 → 3.0.137
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 +15 -0
- package/dist/index.d.mts +10 -11
- package/dist/index.d.ts +10 -11
- package/dist/index.js +291 -256
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +201 -161
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +62 -40
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +62 -40
- package/dist/internal/index.mjs.map +1 -1
- package/docs/15-google-generative-ai.mdx +8 -0
- package/package.json +2 -2
- package/src/google-generative-ai-embedding-options.ts +15 -14
- package/src/google-generative-ai-image-model.ts +1 -1
- package/src/google-generative-ai-language-model.ts +73 -42
- package/src/google-generative-ai-prompt.ts +2 -0
- package/src/google-generative-ai-video-model.ts +30 -26
- package/src/tool/file-search.ts +33 -30
- package/src/tool/google-search.ts +19 -18
- package/src/transcription/google-transcription-model-options.ts +40 -31
- package/src/transcription/google-transcription-model.ts +37 -30
package/dist/index.mjs
CHANGED
|
@@ -3,6 +3,8 @@ import {
|
|
|
3
3
|
InvalidArgumentError
|
|
4
4
|
} from "@ai-sdk/provider";
|
|
5
5
|
import {
|
|
6
|
+
lazySchema as lazySchema3,
|
|
7
|
+
zodSchema as zodSchema3,
|
|
6
8
|
combineHeaders,
|
|
7
9
|
convertToBase64,
|
|
8
10
|
createJsonResponseHandler,
|
|
@@ -37,37 +39,45 @@ var googleFailedResponseHandler = createJsonErrorResponseHandler({
|
|
|
37
39
|
});
|
|
38
40
|
|
|
39
41
|
// src/transcription/google-transcription-model-options.ts
|
|
42
|
+
import {
|
|
43
|
+
lazySchema as lazySchema2,
|
|
44
|
+
zodSchema as zodSchema2
|
|
45
|
+
} from "@ai-sdk/provider-utils";
|
|
40
46
|
import { z as z2 } from "zod/v4";
|
|
41
|
-
var googleTranscriptionModelOptions =
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
47
|
+
var googleTranscriptionModelOptions = lazySchema2(
|
|
48
|
+
() => zodSchema2(
|
|
49
|
+
z2.object({
|
|
50
|
+
/**
|
|
51
|
+
* BCP-47 language codes providing hints about the languages present in the
|
|
52
|
+
* audio. If omitted or empty, defaults to automatic language detection.
|
|
53
|
+
*/
|
|
54
|
+
languageCodes: z2.array(z2.string()).optional(),
|
|
55
|
+
/**
|
|
56
|
+
* Custom vocabulary phrases, which bias the speech recognition model
|
|
57
|
+
* toward recognizing specific terms.
|
|
58
|
+
*/
|
|
59
|
+
customVocabulary: z2.array(z2.string()).optional(),
|
|
60
|
+
/**
|
|
61
|
+
* Enables word-level timestamp generation.
|
|
62
|
+
*/
|
|
63
|
+
wordTimestamp: z2.boolean().optional(),
|
|
64
|
+
/**
|
|
65
|
+
* Enables speaker diarization.
|
|
66
|
+
*/
|
|
67
|
+
diarization: z2.boolean().optional(),
|
|
68
|
+
/**
|
|
69
|
+
* Transcription output formatting mode.
|
|
70
|
+
*
|
|
71
|
+
* - `VERBATIM` (default): exact literal transcript preserving filler
|
|
72
|
+
* words, repetitions, and false starts.
|
|
73
|
+
* - `SMART`: cleans up and structures the transcript in real time —
|
|
74
|
+
* disfluency removal, inline self-corrections, structured formatting
|
|
75
|
+
* (lists, numbers, dates, paragraph breaks), and grammar/casing polish.
|
|
76
|
+
*/
|
|
77
|
+
mode: z2.enum(["SMART", "VERBATIM"]).optional()
|
|
78
|
+
})
|
|
79
|
+
)
|
|
80
|
+
);
|
|
71
81
|
|
|
72
82
|
// src/transcription/google-transcription-model.ts
|
|
73
83
|
function isLiveTranscriptionModelId(modelId) {
|
|
@@ -191,29 +201,33 @@ function parseOffsetSeconds(offset) {
|
|
|
191
201
|
const parsed = Number.parseFloat(offset);
|
|
192
202
|
return Number.isFinite(parsed) ? parsed : void 0;
|
|
193
203
|
}
|
|
194
|
-
var googleInteractionsWordAnnotationSchema = z3.object({
|
|
204
|
+
var googleInteractionsWordAnnotationSchema = () => z3.object({
|
|
195
205
|
type: z3.string().nullish(),
|
|
196
206
|
text: z3.string().nullish(),
|
|
197
207
|
speaker: z3.string().nullish(),
|
|
198
208
|
start_offset: z3.string().nullish(),
|
|
199
209
|
end_offset: z3.string().nullish()
|
|
200
210
|
});
|
|
201
|
-
var googleInteractionsTranscriptionResponseSchema =
|
|
202
|
-
|
|
203
|
-
steps: z3.array(
|
|
211
|
+
var googleInteractionsTranscriptionResponseSchema = lazySchema3(
|
|
212
|
+
() => zodSchema3(
|
|
204
213
|
z3.object({
|
|
205
|
-
|
|
206
|
-
|
|
214
|
+
status: z3.string().nullish(),
|
|
215
|
+
steps: z3.array(
|
|
207
216
|
z3.object({
|
|
208
217
|
type: z3.string().nullish(),
|
|
209
|
-
|
|
210
|
-
|
|
218
|
+
content: z3.array(
|
|
219
|
+
z3.object({
|
|
220
|
+
type: z3.string().nullish(),
|
|
221
|
+
text: z3.string().nullish(),
|
|
222
|
+
annotations: z3.array(googleInteractionsWordAnnotationSchema()).nullish()
|
|
223
|
+
})
|
|
224
|
+
).nullish()
|
|
211
225
|
})
|
|
212
|
-
).nullish()
|
|
226
|
+
).nullish(),
|
|
227
|
+
usage: z3.record(z3.string(), z3.unknown()).nullish()
|
|
213
228
|
})
|
|
214
|
-
)
|
|
215
|
-
|
|
216
|
-
});
|
|
229
|
+
)
|
|
230
|
+
);
|
|
217
231
|
|
|
218
232
|
// src/google-provider.ts
|
|
219
233
|
import {
|
|
@@ -224,7 +238,7 @@ import {
|
|
|
224
238
|
} from "@ai-sdk/provider-utils";
|
|
225
239
|
|
|
226
240
|
// src/version.ts
|
|
227
|
-
var VERSION = true ? "3.0.
|
|
241
|
+
var VERSION = true ? "3.0.137" : "0.0.0-test";
|
|
228
242
|
|
|
229
243
|
// src/google-generative-ai-embedding-model.ts
|
|
230
244
|
import {
|
|
@@ -234,21 +248,21 @@ import {
|
|
|
234
248
|
combineHeaders as combineHeaders2,
|
|
235
249
|
createJsonResponseHandler as createJsonResponseHandler2,
|
|
236
250
|
EXPERIMENTAL_EMBEDDING_MODEL_PROVIDER_OPTIONS_TRANSFORMER,
|
|
237
|
-
lazySchema as
|
|
251
|
+
lazySchema as lazySchema5,
|
|
238
252
|
parseProviderOptions as parseProviderOptions2,
|
|
239
253
|
postJsonToApi as postJsonToApi2,
|
|
240
254
|
resolve as resolve2,
|
|
241
|
-
zodSchema as
|
|
255
|
+
zodSchema as zodSchema5
|
|
242
256
|
} from "@ai-sdk/provider-utils";
|
|
243
257
|
import { z as z5 } from "zod/v4";
|
|
244
258
|
|
|
245
259
|
// src/google-generative-ai-embedding-options.ts
|
|
246
260
|
import {
|
|
247
|
-
lazySchema as
|
|
248
|
-
zodSchema as
|
|
261
|
+
lazySchema as lazySchema4,
|
|
262
|
+
zodSchema as zodSchema4
|
|
249
263
|
} from "@ai-sdk/provider-utils";
|
|
250
264
|
import { z as z4 } from "zod/v4";
|
|
251
|
-
var googleEmbeddingContentPartSchema = z4.union([
|
|
265
|
+
var googleEmbeddingContentPartSchema = () => z4.union([
|
|
252
266
|
z4.object({ text: z4.string() }),
|
|
253
267
|
z4.object({
|
|
254
268
|
inlineData: z4.object({
|
|
@@ -263,8 +277,8 @@ var googleEmbeddingContentPartSchema = z4.union([
|
|
|
263
277
|
})
|
|
264
278
|
})
|
|
265
279
|
]);
|
|
266
|
-
var googleEmbeddingModelOptions =
|
|
267
|
-
() =>
|
|
280
|
+
var googleEmbeddingModelOptions = lazySchema4(
|
|
281
|
+
() => zodSchema4(
|
|
268
282
|
z4.object({
|
|
269
283
|
/**
|
|
270
284
|
* Optional. Optional reduced dimension for the output embedding.
|
|
@@ -302,7 +316,7 @@ var googleEmbeddingModelOptions = lazySchema2(
|
|
|
302
316
|
* The array length must match the number of values being embedded. In
|
|
303
317
|
* the case of a single embedding, the array length must be 1.
|
|
304
318
|
*/
|
|
305
|
-
content: z4.array(z4.array(googleEmbeddingContentPartSchema).min(1).nullable()).optional()
|
|
319
|
+
content: z4.array(z4.array(googleEmbeddingContentPartSchema()).min(1).nullable()).optional()
|
|
306
320
|
})
|
|
307
321
|
)
|
|
308
322
|
);
|
|
@@ -434,15 +448,15 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
434
448
|
};
|
|
435
449
|
}
|
|
436
450
|
};
|
|
437
|
-
var googleGenerativeAITextEmbeddingResponseSchema =
|
|
438
|
-
() =>
|
|
451
|
+
var googleGenerativeAITextEmbeddingResponseSchema = lazySchema5(
|
|
452
|
+
() => zodSchema5(
|
|
439
453
|
z5.object({
|
|
440
454
|
embeddings: z5.array(z5.object({ values: z5.array(z5.number()) }))
|
|
441
455
|
})
|
|
442
456
|
)
|
|
443
457
|
);
|
|
444
|
-
var googleGenerativeAISingleEmbeddingResponseSchema =
|
|
445
|
-
() =>
|
|
458
|
+
var googleGenerativeAISingleEmbeddingResponseSchema = lazySchema5(
|
|
459
|
+
() => zodSchema5(
|
|
446
460
|
z5.object({
|
|
447
461
|
embedding: z5.object({ values: z5.array(z5.number()) })
|
|
448
462
|
})
|
|
@@ -465,11 +479,11 @@ import {
|
|
|
465
479
|
createEventSourceResponseHandler,
|
|
466
480
|
createJsonResponseHandler as createJsonResponseHandler3,
|
|
467
481
|
generateId,
|
|
468
|
-
lazySchema as
|
|
482
|
+
lazySchema as lazySchema7,
|
|
469
483
|
parseProviderOptions as parseProviderOptions3,
|
|
470
484
|
postJsonToApi as postJsonToApi3,
|
|
471
485
|
resolve as resolve3,
|
|
472
|
-
zodSchema as
|
|
486
|
+
zodSchema as zodSchema7
|
|
473
487
|
} from "@ai-sdk/provider-utils";
|
|
474
488
|
import { z as z7 } from "zod/v4";
|
|
475
489
|
|
|
@@ -1354,12 +1368,12 @@ function getModelPath(modelId) {
|
|
|
1354
1368
|
|
|
1355
1369
|
// src/google-generative-ai-options.ts
|
|
1356
1370
|
import {
|
|
1357
|
-
lazySchema as
|
|
1358
|
-
zodSchema as
|
|
1371
|
+
lazySchema as lazySchema6,
|
|
1372
|
+
zodSchema as zodSchema6
|
|
1359
1373
|
} from "@ai-sdk/provider-utils";
|
|
1360
1374
|
import { z as z6 } from "zod/v4";
|
|
1361
|
-
var googleLanguageModelOptions =
|
|
1362
|
-
() =>
|
|
1375
|
+
var googleLanguageModelOptions = lazySchema6(
|
|
1376
|
+
() => zodSchema6(
|
|
1363
1377
|
z6.object({
|
|
1364
1378
|
responseModalities: z6.array(z6.enum(["TEXT", "IMAGE"])).optional(),
|
|
1365
1379
|
thinkingConfig: z6.object({
|
|
@@ -2325,7 +2339,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2325
2339
|
};
|
|
2326
2340
|
}
|
|
2327
2341
|
async doGenerate(options) {
|
|
2328
|
-
var _a2, _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;
|
|
2342
|
+
var _a2, _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, _B;
|
|
2329
2343
|
const { args, warnings, providerOptionsName, extraHeaders } = await this.getArgs(options);
|
|
2330
2344
|
const mergedHeaders = combineHeaders3(
|
|
2331
2345
|
await resolve3(this.config.headers),
|
|
@@ -2349,18 +2363,20 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2349
2363
|
rawValue: rawResponse
|
|
2350
2364
|
} = await generateContent(args);
|
|
2351
2365
|
const continuedParts = [];
|
|
2366
|
+
const groundingMetadataPerRequest = [];
|
|
2352
2367
|
let continuedUsageMetadata;
|
|
2353
2368
|
const firstPromptTokenCount = (_a2 = response.usageMetadata) == null ? void 0 : _a2.promptTokenCount;
|
|
2354
2369
|
while (true) {
|
|
2355
2370
|
const candidate2 = (_b = response.candidates) == null ? void 0 : _b[0];
|
|
2371
|
+
groundingMetadataPerRequest.push((_c = candidate2 == null ? void 0 : candidate2.groundingMetadata) != null ? _c : null);
|
|
2356
2372
|
const continuationToken = (candidate2 == null ? void 0 : candidate2.finishReason) === "CONTINUATION" ? candidate2.continuationToken : void 0;
|
|
2357
2373
|
if (continuationToken == null) {
|
|
2358
2374
|
break;
|
|
2359
2375
|
}
|
|
2360
|
-
continuedParts.push(...(
|
|
2376
|
+
continuedParts.push(...(_e = (_d = candidate2 == null ? void 0 : candidate2.content) == null ? void 0 : _d.parts) != null ? _e : []);
|
|
2361
2377
|
continuedUsageMetadata = addGoogleGenerativeAIUsageMetadata(
|
|
2362
2378
|
continuedUsageMetadata,
|
|
2363
|
-
(
|
|
2379
|
+
(_f = response.usageMetadata) != null ? _f : void 0
|
|
2364
2380
|
);
|
|
2365
2381
|
({
|
|
2366
2382
|
responseHeaders,
|
|
@@ -2368,23 +2384,23 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2368
2384
|
rawValue: rawResponse
|
|
2369
2385
|
} = await generateContent({ ...args, continuationToken }));
|
|
2370
2386
|
}
|
|
2371
|
-
const candidate = (
|
|
2372
|
-
const promptBlockReason = (
|
|
2387
|
+
const candidate = (_g = response.candidates) == null ? void 0 : _g[0];
|
|
2388
|
+
const promptBlockReason = (_h = response.promptFeedback) == null ? void 0 : _h.blockReason;
|
|
2373
2389
|
const confirmedPromptBlockReason = isConfirmedPromptBlockReason(
|
|
2374
2390
|
promptBlockReason
|
|
2375
2391
|
) ? promptBlockReason : void 0;
|
|
2376
2392
|
const isPromptBlocked = (candidate == null ? void 0 : candidate.finishReason) == null && confirmedPromptBlockReason != null;
|
|
2377
|
-
const rawFinishReason = (
|
|
2393
|
+
const rawFinishReason = (_i = candidate == null ? void 0 : candidate.finishReason) != null ? _i : confirmedPromptBlockReason;
|
|
2378
2394
|
const content = [];
|
|
2379
|
-
const parts = [...continuedParts, ...(
|
|
2395
|
+
const parts = [...continuedParts, ...(_k = (_j = candidate == null ? void 0 : candidate.content) == null ? void 0 : _j.parts) != null ? _k : []];
|
|
2380
2396
|
const usageMetadata = addGoogleGenerativeAIUsageMetadata(
|
|
2381
2397
|
continuedUsageMetadata,
|
|
2382
|
-
(
|
|
2398
|
+
(_l = response.usageMetadata) != null ? _l : void 0
|
|
2383
2399
|
);
|
|
2384
2400
|
let lastCodeExecutionToolCallId;
|
|
2385
2401
|
let lastServerToolCallId;
|
|
2386
2402
|
for (const part of parts) {
|
|
2387
|
-
if ("executableCode" in part && ((
|
|
2403
|
+
if ("executableCode" in part && ((_m = part.executableCode) == null ? void 0 : _m.code)) {
|
|
2388
2404
|
const toolCallId = this.config.generateId();
|
|
2389
2405
|
lastCodeExecutionToolCallId = toolCallId;
|
|
2390
2406
|
content.push({
|
|
@@ -2402,7 +2418,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2402
2418
|
toolName: "code_execution",
|
|
2403
2419
|
result: {
|
|
2404
2420
|
outcome: part.codeExecutionResult.outcome,
|
|
2405
|
-
output: (
|
|
2421
|
+
output: (_n = part.codeExecutionResult.output) != null ? _n : ""
|
|
2406
2422
|
}
|
|
2407
2423
|
});
|
|
2408
2424
|
} else if ("text" in part && part.text != null) {
|
|
@@ -2426,9 +2442,9 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2426
2442
|
} else if ("functionCall" in part && part.functionCall.name != null) {
|
|
2427
2443
|
content.push({
|
|
2428
2444
|
type: "tool-call",
|
|
2429
|
-
toolCallId: (
|
|
2445
|
+
toolCallId: (_o = part.functionCall.id) != null ? _o : this.config.generateId(),
|
|
2430
2446
|
toolName: part.functionCall.name,
|
|
2431
|
-
input: JSON.stringify((
|
|
2447
|
+
input: JSON.stringify((_p = part.functionCall.args) != null ? _p : {}),
|
|
2432
2448
|
providerMetadata: part.thoughtSignature ? {
|
|
2433
2449
|
[providerOptionsName]: {
|
|
2434
2450
|
thoughtSignature: part.thoughtSignature
|
|
@@ -2450,13 +2466,13 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2450
2466
|
} : void 0
|
|
2451
2467
|
});
|
|
2452
2468
|
} else if ("toolCall" in part && part.toolCall) {
|
|
2453
|
-
const toolCallId = (
|
|
2469
|
+
const toolCallId = (_q = part.toolCall.id) != null ? _q : this.config.generateId();
|
|
2454
2470
|
lastServerToolCallId = toolCallId;
|
|
2455
2471
|
content.push({
|
|
2456
2472
|
type: "tool-call",
|
|
2457
2473
|
toolCallId,
|
|
2458
2474
|
toolName: `server:${part.toolCall.toolType}`,
|
|
2459
|
-
input: JSON.stringify((
|
|
2475
|
+
input: JSON.stringify((_r = part.toolCall.args) != null ? _r : {}),
|
|
2460
2476
|
providerExecuted: true,
|
|
2461
2477
|
dynamic: true,
|
|
2462
2478
|
providerMetadata: part.thoughtSignature ? {
|
|
@@ -2473,12 +2489,12 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2473
2489
|
}
|
|
2474
2490
|
});
|
|
2475
2491
|
} else if ("toolResponse" in part && part.toolResponse) {
|
|
2476
|
-
const responseToolCallId = (
|
|
2492
|
+
const responseToolCallId = (_s = lastServerToolCallId != null ? lastServerToolCallId : part.toolResponse.id) != null ? _s : this.config.generateId();
|
|
2477
2493
|
content.push({
|
|
2478
2494
|
type: "tool-result",
|
|
2479
2495
|
toolCallId: responseToolCallId,
|
|
2480
2496
|
toolName: `server:${part.toolResponse.toolType}`,
|
|
2481
|
-
result: (
|
|
2497
|
+
result: (_t = part.toolResponse.response) != null ? _t : {},
|
|
2482
2498
|
providerMetadata: part.thoughtSignature ? {
|
|
2483
2499
|
[providerOptionsName]: {
|
|
2484
2500
|
thoughtSignature: part.thoughtSignature,
|
|
@@ -2495,10 +2511,10 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2495
2511
|
lastServerToolCallId = void 0;
|
|
2496
2512
|
}
|
|
2497
2513
|
}
|
|
2498
|
-
const sources = (
|
|
2514
|
+
const sources = (_u = extractSources({
|
|
2499
2515
|
groundingMetadata: candidate == null ? void 0 : candidate.groundingMetadata,
|
|
2500
2516
|
generateId: this.config.generateId
|
|
2501
|
-
})) != null ?
|
|
2517
|
+
})) != null ? _u : [];
|
|
2502
2518
|
for (const source of sources) {
|
|
2503
2519
|
content.push(source);
|
|
2504
2520
|
}
|
|
@@ -2518,13 +2534,14 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2518
2534
|
warnings,
|
|
2519
2535
|
providerMetadata: {
|
|
2520
2536
|
[providerOptionsName]: {
|
|
2521
|
-
promptFeedback: (
|
|
2522
|
-
groundingMetadata: (
|
|
2523
|
-
|
|
2524
|
-
|
|
2537
|
+
promptFeedback: (_v = response.promptFeedback) != null ? _v : null,
|
|
2538
|
+
groundingMetadata: (_w = candidate == null ? void 0 : candidate.groundingMetadata) != null ? _w : null,
|
|
2539
|
+
...groundingMetadataPerRequest.length > 1 ? { groundingMetadataPerRequest } : {},
|
|
2540
|
+
urlContextMetadata: (_x = candidate == null ? void 0 : candidate.urlContextMetadata) != null ? _x : null,
|
|
2541
|
+
safetyRatings: (_y = candidate == null ? void 0 : candidate.safetyRatings) != null ? _y : null,
|
|
2525
2542
|
usageMetadata: usageMetadata != null ? usageMetadata : null,
|
|
2526
|
-
finishMessage: (
|
|
2527
|
-
serviceTier: (
|
|
2543
|
+
finishMessage: (_z = candidate == null ? void 0 : candidate.finishMessage) != null ? _z : null,
|
|
2544
|
+
serviceTier: (_A = usageMetadata == null ? void 0 : usageMetadata.serviceTier) != null ? _A : null,
|
|
2528
2545
|
...(candidate == null ? void 0 : candidate.continuationToken) != null && rawFinishReason === "MAX_TOKENS" ? { continuationToken: candidate.continuationToken } : {},
|
|
2529
2546
|
...continuedUsageMetadata != null && firstPromptTokenCount != null ? { initialPromptTokenCount: firstPromptTokenCount } : {}
|
|
2530
2547
|
}
|
|
@@ -2532,7 +2549,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2532
2549
|
request: { body: args },
|
|
2533
2550
|
response: {
|
|
2534
2551
|
// TODO timestamp, model id
|
|
2535
|
-
id: (
|
|
2552
|
+
id: (_B = response.responseId) != null ? _B : void 0,
|
|
2536
2553
|
headers: responseHeaders,
|
|
2537
2554
|
body: rawResponse
|
|
2538
2555
|
}
|
|
@@ -2557,14 +2574,27 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2557
2574
|
fetch: this.config.fetch
|
|
2558
2575
|
});
|
|
2559
2576
|
const { responseHeaders, value: firstResponse } = await streamGenerateContent(args);
|
|
2577
|
+
const groundingMetadataPerRequest = [];
|
|
2578
|
+
let requestGroundingMetadata = null;
|
|
2560
2579
|
const response = continueGoogleStream({
|
|
2561
2580
|
stream: firstResponse,
|
|
2562
2581
|
getContinuationToken: (chunk) => {
|
|
2563
2582
|
var _a2, _b;
|
|
2564
2583
|
const candidate = (_a2 = chunk.candidates) == null ? void 0 : _a2[0];
|
|
2584
|
+
if ((candidate == null ? void 0 : candidate.groundingMetadata) != null) {
|
|
2585
|
+
requestGroundingMetadata = candidate.groundingMetadata;
|
|
2586
|
+
}
|
|
2565
2587
|
return (candidate == null ? void 0 : candidate.finishReason) === "CONTINUATION" ? (_b = candidate.continuationToken) != null ? _b : void 0 : void 0;
|
|
2566
2588
|
},
|
|
2567
|
-
continueStream: async (continuationToken) =>
|
|
2589
|
+
continueStream: async (continuationToken) => {
|
|
2590
|
+
const { value } = await streamGenerateContent({
|
|
2591
|
+
...args,
|
|
2592
|
+
continuationToken
|
|
2593
|
+
});
|
|
2594
|
+
groundingMetadataPerRequest.push(requestGroundingMetadata);
|
|
2595
|
+
requestGroundingMetadata = null;
|
|
2596
|
+
return value;
|
|
2597
|
+
}
|
|
2568
2598
|
});
|
|
2569
2599
|
let finishReason = {
|
|
2570
2600
|
unified: "other",
|
|
@@ -2999,6 +3029,12 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2999
3029
|
[providerOptionsName]: {
|
|
3000
3030
|
promptFeedback,
|
|
3001
3031
|
groundingMetadata: lastGroundingMetadata,
|
|
3032
|
+
...groundingMetadataPerRequest.length > 0 ? {
|
|
3033
|
+
groundingMetadataPerRequest: [
|
|
3034
|
+
...groundingMetadataPerRequest,
|
|
3035
|
+
requestGroundingMetadata
|
|
3036
|
+
]
|
|
3037
|
+
} : {},
|
|
3002
3038
|
urlContextMetadata: lastUrlContextMetadata,
|
|
3003
3039
|
safetyRatings: lastSafetyRatings,
|
|
3004
3040
|
usageMetadata: usage != null ? usage : null,
|
|
@@ -3171,7 +3207,7 @@ var getGroundingMetadataSchema = () => z7.object({
|
|
|
3171
3207
|
z7.object({})
|
|
3172
3208
|
]).nullish()
|
|
3173
3209
|
});
|
|
3174
|
-
var partialArgSchema = z7.object({
|
|
3210
|
+
var partialArgSchema = () => z7.object({
|
|
3175
3211
|
jsonPath: z7.string(),
|
|
3176
3212
|
stringValue: z7.string().nullish(),
|
|
3177
3213
|
numberValue: z7.number().nullish(),
|
|
@@ -3188,7 +3224,7 @@ var getContentSchema = () => z7.object({
|
|
|
3188
3224
|
id: z7.string().nullish(),
|
|
3189
3225
|
name: z7.string().nullish(),
|
|
3190
3226
|
args: z7.unknown().nullish(),
|
|
3191
|
-
partialArgs: z7.array(partialArgSchema).nullish(),
|
|
3227
|
+
partialArgs: z7.array(partialArgSchema()).nullish(),
|
|
3192
3228
|
willContinue: z7.boolean().nullish()
|
|
3193
3229
|
}),
|
|
3194
3230
|
thoughtSignature: z7.string().nullish()
|
|
@@ -3241,13 +3277,13 @@ var getSafetyRatingSchema = () => z7.object({
|
|
|
3241
3277
|
severityScore: z7.number().nullish(),
|
|
3242
3278
|
blocked: z7.boolean().nullish()
|
|
3243
3279
|
});
|
|
3244
|
-
var tokenDetailsSchema = z7.array(
|
|
3280
|
+
var tokenDetailsSchema = () => z7.array(
|
|
3245
3281
|
z7.object({
|
|
3246
3282
|
modality: z7.string(),
|
|
3247
3283
|
tokenCount: z7.number()
|
|
3248
3284
|
}).catchall(z7.json())
|
|
3249
3285
|
).nullish();
|
|
3250
|
-
var usageSchema = z7.object({
|
|
3286
|
+
var usageSchema = () => z7.object({
|
|
3251
3287
|
cachedContentTokenCount: z7.number().nullish(),
|
|
3252
3288
|
thoughtsTokenCount: z7.number().nullish(),
|
|
3253
3289
|
promptTokenCount: z7.number().nullish(),
|
|
@@ -3258,10 +3294,10 @@ var usageSchema = z7.object({
|
|
|
3258
3294
|
trafficType: z7.string().nullish(),
|
|
3259
3295
|
serviceTier: z7.string().nullish(),
|
|
3260
3296
|
// https://ai.google.dev/api/generate-content#Modality
|
|
3261
|
-
promptTokensDetails: tokenDetailsSchema,
|
|
3262
|
-
cacheTokensDetails: tokenDetailsSchema,
|
|
3263
|
-
candidatesTokensDetails: tokenDetailsSchema,
|
|
3264
|
-
toolUsePromptTokensDetails: tokenDetailsSchema
|
|
3297
|
+
promptTokensDetails: tokenDetailsSchema(),
|
|
3298
|
+
cacheTokensDetails: tokenDetailsSchema(),
|
|
3299
|
+
candidatesTokensDetails: tokenDetailsSchema(),
|
|
3300
|
+
toolUsePromptTokensDetails: tokenDetailsSchema()
|
|
3265
3301
|
}).catchall(z7.json());
|
|
3266
3302
|
var getUrlContextMetadataSchema = () => z7.object({
|
|
3267
3303
|
urlMetadata: z7.array(
|
|
@@ -3271,8 +3307,8 @@ var getUrlContextMetadataSchema = () => z7.object({
|
|
|
3271
3307
|
})
|
|
3272
3308
|
).nullish()
|
|
3273
3309
|
});
|
|
3274
|
-
var responseSchema =
|
|
3275
|
-
() =>
|
|
3310
|
+
var responseSchema = lazySchema7(
|
|
3311
|
+
() => zodSchema7(
|
|
3276
3312
|
z7.object({
|
|
3277
3313
|
responseId: z7.string().nullish(),
|
|
3278
3314
|
candidates: z7.array(
|
|
@@ -3286,7 +3322,7 @@ var responseSchema = lazySchema5(
|
|
|
3286
3322
|
urlContextMetadata: getUrlContextMetadataSchema().nullish()
|
|
3287
3323
|
})
|
|
3288
3324
|
).nullish(),
|
|
3289
|
-
usageMetadata: usageSchema.nullish(),
|
|
3325
|
+
usageMetadata: usageSchema().nullish(),
|
|
3290
3326
|
promptFeedback: z7.object({
|
|
3291
3327
|
blockReason: z7.string().nullish(),
|
|
3292
3328
|
safetyRatings: z7.array(getSafetyRatingSchema()).nullish()
|
|
@@ -3294,8 +3330,8 @@ var responseSchema = lazySchema5(
|
|
|
3294
3330
|
})
|
|
3295
3331
|
)
|
|
3296
3332
|
);
|
|
3297
|
-
var chunkSchema =
|
|
3298
|
-
() =>
|
|
3333
|
+
var chunkSchema = lazySchema7(
|
|
3334
|
+
() => zodSchema7(
|
|
3299
3335
|
z7.object({
|
|
3300
3336
|
responseId: z7.string().nullish(),
|
|
3301
3337
|
candidates: z7.array(
|
|
@@ -3309,7 +3345,7 @@ var chunkSchema = lazySchema5(
|
|
|
3309
3345
|
urlContextMetadata: getUrlContextMetadataSchema().nullish()
|
|
3310
3346
|
})
|
|
3311
3347
|
).nullish(),
|
|
3312
|
-
usageMetadata: usageSchema.nullish(),
|
|
3348
|
+
usageMetadata: usageSchema().nullish(),
|
|
3313
3349
|
promptFeedback: z7.object({
|
|
3314
3350
|
blockReason: z7.string().nullish(),
|
|
3315
3351
|
safetyRatings: z7.array(getSafetyRatingSchema()).nullish()
|
|
@@ -3339,23 +3375,23 @@ var codeExecution = createProviderToolFactoryWithOutputSchema({
|
|
|
3339
3375
|
// src/tool/enterprise-web-search.ts
|
|
3340
3376
|
import {
|
|
3341
3377
|
createProviderToolFactory,
|
|
3342
|
-
lazySchema as
|
|
3343
|
-
zodSchema as
|
|
3378
|
+
lazySchema as lazySchema8,
|
|
3379
|
+
zodSchema as zodSchema8
|
|
3344
3380
|
} from "@ai-sdk/provider-utils";
|
|
3345
3381
|
import { z as z9 } from "zod/v4";
|
|
3346
3382
|
var enterpriseWebSearch = createProviderToolFactory({
|
|
3347
3383
|
id: "google.enterprise_web_search",
|
|
3348
|
-
inputSchema:
|
|
3384
|
+
inputSchema: lazySchema8(() => zodSchema8(z9.object({})))
|
|
3349
3385
|
});
|
|
3350
3386
|
|
|
3351
3387
|
// src/tool/file-search.ts
|
|
3352
3388
|
import {
|
|
3353
3389
|
createProviderToolFactory as createProviderToolFactory2,
|
|
3354
|
-
lazySchema as
|
|
3355
|
-
zodSchema as
|
|
3390
|
+
lazySchema as lazySchema9,
|
|
3391
|
+
zodSchema as zodSchema9
|
|
3356
3392
|
} from "@ai-sdk/provider-utils";
|
|
3357
3393
|
import { z as z10 } from "zod/v4";
|
|
3358
|
-
var fileSearchArgsBaseSchema = z10.object({
|
|
3394
|
+
var fileSearchArgsBaseSchema = () => z10.object({
|
|
3359
3395
|
/** The names of the file_search_stores to retrieve from.
|
|
3360
3396
|
* Example: `fileSearchStores/my-file-search-store-123`
|
|
3361
3397
|
*/
|
|
@@ -3371,8 +3407,8 @@ var fileSearchArgsBaseSchema = z10.object({
|
|
|
3371
3407
|
"Metadata filter to apply to the file search retrieval documents. See https://google.aip.dev/160 for the syntax of the filter expression."
|
|
3372
3408
|
).optional()
|
|
3373
3409
|
}).passthrough();
|
|
3374
|
-
var fileSearchArgsSchema =
|
|
3375
|
-
() =>
|
|
3410
|
+
var fileSearchArgsSchema = lazySchema9(
|
|
3411
|
+
() => zodSchema9(fileSearchArgsBaseSchema())
|
|
3376
3412
|
);
|
|
3377
3413
|
var fileSearch = createProviderToolFactory2({
|
|
3378
3414
|
id: "google.file_search",
|
|
@@ -3382,23 +3418,23 @@ var fileSearch = createProviderToolFactory2({
|
|
|
3382
3418
|
// src/tool/google-maps.ts
|
|
3383
3419
|
import {
|
|
3384
3420
|
createProviderToolFactory as createProviderToolFactory3,
|
|
3385
|
-
lazySchema as
|
|
3386
|
-
zodSchema as
|
|
3421
|
+
lazySchema as lazySchema10,
|
|
3422
|
+
zodSchema as zodSchema10
|
|
3387
3423
|
} from "@ai-sdk/provider-utils";
|
|
3388
3424
|
import { z as z11 } from "zod/v4";
|
|
3389
3425
|
var googleMaps = createProviderToolFactory3({
|
|
3390
3426
|
id: "google.google_maps",
|
|
3391
|
-
inputSchema:
|
|
3427
|
+
inputSchema: lazySchema10(() => zodSchema10(z11.object({})))
|
|
3392
3428
|
});
|
|
3393
3429
|
|
|
3394
3430
|
// src/tool/google-search.ts
|
|
3395
3431
|
import {
|
|
3396
3432
|
createProviderToolFactory as createProviderToolFactory4,
|
|
3397
|
-
lazySchema as
|
|
3398
|
-
zodSchema as
|
|
3433
|
+
lazySchema as lazySchema11,
|
|
3434
|
+
zodSchema as zodSchema11
|
|
3399
3435
|
} from "@ai-sdk/provider-utils";
|
|
3400
3436
|
import { z as z12 } from "zod/v4";
|
|
3401
|
-
var googleSearchToolArgsBaseSchema = z12.object({
|
|
3437
|
+
var googleSearchToolArgsBaseSchema = () => z12.object({
|
|
3402
3438
|
searchTypes: z12.object({
|
|
3403
3439
|
webSearch: z12.object({}).optional(),
|
|
3404
3440
|
imageSearch: z12.object({}).optional()
|
|
@@ -3408,8 +3444,8 @@ var googleSearchToolArgsBaseSchema = z12.object({
|
|
|
3408
3444
|
endTime: z12.string()
|
|
3409
3445
|
}).optional()
|
|
3410
3446
|
}).passthrough();
|
|
3411
|
-
var googleSearchToolArgsSchema =
|
|
3412
|
-
() =>
|
|
3447
|
+
var googleSearchToolArgsSchema = lazySchema11(
|
|
3448
|
+
() => zodSchema11(googleSearchToolArgsBaseSchema())
|
|
3413
3449
|
);
|
|
3414
3450
|
var googleSearch = createProviderToolFactory4(
|
|
3415
3451
|
{
|
|
@@ -3421,13 +3457,13 @@ var googleSearch = createProviderToolFactory4(
|
|
|
3421
3457
|
// src/tool/url-context.ts
|
|
3422
3458
|
import {
|
|
3423
3459
|
createProviderToolFactory as createProviderToolFactory5,
|
|
3424
|
-
lazySchema as
|
|
3425
|
-
zodSchema as
|
|
3460
|
+
lazySchema as lazySchema12,
|
|
3461
|
+
zodSchema as zodSchema12
|
|
3426
3462
|
} from "@ai-sdk/provider-utils";
|
|
3427
3463
|
import { z as z13 } from "zod/v4";
|
|
3428
3464
|
var urlContext = createProviderToolFactory5({
|
|
3429
3465
|
id: "google.url_context",
|
|
3430
|
-
inputSchema:
|
|
3466
|
+
inputSchema: lazySchema12(() => zodSchema12(z13.object({})))
|
|
3431
3467
|
});
|
|
3432
3468
|
|
|
3433
3469
|
// src/tool/vertex-rag-store.ts
|
|
@@ -3507,11 +3543,11 @@ import {
|
|
|
3507
3543
|
convertToBase64 as convertToBase643,
|
|
3508
3544
|
createJsonResponseHandler as createJsonResponseHandler4,
|
|
3509
3545
|
generateId as defaultGenerateId,
|
|
3510
|
-
lazySchema as
|
|
3546
|
+
lazySchema as lazySchema13,
|
|
3511
3547
|
parseProviderOptions as parseProviderOptions4,
|
|
3512
3548
|
postJsonToApi as postJsonToApi4,
|
|
3513
3549
|
resolve as resolve4,
|
|
3514
|
-
zodSchema as
|
|
3550
|
+
zodSchema as zodSchema13
|
|
3515
3551
|
} from "@ai-sdk/provider-utils";
|
|
3516
3552
|
import { z as z15 } from "zod/v4";
|
|
3517
3553
|
var GoogleGenerativeAIImageModel = class {
|
|
@@ -3767,8 +3803,8 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
3767
3803
|
function isGeminiModel(modelId) {
|
|
3768
3804
|
return modelId.startsWith("gemini-");
|
|
3769
3805
|
}
|
|
3770
|
-
var googleImageResponseSchema =
|
|
3771
|
-
() =>
|
|
3806
|
+
var googleImageResponseSchema = lazySchema13(
|
|
3807
|
+
() => zodSchema13(
|
|
3772
3808
|
z15.object({
|
|
3773
3809
|
predictions: z15.array(
|
|
3774
3810
|
z15.union([
|
|
@@ -3779,8 +3815,8 @@ var googleImageResponseSchema = lazySchema11(
|
|
|
3779
3815
|
})
|
|
3780
3816
|
)
|
|
3781
3817
|
);
|
|
3782
|
-
var googleImageModelOptionsSchema =
|
|
3783
|
-
() =>
|
|
3818
|
+
var googleImageModelOptionsSchema = lazySchema13(
|
|
3819
|
+
() => zodSchema13(
|
|
3784
3820
|
z15.object({
|
|
3785
3821
|
personGeneration: z15.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
|
|
3786
3822
|
aspectRatio: z15.enum(["1:1", "3:4", "4:3", "9:16", "16:9"]).nullish(),
|
|
@@ -3793,7 +3829,7 @@ var googleImageModelOptionsSchema = lazySchema11(
|
|
|
3793
3829
|
* dedicated escape hatch for grounding image generation the same way
|
|
3794
3830
|
* `generateText` does.
|
|
3795
3831
|
*/
|
|
3796
|
-
googleSearch: googleSearchToolArgsBaseSchema.optional()
|
|
3832
|
+
googleSearch: googleSearchToolArgsBaseSchema().optional()
|
|
3797
3833
|
})
|
|
3798
3834
|
)
|
|
3799
3835
|
);
|
|
@@ -3809,11 +3845,11 @@ import {
|
|
|
3809
3845
|
delay,
|
|
3810
3846
|
getFromApi,
|
|
3811
3847
|
isSameOrigin,
|
|
3812
|
-
lazySchema as
|
|
3848
|
+
lazySchema as lazySchema14,
|
|
3813
3849
|
parseProviderOptions as parseProviderOptions5,
|
|
3814
3850
|
postJsonToApi as postJsonToApi5,
|
|
3815
3851
|
resolve as resolve5,
|
|
3816
|
-
zodSchema as
|
|
3852
|
+
zodSchema as zodSchema14
|
|
3817
3853
|
} from "@ai-sdk/provider-utils";
|
|
3818
3854
|
import { z as z16 } from "zod/v4";
|
|
3819
3855
|
function getFirstFrameImage(options) {
|
|
@@ -4080,28 +4116,32 @@ var GoogleGenerativeAIVideoModel = class {
|
|
|
4080
4116
|
};
|
|
4081
4117
|
}
|
|
4082
4118
|
};
|
|
4083
|
-
var googleOperationSchema =
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
z16.object({
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
})
|
|
4103
|
-
|
|
4104
|
-
|
|
4119
|
+
var googleOperationSchema = lazySchema14(
|
|
4120
|
+
() => zodSchema14(
|
|
4121
|
+
z16.object({
|
|
4122
|
+
name: z16.string().nullish(),
|
|
4123
|
+
done: z16.boolean().nullish(),
|
|
4124
|
+
error: z16.object({
|
|
4125
|
+
code: z16.number().nullish(),
|
|
4126
|
+
message: z16.string(),
|
|
4127
|
+
status: z16.string().nullish()
|
|
4128
|
+
}).nullish(),
|
|
4129
|
+
response: z16.object({
|
|
4130
|
+
generateVideoResponse: z16.object({
|
|
4131
|
+
generatedSamples: z16.array(
|
|
4132
|
+
z16.object({
|
|
4133
|
+
video: z16.object({
|
|
4134
|
+
uri: z16.string().nullish()
|
|
4135
|
+
}).nullish()
|
|
4136
|
+
})
|
|
4137
|
+
).nullish()
|
|
4138
|
+
}).nullish()
|
|
4139
|
+
}).nullish()
|
|
4140
|
+
})
|
|
4141
|
+
)
|
|
4142
|
+
);
|
|
4143
|
+
var googleVideoModelOptionsSchema = lazySchema14(
|
|
4144
|
+
() => zodSchema14(
|
|
4105
4145
|
z16.object({
|
|
4106
4146
|
pollIntervalMs: z16.number().positive().nullish(),
|
|
4107
4147
|
pollTimeoutMs: z16.number().positive().nullish(),
|
|
@@ -5283,8 +5323,8 @@ ${block.text}`
|
|
|
5283
5323
|
|
|
5284
5324
|
// src/interactions/google-interactions-api.ts
|
|
5285
5325
|
import {
|
|
5286
|
-
lazySchema as
|
|
5287
|
-
zodSchema as
|
|
5326
|
+
lazySchema as lazySchema15,
|
|
5327
|
+
zodSchema as zodSchema15
|
|
5288
5328
|
} from "@ai-sdk/provider-utils";
|
|
5289
5329
|
import { z as z17 } from "zod/v4";
|
|
5290
5330
|
var tokenByModalitySchema = () => z17.object({
|
|
@@ -5448,8 +5488,8 @@ var stepSchema = () => {
|
|
|
5448
5488
|
z17.object({ type: z17.string() }).loose()
|
|
5449
5489
|
]);
|
|
5450
5490
|
};
|
|
5451
|
-
var googleInteractionsResponseSchema =
|
|
5452
|
-
() =>
|
|
5491
|
+
var googleInteractionsResponseSchema = lazySchema15(
|
|
5492
|
+
() => zodSchema15(
|
|
5453
5493
|
z17.object({
|
|
5454
5494
|
/*
|
|
5455
5495
|
* `id` is omitted from the response body when `store: false` (fully
|
|
@@ -5470,8 +5510,8 @@ var googleInteractionsResponseSchema = lazySchema13(
|
|
|
5470
5510
|
}).loose()
|
|
5471
5511
|
)
|
|
5472
5512
|
);
|
|
5473
|
-
var googleInteractionsEventSchema =
|
|
5474
|
-
() =>
|
|
5513
|
+
var googleInteractionsEventSchema = lazySchema15(
|
|
5514
|
+
() => zodSchema15(
|
|
5475
5515
|
(() => {
|
|
5476
5516
|
const status = interactionStatusSchema();
|
|
5477
5517
|
const annotation = annotationSchema();
|
|
@@ -5629,12 +5669,12 @@ var googleInteractionsEventSchema = lazySchema13(
|
|
|
5629
5669
|
|
|
5630
5670
|
// src/interactions/google-interactions-language-model-options.ts
|
|
5631
5671
|
import {
|
|
5632
|
-
lazySchema as
|
|
5633
|
-
zodSchema as
|
|
5672
|
+
lazySchema as lazySchema16,
|
|
5673
|
+
zodSchema as zodSchema16
|
|
5634
5674
|
} from "@ai-sdk/provider-utils";
|
|
5635
5675
|
import { z as z18 } from "zod/v4";
|
|
5636
|
-
var googleInteractionsLanguageModelOptions =
|
|
5637
|
-
() =>
|
|
5676
|
+
var googleInteractionsLanguageModelOptions = lazySchema16(
|
|
5677
|
+
() => zodSchema16(
|
|
5638
5678
|
z18.object({
|
|
5639
5679
|
previousInteractionId: z18.string().nullish(),
|
|
5640
5680
|
store: z18.boolean().nullish(),
|