@ai-sdk/amazon-bedrock 4.0.0-beta.59 → 4.0.0-beta.61
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 +14 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +39 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.mjs
CHANGED
|
@@ -77,7 +77,11 @@ var bedrockProviderOptions = z.object({
|
|
|
77
77
|
reasoningConfig: z.object({
|
|
78
78
|
type: z.union([z.literal("enabled"), z.literal("disabled")]).optional(),
|
|
79
79
|
budgetTokens: z.number().optional()
|
|
80
|
-
}).optional()
|
|
80
|
+
}).optional(),
|
|
81
|
+
/**
|
|
82
|
+
* Anthropic beta features to enable
|
|
83
|
+
*/
|
|
84
|
+
anthropicBeta: z.array(z.string()).optional()
|
|
81
85
|
});
|
|
82
86
|
|
|
83
87
|
// src/bedrock-error.ts
|
|
@@ -689,7 +693,7 @@ var BedrockChatLanguageModel = class {
|
|
|
689
693
|
toolChoice,
|
|
690
694
|
providerOptions
|
|
691
695
|
}) {
|
|
692
|
-
var _a, _b, _c, _d, _e, _f;
|
|
696
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
693
697
|
const bedrockOptions = (_a = await parseProviderOptions2({
|
|
694
698
|
provider: "bedrock",
|
|
695
699
|
providerOptions,
|
|
@@ -714,6 +718,21 @@ var BedrockChatLanguageModel = class {
|
|
|
714
718
|
setting: "seed"
|
|
715
719
|
});
|
|
716
720
|
}
|
|
721
|
+
if (temperature != null && temperature > 1) {
|
|
722
|
+
warnings.push({
|
|
723
|
+
type: "unsupported-setting",
|
|
724
|
+
setting: "temperature",
|
|
725
|
+
details: `${temperature} exceeds bedrock maximum of 1.0. clamped to 1.0`
|
|
726
|
+
});
|
|
727
|
+
temperature = 1;
|
|
728
|
+
} else if (temperature != null && temperature < 0) {
|
|
729
|
+
warnings.push({
|
|
730
|
+
type: "unsupported-setting",
|
|
731
|
+
setting: "temperature",
|
|
732
|
+
details: `${temperature} is below bedrock minimum of 0. clamped to 0`
|
|
733
|
+
});
|
|
734
|
+
temperature = 0;
|
|
735
|
+
}
|
|
717
736
|
if (responseFormat != null && responseFormat.type !== "text" && responseFormat.type !== "json") {
|
|
718
737
|
warnings.push({
|
|
719
738
|
type: "unsupported-setting",
|
|
@@ -747,8 +766,16 @@ var BedrockChatLanguageModel = class {
|
|
|
747
766
|
...additionalTools
|
|
748
767
|
};
|
|
749
768
|
}
|
|
750
|
-
|
|
751
|
-
|
|
769
|
+
if (betas.size > 0 || bedrockOptions.anthropicBeta) {
|
|
770
|
+
const existingBetas = (_b = bedrockOptions.anthropicBeta) != null ? _b : [];
|
|
771
|
+
const mergedBetas = betas.size > 0 ? [...existingBetas, ...Array.from(betas)] : existingBetas;
|
|
772
|
+
bedrockOptions.additionalModelRequestFields = {
|
|
773
|
+
...bedrockOptions.additionalModelRequestFields,
|
|
774
|
+
anthropic_beta: mergedBetas
|
|
775
|
+
};
|
|
776
|
+
}
|
|
777
|
+
const isThinking = ((_c = bedrockOptions.reasoningConfig) == null ? void 0 : _c.type) === "enabled";
|
|
778
|
+
const thinkingBudget = (_d = bedrockOptions.reasoningConfig) == null ? void 0 : _d.budgetTokens;
|
|
752
779
|
const inferenceConfig = {
|
|
753
780
|
...maxOutputTokens != null && { maxTokens: maxOutputTokens },
|
|
754
781
|
...temperature != null && { temperature },
|
|
@@ -765,7 +792,7 @@ var BedrockChatLanguageModel = class {
|
|
|
765
792
|
bedrockOptions.additionalModelRequestFields = {
|
|
766
793
|
...bedrockOptions.additionalModelRequestFields,
|
|
767
794
|
thinking: {
|
|
768
|
-
type: (
|
|
795
|
+
type: (_e = bedrockOptions.reasoningConfig) == null ? void 0 : _e.type,
|
|
769
796
|
budget_tokens: thinkingBudget
|
|
770
797
|
}
|
|
771
798
|
};
|
|
@@ -794,7 +821,7 @@ var BedrockChatLanguageModel = class {
|
|
|
794
821
|
details: "topK is not supported when thinking is enabled"
|
|
795
822
|
});
|
|
796
823
|
}
|
|
797
|
-
const hasAnyTools = ((
|
|
824
|
+
const hasAnyTools = ((_g = (_f = toolConfig.tools) == null ? void 0 : _f.length) != null ? _g : 0) > 0 || additionalTools;
|
|
798
825
|
let filteredPrompt = prompt;
|
|
799
826
|
if (!hasAnyTools) {
|
|
800
827
|
const hasToolContent = prompt.some(
|
|
@@ -843,27 +870,21 @@ var BedrockChatLanguageModel = class {
|
|
|
843
870
|
};
|
|
844
871
|
}
|
|
845
872
|
async getHeaders({
|
|
846
|
-
betas,
|
|
847
873
|
headers
|
|
848
874
|
}) {
|
|
849
|
-
return combineHeaders(
|
|
850
|
-
await resolve(this.config.headers),
|
|
851
|
-
betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {},
|
|
852
|
-
headers
|
|
853
|
-
);
|
|
875
|
+
return combineHeaders(await resolve(this.config.headers), headers);
|
|
854
876
|
}
|
|
855
877
|
async doGenerate(options) {
|
|
856
878
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
857
879
|
const {
|
|
858
880
|
command: args,
|
|
859
881
|
warnings,
|
|
860
|
-
usesJsonResponseTool
|
|
861
|
-
betas
|
|
882
|
+
usesJsonResponseTool
|
|
862
883
|
} = await this.getArgs(options);
|
|
863
884
|
const url = `${this.getUrl(this.modelId)}/converse`;
|
|
864
885
|
const { value: response, responseHeaders } = await postJsonToApi({
|
|
865
886
|
url,
|
|
866
|
-
headers: await this.getHeaders({
|
|
887
|
+
headers: await this.getHeaders({ headers: options.headers }),
|
|
867
888
|
body: args,
|
|
868
889
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
869
890
|
errorSchema: BedrockErrorSchema,
|
|
@@ -960,13 +981,12 @@ var BedrockChatLanguageModel = class {
|
|
|
960
981
|
const {
|
|
961
982
|
command: args,
|
|
962
983
|
warnings,
|
|
963
|
-
usesJsonResponseTool
|
|
964
|
-
betas
|
|
984
|
+
usesJsonResponseTool
|
|
965
985
|
} = await this.getArgs(options);
|
|
966
986
|
const url = `${this.getUrl(this.modelId)}/converse-stream`;
|
|
967
987
|
const { value: response, responseHeaders } = await postJsonToApi({
|
|
968
988
|
url,
|
|
969
|
-
headers: await this.getHeaders({
|
|
989
|
+
headers: await this.getHeaders({ headers: options.headers }),
|
|
970
990
|
body: args,
|
|
971
991
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
972
992
|
errorSchema: BedrockErrorSchema,
|
|
@@ -1527,7 +1547,7 @@ import {
|
|
|
1527
1547
|
import { AwsV4Signer } from "aws4fetch";
|
|
1528
1548
|
|
|
1529
1549
|
// src/version.ts
|
|
1530
|
-
var VERSION = true ? "4.0.0-beta.
|
|
1550
|
+
var VERSION = true ? "4.0.0-beta.61" : "0.0.0-test";
|
|
1531
1551
|
|
|
1532
1552
|
// src/bedrock-sigv4-fetch.ts
|
|
1533
1553
|
function createSigV4FetchFunction(getCredentials, fetch = globalThis.fetch) {
|