GithubHelp home page GithubHelp logo

diehard073055 / discordasyncjobhandler Goto Github PK

View Code? Open in Web Editor NEW
0.0 5.0 0.0 3.09 MB

Discord bot that efficiently manages long-running tasks through a job queue system, allowing users to execute AI-based tasks without blocking other processes. Features background processing and seamless user interaction.

License: MIT License

Python 100.00%

discordasyncjobhandler's Introduction

DiscordAsyncJobHandler

This project implements an AI-powered Discord bot capable of generating images and text based on user input. It utilizes a job queue system to manage and process image and text generation requests asynchronously. The bot is built using the Discord.py library and communicates with separate AI models for image and text generation.

Demo

Here's a demonstration of the bot in action:

Bot demonstration

How it works

  1. The main entry point of the application is main.py. This file initializes the custom Discord client, sets up logging, and starts the job queue thread.
  2. The custom Discord client is defined in client.py. It is responsible for handling interactions and managing the command tree.
  3. The bot uses a job queue system to manage requests. This is implemented in job_handler.py. The job queue runs in a separate thread and processes jobs asynchronously.
  4. Image and text generation commands are defined in commands/img.py and commands/txt.py, respectively. Each command is a function that takes user input and adds a job to the job queue.
  5. The bot uses separate AI models for image and text generation. The models are hosted on external servers and are accessed via HTTP requests.
  6. Configuration parameters for the bot and AI models are stored in config.py.

Setup

  1. Install the required Python packages using pip install -r requirements.txt.
  2. Set up the environment variables:
    • DISCORD_BOT_TOKEN: Your Discord bot token
    • DISCORD_GUILD_ID: The ID of the guild (server) where your bot will be deployed
  3. Run the bot using python main.py.

Usage

Once the bot is running, you can use the following commands in your Discord server:

  • /img: Generates an image based on the provided prompt and optional parameters.
  • /txt: Generates text based on the provided prompt and optional parameters.

Please refer to the command descriptions for more information on the available parameters and their usage.

Contributing

If you'd like to contribute to this project, please create a fork and submit a pull request with your changes. Make sure to follow the existing code style and include relevant documentation.

License

This project is licensed under the MIT License. See the LICENSE file for more information.

discordasyncjobhandler's People

Contributors

diehard073055 avatar pamdayne avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

discordasyncjobhandler's Issues

Suggestion: Bot prompt respond messages

Story

As a user, I want to receive bot message responds at appropriate timing.

Current iteration

There are about 4 different messages, which can be confusing which messages are responding for which.

Screenshot CleanShot 2023-04-27 at 23 03 36@2x

We could improve this user experience. โœจ

Suggestion

Send very few - about two (2) types of respond messages after user submits a prompt.

  1. Pending message. Examples:
    • Acknowledging: Prompt received. ๐Ÿšง Generating image...
    • Optional: message is deleted after image generation is done
    • Bonus: message can only be seen by the user.
Blue willow example image
WOMBO Dream example image
  1. Message sent ALONG with the image generated result
    • User name and prompt: @<tag username> prompted: <user's prompt> OR
    • Prompt then tag User name: ๐Ÿ–ผ๏ธ <user's prompt> - @<tag username>
    • Optional: include negative prompt
    • Optional: include "preset" used (relating to issue #7 )
Blue willow example CleanShot 2023-04-27 at 23 00 27@2x
WOMBO Dream example image

Show error message to user when cluster has issue

Background

There is not indicator to the user that there is a problem happening.
Example: Out of Memory
CleanShot 2023-05-01 at 23 05 47@2x

Error should be shown to user as well when the cluster runs into an issue.

Oops! Something went wrong. Please try again later.

Suggestion: Preset negative prompt

Story

As a a user, I want to be able to select a preset negative prompt.

I want to be able to just render apple without needing to override the current negative prompt.

DEFAULT_NEGATIVE_PROMPT="paintings, sketches, (worst quality:2), (low quality:2), (normal quality:2), lowres, normal quality, ((monochrome)), ((grayscale)), skin spots, acnes, skin blemishes, age spot, glans, (ugly:1.331), (duplicate:1.331), (morbid:1.21), (mutilated:1.21), (tranny:1.331), mutated hands, (poorly drawn hands:1.331), blurry, 3hands,4fingers,3arms, bad anatomy, missing fingers, extra digit, fewer digits, cropped, jpeg artifacts,poorly drawn face,mutation,deformed"

Suggestion

Let's set the negative prompt to empty.

DEFAULT_NEGATIVE_PROMPT = ""

Then, one of the options can be the negative prompt.

NEGATIVE_PROMPT_PRESET_GOOD_LOOKING="paintings, sketches, (worst quality:2), (low quality:2), (normal quality:2), lowres, normal quality, ((monochrome)), ((grayscale)), skin spots, acnes, skin blemishes, age spot, glans, (ugly:1.331), (duplicate:1.331), (morbid:1.21), (mutilated:1.21), (tranny:1.331), mutated hands, (poorly drawn hands:1.331), blurry, 3hands,4fingers,3arms, bad anatomy, missing fingers, extra digit, fewer digits, cropped, jpeg artifacts,poorly drawn face,mutation,deformed"
Screenshot of `OPTIONAL` messages

CleanShot 2023-04-27 at 23 11 31@2x

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.