From bbd45bf6a29c8c95f59c485bc4617f4b3b62245c Mon Sep 17 00:00:00 2001 From: Olivier Chafik Date: Tue, 4 Feb 2025 00:14:15 +0000 Subject: [PATCH] sync: minja --- common/chat-template.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/chat-template.hpp b/common/chat-template.hpp index 2c3d96c36..69ee4e83e 100644 --- a/common/chat-template.hpp +++ b/common/chat-template.hpp @@ -303,13 +303,13 @@ class chat_template { auto has_tool_responses = false; auto has_string_content = false; for (const auto & message : inputs.messages) { - if (!message["tool_calls"].is_null()) { + if (message.contains("tool_calls") && !message["tool_calls"].is_null()) { has_tool_calls = true; } - if (message["role"] == "tool") { + if (message.contains("role") && message["role"] == "tool") { has_tool_responses = true; } - if (message["content"].is_string()) { + if (message.contains("content") && message["content"].is_string()) { has_string_content = true; } }