fix(deploy): _inst.sh 补全 ai_review/aibox/redirect80; ai_review 模型走 ModelScope 镜像
- _inst.sh: 补入遗漏的 3 个模块(confs 之后、core 之前) - ai_review/_fetch_onnx_model.sh: 新增 chromadb onnx 模型预下载脚本 (默认 ModelScope 镜像,支持 ONNX_MODEL_BASE_URL/CHROMA_CACHE_DIR 覆盖, 断点续传+幂等,绕过 chromadb 写死的 AWS S3 下载) - ai_review/_set.sh: 安装后自动调用模型下载 - README.md: 更新部署说明 - docs/reviews/DEPLOY_DEFECT_AUDIT_20260806.md: 新增部署缺陷审查报告 - docs/INDEX.md: 登记审查报告
This commit is contained in:
1 parent
ea2717c400
commit
49ed3f738f
6 files changed
+173
-1
No files matched your search
Executable
+68
@@ -0,0 +1,68 @@
|
||||
#!/bin/bash
|
||||
# ============================================================
|
||||
# _fetch_onnx_model.sh — 预下载 chromadb ONNX 嵌入模型
|
||||
# ------------------------------------------------------------
|
||||
# chromadb 默认从 AWS S3 拉取 all-MiniLM-L6-v2 (onnx.tar.gz),
|
||||
# 国内直连极慢(~18KB/s)且失败会导致 ai_review 无法启动。
|
||||
# 本脚本改为从 ModelScope 镜像逐个下载 chroma 所需的 6 个文件,
|
||||
# 放到 chromadb 的缓存目录,跳过其内置下载逻辑。
|
||||
#
|
||||
# 可配置:
|
||||
# ONNX_MODEL_BASE_URL 模型仓库 base URL(默认 ModelScope 镜像)
|
||||
# CHROMA_CACHE_DIR chroma 缓存根目录(默认 $HOME/.cache/chroma)
|
||||
# ============================================================
|
||||
set -uo pipefail
|
||||
|
||||
CACHE_ROOT="${CHROMA_CACHE_DIR:-$HOME/.cache/chroma}"
|
||||
DEST_DIR="$CACHE_ROOT/onnx_models/all-MiniLM-L6-v2/onnx"
|
||||
BASE_URL="${ONNX_MODEL_BASE_URL:-https://modelscope.cn/models/AI-ModelScope/all-MiniLM-L6-v2/resolve/master}"
|
||||
|
||||
# chromadb ONNXMiniLM_L6_V2._download_model_if_not_exists 检查的文件
|
||||
FILES=(
|
||||
"config.json"
|
||||
"model.onnx"
|
||||
"special_tokens_map.json"
|
||||
"tokenizer_config.json"
|
||||
"tokenizer.json"
|
||||
"vocab.txt"
|
||||
)
|
||||
|
||||
echo "[fetch-onnx] 目标目录: $DEST_DIR"
|
||||
mkdir -p "$DEST_DIR"
|
||||
|
||||
# 已有完整模型则跳过
|
||||
need=0
|
||||
for f in "${FILES[@]}"; do
|
||||
[ -s "$DEST_DIR/$f" ] || need=1
|
||||
done
|
||||
if [ "$need" = "0" ]; then
|
||||
echo "[fetch-onnx] 模型已存在,跳过下载"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
fail=0
|
||||
for f in "${FILES[@]}"; do
|
||||
if [ -s "$DEST_DIR/$f" ]; then
|
||||
echo "[fetch-onnx] $f 已存在,跳过"
|
||||
continue
|
||||
fi
|
||||
# model.onnx 在仓库 onnx/ 子目录,其余在根目录
|
||||
if [ "$f" = "model.onnx" ]; then
|
||||
url="$BASE_URL/onnx/$f"
|
||||
else
|
||||
url="$BASE_URL/$f"
|
||||
fi
|
||||
echo "[fetch-onnx] 下载 $f <- $url"
|
||||
if ! curl -fsSL --retry 3 --connect-timeout 15 -o "$DEST_DIR/$f" "$url"; then
|
||||
echo "[fetch-onnx] ⚠ 下载 $f 失败" >&2
|
||||
fail=1
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$fail" = "1" ]; then
|
||||
echo "[fetch-onnx] ⚠ 部分文件下载失败,ai_review 启动时 chromadb 会尝试原 S3 下载" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[fetch-onnx] ✅ 完成,文件清单:"
|
||||
ls -la "$DEST_DIR"
|
||||
@@ -4,5 +4,9 @@ python3 -m venv venv
|
||||
#sudo chmod +x .env/bin/activate
|
||||
source venv/bin/activate
|
||||
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
|
||||
|
||||
# 预下载 chromadb ONNX 嵌入模型(默认 ModelScope 镜像,避免 AWS S3 国内直连超时)
|
||||
# 可用 ONNX_MODEL_BASE_URL 覆盖镜像源;失败不阻塞安装,但 ai_review 启动时可能需手动处理
|
||||
bash _fetch_onnx_model.sh || echo "⚠ onnx 模型下载失败,可稍后重跑 bash _fetch_onnx_model.sh"
|
||||
#nuitka --onefile --jobs=1 dnfs.py
|
||||
|
||||
Reference in new issue
Block a user