From c9c73373a85a97c5fee3762b832ed32d81419371 Mon Sep 17 00:00:00 2001 From: Jeff MAURY Date: Tue, 24 Sep 2024 17:25:14 +0200 Subject: [PATCH] fix: handle multiple calls to the same tool Fixes #1756 Signed-off-by: Jeff MAURY --- llama_cpp/llama_chat_format.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llama_cpp/llama_chat_format.py b/llama_cpp/llama_chat_format.py index dfb0af65e..c52ebcdab 100644 --- a/llama_cpp/llama_chat_format.py +++ b/llama_cpp/llama_chat_format.py @@ -3714,7 +3714,7 @@ def chatml_function_calling( ) response = cast(llama_types.CreateCompletionResponse, response) - tool_name = response["choices"][0]["text"][len("functions.") :] + tool_name = response["choices"][0]["text"][len("functions.") :-1] tool = next( (tool for tool in tools if tool["function"]["name"] == tool_name), None )