Files
DronePlanningV2/run_api.sh
2026-03-23 20:26:13 +08:00

40 lines
1.4 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# 启动 LLM 服务 + DronePlanning API
# - Chat 模型8081
# - Embedding 模型8090
# - API8000
cd "$(dirname "$0")"
# llama-server 所在目录(可在该目录下启动模型)
LLAMA_BIN_DIR="${LLAMA_BIN_DIR:-$HOME/llama.cpp/build/bin}"
# 强制关闭 thinking传递给 Python 侧 LLM 客户端)
export ENABLE_THINKING=false
cleanup() {
echo ""
echo "正在停止服务..."
kill $LLAMA_CHAT_PID $LLAMA_EMBED_PID 2>/dev/null
exit 0
}
trap cleanup SIGINT SIGTERM
# 启动 Chat 模型 (8081)
# --reasoning-budget 0强制关闭 Qwen3 思考模式,否则会生成大量 <think> 导致首层 Router 极慢(数分钟)
echo "=== 启动 LLM Chat 服务 (端口 8081) ==="
(cd "$LLAMA_BIN_DIR" && ./llama-server -m ~/models/gguf/Qwen3/Qwen3-4B/Qwen3-4B-Q5_K_M.gguf --port 8081 --gpu_layers 36 --host 0.0.0.0 --ctx_size 16384 --reasoning-budget 0) &
LLAMA_CHAT_PID=$!
# 启动 Embedding 模型 (8090)
echo "=== 启动 LLM Embedding 服务 (端口 8090) ==="
(cd "$LLAMA_BIN_DIR" && ./llama-server -m ~/models/gguf/Qwen3/Qwen3-Embedding-4B/Qwen3-Embedding-4B-Q5_K_M.gguf --gpu_layers 36 --embeddings --port 8090 --host 0.0.0.0) &
LLAMA_EMBED_PID=$!
# 等待 LLM 服务就绪
echo "等待 LLM 服务启动..."
sleep 8
# 启动 DronePlanning API (8000)
echo "=== 启动 DronePlanning API (端口 8000) ==="
PYTHONPATH="$(pwd)/src:$PYTHONPATH" python -m uvicorn main:app --reload --host 0.0.0.0 --port 8000