MCPcopy
hub / github.com/simstudioai/sim / buildBedrockMessageContent

Function buildBedrockMessageContent

apps/sim/providers/attachments.ts:638–678  ·  view source on GitHub ↗
(
  content: string | null | undefined,
  files: UserFile[] | undefined,
  providerId: ProviderId | string
)

Source from the content-addressed store, hash-verified

636}
637
638export function buildBedrockMessageContent(
639 content: string | null | undefined,
640 files: UserFile[] | undefined,
641 providerId: ProviderId | string
642): ContentBlock[] {
643 const parts: ContentBlock[] = []
644 if (content) {
645 parts.push({ text: content } as ContentBlock.TextMember)
646 }
647
648 for (const attachment of prepareProviderAttachments(files, providerId)) {
649 const bytes = Buffer.from(attachment.base64 ?? '', 'base64')
650 if (attachment.contentType === 'image') {
651 parts.push({
652 image: {
653 format: getBedrockImageFormat(attachment) as ContentBlock.ImageMember['image']['format'],
654 source: { bytes },
655 },
656 } as ContentBlock.ImageMember)
657 } else if (attachment.contentType === 'video') {
658 parts.push({
659 video: {
660 format: attachment.extension as ContentBlock.VideoMember['video']['format'],
661 source: { bytes },
662 },
663 } as ContentBlock.VideoMember)
664 } else {
665 parts.push({
666 document: {
667 format: getBedrockDocumentFormat(
668 attachment
669 ) as ContentBlock.DocumentMember['document']['format'],
670 name: sanitizeBedrockName(attachment.filename),
671 source: { bytes },
672 },
673 } as ContentBlock.DocumentMember)
674 }
675 }
676
677 return parts
678}
679
680const SDK_NATIVE_ATTACHMENT_PROVIDERS = new Set<AttachmentProvider>([
681 'openai',

Callers 2

index.tsFile · 0.90

Calls 5

getBedrockImageFormatFunction · 0.85
getBedrockDocumentFormatFunction · 0.85
sanitizeBedrockNameFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected