Skip to content

Amine-LG/Discord-Ollama-ChatBot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Discord Ollama ChatBot

This is a Discord chatbot that uses Ollama to generate responses. It can handle messages, process text attachments, and reset the conversation log using the command '!reset'.

Prerequisites

  • A Discord account and a bot token
  • Ollama installed locally from the official website

Setup Instructions

1. Clone the Repository

First, clone the repository to your local machine and navigate to the project directory.

git clone https://github.com/Amine-LG/Discord-Ollama-ChatBot.git
cd Discord-Ollama-ChatBot

2. Create a Virtual Environment

Create a virtual environment to manage dependencies.

python -m venv bot-env

3. Activate the Virtual Environment

Activate the virtual environment.

  • On Windows:
    bot-env\Scripts\activate
  • On macOS/Linux:
    source bot-env/bin/activate

4. Install Dependencies

Install the required packages using requirements.txt.

pip install -r requirements.txt

5. Set Up Environment Variables

Create a .env file in the root directory and add your Discord bot token.

DISCORD_TOKEN=your_discord_bot_token

6. Ensure Ollama is Running Locally

Make sure Ollama is installed and running on your local machine.

7. Install and Run Llama3 Model

To download and install the Llama3 model, run the following command in your terminal:

ollama run llama3

For more models, visit the Ollama Model Library.

8. Run the Bot

Run the bot using the following command.

python main.py

Code Overview

main.py

This is the main script that runs the bot. It includes the following functionalities:

  • Loading environment variables
  • Initializing logging
  • Defining the bot's behavior
  • Handling messages and attachments
  • Interacting with the Ollama running locally
  • Changing the bot's nickname (optional)

requirements.txt

This file lists all the necessary packages and their versions.

python-dotenv==1.0.1
discord.py==2.3.2
ollama==0.2.0

Usage

Reset Command

You can reset the conversation log by using the !reset command in Discord.

Video Tutorials

How to Install

Watch the video

About

Simple Discord Ollama ChatBot

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages