@ai-sdk/amazon-bedrock 4.0.49 → 4.0.51
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/anthropic/index.d.mts +1 -1
- package/dist/anthropic/index.d.ts +1 -1
- package/dist/anthropic/index.js +1 -1
- package/dist/anthropic/index.mjs +1 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +59 -36
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +59 -36
- package/dist/index.mjs.map +1 -1
- package/docs/08-amazon-bedrock.mdx +2 -2
- package/package.json +4 -4
- package/src/anthropic/bedrock-anthropic-options.ts +2 -2
- package/src/bedrock-chat-language-model.ts +56 -35
- package/src/bedrock-chat-options.ts +8 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @ai-sdk/amazon-bedrock
|
|
2
2
|
|
|
3
|
+
## 4.0.51
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [7168375]
|
|
8
|
+
- @ai-sdk/provider@3.0.8
|
|
9
|
+
- @ai-sdk/anthropic@3.0.38
|
|
10
|
+
- @ai-sdk/provider-utils@4.0.14
|
|
11
|
+
|
|
12
|
+
## 4.0.50
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- 632ab10: feat(amazon-bedrock): add support for new Anthropic adaptive thinking and reasoning effort including max
|
|
17
|
+
|
|
3
18
|
## 4.0.49
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -9,7 +9,7 @@ interface BedrockCredentials {
|
|
|
9
9
|
sessionToken?: string;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
type BedrockAnthropicModelId = 'anthropic.claude-opus-4-6-v1
|
|
12
|
+
type BedrockAnthropicModelId = 'anthropic.claude-opus-4-6-v1' | 'anthropic.claude-opus-4-5-20251101-v1:0' | 'anthropic.claude-sonnet-4-5-20250929-v1:0' | 'anthropic.claude-opus-4-20250514-v1:0' | 'anthropic.claude-sonnet-4-20250514-v1:0' | 'anthropic.claude-opus-4-1-20250805-v1:0' | 'anthropic.claude-haiku-4-5-20251001-v1:0' | 'anthropic.claude-3-7-sonnet-20250219-v1:0' | 'anthropic.claude-3-5-sonnet-20241022-v2:0' | 'anthropic.claude-3-5-sonnet-20240620-v1:0' | 'anthropic.claude-3-5-haiku-20241022-v1:0' | 'anthropic.claude-3-opus-20240229-v1:0' | 'anthropic.claude-3-sonnet-20240229-v1:0' | 'anthropic.claude-3-haiku-20240307-v1:0' | 'us.anthropic.claude-opus-4-6-v1' | 'us.anthropic.claude-opus-4-5-20251101-v1:0' | 'us.anthropic.claude-sonnet-4-5-20250929-v1:0' | 'us.anthropic.claude-opus-4-20250514-v1:0' | 'us.anthropic.claude-sonnet-4-20250514-v1:0' | 'us.anthropic.claude-opus-4-1-20250805-v1:0' | 'us.anthropic.claude-haiku-4-5-20251001-v1:0' | 'us.anthropic.claude-3-7-sonnet-20250219-v1:0' | 'us.anthropic.claude-3-5-sonnet-20241022-v2:0' | 'us.anthropic.claude-3-5-sonnet-20240620-v1:0' | 'us.anthropic.claude-3-5-haiku-20241022-v1:0' | 'us.anthropic.claude-3-opus-20240229-v1:0' | 'us.anthropic.claude-3-sonnet-20240229-v1:0' | 'us.anthropic.claude-3-haiku-20240307-v1:0' | (string & {});
|
|
13
13
|
|
|
14
14
|
interface BedrockAnthropicProvider extends ProviderV3 {
|
|
15
15
|
/**
|
|
@@ -9,7 +9,7 @@ interface BedrockCredentials {
|
|
|
9
9
|
sessionToken?: string;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
type BedrockAnthropicModelId = 'anthropic.claude-opus-4-6-v1
|
|
12
|
+
type BedrockAnthropicModelId = 'anthropic.claude-opus-4-6-v1' | 'anthropic.claude-opus-4-5-20251101-v1:0' | 'anthropic.claude-sonnet-4-5-20250929-v1:0' | 'anthropic.claude-opus-4-20250514-v1:0' | 'anthropic.claude-sonnet-4-20250514-v1:0' | 'anthropic.claude-opus-4-1-20250805-v1:0' | 'anthropic.claude-haiku-4-5-20251001-v1:0' | 'anthropic.claude-3-7-sonnet-20250219-v1:0' | 'anthropic.claude-3-5-sonnet-20241022-v2:0' | 'anthropic.claude-3-5-sonnet-20240620-v1:0' | 'anthropic.claude-3-5-haiku-20241022-v1:0' | 'anthropic.claude-3-opus-20240229-v1:0' | 'anthropic.claude-3-sonnet-20240229-v1:0' | 'anthropic.claude-3-haiku-20240307-v1:0' | 'us.anthropic.claude-opus-4-6-v1' | 'us.anthropic.claude-opus-4-5-20251101-v1:0' | 'us.anthropic.claude-sonnet-4-5-20250929-v1:0' | 'us.anthropic.claude-opus-4-20250514-v1:0' | 'us.anthropic.claude-sonnet-4-20250514-v1:0' | 'us.anthropic.claude-opus-4-1-20250805-v1:0' | 'us.anthropic.claude-haiku-4-5-20251001-v1:0' | 'us.anthropic.claude-3-7-sonnet-20250219-v1:0' | 'us.anthropic.claude-3-5-sonnet-20241022-v2:0' | 'us.anthropic.claude-3-5-sonnet-20240620-v1:0' | 'us.anthropic.claude-3-5-haiku-20241022-v1:0' | 'us.anthropic.claude-3-opus-20240229-v1:0' | 'us.anthropic.claude-3-sonnet-20240229-v1:0' | 'us.anthropic.claude-3-haiku-20240307-v1:0' | (string & {});
|
|
13
13
|
|
|
14
14
|
interface BedrockAnthropicProvider extends ProviderV3 {
|
|
15
15
|
/**
|
package/dist/anthropic/index.js
CHANGED
|
@@ -35,7 +35,7 @@ var import_provider_utils = require("@ai-sdk/provider-utils");
|
|
|
35
35
|
var import_aws4fetch = require("aws4fetch");
|
|
36
36
|
|
|
37
37
|
// src/version.ts
|
|
38
|
-
var VERSION = true ? "4.0.
|
|
38
|
+
var VERSION = true ? "4.0.51" : "0.0.0-test";
|
|
39
39
|
|
|
40
40
|
// src/bedrock-sigv4-fetch.ts
|
|
41
41
|
function createSigV4FetchFunction(getCredentials, fetch = globalThis.fetch) {
|
package/dist/anthropic/index.mjs
CHANGED
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
import { AwsV4Signer } from "aws4fetch";
|
|
25
25
|
|
|
26
26
|
// src/version.ts
|
|
27
|
-
var VERSION = true ? "4.0.
|
|
27
|
+
var VERSION = true ? "4.0.51" : "0.0.0-test";
|
|
28
28
|
|
|
29
29
|
// src/bedrock-sigv4-fetch.ts
|
|
30
30
|
function createSigV4FetchFunction(getCredentials, fetch = globalThis.fetch) {
|
package/dist/index.d.mts
CHANGED
|
@@ -8,12 +8,13 @@ type BedrockChatModelId = 'amazon.titan-tg1-large' | 'amazon.titan-text-express-
|
|
|
8
8
|
declare const bedrockProviderOptions: z.ZodObject<{
|
|
9
9
|
additionalModelRequestFields: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
10
10
|
reasoningConfig: z.ZodOptional<z.ZodObject<{
|
|
11
|
-
type: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"enabled">, z.ZodLiteral<"disabled">]>>;
|
|
11
|
+
type: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"enabled">, z.ZodLiteral<"disabled">, z.ZodLiteral<"adaptive">]>>;
|
|
12
12
|
budgetTokens: z.ZodOptional<z.ZodNumber>;
|
|
13
13
|
maxReasoningEffort: z.ZodOptional<z.ZodEnum<{
|
|
14
14
|
low: "low";
|
|
15
15
|
medium: "medium";
|
|
16
16
|
high: "high";
|
|
17
|
+
max: "max";
|
|
17
18
|
}>>;
|
|
18
19
|
}, z.core.$strip>>;
|
|
19
20
|
anthropicBeta: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
package/dist/index.d.ts
CHANGED
|
@@ -8,12 +8,13 @@ type BedrockChatModelId = 'amazon.titan-tg1-large' | 'amazon.titan-text-express-
|
|
|
8
8
|
declare const bedrockProviderOptions: z.ZodObject<{
|
|
9
9
|
additionalModelRequestFields: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
10
10
|
reasoningConfig: z.ZodOptional<z.ZodObject<{
|
|
11
|
-
type: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"enabled">, z.ZodLiteral<"disabled">]>>;
|
|
11
|
+
type: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"enabled">, z.ZodLiteral<"disabled">, z.ZodLiteral<"adaptive">]>>;
|
|
12
12
|
budgetTokens: z.ZodOptional<z.ZodNumber>;
|
|
13
13
|
maxReasoningEffort: z.ZodOptional<z.ZodEnum<{
|
|
14
14
|
low: "low";
|
|
15
15
|
medium: "medium";
|
|
16
16
|
high: "high";
|
|
17
|
+
max: "max";
|
|
17
18
|
}>>;
|
|
18
19
|
}, z.core.$strip>>;
|
|
19
20
|
anthropicBeta: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
package/dist/index.js
CHANGED
|
@@ -87,9 +87,13 @@ var bedrockProviderOptions = import_v4.z.object({
|
|
|
87
87
|
*/
|
|
88
88
|
additionalModelRequestFields: import_v4.z.record(import_v4.z.string(), import_v4.z.any()).optional(),
|
|
89
89
|
reasoningConfig: import_v4.z.object({
|
|
90
|
-
type: import_v4.z.union([
|
|
90
|
+
type: import_v4.z.union([
|
|
91
|
+
import_v4.z.literal("enabled"),
|
|
92
|
+
import_v4.z.literal("disabled"),
|
|
93
|
+
import_v4.z.literal("adaptive")
|
|
94
|
+
]).optional(),
|
|
91
95
|
budgetTokens: import_v4.z.number().optional(),
|
|
92
|
-
maxReasoningEffort: import_v4.z.enum(["low", "medium", "high"]).optional()
|
|
96
|
+
maxReasoningEffort: import_v4.z.enum(["low", "medium", "high", "max"]).optional()
|
|
93
97
|
}).optional(),
|
|
94
98
|
/**
|
|
95
99
|
* Anthropic beta features to enable
|
|
@@ -771,7 +775,7 @@ var BedrockChatLanguageModel = class {
|
|
|
771
775
|
toolChoice,
|
|
772
776
|
providerOptions
|
|
773
777
|
}) {
|
|
774
|
-
var _a, _b, _c, _d, _e, _f, _g, _h
|
|
778
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
775
779
|
const bedrockOptions = (_a = await (0, import_provider_utils4.parseProviderOptions)({
|
|
776
780
|
provider: "bedrock",
|
|
777
781
|
providerOptions,
|
|
@@ -845,8 +849,9 @@ var BedrockChatLanguageModel = class {
|
|
|
845
849
|
};
|
|
846
850
|
}
|
|
847
851
|
const isAnthropicModel = this.modelId.includes("anthropic");
|
|
848
|
-
const
|
|
849
|
-
const
|
|
852
|
+
const thinkingType = (_c = bedrockOptions.reasoningConfig) == null ? void 0 : _c.type;
|
|
853
|
+
const isThinkingRequested = thinkingType === "enabled" || thinkingType === "adaptive";
|
|
854
|
+
const thinkingBudget = thinkingType === "enabled" ? (_d = bedrockOptions.reasoningConfig) == null ? void 0 : _d.budgetTokens : void 0;
|
|
850
855
|
const isAnthropicThinkingEnabled = isAnthropicModel && isThinkingRequested;
|
|
851
856
|
const inferenceConfig = {
|
|
852
857
|
...maxOutputTokens != null && { maxTokens: maxOutputTokens },
|
|
@@ -855,30 +860,55 @@ var BedrockChatLanguageModel = class {
|
|
|
855
860
|
...topK != null && { topK },
|
|
856
861
|
...stopSequences != null && { stopSequences }
|
|
857
862
|
};
|
|
858
|
-
if (isAnthropicThinkingEnabled
|
|
859
|
-
if (
|
|
860
|
-
inferenceConfig.maxTokens
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
bedrockOptions.additionalModelRequestFields = {
|
|
865
|
-
...bedrockOptions.additionalModelRequestFields,
|
|
866
|
-
thinking: {
|
|
867
|
-
type: (_e = bedrockOptions.reasoningConfig) == null ? void 0 : _e.type,
|
|
868
|
-
budget_tokens: thinkingBudget
|
|
863
|
+
if (isAnthropicThinkingEnabled) {
|
|
864
|
+
if (thinkingBudget != null) {
|
|
865
|
+
if (inferenceConfig.maxTokens != null) {
|
|
866
|
+
inferenceConfig.maxTokens += thinkingBudget;
|
|
867
|
+
} else {
|
|
868
|
+
inferenceConfig.maxTokens = thinkingBudget + 4096;
|
|
869
869
|
}
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
870
|
+
bedrockOptions.additionalModelRequestFields = {
|
|
871
|
+
...bedrockOptions.additionalModelRequestFields,
|
|
872
|
+
thinking: {
|
|
873
|
+
type: "enabled",
|
|
874
|
+
budget_tokens: thinkingBudget
|
|
875
|
+
}
|
|
876
|
+
};
|
|
877
|
+
} else if (thinkingType === "adaptive") {
|
|
878
|
+
bedrockOptions.additionalModelRequestFields = {
|
|
879
|
+
...bedrockOptions.additionalModelRequestFields,
|
|
880
|
+
thinking: {
|
|
881
|
+
type: "adaptive"
|
|
882
|
+
}
|
|
883
|
+
};
|
|
884
|
+
}
|
|
885
|
+
} else if (!isAnthropicModel) {
|
|
886
|
+
if (((_e = bedrockOptions.reasoningConfig) == null ? void 0 : _e.budgetTokens) != null) {
|
|
887
|
+
warnings.push({
|
|
888
|
+
type: "unsupported",
|
|
889
|
+
feature: "budgetTokens",
|
|
890
|
+
details: "budgetTokens applies only to Anthropic models on Bedrock and will be ignored for this model."
|
|
891
|
+
});
|
|
892
|
+
}
|
|
893
|
+
if (thinkingType === "adaptive") {
|
|
894
|
+
warnings.push({
|
|
895
|
+
type: "unsupported",
|
|
896
|
+
feature: "adaptive thinking",
|
|
897
|
+
details: "adaptive thinking type applies only to Anthropic models on Bedrock."
|
|
898
|
+
});
|
|
899
|
+
}
|
|
877
900
|
}
|
|
878
901
|
const maxReasoningEffort = (_f = bedrockOptions.reasoningConfig) == null ? void 0 : _f.maxReasoningEffort;
|
|
879
902
|
const isOpenAIModel = this.modelId.startsWith("openai.");
|
|
880
|
-
if (maxReasoningEffort != null
|
|
881
|
-
if (
|
|
903
|
+
if (maxReasoningEffort != null) {
|
|
904
|
+
if (isAnthropicModel) {
|
|
905
|
+
bedrockOptions.additionalModelRequestFields = {
|
|
906
|
+
...bedrockOptions.additionalModelRequestFields,
|
|
907
|
+
output_config: {
|
|
908
|
+
effort: maxReasoningEffort
|
|
909
|
+
}
|
|
910
|
+
};
|
|
911
|
+
} else if (isOpenAIModel) {
|
|
882
912
|
bedrockOptions.additionalModelRequestFields = {
|
|
883
913
|
...bedrockOptions.additionalModelRequestFields,
|
|
884
914
|
reasoning_effort: maxReasoningEffort
|
|
@@ -887,19 +917,12 @@ var BedrockChatLanguageModel = class {
|
|
|
887
917
|
bedrockOptions.additionalModelRequestFields = {
|
|
888
918
|
...bedrockOptions.additionalModelRequestFields,
|
|
889
919
|
reasoningConfig: {
|
|
890
|
-
...
|
|
891
|
-
|
|
892
|
-
},
|
|
920
|
+
...thinkingType != null && thinkingType !== "adaptive" && { type: thinkingType },
|
|
921
|
+
...thinkingBudget != null && { budgetTokens: thinkingBudget },
|
|
893
922
|
maxReasoningEffort
|
|
894
923
|
}
|
|
895
924
|
};
|
|
896
925
|
}
|
|
897
|
-
} else if (maxReasoningEffort != null && isAnthropicModel) {
|
|
898
|
-
warnings.push({
|
|
899
|
-
type: "unsupported",
|
|
900
|
-
feature: "maxReasoningEffort",
|
|
901
|
-
details: "maxReasoningEffort applies only to Amazon Nova models on Bedrock and will be ignored for this model."
|
|
902
|
-
});
|
|
903
926
|
}
|
|
904
927
|
if (isAnthropicThinkingEnabled && inferenceConfig.temperature != null) {
|
|
905
928
|
delete inferenceConfig.temperature;
|
|
@@ -925,7 +948,7 @@ var BedrockChatLanguageModel = class {
|
|
|
925
948
|
details: "topK is not supported when thinking is enabled"
|
|
926
949
|
});
|
|
927
950
|
}
|
|
928
|
-
const hasAnyTools = ((
|
|
951
|
+
const hasAnyTools = ((_h = (_g = toolConfig.tools) == null ? void 0 : _g.length) != null ? _h : 0) > 0 || additionalTools;
|
|
929
952
|
let filteredPrompt = prompt;
|
|
930
953
|
if (!hasAnyTools) {
|
|
931
954
|
const hasToolContent = prompt.some(
|
|
@@ -1878,7 +1901,7 @@ var import_provider_utils7 = require("@ai-sdk/provider-utils");
|
|
|
1878
1901
|
var import_aws4fetch = require("aws4fetch");
|
|
1879
1902
|
|
|
1880
1903
|
// src/version.ts
|
|
1881
|
-
var VERSION = true ? "4.0.
|
|
1904
|
+
var VERSION = true ? "4.0.51" : "0.0.0-test";
|
|
1882
1905
|
|
|
1883
1906
|
// src/bedrock-sigv4-fetch.ts
|
|
1884
1907
|
function createSigV4FetchFunction(getCredentials, fetch = globalThis.fetch) {
|