@ai-sdk/amazon-bedrock 3.0.64 → 3.0.66

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
@@ -8,7 +8,7 @@ import {
8
8
  } from "@ai-sdk/provider-utils";
9
9
 
10
10
  // src/version.ts
11
- var VERSION = true ? "3.0.64" : "0.0.0-test";
11
+ var VERSION = true ? "3.0.66" : "0.0.0-test";
12
12
 
13
13
  // src/bedrock-provider.ts
14
14
  import { anthropicTools as anthropicTools2 } from "@ai-sdk/anthropic/internal";
@@ -81,7 +81,8 @@ var bedrockProviderOptions = z.object({
81
81
  additionalModelRequestFields: z.record(z.string(), z.any()).optional(),
82
82
  reasoningConfig: z.object({
83
83
  type: z.union([z.literal("enabled"), z.literal("disabled")]).optional(),
84
- budgetTokens: z.number().optional()
84
+ budgetTokens: z.number().optional(),
85
+ maxReasoningEffort: z.enum(["low", "medium", "high"]).optional()
85
86
  }).optional(),
86
87
  /**
87
88
  * Anthropic beta features to enable
@@ -688,7 +689,7 @@ var BedrockChatLanguageModel = class {
688
689
  toolChoice,
689
690
  providerOptions
690
691
  }) {
691
- var _a, _b, _c, _d, _e, _f, _g;
692
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
692
693
  const bedrockOptions = (_a = await parseProviderOptions2({
693
694
  provider: "bedrock",
694
695
  providerOptions,
@@ -761,8 +762,10 @@ var BedrockChatLanguageModel = class {
761
762
  anthropic_beta: mergedBetas
762
763
  };
763
764
  }
764
- const isThinking = ((_c = bedrockOptions.reasoningConfig) == null ? void 0 : _c.type) === "enabled";
765
+ const isAnthropicModel = this.modelId.includes("anthropic");
766
+ const isThinkingRequested = ((_c = bedrockOptions.reasoningConfig) == null ? void 0 : _c.type) === "enabled";
765
767
  const thinkingBudget = (_d = bedrockOptions.reasoningConfig) == null ? void 0 : _d.budgetTokens;
768
+ const isAnthropicThinkingEnabled = isAnthropicModel && isThinkingRequested;
766
769
  const inferenceConfig = {
767
770
  ...maxOutputTokens != null && { maxTokens: maxOutputTokens },
768
771
  ...temperature != null && { temperature },
@@ -770,7 +773,7 @@ var BedrockChatLanguageModel = class {
770
773
  ...topK != null && { topK },
771
774
  ...stopSequences != null && { stopSequences }
772
775
  };
773
- if (isThinking && thinkingBudget != null) {
776
+ if (isAnthropicThinkingEnabled && thinkingBudget != null) {
774
777
  if (inferenceConfig.maxTokens != null) {
775
778
  inferenceConfig.maxTokens += thinkingBudget;
776
779
  } else {
@@ -783,8 +786,32 @@ var BedrockChatLanguageModel = class {
783
786
  budget_tokens: thinkingBudget
784
787
  }
785
788
  };
789
+ } else if (!isAnthropicModel && thinkingBudget != null) {
790
+ warnings.push({
791
+ type: "unsupported-setting",
792
+ setting: "providerOptions",
793
+ details: "budgetTokens applies only to Anthropic models on Bedrock and will be ignored for this model."
794
+ });
795
+ }
796
+ const maxReasoningEffort = (_f = bedrockOptions.reasoningConfig) == null ? void 0 : _f.maxReasoningEffort;
797
+ if (maxReasoningEffort != null && !isAnthropicModel) {
798
+ bedrockOptions.additionalModelRequestFields = {
799
+ ...bedrockOptions.additionalModelRequestFields,
800
+ reasoningConfig: {
801
+ ...((_g = bedrockOptions.reasoningConfig) == null ? void 0 : _g.type) != null && {
802
+ type: bedrockOptions.reasoningConfig.type
803
+ },
804
+ maxReasoningEffort
805
+ }
806
+ };
807
+ } else if (maxReasoningEffort != null && isAnthropicModel) {
808
+ warnings.push({
809
+ type: "unsupported-setting",
810
+ setting: "providerOptions",
811
+ details: "maxReasoningEffort applies only to Amazon Nova models on Bedrock and will be ignored for this model."
812
+ });
786
813
  }
787
- if (isThinking && inferenceConfig.temperature != null) {
814
+ if (isAnthropicThinkingEnabled && inferenceConfig.temperature != null) {
788
815
  delete inferenceConfig.temperature;
789
816
  warnings.push({
790
817
  type: "unsupported-setting",
@@ -792,7 +819,7 @@ var BedrockChatLanguageModel = class {
792
819
  details: "temperature is not supported when thinking is enabled"
793
820
  });
794
821
  }
795
- if (isThinking && inferenceConfig.topP != null) {
822
+ if (isAnthropicThinkingEnabled && inferenceConfig.topP != null) {
796
823
  delete inferenceConfig.topP;
797
824
  warnings.push({
798
825
  type: "unsupported-setting",
@@ -800,7 +827,7 @@ var BedrockChatLanguageModel = class {
800
827
  details: "topP is not supported when thinking is enabled"
801
828
  });
802
829
  }
803
- if (isThinking && inferenceConfig.topK != null) {
830
+ if (isAnthropicThinkingEnabled && inferenceConfig.topK != null) {
804
831
  delete inferenceConfig.topK;
805
832
  warnings.push({
806
833
  type: "unsupported-setting",
@@ -808,7 +835,7 @@ var BedrockChatLanguageModel = class {
808
835
  details: "topK is not supported when thinking is enabled"
809
836
  });
810
837
  }
811
- const hasAnyTools = ((_g = (_f = toolConfig.tools) == null ? void 0 : _f.length) != null ? _g : 0) > 0 || additionalTools;
838
+ const hasAnyTools = ((_i = (_h = toolConfig.tools) == null ? void 0 : _h.length) != null ? _i : 0) > 0 || additionalTools;
812
839
  let filteredPrompt = prompt;
813
840
  if (!hasAnyTools) {
814
841
  const hasToolContent = prompt.some(