add type check and length checl

This commit is contained in:
cotran 2024-12-11 13:35:20 -08:00
parent 8cfef7bcd4
commit 991e336179

View file

@ -493,7 +493,7 @@ class ArchFunctionHandler(ArchBaseHandler):
total_tokens = estimate_token_length(messages)
# Trim messages if token count exceeds the limit
while total_tokens > max_tokens:
while total_tokens > max_tokens and len(messages) >= 3:
# Find the first non-system message pair
for i in range(len(messages)):
if messages[i]["role"] != "system":