Expose OpenAI API compatibility using aichat
This commit is contained in:
@@ -54,10 +54,21 @@ services:
|
|||||||
links:
|
links:
|
||||||
- ollama
|
- ollama
|
||||||
|
|
||||||
aichat-build:
|
aichat:
|
||||||
build:
|
build:
|
||||||
dockerfile: src/aichat/Dockerfile
|
dockerfile: src/aichat/Dockerfile
|
||||||
restart: no
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
- API_KEY=${LLM_API_KEY}
|
||||||
|
depends_on:
|
||||||
|
- ollama
|
||||||
|
links:
|
||||||
|
- ollama
|
||||||
|
healthcheck:
|
||||||
|
test: timeout 10s bash -c ':> /dev/tcp/127.0.0.1/8000' || exit 1
|
||||||
|
interval: 30s
|
||||||
|
timeout: 15s
|
||||||
|
retries: 3
|
||||||
|
|
||||||
faster-whisper-server:
|
faster-whisper-server:
|
||||||
image: fedirz/faster-whisper-server:latest-cuda
|
image: fedirz/faster-whisper-server:latest-cuda
|
||||||
@@ -74,7 +85,7 @@ services:
|
|||||||
capabilities: [gpu]
|
capabilities: [gpu]
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: timeout 10s bash -c ':> /dev/tcp/127.0.0.1/8000' || exit 1
|
test: curl --fail http://localhost:8000 || exit 1
|
||||||
interval: 30s
|
interval: 30s
|
||||||
timeout: 15s
|
timeout: 15s
|
||||||
retries: 3
|
retries: 3
|
||||||
@@ -90,14 +101,17 @@ services:
|
|||||||
- openedai-speech
|
- openedai-speech
|
||||||
- faster-whisper-server
|
- faster-whisper-server
|
||||||
- ollama
|
- ollama
|
||||||
|
- aichat
|
||||||
links:
|
links:
|
||||||
- ollama
|
- ollama
|
||||||
- faster-whisper-server
|
- faster-whisper-server
|
||||||
- openedai-speech
|
- openedai-speech
|
||||||
|
- aichat
|
||||||
ports:
|
ports:
|
||||||
- "11434:11434"
|
- "11434:11434"
|
||||||
- "8000:8000"
|
- "8000:8000"
|
||||||
- "8001:8001"
|
- "8001:8001"
|
||||||
|
- "8002:8002"
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ cd "$SCRIPTPATH" || exit
|
|||||||
if [[ ! -x $(command -v aichat) ]]; then
|
if [[ ! -x $(command -v aichat) ]]; then
|
||||||
echo "aichat is not installed."
|
echo "aichat is not installed."
|
||||||
if [[ $(docker images -q aichat-build 2>/dev/null) ]]; then
|
if [[ $(docker images -q aichat-build 2>/dev/null) ]]; then
|
||||||
container_id=$(docker create "aichat-build")
|
container_id=$(docker create "aichat")
|
||||||
docker cp "${container_id}:/usr/local/cargo/bin/aichat" "./tools/"
|
docker cp "${container_id}:/usr/local/cargo/bin/aichat" "./tools/"
|
||||||
docker rm "${container_id}"
|
docker rm "${container_id}"
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -1,7 +1,14 @@
|
|||||||
FROM rust:latest
|
FROM rust:latest
|
||||||
|
|
||||||
RUN rustup target add x86_64-unknown-linux-musl
|
RUN rustup target add x86_64-unknown-linux-musl
|
||||||
RUN apt update && apt install -y musl-tools musl-dev
|
RUN apt update && apt install -y musl-tools musl-dev curl
|
||||||
RUN update-ca-certificates
|
RUN update-ca-certificates
|
||||||
|
|
||||||
RUN cargo install --target x86_64-unknown-linux-musl aichat
|
RUN cargo install --target x86_64-unknown-linux-musl aichat
|
||||||
|
|
||||||
|
ADD src/aichat/entrypoint.sh /entrypoint.sh
|
||||||
|
ADD src/aichat/config.yaml /aichat_config_tpl.yaml
|
||||||
|
|
||||||
|
RUN chmod 755 entrypoint.sh
|
||||||
|
|
||||||
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
|
|||||||
4
src/aichat/entrypoint.sh
Normal file
4
src/aichat/entrypoint.sh
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
mkdir -p ~/.config/aichat
|
||||||
|
cat /aichat_config_tpl.yaml | sed "s/__LLM_API_KEY__/${LLM_API_KEY}/" | sed "s/localhost/ollama/" >~/.config/aichat/config.yaml
|
||||||
|
aichat --serve 0.0.0.0
|
||||||
@@ -58,4 +58,21 @@ http {
|
|||||||
proxy_set_header Connection "upgrade";
|
proxy_set_header Connection "upgrade";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
server {
|
||||||
|
listen 8002;
|
||||||
|
set $deny 1;
|
||||||
|
if ($http_authorization = "Bearer $API_KEY") {
|
||||||
|
set $deny 0;
|
||||||
|
}
|
||||||
|
if ($deny) {
|
||||||
|
return 403;
|
||||||
|
}
|
||||||
|
location / {
|
||||||
|
proxy_pass http://aichat: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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user