From e8d2d928ac19f1c53801069eaa84fdbf370943c2 Mon Sep 17 00:00:00 2001 From: Mugen0815 Date: Sun, 3 Mar 2024 01:44:34 +0100 Subject: [PATCH] ADDED: check, if model exists before download --- llama-cpp-python/README.md | 12 ++++++------ llama-cpp-python/docker-entrypoint.sh | 12 +++++++----- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/llama-cpp-python/README.md b/llama-cpp-python/README.md index a144eb3..5c01312 100644 --- a/llama-cpp-python/README.md +++ b/llama-cpp-python/README.md @@ -101,7 +101,7 @@ docker run --rm \ ### 1.2 docker-compose.yml -```shell +```yaml version: '3.9' services: @@ -111,11 +111,11 @@ services: cap_add: - SYS_RESOURCE environment: - MODEL_DOWNLOAD="True" \ - MODEL_REPO="TheBloke/Mistral-7B-Instruct-v0.2-GGUF" \ - MODEL="mistral-7b-instruct-v0.2.Q4_K_M.gguf" \ - MODEL_ALIAS="mistral-7b-instruct" \ - CHAT_FORMAT="mistral" \ + MODEL_DOWNLOAD: "True" + MODEL_REPO: "TheBloke/Mistral-7B-Instruct-v0.2-GGUF" + MODEL: "mistral-7b-instruct-v0.2.Q4_K_M.gguf" + MODEL_ALIAS: "mistral-7b-instruct" + CHAT_FORMAT: "mistral" ports: - 8000:8000/tcp ``` diff --git a/llama-cpp-python/docker-entrypoint.sh b/llama-cpp-python/docker-entrypoint.sh index bdfd919..0d86c86 100644 --- a/llama-cpp-python/docker-entrypoint.sh +++ b/llama-cpp-python/docker-entrypoint.sh @@ -24,11 +24,13 @@ ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone # download model if [ "$MODEL_REPO" != "local" ] && { [ "$MODEL_DOWNLOAD" = "True" ] || [ "$MODEL_DOWNLOAD" = "true" ] || [ "$MODEL_DOWNLOAD" = "TRUE" ]; }; then - if [ "$QUIET" != "true" ]; then - echo -e "\nINFO: downloading model from repository ${MODEL_REPO:-'TheBloke/Llama-2-7B-Chat-GGUF'}\n" - fi - mkdir -p "${MODEL_PATH}" - /venv/bin/huggingface-cli download --repo-type model --local-dir="${MODEL_PATH}" --local-dir-use-symlinks=False --resume-download --token="${HF_TOKEN:-''}" "${MODEL_REPO}" "${MODEL}" + if [ ! -e "${MODEL_PATH}"/"${MODEL}" ]; then + if [ "$QUIET" != "true" ]; then + echo -e "\nINFO: downloading model from repository ${MODEL_REPO:-'TheBloke/Llama-2-7B-Chat-GGUF'}\n" + fi + mkdir -p "${MODEL_PATH}" + /venv/bin/huggingface-cli download --repo-type model --local-dir="${MODEL_PATH}" --local-dir-use-symlinks=False --resume-download --token="${HF_TOKEN:-''}" "${MODEL_REPO}" "${MODEL}" + fi fi # if started without args, run app.py