@ai-sdk/google 3.0.100 → 3.0.102

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
@@ -7,7 +7,7 @@ import {
7
7
  } from "@ai-sdk/provider-utils";
8
8
 
9
9
  // src/version.ts
10
- var VERSION = true ? "3.0.100" : "0.0.0-test";
10
+ var VERSION = true ? "3.0.102" : "0.0.0-test";
11
11
 
12
12
  // src/google-generative-ai-embedding-model.ts
13
13
  import {
@@ -452,7 +452,7 @@ function convertUrlToolResultPart(url) {
452
452
  }
453
453
  };
454
454
  }
455
- function appendToolResultParts(parts, toolName, outputValue, toolCallId) {
455
+ function appendToolResultParts(parts, toolName, outputValue, toolCallId, includeFunctionCallIds = true) {
456
456
  const functionResponseParts = [];
457
457
  const responseTextParts = [];
458
458
  for (const contentPart of outputValue) {
@@ -491,7 +491,7 @@ function appendToolResultParts(parts, toolName, outputValue, toolCallId) {
491
491
  }
492
492
  parts.push({
493
493
  functionResponse: {
494
- ...toolCallId != null ? { id: toolCallId } : {},
494
+ ...includeFunctionCallIds && toolCallId != null ? { id: toolCallId } : {},
495
495
  name: toolName,
496
496
  response: {
497
497
  name: toolName,
@@ -501,13 +501,13 @@ function appendToolResultParts(parts, toolName, outputValue, toolCallId) {
501
501
  }
502
502
  });
503
503
  }
504
- function appendLegacyToolResultParts(parts, toolName, outputValue, toolCallId) {
504
+ function appendLegacyToolResultParts(parts, toolName, outputValue, toolCallId, includeFunctionCallIds = true) {
505
505
  for (const contentPart of outputValue) {
506
506
  switch (contentPart.type) {
507
507
  case "text":
508
508
  parts.push({
509
509
  functionResponse: {
510
- ...toolCallId != null ? { id: toolCallId } : {},
510
+ ...includeFunctionCallIds && toolCallId != null ? { id: toolCallId } : {},
511
511
  name: toolName,
512
512
  response: {
513
513
  name: toolName,
@@ -539,7 +539,7 @@ function appendLegacyToolResultParts(parts, toolName, outputValue, toolCallId) {
539
539
  }
540
540
  }
541
541
  function convertToGoogleGenerativeAIMessages(prompt, options) {
542
- var _a, _b, _c, _d, _e;
542
+ var _a, _b, _c, _d, _e, _f;
543
543
  const systemInstructionParts = [];
544
544
  const contents = [];
545
545
  let systemMessagesAllowed = true;
@@ -548,6 +548,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
548
548
  const providerOptionsName = (_c = options == null ? void 0 : options.providerOptionsName) != null ? _c : "google";
549
549
  const supportsFunctionResponseParts = (_d = options == null ? void 0 : options.supportsFunctionResponseParts) != null ? _d : true;
550
550
  const onWarning = options == null ? void 0 : options.onWarning;
551
+ const includeFunctionCallIds = (_e = options == null ? void 0 : options.includeFunctionCallIds) != null ? _e : true;
551
552
  let sentinelInjected = false;
552
553
  const missingSignatureToolNames = [];
553
554
  const injectSkipSignature = (toolName) => {
@@ -664,7 +665,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
664
665
  }
665
666
  return {
666
667
  functionCall: {
667
- ...part.toolCallId != null ? { id: part.toolCallId } : {},
668
+ ...includeFunctionCallIds && part.toolCallId != null ? { id: part.toolCallId } : {},
668
669
  name: part.toolName,
669
670
  args: part.input
670
671
  },
@@ -728,24 +729,26 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
728
729
  parts,
729
730
  part.toolName,
730
731
  output.value,
731
- part.toolCallId
732
+ part.toolCallId,
733
+ includeFunctionCallIds
732
734
  );
733
735
  } else {
734
736
  appendLegacyToolResultParts(
735
737
  parts,
736
738
  part.toolName,
737
739
  output.value,
738
- part.toolCallId
740
+ part.toolCallId,
741
+ includeFunctionCallIds
739
742
  );
740
743
  }
741
744
  } else {
742
745
  parts.push({
743
746
  functionResponse: {
744
- ...part.toolCallId != null ? { id: part.toolCallId } : {},
747
+ ...includeFunctionCallIds && part.toolCallId != null ? { id: part.toolCallId } : {},
745
748
  name: part.toolName,
746
749
  response: {
747
750
  name: part.toolName,
748
- content: output.type === "execution-denied" ? (_e = output.reason) != null ? _e : "Tool call execution denied." : output.value
751
+ content: output.type === "execution-denied" ? (_f = output.reason) != null ? _f : "Tool call execution denied." : output.value
749
752
  }
750
753
  }
751
754
  });
@@ -1622,7 +1625,8 @@ var GoogleGenerativeAILanguageModel = class {
1622
1625
  isGemini3Model: usesGemini3Features,
1623
1626
  providerOptionsName,
1624
1627
  supportsFunctionResponseParts: usesGemini3Features,
1625
- onWarning: (warning) => warnings.push(warning)
1628
+ onWarning: (warning) => warnings.push(warning),
1629
+ includeFunctionCallIds: !isVertexProvider
1626
1630
  }
1627
1631
  );
1628
1632
  const {
@@ -5851,7 +5855,7 @@ var GoogleInteractionsLanguageModel = class {
5851
5855
  };
5852
5856
  }
5853
5857
  async getArgs(options) {
5854
- 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;
5858
+ 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;
5855
5859
  const warnings = [];
5856
5860
  const opts = await parseProviderOptions5({
5857
5861
  provider: "google",
@@ -5859,6 +5863,20 @@ var GoogleInteractionsLanguageModel = class {
5859
5863
  schema: googleInteractionsLanguageModelOptions
5860
5864
  });
5861
5865
  const isAgent = this.agent != null;
5866
+ if (!isAgent) {
5867
+ if (options.frequencyPenalty != null) {
5868
+ warnings.push({
5869
+ type: "unsupported",
5870
+ feature: "frequencyPenalty"
5871
+ });
5872
+ }
5873
+ if (options.presencePenalty != null) {
5874
+ warnings.push({
5875
+ type: "unsupported",
5876
+ feature: "presencePenalty"
5877
+ });
5878
+ }
5879
+ }
5862
5880
  const hasTools = options.tools != null && options.tools.length > 0;
5863
5881
  let toolsForBody;
5864
5882
  let toolChoiceForBody;
@@ -5942,6 +5960,11 @@ var GoogleInteractionsLanguageModel = class {
5942
5960
  const droppedFields = [];
5943
5961
  if (options.temperature != null) droppedFields.push("temperature");
5944
5962
  if (options.topP != null) droppedFields.push("topP");
5963
+ if (options.topK != null) droppedFields.push("topK");
5964
+ if (options.frequencyPenalty != null)
5965
+ droppedFields.push("frequencyPenalty");
5966
+ if (options.presencePenalty != null)
5967
+ droppedFields.push("presencePenalty");
5945
5968
  if (options.seed != null) droppedFields.push("seed");
5946
5969
  if (options.stopSequences != null && options.stopSequences.length > 0) {
5947
5970
  droppedFields.push("stopSequences");
@@ -5964,11 +5987,12 @@ var GoogleInteractionsLanguageModel = class {
5964
5987
  generationConfig = pruneUndefined({
5965
5988
  temperature: (_l = options.temperature) != null ? _l : void 0,
5966
5989
  top_p: (_m = options.topP) != null ? _m : void 0,
5967
- seed: (_n = options.seed) != null ? _n : void 0,
5990
+ top_k: (_n = options.topK) != null ? _n : void 0,
5991
+ seed: (_o = options.seed) != null ? _o : void 0,
5968
5992
  stop_sequences: options.stopSequences != null && options.stopSequences.length > 0 ? options.stopSequences : void 0,
5969
- max_output_tokens: (_o = options.maxOutputTokens) != null ? _o : void 0,
5970
- thinking_level: (_p = opts == null ? void 0 : opts.thinkingLevel) != null ? _p : void 0,
5971
- thinking_summaries: (_q = opts == null ? void 0 : opts.thinkingSummaries) != null ? _q : void 0,
5993
+ max_output_tokens: (_p = options.maxOutputTokens) != null ? _p : void 0,
5994
+ thinking_level: (_q = opts == null ? void 0 : opts.thinkingLevel) != null ? _q : void 0,
5995
+ thinking_summaries: (_r = opts == null ? void 0 : opts.thinkingSummaries) != null ? _r : void 0,
5972
5996
  tool_choice: toolChoiceForBody
5973
5997
  });
5974
5998
  if ((opts == null ? void 0 : opts.imageConfig) != null) {
@@ -5995,9 +6019,9 @@ var GoogleInteractionsLanguageModel = class {
5995
6019
  if (ac.type === "deep-research") {
5996
6020
  agentConfig = pruneUndefined({
5997
6021
  type: "deep-research",
5998
- thinking_summaries: (_r = ac.thinkingSummaries) != null ? _r : void 0,
5999
- visualization: (_s = ac.visualization) != null ? _s : void 0,
6000
- collaborative_planning: (_t = ac.collaborativePlanning) != null ? _t : void 0
6022
+ thinking_summaries: (_s = ac.thinkingSummaries) != null ? _s : void 0,
6023
+ visualization: (_t = ac.visualization) != null ? _t : void 0,
6024
+ collaborative_planning: (_u = ac.collaborativePlanning) != null ? _u : void 0
6001
6025
  });
6002
6026
  } else if (ac.type === "dynamic") {
6003
6027
  agentConfig = { type: "dynamic" };
@@ -6014,7 +6038,7 @@ var GoogleInteractionsLanguageModel = class {
6014
6038
  environment = opts.environment;
6015
6039
  } else {
6016
6040
  const env = opts.environment;
6017
- const sources = (_u = env.sources) == null ? void 0 : _u.map((s) => {
6041
+ const sources = (_v = env.sources) == null ? void 0 : _v.map((s) => {
6018
6042
  var _a2;
6019
6043
  if (s.type === "inline") {
6020
6044
  return {
@@ -6059,20 +6083,20 @@ var GoogleInteractionsLanguageModel = class {
6059
6083
  tools: toolsForBody,
6060
6084
  response_format: responseFormatEntries.length > 0 ? responseFormatEntries : void 0,
6061
6085
  response_modalities: (opts == null ? void 0 : opts.responseModalities) != null ? opts.responseModalities : void 0,
6062
- previous_interaction_id: (_v = opts == null ? void 0 : opts.previousInteractionId) != null ? _v : void 0,
6063
- service_tier: (_w = opts == null ? void 0 : opts.serviceTier) != null ? _w : void 0,
6064
- store: (_x = opts == null ? void 0 : opts.store) != null ? _x : void 0,
6086
+ previous_interaction_id: (_w = opts == null ? void 0 : opts.previousInteractionId) != null ? _w : void 0,
6087
+ service_tier: (_x = opts == null ? void 0 : opts.serviceTier) != null ? _x : void 0,
6088
+ store: (_y = opts == null ? void 0 : opts.store) != null ? _y : void 0,
6065
6089
  generation_config: generationConfig != null && Object.keys(generationConfig).length > 0 ? generationConfig : void 0,
6066
6090
  agent_config: agentConfig,
6067
6091
  environment,
6068
- background: (_y = opts == null ? void 0 : opts.background) != null ? _y : void 0
6092
+ background: (_z = opts == null ? void 0 : opts.background) != null ? _z : void 0
6069
6093
  });
6070
6094
  return {
6071
6095
  args,
6072
6096
  warnings,
6073
6097
  isAgent,
6074
6098
  isBackground: (opts == null ? void 0 : opts.background) === true,
6075
- pollingTimeoutMs: (_z = opts == null ? void 0 : opts.pollingTimeoutMs) != null ? _z : void 0
6099
+ pollingTimeoutMs: (_A = opts == null ? void 0 : opts.pollingTimeoutMs) != null ? _A : void 0
6076
6100
  };
6077
6101
  }
6078
6102
  async doGenerate(options) {