Update app.py
Browse files
app.py
CHANGED
@@ -275,40 +275,46 @@ def handle_submit(user_query: str):
|
|
275 |
|
276 |
def create_chat_input():
|
277 |
"""Create the chat input section with form handling"""
|
278 |
-
#
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
""
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
# Submit button in form
|
300 |
submitted = st.form_submit_button(
|
301 |
"📤 ส่งคำถาม",
|
302 |
type="primary",
|
303 |
use_container_width=True
|
304 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
305 |
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
with clear_col:
|
311 |
-
if st.button("🗑️ ล้างประวัติ", type="secondary", use_container_width=True):
|
312 |
st.session_state.context_memory = []
|
313 |
st.session_state.chat_history = []
|
314 |
st.rerun()
|
|
|
275 |
|
276 |
def create_chat_input():
|
277 |
"""Create the chat input section with form handling"""
|
278 |
+
# Create the form for chat input
|
279 |
+
with st.form(key="chat_form", clear_on_submit=True):
|
280 |
+
st.markdown("""
|
281 |
+
<label for="query_input" style="font-size: 1.2rem; font-weight: 600; margin-bottom: 1rem; display: block;">
|
282 |
+
<span style="color: #ffffff; border-left: 4px solid #ffffff; padding-left: 0.8rem;">
|
283 |
+
โปรดระบุคำถามเกี่ยวกับปฏิทินการศึกษา:
|
284 |
+
</span>
|
285 |
+
</label>
|
286 |
+
""", unsafe_allow_html=True)
|
287 |
+
|
288 |
+
# Text input
|
289 |
+
query = st.text_input(
|
290 |
+
"",
|
291 |
+
key="query_input",
|
292 |
+
placeholder="เช่น: วันสุดท้ายของการสอบปากเปล่าในภาคเรียนที่ 1/2567 คือวันที่เท่าไร?"
|
293 |
+
)
|
294 |
+
|
295 |
+
# Create two columns for buttons with a 7:3 ratio
|
296 |
+
col1, col2 = st.columns([7, 3])
|
297 |
+
|
298 |
+
with col1:
|
299 |
# Submit button in form
|
300 |
submitted = st.form_submit_button(
|
301 |
"📤 ส่งคำถาม",
|
302 |
type="primary",
|
303 |
use_container_width=True
|
304 |
)
|
305 |
+
|
306 |
+
with col2:
|
307 |
+
# Clear history button inside the form
|
308 |
+
clear_button = st.form_submit_button(
|
309 |
+
"🗑️ ล้างประวัติ",
|
310 |
+
type="secondary",
|
311 |
+
use_container_width=True
|
312 |
+
)
|
313 |
|
314 |
+
if submitted:
|
315 |
+
handle_submit(query)
|
316 |
+
|
317 |
+
if clear_button:
|
|
|
|
|
318 |
st.session_state.context_memory = []
|
319 |
st.session_state.chat_history = []
|
320 |
st.rerun()
|