From 991e3361794103e9362a6c70f3b18f47b7ecd96c Mon Sep 17 00:00:00 2001 From: cotran Date: Wed, 11 Dec 2024 13:35:20 -0800 Subject: [PATCH] add type check and length checl --- model_server/src/core/function_calling.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model_server/src/core/function_calling.py b/model_server/src/core/function_calling.py index b0e6414e..a01c7fae 100644 --- a/model_server/src/core/function_calling.py +++ b/model_server/src/core/function_calling.py @@ -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":