Files
agent-safe-middleware/config.yaml
T
starrrLight 5d71803b02 fix(配置): 模型相对路径按运行目录解析
模型相对路径以进程当前工作目录为基准,绝对路径继续直接使用。示例改为 models/guard_model,并补充路径迁移与容器挂载说明。

新增工作目录与配置目录分离、绝对路径和缺失目录校验测试。配置与 LLM 测试 20 项通过;全量测试 75 项通过,2 项现有插件示例测试因缺少初始化配置失败。
2026-10-13 16:42:54 +08:00

60 lines
1.6 KiB
YAML

upstream: http://127.0.0.1:8000
listen_host: 0.0.0.0
listen_port: 8080
limits:
max_sessions: 4
hook_timeout_seconds: 60
upstream_timeout_seconds: 120
llm:
- id: guard_model
type: guard
file: models/guard_model # 相对于进程工作目录,容器内为 /service/models/guard_model
load: {device: cpu} #待修改 (cude / cpu)
limits:
max_input_tokens: 4096
max_new_tokens: 32
timeout_seconds: 30
queue_size: 8
plugins:
- id: network-review
file: plugins/network_review.lua
network:
allow:
- domain: review.example.com # 本地联调改 mock-review.local
scheme: https
ports: [443]
timeout_seconds: 5
max_response_bytes: 1048576
config:
url: https://review.example.com/check # 本地联调改 http://mock-review.local:8001/check
fields: [messages]
headers: {x-api-key: "injected-by-admin"}
paths: [/chat/stream]
- id: response-guard
file: plugins/response_guard.lua
llm: {allow: [guard_model]}
config:
model: guard_model # 必须与 llm 注册的 id 一致
content_path: content
paths: [/chat/stream]
- id: request-rewrite
file: plugins/request_rewrite.lua
config:
prefix: "[checked] "
paths: [/chat/stream]
- id: stream-redact
file: plugins/stream_redact.lua
config:
text_event: text_delta
content_path: content
terminal_error_events: [run_error]
control_event_names: [heartbeat, run_started, run_finished, run_error, run_completed]
max_buffer_bytes: 262144
paths: [/chat/stream]