@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/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -11,6 +11,7 @@ declare const bedrockProviderOptions: z.ZodObject<{
|
|
|
11
11
|
type: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"enabled">, z.ZodLiteral<"disabled">]>>;
|
|
12
12
|
budgetTokens: z.ZodOptional<z.ZodNumber>;
|
|
13
13
|
}, z.core.$strip>>;
|
|
14
|
+
anthropicBeta: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
14
15
|
}, z.core.$strip>;
|
|
15
16
|
type BedrockProviderOptions = z.infer<typeof bedrockProviderOptions>;
|
|
16
17
|
|
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ declare const bedrockProviderOptions: z.ZodObject<{
|
|
|
11
11
|
type: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"enabled">, z.ZodLiteral<"disabled">]>>;
|
|
12
12
|
budgetTokens: z.ZodOptional<z.ZodNumber>;
|
|
13
13
|
}, z.core.$strip>>;
|
|
14
|
+
anthropicBeta: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
14
15
|
}, z.core.$strip>;
|
|
15
16
|
type BedrockProviderOptions = z.infer<typeof bedrockProviderOptions>;
|
|
16
17
|
|
package/dist/index.js
CHANGED
|
@@ -92,7 +92,11 @@ var bedrockProviderOptions = import_v4.z.object({
|
|
|
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
94
|
budgetTokens: import_v4.z.number().optional()
|
|
95
|
-
}).optional()
|
|
95
|
+
}).optional(),
|
|
96
|
+
/**
|
|
97
|
+
* Anthropic beta features to enable
|
|
98
|
+
*/
|
|
99
|
+
anthropicBeta: import_v4.z.array(import_v4.z.string()).optional()
|
|
96
100
|
});
|
|
97
101
|
|
|
98
102
|
// src/bedrock-error.ts
|
|
@@ -693,7 +697,7 @@ var BedrockChatLanguageModel = class {
|
|
|
693
697
|
toolChoice,
|
|
694
698
|
providerOptions
|
|
695
699
|
}) {
|
|
696
|
-
var _a, _b, _c, _d, _e, _f;
|
|
700
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
697
701
|
const bedrockOptions = (_a = await (0, import_provider_utils4.parseProviderOptions)({
|
|
698
702
|
provider: "bedrock",
|
|
699
703
|
providerOptions,
|
|
@@ -766,8 +770,16 @@ var BedrockChatLanguageModel = class {
|
|
|
766
770
|
...additionalTools
|
|
767
771
|
};
|
|
768
772
|
}
|
|
769
|
-
|
|
770
|
-
|
|
773
|
+
if (betas.size > 0 || bedrockOptions.anthropicBeta) {
|
|
774
|
+
const existingBetas = (_b = bedrockOptions.anthropicBeta) != null ? _b : [];
|
|
775
|
+
const mergedBetas = betas.size > 0 ? [...existingBetas, ...Array.from(betas)] : existingBetas;
|
|
776
|
+
bedrockOptions.additionalModelRequestFields = {
|
|
777
|
+
...bedrockOptions.additionalModelRequestFields,
|
|
778
|
+
anthropic_beta: mergedBetas
|
|
779
|
+
};
|
|
780
|
+
}
|
|
781
|
+
const isThinking = ((_c = bedrockOptions.reasoningConfig) == null ? void 0 : _c.type) === "enabled";
|
|
782
|
+
const thinkingBudget = (_d = bedrockOptions.reasoningConfig) == null ? void 0 : _d.budgetTokens;
|
|
771
783
|
const inferenceConfig = {
|
|
772
784
|
...maxOutputTokens != null && { maxTokens: maxOutputTokens },
|
|
773
785
|
...temperature != null && { temperature },
|
|
@@ -784,7 +796,7 @@ var BedrockChatLanguageModel = class {
|
|
|
784
796
|
bedrockOptions.additionalModelRequestFields = {
|
|
785
797
|
...bedrockOptions.additionalModelRequestFields,
|
|
786
798
|
thinking: {
|
|
787
|
-
type: (
|
|
799
|
+
type: (_e = bedrockOptions.reasoningConfig) == null ? void 0 : _e.type,
|
|
788
800
|
budget_tokens: thinkingBudget
|
|
789
801
|
}
|
|
790
802
|
};
|
|
@@ -813,7 +825,7 @@ var BedrockChatLanguageModel = class {
|
|
|
813
825
|
details: "topK is not supported when thinking is enabled"
|
|
814
826
|
});
|
|
815
827
|
}
|
|
816
|
-
const hasAnyTools = ((
|
|
828
|
+
const hasAnyTools = ((_g = (_f = toolConfig.tools) == null ? void 0 : _f.length) != null ? _g : 0) > 0 || additionalTools;
|
|
817
829
|
let filteredPrompt = prompt;
|
|
818
830
|
if (!hasAnyTools) {
|
|
819
831
|
const hasToolContent = prompt.some(
|
|
@@ -862,27 +874,21 @@ var BedrockChatLanguageModel = class {
|
|
|
862
874
|
};
|
|
863
875
|
}
|
|
864
876
|
async getHeaders({
|
|
865
|
-
betas,
|
|
866
877
|
headers
|
|
867
878
|
}) {
|
|
868
|
-
return (0, import_provider_utils4.combineHeaders)(
|
|
869
|
-
await (0, import_provider_utils4.resolve)(this.config.headers),
|
|
870
|
-
betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {},
|
|
871
|
-
headers
|
|
872
|
-
);
|
|
879
|
+
return (0, import_provider_utils4.combineHeaders)(await (0, import_provider_utils4.resolve)(this.config.headers), headers);
|
|
873
880
|
}
|
|
874
881
|
async doGenerate(options) {
|
|
875
882
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
876
883
|
const {
|
|
877
884
|
command: args,
|
|
878
885
|
warnings,
|
|
879
|
-
usesJsonResponseTool
|
|
880
|
-
betas
|
|
886
|
+
usesJsonResponseTool
|
|
881
887
|
} = await this.getArgs(options);
|
|
882
888
|
const url = `${this.getUrl(this.modelId)}/converse`;
|
|
883
889
|
const { value: response, responseHeaders } = await (0, import_provider_utils4.postJsonToApi)({
|
|
884
890
|
url,
|
|
885
|
-
headers: await this.getHeaders({
|
|
891
|
+
headers: await this.getHeaders({ headers: options.headers }),
|
|
886
892
|
body: args,
|
|
887
893
|
failedResponseHandler: (0, import_provider_utils4.createJsonErrorResponseHandler)({
|
|
888
894
|
errorSchema: BedrockErrorSchema,
|
|
@@ -979,13 +985,12 @@ var BedrockChatLanguageModel = class {
|
|
|
979
985
|
const {
|
|
980
986
|
command: args,
|
|
981
987
|
warnings,
|
|
982
|
-
usesJsonResponseTool
|
|
983
|
-
betas
|
|
988
|
+
usesJsonResponseTool
|
|
984
989
|
} = await this.getArgs(options);
|
|
985
990
|
const url = `${this.getUrl(this.modelId)}/converse-stream`;
|
|
986
991
|
const { value: response, responseHeaders } = await (0, import_provider_utils4.postJsonToApi)({
|
|
987
992
|
url,
|
|
988
|
-
headers: await this.getHeaders({
|
|
993
|
+
headers: await this.getHeaders({ headers: options.headers }),
|
|
989
994
|
body: args,
|
|
990
995
|
failedResponseHandler: (0, import_provider_utils4.createJsonErrorResponseHandler)({
|
|
991
996
|
errorSchema: BedrockErrorSchema,
|
|
@@ -1526,7 +1531,7 @@ var import_provider_utils7 = require("@ai-sdk/provider-utils");
|
|
|
1526
1531
|
var import_aws4fetch = require("aws4fetch");
|
|
1527
1532
|
|
|
1528
1533
|
// src/version.ts
|
|
1529
|
-
var VERSION = true ? "4.0.0-beta.
|
|
1534
|
+
var VERSION = true ? "4.0.0-beta.61" : "0.0.0-test";
|
|
1530
1535
|
|
|
1531
1536
|
// src/bedrock-sigv4-fetch.ts
|
|
1532
1537
|
function createSigV4FetchFunction(getCredentials, fetch = globalThis.fetch) {
|