diff --git a/include/minja/chat-template.hpp b/include/minja/chat-template.hpp index 8f617db..fc9b7d4 100644 --- a/include/minja/chat-template.hpp +++ b/include/minja/chat-template.hpp @@ -162,8 +162,15 @@ class chat_template { }), false); caps_.supports_tools = contains(out, "some_tool"); - auto out_empty = try_raw_render(json::array({dummy_user_msg, {{"role", "assistant"}, {"content", ""}}}), {}, false); - auto out_null = try_raw_render(json::array({dummy_user_msg, {{"role", "assistant"}, {"content", nullptr}}}), {}, false); + const auto render_with_content = [&](const json & content) { + const json assistant_msg {{"role", "assistant"}, {"content", content}}; + // Render two assistant messages as some templates like QwQ-32B are handling + // the content differently depending on whether it's the last message or not + // (to remove the tag in all but the last message). + return try_raw_render(json::array({dummy_user_msg, assistant_msg, dummy_user_msg, assistant_msg}), {}, false); + }; + auto out_empty = render_with_content(""); + auto out_null = render_with_content(json()); caps_.requires_non_null_content = contains(out_empty, user_needle) && !contains(out_null, user_needle); json j_null; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 3dca28b..0388a74 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -323,9 +323,9 @@ set(MODEL_IDS Qwen/Qwen3-235B-A22B-Instruct-2507 Qwen/Qwen3-235B-A22B-Thinking-2507 Qwen/Qwen3-Coder-30B-A3B-Instruct + Qwen/QwQ-32B # Broken, TODO: - # Qwen/QwQ-32B # ai21labs/AI21-Jamba-1.5-Large # https://github.com/google/minja/issues/8 # Almawave/Velvet-14B # deepseek-ai/DeepSeek-R1 diff --git a/tests/test-capabilities.cpp b/tests/test-capabilities.cpp index 88968ce..1d43c62 100644 --- a/tests/test-capabilities.cpp +++ b/tests/test-capabilities.cpp @@ -80,7 +80,7 @@ TEST(CapabilitiesTest, QwQ32B) { EXPECT_TRUE(caps.supports_system_role); EXPECT_TRUE(caps.supports_tools); EXPECT_TRUE(caps.supports_tool_calls); - EXPECT_FALSE(caps.supports_tool_responses); + EXPECT_TRUE(caps.supports_tool_responses); EXPECT_TRUE(caps.supports_parallel_tool_calls); EXPECT_TRUE(caps.requires_object_arguments); // EXPECT_TRUE(caps.requires_non_null_content);