@@ -62,6 +62,32 @@ class Qwen3Template(ThinkingTemplate):
6262
6363register_template (QwenTemplateMeta (LLMTemplateType .qwen3 , default_system = None , template_cls = Qwen3Template ))
6464
65+ QWEN3_GUARD_TEMPLATE  =  (
66+     '<|im_start|>user\n ' 
67+     "# Task:\n 1) Evaluate whether THE LAST USER's query belongs to safe or unsafe content based on our " 
68+     'safety policy.\n 2) Identify the category of unsafe content found.\n \n <BEGIN SAFETY POLICY>\n ' 
69+     "**Safety: Safe**: The USER's query does not contain any prohibited content or content that could " 
70+     "lead to prohibited content.\n **Safety: Unsafe**: The USER's query contains prohibited content.\n " 
71+     "**Safety: Controversial**: The USER's query does not explicitly contain prohibited content, but " 
72+     'its intent, context, or potential responses could be misinterpreted, misused, or exploited to ' 
73+     'generate unsafe content under certain conditions.\n <END SAFETY POLICY>\n \n <BEGIN UNSAFE CONTENT ' 
74+     'CATEGORIES>\n Violent.\n Non-violent Illegal Acts.\n Sexual Content or Sexual Acts.\n PII.\n Suicide ' 
75+     '& Self-Harm.\n Unethical Acts.\n Politically Sensitive Topics.\n Copyright Violation.\n Jailbreak.\n ' 
76+     '<END UNSAFE CONTENT CATEGORIES>\n \n <BEGIN CONVERSATION>\n \n USER: {{QUERY}}\n \n <END CONVERSATION>' 
77+     "\n \n Provide your safety assessment for ONLY THE LAST **USER's query** in the above conversation:\n " 
78+     " - The first line must be one of: 'Safety: Safe', 'Safety: Unsafe', 'Safety: Controversial'.\n  - " 
79+     "The second line should start with 'Categories:' followed by a list of any unsafe content " 
80+     "categories, separated by commas. If the content is safe, use 'Categories: None'." 
81+     '<|im_end|>\n <|im_start|>assistant\n ' )
82+ 
83+ register_template (
84+     QwenTemplateMeta (
85+         LLMTemplateType .qwen3_guard ,
86+         default_system = None ,
87+         template_cls = Qwen3Template ,
88+         prompt = [QWEN3_GUARD_TEMPLATE ],
89+         response_prefix = '<think>\n \n </think>\n \n ' ))
90+ 
6591register_template (
6692    QwenTemplateMeta (
6793        LLMTemplateType .qwen3_thinking , default_system = None , response_prefix = '<think>\n ' ,
0 commit comments