@ai-sdk/amazon-bedrock 3.0.55 → 3.0.56
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 +9 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +39 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @ai-sdk/amazon-bedrock
|
|
2
2
|
|
|
3
|
+
## 3.0.56
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f1f5804: fix(amazon-bedrock): clamp temperature to valid 0-1 range with warnings
|
|
8
|
+
- 9cb8436: fix(amazon-bedrock): move anthropic_beta to request body
|
|
9
|
+
- Updated dependencies [54b7c08]
|
|
10
|
+
- @ai-sdk/anthropic@2.0.45
|
|
11
|
+
|
|
3
12
|
## 3.0.55
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -10,6 +10,7 @@ declare const bedrockProviderOptions: z.ZodObject<{
|
|
|
10
10
|
type: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"enabled">, z.ZodLiteral<"disabled">]>>;
|
|
11
11
|
budgetTokens: z.ZodOptional<z.ZodNumber>;
|
|
12
12
|
}, z.core.$strip>>;
|
|
13
|
+
anthropicBeta: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
13
14
|
}, z.core.$strip>;
|
|
14
15
|
type BedrockProviderOptions = z.infer<typeof bedrockProviderOptions>;
|
|
15
16
|
|
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ declare const bedrockProviderOptions: z.ZodObject<{
|
|
|
10
10
|
type: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"enabled">, z.ZodLiteral<"disabled">]>>;
|
|
11
11
|
budgetTokens: z.ZodOptional<z.ZodNumber>;
|
|
12
12
|
}, z.core.$strip>>;
|
|
13
|
+
anthropicBeta: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
13
14
|
}, z.core.$strip>;
|
|
14
15
|
type BedrockProviderOptions = z.infer<typeof bedrockProviderOptions>;
|
|
15
16
|
|
package/dist/index.js
CHANGED
|
@@ -30,7 +30,7 @@ module.exports = __toCommonJS(src_exports);
|
|
|
30
30
|
var import_provider_utils8 = require("@ai-sdk/provider-utils");
|
|
31
31
|
|
|
32
32
|
// src/version.ts
|
|
33
|
-
var VERSION = true ? "3.0.
|
|
33
|
+
var VERSION = true ? "3.0.56" : "0.0.0-test";
|
|
34
34
|
|
|
35
35
|
// src/bedrock-provider.ts
|
|
36
36
|
var import_internal2 = require("@ai-sdk/anthropic/internal");
|
|
@@ -97,7 +97,11 @@ var bedrockProviderOptions = import_v4.z.object({
|
|
|
97
97
|
reasoningConfig: import_v4.z.object({
|
|
98
98
|
type: import_v4.z.union([import_v4.z.literal("enabled"), import_v4.z.literal("disabled")]).optional(),
|
|
99
99
|
budgetTokens: import_v4.z.number().optional()
|
|
100
|
-
}).optional()
|
|
100
|
+
}).optional(),
|
|
101
|
+
/**
|
|
102
|
+
* Anthropic beta features to enable
|
|
103
|
+
*/
|
|
104
|
+
anthropicBeta: import_v4.z.array(import_v4.z.string()).optional()
|
|
101
105
|
});
|
|
102
106
|
|
|
103
107
|
// src/bedrock-error.ts
|
|
@@ -688,7 +692,7 @@ var BedrockChatLanguageModel = class {
|
|
|
688
692
|
toolChoice,
|
|
689
693
|
providerOptions
|
|
690
694
|
}) {
|
|
691
|
-
var _a, _b, _c, _d, _e, _f;
|
|
695
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
692
696
|
const bedrockOptions = (_a = await (0, import_provider_utils4.parseProviderOptions)({
|
|
693
697
|
provider: "bedrock",
|
|
694
698
|
providerOptions,
|
|
@@ -713,6 +717,21 @@ var BedrockChatLanguageModel = class {
|
|
|
713
717
|
setting: "seed"
|
|
714
718
|
});
|
|
715
719
|
}
|
|
720
|
+
if (temperature != null && temperature > 1) {
|
|
721
|
+
warnings.push({
|
|
722
|
+
type: "unsupported-setting",
|
|
723
|
+
setting: "temperature",
|
|
724
|
+
details: `${temperature} exceeds bedrock maximum of 1.0. clamped to 1.0`
|
|
725
|
+
});
|
|
726
|
+
temperature = 1;
|
|
727
|
+
} else if (temperature != null && temperature < 0) {
|
|
728
|
+
warnings.push({
|
|
729
|
+
type: "unsupported-setting",
|
|
730
|
+
setting: "temperature",
|
|
731
|
+
details: `${temperature} is below bedrock minimum of 0. clamped to 0`
|
|
732
|
+
});
|
|
733
|
+
temperature = 0;
|
|
734
|
+
}
|
|
716
735
|
if (responseFormat != null && responseFormat.type !== "text" && responseFormat.type !== "json") {
|
|
717
736
|
warnings.push({
|
|
718
737
|
type: "unsupported-setting",
|
|
@@ -746,8 +765,16 @@ var BedrockChatLanguageModel = class {
|
|
|
746
765
|
...additionalTools
|
|
747
766
|
};
|
|
748
767
|
}
|
|
749
|
-
|
|
750
|
-
|
|
768
|
+
if (betas.size > 0 || bedrockOptions.anthropicBeta) {
|
|
769
|
+
const existingBetas = (_b = bedrockOptions.anthropicBeta) != null ? _b : [];
|
|
770
|
+
const mergedBetas = betas.size > 0 ? [...existingBetas, ...Array.from(betas)] : existingBetas;
|
|
771
|
+
bedrockOptions.additionalModelRequestFields = {
|
|
772
|
+
...bedrockOptions.additionalModelRequestFields,
|
|
773
|
+
anthropic_beta: mergedBetas
|
|
774
|
+
};
|
|
775
|
+
}
|
|
776
|
+
const isThinking = ((_c = bedrockOptions.reasoningConfig) == null ? void 0 : _c.type) === "enabled";
|
|
777
|
+
const thinkingBudget = (_d = bedrockOptions.reasoningConfig) == null ? void 0 : _d.budgetTokens;
|
|
751
778
|
const inferenceConfig = {
|
|
752
779
|
...maxOutputTokens != null && { maxTokens: maxOutputTokens },
|
|
753
780
|
...temperature != null && { temperature },
|
|
@@ -764,7 +791,7 @@ var BedrockChatLanguageModel = class {
|
|
|
764
791
|
bedrockOptions.additionalModelRequestFields = {
|
|
765
792
|
...bedrockOptions.additionalModelRequestFields,
|
|
766
793
|
thinking: {
|
|
767
|
-
type: (
|
|
794
|
+
type: (_e = bedrockOptions.reasoningConfig) == null ? void 0 : _e.type,
|
|
768
795
|
budget_tokens: thinkingBudget
|
|
769
796
|
}
|
|
770
797
|
};
|
|
@@ -793,7 +820,7 @@ var BedrockChatLanguageModel = class {
|
|
|
793
820
|
details: "topK is not supported when thinking is enabled"
|
|
794
821
|
});
|
|
795
822
|
}
|
|
796
|
-
const hasAnyTools = ((
|
|
823
|
+
const hasAnyTools = ((_g = (_f = toolConfig.tools) == null ? void 0 : _f.length) != null ? _g : 0) > 0 || additionalTools;
|
|
797
824
|
let filteredPrompt = prompt;
|
|
798
825
|
if (!hasAnyTools) {
|
|
799
826
|
const hasToolContent = prompt.some(
|
|
@@ -842,27 +869,21 @@ var BedrockChatLanguageModel = class {
|
|
|
842
869
|
};
|
|
843
870
|
}
|
|
844
871
|
async getHeaders({
|
|
845
|
-
betas,
|
|
846
872
|
headers
|
|
847
873
|
}) {
|
|
848
|
-
return (0, import_provider_utils4.combineHeaders)(
|
|
849
|
-
await (0, import_provider_utils4.resolve)(this.config.headers),
|
|
850
|
-
betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {},
|
|
851
|
-
headers
|
|
852
|
-
);
|
|
874
|
+
return (0, import_provider_utils4.combineHeaders)(await (0, import_provider_utils4.resolve)(this.config.headers), headers);
|
|
853
875
|
}
|
|
854
876
|
async doGenerate(options) {
|
|
855
877
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
856
878
|
const {
|
|
857
879
|
command: args,
|
|
858
880
|
warnings,
|
|
859
|
-
usesJsonResponseTool
|
|
860
|
-
betas
|
|
881
|
+
usesJsonResponseTool
|
|
861
882
|
} = await this.getArgs(options);
|
|
862
883
|
const url = `${this.getUrl(this.modelId)}/converse`;
|
|
863
884
|
const { value: response, responseHeaders } = await (0, import_provider_utils4.postJsonToApi)({
|
|
864
885
|
url,
|
|
865
|
-
headers: await this.getHeaders({
|
|
886
|
+
headers: await this.getHeaders({ headers: options.headers }),
|
|
866
887
|
body: args,
|
|
867
888
|
failedResponseHandler: (0, import_provider_utils4.createJsonErrorResponseHandler)({
|
|
868
889
|
errorSchema: BedrockErrorSchema,
|
|
@@ -959,13 +980,12 @@ var BedrockChatLanguageModel = class {
|
|
|
959
980
|
const {
|
|
960
981
|
command: args,
|
|
961
982
|
warnings,
|
|
962
|
-
usesJsonResponseTool
|
|
963
|
-
betas
|
|
983
|
+
usesJsonResponseTool
|
|
964
984
|
} = await this.getArgs(options);
|
|
965
985
|
const url = `${this.getUrl(this.modelId)}/converse-stream`;
|
|
966
986
|
const { value: response, responseHeaders } = await (0, import_provider_utils4.postJsonToApi)({
|
|
967
987
|
url,
|
|
968
|
-
headers: await this.getHeaders({
|
|
988
|
+
headers: await this.getHeaders({ headers: options.headers }),
|
|
969
989
|
body: args,
|
|
970
990
|
failedResponseHandler: (0, import_provider_utils4.createJsonErrorResponseHandler)({
|
|
971
991
|
errorSchema: BedrockErrorSchema,
|