Skip to content

VWongDev/ai-chatops

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ChatOps Discord Bot

A Discord bot that provides chat and remote development via local GPU-accelerated LLM inference. Written in Rust, runs entirely in Docker.

Features

Command Description
/chat <message> Chat with the local vLLM model
/ocode <prompt> Run OpenCode in its container with a prompt
/ocode-reset Reset your OpenCode conversation session
/ocode-status Show the OpenCode server status
/exec <command> Run a shell command inside the OpenCode container
/ocode-upload <file> Upload a file to the shared workspace
/ocode-download <path> Download a file from the shared workspace
/ocode-ls [path] List files in the shared workspace
/admin status Show bot health: vLLM, OpenCode, and model info

Access is restricted to a configured allowlist of Discord user IDs.

Architecture

┌──────────────────────────────────────────────────────────────┐
│                        bot-network                           │
│                                                              │
│  ┌───────────────────────────────────────────────────────┐   │
│  │              discord-bot (Rust/Poise)                 │   │
│  └──────────┬───────────────────────┬────────────────────┘   │
│             │                       │                        │
│             ▼                       ▼                        │
│  ┌──────────────────┐   ┌───────────────────────────────┐    │
│  │       vLLM       │   │          opencode             │    │
│  │  GPU inference   │   │  AI code assistant  :4096     │    │
│  │  :8000/v1        │   │  exec-agent (Go)    :4097     │    │
│  └──────────────────┘   └───────────────────────────────┘    │
│                                    │                         │
│                         workspace volume (shared)            │
│                                                              │
└──────────────────────────────────────────────────────────────┘
          ▲
          │ slash commands
          │
      Discord

All services run on a shared Docker bridge network (bot-network). The bot connects to vLLM at http://vllm:8000/v1 and to OpenCode at http://opencode:4096. Shell execution is handled by a Go-based exec-agent sidecar running inside the opencode container at :4097, authenticated via a shared secret.

The bot and opencode containers share a named Docker volume (workspace) mounted at /workspace, used for file transfers via /ocode-upload, /ocode-download, and /ocode-ls.

The opencode container runs with a hardened security profile: read-only root filesystem, all capabilities dropped, no-new-privileges, and a PID limit.

Prerequisites

  • Docker with the Compose plugin
  • NVIDIA GPU with the NVIDIA Container Toolkit (for vLLM)
  • A Discord bot token

Setup

1. Create your .env file:

cp .env.template .env

Edit .env and fill in your values:

DISCORD_BOT_TOKEN=your_discord_bot_token
ALLOWED_USER_IDS=your_discord_user_id
EXEC_AGENT_SECRET=a_random_secret_string

Your Discord user ID can be found by enabling Developer Mode in Discord settings, then right-clicking your username and selecting "Copy User ID".

2. Start all services:

docker compose up -d

This pulls the prebuilt vllm/vllm-openai:latest image, builds the Rust bot and OpenCode containers, and starts everything.

3. Register slash commands:

Slash commands are registered globally on first bot startup. It may take up to an hour for Discord to propagate them.

Configuration

Environment Variable Default Description
DISCORD_BOT_TOKEN (required) Discord bot token
ALLOWED_USER_IDS (required) Comma-separated Discord user IDs
EXEC_AGENT_SECRET (required) Shared secret for exec-agent authentication
VLLM_BASE_URL http://vllm:8000 Base URL of the vLLM API
DEFAULT_MODEL cyankiwi/Qwen3.5-9B-AWQ-4bit Default model for /chat
OPENCODE_URL http://opencode:4096 Base URL of the OpenCode serve API
EXEC_AGENT_URL http://opencode:4097 Base URL of the exec-agent API
WORKSPACE_PATH /workspace Path to the shared workspace volume in the bot container

Development

Run unit tests locally (requires Rust):

cd bot
cargo test

Build the bot container only:

docker compose build discord-bot

View logs:

docker compose logs -f discord-bot
docker compose logs -f vllm

About

Discord bot for self-hosted LLM chat and AI coding via vLLM and OpenCode.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors