Commit 56371153 authored by DoTheSneedful's avatar DoTheSneedful Committed by AUTOMATIC1111

XY plot prompt order simplify logic

parent 1a6d40db
......@@ -38,15 +38,21 @@ def apply_order(p, x, xs):
token_order.sort(key=lambda t: t[0])
search_from_pos = 0
for idx, (original_pos, old_token) in enumerate(token_order):
# Get position of the token again as it will likely change as tokens are being replaced
pos = search_from_pos + p.prompt[search_from_pos:].find(old_token)
if original_pos >= 0:
# Avoid trying to replace what was just replaced by searching later in the prompt string
p.prompt = p.prompt[0:search_from_pos] + p.prompt[search_from_pos:].replace(old_token, x[idx], 1)
search_from_pos = pos + len(x[idx])
prompt_parts = []
# Split the prompt up, taking out the tokens
for _, token in token_order:
n = p.prompt.find(token)
prompt_parts.append(p.prompt[0:n])
p.prompt = p.prompt[n + len(token):]
# Rebuild the prompt with the tokens in the order we want
prompt_tmp = ""
for idx, part in enumerate(prompt_parts):
prompt_tmp += part
prompt_tmp += x[idx]
p.prompt = prompt_tmp + p.prompt
samplers_dict = {}
for i, sampler in enumerate(modules.sd_samplers.samplers):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment