Initial commit, first public version.

This commit is contained in:
ben
2025-01-12 14:37:13 +01:00
commit 778188ed95
18 changed files with 659 additions and 0 deletions

7
src/aichat/Dockerfile Normal file
View File

@@ -0,0 +1,7 @@
FROM rust:latest
RUN rustup target add x86_64-unknown-linux-musl
RUN apt update && apt install -y musl-tools musl-dev
RUN update-ca-certificates
RUN cargo install --target x86_64-unknown-linux-musl aichat

8
src/aichat/config.yaml Normal file
View File

@@ -0,0 +1,8 @@
# see https://github.com/sigoden/aichat/blob/main/config.example.yaml
model: ollama
clients:
- type: openai-compatible
name: ollama
api_base: http://localhost:11434/v1
api_key: __LLM_API_KEY__

View File

@@ -0,0 +1,12 @@
FROM debian:bookworm-slim
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update
RUN apt-get --yes -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confnew" install bash curl jq
ADD ./src/llm_provision/init_models.sh /init_models.sh
ADD ./src/llm_provision/entrypoint.sh /entrypoint.sh
RUN chmod 755 /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
#ENTRYPOINT ["tail", "-f", "/dev/null"] # to debug

View File

@@ -0,0 +1,4 @@
#!/usr/bin/env bash
echo "pull models into ollama volumes"
bash /init_models.sh

View File

@@ -0,0 +1,17 @@
#!/usr/bin/env bash
OLLAMA_HOST="http://ollama:11434"
IFS=',' read -r -a models_arr <<< "${MODELS}"
## now loop through the above array
for m in "${models_arr[@]}"
do
curl -s "${OLLAMA_HOST}/api/tags" | jq '.models[].name' | grep ${m} > /dev/null
if [[ $? -ne 0 ]]
then
curl -s "${OLLAMA_HOST}/api/pull" -d "{\"model\": \"${m}\"}"
else
echo "${m} already installed"
fi
done

61
src/nginx/nginx.conf Normal file
View File

@@ -0,0 +1,61 @@
events{}
http {
server_tokens off;
client_max_body_size 200m;
server {
listen 11434;
set $deny 1;
if ($http_authorization = "Bearer $API_KEY") {
set $deny 0;
}
if ($deny) {
return 403;
}
location / {
proxy_pass http://ollama:11434;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
server {
listen 8000;
set $deny 1;
if ($http_authorization = "Bearer $API_KEY") {
set $deny 0;
}
if ($deny) {
return 403;
}
location / {
proxy_pass http://openedai-speech:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
server {
listen 8001;
set $deny 1;
if ($http_authorization = "Bearer $API_KEY") {
set $deny 0;
}
if ($deny) {
return 403;
}
location / {
proxy_pass http://faster-whisper-server:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 180;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
}

47
src/tts/Dockerfile Normal file
View File

@@ -0,0 +1,47 @@
FROM python:3.11-slim
RUN --mount=type=cache,target=/root/.cache/pip pip install -U pip
ARG TARGETPLATFORM
RUN <<EOF
apt-get update
apt-get install --no-install-recommends -y curl ffmpeg git
if [ "$TARGETPLATFORM" != "linux/amd64" ]; then
apt-get install --no-install-recommends -y build-essential
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
fi
# for deepspeed support - image +7.5GB, over the 10GB ghcr.io limit, and no noticable gain in speed or VRAM usage?
#curl -O https://developer.download.nvidia.com/compute/cuda/repos/debian11/x86_64/cuda-keyring_1.1-1_all.deb
#dpkg -i cuda-keyring_1.1-1_all.deb
#rm cuda-keyring_1.1-1_all.deb
#apt-get install --no-install-recommends -y libaio-dev build-essential cuda-toolkit
apt-get clean
rm -rf /var/lib/apt/lists/*
EOF
#ENV CUDA_HOME=/usr/local/cuda
ENV PATH="/root/.cargo/bin:${PATH}"
WORKDIR /app
RUN mkdir -p voices config
ARG USE_ROCM
ENV USE_ROCM=${USE_ROCM}
RUN git clone https://github.com/matatonic/openedai-speech.git /tmp/app
RUN mv /tmp/app/* /app/
ADD src/tts/download_voices_tts-1.sh /app/download_voices_tts-1.sh
ADD src/tts/voice_to_speaker.default.yaml /app/voice_to_speaker.default.yaml
RUN if [ "${USE_ROCM}" = "1" ]; then mv /app/requirements-rocm.txt /app/requirements.txt; fi
RUN --mount=type=cache,target=/root/.cache/pip pip install -r requirements.txt
ARG PRELOAD_MODEL
ENV PRELOAD_MODEL=${PRELOAD_MODEL}
ENV TTS_HOME=voices
ENV HF_HOME=voices
ENV COQUI_TOS_AGREED=1
CMD bash startup.sh

View File

@@ -0,0 +1,8 @@
#!/bin/sh
# cat voice_to_speaker.default.yaml | yq '.tts-1 ' | grep mode | cut -d'/' -f2 | cut -d'.' -f1 | sort -u | xargs
models=${*:-"en_GB-alba-medium en_GB-northern_english_male-medium en_US-bryce-medium en_US-john-medium en_US-libritts_r-medium en_US-ryan-high fr_FR-siwis-medium fr_FR-tom-medium fr_FR-upmc-medium"}
piper --update-voices --data-dir voices --download-dir voices --model x 2> /dev/null
for i in $models ; do
[ ! -e "voices/$i.onnx" ] && piper --data-dir voices --download-dir voices --model $i < /dev/null > /dev/null
done

View File

@@ -0,0 +1,36 @@
# Use https://rhasspy.github.io/piper-samples/ to configure
tts-1:
alloy:
model: voices/en_US-libritts_r-medium.onnx
speaker: 79
siwis:
model: voices/fr_FR-siwis-medium.onnx
speaker: 0
tom:
model: voices/fr_FR-tom-medium.onnx
speaker: 0
pierre:
model: voices/fr_FR-upmc-medium.onnx
speaker: 1
jessica:
model: voices/fr_FR-upmc-medium.onnx
speaker: 0
alba:
model: voices/en_GB-alba-medium.onnx
speaker: 0
jack:
model: voices/en_GB-northern_english_male-medium.onnx
speaker: 0
john:
model: voices/en_US-john-medium.onnx
speaker: 0
bryce:
model: voices/en_US-bryce-medium.onnx
speaker: 0
ryan:
model: voices/en_US-ryan-high.onnx
speaker: 0
echo:
model: voices/en_US-libritts_r-medium.onnx
speaker: 134

13
src/whisper/Dockerfile Normal file
View File

@@ -0,0 +1,13 @@
FROM debian:bookworm-slim
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
sudo \
python3 \
python3-distutils \
python3-pip \
ffmpeg
RUN pip install -U openai-whisper --break-system-packages
WORKDIR /app
CMD ["whisper"]