@ai-sdk/amazon-bedrock 4.0.109 → 4.0.111
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 +14 -0
- package/dist/anthropic/index.d.mts +1 -1
- package/dist/anthropic/index.d.ts +1 -1
- package/dist/anthropic/index.js +3 -3
- package/dist/anthropic/index.js.map +1 -1
- package/dist/anthropic/index.mjs +3 -3
- package/dist/anthropic/index.mjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +53 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +53 -23
- package/dist/index.mjs.map +1 -1
- package/docs/08-amazon-bedrock.mdx +2 -0
- package/package.json +2 -2
- package/src/anthropic/bedrock-anthropic-options.ts +2 -0
- package/src/anthropic/bedrock-anthropic-provider.ts +4 -2
- package/src/bedrock-api-types.ts +1 -1
- package/src/bedrock-chat-options.ts +2 -0
- package/src/convert-to-bedrock-chat-messages.ts +59 -24
package/dist/index.mjs
CHANGED
|
@@ -516,32 +516,62 @@ async function convertToBedrockChatMessages(prompt, isMistral = false) {
|
|
|
516
516
|
const output = part.output;
|
|
517
517
|
switch (output.type) {
|
|
518
518
|
case "content": {
|
|
519
|
-
toolResultContent =
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
519
|
+
toolResultContent = await Promise.all(
|
|
520
|
+
output.value.map(async (contentPart) => {
|
|
521
|
+
switch (contentPart.type) {
|
|
522
|
+
case "text":
|
|
523
|
+
return { text: contentPart.text };
|
|
524
|
+
case "image-data": {
|
|
525
|
+
return {
|
|
526
|
+
image: {
|
|
527
|
+
format: getBedrockImageFormat(
|
|
528
|
+
contentPart.mediaType
|
|
529
|
+
),
|
|
530
|
+
source: {
|
|
531
|
+
bytes: convertToBase64(contentPart.data)
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
};
|
|
535
|
+
}
|
|
536
|
+
case "file-data": {
|
|
537
|
+
if (!contentPart.mediaType.startsWith("image/")) {
|
|
538
|
+
const enableCitations = await shouldEnableCitations(
|
|
539
|
+
contentPart.providerOptions
|
|
540
|
+
);
|
|
541
|
+
return {
|
|
542
|
+
document: {
|
|
543
|
+
format: getBedrockDocumentFormat(
|
|
544
|
+
contentPart.mediaType
|
|
545
|
+
),
|
|
546
|
+
name: "filename" in contentPart && contentPart.filename ? stripFileExtension(contentPart.filename) : generateDocumentName(),
|
|
547
|
+
source: {
|
|
548
|
+
bytes: convertToBase64(contentPart.data)
|
|
549
|
+
},
|
|
550
|
+
...enableCitations && {
|
|
551
|
+
citations: { enabled: true }
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
};
|
|
555
|
+
}
|
|
556
|
+
return {
|
|
557
|
+
image: {
|
|
558
|
+
format: getBedrockImageFormat(
|
|
559
|
+
contentPart.mediaType
|
|
560
|
+
),
|
|
561
|
+
source: {
|
|
562
|
+
bytes: convertToBase64(contentPart.data)
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
};
|
|
566
|
+
}
|
|
567
|
+
default: {
|
|
525
568
|
throw new UnsupportedFunctionalityError2({
|
|
526
|
-
functionality: `
|
|
569
|
+
functionality: `unsupported tool content part type: ${contentPart.type}`
|
|
527
570
|
});
|
|
528
571
|
}
|
|
529
|
-
const format = getBedrockImageFormat(
|
|
530
|
-
contentPart.mediaType
|
|
531
|
-
);
|
|
532
|
-
return {
|
|
533
|
-
image: {
|
|
534
|
-
format,
|
|
535
|
-
source: { bytes: contentPart.data }
|
|
536
|
-
}
|
|
537
|
-
};
|
|
538
|
-
default: {
|
|
539
|
-
throw new UnsupportedFunctionalityError2({
|
|
540
|
-
functionality: `unsupported tool content part type: ${contentPart.type}`
|
|
541
|
-
});
|
|
542
572
|
}
|
|
543
|
-
}
|
|
544
|
-
|
|
573
|
+
})
|
|
574
|
+
);
|
|
545
575
|
break;
|
|
546
576
|
}
|
|
547
577
|
case "text":
|
|
@@ -2002,7 +2032,7 @@ import {
|
|
|
2002
2032
|
import { AwsV4Signer } from "aws4fetch";
|
|
2003
2033
|
|
|
2004
2034
|
// src/version.ts
|
|
2005
|
-
var VERSION = true ? "4.0.
|
|
2035
|
+
var VERSION = true ? "4.0.111" : "0.0.0-test";
|
|
2006
2036
|
|
|
2007
2037
|
// src/bedrock-sigv4-fetch.ts
|
|
2008
2038
|
function createSigV4FetchFunction(getCredentials, fetch) {
|