镜像与构建 - 六阶段 Dockerfile(base/wheels/deps/manifest/core|guard),core 不含 torch - 构建期自证:gen_manifest --strict 拦未登记模块,core 阶段重算 sha256 - compose 四服务 host 网络(llm.url 强制回环),config.core/local 可挂载覆盖 无 docker 环境的四段链路 - pull_oci_image.py 直拉 OCI 镜像 rootfs(纯标准库,走加速器) - replay_image_build.sh 按 stage chroot 重放 Dockerfile - run_image_chroot.sh 等价 docker run(uid 10001 + 入口 + host 网络) - pack_image.py 封成 docker save 格式包,自带 diff_id 校验 交付 - make_package.sh 生成自包含目录:镜像包 + 溯源清单 + 构建输入 + 脚本 + 源码快照 - 文档:从零复现指南、docker 打包方案、镜像构建限制与替代方案、交付包 README 命名 - Qwen 品牌名统一替换为 large_model / small_model / large_model_guard, 覆盖 vLLM 服务名、模型目录、配置、脚本、测试与文档 - 模型架构字段(architectures / model_type / tokenizer_class)属上游定义, 改名会导致加载失败,保留原值;check_local_model.py 的架构判断同理 验证:smoke 6/6;test.py 20 通过 0 失败 1 警告;gen --strict 67 文件 / 22 进镜像
123 lines
3.5 KiB
YAML
123 lines
3.5 KiB
YAML
# 容器内配置(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] "
|