Adding Docker Support and updating README.md
This commit is contained in:
parent
1d8572e12b
commit
059dbd307f
20
Dockerfile
Normal file
20
Dockerfile
Normal file
@ -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"]
|
51
README.md
51
README.md
@ -1,40 +1,23 @@
|
|||||||
# OpenWebUI-Discordbot
|
# 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/
|
## Prerequisites
|
||||||
|
|
||||||
Before running you will need to install the required modules
|
- 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
|
||||||
```
|
```
|
||||||
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.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
DISCORD_TOKEN=your_discord_bot_token
|
DISCORD_TOKEN=your_discord_bot_token
|
||||||
OPENAI_API_KEY=your_openwebui_api_key
|
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"
|
MODEL_NAME="Your_Model_Name"
|
Loading…
Reference in New Issue
Block a user