Go to file
2023-04-13 18:44:28 +02:00
.vscode Some settings 2023-04-12 10:28:52 +02:00
fjerkroa_bot Fix history limit handling. 2023-04-13 18:36:06 +02:00
tests Fix mypy errors. 2023-04-13 18:44:28 +02:00
.flake8 Split AI and main tests, implement first AI test. 2023-03-22 18:05:45 +01:00
.gitignore Fix history limit handling. 2023-04-13 18:36:06 +02:00
.pre-commit-config.yaml Switch to TOML for config file, fix bugs. 2023-03-22 21:37:33 +01:00
config.toml Implement possibility to answer to a different channel 2023-04-12 17:56:31 +02:00
mypy.ini Fix mypy errors. 2023-04-13 18:44:28 +02:00
pyproject.toml Parse response values, when they are JSON. 2023-03-30 15:38:42 +02:00
pytest.ini pytest.ini 2023-03-22 11:10:21 +01:00
README.md Refactor discord_bot.py code a bit and improve comments 2023-04-13 16:09:00 +02:00
requirements.txt Improve JSON parsing. 2023-03-29 19:22:54 +02:00
setup.py Initial commit. 2023-03-21 18:25:14 +01:00
setupenv.sh Begin to add tests for AIResponder. 2023-03-22 17:29:14 +01:00

Fjerkroa bot

A simple Discord bot that uses OpenAI's GPT to chat with users.

Installation

  1. Install the package using pip:
pip install fjerkroa-bot
  1. Create a config.toml file with the following content, replacing the tokens with your own:
openai-key = "OPENAIKEY"
discord-token = "DISCORDTOKEN"
model = "gpt-3.5-turbo"
max-tokens = 1024
temperature = 0.9
top-p = 1.0
presence-penalty = 1.0
frequency-penalty = 1.0
history-limit = 20
history-per-channel = 5
history-directory = "history"
welcome-channel = "chat"
staff-channel = "mods"
join-message = "Hi! Ich heiße {name} und ich bin neu hier! Wie geht es euch?"
short-path = [['^news$', '^news-bot$'], ['^mods$', '.*']]
ignore-channels = ["blengon"]
fix-model = "gpt-3.5-turbo"
fix-description = "You are an AI which fixes JSON documents. User send you JSON document, possibly invalid, and you fix it as good as you can and return as answer. Even when document is valid, return it pretty formated."
additional-responders = []
system = "You are an smart AI"
  1. Run the bot:
python -m fjerkroa_bot --config config.toml

Configuration

Create a config.toml file with the following configuration options:

openai-key = "OPENAIKEY"
discord-token = "DISCORDTOKEN"
model = "gpt-3.5-turbo"
max-tokens = 1024
temperature = 0.9
top-p = 1.0
presence-penalty = 1.0
frequency-penalty = 1.0
history-limit = 10
welcome-channel = "welcome"
staff-channel = "staff"
join-message = "Hi! I am {name}, and I am new here."
short-path = [['^news$', '^news-bot$'], ['^mod$', '.*']]
system = "You are an smart AI"
  • discord-token: The token for the Discord bot account.
  • openai-token: The API key for the OpenAI API.
  • model: The OpenAI model name to be used for generating AI responses.
  • temperature: The temperature for the AI model's output.
  • history-limit: The maximum number of messages to maintain in the conversation history.
  • history-directory: The directory where the conversation history will be stored.
  • history-per-channel: The number of history items to keep per channel.
  • max-tokens: The maximum number of tokens in the generated AI response.
  • top-p: The top-p sampling value for the AI model's output.
  • presence-penalty: The presence penalty value for the AI model's output.
  • frequency-penalty: The frequency penalty value for the AI model's output.
  • staff-channel: The name of the channel where staff messages will be sent.
  • welcome-channel: The name of the channel where welcome messages will be sent.
  • join-message: The message template to be sent to AI when a user joins the server, triggers that way the AI to write something to the user.
  • ignore-channels: A list of channels to be ignored by the bot.
  • additional-responders: A list of channels that should have a separate AI responder with separated history.
  • short-path: List of channel and user regex patterns to apply short path (skip sending message to AI, just fill the history).
  • system: The system message template for the AI conversation.
  • fix-model: The OpenAI model name to be used for fixing the AI responses.
  • fix-description: The description for the fix-model's conversation.

register-python-argcomplete