MCPcopy Create free account
hub / github.com/Emmimal/control-layer / __init__

Method __init__

control_layer.py:306–315  ·  view source on GitHub ↗
(self, total_tokens: int, encoding_name: str = "cl100k_base")

Source from the content-addressed store, hash-verified

304 """
305
306 def __init__(self, total_tokens: int, encoding_name: str = "cl100k_base"):
307 self.total_tokens = total_tokens
308 self._enc = None
309 try:
310 self._enc = tiktoken.get_encoding(encoding_name)
311 except Exception:
312 # Graceful offline fallback: char/4 heuristic
313 # Replace with tiktoken when network access is available
314 pass
315 self._slots: Dict[str, int] = {}
316
317 def count(self, text: str) -> int:
318 """Exact token count via tiktoken, or char/4 heuristic if offline."""

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected