Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite with hikari #135

Merged
merged 33 commits into from
Dec 31, 2022
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
3ce6ab8
initial bot structure
AlexanderHott Dec 29, 2022
c8834aa
add a lot of examples
AlexanderHott Dec 29, 2022
99303ed
move example.py to _example.py so it doesn't load on startup
AlexanderHott Dec 29, 2022
9fd2e76
add initial task loop for initial_prompt and rank_initial_prompts
AlexanderHott Dec 29, 2022
221d339
clean up code
AlexanderHott Dec 29, 2022
84146f2
remove database file (luckly it was empty)
AlexanderHott Dec 29, 2022
27ab051
Merge branch 'main' of https://github.com/LAION-AI/Open-Assistant int…
AlexanderHott Dec 29, 2022
bb3b0e7
update api client to upstream version
AlexanderHott Dec 29, 2022
0ed2903
Merge pull request #2 from AlexanderHOtt/LAION-AI-main
AlexanderHott Dec 29, 2022
a2a0e16
fix: parse TaskRequestType enum correctly
AlexanderHott Dec 29, 2022
f7ecf8a
Merge branch 'main' of https://github.com/LAION-AI/Open-Assistant int…
AlexanderHott Dec 30, 2022
26c1b4e
merge upstream main
AlexanderHott Dec 30, 2022
9c15258
move api_client.py back to the correct position
AlexanderHott Dec 30, 2022
63e2120
add completion message to task and add message labeling
AlexanderHott Dec 30, 2022
e4b097e
add database schema and guild setting
AlexanderHott Dec 30, 2022
d71ded1
send the task completion message in the guild's configured channel
AlexanderHott Dec 30, 2022
9895544
explain text_label logic
AlexanderHott Dec 30, 2022
65c078f
pre-commit changes
AlexanderHott Dec 30, 2022
b81eeeb
switch to using pre-commit
AlexanderHott Dec 30, 2022
84d52ef
remove address todo comments
AlexanderHott Dec 30, 2022
36c429d
Merge branch 'main' of https://github.com/LAION-AI/Open-Assistant int…
AlexanderHott Dec 30, 2022
47d449e
Merge branch 'upstream'
AlexanderHott Dec 30, 2022
708011e
move EXAMPLEs.md
AlexanderHott Dec 30, 2022
6cccd74
switch to loguru
AlexanderHott Dec 30, 2022
150fc67
switch to using Pydantic for bot config
AlexanderHott Dec 30, 2022
aff3f18
document code structure
AlexanderHott Dec 30, 2022
0fb7bfd
Add more settings and refactor other md files into README.md
AlexanderHott Dec 31, 2022
37f30f4
update readme
AlexanderHott Dec 31, 2022
004a868
update user input validator
AlexanderHott Dec 31, 2022
6c3a2ea
rename task.py to test_user_input.py
AlexanderHott Dec 31, 2022
1bdd02c
fix breaking api changes
AlexanderHott Dec 31, 2022
a7b7487
remove example table from sql schema
AlexanderHott Dec 31, 2022
8067dc8
rename TOKEN env var to BOT_TOKEN
AlexanderHott Dec 31, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions discord-bot/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
TOKEN=<discord bot token>
DECLARE_GLOBAL_COMMANDS=<testing guild id>
OWNER_IDS=<your user id>
PREFIX="./"
7 changes: 7 additions & 0 deletions discord-bot/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
.env
*.egg-info/
__pycache__/

.venv
.nox
.env

# Database files
*.db
104 changes: 104 additions & 0 deletions discord-bot/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Contributing

## Setup

To run the bot

```
cp .env.example .env

python -V # 3.10

pip install -r requirements.txt
python -m bot
```

To test the bot

```
python -m pip install -r dev-requirements.txt

nox
```

To test the bot on your own discord server you need to register a discord application at the [Discord Developer Portal](https://discord.com/developers/applications) and get at bot token.

1. Follow a tutorial on how to get a bot token, for example this one: [Creating a discord bot & getting a token](https://github.com/reactiflux/discord-irc/wiki/Creating-a-discord-bot-&-getting-a-token)
2. The bot script expects the bot token to be in the `.env` file under the `TOKEN` variable.

## Resources

### Structure

```graphql
.env # Environment variables
.env.example # Example environment variables
CONTRIBUTING.md # This file
dev-requirements.txt # Development requirements
flake8-requirements.txt # Flake8 extensions (for linting)
noxfile.py # Nox session definitions (for formatting, typechecking, linting)
pyproject.toml # Project configuration
README.md # Project readme
requirements.txt # Requirements
templates/ # Message templates

bot/
├─ __init__.py
├─ __main__.py # Entrypoint
├─ bot.py # Main bot class
├─ config.py # Configuration and secrets
├─ utils.py # Utility Functions
├─ db/ # Database related code
│ ├─ database.db # SQLite database
│ └─ schema.sql # Database schema
└── extensions/ # Application logic, see https://hikari-lightbulb.readthedocs.io/en/latest/guides/extensions.html
└─ hot_reload.py # Utility for hot reload extension
```

### Adding a new command/listener

1. Create a new file in the `extensions` folder
2. Copy the template below

```py
# -*- coding: utf-8 -*-
"""My plugin."""
import lightbulb

plugin = lightbulb.Plugin("MyPlugin")

# Add your commands here

def load(bot: lightbulb.BotApp):
"""Add the plugin to the bot."""
bot.add_plugin(plugin)


def unload(bot: lightbulb.BotApp):
"""Remove the plugin to the bot."""
bot.remove_plugin(plugin)
```

For example commands and listeners, see [here](/discord-bot/bot/extensions/_example.py)

### Docs

Discord

- [Discord API Reference](https://discord.com/developers/docs/intro)

Main framework

- [Hikari Repo](https://github.com/hikari-py/hikari)
- [Hikari Docs](https://docs.hikari-py.dev/en/latest/)

Command handler

- [Lightbulb Repo](https://github.com/tandemdude/hikari-lightbulb)
- [Lightbulb Docs](https://hikari-lightbulb.readthedocs.io/en/latest/)

Component handler (buttons, modals, etc... )

- [Miru Repo](https://github.com/HyperGH/hikari-miru)
13 changes: 2 additions & 11 deletions discord-bot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,6 @@ This bot collects human feedback to create a dataset for RLHF-alignment of an as

To add the official Open-Assistant data collection bot to your discord server [click here](https://discord.com/api/oauth2/authorize?client_id=1054078345542910022&permissions=1634235579456&scope=bot). The bot needs access to read the contents of user text messages.

## Bot token for development
## Contributing

To test the bot on your own discord server you need to register a discord application at the [Discord Developer Portal](https://discord.com/developers/applications) and get at bot token.

1. Follow a tutorial on how to get a bot token, for example this one: [Creating a discord bot & getting a token](https://github.com/reactiflux/discord-irc/wiki/Creating-a-discord-bot-&-getting-a-token)
2. The bot script expects the bot token to be in an environment variable called `BOT_TOKEN`.

The simplest way to configure the token is via an `.env` file:

```
BOT_TOKEN=XYZABC123...
```
To contribute to the bot, please refer to the [CONTRIBUTING.md](CONTRIBUTING.md) file.
17 changes: 0 additions & 17 deletions discord-bot/__main__.py

This file was deleted.

79 changes: 0 additions & 79 deletions discord-bot/api_client.py

This file was deleted.