@ai-sdk/amazon-bedrock 4.0.0-beta.78 → 4.0.0-beta.80
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 +16 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +38 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @ai-sdk/amazon-bedrock
|
|
2
2
|
|
|
3
|
+
## 4.0.0-beta.80
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f65d7df: feat(provider/bedrock): Support Nova 2 extended reasoning `maxReasoningEffort` field
|
|
8
|
+
|
|
9
|
+
## 4.0.0-beta.79
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 1bd7d32: feat: tool-specific strict mode
|
|
14
|
+
- Updated dependencies [1bd7d32]
|
|
15
|
+
- @ai-sdk/provider-utils@4.0.0-beta.41
|
|
16
|
+
- @ai-sdk/anthropic@3.0.0-beta.71
|
|
17
|
+
- @ai-sdk/provider@3.0.0-beta.23
|
|
18
|
+
|
|
3
19
|
## 4.0.0-beta.78
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -10,6 +10,11 @@ declare const bedrockProviderOptions: z.ZodObject<{
|
|
|
10
10
|
reasoningConfig: z.ZodOptional<z.ZodObject<{
|
|
11
11
|
type: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"enabled">, z.ZodLiteral<"disabled">]>>;
|
|
12
12
|
budgetTokens: z.ZodOptional<z.ZodNumber>;
|
|
13
|
+
maxReasoningEffort: z.ZodOptional<z.ZodEnum<{
|
|
14
|
+
low: "low";
|
|
15
|
+
medium: "medium";
|
|
16
|
+
high: "high";
|
|
17
|
+
}>>;
|
|
13
18
|
}, z.core.$strip>>;
|
|
14
19
|
anthropicBeta: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
15
20
|
}, z.core.$strip>;
|
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,11 @@ declare const bedrockProviderOptions: z.ZodObject<{
|
|
|
10
10
|
reasoningConfig: z.ZodOptional<z.ZodObject<{
|
|
11
11
|
type: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"enabled">, z.ZodLiteral<"disabled">]>>;
|
|
12
12
|
budgetTokens: z.ZodOptional<z.ZodNumber>;
|
|
13
|
+
maxReasoningEffort: z.ZodOptional<z.ZodEnum<{
|
|
14
|
+
low: "low";
|
|
15
|
+
medium: "medium";
|
|
16
|
+
high: "high";
|
|
17
|
+
}>>;
|
|
13
18
|
}, z.core.$strip>>;
|
|
14
19
|
anthropicBeta: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
15
20
|
}, z.core.$strip>;
|
package/dist/index.js
CHANGED
|
@@ -91,7 +91,8 @@ var bedrockProviderOptions = import_v4.z.object({
|
|
|
91
91
|
additionalModelRequestFields: import_v4.z.record(import_v4.z.string(), import_v4.z.any()).optional(),
|
|
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
|
-
budgetTokens: import_v4.z.number().optional()
|
|
94
|
+
budgetTokens: import_v4.z.number().optional(),
|
|
95
|
+
maxReasoningEffort: import_v4.z.enum(["low", "medium", "high"]).optional()
|
|
95
96
|
}).optional(),
|
|
96
97
|
/**
|
|
97
98
|
* Anthropic beta features to enable
|
|
@@ -236,7 +237,8 @@ async function prepareTools({
|
|
|
236
237
|
betas: anthropicBetas
|
|
237
238
|
} = await (0, import_internal.prepareTools)({
|
|
238
239
|
tools: ProviderTools,
|
|
239
|
-
toolChoice
|
|
240
|
+
toolChoice,
|
|
241
|
+
supportsStructuredOutput: false
|
|
240
242
|
});
|
|
241
243
|
toolWarnings.push(...anthropicToolWarnings);
|
|
242
244
|
anthropicBetas.forEach((beta) => betas.add(beta));
|
|
@@ -695,7 +697,7 @@ var BedrockChatLanguageModel = class {
|
|
|
695
697
|
toolChoice,
|
|
696
698
|
providerOptions
|
|
697
699
|
}) {
|
|
698
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
700
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
699
701
|
const bedrockOptions = (_a = await (0, import_provider_utils4.parseProviderOptions)({
|
|
700
702
|
provider: "bedrock",
|
|
701
703
|
providerOptions,
|
|
@@ -768,8 +770,10 @@ var BedrockChatLanguageModel = class {
|
|
|
768
770
|
anthropic_beta: mergedBetas
|
|
769
771
|
};
|
|
770
772
|
}
|
|
771
|
-
const
|
|
773
|
+
const isAnthropicModel = this.modelId.includes("anthropic");
|
|
774
|
+
const isThinkingRequested = ((_c = bedrockOptions.reasoningConfig) == null ? void 0 : _c.type) === "enabled";
|
|
772
775
|
const thinkingBudget = (_d = bedrockOptions.reasoningConfig) == null ? void 0 : _d.budgetTokens;
|
|
776
|
+
const isAnthropicThinkingEnabled = isAnthropicModel && isThinkingRequested;
|
|
773
777
|
const inferenceConfig = {
|
|
774
778
|
...maxOutputTokens != null && { maxTokens: maxOutputTokens },
|
|
775
779
|
...temperature != null && { temperature },
|
|
@@ -777,7 +781,7 @@ var BedrockChatLanguageModel = class {
|
|
|
777
781
|
...topK != null && { topK },
|
|
778
782
|
...stopSequences != null && { stopSequences }
|
|
779
783
|
};
|
|
780
|
-
if (
|
|
784
|
+
if (isAnthropicThinkingEnabled && thinkingBudget != null) {
|
|
781
785
|
if (inferenceConfig.maxTokens != null) {
|
|
782
786
|
inferenceConfig.maxTokens += thinkingBudget;
|
|
783
787
|
} else {
|
|
@@ -790,8 +794,32 @@ var BedrockChatLanguageModel = class {
|
|
|
790
794
|
budget_tokens: thinkingBudget
|
|
791
795
|
}
|
|
792
796
|
};
|
|
797
|
+
} else if (!isAnthropicModel && thinkingBudget != null) {
|
|
798
|
+
warnings.push({
|
|
799
|
+
type: "unsupported",
|
|
800
|
+
feature: "budgetTokens",
|
|
801
|
+
details: "budgetTokens applies only to Anthropic models on Bedrock and will be ignored for this model."
|
|
802
|
+
});
|
|
803
|
+
}
|
|
804
|
+
const maxReasoningEffort = (_f = bedrockOptions.reasoningConfig) == null ? void 0 : _f.maxReasoningEffort;
|
|
805
|
+
if (maxReasoningEffort != null && !isAnthropicModel) {
|
|
806
|
+
bedrockOptions.additionalModelRequestFields = {
|
|
807
|
+
...bedrockOptions.additionalModelRequestFields,
|
|
808
|
+
reasoningConfig: {
|
|
809
|
+
...((_g = bedrockOptions.reasoningConfig) == null ? void 0 : _g.type) != null && {
|
|
810
|
+
type: bedrockOptions.reasoningConfig.type
|
|
811
|
+
},
|
|
812
|
+
maxReasoningEffort
|
|
813
|
+
}
|
|
814
|
+
};
|
|
815
|
+
} else if (maxReasoningEffort != null && isAnthropicModel) {
|
|
816
|
+
warnings.push({
|
|
817
|
+
type: "unsupported",
|
|
818
|
+
feature: "maxReasoningEffort",
|
|
819
|
+
details: "maxReasoningEffort applies only to Amazon Nova models on Bedrock and will be ignored for this model."
|
|
820
|
+
});
|
|
793
821
|
}
|
|
794
|
-
if (
|
|
822
|
+
if (isAnthropicThinkingEnabled && inferenceConfig.temperature != null) {
|
|
795
823
|
delete inferenceConfig.temperature;
|
|
796
824
|
warnings.push({
|
|
797
825
|
type: "unsupported",
|
|
@@ -799,7 +827,7 @@ var BedrockChatLanguageModel = class {
|
|
|
799
827
|
details: "temperature is not supported when thinking is enabled"
|
|
800
828
|
});
|
|
801
829
|
}
|
|
802
|
-
if (
|
|
830
|
+
if (isAnthropicThinkingEnabled && inferenceConfig.topP != null) {
|
|
803
831
|
delete inferenceConfig.topP;
|
|
804
832
|
warnings.push({
|
|
805
833
|
type: "unsupported",
|
|
@@ -807,7 +835,7 @@ var BedrockChatLanguageModel = class {
|
|
|
807
835
|
details: "topP is not supported when thinking is enabled"
|
|
808
836
|
});
|
|
809
837
|
}
|
|
810
|
-
if (
|
|
838
|
+
if (isAnthropicThinkingEnabled && inferenceConfig.topK != null) {
|
|
811
839
|
delete inferenceConfig.topK;
|
|
812
840
|
warnings.push({
|
|
813
841
|
type: "unsupported",
|
|
@@ -815,7 +843,7 @@ var BedrockChatLanguageModel = class {
|
|
|
815
843
|
details: "topK is not supported when thinking is enabled"
|
|
816
844
|
});
|
|
817
845
|
}
|
|
818
|
-
const hasAnyTools = ((
|
|
846
|
+
const hasAnyTools = ((_i = (_h = toolConfig.tools) == null ? void 0 : _h.length) != null ? _i : 0) > 0 || additionalTools;
|
|
819
847
|
let filteredPrompt = prompt;
|
|
820
848
|
if (!hasAnyTools) {
|
|
821
849
|
const hasToolContent = prompt.some(
|
|
@@ -1534,7 +1562,7 @@ var import_provider_utils7 = require("@ai-sdk/provider-utils");
|
|
|
1534
1562
|
var import_aws4fetch = require("aws4fetch");
|
|
1535
1563
|
|
|
1536
1564
|
// src/version.ts
|
|
1537
|
-
var VERSION = true ? "4.0.0-beta.
|
|
1565
|
+
var VERSION = true ? "4.0.0-beta.80" : "0.0.0-test";
|
|
1538
1566
|
|
|
1539
1567
|
// src/bedrock-sigv4-fetch.ts
|
|
1540
1568
|
function createSigV4FetchFunction(getCredentials, fetch = globalThis.fetch) {
|