@ai-sdk/amazon-bedrock 4.0.141 → 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 +8 -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/index.mjs
CHANGED
|
@@ -102,6 +102,26 @@ var amazonBedrockLanguageModelOptions = z.object({
|
|
|
102
102
|
serviceTier: z.enum(["reserved", "priority", "default", "flex"]).optional()
|
|
103
103
|
});
|
|
104
104
|
|
|
105
|
+
// src/bedrock-anthropic-model-support.ts
|
|
106
|
+
function supportsStrictTools(modelId) {
|
|
107
|
+
return !rejectsNewerSchemaFields(modelId);
|
|
108
|
+
}
|
|
109
|
+
function supportsNativeStructuredOutput(modelId) {
|
|
110
|
+
return !rejectsNewerSchemaFields(modelId);
|
|
111
|
+
}
|
|
112
|
+
var MODELS_REJECTING_NEWER_SCHEMA_FIELDS = [
|
|
113
|
+
"claude-opus-4-7",
|
|
114
|
+
"claude-opus-4-8",
|
|
115
|
+
"claude-opus-5",
|
|
116
|
+
"claude-fable-5",
|
|
117
|
+
"claude-sonnet-5"
|
|
118
|
+
];
|
|
119
|
+
function rejectsNewerSchemaFields(modelId) {
|
|
120
|
+
return MODELS_REJECTING_NEWER_SCHEMA_FIELDS.some(
|
|
121
|
+
(model) => modelId.includes(model)
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
105
125
|
// src/bedrock-error.ts
|
|
106
126
|
import { z as z2 } from "zod/v4";
|
|
107
127
|
var BedrockErrorSchema = z2.object({
|
|
@@ -291,7 +311,7 @@ async function prepareTools({
|
|
|
291
311
|
}
|
|
292
312
|
}
|
|
293
313
|
const filteredFunctionTools = (toolChoice == null ? void 0 : toolChoice.type) === "tool" ? functionTools.filter((t) => t.name === toolChoice.toolName) : functionTools;
|
|
294
|
-
const supportsStrictOnTools =
|
|
314
|
+
const supportsStrictOnTools = supportsStrictTools(modelId);
|
|
295
315
|
for (const tool of filteredFunctionTools) {
|
|
296
316
|
bedrockTools.push({
|
|
297
317
|
toolSpec: {
|
|
@@ -911,9 +931,8 @@ var BedrockChatLanguageModel = class {
|
|
|
911
931
|
}
|
|
912
932
|
const isAnthropicModel = this.modelId.includes("anthropic");
|
|
913
933
|
const isThinkingEnabled = ((_b = bedrockOptions.reasoningConfig) == null ? void 0 : _b.type) === "enabled" || ((_c = bedrockOptions.reasoningConfig) == null ? void 0 : _c.type) === "adaptive";
|
|
914
|
-
const modelRejectsNativeStructuredOutput = this.modelId.includes("claude-opus-4-7") || this.modelId.includes("claude-opus-4-8") || this.modelId.includes("claude-fable-5") || this.modelId.includes("claude-sonnet-5");
|
|
915
934
|
const { supportsStructuredOutput: modelSupportsStructuredOutput } = getModelCapabilities(this.modelId);
|
|
916
|
-
const useNativeStructuredOutput = isAnthropicModel &&
|
|
935
|
+
const useNativeStructuredOutput = isAnthropicModel && supportsNativeStructuredOutput(this.modelId) && (modelSupportsStructuredOutput || isThinkingEnabled) && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null;
|
|
917
936
|
const useJsonInstructionForStructuredOutput = isAnthropicModel && (this.modelId.includes("claude-opus-4-7") || this.modelId.includes("claude-opus-4-8")) && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && tools != null && tools.length > 0;
|
|
918
937
|
const jsonResponseTool = (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && !useNativeStructuredOutput && !useJsonInstructionForStructuredOutput ? {
|
|
919
938
|
type: "function",
|
|
@@ -2164,7 +2183,7 @@ import {
|
|
|
2164
2183
|
import { AwsV4Signer } from "aws4fetch";
|
|
2165
2184
|
|
|
2166
2185
|
// src/version.ts
|
|
2167
|
-
var VERSION = true ? "4.0.
|
|
2186
|
+
var VERSION = true ? "4.0.142" : "0.0.0-test";
|
|
2168
2187
|
|
|
2169
2188
|
// src/bedrock-sigv4-fetch.ts
|
|
2170
2189
|
function createSigV4FetchFunction(getCredentials, fetch, service = "bedrock") {
|