2
2
import fnmatch
3
3
import os
4
4
import os .path
5
- import re
6
5
import typing
7
6
import shutil
8
7
@@ -14,22 +13,6 @@ class PromptStyle(typing.NamedTuple):
14
13
path : str = None
15
14
16
15
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
-
33
16
def merge_prompts (style_prompt : str , prompt : str ) -> str :
34
17
if "{prompt}" in style_prompt :
35
18
res = style_prompt .replace ("{prompt}" , prompt )
@@ -44,7 +27,7 @@ def apply_styles_to_prompt(prompt, styles):
44
27
for style in styles :
45
28
prompt = merge_prompts (style , prompt )
46
29
47
- return clean_text ( prompt )
30
+ return prompt
48
31
49
32
50
33
def unwrap_style_text_from_prompt (style_text , prompt ):
@@ -56,8 +39,8 @@ def unwrap_style_text_from_prompt(style_text, prompt):
56
39
Note that the "cleaned" version of the style text is only used for matching
57
40
purposes here. It isn't returned; the original style text is not modified.
58
41
"""
59
- stripped_prompt = clean_text ( prompt )
60
- stripped_style_text = clean_text ( style_text )
42
+ stripped_prompt = prompt
43
+ stripped_style_text = style_text
61
44
if "{prompt}" in stripped_style_text :
62
45
# Work out whether the prompt is wrapped in the style text. If so, we
63
46
# return True and the "inner" prompt text that isn't part of the style.
0 commit comments