@ai-sdk/amazon-bedrock 4.0.0-beta.79 → 4.0.0-beta.80

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/amazon-bedrock
2
2
 
3
+ ## 4.0.0-beta.80
4
+
5
+ ### Patch Changes
6
+
7
+ - f65d7df: feat(provider/bedrock): Support Nova 2 extended reasoning `maxReasoningEffort` field
8
+
3
9
  ## 4.0.0-beta.79
4
10
 
5
11
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -10,6 +10,11 @@ declare const bedrockProviderOptions: z.ZodObject<{
10
10
  reasoningConfig: z.ZodOptional<z.ZodObject<{
11
11
  type: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"enabled">, z.ZodLiteral<"disabled">]>>;
12
12
  budgetTokens: z.ZodOptional<z.ZodNumber>;
13
+ maxReasoningEffort: z.ZodOptional<z.ZodEnum<{
14
+ low: "low";
15
+ medium: "medium";
16
+ high: "high";
17
+ }>>;
13
18
  }, z.core.$strip>>;
14
19
  anthropicBeta: z.ZodOptional<z.ZodArray<z.ZodString>>;
15
20
  }, z.core.$strip>;
package/dist/index.d.ts CHANGED
@@ -10,6 +10,11 @@ declare const bedrockProviderOptions: z.ZodObject<{
10
10
  reasoningConfig: z.ZodOptional<z.ZodObject<{
11
11
  type: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"enabled">, z.ZodLiteral<"disabled">]>>;
12
12
  budgetTokens: z.ZodOptional<z.ZodNumber>;
13
+ maxReasoningEffort: z.ZodOptional<z.ZodEnum<{
14
+ low: "low";
15
+ medium: "medium";
16
+ high: "high";
17
+ }>>;
13
18
  }, z.core.$strip>>;
14
19
  anthropicBeta: z.ZodOptional<z.ZodArray<z.ZodString>>;
15
20
  }, z.core.$strip>;
package/dist/index.js CHANGED
@@ -91,7 +91,8 @@ var bedrockProviderOptions = import_v4.z.object({
91
91
  additionalModelRequestFields: import_v4.z.record(import_v4.z.string(), import_v4.z.any()).optional(),
92
92
  reasoningConfig: import_v4.z.object({
93
93
  type: import_v4.z.union([import_v4.z.literal("enabled"), import_v4.z.literal("disabled")]).optional(),
94
- budgetTokens: import_v4.z.number().optional()
94
+ budgetTokens: import_v4.z.number().optional(),
95
+ maxReasoningEffort: import_v4.z.enum(["low", "medium", "high"]).optional()
95
96
  }).optional(),
96
97
  /**
97
98
  * Anthropic beta features to enable
@@ -696,7 +697,7 @@ var BedrockChatLanguageModel = class {
696
697
  toolChoice,
697
698
  providerOptions
698
699
  }) {
699
- var _a, _b, _c, _d, _e, _f, _g;
700
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
700
701
  const bedrockOptions = (_a = await (0, import_provider_utils4.parseProviderOptions)({
701
702
  provider: "bedrock",
702
703
  providerOptions,
@@ -769,8 +770,10 @@ var BedrockChatLanguageModel = class {
769
770
  anthropic_beta: mergedBetas
770
771
  };
771
772
  }
772
- const isThinking = ((_c = bedrockOptions.reasoningConfig) == null ? void 0 : _c.type) === "enabled";
773
+ const isAnthropicModel = this.modelId.includes("anthropic");
774
+ const isThinkingRequested = ((_c = bedrockOptions.reasoningConfig) == null ? void 0 : _c.type) === "enabled";
773
775
  const thinkingBudget = (_d = bedrockOptions.reasoningConfig) == null ? void 0 : _d.budgetTokens;
776
+ const isAnthropicThinkingEnabled = isAnthropicModel && isThinkingRequested;
774
777
  const inferenceConfig = {
775
778
  ...maxOutputTokens != null && { maxTokens: maxOutputTokens },
776
779
  ...temperature != null && { temperature },
@@ -778,7 +781,7 @@ var BedrockChatLanguageModel = class {
778
781
  ...topK != null && { topK },
779
782
  ...stopSequences != null && { stopSequences }
780
783
  };
781
- if (isThinking && thinkingBudget != null) {
784
+ if (isAnthropicThinkingEnabled && thinkingBudget != null) {
782
785
  if (inferenceConfig.maxTokens != null) {
783
786
  inferenceConfig.maxTokens += thinkingBudget;
784
787
  } else {
@@ -791,8 +794,32 @@ var BedrockChatLanguageModel = class {
791
794
  budget_tokens: thinkingBudget
792
795
  }
793
796
  };
797
+ } else if (!isAnthropicModel && thinkingBudget != null) {
798
+ warnings.push({
799
+ type: "unsupported",
800
+ feature: "budgetTokens",
801
+ details: "budgetTokens applies only to Anthropic models on Bedrock and will be ignored for this model."
802
+ });
803
+ }
804
+ const maxReasoningEffort = (_f = bedrockOptions.reasoningConfig) == null ? void 0 : _f.maxReasoningEffort;
805
+ if (maxReasoningEffort != null && !isAnthropicModel) {
806
+ bedrockOptions.additionalModelRequestFields = {
807
+ ...bedrockOptions.additionalModelRequestFields,
808
+ reasoningConfig: {
809
+ ...((_g = bedrockOptions.reasoningConfig) == null ? void 0 : _g.type) != null && {
810
+ type: bedrockOptions.reasoningConfig.type
811
+ },
812
+ maxReasoningEffort
813
+ }
814
+ };
815
+ } else if (maxReasoningEffort != null && isAnthropicModel) {
816
+ warnings.push({
817
+ type: "unsupported",
818
+ feature: "maxReasoningEffort",
819
+ details: "maxReasoningEffort applies only to Amazon Nova models on Bedrock and will be ignored for this model."
820
+ });
794
821
  }
795
- if (isThinking && inferenceConfig.temperature != null) {
822
+ if (isAnthropicThinkingEnabled && inferenceConfig.temperature != null) {
796
823
  delete inferenceConfig.temperature;
797
824
  warnings.push({
798
825
  type: "unsupported",
@@ -800,7 +827,7 @@ var BedrockChatLanguageModel = class {
800
827
  details: "temperature is not supported when thinking is enabled"
801
828
  });
802
829
  }
803
- if (isThinking && inferenceConfig.topP != null) {
830
+ if (isAnthropicThinkingEnabled && inferenceConfig.topP != null) {
804
831
  delete inferenceConfig.topP;
805
832
  warnings.push({
806
833
  type: "unsupported",
@@ -808,7 +835,7 @@ var BedrockChatLanguageModel = class {
808
835
  details: "topP is not supported when thinking is enabled"
809
836
  });
810
837
  }
811
- if (isThinking && inferenceConfig.topK != null) {
838
+ if (isAnthropicThinkingEnabled && inferenceConfig.topK != null) {
812
839
  delete inferenceConfig.topK;
813
840
  warnings.push({
814
841
  type: "unsupported",
@@ -816,7 +843,7 @@ var BedrockChatLanguageModel = class {
816
843
  details: "topK is not supported when thinking is enabled"
817
844
  });
818
845
  }
819
- const hasAnyTools = ((_g = (_f = toolConfig.tools) == null ? void 0 : _f.length) != null ? _g : 0) > 0 || additionalTools;
846
+ const hasAnyTools = ((_i = (_h = toolConfig.tools) == null ? void 0 : _h.length) != null ? _i : 0) > 0 || additionalTools;
820
847
  let filteredPrompt = prompt;
821
848
  if (!hasAnyTools) {
822
849
  const hasToolContent = prompt.some(
@@ -1535,7 +1562,7 @@ var import_provider_utils7 = require("@ai-sdk/provider-utils");
1535
1562
  var import_aws4fetch = require("aws4fetch");
1536
1563
 
1537
1564
  // src/version.ts
1538
- var VERSION = true ? "4.0.0-beta.79" : "0.0.0-test";
1565
+ var VERSION = true ? "4.0.0-beta.80" : "0.0.0-test";
1539
1566
 
1540
1567
  // src/bedrock-sigv4-fetch.ts
1541
1568
  function createSigV4FetchFunction(getCredentials, fetch = globalThis.fetch) {