@ai-sdk/amazon-bedrock 3.0.133 → 3.0.135
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 +20 -0
- package/dist/anthropic/index.d.mts +1 -1
- package/dist/anthropic/index.d.ts +1 -1
- package/dist/anthropic/index.js +1 -1
- package/dist/anthropic/index.mjs +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +11 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -7,17 +7,21 @@ import {
|
|
|
7
7
|
} from "@ai-sdk/provider-utils";
|
|
8
8
|
|
|
9
9
|
// src/version.ts
|
|
10
|
-
var VERSION = true ? "3.0.
|
|
10
|
+
var VERSION = true ? "3.0.135" : "0.0.0-test";
|
|
11
11
|
|
|
12
12
|
// src/bedrock-provider.ts
|
|
13
13
|
import { anthropicTools as anthropicTools2 } from "@ai-sdk/anthropic/internal";
|
|
14
14
|
|
|
15
15
|
// src/bedrock-chat-language-model.ts
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
getModelCapabilities,
|
|
18
|
+
sanitizeJsonSchema
|
|
19
|
+
} from "@ai-sdk/anthropic/internal";
|
|
17
20
|
import {
|
|
18
21
|
combineHeaders,
|
|
19
22
|
createJsonErrorResponseHandler as createJsonErrorResponseHandler2,
|
|
20
23
|
createJsonResponseHandler,
|
|
24
|
+
injectJsonInstructionIntoMessages,
|
|
21
25
|
parseProviderOptions as parseProviderOptions2,
|
|
22
26
|
postJsonToApi,
|
|
23
27
|
resolve
|
|
@@ -873,6 +877,7 @@ var BedrockChatLanguageModel = class {
|
|
|
873
877
|
const isOpenAIModel = openAIModelId != null;
|
|
874
878
|
const isOpenAIGptOssModel = (_d = openAIModelId == null ? void 0 : openAIModelId.startsWith("openai.gpt-oss-")) != null ? _d : false;
|
|
875
879
|
const isThinkingRequested = ((_e = bedrockOptions.reasoningConfig) == null ? void 0 : _e.type) === "enabled" || ((_f = bedrockOptions.reasoningConfig) == null ? void 0 : _f.type) === "adaptive";
|
|
880
|
+
const { rejectsForcedToolUse } = getModelCapabilities(this.modelId);
|
|
876
881
|
const structuredOutputMode = (_h = (_g = bedrockOptions.structuredOutputMode) != null ? _g : anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _h : "auto";
|
|
877
882
|
if (structuredOutputMode === "jsonTool") {
|
|
878
883
|
const additionalModelRequestFields = {
|
|
@@ -892,7 +897,8 @@ var BedrockChatLanguageModel = class {
|
|
|
892
897
|
}
|
|
893
898
|
const modelSupportsNativeStructuredOutput = this.config.modelFamily === "anthropic" || supportsNativeStructuredOutput(this.modelId) && isThinkingRequested;
|
|
894
899
|
const useNativeStructuredOutput = isAnthropicModel2 && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && (structuredOutputMode === "outputFormat" || structuredOutputMode === "auto" && modelSupportsNativeStructuredOutput);
|
|
895
|
-
const
|
|
900
|
+
const useJsonInstructionForStructuredOutput = !useNativeStructuredOutput && isAnthropicModel2 && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && rejectsForcedToolUse;
|
|
901
|
+
const jsonResponseTool = (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && !useNativeStructuredOutput && !useJsonInstructionForStructuredOutput ? {
|
|
896
902
|
type: "function",
|
|
897
903
|
name: "json",
|
|
898
904
|
description: "Respond with a JSON object.",
|
|
@@ -1066,6 +1072,13 @@ var BedrockChatLanguageModel = class {
|
|
|
1066
1072
|
});
|
|
1067
1073
|
}
|
|
1068
1074
|
}
|
|
1075
|
+
if (useJsonInstructionForStructuredOutput) {
|
|
1076
|
+
filteredPrompt = injectJsonInstructionIntoMessages({
|
|
1077
|
+
messages: filteredPrompt,
|
|
1078
|
+
schema: responseFormat.schema,
|
|
1079
|
+
schemaSuffix: "You MUST answer with only a JSON object that matches the JSON schema above. Do not wrap it in markdown fences or include any other text."
|
|
1080
|
+
});
|
|
1081
|
+
}
|
|
1069
1082
|
const { system, messages } = await convertToBedrockChatMessages(filteredPrompt);
|
|
1070
1083
|
const {
|
|
1071
1084
|
reasoningConfig: _,
|