Skip to content

Commit

Permalink
ADDED: check, if model exists before download
Browse files Browse the repository at this point in the history
  • Loading branch information
Mugen0815 committed Mar 3, 2024
1 parent c75b63a commit e8d2d92
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
12 changes: 6 additions & 6 deletions llama-cpp-python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ docker run --rm \
### 1.2 docker-compose.yml <a name="docker-compose"></a>
```shell
```yaml
version: '3.9'
services:
Expand All @@ -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
```
Expand Down
12 changes: 7 additions & 5 deletions llama-cpp-python/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e8d2d92

Please sign in to comment.