Update app.py
Browse files
app.py
CHANGED
@@ -561,7 +561,7 @@ with col1:
|
|
561 |
|
562 |
with col2:
|
563 |
# Feedback Display
|
564 |
-
if st.session_state.feedback:
|
565 |
st.markdown("""
|
566 |
<div class="thai-eng">
|
567 |
<div class="thai">📝 คำแนะนำจากครู</div>
|
@@ -572,55 +572,53 @@ with col2:
|
|
572 |
# แสดง feedback ในรูปแบบที่อ่านง่าย
|
573 |
feedback_container = st.container()
|
574 |
with feedback_container:
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
|
|
604 |
)
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
</p>
|
622 |
-
</div>
|
623 |
-
""", unsafe_allow_html=True)
|
624 |
|
625 |
# Help and Suggestions Box
|
626 |
st.markdown("""
|
|
|
561 |
|
562 |
with col2:
|
563 |
# Feedback Display
|
564 |
+
if st.session_state.feedback and st.session_state.feedback.get('has_errors', False):
|
565 |
st.markdown("""
|
566 |
<div class="thai-eng">
|
567 |
<div class="thai">📝 คำแนะนำจากครู</div>
|
|
|
572 |
# แสดง feedback ในรูปแบบที่อ่านง่าย
|
573 |
feedback_container = st.container()
|
574 |
with feedback_container:
|
575 |
+
st.markdown(f"""
|
576 |
+
<div style='background-color: #f0f2f6;
|
577 |
+
padding: 15px;
|
578 |
+
border-radius: 8px;
|
579 |
+
border-left: 4px solid #FF9800;
|
580 |
+
margin: 5px 0;
|
581 |
+
font-family: "Sarabun", sans-serif;'>
|
582 |
+
<p style='color: #1e88e5; margin-bottom: 10px;'>
|
583 |
+
{st.session_state.feedback['feedback']}
|
584 |
+
</p>
|
585 |
+
<p style='color: #666; font-size: 0.9em;'>
|
586 |
+
ประโยคที่ถูกต้อง:<br/>
|
587 |
+
<span style='color: #4CAF50; font-weight: bold;'>
|
588 |
+
{st.session_state.feedback['corrected']}
|
589 |
+
</span>
|
590 |
+
</p>
|
591 |
+
</div>
|
592 |
+
""", unsafe_allow_html=True)
|
593 |
+
|
594 |
+
# แสดงปุ่มแก้ไขเพียงปุ่มเดียว
|
595 |
+
if st.button("✍️ แก้ไขประโยคให้ถูกต้อง", key="correct_button"):
|
596 |
+
last_user_entry_idx = next(
|
597 |
+
(i for i, entry in reversed(list(enumerate(st.session_state.story)))
|
598 |
+
if entry['role'] == 'You'),
|
599 |
+
None
|
600 |
+
)
|
601 |
+
if last_user_entry_idx is not None:
|
602 |
+
apply_correction(
|
603 |
+
last_user_entry_idx,
|
604 |
+
st.session_state.feedback['corrected']
|
605 |
)
|
606 |
+
st.rerun()
|
607 |
+
|
608 |
+
elif st.session_state.feedback:
|
609 |
+
# กรณีไม่มีข้อผิดพลาด
|
610 |
+
st.markdown(f"""
|
611 |
+
<div style='background-color: #f0f2f6;
|
612 |
+
padding: 15px;
|
613 |
+
border-radius: 8px;
|
614 |
+
border-left: 4px solid #4CAF50;
|
615 |
+
margin: 5px 0;
|
616 |
+
font-family: "Sarabun", sans-serif;'>
|
617 |
+
<p style='color: #1e88e5;'>
|
618 |
+
✨ {st.session_state.feedback['feedback']}
|
619 |
+
</p>
|
620 |
+
</div>
|
621 |
+
""", unsafe_allow_html=True)
|
|
|
|
|
|
|
622 |
|
623 |
# Help and Suggestions Box
|
624 |
st.markdown("""
|