@ai-sdk/amazon-bedrock 4.0.84 → 4.0.85
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 +6 -0
- package/dist/anthropic/index.js +1 -1
- package/dist/anthropic/index.mjs +1 -1
- package/dist/index.js +29 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +29 -26
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
- package/src/convert-to-bedrock-chat-messages.ts +33 -25
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.85",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -39,16 +39,16 @@
|
|
|
39
39
|
"@smithy/util-utf8": "^4.0.0",
|
|
40
40
|
"aws4fetch": "^1.0.20",
|
|
41
41
|
"@ai-sdk/anthropic": "3.0.64",
|
|
42
|
-
"@ai-sdk/provider
|
|
43
|
-
"@ai-sdk/provider": "
|
|
42
|
+
"@ai-sdk/provider": "3.0.8",
|
|
43
|
+
"@ai-sdk/provider-utils": "4.0.21"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/node": "20.17.24",
|
|
47
47
|
"tsup": "^8.3.0",
|
|
48
48
|
"typescript": "5.8.3",
|
|
49
49
|
"zod": "3.25.76",
|
|
50
|
-
"@
|
|
51
|
-
"@ai-
|
|
50
|
+
"@ai-sdk/test-server": "1.0.3",
|
|
51
|
+
"@vercel/ai-tsconfig": "0.0.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"zod": "^3.25.76 || ^4.1.8"
|
|
@@ -287,33 +287,41 @@ export async function convertToBedrockChatMessages(
|
|
|
287
287
|
schema: bedrockReasoningMetadataSchema,
|
|
288
288
|
});
|
|
289
289
|
|
|
290
|
-
if (reasoningMetadata != null) {
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
text: trimIfLast(
|
|
299
|
-
isLastBlock,
|
|
300
|
-
isLastMessage,
|
|
301
|
-
isLastContentPart,
|
|
302
|
-
part.text,
|
|
303
|
-
),
|
|
304
|
-
signature: reasoningMetadata.signature,
|
|
305
|
-
},
|
|
290
|
+
if (reasoningMetadata?.signature != null) {
|
|
291
|
+
// do not trim reasoning text when a signature is present:
|
|
292
|
+
// the signature validates the exact original bytes
|
|
293
|
+
bedrockContent.push({
|
|
294
|
+
reasoningContent: {
|
|
295
|
+
reasoningText: {
|
|
296
|
+
text: part.text,
|
|
297
|
+
signature: reasoningMetadata.signature,
|
|
306
298
|
},
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
299
|
+
},
|
|
300
|
+
});
|
|
301
|
+
} else if (reasoningMetadata?.redactedData != null) {
|
|
302
|
+
bedrockContent.push({
|
|
303
|
+
reasoningContent: {
|
|
304
|
+
redactedReasoning: {
|
|
305
|
+
data: reasoningMetadata.redactedData,
|
|
314
306
|
},
|
|
315
|
-
}
|
|
316
|
-
}
|
|
307
|
+
},
|
|
308
|
+
});
|
|
309
|
+
} else {
|
|
310
|
+
// trim the last text part if it's the last message in the block
|
|
311
|
+
// because Bedrock does not allow trailing whitespace
|
|
312
|
+
// in pre-filled assistant responses
|
|
313
|
+
bedrockContent.push({
|
|
314
|
+
reasoningContent: {
|
|
315
|
+
reasoningText: {
|
|
316
|
+
text: trimIfLast(
|
|
317
|
+
isLastBlock,
|
|
318
|
+
isLastMessage,
|
|
319
|
+
isLastContentPart,
|
|
320
|
+
part.text,
|
|
321
|
+
),
|
|
322
|
+
},
|
|
323
|
+
},
|
|
324
|
+
});
|
|
317
325
|
}
|
|
318
326
|
|
|
319
327
|
break;
|