From b202fc3fba42872b66219a307e4f6a63234d63ad Mon Sep 17 00:00:00 2001 From: "jinli.yl" Date: Fri, 17 Apr 2026 11:45:39 +0800 Subject: [PATCH] fix(token-counter): handle non-positive divisor in token estimation - 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 --- reme2/component/as_token_counter/estimate_token_counter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reme2/component/as_token_counter/estimate_token_counter.py b/reme2/component/as_token_counter/estimate_token_counter.py index f95b6f62..c36da7aa 100644 --- a/reme2/component/as_token_counter/estimate_token_counter.py +++ b/reme2/component/as_token_counter/estimate_token_counter.py @@ -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