Spaces:
Running
Running
Download scripts/preload_ollama_models.sh from Leon4gr45/brain: direct link, hf CLI and curl.
- Browser
- Download file 839 Bytes
-
https://huggingface.co/spaces/Leon4gr45/brain/resolve/main/scripts/preload_ollama_models.sh
- Command line
-
hf download hf://spaces/Leon4gr45/brain/scripts/preload_ollama_models.sh
-
curl -L -o preload_ollama_models.sh https://huggingface.co/spaces/Leon4gr45/brain/resolve/main/scripts/preload_ollama_models.sh
839 Bytes
| set -euo pipefail | |
| export OLLAMA_HOST=127.0.0.1:11434 | |
| export OLLAMA_MODELS=${OLLAMA_MODELS:-/opt/ollama-models} | |
| ollama serve > /tmp/ollama-preload.log 2>&1 & | |
| ollama_pid=$! | |
| trap 'kill "$ollama_pid" 2>/dev/null || true; wait "$ollama_pid" 2>/dev/null || true' EXIT | |
| ready=false | |
| for attempt in {1..60}; do | |
| if curl --noproxy '*' --fail --silent http://127.0.0.1:11434/api/version >/dev/null; then | |
| ready=true | |
| break | |
| fi | |
| if ! kill -0 "$ollama_pid" 2>/dev/null; then | |
| cat /tmp/ollama-preload.log >&2 | |
| exit 1 | |
| fi | |
| sleep 1 | |
| done | |
| if [ "$ready" != true ]; then | |
| echo 'Ollama did not become ready during model preload' >&2 | |
| exit 1 | |
| fi | |
| ollama pull "${OLLAMA_EMBEDDING_MODEL:-embeddinggemma-2:270m}" | |
| if [ -n "${OLLAMA_CHAT_MODEL:-}" ]; then | |
| ollama pull "${OLLAMA_CHAT_MODEL:-}" | |
| fi | |