Update app.py
Browse files
app.py
CHANGED
@@ -28,10 +28,23 @@ chat = Conversation()
|
|
28 |
t2a = T2A()
|
29 |
|
30 |
def remove_labels_with_regex(text: str):
|
|
|
31 |
pattern = r'^(Human:|AI:|Chelsea:)\s*'
|
32 |
-
cleaned_text = re.sub(pattern, '',
|
33 |
return cleaned_text
|
34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
def main():
|
37 |
try:
|
|
|
28 |
t2a = T2A()
|
29 |
|
30 |
def remove_labels_with_regex(text: str):
|
31 |
+
removed_dub = remove_duplicates(text)
|
32 |
pattern = r'^(Human:|AI:|Chelsea:)\s*'
|
33 |
+
cleaned_text = re.sub(pattern, '', removed_dub, flags=re.MULTILINE)
|
34 |
return cleaned_text
|
35 |
|
36 |
+
def remove_duplicates(text):
|
37 |
+
lines = text.split('\n')
|
38 |
+
seen = set()
|
39 |
+
result = []
|
40 |
+
|
41 |
+
for line in lines:
|
42 |
+
if line not in seen:
|
43 |
+
result.append(line)
|
44 |
+
seen.add(line)
|
45 |
+
|
46 |
+
return '\n'.join(result)
|
47 |
+
|
48 |
|
49 |
def main():
|
50 |
try:
|