AndrewVeee / nucleo-ai

An AI assistant beyond the chat box.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Stable Diffusion support

AndrewVeee opened this issue · comments

AUTOMATIC1111 has an API:
https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/API

This looks really easy to build with! Here are some notes:

The function definition would look something like:

class CreateImage:
  def __init__(self, app):
    self.app = app
    self.reg = app.ai_functions.define(self.run, 'create_image', 'Create a new image',
        short_description="create images")
    self.reg.add_argument('description', 'An in-depth one line description of the image to create', question="What is the description of the image?")
    self.reg.add_argument('count', 'Number of sample images to create (default is 1)', question="How many images did the user request?")
    self.reg.add_to('Artist')

Add a config file section for it:

[a1111]
base_url = 'http://localhost:7860/' # App will append /sdapi/v1/txt2img

Then it's just a matter of sending the description to the API, writing the images to the data/uploads/ folder, and sending the response back, like f"I created an image for you: "

Got a test version of this working. Here's what's left to do:

  • Create an ID for the image returned (UserStore.create(data_type='upload', name=filename, content=description))
  • Save the image returned to data/uploads/{id}-{filename} (note: should probably use jpg instead of png)
  • Add a /uploads/ endpoint to serve the file

Running into some issues getting flask to send a test file. Once that's working, this should be ready to release.