runew0lf / RuinedFooocus

Focus on prompting and generating
GNU General Public License v3.0
370 stars 20 forks source link

Fixed OneButtonPrompt wildcards generating same results #84

Closed Lavorther closed 11 months ago

Lavorther commented 11 months ago

Fixed OneButtonPrompt wildcards generating same results when used multiple times in same prompt. Mostly just moved all the existing prompt generation code down to the final step (replacing into the prompt text), which ensures it doesn't reuse the previous generation.

For normal wildcards, the contents of their text file is added to the placeholder_choices dict, and then in the second loop at the end of the process_wildcards() function it picks a random one from that list for each wildcard encountered in the prompt and replaces it with that pick. However, what the old code for OneButtonPrompt wildcards did, was add a list with a single entry to that dict for the relevant OneButtonPrompt generation, then for each future matches, it would overwrite the existing dict entry with a new single-item list. Then, at the end, it loops again and picks a random entry from this single-item list, which of course is always the same entry. By moving the generation code down to the second loop, it will now generate a random prompt for each OneButtonPrompt wildcard it encounters even when it has seen it before, because it's no longer tracking them in the dict but generating a new one when needed.