@ai-sdk/amazon-bedrock 4.0.194 → 4.0.196
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 +18 -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 +4 -4
- package/src/bedrock-anthropic-model-support.ts +19 -25
- package/src/bedrock-chat-language-model.ts +5 -0
package/dist/mantle/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 ? "4.0.
|
|
38
|
+
var VERSION = true ? "4.0.196" : "0.0.0-test";
|
|
39
39
|
|
|
40
40
|
// src/bedrock-sigv4-fetch.ts
|
|
41
41
|
function createSigV4FetchFunction(getCredentials, fetch, service = "bedrock") {
|
package/dist/mantle/index.mjs
CHANGED
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
import { AwsV4Signer } from "aws4fetch";
|
|
24
24
|
|
|
25
25
|
// src/version.ts
|
|
26
|
-
var VERSION = true ? "4.0.
|
|
26
|
+
var VERSION = true ? "4.0.196" : "0.0.0-test";
|
|
27
27
|
|
|
28
28
|
// src/bedrock-sigv4-fetch.ts
|
|
29
29
|
function createSigV4FetchFunction(getCredentials, fetch, service = "bedrock") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/amazon-bedrock",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.196",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
"@smithy/eventstream-codec": "^4.0.1",
|
|
45
45
|
"@smithy/util-utf8": "^4.0.0",
|
|
46
46
|
"aws4fetch": "^1.0.20",
|
|
47
|
-
"@ai-sdk/anthropic": "3.0.
|
|
48
|
-
"@ai-sdk/openai": "3.0.125",
|
|
47
|
+
"@ai-sdk/anthropic": "3.0.130",
|
|
49
48
|
"@ai-sdk/provider": "3.0.18",
|
|
50
|
-
"@ai-sdk/provider-utils": "4.0.
|
|
49
|
+
"@ai-sdk/provider-utils": "4.0.58",
|
|
50
|
+
"@ai-sdk/openai": "3.0.127"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/node": "20.17.24",
|
|
@@ -17,37 +17,31 @@ export function isAnthropicModel({
|
|
|
17
17
|
);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
// Bedrock validates its own Messages schema. New Claude generations currently
|
|
21
|
+
// reject native structured output and strict tools, so only known supported
|
|
22
|
+
// Claude models receive those fields. Non-Claude models and opaque inference
|
|
23
|
+
// profile IDs retain their existing behavior.
|
|
20
24
|
export function supportsStrictTools(modelId: string): boolean {
|
|
21
|
-
return
|
|
25
|
+
return (
|
|
26
|
+
!modelId.includes('claude-') ||
|
|
27
|
+
LEGACY_CLAUDE_PATTERN.test(modelId) ||
|
|
28
|
+
MODELS_WITH_STRICT_TOOL_SUPPORT.some(pattern => pattern.test(modelId))
|
|
29
|
+
);
|
|
22
30
|
}
|
|
23
31
|
|
|
24
32
|
export function supportsNativeStructuredOutput(modelId: string): boolean {
|
|
25
|
-
return
|
|
26
|
-
modelId
|
|
27
|
-
|
|
33
|
+
return (
|
|
34
|
+
supportsStrictTools(modelId) &&
|
|
35
|
+
!/claude-(?:sonnet-4-6|haiku-4-5)(?=[-.:]|$)/.test(modelId)
|
|
28
36
|
);
|
|
29
37
|
}
|
|
30
38
|
|
|
31
|
-
|
|
32
|
-
// `output_config.format` and tool `strict` for the newest Claude models
|
|
33
|
-
const MODELS_WITHOUT_STRICT_TOOL_SUPPORT = [
|
|
34
|
-
'claude-opus-4-7',
|
|
35
|
-
'claude-opus-4-8',
|
|
36
|
-
'claude-opus-5',
|
|
37
|
-
'claude-fable-5',
|
|
38
|
-
'claude-sonnet-5',
|
|
39
|
-
'claude-haiku-5-5',
|
|
40
|
-
];
|
|
39
|
+
const LEGACY_CLAUDE_PATTERN = /claude-(?:instant|v?2|3)(?=[-.:]|$)/;
|
|
41
40
|
|
|
42
|
-
|
|
43
|
-
//
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
'claude-haiku-4-5',
|
|
41
|
+
const MODELS_WITH_STRICT_TOOL_SUPPORT = [
|
|
42
|
+
// Original Claude 4 IDs include a release date instead of a minor version.
|
|
43
|
+
/claude-(?:opus|sonnet)-4(?:-\d{8})?(?:-v\d+)?(?=[:.]|$)/,
|
|
44
|
+
/claude-opus-4-(?:1|5|6)(?=[-.:]|$)/,
|
|
45
|
+
/claude-sonnet-4-(?:5|6)(?=[-.:]|$)/,
|
|
46
|
+
/claude-haiku-4-5(?=[-.:]|$)/,
|
|
49
47
|
];
|
|
50
|
-
|
|
51
|
-
function matchesModel(modelId: string, models: string[]): boolean {
|
|
52
|
-
return models.some(model => modelId.includes(model));
|
|
53
|
-
}
|
|
@@ -187,6 +187,7 @@ export class BedrockChatLanguageModel implements LanguageModelV3 {
|
|
|
187
187
|
const {
|
|
188
188
|
supportsStructuredOutput: modelSupportsStructuredOutput,
|
|
189
189
|
rejectsForcedToolUse,
|
|
190
|
+
isKnownModel,
|
|
190
191
|
} = getModelCapabilities(this.modelId);
|
|
191
192
|
|
|
192
193
|
const structuredOutputMode =
|
|
@@ -240,6 +241,10 @@ export class BedrockChatLanguageModel implements LanguageModelV3 {
|
|
|
240
241
|
responseFormat?.type === 'json' &&
|
|
241
242
|
responseFormat.schema != null &&
|
|
242
243
|
(rejectsForcedToolUse ||
|
|
244
|
+
(this.modelId.includes('claude-') &&
|
|
245
|
+
(!isKnownModel || !modelSupportsStructuredOutput) &&
|
|
246
|
+
!supportsNativeStructuredOutput(this.modelId) &&
|
|
247
|
+
structuredOutputMode !== 'jsonTool') ||
|
|
243
248
|
(structuredOutputMode !== 'jsonTool' &&
|
|
244
249
|
!supportsStrictTools(this.modelId) &&
|
|
245
250
|
tools != null &&
|