@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/dist/index.mjs CHANGED
@@ -224,7 +224,7 @@ import {
224
224
  } from "@ai-sdk/provider-utils";
225
225
 
226
226
  // src/version.ts
227
- var VERSION = true ? "3.0.118" : "0.0.0-test";
227
+ var VERSION = true ? "3.0.120" : "0.0.0-test";
228
228
 
229
229
  // src/google-generative-ai-embedding-model.ts
230
230
  import {
@@ -2928,21 +2928,24 @@ var tokenDetailsSchema = z7.array(
2928
2928
  z7.object({
2929
2929
  modality: z7.string(),
2930
2930
  tokenCount: z7.number()
2931
- })
2931
+ }).catchall(z7.json())
2932
2932
  ).nullish();
2933
2933
  var usageSchema = z7.object({
2934
2934
  cachedContentTokenCount: z7.number().nullish(),
2935
2935
  thoughtsTokenCount: z7.number().nullish(),
2936
2936
  promptTokenCount: z7.number().nullish(),
2937
2937
  candidatesTokenCount: z7.number().nullish(),
2938
+ toolUsePromptTokenCount: z7.number().nullish(),
2938
2939
  totalTokenCount: z7.number().nullish(),
2939
2940
  // https://cloud.google.com/vertex-ai/generative-ai/docs/reference/rest/v1/GenerateContentResponse#TrafficType
2940
2941
  trafficType: z7.string().nullish(),
2941
2942
  serviceTier: z7.string().nullish(),
2942
2943
  // https://ai.google.dev/api/generate-content#Modality
2943
2944
  promptTokensDetails: tokenDetailsSchema,
2944
- candidatesTokensDetails: tokenDetailsSchema
2945
- });
2945
+ cacheTokensDetails: tokenDetailsSchema,
2946
+ candidatesTokensDetails: tokenDetailsSchema,
2947
+ toolUsePromptTokensDetails: tokenDetailsSchema
2948
+ }).catchall(z7.json());
2946
2949
  var getUrlContextMetadataSchema = () => z7.object({
2947
2950
  urlMetadata: z7.array(
2948
2951
  z7.object({
@@ -5317,8 +5320,8 @@ var googleInteractionsLanguageModelOptions = lazySchema14(
5317
5320
  thinkingSummaries: z18.enum(["auto", "none"]).nullish(),
5318
5321
  /**
5319
5322
  * Output-format entries that map directly to the API's `response_format`
5320
- * array. Use this to request image, audio, or non-JSON text outputs
5321
- * with full control over `mime_type`, `aspect_ratio`, and `image_size`.
5323
+ * array. Use this to request image, audio, video, or non-JSON text
5324
+ * outputs with modality-specific controls.
5322
5325
  *
5323
5326
  * Entries are sent in order. The AI SDK call-level `responseFormat: {
5324
5327
  * type: 'json', schema }` still drives JSON-mode and adds a matching
@@ -5355,6 +5358,14 @@ var googleInteractionsLanguageModelOptions = lazySchema14(
5355
5358
  z18.object({
5356
5359
  type: z18.literal("audio"),
5357
5360
  mimeType: z18.string().nullish()
5361
+ }).loose(),
5362
+ z18.object({
5363
+ type: z18.literal("video"),
5364
+ aspectRatio: z18.enum(["16:9", "9:16"]).nullish(),
5365
+ resolution: z18.enum(["360p", "720p", "1080p", "4k"]).nullish(),
5366
+ duration: z18.string().nullish(),
5367
+ delivery: z18.enum(["inline", "uri"]).nullish(),
5368
+ gcsUri: z18.string().nullish()
5358
5369
  }).loose()
5359
5370
  ])
5360
5371
  ).nullish(),
@@ -6255,7 +6266,7 @@ var GoogleInteractionsLanguageModel = class {
6255
6266
  };
6256
6267
  }
6257
6268
  async getArgs(options) {
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;
6269
+ 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;
6259
6270
  const warnings = [];
6260
6271
  const opts = await parseProviderOptions6({
6261
6272
  provider: "google",
@@ -6331,6 +6342,17 @@ var GoogleInteractionsLanguageModel = class {
6331
6342
  mime_type: (_g = entry.mimeType) != null ? _g : void 0
6332
6343
  })
6333
6344
  );
6345
+ } else if (entry.type === "video") {
6346
+ responseFormatEntries.push(
6347
+ pruneUndefined({
6348
+ type: "video",
6349
+ aspect_ratio: (_h = entry.aspectRatio) != null ? _h : void 0,
6350
+ resolution: (_i = entry.resolution) != null ? _i : void 0,
6351
+ duration: (_j = entry.duration) != null ? _j : void 0,
6352
+ delivery: (_k = entry.delivery) != null ? _k : void 0,
6353
+ gcs_uri: (_l = entry.gcsUri) != null ? _l : void 0
6354
+ })
6355
+ );
6334
6356
  }
6335
6357
  }
6336
6358
  }
@@ -6340,13 +6362,13 @@ var GoogleInteractionsLanguageModel = class {
6340
6362
  warnings: convWarnings
6341
6363
  } = convertToGoogleInteractionsInput({
6342
6364
  prompt: options.prompt,
6343
- previousInteractionId: (_h = opts == null ? void 0 : opts.previousInteractionId) != null ? _h : void 0,
6344
- store: (_i = opts == null ? void 0 : opts.store) != null ? _i : void 0,
6345
- mediaResolution: (_j = opts == null ? void 0 : opts.mediaResolution) != null ? _j : void 0
6365
+ previousInteractionId: (_m = opts == null ? void 0 : opts.previousInteractionId) != null ? _m : void 0,
6366
+ store: (_n = opts == null ? void 0 : opts.store) != null ? _n : void 0,
6367
+ mediaResolution: (_o = opts == null ? void 0 : opts.mediaResolution) != null ? _o : void 0
6346
6368
  });
6347
6369
  warnings.push(...convWarnings);
6348
6370
  let systemInstruction = convertedSystemInstruction;
6349
- const optionSystemInstruction = (_k = opts == null ? void 0 : opts.systemInstruction) != null ? _k : void 0;
6371
+ const optionSystemInstruction = (_p = opts == null ? void 0 : opts.systemInstruction) != null ? _p : void 0;
6350
6372
  if (systemInstruction != null && optionSystemInstruction != null) {
6351
6373
  warnings.push({
6352
6374
  type: "other",
@@ -6385,14 +6407,14 @@ var GoogleInteractionsLanguageModel = class {
6385
6407
  generationConfig = void 0;
6386
6408
  } else {
6387
6409
  generationConfig = pruneUndefined({
6388
- temperature: (_l = options.temperature) != null ? _l : void 0,
6389
- top_p: (_m = options.topP) != null ? _m : void 0,
6390
- top_k: (_n = options.topK) != null ? _n : void 0,
6391
- seed: (_o = options.seed) != null ? _o : void 0,
6410
+ temperature: (_q = options.temperature) != null ? _q : void 0,
6411
+ top_p: (_r = options.topP) != null ? _r : void 0,
6412
+ top_k: (_s = options.topK) != null ? _s : void 0,
6413
+ seed: (_t = options.seed) != null ? _t : void 0,
6392
6414
  stop_sequences: options.stopSequences != null && options.stopSequences.length > 0 ? options.stopSequences : void 0,
6393
- max_output_tokens: (_p = options.maxOutputTokens) != null ? _p : void 0,
6394
- thinking_level: (_q = opts == null ? void 0 : opts.thinkingLevel) != null ? _q : void 0,
6395
- thinking_summaries: (_r = opts == null ? void 0 : opts.thinkingSummaries) != null ? _r : void 0,
6415
+ max_output_tokens: (_u = options.maxOutputTokens) != null ? _u : void 0,
6416
+ thinking_level: (_v = opts == null ? void 0 : opts.thinkingLevel) != null ? _v : void 0,
6417
+ thinking_summaries: (_w = opts == null ? void 0 : opts.thinkingSummaries) != null ? _w : void 0,
6396
6418
  tool_choice: toolChoiceForBody
6397
6419
  });
6398
6420
  if ((opts == null ? void 0 : opts.imageConfig) != null) {
@@ -6419,9 +6441,9 @@ var GoogleInteractionsLanguageModel = class {
6419
6441
  if (ac.type === "deep-research") {
6420
6442
  agentConfig = pruneUndefined({
6421
6443
  type: "deep-research",
6422
- thinking_summaries: (_s = ac.thinkingSummaries) != null ? _s : void 0,
6423
- visualization: (_t = ac.visualization) != null ? _t : void 0,
6424
- collaborative_planning: (_u = ac.collaborativePlanning) != null ? _u : void 0
6444
+ thinking_summaries: (_x = ac.thinkingSummaries) != null ? _x : void 0,
6445
+ visualization: (_y = ac.visualization) != null ? _y : void 0,
6446
+ collaborative_planning: (_z = ac.collaborativePlanning) != null ? _z : void 0
6425
6447
  });
6426
6448
  } else if (ac.type === "dynamic") {
6427
6449
  agentConfig = { type: "dynamic" };
@@ -6438,7 +6460,7 @@ var GoogleInteractionsLanguageModel = class {
6438
6460
  environment = opts.environment;
6439
6461
  } else {
6440
6462
  const env = opts.environment;
6441
- const sources = (_v = env.sources) == null ? void 0 : _v.map((s) => {
6463
+ const sources = (_A = env.sources) == null ? void 0 : _A.map((s) => {
6442
6464
  var _a2;
6443
6465
  if (s.type === "inline") {
6444
6466
  return {
@@ -6483,20 +6505,20 @@ var GoogleInteractionsLanguageModel = class {
6483
6505
  tools: toolsForBody,
6484
6506
  response_format: responseFormatEntries.length > 0 ? responseFormatEntries : void 0,
6485
6507
  response_modalities: (opts == null ? void 0 : opts.responseModalities) != null ? opts.responseModalities : void 0,
6486
- previous_interaction_id: (_w = opts == null ? void 0 : opts.previousInteractionId) != null ? _w : void 0,
6487
- service_tier: (_x = opts == null ? void 0 : opts.serviceTier) != null ? _x : void 0,
6488
- store: (_y = opts == null ? void 0 : opts.store) != null ? _y : void 0,
6508
+ previous_interaction_id: (_B = opts == null ? void 0 : opts.previousInteractionId) != null ? _B : void 0,
6509
+ service_tier: (_C = opts == null ? void 0 : opts.serviceTier) != null ? _C : void 0,
6510
+ store: (_D = opts == null ? void 0 : opts.store) != null ? _D : void 0,
6489
6511
  generation_config: generationConfig != null && Object.keys(generationConfig).length > 0 ? generationConfig : void 0,
6490
6512
  agent_config: agentConfig,
6491
6513
  environment,
6492
- background: (_z = opts == null ? void 0 : opts.background) != null ? _z : void 0
6514
+ background: (_E = opts == null ? void 0 : opts.background) != null ? _E : void 0
6493
6515
  });
6494
6516
  return {
6495
6517
  args,
6496
6518
  warnings,
6497
6519
  isAgent,
6498
6520
  isBackground: (opts == null ? void 0 : opts.background) === true,
6499
- pollingTimeoutMs: (_A = opts == null ? void 0 : opts.pollingTimeoutMs) != null ? _A : void 0
6521
+ pollingTimeoutMs: (_F = opts == null ? void 0 : opts.pollingTimeoutMs) != null ? _F : void 0
6500
6522
  };
6501
6523
  }
6502
6524
  async doGenerate(options) {