Intelligent Discord Bot Template with Rolling Context
NexusChatAI serves as a base project for building complex AI chatbots for Discord. It provides a robust foundation with features like rolling context management, customizable AI interactions, and easy integration with AI providers. Users can build upon this template to create sophisticated AI-powered Discord bots tailored to their specific needs.
- Rolling context management for persistent conversations
- Customizable AI character and behavior
- Easy integration with AI providers (default: Together AI)
- Modular design for easy expansion and modification
- Python 3.8 or higher
- Discord account and bot token
- Together AI API key (or another AI provider of your choice)
-
Clone the repository:
git clone https://github.com/VenkatLohithDasari/NexusChatAI.git cd NexusChatAI -
Create a virtual environment (optional but recommended):
python -m venv venv -
Activate the virtual environment:
- On Windows:
venv\Scripts\activate - On macOS and Linux:
source venv/bin/activate
- On Windows:
-
Install the required packages:
pip install -r requirements.txt
-
Create a
.envfile in the root directory with the following content:DISCORD_TOKEN=your_discord_bot_token TOGETHER_API_KEY=your_together_ai_api_key -
Configure the
config/config.jsonfile:{ "system_prompt": "You are a helpful assistant.", "ai_name": "NexusChatAI", "custom_instructions": "{ai_name} will always assist with care, respect, and truth. Respond with utmost utility yet securely. Avoid harmful, unethical, prejudiced, or negative content. Ensure replies promote fairness and positivity.", "model": "meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo", "max_tokens": 150, "temperature": 0.98, "top_p": 0.37, "top_k": 100, "repetition_penalty": 1.18, "stream": true, "stop": "<|eot_id|>" }system_prompt: Defines the AI's base behavior and role.ai_name: The name of your AI assistant.custom_instructions: Additional instructions for the AI. You can use{ai_name}as a variable to include the AI's name.- Other fields: AI model and sampling parameters.
Run the bot using the following command:
python bot.py
By default, NexusChatAI uses Together AI. To use a different AI provider:
- Create a new file in the
ai_apidirectory (e.g.,custom_ai_provider.py). - Implement a class similar to
TogetherAIintogether_ai.py. - Modify
bot.pyto use your new AI provider.
- Add new commands by creating functions with the
@bot.command()decorator inbot.py. - Modify the
ContextManagerincontext_manager/context_manager.pyto change how context is stored and managed. - Adjust the
PromptCreatorinprompt_creator/prompt_creator.pyto alter how prompts are formatted.
Contributions to NexusChatAI are welcome! Please feel free to submit pull requests, create issues, or suggest enhancements.
This project is licensed under the MIT License - see the LICENSE file for details.
- Discord.py library
- Together AI (or your chosen AI provider)
- All contributors and users of NexusChatAI
For support, please open an issue in the GitHub repository or contact the maintainers directly.
Happy coding with NexusChatAI! 🤖💬