Spaces:
Sleeping
Sleeping
| """νΌλλ°± ν΅κ³ μΉμ . | |
| μ¬μ©μ κ²μ¦ νν© (Human-in-the-Loop). | |
| """ | |
| import pandas as pd | |
| import streamlit as st | |
| from core.utils import get_feedback_reason_label, get_feedback_type_emoji | |
| def render_feedback_stats(feedback_stats: dict): | |
| """νΌλλ°± ν΅κ³ μΉμ λ λλ§.""" | |
| if not feedback_stats or feedback_stats.get("total_feedback", 0) == 0: | |
| return | |
| with st.expander("π **νΌλλ°± λΆμ** - μ¬μ©μ κ²μ¦ νν©", expanded=False): | |
| fb_total = feedback_stats.get("total_feedback", 0) | |
| fb_correct = feedback_stats.get("correct_count", 0) | |
| fb_wrong = feedback_stats.get("wrong_count", 0) | |
| fb_ambiguous = feedback_stats.get("ambiguous_count", 0) | |
| accuracy = feedback_stats.get("accuracy_rate", 0) | |
| fb_col1, fb_col2, fb_col3, fb_col4, fb_col5 = st.columns(5) | |
| with fb_col1: | |
| st.metric(label="μ΄ νΌλλ°±", value=f"{fb_total}건", help="μ¬μ©μκ° μ μΆν μ΄ νΌλλ°± μ") | |
| with fb_col2: | |
| st.metric( | |
| label="π μ ν", value=f"{fb_correct}건", | |
| delta=f"{fb_correct/fb_total*100:.0f}%" if fb_total > 0 else None, | |
| delta_color="normal", help="μ ννλ€κ³ νκ°λ λΆμ μ", | |
| ) | |
| with fb_col3: | |
| st.metric( | |
| label="π μ€λ₯", value=f"{fb_wrong}건", | |
| delta=f"{fb_wrong/fb_total*100:.0f}%" if fb_total > 0 else None, | |
| delta_color="inverse", help="νλ Έλ€κ³ νκ°λ λΆμ μ", | |
| ) | |
| with fb_col4: | |
| st.metric(label="π€ μ λ§€", value=f"{fb_ambiguous}건", help="νλ¨νκΈ° μ΄λ €μ΄ κ²½μ°") | |
| with fb_col5: | |
| st.metric(label="μ νλ", value=f"{accuracy:.1f}%", help="correct / (correct + wrong) x 100") | |
| wrong_reasons = feedback_stats.get("wrong_reasons", {}) | |
| if wrong_reasons: | |
| st.markdown("##### μ€λ₯ μμΈ λΆν¬") | |
| reason_df = pd.DataFrame([ | |
| {"μμΈ": get_feedback_reason_label(k), "건μ": v} | |
| for k, v in wrong_reasons.items() | |
| ]).sort_values("건μ", ascending=False) | |
| st.dataframe(reason_df, use_container_width=True, hide_index=True) | |
| recent_feedback = feedback_stats.get("recent_feedback", []) | |
| if recent_feedback: | |
| st.markdown("##### μ΅κ·Ό νΌλλ°± (10건)") | |
| recent_df = pd.DataFrame([ | |
| { | |
| "Answer ID": fb.get("answer_id"), | |
| "μ ν": get_feedback_type_emoji(fb.get("feedback_type", "")), | |
| "μμΈ": get_feedback_reason_label(fb.get("wrong_reason")) if fb.get("wrong_reason") else "-", | |
| "μ½λ©νΈ": fb.get("comment", "-")[:50] + "..." if fb.get("comment") and len(fb.get("comment", "")) > 50 else fb.get("comment", "-"), | |
| "μκ°": fb.get("created_at", "")[:16].replace("T", " ") if fb.get("created_at") else "-", | |
| } | |
| for fb in recent_feedback | |
| ]) | |
| st.dataframe(recent_df, use_container_width=True, hide_index=True) | |