MCPcopy Create free account
hub / github.com/Noumena-Network/code / buildImageContentBlocks

Function buildImageContentBlocks

src/utils/attachments.ts:1105–1131  ·  view source on GitHub ↗
(
  pastedContents: Record<number, PastedContent> | undefined,
)

Source from the content-addressed store, hash-verified

1103}
1104
1105async function buildImageContentBlocks(
1106 pastedContents: Record<number, PastedContent> | undefined,
1107): Promise<ImageBlockParam[]> {
1108 if (!pastedContents) {
1109 return []
1110 }
1111 const imageContents = Object.values(pastedContents).filter(isValidImagePaste)
1112 if (imageContents.length === 0) {
1113 return []
1114 }
1115 const results = await Promise.all(
1116 imageContents.map(async img => {
1117 const imageBlock: ImageBlockParam = {
1118 type: 'image',
1119 source: {
1120 type: 'base64',
1121 media_type: (img.mediaType ||
1122 'image/png') as Base64ImageSource['media_type'],
1123 data: img.content,
1124 },
1125 }
1126 const resized = await maybeResizeAndDownsampleImageBlock(imageBlock)
1127 return resized.block
1128 }),
1129 )
1130 return results
1131}
1132
1133function getPlanModeAttachmentTurnCount(messages: Message[]): {
1134 turnCount: number

Callers 1

Calls 1

Tested by

no test coverage detected