Spaces:
Paused
Paused
Update components/chat.py
Browse files- components/chat.py +6 -81
components/chat.py
CHANGED
|
@@ -4,6 +4,9 @@ from utils.database import verify_vector_store
|
|
| 4 |
|
| 5 |
def clean_response_content(response_content):
|
| 6 |
"""Clean the response content of any technical metadata."""
|
|
|
|
|
|
|
|
|
|
| 7 |
# Remove the content= prefix if it exists
|
| 8 |
if "content='" in response_content:
|
| 9 |
response_content = response_content.split("content='")[1]
|
|
@@ -23,86 +26,7 @@ def clean_response_content(response_content):
|
|
| 23 |
def display_chat_interface():
|
| 24 |
"""Display modern chat interface with clean formatting."""
|
| 25 |
|
| 26 |
-
|
| 27 |
-
st.markdown("""
|
| 28 |
-
<style>
|
| 29 |
-
/* Clean, modern chat container */
|
| 30 |
-
.chat-container {
|
| 31 |
-
max-width: 800px;
|
| 32 |
-
margin: auto;
|
| 33 |
-
}
|
| 34 |
-
|
| 35 |
-
/* Message styling */
|
| 36 |
-
.user-message {
|
| 37 |
-
background-color: #f0f2f6;
|
| 38 |
-
padding: 1rem;
|
| 39 |
-
border-radius: 10px;
|
| 40 |
-
margin: 1rem 0;
|
| 41 |
-
}
|
| 42 |
-
|
| 43 |
-
.assistant-message {
|
| 44 |
-
background-color: #ffffff;
|
| 45 |
-
border: 1px solid #e0e0e0;
|
| 46 |
-
padding: 1.5rem;
|
| 47 |
-
border-radius: 10px;
|
| 48 |
-
margin: 1rem 0;
|
| 49 |
-
}
|
| 50 |
-
|
| 51 |
-
/* Section styling */
|
| 52 |
-
.section-header {
|
| 53 |
-
font-weight: bold;
|
| 54 |
-
color: #0f52ba;
|
| 55 |
-
margin-top: 1rem;
|
| 56 |
-
font-size: 1.2em;
|
| 57 |
-
}
|
| 58 |
-
|
| 59 |
-
.source-info {
|
| 60 |
-
background-color: #f8f9fa;
|
| 61 |
-
padding: 0.5rem;
|
| 62 |
-
border-left: 3px solid #0f52ba;
|
| 63 |
-
margin-top: 1rem;
|
| 64 |
-
font-size: 0.9rem;
|
| 65 |
-
font-style: italic;
|
| 66 |
-
}
|
| 67 |
-
|
| 68 |
-
/* Summary section */
|
| 69 |
-
.summary-section {
|
| 70 |
-
background-color: #f8f9fa;
|
| 71 |
-
padding: 1rem;
|
| 72 |
-
border-radius: 6px;
|
| 73 |
-
margin-bottom: 1rem;
|
| 74 |
-
}
|
| 75 |
-
|
| 76 |
-
/* Key points */
|
| 77 |
-
.key-points {
|
| 78 |
-
margin: 1rem 0;
|
| 79 |
-
}
|
| 80 |
-
|
| 81 |
-
.key-point-item {
|
| 82 |
-
margin: 0.5rem 0;
|
| 83 |
-
line-height: 1.5;
|
| 84 |
-
padding-left: 1.5rem;
|
| 85 |
-
position: relative;
|
| 86 |
-
}
|
| 87 |
-
|
| 88 |
-
.key-point-item:before {
|
| 89 |
-
content: "•";
|
| 90 |
-
position: absolute;
|
| 91 |
-
left: 0.5rem;
|
| 92 |
-
}
|
| 93 |
-
|
| 94 |
-
/* Content sections */
|
| 95 |
-
.content-section {
|
| 96 |
-
margin: 1rem 0;
|
| 97 |
-
}
|
| 98 |
-
|
| 99 |
-
/* Bold text */
|
| 100 |
-
.highlight {
|
| 101 |
-
font-weight: 600;
|
| 102 |
-
color: #1a365d;
|
| 103 |
-
}
|
| 104 |
-
</style>
|
| 105 |
-
""", unsafe_allow_html=True)
|
| 106 |
|
| 107 |
# Check if QA system is initialized
|
| 108 |
if 'qa_system' not in st.session_state or st.session_state.qa_system is None:
|
|
@@ -166,7 +90,8 @@ def display_chat_interface():
|
|
| 166 |
})
|
| 167 |
|
| 168 |
if response:
|
| 169 |
-
|
|
|
|
| 170 |
st.session_state.messages.append(ai_message)
|
| 171 |
st.rerun()
|
| 172 |
else:
|
|
|
|
| 4 |
|
| 5 |
def clean_response_content(response_content):
|
| 6 |
"""Clean the response content of any technical metadata."""
|
| 7 |
+
# Convert to string if it's an AIMessage
|
| 8 |
+
response_content = str(response_content)
|
| 9 |
+
|
| 10 |
# Remove the content= prefix if it exists
|
| 11 |
if "content='" in response_content:
|
| 12 |
response_content = response_content.split("content='")[1]
|
|
|
|
| 26 |
def display_chat_interface():
|
| 27 |
"""Display modern chat interface with clean formatting."""
|
| 28 |
|
| 29 |
+
[Previous CSS styling remains the same...]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
# Check if QA system is initialized
|
| 32 |
if 'qa_system' not in st.session_state or st.session_state.qa_system is None:
|
|
|
|
| 90 |
})
|
| 91 |
|
| 92 |
if response:
|
| 93 |
+
response_str = str(response)
|
| 94 |
+
ai_message = AIMessage(content=response_str)
|
| 95 |
st.session_state.messages.append(ai_message)
|
| 96 |
st.rerun()
|
| 97 |
else:
|