(fix) utils.token trimming ensure new length always greater than 0

This commit is contained in:
ishaan-jaff 2023-10-24 16:03:06 -07:00
parent 81ce24b96e
commit b3dc1eccc3

View file

@ -4156,6 +4156,7 @@ def shorten_message_to_fit_limit(
ratio = (tokens_needed) / total_tokens
new_length = int(len(content) * ratio) -1
new_length = max(0, new_length)
half_length = new_length // 2
left_half = content[:half_length]