aboutsummaryrefslogtreecommitdiffstats
path: root/modules/prompt_parser.py
diff options
context:
space:
mode:
authorAUTOMATIC <16777216c@gmail.com>2023-01-15 19:29:53 +0000
committerAUTOMATIC <16777216c@gmail.com>2023-01-15 19:29:53 +0000
commit8e2aeee4a127b295bfc880800e4a312e0f049b85 (patch)
treea1354cb94c09ad00216e5eadda48259be494fea9 /modules/prompt_parser.py
parent205991df7826429e6183fc4afbbda3d321c9fee4 (diff)
downloadstable-diffusion-webui-gfx803-8e2aeee4a127b295bfc880800e4a312e0f049b85.tar.gz
stable-diffusion-webui-gfx803-8e2aeee4a127b295bfc880800e4a312e0f049b85.tar.bz2
stable-diffusion-webui-gfx803-8e2aeee4a127b295bfc880800e4a312e0f049b85.zip
add BREAK keyword to end current text chunk and start the next
Diffstat (limited to 'modules/prompt_parser.py')
-rw-r--r--modules/prompt_parser.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/modules/prompt_parser.py b/modules/prompt_parser.py
index 870218db..69665372 100644
--- a/modules/prompt_parser.py
+++ b/modules/prompt_parser.py
@@ -274,6 +274,7 @@ re_attention = re.compile(r"""
:
""", re.X)
+re_break = re.compile(r"\s*\bBREAK\b\s*", re.S)
def parse_prompt_attention(text):
"""
@@ -339,7 +340,11 @@ def parse_prompt_attention(text):
elif text == ']' and len(square_brackets) > 0:
multiply_range(square_brackets.pop(), square_bracket_multiplier)
else:
- res.append([text, 1.0])
+ parts = re.split(re_break, text)
+ for i, part in enumerate(parts):
+ if i > 0:
+ res.append(["BREAK", -1])
+ res.append([part, 1.0])
for pos in round_brackets:
multiply_range(pos, round_bracket_multiplier)