diff --git a/README.md b/README.md index e0c9d23..a7e1730 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,12 @@ It updates again every 24 hours (`DOGEBOT_COG_UPDATE_HOURS`). Owners can run `d! | timezone | [aikaterna/aikaterna-cogs](https://github.com/aikaterna/aikaterna-cogs) (branch v3) | | userinfo | [flaree/Flare-Cogs](https://github.com/flaree/Flare-Cogs) | | watch | [RustyRaptor/doge_cogs](https://github.com/RustyRaptor/doge_cogs): `d!watch ` preloads media into the webdav cache through the home lab's media-preload service | -| doge_alignment | [RustyRaptor/doge_cogs](https://github.com/RustyRaptor/doge_cogs): `d!alignment` / `/alignment`, a D&D alignment chart drawn with members' avatars (ImageMagick is in the Red image for it) | +| doge_alignment | [RustyRaptor/doge_cogs](https://github.com/RustyRaptor/doge_cogs): `d!alignment` / `/alignment`, a D&D alignment chart drawn with members' avatars (ImageMagick, its Pango coder and Noto Color Emoji are in the Red image for it) | + +`alignment guess` asks yveltal's own Ollama (the `ollama` system service on port 11434, not part of this repo) +for a guess, using `qwen3.5-9b-gpu` with thinking off; see `ALIGNMENT_MODEL_*` in +`deploy/quadlet/dogebot-red.container`. If Ollama is down or the model is gone, the command says the model +failed and nothing else is affected. `SLASH_COMMANDS` in the manifest lists slash commands to turn on. `dogesetup` enables any that aren't enabled yet once their cog has loaded, and only then syncs with Discord, so the bot doesn't hit Discord's sync rate diff --git a/deploy/install.sh b/deploy/install.sh index 505a43d..d4945f8 100755 --- a/deploy/install.sh +++ b/deploy/install.sh @@ -10,9 +10,6 @@ # - Builds the Red and Lavalink images. # - Installs the quadlets and the daily update timer, and starts Postgres, # yt-cipher and Lavalink. -# - On hosts with an NVIDIA GPU (and CDI for podman), downloads and checks the -# guessing model and runs it with llama.cpp on the GPU with the most memory -# (DOGEBOT_LLM_GPU=<uuid> to choose, DOGEBOT_LLM=off to skip). # - Starts the bot itself only with --start, so a second copy never logs in # with the same token by accident. set -euo pipefail @@ -20,10 +17,6 @@ set -euo pipefail repo=$(cd "$(dirname "$0")/.." && pwd) quadlet_dir=${XDG_CONFIG_HOME:-$HOME/.config}/containers/systemd/dogebot unit_dir=${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user -# doge_alignment's guessing model (any GGUF chat model works) -model_url=https://huggingface.co/bartowski/Qwen2.5-7B-Instruct-GGUF/resolve/main/Qwen2.5-7B-Instruct-Q4_K_M.gguf -model_sha256=65b8fcd92af6b4fefa935c625d1ac27ea29dcb6ee14589c55a8f115ceaaa1423 -model_dir=${XDG_DATA_HOME:-$HOME/.local/share}/dogebot/models start_bot=false [[ ${1:-} == --start ]] && start_bot=true @@ -55,29 +48,6 @@ secret dogebot-postgres-password secret dogebot-lavalink-password secret dogebot-yt-cipher-token -fetch_model() { - local file=$model_dir/${model_url##*/} - [[ -f $file ]] && return - mkdir -p "$model_dir" - curl -fL --progress-bar -o "$file.part" "$model_url" - echo "$model_sha256 $file.part" | sha256sum -c --quiet - - mv "$file.part" "$file" -} - -llm_gpu() { # the GPU with the most memory, unless DOGEBOT_LLM_GPU is set - if [[ -n ${DOGEBOT_LLM_GPU:-} ]]; then - echo "$DOGEBOT_LLM_GPU" - return - fi - nvidia-smi --query-gpu=memory.total,uuid --format=csv,noheader,nounits | - sort -n | tail -1 | awk -F', ' '{print $2}' -} - -use_llm=false -if [[ ${DOGEBOT_LLM:-on} != off ]] && command -v nvidia-smi >/dev/null; then - use_llm=true -fi - cd "$repo" podman build -t localhost/dogebot-red:latest -f containers/red/Containerfile . if ! podman image exists localhost/dogebot-lavalink:current; then @@ -86,20 +56,11 @@ fi mkdir -p "$quadlet_dir" "$unit_dir" install -m 644 deploy/quadlet/* "$quadlet_dir/" -if $use_llm; then - fetch_model - sed -i -e "s|@GPU@|$(llm_gpu)|" -e "s|@MODEL_FILE@|${model_url##*/}|" \ - "$quadlet_dir/dogebot-llm.container" -else - rm -f "$quadlet_dir/dogebot-llm.container" - sed -i '/ALIGNMENT_MODEL_/d' "$quadlet_dir/dogebot-red.container" -fi sed "s|%h/src/dogebot|$repo|" deploy/systemd/dogebot-update.service >"$unit_dir/dogebot-update.service" install -m 644 deploy/systemd/dogebot-update.timer "$unit_dir/" systemctl --user daemon-reload systemctl --user start dogebot-postgres.service dogebot-yt-cipher.service dogebot-lavalink.service -$use_llm && systemctl --user start dogebot-llm.service systemctl --user enable --now dogebot-update.timer if $start_bot; then systemctl --user start dogebot-red.service diff --git a/deploy/quadlet/dogebot-llm.container b/deploy/quadlet/dogebot-llm.container deleted file mode 100644 index 09b7ddb..0000000 --- a/deploy/quadlet/dogebot-llm.container +++ /dev/null @@ -1,29 +0,0 @@ -[Unit] -Description=dogebot: llama.cpp server for doge_alignment's guesses (GTX 1080) - -[Container] -ContainerName=dogebot-llm -# Pinned: llama.cpp's CUDA images will eventually move to CUDA 13, which drops -# Pascal (GTX 10xx). Bump on purpose and check `podman logs dogebot-llm` shows -# the layers offloaded to CUDA. -Image=ghcr.io/ggml-org/llama.cpp:server-cuda -Network=dogebot.network -# One GPU by UUID (stable across PCI order). install.sh fills it in: the GPU -# with the most memory, or DOGEBOT_LLM_GPU. On yveltal that's the GTX 1080 -# (8 GB); the model takes about 5.5 GB of it and the 1060 stays free. -AddDevice=nvidia.com/gpu=@GPU@ -Volume=%h/.local/share/dogebot/models:/models:ro,Z -Exec=-m /models/@MODEL_FILE@ --alias qwen2.5-7b-instruct \ - --host 0.0.0.0 --port 8080 --n-gpu-layers 99 --ctx-size 8192 --parallel 1 -HealthCmd=curl -fsS http://localhost:8080/health -HealthStartPeriod=2m -HealthInterval=30s -Notify=healthy - -[Service] -Restart=always -RestartSec=30 -TimeoutStartSec=600 - -[Install] -WantedBy=default.target diff --git a/deploy/quadlet/dogebot-red.container b/deploy/quadlet/dogebot-red.container index 8556702..d95d9a7 100644 --- a/deploy/quadlet/dogebot-red.container +++ b/deploy/quadlet/dogebot-red.container @@ -2,7 +2,7 @@ Description=dogebot: Red-DiscordBot Requires=dogebot-postgres.service After=dogebot-postgres.service dogebot-lavalink.service -Wants=dogebot-lavalink.service dogebot-llm.service +Wants=dogebot-lavalink.service [Container] ContainerName=dogebot-red @@ -15,9 +15,11 @@ Environment=RED_PREFIX=d! # media-preload (watch cog). host.containers.internal is the host; its LAN IP # would point back at this container on a rootless network. Environment=PRELOAD_API_URL=http://host.containers.internal:8125 -# doge_alignment's `alignment guess` (dogebot-llm.container) -Environment=ALIGNMENT_MODEL_URL=http://dogebot-llm:8080 -Environment=ALIGNMENT_MODEL_NAME=qwen2.5-7b-instruct +# doge_alignment's `alignment guess`: yveltal's own Ollama (a system service, +# not part of dogebot), Qwen3.5-9B with thinking off +Environment=ALIGNMENT_MODEL_URL=http://host.containers.internal:11434 +Environment=ALIGNMENT_MODEL_NAME=qwen3.5-9b-gpu +Environment=ALIGNMENT_MODEL_REASONING=none Secret=dogebot-discord-token,type=env,target=RED_TOKEN Secret=dogebot-postgres-password,type=env,target=PGPASSWORD Secret=dogebot-lavalink-password,type=env,target=LAVALINK_PASSWORD