/lilweirdo

A very mean Discord bot that participates in the conversation.

Primary LanguagePython

Lil Weirdo

Summary

This is a Discord bot which occasionally interjects into conversations with LLM generated goodness. It is highly configurable. It is intended for single guild use and currently applies its configuration across all guilds.

As of 3/18/2024, this is the help message generated by the bot:

What's good?

This is Lil Weirdo, a bot which talks back. There are many personalities defined within Lil Weirdo, known as its various "sickos". Each sicko is defined by an LLM model, a prompt template, and a unique memory recording scheme. Every message that is sent may be recorded into a sicko's memory. There are a couple of commands defined for your consumption pleasure:

  • ~help: Show this help message.
  • ~amnesia: Deletes all of the sickos' memories.
  • ~responserate : Sets the percent of messages the sickos respond to, from 0 to 1. Currently set to 0.05, defaults to 0.05
  • ~sicko list: Lists the available sickos
  • ~sicko current: Lists the currently replying sicko. It is currently None
  • ~sicko shuffle: Sets the sickos to shuffle which one responds to a given message
  • ~sicko set : Sets the currently responding sicko to the given named sicko
  • ~cheevosfrom : What's the list of achievements from your favorite game?

Lil Weirdo is an open source project, more information can be found at https://github.com/DataKinds/lilweirdo.

How to use

  1. First, install Ollama on an accessible server. Then follow Discord.py's instructions for generating a Discord bot account and take note of the bot's token.

  2. Install the lilweirdo project as an editable Python project any way you'd like. I recommend creating a virtual environment and installing it into the venv as such:

    python -m venv env/
    . env/bin/activate
    pip install -e .
    

    However, you're welcome to use pipx (pipx install --editable .) or any equivalent command.

  3. Create a .env file in the root directory of the project, and populate it with your secrets:

    DISCORD_TOKEN=<paste your bot token here>
    OLLAMA_HOST=<optional, place alternative Ollama host URL here>
    
  4. In your virtual environment, start the bot by invoking the lilweirdo binary or by running python src/main.py from the root directory.

  5. Invite your bot to your server by following the instructions provided by Discord.py.

How to add your own sickos

Check out the bottom of src/templater.py. This is where all the Templates are stored, which are given by a prompt template + a choice of LLM model + a choice of stop token.

An example Template is given here:

LIL_WEIRDO = Templater(
    template="""
You are Lil Weirdo, and you are hellishly mean. You are also fantastic at writing insults.

The following conversations are some assholes talking. All of them are fucking dickheads. Each message will start with [MSG] and end with [/MSG]. Here's what these fuckers said:

{{ .Prompt }}
""",
    stoptokens=c.STOP_TOKENS,
    modelname="mistral",
    modeltag="latest"
)

Make sure to supply at least the set of stop tokens given by c.STOP_TOKENS. Conversation history will be filled into the prompt template overtop the {{ .Prompt }} variable. Each message in the conversation will start with an [MSG] tag and will end with an [/MSG] tag. This currently cannot be configured -- so if you want to provide the bot with some example conversations, make sure you enclose the example messages with these tags.

Once you've generated the Template, add it to the bot by adding an extra entry to discordweirdo.DiscordWeirdo.sickos by editing discordweirdo.DiscordWeirdo.__init__. You may either choose keeper.ConvoKeeper or keeper.PeopleKeeper as the sicko's memory. The former records entire conversations, the latter records peoples' individual message histories. Neither group memories by channel, so clutter may build up in the sickos' memories if keeper.ConvoKeeper is used.

Easier ways to add a sicko will come soon, along with more memory keepers and extra configuration options.

How to contribute

Before contributing back any code, make sure to run make fmt to format and typecheck your code changes.

Open an issue or Fork this repo!