Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -139,30 +139,11 @@ with tab1:
|
|
139 |
messages = client.beta.threads.messages.list(thread_id=st.session_state.thread_id)
|
140 |
for m in reversed(messages.data):
|
141 |
if m.role == "assistant":
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
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)
|
157 |
-
cleaned_reply = cleaned_reply.strip()
|
158 |
-
|
159 |
-
if not any(cleaned_reply in msg["content"] or msg["content"] in cleaned_reply for msg in st.session_state.messages if msg["role"] == "assistant"):
|
160 |
-
st.session_state.messages.append({"role": "assistant", "content": cleaned_reply})
|
161 |
-
|
162 |
-
image_matches = re.findall(
|
163 |
-
r'https://raw\.githubusercontent\.com/AndrewLORTech/witspathologai/main/[^\s\n"]+\.png',
|
164 |
-
cleaned_reply
|
165 |
-
)
|
166 |
if image_matches:
|
167 |
st.session_state.image_url = image_matches[0]
|
168 |
st.session_state.image_updated = True
|
@@ -187,7 +168,6 @@ with tab1:
|
|
187 |
except Exception as e:
|
188 |
st.error(f"๐ผ๏ธ Failed to load image: {e}")
|
189 |
|
190 |
-
|
191 |
# ------------------ Tab 2: Visual Reference Search ------------------
|
192 |
with tab2:
|
193 |
ASSISTANT_ID = "asst_9v09zgizdcuuhNdcFQpRo9RO"
|
|
|
139 |
messages = client.beta.threads.messages.list(thread_id=st.session_state.thread_id)
|
140 |
for m in reversed(messages.data):
|
141 |
if m.role == "assistant":
|
142 |
+
reply = m.content[0].text.value.strip()
|
143 |
+
if not any(reply in msg["content"] or msg["content"] in reply for msg in st.session_state.messages if msg["role"] == "assistant"):
|
144 |
+
st.session_state.messages.append({"role": "assistant", "content": reply})
|
145 |
+
|
146 |
+
image_matches = re.findall(r'https://raw\.githubusercontent\.com/AndrewLORTech/witspathologai/main/[^\s\n"]+\.png', reply)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
if image_matches:
|
148 |
st.session_state.image_url = image_matches[0]
|
149 |
st.session_state.image_updated = True
|
|
|
168 |
except Exception as e:
|
169 |
st.error(f"๐ผ๏ธ Failed to load image: {e}")
|
170 |
|
|
|
171 |
# ------------------ Tab 2: Visual Reference Search ------------------
|
172 |
with tab2:
|
173 |
ASSISTANT_ID = "asst_9v09zgizdcuuhNdcFQpRo9RO"
|