Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/arashnrim/5.0-gpa-student
🤖 A GPTs-powered Discord bot for a school server.
https://github.com/arashnrim/5.0-gpa-student
Last synced: 21 days ago
JSON representation
🤖 A GPTs-powered Discord bot for a school server.
- Host: GitHub
- URL: https://github.com/arashnrim/5.0-gpa-student
- Owner: arashnrim
- License: mit
- Created: 2023-12-13T13:51:54.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-09-06T16:07:40.000Z (2 months ago)
- Last Synced: 2024-09-06T19:15:26.619Z (2 months ago)
- Language: TypeScript
- Homepage:
- Size: 126 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# 5.0 GPA Student
Welcome to the repository for the 5.0 GPA Student! The Student is a Discord bot that lets you learn and talk to a virtual student buddy about anything. Being powered by among the latest [large language models](https://www.ibm.com/topics/large-language-models) like [Google's Gemini Pro](https://deepmind.google/technologies/gemini/#introduction) and [OpenAI's GPT-4 Turbo](https://help.openai.com/en/articles/8555510-gpt-4-turbo). More work is being done to value-add to the Student, so stay tuned!
This bot was made with the help of [TypeScript](https://www.typescriptlang.org/) as the primary language, [bun](https://bun.sh) as the package manager and Node runtime, and [Discord.js](https://discordjs.dev) as the Discord API wrapper.
## Features
- **Ask away!** As a wrapper around LLMs, the Student can answer just about any question you have. If you'd like to know more about something, the Student's an ask away by either pinging it or using the `ask` slash command.
- **Compare models easily.** The Student is powered by multiple LLMs, meaning you can ask the Student to generate answers using different models. This is useful if you'd like to compare the answers generated by different models.
- **Some working memory.** The Student stores your conversation as you talk to it, so that it can give answers specific to the context you've given from the start. Just reply to the Student's messages to add to the context!## Motivations
I have a small Discord server with my friends, and we often talk about school-related stuff inside there. We generally also hang out in the voice channels, and sometimes we would talk about our schoolwork. I thought it would be cool to have a bot that can talk to us about schoolwork. Especially considering how LLMs have become so ubiquitous with generally everybody these days, I decided to build the 5.0 GPA Student, a bot that can talk to us about schoolwork, and also learn from us.
## Cost incursions
> [!CAUTION]
> Since you're using LLMs that were made by external parties, you'll need to pay the parties for using their models. As of now, the Gemini Pro model is free to use, but the GPT-4 Turbo model is not. You'll need to pay OpenAI for using their model. You can find out more about the pricing [here](https://openai.com/pricing#gpt-4-turbo).
>
> Current estimates show that daily usage of the bot will cost between $0.15 and $0.30 USD, meaning that monthly usage will cost between $4.50 and $9.00 USD. This is assuming that you're using the bot for 24 hours a day, 7 days a week. You can reduce the cost by using the bot less frequently, or by using the bot for a shorter period of time.## Getting started
#### Developing the bot
1. Clone the repository to your local machine:
```bash
git clone https://github.com/arashnrim/5.0-gpa-student
```2. Install [bun](https://bun.sh) on your local machine. This is the package manager that the bot uses.
3. You'll need to make sure that you have the right tokens, API keys, and generally other secrets that you'll need to run the bot. Here's a list of what you'll need:
- A Discord bot token, which you can get from the [Discord Developer Portal](https://discord.com/developers/applications). You'll need to create a new application, and then add a bot to it. You can then copy the bot token from the Bot tab.
- A Discord application ID, which you can get from the [Discord Developer Portal](https://discord.com/developers/applications). You'll need to create a new application, and then copy the application ID from the General Information tab.
- An OpenAI API key, which you can get from the [OpenAI Developer Portal](https://platform.openai.com/). You'll need to create a new organisation, and then create a new API key. You can then copy the API key from the API keys tab.
- A Google Cloud API key, which, for Gemini models, you can get from the [Google AI Studio](https://makersuite.google.com). You'll need to click on Create API key in either a new project or an existing project. This will create a Google Cloud project for you.
- A development server, which you can create from the [main Discord app](https://discord.com/app). You'll need to create a new server or use an existing one where you have the Manage Server permission, and then copy the server ID from the server settings.
- An admin ID, which you can get from the [main Discord app](https://discord.com/app). You'll need to enable Developer Mode in the Appearance tab of the User Settings, and then copy your user ID from the right-click menu of your user in the server.Once you have all the info you need, copy the `.env.example` file to the root folder, rename it to `.env`, and fill in the values accordingly:
```env
BOT_TOKEN=
OPENAI_API_KEY=
GOOGLE_API_KEY=
NODE_ENV=
DEVELOPMENT_SERVER_ID=
ADMIN_USER_ID=
APPLICATION_ID=
```4. That should be it! You can now run the bot by running the following command:
```bash
bun src/index.ts
```#### Hosting the bot
> [!WARNING]
> Refrain from having two instances of the same bot (with the same token and application ID) running at the same time. This may cause unintended consequences, such as the bot not responding to commands, or the bot responding to commands in the wrong server, or the bot responding twice.A [Dockerfile](https://github.com/arashnrim/5.0-gpa-student/blob/main/Dockerfile) is provided in the repository, so you can use that to host the bot on your own server. Here's how:
0. Install minimally the [Docker Engine](https://docs.docker.com/engine/install/) on your server.
1. You'll need to make sure that you have the right tokens, API keys, and generally other secrets that you'll need to run the bot. Here's a list of what you'll need:
- A Discord bot token, which you can get from the [Discord Developer Portal](https://discord.com/developers/applications). You'll need to create a new application, and then add a bot to it. You can then copy the bot token from the Bot tab.
- A Discord application ID, which you can get from the [Discord Developer Portal](https://discord.com/developers/applications). You'll need to create a new application, and then copy the application ID from the General Information tab.
- An OpenAI API key, which you can get from the [OpenAI Developer Portal](https://platform.openai.com/). You'll need to create a new organisation, and then create a new API key. You can then copy the API key from the API keys tab.
- A Google Cloud API key, which, for Gemini models, you can get from the [Google AI Studio](https://makersuite.google.com). You'll need to click on Create API key in either a new project or an existing project. This will create a Google Cloud project for you.
- A development server, which you can create from the [main Discord app](https://discord.com/app). You'll need to create a new server or use an existing one where you have the Manage Server permission, and then copy the server ID from the server settings.
- An admin ID, which you can get from the [main Discord app](https://discord.com/app). You'll need to enable Developer Mode in the Appearance tab of the User Settings, and then copy your user ID from the right-click menu of your user in the server.Once you have all the info you need, copy the `.env.example` file to the root folder, rename it to `.env`, and fill in the values accordingly:
```env
BOT_TOKEN=
OPENAI_API_KEY=
GOOGLE_API_KEY=
NODE_ENV=
DEVELOPMENT_SERVER_ID=
ADMIN_USER_ID=
APPLICATION_ID=
```2. Pull the latest Docker image from GitHub Packages:
```bash
docker pull ghcr.io/arashnrim/5.0-gpa-student:main
```3. Run the Docker image:
```bash
docker run -d -e .env --name 5.0-gpa-student ghcr.io/arashnrim/5.0-gpa-student:main
```- `-d` tells Docker to run the container in the background (detached mode).
- `-e .env` tells Docker to use the `.env` file as the environment variables for the container.
- `--name 5.0-gpa-student` tells Docker to name the container `5.0-gpa-student`.
- `ghcr.io/arashnrim/5.0-gpa-student:main` tells Docker to use the image from GitHub Packages.That should be it! As the bot operates, you can check the logs of the container by running the following command:
```bash
docker logs 5.0-gpa-student
```## Contributions
Contributions are welcome! If you'd like to contribute to the project, feel free to fork the repository and submit a pull request. If you'd like to just bring up suggestions to better improve the bot or have any questions about the code, feel free to create an Issue on the repository and share your thoughts there.
If possible, I'd love to involve other students in the development of the bot. If you're a student and you'd like to contribute to the project, feel free to!
## License
This project is made open source with the [MIT License](https://github.com/arashnrim/5.0-gpa-student/blob/main/LICENSE.md), which means that you can use the code in this repository for your own projects, as long as you credit me and the other contributors to the project. You can find out more about the MIT License in the link above.