IAMTFRMZA commited on
Commit
cc2834a
ยท
verified ยท
1 Parent(s): 79637d3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -2
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
- # โœ… Clean formatting and strip noise
145
- cleaned_reply = re.sub(r'\[source[\d\.]+\]', '', raw_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)