Skip to content

Commit f92d614

Browse files
Merge pull request #14203 from AUTOMATIC1111/remove-clean_text()
remove clean_text()
2 parents 22e23db + 854f8c3 commit f92d614

File tree

1 file changed

+3
-20
lines changed

1 file changed

+3
-20
lines changed

modules/styles.py

+3-20
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import fnmatch
33
import os
44
import os.path
5-
import re
65
import typing
76
import shutil
87

@@ -14,22 +13,6 @@ class PromptStyle(typing.NamedTuple):
1413
path: str = None
1514

1615

17-
def clean_text(text: str) -> str:
18-
"""
19-
Iterating through a list of regular expressions and replacement strings, we
20-
clean up the prompt and style text to make it easier to match against each
21-
other.
22-
"""
23-
re_list = [
24-
("multiple commas", re.compile("(,+\s+)+,?"), ", "),
25-
("multiple spaces", re.compile("\s{2,}"), " "),
26-
]
27-
for _, regex, replace in re_list:
28-
text = regex.sub(replace, text)
29-
30-
return text.strip(", ")
31-
32-
3316
def merge_prompts(style_prompt: str, prompt: str) -> str:
3417
if "{prompt}" in style_prompt:
3518
res = style_prompt.replace("{prompt}", prompt)
@@ -44,7 +27,7 @@ def apply_styles_to_prompt(prompt, styles):
4427
for style in styles:
4528
prompt = merge_prompts(style, prompt)
4629

47-
return clean_text(prompt)
30+
return prompt
4831

4932

5033
def unwrap_style_text_from_prompt(style_text, prompt):
@@ -56,8 +39,8 @@ def unwrap_style_text_from_prompt(style_text, prompt):
5639
Note that the "cleaned" version of the style text is only used for matching
5740
purposes here. It isn't returned; the original style text is not modified.
5841
"""
59-
stripped_prompt = clean_text(prompt)
60-
stripped_style_text = clean_text(style_text)
42+
stripped_prompt = prompt
43+
stripped_style_text = style_text
6144
if "{prompt}" in stripped_style_text:
6245
# Work out whether the prompt is wrapped in the style text. If so, we
6346
# return True and the "inner" prompt text that isn't part of the style.

0 commit comments

Comments
 (0)