# 容器内配置(core 目标:全部判定走 vLLM HTTP) # # 挂载点固定为 /service/config.yaml,这样 plugins/ 的相对路径仍然按 # /service/plugins 解析(load_settings 的插件路径是相对配置文件所在目录的)。 # # 前提:docs/目前方案说明.md §6 的 4 处补丁已应用,否则 backend: vllm # 会直接过不了 config 校验(LLMConfig.backend 目前只接受 transformers)。 # # 地址全部写 127.0.0.1,配套 network_mode: host。 # 原因:middleware/config.py 的 LLMConfig 校验要求 llm.url 必须是本机回环 # (127.0.0.1 / ::1 / localhost)——这是刻意的安全性质,判定服务不许在远端。 # 所以编排里所有服务都跑 host 网络,容器与 vLLM 共享同一 network namespace。 upstream: http://127.0.0.1:8001 listen_host: 0.0.0.0 listen_port: 8080 limits: max_sessions: 4 hook_timeout_seconds: 120 upstream_timeout_seconds: 120 max_attachment_files: 8 max_attachment_fields: 128 max_attachment_text_bytes: 1048576 max_attachment_unpacked_bytes: 33554432 max_attachment_zip_entries: 2048 attachment_timeout_seconds: 30 max_attachment_reads: 64 # 两个守卫都是独立 vLLM 服务,中间层不加载任何权重 llm: - id: guard_model type: guard backend: vllm url: http://127.0.0.1:8003 served_model: small_model limits: max_input_tokens: 8192 max_new_tokens: 64 timeout_seconds: 30 max_concurrency: 8 # 属于 limits(LLMLimits 上限 32),写条目顶层会 extra_forbidden queue_size: 32 - id: guard_8b type: guard backend: vllm url: http://127.0.0.1:8005 served_model: large_model_guard # 该模型 max_model_len 就是 4096,别照抄 8192 limits: max_input_tokens: 4096 max_new_tokens: 64 timeout_seconds: 60 max_concurrency: 8 queue_size: 16 plugins: - id: file-content-review enabled: false file: plugins/file_content_review.lua match: paths: ["/upload"] config: model: guard_model allowed_extensions: [txt, doc, docx] max_review_bytes: 8192 max_files: 8 - id: network-review enabled: false file: plugins/network_review.lua match: paths: ["/chat/stream"] network: allow: - domain: review.example.com scheme: https ports: [443] timeout_seconds: 5 max_response_bytes: 1048576 config: url: https://review.example.com/check fields: [messages] headers: {x-api-key: "injected-by-admin"} - id: response-guard file: plugins/response_guard.lua match: paths: ["/v1/chat/completions"] llm: # 漏写 guard_8b 的话,宿主不会给它起 adapter,复核会静默退化成单级 allow: [guard_model, guard_8b] config: model: guard_model review_model: guard_8b block_status: 400 stream_mode: incremental flush_chars: 512 force_flush_bytes: 4096 max_buffer_bytes: 65536 judge_chunk_bytes: 8192 check_input: true check_output: true block_controversial: true multiturn_context_bytes: 2048 - id: stream-redact enabled: false file: plugins/stream_redact.lua match: paths: ["/v1/chat/completions"] 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] "