aphisit.t Claude Sonnet 4.6 commited on
Commit
a11d46a
·
1 Parent(s): 45a9e51

feat: stable final version with pinned deps and MODEL_URL env var

Browse files

- Add requirements.txt with pinned llama-cpp-python[server]==0.2.90, pydantic<2
- Dockerfile uses requirements.txt + cmake/build-essential, start.sh as entrypoint
- start.sh downloads via MODEL_URL env var with curl, skips if exists
- Add .huggingface.yml with sdk: docker

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Files changed (4) hide show
  1. .huggingface.yml +1 -0
  2. Dockerfile +11 -24
  3. requirements.txt +4 -0
  4. start.sh +15 -9
.huggingface.yml ADDED
@@ -0,0 +1 @@
 
 
1
+ sdk: docker
Dockerfile CHANGED
@@ -2,35 +2,22 @@ FROM python:3.10-slim
2
 
3
  ENV DEBIAN_FRONTEND=noninteractive
4
  ENV PYTHONUNBUFFERED=1
 
5
 
6
  RUN apt-get update && apt-get install -y --no-install-recommends \
7
  curl \
8
- && rm -rf /var/lib/apt/lists/*
 
 
9
 
10
- RUN pip install --no-cache-dir \
11
- huggingface-hub \
12
- uvicorn \
13
- fastapi \
14
- sse-starlette \
15
- pydantic-settings \
16
- starlette-context
17
 
18
- RUN pip install --no-cache-dir \
19
- llama-cpp-python \
20
- --index-url https://abetlen.github.io/llama-cpp-python/whl/cpu
 
 
21
 
22
  EXPOSE 7860
23
 
24
- CMD bash -c "mkdir -p /models && \
25
- echo 'Downloading model...' && \
26
- curl -L \
27
- -H 'Authorization: Bearer '\"${HF_TOKEN}\" \
28
- 'https://huggingface.co/bldeaw/guardrails_typhoon25_q4_k_m/resolve/main/guardrails_typhoon25_q4_k_m.gguf' \
29
- -o /models/model.gguf && \
30
- echo 'Starting server...' && \
31
- python -m llama_cpp.server \
32
- --model /models/model.gguf \
33
- --host 0.0.0.0 \
34
- --port 7860 \
35
- --n_ctx 512 \
36
- --n_threads 2"
 
2
 
3
  ENV DEBIAN_FRONTEND=noninteractive
4
  ENV PYTHONUNBUFFERED=1
5
+ ENV PIP_NO_CACHE_DIR=1
6
 
7
  RUN apt-get update && apt-get install -y --no-install-recommends \
8
  curl \
9
+ build-essential \
10
+ cmake \
11
+ && rm -rf /var/lib/apt/lists/*
12
 
13
+ WORKDIR /app
 
 
 
 
 
 
14
 
15
+ COPY requirements.txt .
16
+ RUN pip install -r requirements.txt
17
+
18
+ COPY start.sh .
19
+ RUN chmod +x start.sh
20
 
21
  EXPOSE 7860
22
 
23
+ CMD ["./start.sh"]
 
 
 
 
 
 
 
 
 
 
 
 
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ llama-cpp-python[server]==0.2.90
2
+ pydantic<2
3
+ fastapi<0.111
4
+ uvicorn<0.30
start.sh CHANGED
@@ -1,18 +1,24 @@
1
  #!/bin/bash
2
  set -e
3
 
4
- mkdir -p /models
 
5
 
6
- echo "Downloading model..."
7
- huggingface-cli download bldeaw/guardrails_typhoon25_q4_k_m \
8
- guardrails_typhoon25_q4_k_m.gguf \
9
- --local-dir /models \
10
- --token "${HF_TOKEN}"
 
 
 
 
 
 
11
 
12
- echo "Starting llama-cpp-python server..."
13
  python -m llama_cpp.server \
14
- --model /models/guardrails_typhoon25_q4_k_m.gguf \
15
  --host 0.0.0.0 \
16
  --port 7860 \
17
- --n_ctx 512 \
18
  --n_threads 2
 
1
  #!/bin/bash
2
  set -e
3
 
4
+ MODEL_DIR=/models
5
+ MODEL_FILE=typhoon.gguf
6
 
7
+ mkdir -p $MODEL_DIR
8
+
9
+ if [ ! -f "$MODEL_DIR/$MODEL_FILE" ]; then
10
+ echo "Downloading model..."
11
+ curl -L "$MODEL_URL" -o "$MODEL_DIR/$MODEL_FILE"
12
+ echo "✓ Downloaded"
13
+ else
14
+ echo "✓ Model already exists"
15
+ fi
16
+
17
+ echo "Starting server..."
18
 
 
19
  python -m llama_cpp.server \
20
+ --model $MODEL_DIR/$MODEL_FILE \
21
  --host 0.0.0.0 \
22
  --port 7860 \
23
+ --n_ctx 1024 \
24
  --n_threads 2