sdwebui-w-horde / sd-webui-stable-horde-worker

Stable Horde Unofficial Worker Bridge as Stable Diffusion WebUI (AUTOMATIC1111) Extension
GNU Affero General Public License v3.0
60 stars 18 forks source link

Prompt splitting multiple delimiters #44

Closed SlayerTO closed 1 year ago

SlayerTO commented 1 year ago

had an occurence of multiple ### in prompt, rsplit would be one solution. No solution is perfect because there is no way of finding out which is the real delimiter.

SlayerTO commented 1 year ago

soome clients do not add the whitespace before and after the delimteter. would introduce another unwanted bahavior

MaikoTan commented 1 year ago

Hello, thanks for the PR.

So you meant that some prompts would contain multiple ###s which causes part of the "positive" prompt would become the negative prompt? Is there any other problem with this solution? Could you let me know why closed the PR?

SlayerTO commented 1 year ago

For sure @MaikoTan

I tried this solution first but very quickly I realized that you can get valid proompts where there are no white spaces for example "cat###dog" usually the prompt will be delivered like this "cat ### dogs" so that solution will fail in the first case, because i don't know how to edit an already oopend pull request i closed it.

I'm playing around modified it to run multi model and with one request I had the problem that someone did manage to write a prompt like this "white###cat ### dog" that did fail obvios because the map got 3 instead of 2 parms.

A solution would be

prompt, negative = map(lambda x: x.strip(), prompt.rsplit(###", 1))

however we can't with certainty say if the additioonal delimiter is in the positiv or negativ part. But with an rsplit or an split limited to 1 we could at least run the request.

The optimal solution would be if we could flag the request as an maleformed prompt for the API but i didn't saw anything like this.

Now im unsure if i should open another patch for the one liner, if you want that at all or if you implement a solution yourself.

best regards