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

Function processAttachment

src/utils/analyzeContext.ts:840–852  ·  view source on GitHub ↗
(
  msg: AttachmentMessage,
  breakdown: MessageBreakdown,
)

Source from the content-addressed store, hash-verified

838}
839
840function processAttachment(
841 msg: AttachmentMessage,
842 breakdown: MessageBreakdown,
843): void {
844 const contentStr = jsonStringify(msg.attachment)
845 const tokens = roughTokenCountEstimation(contentStr)
846 breakdown.attachmentTokens += tokens
847 const attachType = msg.attachment.type || 'unknown'
848 breakdown.attachmentsByType.set(
849 attachType,
850 (breakdown.attachmentsByType.get(attachType) || 0) + tokens,
851 )
852}
853
854async function approximateMessageTokens(
855 messages: Message[],

Callers 1

approximateMessageTokensFunction · 0.85

Calls 4

jsonStringifyFunction · 0.85
setMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected