forked from phoenix/litellm-mirror
(fix) utils.token trimming ensure new length always greater than 0
This commit is contained in:
parent
81ce24b96e
commit
b3dc1eccc3
1 changed files with 1 additions and 0 deletions
|
@ -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]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue