@ai-sdk/amazon-bedrock 4.0.0-beta.59 → 4.0.0-beta.61

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,19 @@
1
1
  # @ai-sdk/amazon-bedrock
2
2
 
3
+ ## 4.0.0-beta.61
4
+
5
+ ### Patch Changes
6
+
7
+ - 0a6fd91: fix(amazon-bedrock): move anthropic_beta to request body
8
+
9
+ ## 4.0.0-beta.60
10
+
11
+ ### Patch Changes
12
+
13
+ - 33343c3: fix(amazon-bedrock): clamp temperature to valid 0-1 range with warnings
14
+ - Updated dependencies [1d15673]
15
+ - @ai-sdk/anthropic@3.0.0-beta.54
16
+
3
17
  ## 4.0.0-beta.59
4
18
 
5
19
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -11,6 +11,7 @@ declare const bedrockProviderOptions: z.ZodObject<{
11
11
  type: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"enabled">, z.ZodLiteral<"disabled">]>>;
12
12
  budgetTokens: z.ZodOptional<z.ZodNumber>;
13
13
  }, z.core.$strip>>;
14
+ anthropicBeta: z.ZodOptional<z.ZodArray<z.ZodString>>;
14
15
  }, z.core.$strip>;
15
16
  type BedrockProviderOptions = z.infer<typeof bedrockProviderOptions>;
16
17
 
package/dist/index.d.ts CHANGED
@@ -11,6 +11,7 @@ declare const bedrockProviderOptions: z.ZodObject<{
11
11
  type: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"enabled">, z.ZodLiteral<"disabled">]>>;
12
12
  budgetTokens: z.ZodOptional<z.ZodNumber>;
13
13
  }, z.core.$strip>>;
14
+ anthropicBeta: z.ZodOptional<z.ZodArray<z.ZodString>>;
14
15
  }, z.core.$strip>;
15
16
  type BedrockProviderOptions = z.infer<typeof bedrockProviderOptions>;
16
17
 
package/dist/index.js CHANGED
@@ -92,7 +92,11 @@ var bedrockProviderOptions = import_v4.z.object({
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
94
  budgetTokens: import_v4.z.number().optional()
95
- }).optional()
95
+ }).optional(),
96
+ /**
97
+ * Anthropic beta features to enable
98
+ */
99
+ anthropicBeta: import_v4.z.array(import_v4.z.string()).optional()
96
100
  });
97
101
 
98
102
  // src/bedrock-error.ts
@@ -693,7 +697,7 @@ var BedrockChatLanguageModel = class {
693
697
  toolChoice,
694
698
  providerOptions
695
699
  }) {
696
- var _a, _b, _c, _d, _e, _f;
700
+ var _a, _b, _c, _d, _e, _f, _g;
697
701
  const bedrockOptions = (_a = await (0, import_provider_utils4.parseProviderOptions)({
698
702
  provider: "bedrock",
699
703
  providerOptions,
@@ -718,6 +722,21 @@ var BedrockChatLanguageModel = class {
718
722
  setting: "seed"
719
723
  });
720
724
  }
725
+ if (temperature != null && temperature > 1) {
726
+ warnings.push({
727
+ type: "unsupported-setting",
728
+ setting: "temperature",
729
+ details: `${temperature} exceeds bedrock maximum of 1.0. clamped to 1.0`
730
+ });
731
+ temperature = 1;
732
+ } else if (temperature != null && temperature < 0) {
733
+ warnings.push({
734
+ type: "unsupported-setting",
735
+ setting: "temperature",
736
+ details: `${temperature} is below bedrock minimum of 0. clamped to 0`
737
+ });
738
+ temperature = 0;
739
+ }
721
740
  if (responseFormat != null && responseFormat.type !== "text" && responseFormat.type !== "json") {
722
741
  warnings.push({
723
742
  type: "unsupported-setting",
@@ -751,8 +770,16 @@ var BedrockChatLanguageModel = class {
751
770
  ...additionalTools
752
771
  };
753
772
  }
754
- const isThinking = ((_b = bedrockOptions.reasoningConfig) == null ? void 0 : _b.type) === "enabled";
755
- const thinkingBudget = (_c = bedrockOptions.reasoningConfig) == null ? void 0 : _c.budgetTokens;
773
+ if (betas.size > 0 || bedrockOptions.anthropicBeta) {
774
+ const existingBetas = (_b = bedrockOptions.anthropicBeta) != null ? _b : [];
775
+ const mergedBetas = betas.size > 0 ? [...existingBetas, ...Array.from(betas)] : existingBetas;
776
+ bedrockOptions.additionalModelRequestFields = {
777
+ ...bedrockOptions.additionalModelRequestFields,
778
+ anthropic_beta: mergedBetas
779
+ };
780
+ }
781
+ const isThinking = ((_c = bedrockOptions.reasoningConfig) == null ? void 0 : _c.type) === "enabled";
782
+ const thinkingBudget = (_d = bedrockOptions.reasoningConfig) == null ? void 0 : _d.budgetTokens;
756
783
  const inferenceConfig = {
757
784
  ...maxOutputTokens != null && { maxTokens: maxOutputTokens },
758
785
  ...temperature != null && { temperature },
@@ -769,7 +796,7 @@ var BedrockChatLanguageModel = class {
769
796
  bedrockOptions.additionalModelRequestFields = {
770
797
  ...bedrockOptions.additionalModelRequestFields,
771
798
  thinking: {
772
- type: (_d = bedrockOptions.reasoningConfig) == null ? void 0 : _d.type,
799
+ type: (_e = bedrockOptions.reasoningConfig) == null ? void 0 : _e.type,
773
800
  budget_tokens: thinkingBudget
774
801
  }
775
802
  };
@@ -798,7 +825,7 @@ var BedrockChatLanguageModel = class {
798
825
  details: "topK is not supported when thinking is enabled"
799
826
  });
800
827
  }
801
- const hasAnyTools = ((_f = (_e = toolConfig.tools) == null ? void 0 : _e.length) != null ? _f : 0) > 0 || additionalTools;
828
+ const hasAnyTools = ((_g = (_f = toolConfig.tools) == null ? void 0 : _f.length) != null ? _g : 0) > 0 || additionalTools;
802
829
  let filteredPrompt = prompt;
803
830
  if (!hasAnyTools) {
804
831
  const hasToolContent = prompt.some(
@@ -847,27 +874,21 @@ var BedrockChatLanguageModel = class {
847
874
  };
848
875
  }
849
876
  async getHeaders({
850
- betas,
851
877
  headers
852
878
  }) {
853
- return (0, import_provider_utils4.combineHeaders)(
854
- await (0, import_provider_utils4.resolve)(this.config.headers),
855
- betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {},
856
- headers
857
- );
879
+ return (0, import_provider_utils4.combineHeaders)(await (0, import_provider_utils4.resolve)(this.config.headers), headers);
858
880
  }
859
881
  async doGenerate(options) {
860
882
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
861
883
  const {
862
884
  command: args,
863
885
  warnings,
864
- usesJsonResponseTool,
865
- betas
886
+ usesJsonResponseTool
866
887
  } = await this.getArgs(options);
867
888
  const url = `${this.getUrl(this.modelId)}/converse`;
868
889
  const { value: response, responseHeaders } = await (0, import_provider_utils4.postJsonToApi)({
869
890
  url,
870
- headers: await this.getHeaders({ betas, headers: options.headers }),
891
+ headers: await this.getHeaders({ headers: options.headers }),
871
892
  body: args,
872
893
  failedResponseHandler: (0, import_provider_utils4.createJsonErrorResponseHandler)({
873
894
  errorSchema: BedrockErrorSchema,
@@ -964,13 +985,12 @@ var BedrockChatLanguageModel = class {
964
985
  const {
965
986
  command: args,
966
987
  warnings,
967
- usesJsonResponseTool,
968
- betas
988
+ usesJsonResponseTool
969
989
  } = await this.getArgs(options);
970
990
  const url = `${this.getUrl(this.modelId)}/converse-stream`;
971
991
  const { value: response, responseHeaders } = await (0, import_provider_utils4.postJsonToApi)({
972
992
  url,
973
- headers: await this.getHeaders({ betas, headers: options.headers }),
993
+ headers: await this.getHeaders({ headers: options.headers }),
974
994
  body: args,
975
995
  failedResponseHandler: (0, import_provider_utils4.createJsonErrorResponseHandler)({
976
996
  errorSchema: BedrockErrorSchema,
@@ -1511,7 +1531,7 @@ var import_provider_utils7 = require("@ai-sdk/provider-utils");
1511
1531
  var import_aws4fetch = require("aws4fetch");
1512
1532
 
1513
1533
  // src/version.ts
1514
- var VERSION = true ? "4.0.0-beta.59" : "0.0.0-test";
1534
+ var VERSION = true ? "4.0.0-beta.61" : "0.0.0-test";
1515
1535
 
1516
1536
  // src/bedrock-sigv4-fetch.ts
1517
1537
  function createSigV4FetchFunction(getCredentials, fetch = globalThis.fetch) {