Update src/chat_display.py
Browse files- src/chat_display.py +7 -0
src/chat_display.py
CHANGED
|
@@ -6,6 +6,7 @@ import streamlit as st
|
|
| 6 |
import os
|
| 7 |
from utils import has_meaningful_content, remove_reasoning_and_sources, clean_explanation, get_image_base64
|
| 8 |
from session_state import get_full_history
|
|
|
|
| 9 |
|
| 10 |
|
| 11 |
def get_avatars():
|
|
@@ -68,6 +69,12 @@ def display_chat_history():
|
|
| 68 |
# Clean up the explanation text
|
| 69 |
cleaned_explanation = clean_explanation(message["explanation"])
|
| 70 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
with st.expander("Show Reasoning"):
|
| 72 |
st.markdown(cleaned_explanation)
|
| 73 |
|
|
|
|
| 6 |
import os
|
| 7 |
from utils import has_meaningful_content, remove_reasoning_and_sources, clean_explanation, get_image_base64
|
| 8 |
from session_state import get_full_history
|
| 9 |
+
import re
|
| 10 |
|
| 11 |
|
| 12 |
def get_avatars():
|
|
|
|
| 69 |
# Clean up the explanation text
|
| 70 |
cleaned_explanation = clean_explanation(message["explanation"])
|
| 71 |
|
| 72 |
+
# Additional cleaning to remove any source information from reasoning
|
| 73 |
+
# Remove any sources/references sections
|
| 74 |
+
cleaned_explanation = re.sub(r'(?i)(\n+\s*sources:|\n+\s*references:|\n+\s*\*{0,2}sources\*{0,2}:?|\n+\s*\*{0,2}references\*{0,2}:?|\n+\s*#{1,3}\s*sources|\n+\s*#{1,3}\s*references).*', '', cleaned_explanation, flags=re.DOTALL)
|
| 75 |
+
# Remove any ## Sources heading and content
|
| 76 |
+
cleaned_explanation = re.sub(r'#{1,3}\s+Sources.*', '', cleaned_explanation, flags=re.DOTALL)
|
| 77 |
+
|
| 78 |
with st.expander("Show Reasoning"):
|
| 79 |
st.markdown(cleaned_explanation)
|
| 80 |
|