@ai-sdk/google 4.0.0-beta.0 → 4.0.0-beta.1

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,11 @@
1
1
  # @ai-sdk/google
2
2
 
3
+ ## 4.0.0-beta.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 19b95f9: fix(google): use VALIDATED function calling mode when any tool has strict:true
8
+
3
9
  ## 4.0.0-beta.0
4
10
 
5
11
  ### Major Changes
package/dist/index.js CHANGED
@@ -30,7 +30,7 @@ module.exports = __toCommonJS(src_exports);
30
30
  var import_provider_utils16 = require("@ai-sdk/provider-utils");
31
31
 
32
32
  // src/version.ts
33
- var VERSION = true ? "4.0.0-beta.0" : "0.0.0-test";
33
+ var VERSION = true ? "4.0.0-beta.1" : "0.0.0-test";
34
34
 
35
35
  // src/google-generative-ai-embedding-model.ts
36
36
  var import_provider = require("@ai-sdk/provider");
@@ -795,6 +795,7 @@ function prepareTools({
795
795
  };
796
796
  }
797
797
  const functionDeclarations = [];
798
+ let hasStrictTools = false;
798
799
  for (const tool of tools) {
799
800
  switch (tool.type) {
800
801
  case "function":
@@ -803,6 +804,9 @@ function prepareTools({
803
804
  description: (_a = tool.description) != null ? _a : "",
804
805
  parameters: convertJSONSchemaToOpenAPISchema(tool.inputSchema)
805
806
  });
807
+ if (tool.strict === true) {
808
+ hasStrictTools = true;
809
+ }
806
810
  break;
807
811
  default:
808
812
  toolWarnings.push({
@@ -815,7 +819,7 @@ function prepareTools({
815
819
  if (toolChoice == null) {
816
820
  return {
817
821
  tools: [{ functionDeclarations }],
818
- toolConfig: void 0,
822
+ toolConfig: hasStrictTools ? { functionCallingConfig: { mode: "VALIDATED" } } : void 0,
819
823
  toolWarnings
820
824
  };
821
825
  }
@@ -824,7 +828,11 @@ function prepareTools({
824
828
  case "auto":
825
829
  return {
826
830
  tools: [{ functionDeclarations }],
827
- toolConfig: { functionCallingConfig: { mode: "AUTO" } },
831
+ toolConfig: {
832
+ functionCallingConfig: {
833
+ mode: hasStrictTools ? "VALIDATED" : "AUTO"
834
+ }
835
+ },
828
836
  toolWarnings
829
837
  };
830
838
  case "none":
@@ -836,7 +844,11 @@ function prepareTools({
836
844
  case "required":
837
845
  return {
838
846
  tools: [{ functionDeclarations }],
839
- toolConfig: { functionCallingConfig: { mode: "ANY" } },
847
+ toolConfig: {
848
+ functionCallingConfig: {
849
+ mode: hasStrictTools ? "VALIDATED" : "ANY"
850
+ }
851
+ },
840
852
  toolWarnings
841
853
  };
842
854
  case "tool":
@@ -844,7 +856,7 @@ function prepareTools({
844
856
  tools: [{ functionDeclarations }],
845
857
  toolConfig: {
846
858
  functionCallingConfig: {
847
- mode: "ANY",
859
+ mode: hasStrictTools ? "VALIDATED" : "ANY",
848
860
  allowedFunctionNames: [toolChoice.toolName]
849
861
  }
850
862
  },