Kilvoctu / aiyabot

A neat Discord bot for AUTOMATIC1111's Web UI
GNU General Public License v2.0
305 stars 79 forks source link

Generate fix + draw button + other model #209

Closed wizz13150 closed 10 months ago

wizz13150 commented 10 months ago

Hey,

hope you're fine !

I adjusted the Generate command this way :

Seems robust to me. Had to adjust here and there.

Screenshots :

image image image

Cheers ! 🥂

wizz13150 commented 10 months ago

huh, i should use git one day for my commits ...

wizz13150 commented 10 months ago

Ah crap, the buttons break after a few minutes... huh

Don't know how to manage with this yet, even looking at the existing code, lol.

solareon commented 10 months ago

Welcome to the hell that is discord buttons and context menus lol. They break in all sorts or new and exciting ways when you least expect it.

wizz13150 commented 10 months ago

ahahah !

Yeah, also noticed/realized the 4096 chars allowed for a discord message. So it doesnt' fit my maximum allowed for /Generate when asking for 10 prompts of 250 tokens.

So i need to calculate the max amount generated and decrease the max prompt or length, or dynamically calculate this maybe. Will see, not a blocking issue...

I'm less confident for the button, i don't want to complexify even more the code. I don't close this PR yet, just as lab.

Cheers ! 🥂

wizz13150 commented 10 months ago

Okay, let's start again from this and see. A 'lil bit more homogeneous with the bot. Just a bit lol.

image

Result, For viewing pleasure :

image image image

Also, i think posting a single PR for both /generate and the progression message would be nice. Had to add 2 more controls in it. Here is the actual visual :

image

Waiting to see if i can post a single PR or not. And if i can find a clue about the buttons-breaking management... Seems not bad except this point.

wizz13150 commented 10 months ago

Okay, this timeout arg was the trick. *Edit: Or not ...

Buttons still working after a while. *Edit: meh, another error. Need to reactivate the button in some way. Also, default max_length is now 75 tokens, from 100, to speed up the generation. No need more as default value.

So, i'll wait and see what to edit to finalize this, would be cool to have a feedback about the logic/method, and then i'll post a single PR for both current ones.

Time to bed.

Cheers ! 🥂

wizz13150 commented 10 months ago

hum, not bad, waiting to see if it's still working in an hour lol 😅

Added a Reroll button, suggested by a friend. Will reroll the /Generate command for new prompts.

image

I may add a 'Draw from Caption' button to identify too. Will see.

wizz13150 commented 10 months ago

Found this, i'll dig.

https://github.com/Pycord-Development/pycord/blob/master/examples/views/persistent.py

wizz13150 commented 10 months ago

I give up !

I think I'll dissect viewhandler.py and mimic what I see. Maybe I should use this file for my buttons, in fine.

huh, so frustrating, lmao !

wizz13150 commented 10 months ago

So, i tried to implement my generatecog.py buttons-related code into viewhandler.py... But it seems quite impossible for me to manage interactions/response properly... with my skillset. And i still have 15+min issues anyway ...

Back to my initial approach, using only generatecog.py seems to be the way, but i'm back on my old problems.

Discord is a fucking joke !!!!!!!! Kind of pissed off atm, i literally got an headache from this.

Any help/code review available ? If someone have some time to waste 😭

At this point i'm close. (probably not exactly the commits here)

Here is my last issue : After a while, the buttons will send to discord the exception message, instead of the good one image

And in the console, i get:

Received interaction: {'custom_id': 'prompt_0', 'component_type': 2}
Entering PromptButton callback
Request -- toto#6969 -- Prompt: rise of kingdom, chaos, realist, trending on artstation, volumetric lighting, cgsociety, ralph mcquarrie and greg rutkowski, cinematic light, octane render, dramatic lighting, hyperrealistic, high details, cinematic colors, 8k resolution, beautiful detailed, photorealistic, digital painting, concept art, smooth <lora:Details:0.85>
The draw button broke: 401 Unauthorized (error code: 50027): Invalid Webhook Token
**Traceback: Traceback (most recent call last):
  File "C:\Users\wizz\stable-diffusion\aiyabot\core\generatecog.py", line 30, in callback
    await self.parent_view.stable_cog.dream_handler(self.parent_view.ctx, prompt=prompt)
  File "C:\Users\wizz\stable-diffusion\aiyabot\venv\lib\site-packages\discord\commands\core.py", line 251, in __call__
    return await self.callback(self.cog, ctx, *args, **kwargs)
  File "C:\Users\wizz\stable-diffusion\aiyabot\core\stablecog.py", line 358, in dream_handler
    await ctx.send_followup(message_to_send)
  File "C:\Users\wizz\stable-diffusion\aiyabot\venv\lib\site-packages\discord\webhook\async_.py", line 1745, in send
    data = await adapter.execute_webhook(
  File "C:\Users\wizz\stable-diffusion\aiyabot\venv\lib\site-packages\discord\webhook\async_.py", line 221, in request
    raise HTTPException(response, data)
discord.errors.HTTPException: 401 Unauthorized (error code: 50027): Invalid Webhook Token** 

Buuut, the job (Draw buttons or Reroll) is actually running fine. Like, the button is working fine, but i get this error and the exception message is sent. I just don't understand what i don't understand, and how to manage this token issue.

I give up on this for now. Will try later.