@ai-sdk/amazon-bedrock 4.0.49 → 4.0.50
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 +6 -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 +60 -36
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +60 -36
- package/dist/index.mjs.map +1 -1
- package/docs/08-amazon-bedrock.mdx +2 -2
- package/package.json +1 -1
- package/src/anthropic/bedrock-anthropic-options.ts +2 -2
- package/src/bedrock-chat-language-model.ts +59 -35
- package/src/bedrock-chat-options.ts +8 -2
package/CHANGELOG.md
CHANGED
|
@@ -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.50" : "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.50" : "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, _i;
|
|
778
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
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,56 @@ 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
|
+
const existingBetas = (_h = (_g = bedrockOptions.additionalModelRequestFields) == null ? void 0 : _g.anthropic_beta) != null ? _h : [];
|
|
906
|
+
bedrockOptions.additionalModelRequestFields = {
|
|
907
|
+
...bedrockOptions.additionalModelRequestFields,
|
|
908
|
+
output_config: {
|
|
909
|
+
effort: maxReasoningEffort
|
|
910
|
+
}
|
|
911
|
+
};
|
|
912
|
+
} else if (isOpenAIModel) {
|
|
882
913
|
bedrockOptions.additionalModelRequestFields = {
|
|
883
914
|
...bedrockOptions.additionalModelRequestFields,
|
|
884
915
|
reasoning_effort: maxReasoningEffort
|
|
@@ -887,19 +918,12 @@ var BedrockChatLanguageModel = class {
|
|
|
887
918
|
bedrockOptions.additionalModelRequestFields = {
|
|
888
919
|
...bedrockOptions.additionalModelRequestFields,
|
|
889
920
|
reasoningConfig: {
|
|
890
|
-
...
|
|
891
|
-
|
|
892
|
-
},
|
|
921
|
+
...thinkingType != null && thinkingType !== "adaptive" && { type: thinkingType },
|
|
922
|
+
...thinkingBudget != null && { budgetTokens: thinkingBudget },
|
|
893
923
|
maxReasoningEffort
|
|
894
924
|
}
|
|
895
925
|
};
|
|
896
926
|
}
|
|
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
927
|
}
|
|
904
928
|
if (isAnthropicThinkingEnabled && inferenceConfig.temperature != null) {
|
|
905
929
|
delete inferenceConfig.temperature;
|
|
@@ -925,7 +949,7 @@ var BedrockChatLanguageModel = class {
|
|
|
925
949
|
details: "topK is not supported when thinking is enabled"
|
|
926
950
|
});
|
|
927
951
|
}
|
|
928
|
-
const hasAnyTools = ((
|
|
952
|
+
const hasAnyTools = ((_j = (_i = toolConfig.tools) == null ? void 0 : _i.length) != null ? _j : 0) > 0 || additionalTools;
|
|
929
953
|
let filteredPrompt = prompt;
|
|
930
954
|
if (!hasAnyTools) {
|
|
931
955
|
const hasToolContent = prompt.some(
|
|
@@ -1878,7 +1902,7 @@ var import_provider_utils7 = require("@ai-sdk/provider-utils");
|
|
|
1878
1902
|
var import_aws4fetch = require("aws4fetch");
|
|
1879
1903
|
|
|
1880
1904
|
// src/version.ts
|
|
1881
|
-
var VERSION = true ? "4.0.
|
|
1905
|
+
var VERSION = true ? "4.0.50" : "0.0.0-test";
|
|
1882
1906
|
|
|
1883
1907
|
// src/bedrock-sigv4-fetch.ts
|
|
1884
1908
|
function createSigV4FetchFunction(getCredentials, fetch = globalThis.fetch) {
|