ljleb / sd-webui-neutral-prompt

Collision-free AND keywords for a1111 webui!
MIT License
187 stars 13 forks source link

Conflict with Prompt fusion extension #31

Closed asagi4 closed 1 year ago

asagi4 commented 1 year ago

There seems to be a conflict between prompt fusion and this extension when using variables, even when NP is not in use.

I'm on mobile right now, so I can't give you all the details, but I did disable most of my extensions that may have conflicted. This should be easy to reproduce with a simple prompt:

$p=cat, [blue fur:red fur:,]
$p

With Neutral Prompt enabled, it seems this gets interpreted as an empty prompt. If I don't use variables, things work as expected.

ljleb commented 1 year ago

Indeed, there is a situation here. Neutral prompt transforms newlines into whitespace before further processing. The reason newlines are transformed is that the webui prompt parser stops handling AND keywords properly as soon as there is a newline anywhere other than in the first prompt.

There are multiple options here. I could remove variables from PF because there are other extensions that add these refactoring capabilities.

I'm not sure the AND parsing is easily monkey patched, so I could open a PR in the webui. Once it is handled properly the extension will be able to work without stripping newlines.

asagi4 commented 1 year ago

I tried this, but it doesn't seem to work quite right. As far as I can tell, neutral prompt still sees the prompt without the variables expanded because it hijacks a function that gets called before prompt fusion does variable expansion.

I tried to make NP hijack get_learned_conditioning and making sure the functions are called in order with prompt fusion going first, but that doesn't seem to be the correct solution either.

ljleb commented 1 year ago

I just merged a second PR that now should make both extensions compatible. Are you sure you tested on the latest version?

asagi4 commented 1 year ago

I had the commit just before the last one. With the latest commit, everything seems to work properly. Thanks for the fix!