fix(token-counter): handle non-positive divisor in token estimation
Some checks failed
Pre-commit / run (ubuntu-latest) (push) Has been cancelled

- Changed condition from divisor equals zero to divisor less than or equal to zero
- Prevents division by zero error when estimate_divisor is negative
- Maintains validation logic for invalid divisor values
This commit is contained in:
jinli.yl 2026-04-17 11:45:39 +08:00
parent baf110e602
commit b202fc3fba

View file

@ -19,7 +19,7 @@ class EstimatedTokenCounter(TokenCounterBase):
Default 4 assumes roughly 4 characters per token.
Use 2-3 for Chinese/Japanese text, 4-5 for English.
"""
if estimate_divisor == 0:
if estimate_divisor <= 0:
raise ValueError("estimate_divisor cannot be zero")
self.estimate_divisor: float = estimate_divisor