MCPcopy Create free account
hub / github.com/AQ-MedAI/MedMemoryBench / count_tokens

Function count_tokens

utils/tokenizer.py:129–134  ·  view source on GitHub ↗

Count tokens in text.

(text: str, tokenizer: Optional[TokenizerProtocol] = None)

Source from the content-addressed store, hash-verified

127
128
129def count_tokens(text: str, tokenizer: Optional[TokenizerProtocol] = None) -> int:
130 """Count tokens in text."""
131 if tokenizer is None:
132 tokenizer = get_tokenizer()
133
134 return len(tokenizer.encode(text))
135
136
137# ============================================================================

Callers

nothing calls this directly

Calls 2

get_tokenizerFunction · 0.85
encodeMethod · 0.45

Tested by

no test coverage detected