ford442 commited on
Commit
bc534c7
·
verified ·
1 Parent(s): 56b069d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -83,8 +83,11 @@ model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map='balanced')
83
 
84
  def filter_text(text):
85
  """Filters out the text up to and including 'Rewritten Prompt:'."""
86
- pattern = r".*?Rewritten Prompt:\s*" # Matches any characters up to 'Rewritten Prompt:'
87
- filtered_text = re.sub(pattern, "", text,flags=re.DOTALL) # Removes the matched pattern from the text
 
 
 
88
  return filtered_text
89
 
90
  MAX_SEED = np.iinfo(np.int32).max
 
83
 
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
+ match = re.search(pattern, text)
89
+ # match = re.search(pattern, text,flags=re.DOTALL)
90
+ filtered_text = match.group(2)
91
  return filtered_text
92
 
93
  MAX_SEED = np.iinfo(np.int32).max