@ai-sdk/amazon-bedrock 3.0.120 → 3.0.124
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 +30 -0
- package/dist/anthropic/index.js +1 -1
- package/dist/anthropic/index.mjs +1 -1
- package/dist/index.js +78 -34
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +78 -34
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# @ai-sdk/amazon-bedrock
|
|
2
2
|
|
|
3
|
+
## 3.0.124
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 7a7a971: Forward the Anthropic option for disabling parallel tool use through Amazon Bedrock without sending conflicting tool choice fields.
|
|
8
|
+
|
|
9
|
+
## 3.0.123
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 1f9e026: Omit assistant messages that become empty after unsupported reasoning content is removed.
|
|
14
|
+
- Updated dependencies [77d33c0]
|
|
15
|
+
- @ai-sdk/provider-utils@3.0.35
|
|
16
|
+
- @ai-sdk/anthropic@2.0.98
|
|
17
|
+
|
|
18
|
+
## 3.0.122
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- 5f3c624: Send nested reasoning effort for CRIS-prefixed OpenAI GPT-5.x Converse requests while preserving the flat gpt-oss format.
|
|
23
|
+
|
|
24
|
+
## 3.0.121
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- Updated dependencies [2fff9f1]
|
|
29
|
+
- Updated dependencies [f364ea0]
|
|
30
|
+
- @ai-sdk/provider-utils@3.0.34
|
|
31
|
+
- @ai-sdk/anthropic@2.0.97
|
|
32
|
+
|
|
3
33
|
## 3.0.120
|
|
4
34
|
|
|
5
35
|
### Patch Changes
|
package/dist/anthropic/index.js
CHANGED
|
@@ -35,7 +35,7 @@ var import_provider_utils = require("@ai-sdk/provider-utils");
|
|
|
35
35
|
var import_aws4fetch = require("aws4fetch");
|
|
36
36
|
|
|
37
37
|
// src/version.ts
|
|
38
|
-
var VERSION = true ? "3.0.
|
|
38
|
+
var VERSION = true ? "3.0.124" : "0.0.0-test";
|
|
39
39
|
|
|
40
40
|
// src/bedrock-sigv4-fetch.ts
|
|
41
41
|
function createSigV4FetchFunction(getCredentials, fetch = globalThis.fetch) {
|
package/dist/anthropic/index.mjs
CHANGED
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
import { AwsV4Signer } from "aws4fetch";
|
|
25
25
|
|
|
26
26
|
// src/version.ts
|
|
27
|
-
var VERSION = true ? "3.0.
|
|
27
|
+
var VERSION = true ? "3.0.124" : "0.0.0-test";
|
|
28
28
|
|
|
29
29
|
// src/bedrock-sigv4-fetch.ts
|
|
30
30
|
function createSigV4FetchFunction(getCredentials, fetch = globalThis.fetch) {
|
package/dist/index.js
CHANGED
|
@@ -30,7 +30,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
30
30
|
var import_provider_utils8 = require("@ai-sdk/provider-utils");
|
|
31
31
|
|
|
32
32
|
// src/version.ts
|
|
33
|
-
var VERSION = true ? "3.0.
|
|
33
|
+
var VERSION = true ? "3.0.124" : "0.0.0-test";
|
|
34
34
|
|
|
35
35
|
// src/bedrock-provider.ts
|
|
36
36
|
var import_internal3 = require("@ai-sdk/anthropic/internal");
|
|
@@ -229,7 +229,8 @@ var import_internal = require("@ai-sdk/anthropic/internal");
|
|
|
229
229
|
async function prepareTools({
|
|
230
230
|
tools,
|
|
231
231
|
toolChoice,
|
|
232
|
-
modelId
|
|
232
|
+
modelId,
|
|
233
|
+
disableParallelToolUse
|
|
233
234
|
}) {
|
|
234
235
|
var _a;
|
|
235
236
|
const toolWarnings = [];
|
|
@@ -283,7 +284,8 @@ async function prepareTools({
|
|
|
283
284
|
betas: anthropicBetas
|
|
284
285
|
} = await (0, import_internal.prepareTools)({
|
|
285
286
|
tools: providerDefinedTools,
|
|
286
|
-
toolChoice
|
|
287
|
+
toolChoice,
|
|
288
|
+
disableParallelToolUse
|
|
287
289
|
});
|
|
288
290
|
toolWarnings.push(...anthropicToolWarnings);
|
|
289
291
|
anthropicBetas.forEach((beta) => betas.add(beta));
|
|
@@ -327,8 +329,17 @@ async function prepareTools({
|
|
|
327
329
|
}
|
|
328
330
|
});
|
|
329
331
|
}
|
|
332
|
+
if (isAnthropicModel && !usingAnthropicTools && disableParallelToolUse && bedrockTools.length > 0 && (toolChoice == null ? void 0 : toolChoice.type) !== "none") {
|
|
333
|
+
additionalTools = {
|
|
334
|
+
tool_choice: (toolChoice == null ? void 0 : toolChoice.type) === "required" ? { type: "any", disable_parallel_tool_use: true } : (toolChoice == null ? void 0 : toolChoice.type) === "tool" ? {
|
|
335
|
+
type: "tool",
|
|
336
|
+
name: toolChoice.toolName,
|
|
337
|
+
disable_parallel_tool_use: true
|
|
338
|
+
} : { type: "auto", disable_parallel_tool_use: true }
|
|
339
|
+
};
|
|
340
|
+
}
|
|
330
341
|
let bedrockToolChoice = void 0;
|
|
331
|
-
if (!usingAnthropicTools && bedrockTools.length > 0 && toolChoice) {
|
|
342
|
+
if (!usingAnthropicTools && (additionalTools == null ? void 0 : additionalTools.tool_choice) == null && bedrockTools.length > 0 && toolChoice) {
|
|
332
343
|
const type = toolChoice.type;
|
|
333
344
|
switch (type) {
|
|
334
345
|
case "auto":
|
|
@@ -543,7 +554,12 @@ async function convertToBedrockChatMessages(prompt) {
|
|
|
543
554
|
bedrockContent.push(BEDROCK_CACHE_POINT);
|
|
544
555
|
}
|
|
545
556
|
}
|
|
546
|
-
messages.
|
|
557
|
+
const previousMessage = messages.at(-1);
|
|
558
|
+
if ((previousMessage == null ? void 0 : previousMessage.role) === "user") {
|
|
559
|
+
previousMessage.content.push(...bedrockContent);
|
|
560
|
+
} else {
|
|
561
|
+
messages.push({ role: "user", content: bedrockContent });
|
|
562
|
+
}
|
|
547
563
|
break;
|
|
548
564
|
}
|
|
549
565
|
case "assistant": {
|
|
@@ -633,7 +649,9 @@ async function convertToBedrockChatMessages(prompt) {
|
|
|
633
649
|
bedrockContent.push(BEDROCK_CACHE_POINT);
|
|
634
650
|
}
|
|
635
651
|
}
|
|
636
|
-
|
|
652
|
+
if (bedrockContent.length > 0) {
|
|
653
|
+
messages.push({ role: "assistant", content: bedrockContent });
|
|
654
|
+
}
|
|
637
655
|
break;
|
|
638
656
|
}
|
|
639
657
|
default: {
|
|
@@ -742,6 +760,9 @@ function mapBedrockFinishReason(finishReason, isJsonResponseFromTool) {
|
|
|
742
760
|
}
|
|
743
761
|
|
|
744
762
|
// src/bedrock-chat-language-model.ts
|
|
763
|
+
var anthropicProviderOptions = import_v44.z.object({
|
|
764
|
+
disableParallelToolUse: import_v44.z.boolean().optional()
|
|
765
|
+
});
|
|
745
766
|
var BedrockChatLanguageModel = class {
|
|
746
767
|
constructor(modelId, config) {
|
|
747
768
|
this.modelId = modelId;
|
|
@@ -767,12 +788,17 @@ var BedrockChatLanguageModel = class {
|
|
|
767
788
|
toolChoice,
|
|
768
789
|
providerOptions
|
|
769
790
|
}) {
|
|
770
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
791
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
771
792
|
const bedrockOptions = (_a = await (0, import_provider_utils4.parseProviderOptions)({
|
|
772
793
|
provider: "bedrock",
|
|
773
794
|
providerOptions,
|
|
774
795
|
schema: bedrockProviderOptions
|
|
775
796
|
})) != null ? _a : {};
|
|
797
|
+
const anthropicOptions = await (0, import_provider_utils4.parseProviderOptions)({
|
|
798
|
+
provider: "anthropic",
|
|
799
|
+
providerOptions,
|
|
800
|
+
schema: anthropicProviderOptions
|
|
801
|
+
});
|
|
776
802
|
const warnings = [];
|
|
777
803
|
if (frequencyPenalty != null) {
|
|
778
804
|
warnings.push({
|
|
@@ -815,7 +841,10 @@ var BedrockChatLanguageModel = class {
|
|
|
815
841
|
});
|
|
816
842
|
}
|
|
817
843
|
const isAnthropicModel = this.modelId.includes("anthropic");
|
|
818
|
-
const
|
|
844
|
+
const openAIModelId = (_b = /^(?:[^.]+\.)?(openai\..+)$/.exec(this.modelId)) == null ? void 0 : _b[1];
|
|
845
|
+
const isOpenAIModel = openAIModelId != null;
|
|
846
|
+
const isOpenAIGptOssModel = (_c = openAIModelId == null ? void 0 : openAIModelId.startsWith("openai.gpt-oss-")) != null ? _c : false;
|
|
847
|
+
const isThinkingRequested = ((_d = bedrockOptions.reasoningConfig) == null ? void 0 : _d.type) === "enabled" || ((_e = bedrockOptions.reasoningConfig) == null ? void 0 : _e.type) === "adaptive";
|
|
819
848
|
const useNativeStructuredOutput = isAnthropicModel && supportsNativeStructuredOutput(this.modelId) && isThinkingRequested && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null;
|
|
820
849
|
const jsonResponseTool = (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && !useNativeStructuredOutput ? {
|
|
821
850
|
type: "function",
|
|
@@ -826,7 +855,8 @@ var BedrockChatLanguageModel = class {
|
|
|
826
855
|
const { toolConfig, additionalTools, toolWarnings, betas } = await prepareTools({
|
|
827
856
|
tools: jsonResponseTool ? [...tools != null ? tools : [], jsonResponseTool] : tools,
|
|
828
857
|
toolChoice: jsonResponseTool != null ? { type: "required" } : toolChoice,
|
|
829
|
-
modelId: this.modelId
|
|
858
|
+
modelId: this.modelId,
|
|
859
|
+
disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse
|
|
830
860
|
});
|
|
831
861
|
warnings.push(...toolWarnings);
|
|
832
862
|
if (additionalTools) {
|
|
@@ -836,16 +866,16 @@ var BedrockChatLanguageModel = class {
|
|
|
836
866
|
};
|
|
837
867
|
}
|
|
838
868
|
if (betas.size > 0 || bedrockOptions.anthropicBeta) {
|
|
839
|
-
const existingBetas = (
|
|
869
|
+
const existingBetas = (_f = bedrockOptions.anthropicBeta) != null ? _f : [];
|
|
840
870
|
const mergedBetas = betas.size > 0 ? [...existingBetas, ...Array.from(betas)] : existingBetas;
|
|
841
871
|
bedrockOptions.additionalModelRequestFields = {
|
|
842
872
|
...bedrockOptions.additionalModelRequestFields,
|
|
843
873
|
anthropic_beta: mergedBetas
|
|
844
874
|
};
|
|
845
875
|
}
|
|
846
|
-
const thinkingType = (
|
|
847
|
-
const thinkingBudget = thinkingType === "enabled" ? (
|
|
848
|
-
const thinkingDisplay = thinkingType === "adaptive" ? (
|
|
876
|
+
const thinkingType = (_g = bedrockOptions.reasoningConfig) == null ? void 0 : _g.type;
|
|
877
|
+
const thinkingBudget = thinkingType === "enabled" ? (_h = bedrockOptions.reasoningConfig) == null ? void 0 : _h.budgetTokens : void 0;
|
|
878
|
+
const thinkingDisplay = thinkingType === "adaptive" ? (_i = bedrockOptions.reasoningConfig) == null ? void 0 : _i.display : void 0;
|
|
849
879
|
const isAnthropicThinkingEnabled = isAnthropicModel && isThinkingRequested;
|
|
850
880
|
const inferenceConfig = {
|
|
851
881
|
...maxOutputTokens != null && { maxTokens: maxOutputTokens },
|
|
@@ -878,7 +908,7 @@ var BedrockChatLanguageModel = class {
|
|
|
878
908
|
};
|
|
879
909
|
}
|
|
880
910
|
} else if (!isAnthropicModel) {
|
|
881
|
-
if (((
|
|
911
|
+
if (((_j = bedrockOptions.reasoningConfig) == null ? void 0 : _j.budgetTokens) != null) {
|
|
882
912
|
warnings.push({
|
|
883
913
|
type: "unsupported-setting",
|
|
884
914
|
setting: "budgetTokens",
|
|
@@ -893,30 +923,44 @@ var BedrockChatLanguageModel = class {
|
|
|
893
923
|
});
|
|
894
924
|
}
|
|
895
925
|
}
|
|
896
|
-
const maxReasoningEffort = (
|
|
897
|
-
if (maxReasoningEffort != null
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
}
|
|
906
|
-
}
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
926
|
+
const maxReasoningEffort = (_k = bedrockOptions.reasoningConfig) == null ? void 0 : _k.maxReasoningEffort;
|
|
927
|
+
if (maxReasoningEffort != null) {
|
|
928
|
+
if (isAnthropicModel) {
|
|
929
|
+
bedrockOptions.additionalModelRequestFields = {
|
|
930
|
+
...bedrockOptions.additionalModelRequestFields,
|
|
931
|
+
output_config: {
|
|
932
|
+
...(_l = bedrockOptions.additionalModelRequestFields) == null ? void 0 : _l.output_config,
|
|
933
|
+
effort: maxReasoningEffort
|
|
934
|
+
}
|
|
935
|
+
};
|
|
936
|
+
} else if (isOpenAIModel) {
|
|
937
|
+
bedrockOptions.additionalModelRequestFields = isOpenAIGptOssModel ? {
|
|
938
|
+
...bedrockOptions.additionalModelRequestFields,
|
|
939
|
+
reasoning_effort: maxReasoningEffort
|
|
940
|
+
} : {
|
|
941
|
+
...bedrockOptions.additionalModelRequestFields,
|
|
942
|
+
reasoning: {
|
|
943
|
+
...(_m = bedrockOptions.additionalModelRequestFields) == null ? void 0 : _m.reasoning,
|
|
944
|
+
effort: maxReasoningEffort
|
|
945
|
+
}
|
|
946
|
+
};
|
|
947
|
+
} else {
|
|
948
|
+
bedrockOptions.additionalModelRequestFields = {
|
|
949
|
+
...bedrockOptions.additionalModelRequestFields,
|
|
950
|
+
reasoningConfig: {
|
|
951
|
+
...((_n = bedrockOptions.reasoningConfig) == null ? void 0 : _n.type) != null && {
|
|
952
|
+
type: bedrockOptions.reasoningConfig.type
|
|
953
|
+
},
|
|
954
|
+
maxReasoningEffort
|
|
955
|
+
}
|
|
956
|
+
};
|
|
957
|
+
}
|
|
914
958
|
}
|
|
915
959
|
if (useNativeStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null) {
|
|
916
960
|
bedrockOptions.additionalModelRequestFields = {
|
|
917
961
|
...bedrockOptions.additionalModelRequestFields,
|
|
918
962
|
output_config: {
|
|
919
|
-
...(
|
|
963
|
+
...(_o = bedrockOptions.additionalModelRequestFields) == null ? void 0 : _o.output_config,
|
|
920
964
|
format: {
|
|
921
965
|
type: "json_schema",
|
|
922
966
|
schema: (0, import_internal2.sanitizeJsonSchema)(responseFormat.schema)
|
|
@@ -948,7 +992,7 @@ var BedrockChatLanguageModel = class {
|
|
|
948
992
|
details: "topK is not supported when thinking is enabled"
|
|
949
993
|
});
|
|
950
994
|
}
|
|
951
|
-
const hasAnyTools = ((
|
|
995
|
+
const hasAnyTools = ((_q = (_p = toolConfig.tools) == null ? void 0 : _p.length) != null ? _q : 0) > 0 || additionalTools;
|
|
952
996
|
let filteredPrompt = prompt;
|
|
953
997
|
if (!hasAnyTools) {
|
|
954
998
|
const hasToolContent = prompt.some(
|