(self, total_tokens: int, encoding_name: str = "cl100k_base")
| 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.""" |
nothing calls this directly
no outgoing calls
no test coverage detected