Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't use multicond parser for negative prompt counter #13118

Merged
merged 2 commits into from
Sep 9, 2023

Conversation

ljleb
Copy link
Contributor

@ljleb ljleb commented Sep 6, 2023

Description

The negative prompt token counter uses the multicond prompt parser, which is currently only effectively used by the positive prompt when generating.

When using conds caching, if the user only changes the negative prompt, then prompt_parser.get_multicond_prompt_list is called only to update the negative counter, but is not called during generation. This creates issues for prompt extensions that patch get_multicond_prompt_list to update the counter correctly. See for example ljleb/sd-webui-neutral-prompt#44

Screenshots/videos:

Before (negative counter = 2/75, positive counter = 2/75):

image

After (negative counter = 4/75, positive counter = 2/75):

image

Checklist:

@AUTOMATIC1111
Copy link
Owner

AUTOMATIC1111 commented Sep 9, 2023

it would be a lot less copy-pasted code if you just change def update_token_counter(text, steps): to def update_token_counter(text, steps, *, is_negative_prompt=False):.

@ljleb
Copy link
Contributor Author

ljleb commented Sep 9, 2023

refactored, hope it's more to your taste now.

linter fails on a file I did not touch?

@AUTOMATIC1111 AUTOMATIC1111 merged commit 73c2a03 into AUTOMATIC1111:dev Sep 9, 2023
2 of 3 checks passed
@ljleb ljleb deleted the fix-counter branch September 9, 2023 07:26
AUTOMATIC1111 added a commit that referenced this pull request Sep 9, 2023
@w-e-w w-e-w mentioned this pull request Dec 4, 2023
@w-e-w w-e-w mentioned this pull request Dec 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants