This project allows you to ask questions about Giveth, a non-profit organization focused on blockchain-based donations and decentralized governance, by utilizing a bot which fetches answers directly from Giveth's documentation.
- Python 3.7 or later.
- Git
- Ensure you have the required dependencies installed.
- Clone the repository.
- Install the required Python libraries by running
pip install -r requirements.txt
in the root directory of the project.
The bot is intended for use within a Discord server. Here is how you can utilize the bot's commands:
/reload
- This command reloads the knowledge base from the Giveth's documentation./ask <your question here>
- This command fetches the answer to your question from the knowledge base. Replace<your question here>
with your actual question about Giveth./experimental_agent <your question here> - This command fetches the answer to your question using the experimental agent. Replace
` with your actual question about Giveth.
The bot uses Discord's token for authentication and OpenAI's API key to generate text embeddings.
To obtain a token, follow these steps:
- Visit the Discord Developer Portal (https://discord.com/developers/applications)
- Click on "New Application"
- Name your application and click "Create"
- On the left panel, click on "Bot"
- Click on "Add Bot"
- Under the bot settings, click on "Copy" to copy the bot token
To obtain the OpenAI API key, follow these steps:
- Visit the OpenAI website and create an account (https://www.openai.com/)
- Navigate to the API section (https://platform.openai.com/account/api-keys)
- Generate a new key
Next, create a .env
file in the root directory of the project and paste your bot token and OpenAI API Key like this:
DISCORD_TOKEN=your_discord_token_here
OPENAI_API_KEY=your_openai_api_key_here
Replace your_discord_token_here
with the actual token and your_openai_api_key_here
with the actual API key.
The bot relies on the Giveth's documentation as its knowledge base. The documentation is fetched from the Giveth's GitHub repository.
Upon running the bot for the first time, it automatically clones the Giveth's documentation repository, if it doesn't already exist in the giveth-docs
directory. If the repository already exists, it performs a git pull to fetch the latest documentation.
The bot then reads all markdown files from the repository, breaks the text into chunks, and generates embeddings for each chunk. The embeddings are used to perform a similarity search when a question is asked.
To run the bot, simply execute the main.py
script:
python main.py
The bot then connects to your Discord server and is ready to accept commands.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the GNU Affero General Public License v3.0 - see the LICENSE file for details.