From a5bd0054112b09e8cab50d1e8fcae82522b162c4 Mon Sep 17 00:00:00 2001 From: Shuguang Chen <54548843+nehcgs@users.noreply.github.com> Date: Thu, 5 Dec 2024 12:06:56 -0800 Subject: [PATCH] Fix a bug in function_calling.py --- .../app/model_handler/function_calling.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/model_server/app/model_handler/function_calling.py b/model_server/app/model_handler/function_calling.py index ea13678c..3630e8bf 100644 --- a/model_server/app/model_handler/function_calling.py +++ b/model_server/app/model_handler/function_calling.py @@ -358,15 +358,16 @@ class ArchFunctionHandler(ArchBaseHandler): for token in response: token_content = token.choices[0].delta.content.strip() - if has_tool_call is None and token_content != "": - has_tool_call = False - response.close() - break - else: - has_tool_call = True + if token_content: + if has_tool_call is None and token_content != "": + has_tool_call = False + response.close() + break + else: + has_tool_call = True - if has_tool_call is True: - model_response += token_content + if has_tool_call is True: + model_response += token_content # start parameter gathering if the model is not generating a tool call if has_tool_call is False: