Skip to content

Commit

Permalink
Merge pull request #7 from Mugen0815/main
Browse files Browse the repository at this point in the history
Check, if model exists locally, before download
  • Loading branch information
3x3cut0r authored Mar 4, 2024
2 parents c75b63a + dcb26ad commit 0bdf36f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
14 changes: 7 additions & 7 deletions llama-cpp-python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ docker run -d \
docker run -d \
--name llama-cpp-python \
--cap-add SYS_RESOURCE \
-e MODEL_DOWNLOAD="False \
-e MODEL_DOWNLOAD="False" \
-v /path/to/your/model/mistral-7b-instruct-v0.2.Q4_K_M.gguf:/model/mistral-7b-instruct-v0.2.Q4_K_M.gguf \
-p 8000:8000/tcp \
3x3cut0r/llama-cpp-python:latest \
Expand All @@ -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 0bdf36f

Please sign in to comment.