Update app.py
Browse files
app.py
CHANGED
@@ -194,12 +194,6 @@ def add_to_history(role: str, message: str):
|
|
194 |
# Get the corresponding user query (previous message)
|
195 |
user_query = st.session_state.chat_history[-2][1]
|
196 |
add_to_qa_history(user_query, message)
|
197 |
-
|
198 |
-
# Modify the clear history button handler in main():
|
199 |
-
if clear_history:
|
200 |
-
st.session_state.chat_history = []
|
201 |
-
clear_qa_history() # Clear saved history
|
202 |
-
st.rerun()
|
203 |
|
204 |
def display_chat_history():
|
205 |
"""Display chat history with enhanced styling"""
|
@@ -277,7 +271,7 @@ def main():
|
|
277 |
|
278 |
# Button layout
|
279 |
col1, col2, col3 = st.columns([1, 1, 4])
|
280 |
-
|
281 |
with col1:
|
282 |
send_query = st.button(
|
283 |
"📤 ส่งคำถาม",
|
@@ -285,7 +279,7 @@ def main():
|
|
285 |
use_container_width=True,
|
286 |
key="send_query_button"
|
287 |
)
|
288 |
-
|
289 |
with col2:
|
290 |
clear_history = st.button(
|
291 |
"🗑️ ล้างประวัติ",
|
@@ -373,5 +367,11 @@ def main():
|
|
373 |
"พร้อมใช้งาน" if st.session_state.pipeline else "ไม่พร้อมใช้งาน"
|
374 |
), unsafe_allow_html=True)
|
375 |
|
|
|
|
|
|
|
|
|
|
|
|
|
376 |
if __name__ == "__main__":
|
377 |
main()
|
|
|
194 |
# Get the corresponding user query (previous message)
|
195 |
user_query = st.session_state.chat_history[-2][1]
|
196 |
add_to_qa_history(user_query, message)
|
|
|
|
|
|
|
|
|
|
|
|
|
197 |
|
198 |
def display_chat_history():
|
199 |
"""Display chat history with enhanced styling"""
|
|
|
271 |
|
272 |
# Button layout
|
273 |
col1, col2, col3 = st.columns([1, 1, 4])
|
274 |
+
|
275 |
with col1:
|
276 |
send_query = st.button(
|
277 |
"📤 ส่งคำถาม",
|
|
|
279 |
use_container_width=True,
|
280 |
key="send_query_button"
|
281 |
)
|
282 |
+
|
283 |
with col2:
|
284 |
clear_history = st.button(
|
285 |
"🗑️ ล้างประวัติ",
|
|
|
367 |
"พร้อมใช้งาน" if st.session_state.pipeline else "ไม่พร้อมใช้งาน"
|
368 |
), unsafe_allow_html=True)
|
369 |
|
370 |
+
# Handle clear history action
|
371 |
+
if clear_history:
|
372 |
+
st.session_state.chat_history = []
|
373 |
+
clear_qa_history()
|
374 |
+
st.rerun()
|
375 |
+
|
376 |
if __name__ == "__main__":
|
377 |
main()
|