@ai-sdk/amazon-bedrock 4.0.0-beta.60 → 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 +6 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +24 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
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,
|
|
@@ -762,8 +766,16 @@ var BedrockChatLanguageModel = class {
|
|
|
762
766
|
...additionalTools
|
|
763
767
|
};
|
|
764
768
|
}
|
|
765
|
-
|
|
766
|
-
|
|
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;
|
|
767
779
|
const inferenceConfig = {
|
|
768
780
|
...maxOutputTokens != null && { maxTokens: maxOutputTokens },
|
|
769
781
|
...temperature != null && { temperature },
|
|
@@ -780,7 +792,7 @@ var BedrockChatLanguageModel = class {
|
|
|
780
792
|
bedrockOptions.additionalModelRequestFields = {
|
|
781
793
|
...bedrockOptions.additionalModelRequestFields,
|
|
782
794
|
thinking: {
|
|
783
|
-
type: (
|
|
795
|
+
type: (_e = bedrockOptions.reasoningConfig) == null ? void 0 : _e.type,
|
|
784
796
|
budget_tokens: thinkingBudget
|
|
785
797
|
}
|
|
786
798
|
};
|
|
@@ -809,7 +821,7 @@ var BedrockChatLanguageModel = class {
|
|
|
809
821
|
details: "topK is not supported when thinking is enabled"
|
|
810
822
|
});
|
|
811
823
|
}
|
|
812
|
-
const hasAnyTools = ((
|
|
824
|
+
const hasAnyTools = ((_g = (_f = toolConfig.tools) == null ? void 0 : _f.length) != null ? _g : 0) > 0 || additionalTools;
|
|
813
825
|
let filteredPrompt = prompt;
|
|
814
826
|
if (!hasAnyTools) {
|
|
815
827
|
const hasToolContent = prompt.some(
|
|
@@ -858,27 +870,21 @@ var BedrockChatLanguageModel = class {
|
|
|
858
870
|
};
|
|
859
871
|
}
|
|
860
872
|
async getHeaders({
|
|
861
|
-
betas,
|
|
862
873
|
headers
|
|
863
874
|
}) {
|
|
864
|
-
return combineHeaders(
|
|
865
|
-
await resolve(this.config.headers),
|
|
866
|
-
betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {},
|
|
867
|
-
headers
|
|
868
|
-
);
|
|
875
|
+
return combineHeaders(await resolve(this.config.headers), headers);
|
|
869
876
|
}
|
|
870
877
|
async doGenerate(options) {
|
|
871
878
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
872
879
|
const {
|
|
873
880
|
command: args,
|
|
874
881
|
warnings,
|
|
875
|
-
usesJsonResponseTool
|
|
876
|
-
betas
|
|
882
|
+
usesJsonResponseTool
|
|
877
883
|
} = await this.getArgs(options);
|
|
878
884
|
const url = `${this.getUrl(this.modelId)}/converse`;
|
|
879
885
|
const { value: response, responseHeaders } = await postJsonToApi({
|
|
880
886
|
url,
|
|
881
|
-
headers: await this.getHeaders({
|
|
887
|
+
headers: await this.getHeaders({ headers: options.headers }),
|
|
882
888
|
body: args,
|
|
883
889
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
884
890
|
errorSchema: BedrockErrorSchema,
|
|
@@ -975,13 +981,12 @@ var BedrockChatLanguageModel = class {
|
|
|
975
981
|
const {
|
|
976
982
|
command: args,
|
|
977
983
|
warnings,
|
|
978
|
-
usesJsonResponseTool
|
|
979
|
-
betas
|
|
984
|
+
usesJsonResponseTool
|
|
980
985
|
} = await this.getArgs(options);
|
|
981
986
|
const url = `${this.getUrl(this.modelId)}/converse-stream`;
|
|
982
987
|
const { value: response, responseHeaders } = await postJsonToApi({
|
|
983
988
|
url,
|
|
984
|
-
headers: await this.getHeaders({
|
|
989
|
+
headers: await this.getHeaders({ headers: options.headers }),
|
|
985
990
|
body: args,
|
|
986
991
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
987
992
|
errorSchema: BedrockErrorSchema,
|
|
@@ -1542,7 +1547,7 @@ import {
|
|
|
1542
1547
|
import { AwsV4Signer } from "aws4fetch";
|
|
1543
1548
|
|
|
1544
1549
|
// src/version.ts
|
|
1545
|
-
var VERSION = true ? "4.0.0-beta.
|
|
1550
|
+
var VERSION = true ? "4.0.0-beta.61" : "0.0.0-test";
|
|
1546
1551
|
|
|
1547
1552
|
// src/bedrock-sigv4-fetch.ts
|
|
1548
1553
|
function createSigV4FetchFunction(getCredentials, fetch = globalThis.fetch) {
|