Skip to content

Commit bbd45bf

Browse files
author
Olivier Chafik
committed
sync: minja
1 parent 30ea359 commit bbd45bf

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

common/chat-template.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,13 +303,13 @@ class chat_template {
303303
auto has_tool_responses = false;
304304
auto has_string_content = false;
305305
for (const auto & message : inputs.messages) {
306-
if (!message["tool_calls"].is_null()) {
306+
if (message.contains("tool_calls") && !message["tool_calls"].is_null()) {
307307
has_tool_calls = true;
308308
}
309-
if (message["role"] == "tool") {
309+
if (message.contains("role") && message["role"] == "tool") {
310310
has_tool_responses = true;
311311
}
312-
if (message["content"].is_string()) {
312+
if (message.contains("content") && message["content"].is_string()) {
313313
has_string_content = true;
314314
}
315315
}

0 commit comments

Comments
 (0)