server: expose the reasoning effort levels of the chat template (#31271)
* server: expose the reasoning effort levels of the chat template The capability probe renders a user turn for each candidate level (minimal, low, medium, high, xhigh, max) and for an unknown level. A level is honored when it renders without raising and differently from the unknown level, which shows the template fallback. Levels sharing a render are aliases and the highest one is kept. The caps serialize to JSON, and chat_template_caps in /props reports the list as reasoning_effort_levels, from lowest to highest. * jinja: keep the caps free of the json dependency The caps keep reporting their flags as a map, and the effort levels stay a plain member. common_chat_templates_get_caps() builds the JSON the server reports from both, so jinja depends on json only for the probe inputs.
This commit is contained in:
1 parent
a919179942
commit
1b4554eff1
9 files changed
+90
-13
No files matched your search
+20
-2
@@ -7738,7 +7738,7 @@ static void test_template_generation_prompt() {
|
||||
preserve_reasoning_inputs.chat_template_kwargs["preserve_reasoning"] = "true";
|
||||
auto preserve_reasoning_params = common_chat_templates_apply(tmpls.get(), preserve_reasoning_inputs);
|
||||
assert_contains(preserve_reasoning_params.prompt.str(), "<|Assistant|><think>Previous reasoning</think>Previous answer");
|
||||
assert_equals(true, common_chat_templates_get_caps(tmpls.get()).at("supports_preserve_reasoning"));
|
||||
assert_equals(true, common_chat_templates_get_caps(tmpls.get()).at("supports_preserve_reasoning").get<bool>());
|
||||
|
||||
auto no_preserve_reasoning_inputs = default_history_inputs;
|
||||
no_preserve_reasoning_inputs.chat_template_kwargs["preserve_reasoning"] = "false";
|
||||
@@ -8311,7 +8311,7 @@ static void test_reasoning_effort_caps() {
|
||||
|
||||
auto assert_supports_effort = [](const std::string & path, bool expected) {
|
||||
auto tmpls = read_templates(path);
|
||||
assert_equals(expected, common_chat_templates_get_caps(tmpls.get()).at("supports_reasoning_effort"));
|
||||
assert_equals(expected, common_chat_templates_get_caps(tmpls.get()).at("supports_reasoning_effort").get<bool>());
|
||||
};
|
||||
|
||||
assert_supports_effort("models/templates/deepseek-ai-DeepSeek-V4.jinja", true);
|
||||
@@ -8322,6 +8322,24 @@ static void test_reasoning_effort_caps() {
|
||||
assert_supports_effort("models/templates/Cohere2MoE.jinja", true);
|
||||
assert_supports_effort("models/templates/meta-llama-Llama-3.1-8B-Instruct.jinja", false);
|
||||
assert_supports_effort("models/templates/Qwen-Qwen3-0.6B.jinja", false);
|
||||
|
||||
auto assert_effort_levels = [](const std::string & path, const std::vector<std::string> & expected) {
|
||||
auto tmpls = read_templates(path);
|
||||
assert_equals(json(expected).dump(), common_chat_templates_get_caps(tmpls.get()).at("reasoning_effort_levels").dump());
|
||||
};
|
||||
|
||||
const std::vector<std::string> all_levels = { "minimal", "low", "medium", "high", "xhigh", "max" };
|
||||
|
||||
assert_effort_levels("models/templates/deepseek-ai-DeepSeek-V4.jinja", { "max" });
|
||||
assert_effort_levels("models/templates/deepseek-ai-DeepSeek-V4-Flash-0731.jinja", { "high", "max" });
|
||||
assert_effort_levels("models/templates/IFM-K2-Horizon.jinja", { "low", "medium", "high" });
|
||||
assert_effort_levels("models/templates/tencent-Hy3.jinja", { "low", "high" });
|
||||
assert_effort_levels("models/templates/muse-spark.jinja", { "minimal", "low", "medium", "high" });
|
||||
assert_effort_levels("models/templates/upstage-Solar-Open-100B.jinja", { "low" });
|
||||
assert_effort_levels("models/templates/muse-glimmer.jinja", all_levels);
|
||||
assert_effort_levels("models/templates/openai-gpt-oss-120b.jinja", all_levels);
|
||||
assert_effort_levels("models/templates/Cohere2MoE.jinja", {});
|
||||
assert_effort_levels("models/templates/Qwen-Qwen3-0.6B.jinja", {});
|
||||
}
|
||||
|
||||
static void test_msg_diffs_compute() {
|
||||
|
||||
Reference in new issue
Block a user