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

Function getTokens

src/services/compact/sessionMemoryCompact.ts:374–380  ·  view source on GitHub ↗
(msg: Message)

Source from the content-addressed store, hash-verified

372 // pass (range startIndex..end) and again during backward expansion.
373 const tokenMemo = new Map<Message, number>()
374 function getTokens(msg: Message): number {
375 const cached = tokenMemo.get(msg)
376 if (cached !== undefined) return cached
377 const t = estimateMessageTokensForSingleMessage(msg)
378 tokenMemo.set(msg, t)
379 return t
380 }
381
382 // Calculate current tokens and text-block message count from startIndex to end
383 let totalTokens = 0

Callers 1

Calls 3

setMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected