@ai-sdk/amazon-bedrock 4.0.109 → 4.0.110

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/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 = output.value.map((contentPart) => {
520
- switch (contentPart.type) {
521
- case "text":
522
- return { text: contentPart.text };
523
- case "image-data":
524
- if (!contentPart.mediaType.startsWith("image/")) {
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: `media type: ${contentPart.mediaType}`
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.109" : "0.0.0-test";
2035
+ var VERSION = true ? "4.0.110" : "0.0.0-test";
2006
2036
 
2007
2037
  // src/bedrock-sigv4-fetch.ts
2008
2038
  function createSigV4FetchFunction(getCredentials, fetch) {