diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9933823 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +# Use Python 3 base image +FROM python:3.9-slim + +# Set working directory +WORKDIR /app + +# Install system dependencies for audio support +RUN apt-get update && apt-get install -y \ + python3-pip \ + libopus0 \ + && rm -rf /var/lib/apt/lists/* + +# Install required packages +RUN pip install --no-cache-dir discord.py python-dotenv openai + +# Copy the bot script +COPY /scripts/discordbot.py . + +# Run the bot on container start +CMD ["python", "discordbot.py"] \ No newline at end of file diff --git a/README.md b/README.md index 9882629..80b2211 100644 --- a/README.md +++ b/README.md @@ -1,40 +1,23 @@ # OpenWebUI-Discordbot -A Discord bot to communicate with an OpenWebUI instance. +A Discord bot that interfaces with an OpenWebUI instance to provide AI-powered responses in your Discord server. -A helpful guide to creating your Discord Bot's Token: https://www.writebots.com/discord-bot-token/ - -Before running you will need to install the required modules - -``` -pip install discord.py python-dotenv openai -``` - - -This script: - -Uses environment variables for secure configuration -Initializes a Discord bot with message content intents -Configures the OpenAI client to point to your OpenWebUI instance -Watches for messages that mention the bot -When mentioned, it: -Removes the mention from the message to get the actual prompt -Shows a typing indicator while processing -Sends the prompt to OpenWebUI -Handles long responses by splitting them if necessary -Posts the response back to the Discord channel -To use this bot: - -Create a Discord application and bot at the Discord Developer Portal -Get your bot token and add it to the .env file -Invite the bot to your server with appropriate permissions -Set up your OpenWebUI instance and get its API endpoint -Run the script -You can mention the bot in any channel it has access to with a message like: - -@YourBot What is the weather like today? -The bot will process the message and respond with the AI-generated response from your OpenWebUI instance. +## Prerequisites +- Docker (for containerized deployment) +- Python 3.8 or higher+ (for local development) +- A Discord Bot Token ([How to create a Discord Bot Token](https://www.writebots.com/discord-bot-token/)) +- Access to an OpenWebUI instance +## Installation +##### Running locally +1. Clone the repository +2. Copy `.env.sample` to `.env` and configure your environment variables: +```env + DISCORD_TOKEN=your_discord_bot_token + OPENAI_API_KEY=your_openwebui_api_key + OPENWEBUI_API_BASE=http://your_openwebui_instance:port/api + MODEL_NAME=your_model_name +``` \ No newline at end of file diff --git a/scripts/.env.sample b/scripts/.env.sample index 55553e3..03752cf 100644 --- a/scripts/.env.sample +++ b/scripts/.env.sample @@ -1,4 +1,4 @@ DISCORD_TOKEN=your_discord_bot_token OPENAI_API_KEY=your_openwebui_api_key -OPENWEBUI_API_BASE=http://your_openwebui_instance:port/v1 +OPENWEBUI_API_BASE=http://your_openwebui_instance:port/api MODEL_NAME="Your_Model_Name" \ No newline at end of file