File size: 190 Bytes
ce45eb0
 
 
 
 
 
1
2
3
4
5
6
7
"""Model-agnostic token estimation, good enough for budgeting."""
from __future__ import annotations


def approx_tokens(text: str) -> int:
    return max(1, round(len(text.split()) * 1.3))