@ai-sdk/amazon-bedrock 3.0.54 → 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 +15 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +41 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +41 -20
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
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
|
+
|
|
12
|
+
## 3.0.55
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- cddda46: fix (provider/amazon-bedrock): deal gracefully with empty tool descriptions
|
|
17
|
+
|
|
3
18
|
## 3.0.54
|
|
4
19
|
|
|
5
20
|
### 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
|
|
@@ -187,6 +191,7 @@ async function prepareTools({
|
|
|
187
191
|
toolChoice,
|
|
188
192
|
modelId
|
|
189
193
|
}) {
|
|
194
|
+
var _a;
|
|
190
195
|
const toolWarnings = [];
|
|
191
196
|
const betas = /* @__PURE__ */ new Set();
|
|
192
197
|
if (tools == null || tools.length === 0) {
|
|
@@ -275,7 +280,7 @@ async function prepareTools({
|
|
|
275
280
|
bedrockTools.push({
|
|
276
281
|
toolSpec: {
|
|
277
282
|
name: tool.name,
|
|
278
|
-
description: tool.description,
|
|
283
|
+
...((_a = tool.description) == null ? void 0 : _a.trim()) !== "" ? { description: tool.description } : {},
|
|
279
284
|
inputSchema: {
|
|
280
285
|
json: tool.inputSchema
|
|
281
286
|
}
|
|
@@ -687,7 +692,7 @@ var BedrockChatLanguageModel = class {
|
|
|
687
692
|
toolChoice,
|
|
688
693
|
providerOptions
|
|
689
694
|
}) {
|
|
690
|
-
var _a, _b, _c, _d, _e, _f;
|
|
695
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
691
696
|
const bedrockOptions = (_a = await (0, import_provider_utils4.parseProviderOptions)({
|
|
692
697
|
provider: "bedrock",
|
|
693
698
|
providerOptions,
|
|
@@ -712,6 +717,21 @@ var BedrockChatLanguageModel = class {
|
|
|
712
717
|
setting: "seed"
|
|
713
718
|
});
|
|
714
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
|
+
}
|
|
715
735
|
if (responseFormat != null && responseFormat.type !== "text" && responseFormat.type !== "json") {
|
|
716
736
|
warnings.push({
|
|
717
737
|
type: "unsupported-setting",
|
|
@@ -745,8 +765,16 @@ var BedrockChatLanguageModel = class {
|
|
|
745
765
|
...additionalTools
|
|
746
766
|
};
|
|
747
767
|
}
|
|
748
|
-
|
|
749
|
-
|
|
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;
|
|
750
778
|
const inferenceConfig = {
|
|
751
779
|
...maxOutputTokens != null && { maxTokens: maxOutputTokens },
|
|
752
780
|
...temperature != null && { temperature },
|
|
@@ -763,7 +791,7 @@ var BedrockChatLanguageModel = class {
|
|
|
763
791
|
bedrockOptions.additionalModelRequestFields = {
|
|
764
792
|
...bedrockOptions.additionalModelRequestFields,
|
|
765
793
|
thinking: {
|
|
766
|
-
type: (
|
|
794
|
+
type: (_e = bedrockOptions.reasoningConfig) == null ? void 0 : _e.type,
|
|
767
795
|
budget_tokens: thinkingBudget
|
|
768
796
|
}
|
|
769
797
|
};
|
|
@@ -792,7 +820,7 @@ var BedrockChatLanguageModel = class {
|
|
|
792
820
|
details: "topK is not supported when thinking is enabled"
|
|
793
821
|
});
|
|
794
822
|
}
|
|
795
|
-
const hasAnyTools = ((
|
|
823
|
+
const hasAnyTools = ((_g = (_f = toolConfig.tools) == null ? void 0 : _f.length) != null ? _g : 0) > 0 || additionalTools;
|
|
796
824
|
let filteredPrompt = prompt;
|
|
797
825
|
if (!hasAnyTools) {
|
|
798
826
|
const hasToolContent = prompt.some(
|
|
@@ -841,27 +869,21 @@ var BedrockChatLanguageModel = class {
|
|
|
841
869
|
};
|
|
842
870
|
}
|
|
843
871
|
async getHeaders({
|
|
844
|
-
betas,
|
|
845
872
|
headers
|
|
846
873
|
}) {
|
|
847
|
-
return (0, import_provider_utils4.combineHeaders)(
|
|
848
|
-
await (0, import_provider_utils4.resolve)(this.config.headers),
|
|
849
|
-
betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {},
|
|
850
|
-
headers
|
|
851
|
-
);
|
|
874
|
+
return (0, import_provider_utils4.combineHeaders)(await (0, import_provider_utils4.resolve)(this.config.headers), headers);
|
|
852
875
|
}
|
|
853
876
|
async doGenerate(options) {
|
|
854
877
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
855
878
|
const {
|
|
856
879
|
command: args,
|
|
857
880
|
warnings,
|
|
858
|
-
usesJsonResponseTool
|
|
859
|
-
betas
|
|
881
|
+
usesJsonResponseTool
|
|
860
882
|
} = await this.getArgs(options);
|
|
861
883
|
const url = `${this.getUrl(this.modelId)}/converse`;
|
|
862
884
|
const { value: response, responseHeaders } = await (0, import_provider_utils4.postJsonToApi)({
|
|
863
885
|
url,
|
|
864
|
-
headers: await this.getHeaders({
|
|
886
|
+
headers: await this.getHeaders({ headers: options.headers }),
|
|
865
887
|
body: args,
|
|
866
888
|
failedResponseHandler: (0, import_provider_utils4.createJsonErrorResponseHandler)({
|
|
867
889
|
errorSchema: BedrockErrorSchema,
|
|
@@ -958,13 +980,12 @@ var BedrockChatLanguageModel = class {
|
|
|
958
980
|
const {
|
|
959
981
|
command: args,
|
|
960
982
|
warnings,
|
|
961
|
-
usesJsonResponseTool
|
|
962
|
-
betas
|
|
983
|
+
usesJsonResponseTool
|
|
963
984
|
} = await this.getArgs(options);
|
|
964
985
|
const url = `${this.getUrl(this.modelId)}/converse-stream`;
|
|
965
986
|
const { value: response, responseHeaders } = await (0, import_provider_utils4.postJsonToApi)({
|
|
966
987
|
url,
|
|
967
|
-
headers: await this.getHeaders({
|
|
988
|
+
headers: await this.getHeaders({ headers: options.headers }),
|
|
968
989
|
body: args,
|
|
969
990
|
failedResponseHandler: (0, import_provider_utils4.createJsonErrorResponseHandler)({
|
|
970
991
|
errorSchema: BedrockErrorSchema,
|