guard: 修正本地守卫模型的输入形态(Qwen3Guard 直接收原文)
上一版把自定义指令塞进 prompt、并在 response_moderation 里丢了用户提问,与 Qwen3Guard-Gen 的实际用法不符: - 输入:prompt 就是待审原文,不再加指令和 <BEGIN CONTENT> 包裹 - 输出:prompt=用户原问题(截断 2000 字节)、response=模型输出,恢复问答上下文 - 自定义指令改为可选的 prompt_prefix,默认不发送 宿主的 parse_guard_output 与九个类别名逐字对应 Qwen3Guard-Gen,已在注释和自检脚本里写明必须用该族模型。 验证:verify_plugins.py 104 项全通过;用假模型目录跑 load_settings + LLMRegistry, 确认 5 插件/1 启用、guard_model adapter 与两项能力正常建立;luac -p 通过。
This commit is contained in:
1 parent
d239cf584c
commit
6d9ab4fbf8
5 files changed
+69
-53
No files matched your search
@@ -12,6 +12,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import pathlib
|
||||
import sys
|
||||
|
||||
@@ -40,6 +41,18 @@ def check_model_dir(path: pathlib.Path) -> bool:
|
||||
|
||||
config_json = path / "config.json"
|
||||
passed &= ok("config.json 存在") if config_json.is_file() else fail("config.json 缺失")
|
||||
if config_json.is_file():
|
||||
# 宿主按 Qwen3Guard 的 Safety/Categories 文本解析,换别的 guard 模型会全部 503
|
||||
try:
|
||||
cfg = json.loads(config_json.read_text(encoding="utf-8"))
|
||||
except (OSError, ValueError):
|
||||
cfg = {}
|
||||
model_type = str(cfg.get("model_type", ""))
|
||||
if "qwen" in model_type.lower():
|
||||
passed &= ok("model_type", model_type)
|
||||
else:
|
||||
print(f" WARN model_type={model_type or '?'};宿主解析器按 Qwen3Guard 格式工作,"
|
||||
"其它 guard 模型会解析失败")
|
||||
|
||||
weights = [p for p in path.iterdir() if p.suffix in WEIGHT_SUFFIXES]
|
||||
if weights:
|
||||
|
||||
Reference in new issue
Block a user