@ai-sdk/amazon-bedrock 5.0.30 → 5.0.32
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/index.js +23 -4
- package/dist/index.js.map +1 -1
- package/dist/mantle/index.cjs +1 -1
- package/dist/mantle/index.js +1 -1
- package/package.json +2 -2
- package/src/amazon-bedrock-anthropic-model-support.ts +23 -0
- package/src/amazon-bedrock-chat-language-model.ts +2 -7
- package/src/amazon-bedrock-prepare-tools.ts +2 -5
- package/src/anthropic/amazon-bedrock-anthropic-provider.ts +6 -7
package/dist/mantle/index.cjs
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 ? "5.0.
|
|
38
|
+
var VERSION = true ? "5.0.32" : "0.0.0-test";
|
|
39
39
|
|
|
40
40
|
// src/amazon-bedrock-sigv4-fetch.ts
|
|
41
41
|
function createSigV4FetchFunction(getCredentials, fetch, service = "bedrock") {
|
package/dist/mantle/index.js
CHANGED
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
import { AwsV4Signer } from "aws4fetch";
|
|
24
24
|
|
|
25
25
|
// src/version.ts
|
|
26
|
-
var VERSION = true ? "5.0.
|
|
26
|
+
var VERSION = true ? "5.0.32" : "0.0.0-test";
|
|
27
27
|
|
|
28
28
|
// src/amazon-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": "5.0.
|
|
3
|
+
"version": "5.0.32",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@smithy/eventstream-codec": "^4.3.3",
|
|
45
45
|
"@smithy/util-utf8": "^4.3.3",
|
|
46
46
|
"aws4fetch": "^1.0.20",
|
|
47
|
-
"@ai-sdk/anthropic": "4.0.
|
|
47
|
+
"@ai-sdk/anthropic": "4.0.21",
|
|
48
48
|
"@ai-sdk/openai": "4.0.20",
|
|
49
49
|
"@ai-sdk/provider": "4.0.3",
|
|
50
50
|
"@ai-sdk/provider-utils": "5.0.12"
|
|
@@ -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
|
+
}
|
|
@@ -45,6 +45,7 @@ import {
|
|
|
45
45
|
type AmazonBedrockLanguageModelChatOptions,
|
|
46
46
|
type AmazonBedrockChatModelId,
|
|
47
47
|
} from './amazon-bedrock-chat-language-model-options';
|
|
48
|
+
import { supportsNativeStructuredOutput } from './amazon-bedrock-anthropic-model-support';
|
|
48
49
|
import { AmazonBedrockErrorSchema } from './amazon-bedrock-error';
|
|
49
50
|
import { createAmazonBedrockEventStreamResponseHandler } from './amazon-bedrock-event-stream-response-handler';
|
|
50
51
|
import { prepareTools } from './amazon-bedrock-prepare-tools';
|
|
@@ -193,15 +194,9 @@ export class AmazonBedrockChatLanguageModel implements LanguageModelV4 {
|
|
|
193
194
|
const { supportsStructuredOutput: modelSupportsStructuredOutput } =
|
|
194
195
|
getModelCapabilities(this.modelId);
|
|
195
196
|
|
|
196
|
-
const modelRejectsNativeStructuredOutput =
|
|
197
|
-
this.modelId.includes('claude-opus-4-7') ||
|
|
198
|
-
this.modelId.includes('claude-opus-4-8') ||
|
|
199
|
-
this.modelId.includes('claude-fable-5') ||
|
|
200
|
-
this.modelId.includes('claude-sonnet-5');
|
|
201
|
-
|
|
202
197
|
const useNativeStructuredOutput =
|
|
203
198
|
isAnthropicModel &&
|
|
204
|
-
|
|
199
|
+
supportsNativeStructuredOutput(this.modelId) &&
|
|
205
200
|
(modelSupportsStructuredOutput || isThinkingEnabled) &&
|
|
206
201
|
responseFormat?.type === 'json' &&
|
|
207
202
|
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 './amazon-bedrock-anthropic-model-support';
|
|
12
13
|
import type {
|
|
13
14
|
AmazonBedrockTool,
|
|
14
15
|
AmazonBedrockToolConfiguration,
|
|
@@ -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
|
amazonBedrockTools.push({
|
|
@@ -21,6 +21,10 @@ import {
|
|
|
21
21
|
createSigV4FetchFunction,
|
|
22
22
|
type AmazonBedrockCredentials,
|
|
23
23
|
} from '../amazon-bedrock-sigv4-fetch';
|
|
24
|
+
import {
|
|
25
|
+
supportsNativeStructuredOutput,
|
|
26
|
+
supportsStrictTools,
|
|
27
|
+
} from '../amazon-bedrock-anthropic-model-support';
|
|
24
28
|
import { createAmazonBedrockAnthropicFetch } from './amazon-bedrock-anthropic-fetch';
|
|
25
29
|
import type { AmazonBedrockAnthropicModelId } from './amazon-bedrock-anthropic-options';
|
|
26
30
|
import { VERSION } from '../version';
|
|
@@ -342,13 +346,8 @@ export function createAmazonBedrockAnthropic(
|
|
|
342
346
|
|
|
343
347
|
// Bedrock Anthropic doesn't support URL sources, force download and base64 conversion
|
|
344
348
|
supportedUrls: () => ({}),
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
supportsNativeStructuredOutput:
|
|
348
|
-
!modelId.includes('claude-opus-4-7') &&
|
|
349
|
-
!modelId.includes('claude-opus-4-8') &&
|
|
350
|
-
!modelId.includes('claude-fable-5') &&
|
|
351
|
-
!modelId.includes('claude-sonnet-5'),
|
|
349
|
+
supportsNativeStructuredOutput: supportsNativeStructuredOutput(modelId),
|
|
350
|
+
supportsStrictTools: supportsStrictTools(modelId),
|
|
352
351
|
});
|
|
353
352
|
|
|
354
353
|
const provider = function (modelId: AmazonBedrockAnthropicModelId) {
|