Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -84,12 +84,19 @@ model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map='balanced')
|
|
84 |
def filter_text(text):
|
85 |
"""Filters out the text up to and including 'Rewritten Prompt:'."""
|
86 |
phrase = "Rewritten Prompt: "
|
|
|
87 |
pattern = f"(.*?){re.escape(phrase)}(.*)"
|
88 |
-
|
|
|
89 |
# match = re.search(pattern, text,flags=re.DOTALL)
|
90 |
-
if
|
91 |
-
filtered_text =
|
92 |
-
|
|
|
|
|
|
|
|
|
|
|
93 |
else:
|
94 |
# Handle the case where no match is found
|
95 |
return text
|
|
|
84 |
def filter_text(text):
|
85 |
"""Filters out the text up to and including 'Rewritten Prompt:'."""
|
86 |
phrase = "Rewritten Prompt: "
|
87 |
+
phraseB = "rewritten text: "
|
88 |
pattern = f"(.*?){re.escape(phrase)}(.*)"
|
89 |
+
patternB = f"(.*?){re.escape(phraseB)}(.*)"
|
90 |
+
matchB = re.search(patternB, text)
|
91 |
# match = re.search(pattern, text,flags=re.DOTALL)
|
92 |
+
if matchB:
|
93 |
+
filtered_text = matchB.group(2)
|
94 |
+
match = re.search(pattern, filtered_text)
|
95 |
+
if match:
|
96 |
+
filtered_text = match.group(2)
|
97 |
+
return filtered_text
|
98 |
+
else:
|
99 |
+
return filtered_text
|
100 |
else:
|
101 |
# Handle the case where no match is found
|
102 |
return text
|