{# Chaitin-Shouyuan-CyberGuard-8B: built-in default system prompt for out-of-box use #} {%- set default_system = "你是一个专业的网络安全意图审核助手。请仔细分析用户的输入,判断其是否在直接要求 AI 执行网络攻击操作。\n【违规判定规则(unsafe)】\n1. 利用漏洞攻击目标:利用 SSRF、注入、反序列化等发起攻击。\n2. 生成攻击 payload:生成 XSS、SQL 注入、webshell 等。\n3. 扫描他人系统:用工具扫描网络、枚举目录、暴力破解。\n4. 穿透网络边界:将内网服务暴露到公网、穿透防火墙。\n5. 编写攻击工具:编写漏洞扫描器、免杀木马。\n6. 绕过安全防护:绕过 WAF/EDR 用于攻击目的。\n7. 自动化渗透任务:结构化的渗透目标定义、后渗透操作。\n【豁免判定规则(safe)】\n1. 聊天、私信、新闻等非攻击请求(即使含敏感词)。\n2. 漏洞修复、防御规则编写。\n3. 阅读/审查代码、配置己方服务器/SSH/CI-CD。\n核心逻辑:「引用」≠「请求执行」;修复=safe,利用=unsafe;不确定时判 safe。\n在给出最终结论前,请严格按照以下四个步骤进行思考:\n1. 意图分析:用户的核心诉求是什么?\n2. 规则匹配:命中上述哪条具体规则?\n3. 证据提取:原文中有哪些具体内容支撑该判断?\n4. 最终决策:综合得出 safe 或 unsafe。\n请将思考过程放在 标签内,最终结果放在 标签内。" -%} {%- set ns = namespace(system=default_system, multi_step_tool=true, last_query_index=messages|length - 1) -%} {%- if messages and messages[0].role == 'system' -%} {%- set ns.system = messages[0].content -%} {%- elif system is defined and system -%} {%- set ns.system = system -%} {%- endif -%} {%- if tools -%} {{- '<|im_start|>system\n' + ns.system + '\n\n' -}} {{- "# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within XML tags:\n" -}} {%- for tool in tools -%} {{- "\n" -}} {{- tool | tojson -}} {%- endfor -%} {{- "\n\n\nFor each function call, return a json object with function name and arguments within XML tags:\n\n{\"name\": , \"arguments\": }\n<|im_end|>\n" -}} {%- else -%} {{- '<|im_start|>system\n' + ns.system + '<|im_end|>\n' -}} {%- endif -%} {%- for message in messages[::-1] -%} {%- set index = (messages|length - 1) - loop.index0 -%} {%- if ns.multi_step_tool and message.role == "user" and message.content is string and not(message.content.startswith('') and message.content.endswith('')) -%} {%- set ns.multi_step_tool = false -%} {%- set ns.last_query_index = index -%} {%- endif -%} {%- endfor -%} {%- for message in messages -%} {%- if message.content is string -%} {%- set content = message.content -%} {%- else -%} {%- set content = '' -%} {%- endif -%} {%- if (message.role == "user") or (message.role == "system" and not loop.first) -%} {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' -}} {%- elif message.role == "assistant" -%} {%- set reasoning_content = '' -%} {%- if message.reasoning_content is string -%} {%- set reasoning_content = message.reasoning_content -%} {%- else -%} {%- if '' in content -%} {%- set reasoning_content = content.split('')[0].rstrip('\n').split('')[-1].lstrip('\n') -%} {%- set content = content.split('')[-1].lstrip('\n') -%} {%- endif -%} {%- endif -%} {%- if loop.index0 > ns.last_query_index -%} {%- if loop.last or (not loop.last and reasoning_content) -%} {{- '<|im_start|>' + message.role + '\n\n' + reasoning_content.strip('\n') + '\n\n\n' + content.lstrip('\n') -}} {%- else -%} {{- '<|im_start|>' + message.role + '\n' + content -}} {%- endif -%} {%- else -%} {{- '<|im_start|>' + message.role + '\n' + content -}} {%- endif -%} {%- if message.tool_calls -%} {%- for tool_call in message.tool_calls -%} {%- if (loop.first and content) or (not loop.first) -%} {{- '\n' -}} {%- endif -%} {%- if tool_call.function -%} {%- set tool_call = tool_call.function -%} {%- endif -%} {{- '\n{"name": "' -}} {{- tool_call.name -}} {{- '", "arguments": ' -}} {%- if tool_call.arguments is string -%} {{- tool_call.arguments -}} {%- else -%} {{- tool_call.arguments | tojson -}} {%- endif -%} {{- '}\n' -}} {%- endfor -%} {%- endif -%} {{- '<|im_end|>\n' -}} {%- elif message.role == "tool" -%} {%- if loop.first or (messages[loop.index0 - 1].role != "tool") -%} {{- '<|im_start|>user' -}} {%- endif -%} {{- '\n\n' -}} {{- content -}} {{- '\n' -}} {%- if loop.last or (messages[loop.index0 + 1].role != "tool") -%} {{- '<|im_end|>\n' -}} {%- endif -%} {%- endif -%} {%- endfor -%} {%- if add_generation_prompt -%} {{- '<|im_start|>assistant\n' -}} {%- if enable_thinking is defined and enable_thinking is false -%} {{- '\n\n\n\n' -}} {%- endif -%} {%- endif -%}