Improve verify auto-detection without docker

This commit is contained in:
2026-10-26 17:01:28 +08:00
parent 9000c3ab0e
commit 4857faec4e

View File

@@ -106,17 +106,45 @@ for m in mounts:
fi
# ---------------------------------------------------------------- model dir
if [[ -z "${MODEL_DIR}" ]]; then
for candidate in \
"/mnt/disk0/models/LLM-Research/Llama-4-Scout-17B-16E-Instruct" \
"/mnt/disk0/models/LLM-Research/Llama-4-Maverick-17B-128E-Instruct-FP8"; do
if [[ -f "${candidate}/config.json" ]]; then
MODEL_DIR="${candidate}"
SCOUT_DEFAULT="/mnt/disk0/models/LLM-Research/Llama-4-Scout-17B-16E-Instruct"
MAVERICK_DEFAULT="/mnt/disk0/models/LLM-Research/Llama-4-Maverick-17B-128E-Instruct-FP8"
# 没有 docker 时(例如在 ugly_hopper 内运行),按端口探测正在运行的服务。
if [[ -z "${CONTAINER}" && -z "${PORT}" && -z "${MODEL_DIR}" && -z "${BASE_URL}" ]]; then
for candidate_port in 8091 8092; do
if curl -fsS --max-time 2 "http://127.0.0.1:${candidate_port}/health" >/dev/null 2>&1; then
PORT="${candidate_port}"
break
fi
done
fi
# 从 served name 反推模型目录(方便 --base-url + --served-name 的用法)。
if [[ -z "${MODEL_DIR}" && -n "${SERVED_NAME}" ]]; then
case "${SERVED_NAME}" in
*maverick*)
if [[ -f "${MAVERICK_DEFAULT}/config.json" ]]; then
MODEL_DIR="${MAVERICK_DEFAULT}"
fi
;;
*scout*)
if [[ -f "${SCOUT_DEFAULT}/config.json" ]]; then
MODEL_DIR="${SCOUT_DEFAULT}"
fi
;;
esac
fi
if [[ -z "${MODEL_DIR}" && -z "${BASE_URL}" ]]; then
if [[ "${PORT}" == "8092" && -f "${MAVERICK_DEFAULT}/config.json" ]]; then
MODEL_DIR="${MAVERICK_DEFAULT}"
elif [[ -f "${SCOUT_DEFAULT}/config.json" ]]; then
MODEL_DIR="${SCOUT_DEFAULT}"
elif [[ -f "${MAVERICK_DEFAULT}/config.json" ]]; then
MODEL_DIR="${MAVERICK_DEFAULT}"
fi
fi
DETECT_JSON=""
if [[ -n "${MODEL_DIR}" ]]; then
if [[ -f "${MODEL_DIR}/config.json" ]]; then