From e7329fec18b9ec05bc751e28132d33fc74f2b838 Mon Sep 17 00:00:00 2001 From: Nicolas Patry Date: Tue, 29 Apr 2025 16:29:26 +0200 Subject: [PATCH] Fixing the router + template for Qwen3. (#3200) --- router/src/config.rs | 1 + router/src/infer/chat_template.rs | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/router/src/config.rs b/router/src/config.rs index 93b6f4fa..7c595e2d 100644 --- a/router/src/config.rs +++ b/router/src/config.rs @@ -414,6 +414,7 @@ pub enum Config { T5, DeepseekV2, DeepseekV3, + Qwen3, } #[derive(Clone, Debug, Serialize, Deserialize)] diff --git a/router/src/infer/chat_template.rs b/router/src/infer/chat_template.rs index a6687203..b26b3824 100644 --- a/router/src/infer/chat_template.rs +++ b/router/src/infer/chat_template.rs @@ -41,6 +41,10 @@ impl ChatTemplate { "messages[0]['content'][0]['text']", "messages[0]['content']", ); + // Hack to fix Qwen3 templating. + // It uses python notation to reverse lists, which do not exist in minijinja + // so we're using the reverse filter instead. + let mutated_template = mutated_template.replace("[::-1]", "|reverse"); let template_str = mutated_template.into_boxed_str(); env.add_function("raise_exception", raise_exception);