JirasakJo commited on
Commit
3fc1194
·
verified ·
1 Parent(s): c00bacb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -27
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
- # Column layout for the entire input section
279
- input_col, clear_col = st.columns([4, 1])
280
-
281
- with input_col:
282
- # Create the form for chat input
283
- with st.form(key="chat_form", clear_on_submit=True):
284
- st.markdown("""
285
- <label for="query_input" style="font-size: 1.2rem; font-weight: 600; margin-bottom: 1rem; display: block;">
286
- <span style="color: #ffffff; border-left: 4px solid #ffffff; padding-left: 0.8rem;">
287
- โปรดระบุคำถามเกี่ยวกับปฏิทินการศึกษา:
288
- </span>
289
- </label>
290
- """, unsafe_allow_html=True)
291
-
292
- # Text input
293
- query = st.text_input(
294
- "",
295
- key="query_input",
296
- placeholder="เช่น: วันสุดท้ายของการสอบปากเปล่าในภาคเรียนที่ 1/2567 คือวันที่เท่าไร?"
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
- if submitted:
307
- handle_submit(query)
308
-
309
- # Clear history button outside the form
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()