Update app.py
Browse files
app.py
CHANGED
@@ -460,7 +460,7 @@ def handle_submit(user_query: str):
|
|
460 |
st.rerun()
|
461 |
|
462 |
def create_chat_input():
|
463 |
-
"""Create chat input with enhanced configuration and clear
|
464 |
with st.form(key="chat_form", clear_on_submit=True):
|
465 |
st.markdown("""
|
466 |
<label for="query_input" style="font-size: 1.2rem; font-weight: 600; margin-bottom: 1rem; display: block;">
|
@@ -476,7 +476,7 @@ def create_chat_input():
|
|
476 |
placeholder="เช่น: วิชาเลือกมีอะไรบ้าง?"
|
477 |
)
|
478 |
|
479 |
-
col1, col2
|
480 |
|
481 |
with col1:
|
482 |
submitted = st.form_submit_button(
|
@@ -486,15 +486,8 @@ def create_chat_input():
|
|
486 |
)
|
487 |
|
488 |
with col2:
|
489 |
-
|
490 |
-
"🗑️
|
491 |
-
type="secondary",
|
492 |
-
use_container_width=True
|
493 |
-
)
|
494 |
-
|
495 |
-
with col3:
|
496 |
-
clear_context_button = st.form_submit_button(
|
497 |
-
"🧠 ล้างบริบทสนทนา",
|
498 |
type="secondary",
|
499 |
use_container_width=True
|
500 |
)
|
@@ -502,13 +495,13 @@ def create_chat_input():
|
|
502 |
if submitted:
|
503 |
handle_submit(query)
|
504 |
|
505 |
-
if
|
|
|
506 |
st.session_state.chat_history = []
|
507 |
-
|
508 |
-
|
509 |
-
if clear_context_button:
|
510 |
clear_conversation_context()
|
511 |
-
st.info("
|
|
|
512 |
|
513 |
def main():
|
514 |
# Page config
|
|
|
460 |
st.rerun()
|
461 |
|
462 |
def create_chat_input():
|
463 |
+
"""Create chat input with enhanced configuration and combined clear button"""
|
464 |
with st.form(key="chat_form", clear_on_submit=True):
|
465 |
st.markdown("""
|
466 |
<label for="query_input" style="font-size: 1.2rem; font-weight: 600; margin-bottom: 1rem; display: block;">
|
|
|
476 |
placeholder="เช่น: วิชาเลือกมีอะไรบ้าง?"
|
477 |
)
|
478 |
|
479 |
+
col1, col2 = st.columns([5, 5])
|
480 |
|
481 |
with col1:
|
482 |
submitted = st.form_submit_button(
|
|
|
486 |
)
|
487 |
|
488 |
with col2:
|
489 |
+
clear_all_button = st.form_submit_button(
|
490 |
+
"🗑️ ล้างประวัติและบริบทสนทนา",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
491 |
type="secondary",
|
492 |
use_container_width=True
|
493 |
)
|
|
|
495 |
if submitted:
|
496 |
handle_submit(query)
|
497 |
|
498 |
+
if clear_all_button:
|
499 |
+
# Clear chat history
|
500 |
st.session_state.chat_history = []
|
501 |
+
# Clear conversation context
|
|
|
|
|
502 |
clear_conversation_context()
|
503 |
+
st.info("ล้างประวัติและบริบทสนทนาแล้ว")
|
504 |
+
st.rerun()
|
505 |
|
506 |
def main():
|
507 |
# Page config
|