MCPcopy Index your code
hub / github.com/ChatLab/ChatLab / initTokenizer

Function initTokenizer

packages/node-runtime/src/ai/tokenizer.ts:26–36  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

24 * 可安全多次调用(幂等)。
25 */
26export async function initTokenizer(): Promise<void> {
27 if (encoder) return
28 if (initPromise) return initPromise
29
30 initPromise = (async () => {
31 const ranks = (await import('js-tiktoken/ranks/cl100k_base')).default
32 encoder = new Tiktoken(ranks)
33 })()
34
35 return initPromise
36}
37
38/**
39 * 轻量字符估算(fallback)

Callers 3

runAgentCoreFunction · 0.90
runServerAgentFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected