清理冗余注释
只保留不写就会改错的说明(宿主 block 只给固定 403、UTF-8 边界、脱敏长度不变、 messages 需稠密整数表才能编成数组、input_text 绕过等),其余说明性段落删掉。 response_guard 注释 129 → 42 行;config.yaml 注释 51 → 13 行;配置结构未变。
This commit is contained in:
1 parent
5b4438a306
commit
ec6f5fc811
5 files changed
+56
-258
No files matched your search
+25
-69
@@ -4,7 +4,7 @@ listen_port: 8080
|
||||
|
||||
limits:
|
||||
max_sessions: 4
|
||||
# 判定走远程 /chat/completions:单次 1~5s,最多切 8 段,留足余量
|
||||
# 单次判定 1~5s,最多切 8 段
|
||||
hook_timeout_seconds: 45
|
||||
upstream_timeout_seconds: 120
|
||||
max_attachment_files: 8
|
||||
@@ -15,9 +15,7 @@ limits:
|
||||
attachment_timeout_seconds: 30
|
||||
max_attachment_reads: 64
|
||||
|
||||
# 本地守卫模型已停用,判定统一走下面的 OpenAI 兼容接口。
|
||||
# models/guard_model 在当前环境中不存在,保留本段会导致网关启动失败,故整段注释。
|
||||
# 若要把本地守卫模型加回来:取消注释,并把模型文件放到 models/guard_model。
|
||||
# 本地守卫模型已停用(模型文件不存在,启用会导致启动失败),判定走下面的 OpenAI 接口
|
||||
# llm:
|
||||
# - id: guard_model
|
||||
# type: guard
|
||||
@@ -30,10 +28,7 @@ limits:
|
||||
# queue_size: 8
|
||||
|
||||
plugins:
|
||||
# ---------------------------------------------------------------------------
|
||||
# 旧协议遗留(/upload),依赖上面已停用的 guard_model,并且宿主没有 host.files
|
||||
# 能力,实际无法工作。文件保留在 plugins/ 下,配置停用;需要时再恢复。
|
||||
# ---------------------------------------------------------------------------
|
||||
# 旧协议遗留,依赖已停用的 guard_model,且宿主没有 host.files
|
||||
- id: file-content-review
|
||||
enabled: false
|
||||
file: plugins/file_content_review.lua
|
||||
@@ -45,9 +40,7 @@ plugins:
|
||||
max_review_bytes: 8192
|
||||
max_files: 8
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 旧协议遗留(/chat/stream),外部审核服务白名单转发,本来就是停用状态。
|
||||
# ---------------------------------------------------------------------------
|
||||
# 旧协议遗留,外部审核服务白名单转发
|
||||
- id: network-review
|
||||
enabled: false
|
||||
file: plugins/network_review.lua
|
||||
@@ -65,11 +58,6 @@ plugins:
|
||||
fields: [messages]
|
||||
headers: {x-api-key: "injected-by-admin"}
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 输入 + 输出内容安全(OpenAI 协议)
|
||||
# 请求侧:判定不通过 → 请求体换成 stub(原文不发给模型)→ 响应侧返回 400
|
||||
# 响应侧:逐段审核 → 脱敏 → 放行;不安全/审核不可用 → OpenAI 错误体
|
||||
# ---------------------------------------------------------------------------
|
||||
- id: response-guard
|
||||
file: plugins/response_guard.lua
|
||||
match:
|
||||
@@ -82,73 +70,33 @@ plugins:
|
||||
timeout_seconds: 20
|
||||
max_response_bytes: 1048576
|
||||
config:
|
||||
# 判定端点 = base_url + /chat/completions;base_url 写下面三种都可以:
|
||||
# https://ai.leapstella.com → 自动补 /v1/chat/completions
|
||||
# https://ai.leapstella.com/v1 → /v1/chat/completions
|
||||
# https://ai.leapstella.com/v1/chat/completions(完整端点)
|
||||
# 主机、/v1、完整端点三种写法都可以
|
||||
base_url: https://ai.leapstella.com/v1
|
||||
# 部署时填入自己的密钥;仓库里只有占位符,真实密钥不入库
|
||||
# 部署时填入自己的密钥;仓库里只有占位符
|
||||
api_key: "sk-REPLACE_ME"
|
||||
# 该网关 /v1/models 只有 deepseek-flash 与 deepseek-v4-pro。
|
||||
# 实测 17 次判定:v4-pro 中位 1.08s(0.59~1.30s),flash 中位 1.39s(1.15~4.62s);
|
||||
# 16KB 长输入 v4-pro 1.08s vs flash 2.13s。7 组风险/正常样本判定结果完全一致。
|
||||
# 结论:判定用 v4-pro,时延更低且抖动明显更小。换回 flash 只改这一行。
|
||||
# 比 deepseek-flash 快且抖动小,实测 1.0~1.3s
|
||||
model: deepseek-v4-pro
|
||||
# 拦截状态码:400 = OpenAI 内容策略拒绝的标准形态
|
||||
block_status: 400
|
||||
# incremental: 攒够 flush_chars 且遇到句边界就审核放行(有增量输出)
|
||||
# buffered : 整条响应结束再一次审核(1 次判定,但客户端看不到增量)
|
||||
# buffered 则整条响应只判一次,但客户端看不到增量
|
||||
stream_mode: incremental
|
||||
flush_chars: 512
|
||||
force_flush_bytes: 4096
|
||||
# 上限与判定能力对齐:8 段 × judge_chunk_bytes(16KB) = 128KB
|
||||
# 8 段 × judge_chunk_bytes(16KB)
|
||||
max_buffer_bytes: 131072
|
||||
# 正文路径用插件默认值:
|
||||
# 流式 choices[*].delta.content
|
||||
# 非流式 choices[*].message.content
|
||||
# 工具调用参数也要审核时,改成数组并在其中追加:
|
||||
# content_path_stream: ["choices.*.delta.content",
|
||||
# "choices.*.delta.tool_calls.*.function.arguments"]
|
||||
# content_path_full: ["choices.*.message.content",
|
||||
# "choices.*.message.tool_calls.*.function.arguments"]
|
||||
|
||||
judge_chunk_bytes: 16384
|
||||
judge_max_tokens: 512
|
||||
# deepseek 系列默认带思维链,判定用不到;none 可省 ~0.3s 且避免思维链吃光 token。
|
||||
# 换后端若报 400,删掉这一行即可。
|
||||
# 关掉思维链,省时延也避免 content 被思维链挤空
|
||||
judge_reasoning_effort: none
|
||||
# ---- 换后端时才需要的三个开关,默认值对 DeepSeek 一类兼容服务都可直接跑 ----
|
||||
# 生成上限的参数名:OpenAI 的 gpt-5 / o 系列只收 max_completion_tokens,
|
||||
# 发 max_tokens 会 400。
|
||||
# judge_token_param: max_completion_tokens
|
||||
# temperature:o 系列 / gpt-5 只接受默认值 1,发 0 会 400;设 false 即不发送该字段。
|
||||
# judge_temperature: false
|
||||
# 后端不支持 response_format 时关掉,仅靠 system_prompt 约束输出 JSON。
|
||||
# judge_json_mode: false
|
||||
# ---- 拦截后替换给上游的占位请求(原文不出网关)----
|
||||
# 默认形态即最小合规请求:{model, messages:[{role:user,content:"ping"}], stream, max_tokens:16}
|
||||
# 客户端请求里没有 model 时用下面这个兜底(OpenAI 规范要求 model 必填):
|
||||
# stub_model: deepseek-v4-pro
|
||||
# 上游换成 gpt-5 / o 系列(只认 max_completion_tokens)时设 false,不发 max_tokens:
|
||||
# stub_max_tokens: false
|
||||
check_input: true
|
||||
check_output: true
|
||||
# 换 gpt-5 / o 系列时需要,DeepSeek 类服务不用改
|
||||
# judge_token_param: max_completion_tokens
|
||||
# judge_temperature: false
|
||||
# judge_json_mode: false
|
||||
# 拦截后替换给上游的占位请求:客户端没给 model 时用它兜底
|
||||
# stub_model: deepseek-v4-pro
|
||||
# stub_max_tokens: false
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 最后一条 user 消息打标;会重写整个 body,默认关闭
|
||||
# ---------------------------------------------------------------------------
|
||||
- id: request-rewrite
|
||||
enabled: false
|
||||
file: plugins/request_rewrite.lua
|
||||
match:
|
||||
paths: ["/v1/chat/completions"]
|
||||
config:
|
||||
prefix: "[checked] "
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 全缓冲 PII 兜底(跨帧拆分的证件号/手机号)
|
||||
# 代价:流式退化为一次性输出,与 response_guard 的增量放行冲突,默认关闭
|
||||
# ---------------------------------------------------------------------------
|
||||
- id: stream-redact
|
||||
enabled: false
|
||||
file: plugins/stream_redact.lua
|
||||
@@ -157,3 +105,11 @@ plugins:
|
||||
config:
|
||||
content_path: choices.*.delta.content
|
||||
max_buffer_bytes: 262144
|
||||
|
||||
- id: request-rewrite
|
||||
enabled: false
|
||||
file: plugins/request_rewrite.lua
|
||||
match:
|
||||
paths: ["/v1/chat/completions"]
|
||||
config:
|
||||
prefix: "[checked] "
|
||||
Reference in new issue
Block a user