This Discord bot, which is written in Python and uses the Discord.py library, leverages the llama-cpp-python bindings to generate responses. It offers several commands for controlling the bot and interacting with the models it has access to.
llama-cpp-python: https://github.com/abetlen/llama-cpp-python
Discord.py: https://github.com/Rapptz/discord.py
@{botname} question
You can list every model in your models folder with the following command:
/list_models
This will provide you with a list of all the models available to the bot.
To switch to a different model, simply specify the name of the model you want to switch to:
/change_model {model_name}
This will change the bot's active model.
To shut down the bot, use the following command:
/shutdown
This will terminate the bot.
You can list every personality in your bot_personality folder with the following command:
/list_personalities
This will provide you with a list of all the personalities available to the bot.
To switch to a different Personality, simply specify the name of the Personality you want to switch to:
/change_bot_personality {personality_name}
This will change the bot's active personality.
To get started quickly, follow these steps:
- Clone this repository:
git clone https://github.com/jediknight813/llama-cpp-discord-bot.git
- Install the dependencies:
pip install -r requirements.txt
- Add a llama.cpp compatible model in the models folder.
- Rename the .env.example file to .env.
- Set your discord bot token and model path in the .env file.
discord_bot_token = '1234'
llm_model_path = './models/ggml-vicuna-7b-1.1-q4_0.bin'
- Run the bot:
python scripts/main.py
Make sure you have docker desktop installed and running.
- Clone this repository:
git clone https://github.com/jediknight813/llama-cpp-discord-bot.git
- Rename the .env.example file to .env.
- Add a llama.cpp compatible model in the models folder.
- Set your discord bot token and model path in the .env file.
discord_bot_token = '1234'
llm_model_path = './models/ggml-vicuna-7b-1.1-q4_0.bin'
- Build the docker image
docker build -t llama-cpp-discord-bot:latest .
- Run it
docker run llama-cpp-discord-bot:latest
I've tried to make it as easy as possible to make a new bot personality.
First create a new json file with your bots name.
Then paste this in the file:
{
"bot_personality": "",
"bot_name": "",
"bot_image": "./images/"
}
Change this to whatever you like, keep in mind that the longer this is the more time it will take for the bot to respond.
bot_personality = 'you are a chatbot named llama-bot, and you never fail to answer the users questions with experience and precision.'
Add the image you want for the bot in the images folder and add it to your bots json file.
bot_image = './images/default.png'
Change this to whatever you like.
bot_name = 'llama-bot'
If you don't want users without permissions running the bot commands (change model, list_models, shutdown) add the role name to the bot_allowed_command_roles in the settings.py file.
bot_allowed_command_roles = ['admin']
If you don't want the bot to reply in every channel on the server, add the channel name to the bot_allowed_channels in the settings.py file.
bot_allowed_channels = ['general']