TiagoMarinho / Soph

A discord bot for generating images with artificial intelligence
19 stars 4 forks source link
artificial-intelligence discord-bot discord-js stable-diffusion


Soph

A discord bot for generating art with artificial intelligence

Table of Contents

  1. How to use
  2. Features
  3. About
  4. Commands
  5. Installation
  6. Running
  7. Contributing

How to use

/dream prompt: 1girl, solo, blonde hair, twintails, blue eyes, blue dress

Here are some examples of possible images generated using the bot:

Four AI-generated images, each in a different style

Features

More about Soph

Soph works by communicating with Stable Diffusion WebUI API to generate images using artificial intelligence. This can be achieved by running WebUI locally on the same machine, on the same network or over the internet.

Soph prioritizes UX and being a first-class Discord citizen, and as such uses slash commands and rich embeds with proper multiple image support rather than baking all results into a single image grid, sending each result as a separate image attachment or only displaying one image at a time.

Individual images are sent as soon as they're ready rather than only sending the entire batch at once or showing multiple unfinished images at the same time, that way we can ensure the user gets useful and immediate feedback of their generation request.

animated GIF of Soph's response to a command

Commands

Installation

  1. Install https://github.com/AUTOMATIC1111/stable-diffusion-webui and its dependencies
  2. Add --api to WebUI's commandline arguments
  3. Install NodeJS
  4. Run git clone https://github.com/TiagoMarinho/Soph to clone Soph's repo
  5. Create a new Discord application in the Discord Developer Portal
  6. Copy the token and client id of your new discord application and put it in a new file inside Soph's root folder, Soph/config.json, like this:

    {
        "token": "TOKEN HERE",
        "clientId": "CLIENT ID HERE",
        "cacheChannelId": "SEE NEXT STEP"
    }
  7. Add a channel ID in the above config.json file for a chat your application has access to, so that it can use as a cache for the images. Every image generated with the bot will be sent in this chat first.
  8. Install dependencies by running npm install inside Soph's root folder
  9. Run npm run deploy inside Soph's root folder to register slash commands for the bot.

Running

  1. Launch WebUI and wait for it to finish loading
  2. Run node . inside Soph's root folder to launch Soph

Contributing

Contributions, even in the form of creating new issues, are more than welcome!

Here's a basic overview of the project structure for new contributors to get used to the code base:

Unabled to run Stable Diffusion but still want to contribute? You can install EdoanR's "a1111-fake-webui-api" to mimic the Stable Diffusion WebUI API to develop Soph without having to actually run the AI.