hc20k / LLMChat

A Discord chatbot that supports popular LLMs for text generation and ultra-realistic voices for voice chat.
GNU General Public License v3.0
85 stars 15 forks source link
ai artificial-intelligence bot chatbot discord gpt-4 openai python speech-recognition

LLMChat

A Discord chatbot that uses GPT-4, 3.5, 3, or LLaMA for text generation and ElevenLabs, Azure TTS, or Silero for voice chat.

This is actively being improved! Pull requests and issues are very welcome!

Features:

Screenshot of messages

NOTE: Please only use this on small private servers. Right now it is set up for testing only, meaning anyone on the server can invoke its commands. Also, the bot will join voice chat whenever someone else joins!

Installation

Setting up a Server

Setup a server to run the bot on so it can run when your computer is off 24/7. For this guide, I will be using DigitalOcean, but you can use any server host you want. Skip this section if you already have a server or want to run it locally.

  1. Create a DigitalOcean account here

  2. Create a droplet

    • Open your dashboard
    • Click "Create" -> "Droplets"
    • Select whatever region is closest to you and doesn't have any notes.
    • Choose an image>Ubuntu>Ubuntu 20.04 (LTS) x64
    • Droplet Type>Basic
    • CPU options>Premium Intel (Regular is $1 cheaper but much slower.)
    • 2 GB / 1 Intel CPU / 50 GB Disk / 2 TB Transfer (You need at least 2GB of Ram & 50GB of storage is more than enough storage for this bot.)
    • Choose Authentication Method>Password>Pick a password
    • Enable backups if you want. (This will cost extra but allow you to go back to a previous version of your server if you mess something up.)
    • Create Droplet
  3. Connect to your droplet

    • Open your dashboard
    • Find your droplet>more>access console
    • Log in as...root>Launch Droplet Console

Requirements

sudo apt-get install portaudio19-dev

Automatically Install Dependencies

Clone the project files and cd into the directory

git clone https://github.com/hc20k/LLMChat.git
cd LLMChat

Simply run

python3.9 update.py -y
# -y installs required dependencies without user interaction
# Change python.x if using a different version of Python

to install all required dependencies. You will be asked if you want to install the optional dependencies for voice and/or image recognition in the script.

NOTE: It's healthy to run update.py after a new commit is made, because requirements may be added.

Manually Install Dependencies

If you were having trouble with the update.py script, you can install the dependencies manually using these commands.

Clone the project files and cd into the directory

git clone https://github.com/hc20k/LLMChat.git
cd LLMChat

Manually install the dependencies

pip install -r requirements.txt

# for voice support (ElevenLabs, bark, Azure, whisper)
pip install -r optional/voice-requirements.txt

# for BLIP support
pip install -r optional/blip-requirements.txt
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu

# for LLaMA support
pip install -r optional/llama-requirements.txt

Configuration

Create the bot:

Copy the config file

cp config.example.ini config.ini

Edit the config file

nano config.ini

[Bot]

speech_recognition_service =:

tts_service =:

audiobook_mode =

llm =:

blip_enabled =

[OpenAI]

key =

model =

use_embeddings =

[Discord]

bot_api_key =

[Azure], [ElevenLabs], [Silero], [Play.ht]

Supply your API keys & desired voice for the service you chose for tts_service

Starting The Bot:

After changing the configuration files, start the bot

python3.9 main.py

Or run the bot in the background useing screen to keep it running after you disconnect from a server.

screen -S name python3.9 main.py
# Press `Ctrl+a` then `d` to detach from the running bot.

Discord Commands

Bot Settings:

Utilties:

Info: