Restore original return logic for force_accurate condition

This commit is contained in:
kkan9ma
2025-05-21 17:52:51 +09:00
parent 648829b770
commit c3ea048b71

View File

@ -166,8 +166,8 @@ class TokenHandler:
"""
encoder_estimate = len(self.encoder.encode(patch, disallowed_special=()))
if force_accurate:
return self.get_token_count_by_model_type(patch, encoder_estimate)
# If an estimate is enough (for example, in cases where the maximal allowed tokens is way below the known limits), return it.
return encoder_estimate
if not force_accurate:
return encoder_estimate
return self.get_token_count_by_model_type(patch, encoder_estimate)