MCPcopy
hub / github.com/coder/mux / countTokens

Method countTokens

src/node/services/tokenizerService.ts:43–50  ·  view source on GitHub ↗

* Count tokens for a single string

(model: string, text: string)

Source from the content-addressed store, hash-verified

41 * Count tokens for a single string
42 */
43 async countTokens(model: string, text: string): Promise<number> {
44 assert(
45 typeof model === "string" && model.length > 0,
46 "Tokenizer countTokens requires model name"
47 );
48 assert(typeof text === "string", "Tokenizer countTokens requires text");
49 return countTokens(model, text);
50 }
51
52 /**
53 * Count tokens for a batch of strings

Callers 12

createTokenCountingJobsFunction · 0.45
truncateHistoryMethod · 0.45
buildStreamSystemContextFunction · 0.45
emitPartAsEventMethod · 0.45
selectHotMemoriesFunction · 0.45
streamMessageMethod · 0.45
tokenizeWithMockModelFunction · 0.45
routerFunction · 0.45

Calls 2

countTokensFunction · 0.90
assertFunction · 0.50

Tested by

no test coverage detected