@ai-sdk/google 3.0.118 → 3.0.120
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/index.d.mts +23 -1
- package/dist/index.d.ts +23 -1
- package/dist/index.js +49 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +49 -27
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +14 -0
- package/dist/internal/index.d.ts +14 -0
- package/dist/internal/index.js +48 -26
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +48 -26
- package/dist/internal/index.mjs.map +1 -1
- package/docs/15-google-generative-ai.mdx +32 -6
- package/package.json +2 -2
- package/src/convert-google-generative-ai-usage.ts +3 -0
- package/src/google-generative-ai-language-model.ts +24 -17
- package/src/interactions/google-interactions-language-model-options.ts +12 -2
- package/src/interactions/google-interactions-language-model.ts +11 -0
- package/src/interactions/google-interactions-prompt.ts +15 -1
package/dist/internal/index.mjs
CHANGED
|
@@ -2518,21 +2518,24 @@ var tokenDetailsSchema = z3.array(
|
|
|
2518
2518
|
z3.object({
|
|
2519
2519
|
modality: z3.string(),
|
|
2520
2520
|
tokenCount: z3.number()
|
|
2521
|
-
})
|
|
2521
|
+
}).catchall(z3.json())
|
|
2522
2522
|
).nullish();
|
|
2523
2523
|
var usageSchema = z3.object({
|
|
2524
2524
|
cachedContentTokenCount: z3.number().nullish(),
|
|
2525
2525
|
thoughtsTokenCount: z3.number().nullish(),
|
|
2526
2526
|
promptTokenCount: z3.number().nullish(),
|
|
2527
2527
|
candidatesTokenCount: z3.number().nullish(),
|
|
2528
|
+
toolUsePromptTokenCount: z3.number().nullish(),
|
|
2528
2529
|
totalTokenCount: z3.number().nullish(),
|
|
2529
2530
|
// https://cloud.google.com/vertex-ai/generative-ai/docs/reference/rest/v1/GenerateContentResponse#TrafficType
|
|
2530
2531
|
trafficType: z3.string().nullish(),
|
|
2531
2532
|
serviceTier: z3.string().nullish(),
|
|
2532
2533
|
// https://ai.google.dev/api/generate-content#Modality
|
|
2533
2534
|
promptTokensDetails: tokenDetailsSchema,
|
|
2534
|
-
|
|
2535
|
-
|
|
2535
|
+
cacheTokensDetails: tokenDetailsSchema,
|
|
2536
|
+
candidatesTokensDetails: tokenDetailsSchema,
|
|
2537
|
+
toolUsePromptTokensDetails: tokenDetailsSchema
|
|
2538
|
+
}).catchall(z3.json());
|
|
2536
2539
|
var getUrlContextMetadataSchema = () => z3.object({
|
|
2537
2540
|
urlMetadata: z3.array(
|
|
2538
2541
|
z3.object({
|
|
@@ -4303,8 +4306,8 @@ var googleInteractionsLanguageModelOptions = lazySchema10(
|
|
|
4303
4306
|
thinkingSummaries: z12.enum(["auto", "none"]).nullish(),
|
|
4304
4307
|
/**
|
|
4305
4308
|
* Output-format entries that map directly to the API's `response_format`
|
|
4306
|
-
* array. Use this to request image, audio, or non-JSON text
|
|
4307
|
-
* with
|
|
4309
|
+
* array. Use this to request image, audio, video, or non-JSON text
|
|
4310
|
+
* outputs with modality-specific controls.
|
|
4308
4311
|
*
|
|
4309
4312
|
* Entries are sent in order. The AI SDK call-level `responseFormat: {
|
|
4310
4313
|
* type: 'json', schema }` still drives JSON-mode and adds a matching
|
|
@@ -4341,6 +4344,14 @@ var googleInteractionsLanguageModelOptions = lazySchema10(
|
|
|
4341
4344
|
z12.object({
|
|
4342
4345
|
type: z12.literal("audio"),
|
|
4343
4346
|
mimeType: z12.string().nullish()
|
|
4347
|
+
}).loose(),
|
|
4348
|
+
z12.object({
|
|
4349
|
+
type: z12.literal("video"),
|
|
4350
|
+
aspectRatio: z12.enum(["16:9", "9:16"]).nullish(),
|
|
4351
|
+
resolution: z12.enum(["360p", "720p", "1080p", "4k"]).nullish(),
|
|
4352
|
+
duration: z12.string().nullish(),
|
|
4353
|
+
delivery: z12.enum(["inline", "uri"]).nullish(),
|
|
4354
|
+
gcsUri: z12.string().nullish()
|
|
4344
4355
|
}).loose()
|
|
4345
4356
|
])
|
|
4346
4357
|
).nullish(),
|
|
@@ -5241,7 +5252,7 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5241
5252
|
};
|
|
5242
5253
|
}
|
|
5243
5254
|
async getArgs(options) {
|
|
5244
|
-
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;
|
|
5255
|
+
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, _B, _C, _D, _E, _F;
|
|
5245
5256
|
const warnings = [];
|
|
5246
5257
|
const opts = await parseProviderOptions2({
|
|
5247
5258
|
provider: "google",
|
|
@@ -5317,6 +5328,17 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5317
5328
|
mime_type: (_g = entry.mimeType) != null ? _g : void 0
|
|
5318
5329
|
})
|
|
5319
5330
|
);
|
|
5331
|
+
} else if (entry.type === "video") {
|
|
5332
|
+
responseFormatEntries.push(
|
|
5333
|
+
pruneUndefined({
|
|
5334
|
+
type: "video",
|
|
5335
|
+
aspect_ratio: (_h = entry.aspectRatio) != null ? _h : void 0,
|
|
5336
|
+
resolution: (_i = entry.resolution) != null ? _i : void 0,
|
|
5337
|
+
duration: (_j = entry.duration) != null ? _j : void 0,
|
|
5338
|
+
delivery: (_k = entry.delivery) != null ? _k : void 0,
|
|
5339
|
+
gcs_uri: (_l = entry.gcsUri) != null ? _l : void 0
|
|
5340
|
+
})
|
|
5341
|
+
);
|
|
5320
5342
|
}
|
|
5321
5343
|
}
|
|
5322
5344
|
}
|
|
@@ -5326,13 +5348,13 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5326
5348
|
warnings: convWarnings
|
|
5327
5349
|
} = convertToGoogleInteractionsInput({
|
|
5328
5350
|
prompt: options.prompt,
|
|
5329
|
-
previousInteractionId: (
|
|
5330
|
-
store: (
|
|
5331
|
-
mediaResolution: (
|
|
5351
|
+
previousInteractionId: (_m = opts == null ? void 0 : opts.previousInteractionId) != null ? _m : void 0,
|
|
5352
|
+
store: (_n = opts == null ? void 0 : opts.store) != null ? _n : void 0,
|
|
5353
|
+
mediaResolution: (_o = opts == null ? void 0 : opts.mediaResolution) != null ? _o : void 0
|
|
5332
5354
|
});
|
|
5333
5355
|
warnings.push(...convWarnings);
|
|
5334
5356
|
let systemInstruction = convertedSystemInstruction;
|
|
5335
|
-
const optionSystemInstruction = (
|
|
5357
|
+
const optionSystemInstruction = (_p = opts == null ? void 0 : opts.systemInstruction) != null ? _p : void 0;
|
|
5336
5358
|
if (systemInstruction != null && optionSystemInstruction != null) {
|
|
5337
5359
|
warnings.push({
|
|
5338
5360
|
type: "other",
|
|
@@ -5371,14 +5393,14 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5371
5393
|
generationConfig = void 0;
|
|
5372
5394
|
} else {
|
|
5373
5395
|
generationConfig = pruneUndefined({
|
|
5374
|
-
temperature: (
|
|
5375
|
-
top_p: (
|
|
5376
|
-
top_k: (
|
|
5377
|
-
seed: (
|
|
5396
|
+
temperature: (_q = options.temperature) != null ? _q : void 0,
|
|
5397
|
+
top_p: (_r = options.topP) != null ? _r : void 0,
|
|
5398
|
+
top_k: (_s = options.topK) != null ? _s : void 0,
|
|
5399
|
+
seed: (_t = options.seed) != null ? _t : void 0,
|
|
5378
5400
|
stop_sequences: options.stopSequences != null && options.stopSequences.length > 0 ? options.stopSequences : void 0,
|
|
5379
|
-
max_output_tokens: (
|
|
5380
|
-
thinking_level: (
|
|
5381
|
-
thinking_summaries: (
|
|
5401
|
+
max_output_tokens: (_u = options.maxOutputTokens) != null ? _u : void 0,
|
|
5402
|
+
thinking_level: (_v = opts == null ? void 0 : opts.thinkingLevel) != null ? _v : void 0,
|
|
5403
|
+
thinking_summaries: (_w = opts == null ? void 0 : opts.thinkingSummaries) != null ? _w : void 0,
|
|
5382
5404
|
tool_choice: toolChoiceForBody
|
|
5383
5405
|
});
|
|
5384
5406
|
if ((opts == null ? void 0 : opts.imageConfig) != null) {
|
|
@@ -5405,9 +5427,9 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5405
5427
|
if (ac.type === "deep-research") {
|
|
5406
5428
|
agentConfig = pruneUndefined({
|
|
5407
5429
|
type: "deep-research",
|
|
5408
|
-
thinking_summaries: (
|
|
5409
|
-
visualization: (
|
|
5410
|
-
collaborative_planning: (
|
|
5430
|
+
thinking_summaries: (_x = ac.thinkingSummaries) != null ? _x : void 0,
|
|
5431
|
+
visualization: (_y = ac.visualization) != null ? _y : void 0,
|
|
5432
|
+
collaborative_planning: (_z = ac.collaborativePlanning) != null ? _z : void 0
|
|
5411
5433
|
});
|
|
5412
5434
|
} else if (ac.type === "dynamic") {
|
|
5413
5435
|
agentConfig = { type: "dynamic" };
|
|
@@ -5424,7 +5446,7 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5424
5446
|
environment = opts.environment;
|
|
5425
5447
|
} else {
|
|
5426
5448
|
const env = opts.environment;
|
|
5427
|
-
const sources = (
|
|
5449
|
+
const sources = (_A = env.sources) == null ? void 0 : _A.map((s) => {
|
|
5428
5450
|
var _a2;
|
|
5429
5451
|
if (s.type === "inline") {
|
|
5430
5452
|
return {
|
|
@@ -5469,20 +5491,20 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5469
5491
|
tools: toolsForBody,
|
|
5470
5492
|
response_format: responseFormatEntries.length > 0 ? responseFormatEntries : void 0,
|
|
5471
5493
|
response_modalities: (opts == null ? void 0 : opts.responseModalities) != null ? opts.responseModalities : void 0,
|
|
5472
|
-
previous_interaction_id: (
|
|
5473
|
-
service_tier: (
|
|
5474
|
-
store: (
|
|
5494
|
+
previous_interaction_id: (_B = opts == null ? void 0 : opts.previousInteractionId) != null ? _B : void 0,
|
|
5495
|
+
service_tier: (_C = opts == null ? void 0 : opts.serviceTier) != null ? _C : void 0,
|
|
5496
|
+
store: (_D = opts == null ? void 0 : opts.store) != null ? _D : void 0,
|
|
5475
5497
|
generation_config: generationConfig != null && Object.keys(generationConfig).length > 0 ? generationConfig : void 0,
|
|
5476
5498
|
agent_config: agentConfig,
|
|
5477
5499
|
environment,
|
|
5478
|
-
background: (
|
|
5500
|
+
background: (_E = opts == null ? void 0 : opts.background) != null ? _E : void 0
|
|
5479
5501
|
});
|
|
5480
5502
|
return {
|
|
5481
5503
|
args,
|
|
5482
5504
|
warnings,
|
|
5483
5505
|
isAgent,
|
|
5484
5506
|
isBackground: (opts == null ? void 0 : opts.background) === true,
|
|
5485
|
-
pollingTimeoutMs: (
|
|
5507
|
+
pollingTimeoutMs: (_F = opts == null ? void 0 : opts.pollingTimeoutMs) != null ? _F : void 0
|
|
5486
5508
|
};
|
|
5487
5509
|
}
|
|
5488
5510
|
async doGenerate(options) {
|