@ai-sdk/amazon-bedrock 4.0.0-beta.79 → 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 +6 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +36 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +36 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -76,7 +76,8 @@ var bedrockProviderOptions = z.object({
|
|
|
76
76
|
additionalModelRequestFields: z.record(z.string(), z.any()).optional(),
|
|
77
77
|
reasoningConfig: z.object({
|
|
78
78
|
type: z.union([z.literal("enabled"), z.literal("disabled")]).optional(),
|
|
79
|
-
budgetTokens: z.number().optional()
|
|
79
|
+
budgetTokens: z.number().optional(),
|
|
80
|
+
maxReasoningEffort: z.enum(["low", "medium", "high"]).optional()
|
|
80
81
|
}).optional(),
|
|
81
82
|
/**
|
|
82
83
|
* Anthropic beta features to enable
|
|
@@ -692,7 +693,7 @@ var BedrockChatLanguageModel = class {
|
|
|
692
693
|
toolChoice,
|
|
693
694
|
providerOptions
|
|
694
695
|
}) {
|
|
695
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
696
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
696
697
|
const bedrockOptions = (_a = await parseProviderOptions2({
|
|
697
698
|
provider: "bedrock",
|
|
698
699
|
providerOptions,
|
|
@@ -765,8 +766,10 @@ var BedrockChatLanguageModel = class {
|
|
|
765
766
|
anthropic_beta: mergedBetas
|
|
766
767
|
};
|
|
767
768
|
}
|
|
768
|
-
const
|
|
769
|
+
const isAnthropicModel = this.modelId.includes("anthropic");
|
|
770
|
+
const isThinkingRequested = ((_c = bedrockOptions.reasoningConfig) == null ? void 0 : _c.type) === "enabled";
|
|
769
771
|
const thinkingBudget = (_d = bedrockOptions.reasoningConfig) == null ? void 0 : _d.budgetTokens;
|
|
772
|
+
const isAnthropicThinkingEnabled = isAnthropicModel && isThinkingRequested;
|
|
770
773
|
const inferenceConfig = {
|
|
771
774
|
...maxOutputTokens != null && { maxTokens: maxOutputTokens },
|
|
772
775
|
...temperature != null && { temperature },
|
|
@@ -774,7 +777,7 @@ var BedrockChatLanguageModel = class {
|
|
|
774
777
|
...topK != null && { topK },
|
|
775
778
|
...stopSequences != null && { stopSequences }
|
|
776
779
|
};
|
|
777
|
-
if (
|
|
780
|
+
if (isAnthropicThinkingEnabled && thinkingBudget != null) {
|
|
778
781
|
if (inferenceConfig.maxTokens != null) {
|
|
779
782
|
inferenceConfig.maxTokens += thinkingBudget;
|
|
780
783
|
} else {
|
|
@@ -787,8 +790,32 @@ var BedrockChatLanguageModel = class {
|
|
|
787
790
|
budget_tokens: thinkingBudget
|
|
788
791
|
}
|
|
789
792
|
};
|
|
793
|
+
} else if (!isAnthropicModel && thinkingBudget != null) {
|
|
794
|
+
warnings.push({
|
|
795
|
+
type: "unsupported",
|
|
796
|
+
feature: "budgetTokens",
|
|
797
|
+
details: "budgetTokens applies only to Anthropic models on Bedrock and will be ignored for this model."
|
|
798
|
+
});
|
|
799
|
+
}
|
|
800
|
+
const maxReasoningEffort = (_f = bedrockOptions.reasoningConfig) == null ? void 0 : _f.maxReasoningEffort;
|
|
801
|
+
if (maxReasoningEffort != null && !isAnthropicModel) {
|
|
802
|
+
bedrockOptions.additionalModelRequestFields = {
|
|
803
|
+
...bedrockOptions.additionalModelRequestFields,
|
|
804
|
+
reasoningConfig: {
|
|
805
|
+
...((_g = bedrockOptions.reasoningConfig) == null ? void 0 : _g.type) != null && {
|
|
806
|
+
type: bedrockOptions.reasoningConfig.type
|
|
807
|
+
},
|
|
808
|
+
maxReasoningEffort
|
|
809
|
+
}
|
|
810
|
+
};
|
|
811
|
+
} else if (maxReasoningEffort != null && isAnthropicModel) {
|
|
812
|
+
warnings.push({
|
|
813
|
+
type: "unsupported",
|
|
814
|
+
feature: "maxReasoningEffort",
|
|
815
|
+
details: "maxReasoningEffort applies only to Amazon Nova models on Bedrock and will be ignored for this model."
|
|
816
|
+
});
|
|
790
817
|
}
|
|
791
|
-
if (
|
|
818
|
+
if (isAnthropicThinkingEnabled && inferenceConfig.temperature != null) {
|
|
792
819
|
delete inferenceConfig.temperature;
|
|
793
820
|
warnings.push({
|
|
794
821
|
type: "unsupported",
|
|
@@ -796,7 +823,7 @@ var BedrockChatLanguageModel = class {
|
|
|
796
823
|
details: "temperature is not supported when thinking is enabled"
|
|
797
824
|
});
|
|
798
825
|
}
|
|
799
|
-
if (
|
|
826
|
+
if (isAnthropicThinkingEnabled && inferenceConfig.topP != null) {
|
|
800
827
|
delete inferenceConfig.topP;
|
|
801
828
|
warnings.push({
|
|
802
829
|
type: "unsupported",
|
|
@@ -804,7 +831,7 @@ var BedrockChatLanguageModel = class {
|
|
|
804
831
|
details: "topP is not supported when thinking is enabled"
|
|
805
832
|
});
|
|
806
833
|
}
|
|
807
|
-
if (
|
|
834
|
+
if (isAnthropicThinkingEnabled && inferenceConfig.topK != null) {
|
|
808
835
|
delete inferenceConfig.topK;
|
|
809
836
|
warnings.push({
|
|
810
837
|
type: "unsupported",
|
|
@@ -812,7 +839,7 @@ var BedrockChatLanguageModel = class {
|
|
|
812
839
|
details: "topK is not supported when thinking is enabled"
|
|
813
840
|
});
|
|
814
841
|
}
|
|
815
|
-
const hasAnyTools = ((
|
|
842
|
+
const hasAnyTools = ((_i = (_h = toolConfig.tools) == null ? void 0 : _h.length) != null ? _i : 0) > 0 || additionalTools;
|
|
816
843
|
let filteredPrompt = prompt;
|
|
817
844
|
if (!hasAnyTools) {
|
|
818
845
|
const hasToolContent = prompt.some(
|
|
@@ -1551,7 +1578,7 @@ import {
|
|
|
1551
1578
|
import { AwsV4Signer } from "aws4fetch";
|
|
1552
1579
|
|
|
1553
1580
|
// src/version.ts
|
|
1554
|
-
var VERSION = true ? "4.0.0-beta.
|
|
1581
|
+
var VERSION = true ? "4.0.0-beta.80" : "0.0.0-test";
|
|
1555
1582
|
|
|
1556
1583
|
// src/bedrock-sigv4-fetch.ts
|
|
1557
1584
|
function createSigV4FetchFunction(getCredentials, fetch = globalThis.fetch) {
|