@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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @ai-sdk/google
2
2
 
3
+ ## 3.0.102
4
+
5
+ ### Patch Changes
6
+
7
+ - e728a98: Forward `topK` through Google Interactions requests and warn when unsupported frequency or presence penalties are provided.
8
+
9
+ ## 3.0.101
10
+
11
+ ### Patch Changes
12
+
13
+ - 326887b: fix(google): omit unsupported function call IDs
14
+
3
15
  ## 3.0.100
4
16
 
5
17
  ### Patch Changes
package/dist/index.js CHANGED
@@ -30,7 +30,7 @@ module.exports = __toCommonJS(index_exports);
30
30
  var import_provider_utils23 = require("@ai-sdk/provider-utils");
31
31
 
32
32
  // src/version.ts
33
- var VERSION = true ? "3.0.100" : "0.0.0-test";
33
+ var VERSION = true ? "3.0.102" : "0.0.0-test";
34
34
 
35
35
  // src/google-generative-ai-embedding-model.ts
36
36
  var import_provider = require("@ai-sdk/provider");
@@ -446,7 +446,7 @@ function convertUrlToolResultPart(url) {
446
446
  }
447
447
  };
448
448
  }
449
- function appendToolResultParts(parts, toolName, outputValue, toolCallId) {
449
+ function appendToolResultParts(parts, toolName, outputValue, toolCallId, includeFunctionCallIds = true) {
450
450
  const functionResponseParts = [];
451
451
  const responseTextParts = [];
452
452
  for (const contentPart of outputValue) {
@@ -485,7 +485,7 @@ function appendToolResultParts(parts, toolName, outputValue, toolCallId) {
485
485
  }
486
486
  parts.push({
487
487
  functionResponse: {
488
- ...toolCallId != null ? { id: toolCallId } : {},
488
+ ...includeFunctionCallIds && toolCallId != null ? { id: toolCallId } : {},
489
489
  name: toolName,
490
490
  response: {
491
491
  name: toolName,
@@ -495,13 +495,13 @@ function appendToolResultParts(parts, toolName, outputValue, toolCallId) {
495
495
  }
496
496
  });
497
497
  }
498
- function appendLegacyToolResultParts(parts, toolName, outputValue, toolCallId) {
498
+ function appendLegacyToolResultParts(parts, toolName, outputValue, toolCallId, includeFunctionCallIds = true) {
499
499
  for (const contentPart of outputValue) {
500
500
  switch (contentPart.type) {
501
501
  case "text":
502
502
  parts.push({
503
503
  functionResponse: {
504
- ...toolCallId != null ? { id: toolCallId } : {},
504
+ ...includeFunctionCallIds && toolCallId != null ? { id: toolCallId } : {},
505
505
  name: toolName,
506
506
  response: {
507
507
  name: toolName,
@@ -533,7 +533,7 @@ function appendLegacyToolResultParts(parts, toolName, outputValue, toolCallId) {
533
533
  }
534
534
  }
535
535
  function convertToGoogleGenerativeAIMessages(prompt, options) {
536
- var _a, _b, _c, _d, _e;
536
+ var _a, _b, _c, _d, _e, _f;
537
537
  const systemInstructionParts = [];
538
538
  const contents = [];
539
539
  let systemMessagesAllowed = true;
@@ -542,6 +542,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
542
542
  const providerOptionsName = (_c = options == null ? void 0 : options.providerOptionsName) != null ? _c : "google";
543
543
  const supportsFunctionResponseParts = (_d = options == null ? void 0 : options.supportsFunctionResponseParts) != null ? _d : true;
544
544
  const onWarning = options == null ? void 0 : options.onWarning;
545
+ const includeFunctionCallIds = (_e = options == null ? void 0 : options.includeFunctionCallIds) != null ? _e : true;
545
546
  let sentinelInjected = false;
546
547
  const missingSignatureToolNames = [];
547
548
  const injectSkipSignature = (toolName) => {
@@ -658,7 +659,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
658
659
  }
659
660
  return {
660
661
  functionCall: {
661
- ...part.toolCallId != null ? { id: part.toolCallId } : {},
662
+ ...includeFunctionCallIds && part.toolCallId != null ? { id: part.toolCallId } : {},
662
663
  name: part.toolName,
663
664
  args: part.input
664
665
  },
@@ -722,24 +723,26 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
722
723
  parts,
723
724
  part.toolName,
724
725
  output.value,
725
- part.toolCallId
726
+ part.toolCallId,
727
+ includeFunctionCallIds
726
728
  );
727
729
  } else {
728
730
  appendLegacyToolResultParts(
729
731
  parts,
730
732
  part.toolName,
731
733
  output.value,
732
- part.toolCallId
734
+ part.toolCallId,
735
+ includeFunctionCallIds
733
736
  );
734
737
  }
735
738
  } else {
736
739
  parts.push({
737
740
  functionResponse: {
738
- ...part.toolCallId != null ? { id: part.toolCallId } : {},
741
+ ...includeFunctionCallIds && part.toolCallId != null ? { id: part.toolCallId } : {},
739
742
  name: part.toolName,
740
743
  response: {
741
744
  name: part.toolName,
742
- content: output.type === "execution-denied" ? (_e = output.reason) != null ? _e : "Tool call execution denied." : output.value
745
+ content: output.type === "execution-denied" ? (_f = output.reason) != null ? _f : "Tool call execution denied." : output.value
743
746
  }
744
747
  }
745
748
  });
@@ -1611,7 +1614,8 @@ var GoogleGenerativeAILanguageModel = class {
1611
1614
  isGemini3Model: usesGemini3Features,
1612
1615
  providerOptionsName,
1613
1616
  supportsFunctionResponseParts: usesGemini3Features,
1614
- onWarning: (warning) => warnings.push(warning)
1617
+ onWarning: (warning) => warnings.push(warning),
1618
+ includeFunctionCallIds: !isVertexProvider
1615
1619
  }
1616
1620
  );
1617
1621
  const {
@@ -5768,7 +5772,7 @@ var GoogleInteractionsLanguageModel = class {
5768
5772
  };
5769
5773
  }
5770
5774
  async getArgs(options) {
5771
- 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;
5775
+ 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;
5772
5776
  const warnings = [];
5773
5777
  const opts = await (0, import_provider_utils22.parseProviderOptions)({
5774
5778
  provider: "google",
@@ -5776,6 +5780,20 @@ var GoogleInteractionsLanguageModel = class {
5776
5780
  schema: googleInteractionsLanguageModelOptions
5777
5781
  });
5778
5782
  const isAgent = this.agent != null;
5783
+ if (!isAgent) {
5784
+ if (options.frequencyPenalty != null) {
5785
+ warnings.push({
5786
+ type: "unsupported",
5787
+ feature: "frequencyPenalty"
5788
+ });
5789
+ }
5790
+ if (options.presencePenalty != null) {
5791
+ warnings.push({
5792
+ type: "unsupported",
5793
+ feature: "presencePenalty"
5794
+ });
5795
+ }
5796
+ }
5779
5797
  const hasTools = options.tools != null && options.tools.length > 0;
5780
5798
  let toolsForBody;
5781
5799
  let toolChoiceForBody;
@@ -5859,6 +5877,11 @@ var GoogleInteractionsLanguageModel = class {
5859
5877
  const droppedFields = [];
5860
5878
  if (options.temperature != null) droppedFields.push("temperature");
5861
5879
  if (options.topP != null) droppedFields.push("topP");
5880
+ if (options.topK != null) droppedFields.push("topK");
5881
+ if (options.frequencyPenalty != null)
5882
+ droppedFields.push("frequencyPenalty");
5883
+ if (options.presencePenalty != null)
5884
+ droppedFields.push("presencePenalty");
5862
5885
  if (options.seed != null) droppedFields.push("seed");
5863
5886
  if (options.stopSequences != null && options.stopSequences.length > 0) {
5864
5887
  droppedFields.push("stopSequences");
@@ -5881,11 +5904,12 @@ var GoogleInteractionsLanguageModel = class {
5881
5904
  generationConfig = pruneUndefined({
5882
5905
  temperature: (_l = options.temperature) != null ? _l : void 0,
5883
5906
  top_p: (_m = options.topP) != null ? _m : void 0,
5884
- seed: (_n = options.seed) != null ? _n : void 0,
5907
+ top_k: (_n = options.topK) != null ? _n : void 0,
5908
+ seed: (_o = options.seed) != null ? _o : void 0,
5885
5909
  stop_sequences: options.stopSequences != null && options.stopSequences.length > 0 ? options.stopSequences : void 0,
5886
- max_output_tokens: (_o = options.maxOutputTokens) != null ? _o : void 0,
5887
- thinking_level: (_p = opts == null ? void 0 : opts.thinkingLevel) != null ? _p : void 0,
5888
- thinking_summaries: (_q = opts == null ? void 0 : opts.thinkingSummaries) != null ? _q : void 0,
5910
+ max_output_tokens: (_p = options.maxOutputTokens) != null ? _p : void 0,
5911
+ thinking_level: (_q = opts == null ? void 0 : opts.thinkingLevel) != null ? _q : void 0,
5912
+ thinking_summaries: (_r = opts == null ? void 0 : opts.thinkingSummaries) != null ? _r : void 0,
5889
5913
  tool_choice: toolChoiceForBody
5890
5914
  });
5891
5915
  if ((opts == null ? void 0 : opts.imageConfig) != null) {
@@ -5912,9 +5936,9 @@ var GoogleInteractionsLanguageModel = class {
5912
5936
  if (ac.type === "deep-research") {
5913
5937
  agentConfig = pruneUndefined({
5914
5938
  type: "deep-research",
5915
- thinking_summaries: (_r = ac.thinkingSummaries) != null ? _r : void 0,
5916
- visualization: (_s = ac.visualization) != null ? _s : void 0,
5917
- collaborative_planning: (_t = ac.collaborativePlanning) != null ? _t : void 0
5939
+ thinking_summaries: (_s = ac.thinkingSummaries) != null ? _s : void 0,
5940
+ visualization: (_t = ac.visualization) != null ? _t : void 0,
5941
+ collaborative_planning: (_u = ac.collaborativePlanning) != null ? _u : void 0
5918
5942
  });
5919
5943
  } else if (ac.type === "dynamic") {
5920
5944
  agentConfig = { type: "dynamic" };
@@ -5931,7 +5955,7 @@ var GoogleInteractionsLanguageModel = class {
5931
5955
  environment = opts.environment;
5932
5956
  } else {
5933
5957
  const env = opts.environment;
5934
- const sources = (_u = env.sources) == null ? void 0 : _u.map((s) => {
5958
+ const sources = (_v = env.sources) == null ? void 0 : _v.map((s) => {
5935
5959
  var _a2;
5936
5960
  if (s.type === "inline") {
5937
5961
  return {
@@ -5976,20 +6000,20 @@ var GoogleInteractionsLanguageModel = class {
5976
6000
  tools: toolsForBody,
5977
6001
  response_format: responseFormatEntries.length > 0 ? responseFormatEntries : void 0,
5978
6002
  response_modalities: (opts == null ? void 0 : opts.responseModalities) != null ? opts.responseModalities : void 0,
5979
- previous_interaction_id: (_v = opts == null ? void 0 : opts.previousInteractionId) != null ? _v : void 0,
5980
- service_tier: (_w = opts == null ? void 0 : opts.serviceTier) != null ? _w : void 0,
5981
- store: (_x = opts == null ? void 0 : opts.store) != null ? _x : void 0,
6003
+ previous_interaction_id: (_w = opts == null ? void 0 : opts.previousInteractionId) != null ? _w : void 0,
6004
+ service_tier: (_x = opts == null ? void 0 : opts.serviceTier) != null ? _x : void 0,
6005
+ store: (_y = opts == null ? void 0 : opts.store) != null ? _y : void 0,
5982
6006
  generation_config: generationConfig != null && Object.keys(generationConfig).length > 0 ? generationConfig : void 0,
5983
6007
  agent_config: agentConfig,
5984
6008
  environment,
5985
- background: (_y = opts == null ? void 0 : opts.background) != null ? _y : void 0
6009
+ background: (_z = opts == null ? void 0 : opts.background) != null ? _z : void 0
5986
6010
  });
5987
6011
  return {
5988
6012
  args,
5989
6013
  warnings,
5990
6014
  isAgent,
5991
6015
  isBackground: (opts == null ? void 0 : opts.background) === true,
5992
- pollingTimeoutMs: (_z = opts == null ? void 0 : opts.pollingTimeoutMs) != null ? _z : void 0
6016
+ pollingTimeoutMs: (_A = opts == null ? void 0 : opts.pollingTimeoutMs) != null ? _A : void 0
5993
6017
  };
5994
6018
  }
5995
6019
  async doGenerate(options) {