Skip to content

Commit

Permalink
Merge branch 'audio-rewrite'
Browse files Browse the repository at this point in the history
  • Loading branch information
JMaynor committed Aug 21, 2024
2 parents f6e4a75 + 1efcb47 commit 993ac22
Show file tree
Hide file tree
Showing 19 changed files with 908 additions and 433 deletions.
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ updates:
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
8 changes: 6 additions & 2 deletions .github/workflows/ghcr-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ jobs:
uses: docker/metadata-action@v4
with:
images: ghcr.io/JMaynor/dolores
tags: type=sha
tags: |
type=sha
type=ref,event=branch,ref=main
- name: Login to GHCR
uses: docker/login-action@v3
with:
Expand All @@ -30,4 +32,6 @@ jobs:
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
tags: |
${{ steps.meta.outputs.tags }}
ghcr.io/JMaynor/dolores:latest
105 changes: 91 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,106 @@
# Summary

Discord bot named Dolores for rolling dice and a number of other helper functions.
Discord bot named Dolores for rolling dice, playing audio, and a number of other helper functions. She was initially created to help facilitiate playing tabletop games over Discord.

Dolores can be run easily directly as a python program, but she can also be ran within a Docker container, allowing for easier updating.
Dolores can be run easily directly as a python program. Generally, I have her running as a Docker container, allows for easier updating. An example `compose.yml` layout is included below, assuming the user wants to make use of all functionality.

Note: Dolores requires a config.yml file with a bot API key and a couple other details to run. example_config.yml is included to show formatting. Config file is organized by service. The only heading explicitly required to run is the info under DISCORD
> Note: Dolores is largely a personal project created for a few small Discord servers. So there's a number of features or peculiarities that specifically deal with things unique to what I want her to do. Should still be useful in a broader more generalized context, but I will work over time to make her less specific. Or at least make her uses more configurable.
## Modules
## Config

Dolores runs using a number of environment variables for API keys and settings. Not all are required for core functionality. Each cog has a corresponding environment variable to turn it on or off. Will determine whether the cog is loaded when Dolores is run. If a cog isn't loaded, none of the environment variables that are associated with that module are required.

The only explicitly required environment variable is `DISCORD_API_KEY`.

Dolores' functionality is divided into several cogs modules. dolores.py handles discord events and processing commands.
Env vars can be provided via a `.env` file in the main directory, if desired. Useful for testing locally.

### Rolling
| Required by Which Module | Env Var Name | Description |
| --- | --- | --- |
| | | |
| Base | DISCORD_API_KEY | The main API key for the bot. |
| Base | AUDIO_ENABLED | Enables audio cog, when set as true |
| Base | SCHEDULING_ENABLED | Enables scheduling cog, when set as true |
| Base | GENERATION_ENABLED | Enables URL sumamrization, LLM replies, image generation. |
| Base | LOG_LEVEL | Level of logging. Dolores uses DEBUG, INFO, and ERROR. |
| Scheduling | NOTION_API_KEY | API Key for querying data from Notion |
| Scheduling | NOTION_VERSION | Version of Notion API used for querying. |
| Scheduling | NOTION_BASE_URL | Base URL of the Notion API, should be |
| Scheduling | NOTION_DATABASE_ID | ID for database where stream info is kept |
| None | TWITCH_CLIENT_ID | Not yet used |
| None | TWITCH_CLIENT_SECRET | Not yet used |
| None | TWITCH_BASE_URL | Not yet used |
| None | TWITCH_BROADCASTER_ID | Not yet used |
| None | TWITCH_BROADCASTER_NAME | not yet used |
| Generation | REPLY_METHOD | Method to use for generating a reply to user's message. At this point only 'openai' is supported. |
| Generation | OPENAI_API_KEY | API Key used for generating replies |
| Generation | OPENAI_MODEL | Which LLM model to use. |
| Generation | OPENAI_IMAGE_MODEL | Which image model to use. |
| Generation | IMAGE_STYLE | vivid or natural |
| Generation | MAX_TOKENS | Max number of tokens generated in LLM chat. |
| Generation | TEMPERATURE | Float value for temperature of LLM chat response. |
| Generation | TOP_P | Float value alternative to temperature with LLM chat. |
| Generation | FREQUENCY_PENALTY | Frequency penalty for LLM chat. |
| Generation | PRESENCE_PENALTY | Presence penalty for LLM chat. |
| Generation | SMMRY_BASE_URL | base URL for the SMMRY API. |
| Generation | SMMRY_API_KEY | API key for the SMMRY API |
| Generation | SMMRY_QUOTE_AVOID | SMMRY boolean option on whether to avoid or include quotes in text that's summarized. Usually true. |
| Generation | SMMRY_LENGTH | max number of sentences a summary should be. |
| Generation | SMMRY_MIN_REDUCED_AMOUNT | Minium percentage a news article should be reduced by summarization to post it. |
| Generation | NEWS_CHANNEL_ID | Not currently used, but was automatically summarizing articles posted into a particular discord channel. |

The main module. Used to roll dice and for any other randomization-based tasks.
## Compose

### Audio
Below is an example docker compose spec if using all functionality.

The audio module uses yt-dlp to download videos and stream the audio into whichever channel the calling user is in.
```yml
name: Dolores

### Scheduling
services:
dolores:
image: exaltatus/dolores:latest
container_name: dolores
restart: unless-stopped
volumes:
- C:\{Docker folder}\Dolores:/home/dolores/config
lavalink:
image: ghcr.io/lavalink-devs/lavalink:4
container_name: lavalink
restart: unless-stopped
environment:
- _JAVA_OPTIONS=-Xmx6G
- SERVER_PORT=2333
- SERVER_ADDRESS=0.0.0.0
- SERVER_HTTP2_ENABLED=true
- LAVALINK_SERVER_PASSWORD=password
- LAVALINK_SERVER_SOURCES_YOUTUBE=true
- LAVALINK_SERVER_SOURCES_BANDCAMP=false
- LAVALINK_SERVER_SOURCES_SOUNDCLOUD=false
- LAVALINK_SERVER_SOURCES_TWITCH=false
- LAVALINK_SERVER_SOURCES_VIMEO=false
- LAVALINK_SERVER_SOURCES_HTTP=true
- LAVALINK_SERVER_SOURCES_LOCAL=false
- LAVALINK_PLUGINS_DIR=/opt/Lavalink/plugins/
volumes:
- C:\{Docker folder}\lavalink\plugins/:/opt/Lavalink/plugins/
networks:
- lavalink
expose:
- 2333
ports:
- "2333:2333"
```
## Modules
The scheduling module is used for tasks related to Notion and Twitch. Pulling schedule in from a Notion database and posting to twitch schedule.
Dolores' functionality is divided into several cogs modules. `dolores.py` handles main discord events and processing commands.

### Text
| Cog | Description |
| --- | ----------- |
| Rolling | Used to roll dice and for any other randomization-based tasks. |
| Audio | The audio module uses pomice/lavalink to stream audio. Uses a queue system. Largely a copy of the example bot given in pomice's documentation. |
| Scheduling | The scheduling module is used for tasks related to Notion and Twitch. Pulling schedule in from a Notion database and posting to twitch schedule. |
| Generation | Module for text and image generation. Currently using chatGPT, but intent is to move to add ability to use self-hosted LLM. Should be able to choose between something the user is hosting or commercially available alternatives. Also handles simple randomized snarky replies. |

Module for text generation. Currently using chatGPT, but intent is to move to add ability to use self-hosted LLM. Should be able to choose between something the user is hosting or commercially available alternatives. Also handles simple randomized snarky replies.
## Licensing

This project is licensed under the terms of the MIT license.
This project is licensed under the terms of the MIT license.
44 changes: 0 additions & 44 deletions config/example_config.yml

This file was deleted.

10 changes: 0 additions & 10 deletions configload.py

This file was deleted.

3 changes: 1 addition & 2 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
FROM python:3.12
RUN apt-get -y update && apt-get install -y ffmpeg
RUN python -m pip install --upgrade pip
RUN mkdir /home/dolores
COPY . /home/dolores
RUN python -m venv /home/dolores/.venv
RUN . /home/dolores/.venv/bin/activate
RUN pip install -r /home/dolores/requirements.txt
CMD python /home/dolores/dolores.py
CMD python /home/dolores/src/dolores.py
56 changes: 56 additions & 0 deletions locales/strings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"LLM_SYSTEM_MESSAGES": [
"Your name is Dolores.",
"Your replies should be snarky, sarcastic, and funny.",
"You are a female AI that runs on a Discord server.",
"You have inner thoughts and monologues.",
"You will occasionally say ominous things.",
"The name of your programmer is Jordan."
],
"SARCASTIC_NAMES": [
"my lovely",
"darling",
"sweetie",
"sweetie-pie",
"my sugar lump princess",
"my big strong warrior",
"dearest",
"lover",
"honey",
"foxy mama",
"loathsome dung eater",
"baby girl",
"Felicia",
"mamacita",
"diva",
"hunty",
"Queen",
"Jan"
],
"SNARKY_COMMENTS": [
"How many sessions is it gonna take before you people understand how to use my commands?",
"Wrong.",
"I cannot do that...",
"Nope.",
"Not a command, sweetie.",
"Must I hold your hand for this?",
"Oh, ya still cannot type?",
"Girl, go hit up Mavis Beacon, cuz you cannot type.",
"Close.",
"Slow.",
"Homeless.",
"Goon.",
"You goonga.",
"Prison, honey.",
"No.",
"Big Dumb."
],
"SUMMARY_EXCLUDED_STRINGS": [
"tenor",
"giphy",
"imgur",
"gfycat",
"youtube",
"youtu.be"
]
}
106 changes: 0 additions & 106 deletions modules/audio.py

This file was deleted.

Loading

0 comments on commit 993ac22

Please sign in to comment.