We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 30ea359 commit bbd45bfCopy full SHA for bbd45bf
common/chat-template.hpp
@@ -303,13 +303,13 @@ class chat_template {
303
auto has_tool_responses = false;
304
auto has_string_content = false;
305
for (const auto & message : inputs.messages) {
306
- if (!message["tool_calls"].is_null()) {
+ if (message.contains("tool_calls") && !message["tool_calls"].is_null()) {
307
has_tool_calls = true;
308
}
309
- if (message["role"] == "tool") {
+ if (message.contains("role") && message["role"] == "tool") {
310
has_tool_responses = true;
311
312
- if (message["content"].is_string()) {
+ if (message.contains("content") && message["content"].is_string()) {
313
has_string_content = true;
314
315
0 commit comments