@ai-sdk/amazon-bedrock 4.0.194 → 4.0.195
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 +8 -0
- package/dist/anthropic/index.js +10 -21
- package/dist/anthropic/index.js.map +1 -1
- package/dist/anthropic/index.mjs +10 -21
- package/dist/anthropic/index.mjs.map +1 -1
- package/dist/index.js +13 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -23
- package/dist/index.mjs.map +1 -1
- package/dist/mantle/index.js +1 -1
- package/dist/mantle/index.mjs +1 -1
- package/package.json +2 -2
- package/src/bedrock-anthropic-model-support.ts +19 -25
- package/src/bedrock-chat-language-model.ts +5 -0
package/dist/index.mjs
CHANGED
|
@@ -118,30 +118,19 @@ function isAnthropicModel({
|
|
|
118
118
|
return modelFamily === "anthropic" || modelId.includes("anthropic") || modelId.includes(":application-inference-profile/") && reasoningBudgetTokens != null;
|
|
119
119
|
}
|
|
120
120
|
function supportsStrictTools(modelId) {
|
|
121
|
-
return !
|
|
121
|
+
return !modelId.includes("claude-") || LEGACY_CLAUDE_PATTERN.test(modelId) || MODELS_WITH_STRICT_TOOL_SUPPORT.some((pattern) => pattern.test(modelId));
|
|
122
122
|
}
|
|
123
123
|
function supportsNativeStructuredOutput(modelId) {
|
|
124
|
-
return
|
|
125
|
-
modelId,
|
|
126
|
-
MODELS_WITHOUT_RELIABLE_NATIVE_STRUCTURED_OUTPUT
|
|
127
|
-
);
|
|
124
|
+
return supportsStrictTools(modelId) && !/claude-(?:sonnet-4-6|haiku-4-5)(?=[-.:]|$)/.test(modelId);
|
|
128
125
|
}
|
|
129
|
-
var
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
126
|
+
var LEGACY_CLAUDE_PATTERN = /claude-(?:instant|v?2|3)(?=[-.:]|$)/;
|
|
127
|
+
var MODELS_WITH_STRICT_TOOL_SUPPORT = [
|
|
128
|
+
// Original Claude 4 IDs include a release date instead of a minor version.
|
|
129
|
+
/claude-(?:opus|sonnet)-4(?:-\d{8})?(?:-v\d+)?(?=[:.]|$)/,
|
|
130
|
+
/claude-opus-4-(?:1|5|6)(?=[-.:]|$)/,
|
|
131
|
+
/claude-sonnet-4-(?:5|6)(?=[-.:]|$)/,
|
|
132
|
+
/claude-haiku-4-5(?=[-.:]|$)/
|
|
136
133
|
];
|
|
137
|
-
var MODELS_WITHOUT_RELIABLE_NATIVE_STRUCTURED_OUTPUT = [
|
|
138
|
-
...MODELS_WITHOUT_STRICT_TOOL_SUPPORT,
|
|
139
|
-
"claude-sonnet-4-6",
|
|
140
|
-
"claude-haiku-4-5"
|
|
141
|
-
];
|
|
142
|
-
function matchesModel(modelId, models) {
|
|
143
|
-
return models.some((model) => modelId.includes(model));
|
|
144
|
-
}
|
|
145
134
|
|
|
146
135
|
// src/bedrock-error.ts
|
|
147
136
|
import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
|
|
@@ -1044,7 +1033,8 @@ var BedrockChatLanguageModel = class {
|
|
|
1044
1033
|
const isThinkingEnabled = ((_e = bedrockOptions.reasoningConfig) == null ? void 0 : _e.type) === "enabled" || ((_f = bedrockOptions.reasoningConfig) == null ? void 0 : _f.type) === "adaptive";
|
|
1045
1034
|
const {
|
|
1046
1035
|
supportsStructuredOutput: modelSupportsStructuredOutput,
|
|
1047
|
-
rejectsForcedToolUse
|
|
1036
|
+
rejectsForcedToolUse,
|
|
1037
|
+
isKnownModel
|
|
1048
1038
|
} = getModelCapabilities(this.modelId);
|
|
1049
1039
|
const structuredOutputMode = (_h = (_g = bedrockOptions.structuredOutputMode) != null ? _g : anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _h : "auto";
|
|
1050
1040
|
if (structuredOutputMode === "jsonTool") {
|
|
@@ -1065,7 +1055,7 @@ var BedrockChatLanguageModel = class {
|
|
|
1065
1055
|
}
|
|
1066
1056
|
const modelSupportsNativeStructuredOutput = supportsNativeStructuredOutput(this.modelId) && (modelSupportsStructuredOutput || isThinkingEnabled || this.config.modelFamily === "anthropic");
|
|
1067
1057
|
const useNativeStructuredOutput = isAnthropicModel2 && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && (structuredOutputMode === "outputFormat" || structuredOutputMode === "auto" && modelSupportsNativeStructuredOutput);
|
|
1068
|
-
const useJsonInstructionForStructuredOutput = !useNativeStructuredOutput && isAnthropicModel2 && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && (rejectsForcedToolUse || structuredOutputMode !== "jsonTool" && !supportsStrictTools(this.modelId) && tools != null && tools.length > 0);
|
|
1058
|
+
const useJsonInstructionForStructuredOutput = !useNativeStructuredOutput && isAnthropicModel2 && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && (rejectsForcedToolUse || this.modelId.includes("claude-") && (!isKnownModel || !modelSupportsStructuredOutput) && !supportsNativeStructuredOutput(this.modelId) && structuredOutputMode !== "jsonTool" || structuredOutputMode !== "jsonTool" && !supportsStrictTools(this.modelId) && tools != null && tools.length > 0);
|
|
1069
1059
|
const jsonResponseTool = (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && !useNativeStructuredOutput && !useJsonInstructionForStructuredOutput ? {
|
|
1070
1060
|
type: "function",
|
|
1071
1061
|
name: "json",
|
|
@@ -2382,7 +2372,7 @@ import {
|
|
|
2382
2372
|
import { AwsV4Signer } from "aws4fetch";
|
|
2383
2373
|
|
|
2384
2374
|
// src/version.ts
|
|
2385
|
-
var VERSION = true ? "4.0.
|
|
2375
|
+
var VERSION = true ? "4.0.195" : "0.0.0-test";
|
|
2386
2376
|
|
|
2387
2377
|
// src/bedrock-sigv4-fetch.ts
|
|
2388
2378
|
function createSigV4FetchFunction(getCredentials, fetch, service = "bedrock") {
|