Spaces:
Runtime error
Runtime error
Use llama.cpp
Browse files- Dockerfile +10 -10
- README.md +1 -0
- index.html +1 -1
- start-services.sh +5 -10
Dockerfile
CHANGED
|
@@ -21,8 +21,17 @@ RUN apt-get update && apt-get install -y \
|
|
| 21 |
clang \
|
| 22 |
cuda-toolkit \
|
| 23 |
nginx \
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
&& rm -rf /var/lib/apt/lists/*
|
| 25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
# Install Node.js and pnpm
|
| 27 |
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
|
| 28 |
apt-get update && \
|
|
@@ -34,12 +43,11 @@ RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
|
|
| 34 |
RUN corepack enable && corepack prepare pnpm@latest --activate
|
| 35 |
|
| 36 |
# Create directories and set permissions
|
| 37 |
-
RUN mkdir -p /tmp/
|
| 38 |
mkdir -p $HOME/models && \
|
| 39 |
mkdir -p $HOME/app && \
|
| 40 |
mkdir -p $HOME/app/docauth && \
|
| 41 |
mkdir -p $HOME/app/aia && \
|
| 42 |
-
mkdir -p $HOME/.llamafile && \
|
| 43 |
mkdir -p /var/cache/nginx && \
|
| 44 |
mkdir -p /var/log/nginx && \
|
| 45 |
mkdir -p /var/lib/nginx && \
|
|
@@ -52,14 +60,6 @@ RUN mkdir -p /tmp/llamafile && \
|
|
| 52 |
chown -R user:user /var/run/nginx.pid && \
|
| 53 |
chown -R user:user /run/nginx
|
| 54 |
|
| 55 |
-
# Install llamafiler
|
| 56 |
-
RUN cd /tmp/llamafile && \
|
| 57 |
-
wget --no-check-certificate https://github.com/Mozilla-Ocho/llamafile/releases/download/0.8.17/llamafile-0.8.17.zip && \
|
| 58 |
-
unzip llamafile-0.8.17.zip && \
|
| 59 |
-
cp llamafile-0.8.17/bin/llamafiler /usr/local/bin/ && \
|
| 60 |
-
chmod +x /usr/local/bin/llamafiler && \
|
| 61 |
-
rm -rf /tmp/llamafile
|
| 62 |
-
|
| 63 |
# Copy AI Assistant app
|
| 64 |
COPY --from=pspdfkit/ai-assistant:nightly /base $HOME/app/aia
|
| 65 |
COPY --chown=node:node service-config.yml /service-config.yml
|
|
|
|
| 21 |
clang \
|
| 22 |
cuda-toolkit \
|
| 23 |
nginx \
|
| 24 |
+
build-essential \
|
| 25 |
+
cmake \
|
| 26 |
+
git \
|
| 27 |
+
libcurl4-openssl-dev \
|
| 28 |
&& rm -rf /var/lib/apt/lists/*
|
| 29 |
|
| 30 |
+
# Copy llama.cpp server files from official image
|
| 31 |
+
COPY --from=ghcr.io/ggerganov/llama.cpp:server-cuda /app/llama-server $HOME/app/llama-server
|
| 32 |
+
COPY --from=ghcr.io/ggerganov/llama.cpp:server-cuda /app/*.so* $HOME/app/
|
| 33 |
+
RUN chmod +x $HOME/app/llama-server
|
| 34 |
+
|
| 35 |
# Install Node.js and pnpm
|
| 36 |
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
|
| 37 |
apt-get update && \
|
|
|
|
| 43 |
RUN corepack enable && corepack prepare pnpm@latest --activate
|
| 44 |
|
| 45 |
# Create directories and set permissions
|
| 46 |
+
RUN mkdir -p /tmp/llamacpp && \
|
| 47 |
mkdir -p $HOME/models && \
|
| 48 |
mkdir -p $HOME/app && \
|
| 49 |
mkdir -p $HOME/app/docauth && \
|
| 50 |
mkdir -p $HOME/app/aia && \
|
|
|
|
| 51 |
mkdir -p /var/cache/nginx && \
|
| 52 |
mkdir -p /var/log/nginx && \
|
| 53 |
mkdir -p /var/lib/nginx && \
|
|
|
|
| 60 |
chown -R user:user /var/run/nginx.pid && \
|
| 61 |
chown -R user:user /run/nginx
|
| 62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
# Copy AI Assistant app
|
| 64 |
COPY --from=pspdfkit/ai-assistant:nightly /base $HOME/app/aia
|
| 65 |
COPY --chown=node:node service-config.yml /service-config.yml
|
README.md
CHANGED
|
@@ -6,6 +6,7 @@ colorTo: yellow
|
|
| 6 |
sdk: docker
|
| 7 |
pinned: false
|
| 8 |
short_description: A WYSIWYG editor that translates text to multiple languages.
|
|
|
|
| 9 |
---
|
| 10 |
|
| 11 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 6 |
sdk: docker
|
| 7 |
pinned: false
|
| 8 |
short_description: A WYSIWYG editor that translates text to multiple languages.
|
| 9 |
+
startup_duration_timeout: 1h
|
| 10 |
---
|
| 11 |
|
| 12 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
|
@@ -207,7 +207,7 @@
|
|
| 207 |
<body>
|
| 208 |
<div id="loadingOverlay">
|
| 209 |
<div id="loadingSpinner"></div>
|
| 210 |
-
<div id="loadingMessage">Initializing AI models... This may take
|
| 211 |
</div>
|
| 212 |
<div id="app">
|
| 213 |
<div style="height: 100vh; display: flex; flex-direction: column;">
|
|
|
|
| 207 |
<body>
|
| 208 |
<div id="loadingOverlay">
|
| 209 |
<div id="loadingSpinner"></div>
|
| 210 |
+
<div id="loadingMessage">Initializing AI models... This may take a while.</div>
|
| 211 |
</div>
|
| 212 |
<div id="app">
|
| 213 |
<div style="height: 100vh; display: flex; flex-direction: column;">
|
start-services.sh
CHANGED
|
@@ -27,10 +27,10 @@ echo "Nginx started successfully"
|
|
| 27 |
|
| 28 |
# Start the models
|
| 29 |
echo "Starting models..."
|
| 30 |
-
TMPDIR=/tmp/
|
| 31 |
GEMMA_PID=$!
|
| 32 |
|
| 33 |
-
TMPDIR=/tmp/
|
| 34 |
EMBEDDINGS_PID=$!
|
| 35 |
|
| 36 |
# Wait for models to be ready
|
|
@@ -39,15 +39,10 @@ START_TIME=$SECONDS
|
|
| 39 |
TIMEOUT=600 # 10 minutes
|
| 40 |
|
| 41 |
wait_for_models() {
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
-d '{"model":"gemma-2b","messages":[{"role":"user","content":"test"}]}')
|
| 45 |
|
| 46 |
-
|
| 47 |
-
-H "Content-Type: application/json" \
|
| 48 |
-
-d '{"input":"test"}')
|
| 49 |
-
|
| 50 |
-
[[ "$CHAT_TEST" == *"content"* ]] && [[ "$EMBED_TEST" == *"embedding"* ]]
|
| 51 |
}
|
| 52 |
|
| 53 |
until wait_for_models; do
|
|
|
|
| 27 |
|
| 28 |
# Start the models
|
| 29 |
echo "Starting models..."
|
| 30 |
+
TMPDIR=/tmp/llamacpp ./llama-server -m $HOME/models/gemma-2b.gguf -ngl 999 --host 0.0.0.0 --port 8082 &
|
| 31 |
GEMMA_PID=$!
|
| 32 |
|
| 33 |
+
TMPDIR=/tmp/llamacpp ./llama-server --embedding -m $HOME/models/embeddings.gguf -ngl 999 --host 0.0.0.0 --port 8081 &
|
| 34 |
EMBEDDINGS_PID=$!
|
| 35 |
|
| 36 |
# Wait for models to be ready
|
|
|
|
| 39 |
TIMEOUT=600 # 10 minutes
|
| 40 |
|
| 41 |
wait_for_models() {
|
| 42 |
+
CHAT_HEALTH=$(curl -s http://127.0.0.1:8082/health)
|
| 43 |
+
EMBED_HEALTH=$(curl -s http://127.0.0.1:8081/health)
|
|
|
|
| 44 |
|
| 45 |
+
[[ "$CHAT_HEALTH" == *"\"status\":\"ok\""* ]] && [[ "$EMBED_HEALTH" == *"\"status\":\"ok\""* ]]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
}
|
| 47 |
|
| 48 |
until wait_for_models; do
|