From 4b0e3320bd8c2c209e29978d0b21e2e471cc9ee3 Mon Sep 17 00:00:00 2001 From: Andrei Betlen Date: Tue, 13 Feb 2024 03:11:35 -0500 Subject: [PATCH] fix: minor formatting bugs for chatml-function-calling --- llama_cpp/llama_chat_format.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/llama_cpp/llama_chat_format.py b/llama_cpp/llama_chat_format.py index af60d5f..66e40ae 100644 --- a/llama_cpp/llama_chat_format.py +++ b/llama_cpp/llama_chat_format.py @@ -2072,12 +2072,14 @@ def chatml_function_calling( "{% if message.role == 'assistant' %}" ## Reglar message "{% if message.content and message.content | length > 0 %}" + "{% if tool_calls %}" "message:\n" + "{% endif %}" "{{ message.content }}" "\n<|im_end|>\n" "{% endif %}" ## Function calls - "{% if message.tool_calls %}" + "{% if 'tool_calls' in message %}" "{% for tool_call in message.tool_calls %}" "functions.{{ tool_call.function.name }}:\n" "{{ tool_call.function.arguments }}"