freestream / scripts /serve_local_llm.sh
LoveLogicAI's picture
Mac mini: MLX/llama.cpp server launcher
1d72527 verified
Raw History Blame Contribute Delete
1.05 kB
#!/bin/sh
# FREESTREAM sovereign LLM server on the mac mini.
# ./serve_local_llm.sh mlx -> MLX (Apple Silicon native, fastest on M-series)
# ./serve_local_llm.cpp -> llama.cpp (brew install llama.cpp)
# Both expose OpenAI-compatible APIs; point FREESTREAM at:
# export FREESTREAM_LLM_BASE_URL=http://localhost:8080/v1
# export FREESTREAM_LLM_MODEL=local
# export FREESTREAM_AGENT=llm
set -e
MODE="${1:-mlx}"
PORT="${PORT:-8080}"
case "$MODE" in
mlx)
# python3.10+ with Apple Silicon; 4-bit quant runs fast on M-series
pip install -q "mlx-lm>=0.19" || true
exec python -m mlx_lm.server \
--model "${MODEL:-mlx-community/Qwen2.5-7B-Instruct-4bit}" \
--host 0.0.0.0 --port "$PORT"
;;
cpp)
# brew install llama.cpp
exec llama-server \
-hf "${MODEL_HF:-bartowski/Qwen2.5-7B-Instruct-GGUF:Q4_K_M}" \
--host 0.0.0.0 --port "$PORT" \
-c "${CONTEXT_SIZE:-4096}" ${API_KEY:+--api-key "$API_KEY"}
;;
*)
echo "usage: serve_local_llm.sh [mlx|cpp]" >&2
exit 2
;;
esac