Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -141,8 +141,16 @@ with tab1:
|
|
141 |
if m.role == "assistant":
|
142 |
raw_reply = m.content[0].text.value.strip()
|
143 |
|
144 |
-
# โ
|
145 |
-
cleaned_reply =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
cleaned_reply = re.sub(r'\n{3,}', '\n\n', cleaned_reply)
|
147 |
cleaned_reply = re.sub(r'\*\*+', '**', cleaned_reply)
|
148 |
cleaned_reply = re.sub(r'(?<=\n)([-*]\s[^\n]+)', r'\1\n', cleaned_reply)
|
|
|
141 |
if m.role == "assistant":
|
142 |
raw_reply = m.content[0].text.value.strip()
|
143 |
|
144 |
+
# โ
Format cleanup and enhancement
|
145 |
+
cleaned_reply = raw_reply
|
146 |
+
cleaned_reply = re.sub(r'\[source[\d\.]+\]', '', cleaned_reply)
|
147 |
+
cleaned_reply = re.sub(r'(?i)^document references', '### ๐ Document References', cleaned_reply, flags=re.MULTILINE)
|
148 |
+
cleaned_reply = re.sub(r'(?i)^key points', '### ๐ Key Points', cleaned_reply, flags=re.MULTILINE)
|
149 |
+
cleaned_reply = re.sub(r'(?i)^some possible questions', '### โ Some Possible Questions', cleaned_reply, flags=re.MULTILINE)
|
150 |
+
cleaned_reply = re.sub(r'(?i)^other references', '### ๐ Other References', cleaned_reply, flags=re.MULTILINE)
|
151 |
+
cleaned_reply = re.sub(r'(?i)^section[:]', '**Section:**', cleaned_reply, flags=re.MULTILINE)
|
152 |
+
cleaned_reply = re.sub(r'(Page \d+)', r'**\1**', cleaned_reply)
|
153 |
+
cleaned_reply = re.sub(r'(https://raw\.githubusercontent\.com/AndrewLORTech/witspathologai/main/[^\s\n"]+\.png)', r'[๐ผ๏ธ View Referenced Image](\1)', cleaned_reply)
|
154 |
cleaned_reply = re.sub(r'\n{3,}', '\n\n', cleaned_reply)
|
155 |
cleaned_reply = re.sub(r'\*\*+', '**', cleaned_reply)
|
156 |
cleaned_reply = re.sub(r'(?<=\n)([-*]\s[^\n]+)', r'\1\n', cleaned_reply)
|