@ai-sdk/amazon-bedrock 4.0.140 → 4.0.142
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 +17 -0
- package/dist/anthropic/index.js +23 -4
- package/dist/anthropic/index.js.map +1 -1
- package/dist/anthropic/index.mjs +23 -4
- package/dist/anthropic/index.mjs.map +1 -1
- package/dist/index.js +23 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -4
- 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/anthropic/bedrock-anthropic-provider.ts +6 -7
- package/src/bedrock-anthropic-model-support.ts +23 -0
- package/src/bedrock-chat-language-model.ts +2 -7
- package/src/bedrock-prepare-tools.ts +2 -5
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.142" : "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.142" : "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.142",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -44,7 +44,7 @@
|
|
|
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.
|
|
47
|
+
"@ai-sdk/anthropic": "3.0.103",
|
|
48
48
|
"@ai-sdk/openai": "3.0.88",
|
|
49
49
|
"@ai-sdk/provider": "3.0.14",
|
|
50
50
|
"@ai-sdk/provider-utils": "4.0.40"
|
|
@@ -21,6 +21,10 @@ import {
|
|
|
21
21
|
createSigV4FetchFunction,
|
|
22
22
|
type BedrockCredentials,
|
|
23
23
|
} from '../bedrock-sigv4-fetch';
|
|
24
|
+
import {
|
|
25
|
+
supportsNativeStructuredOutput,
|
|
26
|
+
supportsStrictTools,
|
|
27
|
+
} from '../bedrock-anthropic-model-support';
|
|
24
28
|
import { createBedrockAnthropicFetch } from './bedrock-anthropic-fetch';
|
|
25
29
|
import type { BedrockAnthropicModelId } from './bedrock-anthropic-options';
|
|
26
30
|
import { VERSION } from '../version';
|
|
@@ -334,13 +338,8 @@ export function createBedrockAnthropic(
|
|
|
334
338
|
|
|
335
339
|
// Bedrock Anthropic doesn't support URL sources, force download and base64 conversion
|
|
336
340
|
supportedUrls: () => ({}),
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
supportsNativeStructuredOutput:
|
|
340
|
-
!modelId.includes('claude-opus-4-7') &&
|
|
341
|
-
!modelId.includes('claude-opus-4-8') &&
|
|
342
|
-
!modelId.includes('claude-fable-5') &&
|
|
343
|
-
!modelId.includes('claude-sonnet-5'),
|
|
341
|
+
supportsNativeStructuredOutput: supportsNativeStructuredOutput(modelId),
|
|
342
|
+
supportsStrictTools: supportsStrictTools(modelId),
|
|
344
343
|
});
|
|
345
344
|
|
|
346
345
|
const provider = function (modelId: BedrockAnthropicModelId) {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export function supportsStrictTools(modelId: string): boolean {
|
|
2
|
+
return !rejectsNewerSchemaFields(modelId);
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export function supportsNativeStructuredOutput(modelId: string): boolean {
|
|
6
|
+
return !rejectsNewerSchemaFields(modelId);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// Bedrock validates against its own copy of the Messages schema, which rejects
|
|
10
|
+
// `output_config.format` and tool `strict` for the newest Claude models
|
|
11
|
+
const MODELS_REJECTING_NEWER_SCHEMA_FIELDS = [
|
|
12
|
+
'claude-opus-4-7',
|
|
13
|
+
'claude-opus-4-8',
|
|
14
|
+
'claude-opus-5',
|
|
15
|
+
'claude-fable-5',
|
|
16
|
+
'claude-sonnet-5',
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
function rejectsNewerSchemaFields(modelId: string): boolean {
|
|
20
|
+
return MODELS_REJECTING_NEWER_SCHEMA_FIELDS.some(model =>
|
|
21
|
+
modelId.includes(model),
|
|
22
|
+
);
|
|
23
|
+
}
|
|
@@ -38,6 +38,7 @@ import {
|
|
|
38
38
|
amazonBedrockLanguageModelOptions,
|
|
39
39
|
type BedrockChatModelId,
|
|
40
40
|
} from './bedrock-chat-options';
|
|
41
|
+
import { supportsNativeStructuredOutput } from './bedrock-anthropic-model-support';
|
|
41
42
|
import { BedrockErrorSchema } from './bedrock-error';
|
|
42
43
|
import { createBedrockEventStreamResponseHandler } from './bedrock-event-stream-response-handler';
|
|
43
44
|
import { prepareTools } from './bedrock-prepare-tools';
|
|
@@ -151,18 +152,12 @@ export class BedrockChatLanguageModel implements LanguageModelV3 {
|
|
|
151
152
|
bedrockOptions.reasoningConfig?.type === 'enabled' ||
|
|
152
153
|
bedrockOptions.reasoningConfig?.type === 'adaptive';
|
|
153
154
|
|
|
154
|
-
const modelRejectsNativeStructuredOutput =
|
|
155
|
-
this.modelId.includes('claude-opus-4-7') ||
|
|
156
|
-
this.modelId.includes('claude-opus-4-8') ||
|
|
157
|
-
this.modelId.includes('claude-fable-5') ||
|
|
158
|
-
this.modelId.includes('claude-sonnet-5');
|
|
159
|
-
|
|
160
155
|
const { supportsStructuredOutput: modelSupportsStructuredOutput } =
|
|
161
156
|
getModelCapabilities(this.modelId);
|
|
162
157
|
|
|
163
158
|
const useNativeStructuredOutput =
|
|
164
159
|
isAnthropicModel &&
|
|
165
|
-
|
|
160
|
+
supportsNativeStructuredOutput(this.modelId) &&
|
|
166
161
|
(modelSupportsStructuredOutput || isThinkingEnabled) &&
|
|
167
162
|
responseFormat?.type === 'json' &&
|
|
168
163
|
responseFormat.schema != null;
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
anthropicTools,
|
|
10
10
|
prepareTools as prepareAnthropicTools,
|
|
11
11
|
} from '@ai-sdk/anthropic/internal';
|
|
12
|
+
import { supportsStrictTools } from './bedrock-anthropic-model-support';
|
|
12
13
|
import type {
|
|
13
14
|
BedrockTool,
|
|
14
15
|
BedrockToolConfiguration,
|
|
@@ -133,11 +134,7 @@ export async function prepareTools({
|
|
|
133
134
|
? functionTools.filter(t => t.name === toolChoice.toolName)
|
|
134
135
|
: functionTools;
|
|
135
136
|
|
|
136
|
-
|
|
137
|
-
// https://docs.aws.amazon.com/bedrock/latest/userguide/count-tokens.html
|
|
138
|
-
const supportsStrictOnTools =
|
|
139
|
-
!modelId.includes('claude-opus-4-7') &&
|
|
140
|
-
!modelId.includes('claude-opus-4-8');
|
|
137
|
+
const supportsStrictOnTools = supportsStrictTools(modelId);
|
|
141
138
|
|
|
142
139
|
for (const tool of filteredFunctionTools) {
|
|
143
140
|
bedrockTools.push({
|