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

Function shouldUseApproxTokenizer

src/node/utils/main/tokenizer.ts:24–31  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

22const APPROX_ENCODING = "approx-4";
23
24function shouldUseApproxTokenizer(): boolean {
25 // MUX_FORCE_REAL_TOKENIZER=1 overrides approx mode (for tests that need real tokenization)
26 // MUX_APPROX_TOKENIZER=1 enables fast approximate mode (default in Jest)
27 if (process.env.MUX_FORCE_REAL_TOKENIZER === "1") {
28 return false;
29 }
30 return process.env.MUX_APPROX_TOKENIZER === "1";
31}
32
33function approximateCount(text: string): number {
34 if (typeof text !== "string" || text.length === 0) {

Callers 4

loadTokenizerModulesFunction · 0.85
getTokenizerForModelFunction · 0.85
countTokensFunction · 0.85
countTokensBatchFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected