AndrewVeee / nucleo-ai

An AI assistant beyond the chat box.
Apache License 2.0
313 stars 29 forks source link

Stable Diffusion support #1

Open AndrewVeee opened 7 months ago

AndrewVeee commented 7 months ago

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: "

AndrewVeee commented 7 months ago

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

AndrewVeee commented 7 months ago

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