Spaces:
Sleeping
Sleeping
| """Dashboard metrics and KPI components.""" | |
| import streamlit as st | |
| def render_kpi_row( | |
| total_nudge: int, | |
| high_count: int, | |
| medium_count: int, | |
| risk_score: float, | |
| citation_total: int, | |
| ) -> None: | |
| """Render key metrics row with 5 KPIs. | |
| Args: | |
| total_nudge: Total negative mentions | |
| high_count: HIGH tier count | |
| medium_count: MEDIUM tier count | |
| risk_score: Calculated risk score | |
| citation_total: Total citation sources | |
| """ | |
| kpi1, kpi2, kpi3, kpi4, kpi5 = st.columns(5) | |
| with kpi1: | |
| st.metric( | |
| label="μ΄ λΆμ μΈκΈ", | |
| value=f"{total_nudge}건", | |
| help="AIκ° μμ¬ λΈλλλ₯Ό λΆμ μ μΌλ‘ μΈκΈν λ΅λ³ μ", | |
| ) | |
| with kpi2: | |
| st.metric( | |
| label="π΄ HIGH (μ¦μ λμ)", | |
| value=f"{high_count}건", | |
| help="β₯85% νμ λ - μ¦μ λμ κΆμ₯", | |
| ) | |
| with kpi3: | |
| st.metric( | |
| label="π‘ MEDIUM (κ²ν )", | |
| value=f"{medium_count}건", | |
| help="70-85% νμ λ - κ²ν νμ", | |
| ) | |
| with kpi4: | |
| st.metric( | |
| label="리μ€ν¬ μ μ", | |
| value=f"{risk_score:.1f}", | |
| help="HIGH=100%, MEDIUM=50%, LOW=20% κ°μ€ νκ· ", | |
| ) | |
| with kpi5: | |
| st.metric( | |
| label="μ΄ μΈμ© μμ€", | |
| value=f"{citation_total}κ°", | |
| help="AI λ΅λ³μμ μΈμ©λ μ΄ μμ€ μ", | |
| ) | |
| def render_verification_stats( | |
| total_verified: int, | |
| false_positives_count: int, | |
| true_negatives_count: int, | |
| ) -> None: | |
| """Render LLM verification statistics row. | |
| Args: | |
| total_verified: Total verified items | |
| false_positives_count: False positive count | |
| true_negatives_count: True negative count | |
| """ | |
| stat_col1, stat_col2, stat_col3, stat_col4 = st.columns(4) | |
| with stat_col1: | |
| st.metric("κ²μ¦ μλ£", f"{total_verified}건") | |
| with stat_col2: | |
| fp_rate = (false_positives_count / total_verified * 100) if total_verified > 0 else 0 | |
| st.metric("μ€ν (False Positive)", f"{false_positives_count}건", f"{fp_rate:.1f}%") | |
| with stat_col3: | |
| tn_rate = (true_negatives_count / total_verified * 100) if total_verified > 0 else 0 | |
| st.metric("μ§μμ± (True Negative)", f"{true_negatives_count}건", f"{tn_rate:.1f}%") | |
| with stat_col4: | |
| if total_verified > 0: | |
| st.metric("μ€νλ₯ ", f"{fp_rate:.1f}%", delta=None) | |
| else: | |
| st.metric("μ€νλ₯ ", "N/A") | |
| def render_polarity_stats( | |
| positive_count: int, | |
| neutral_count: int, | |
| negative_count: int, | |
| ) -> None: | |
| """Render polarity distribution statistics. | |
| Args: | |
| positive_count: Positive sentiment count | |
| neutral_count: Neutral sentiment count | |
| negative_count: Negative sentiment count | |
| """ | |
| total_answers = positive_count + neutral_count + negative_count | |
| pol_col1, pol_col2, pol_col3, pol_col4 = st.columns(4) | |
| with pol_col1: | |
| st.metric("μ 체 λΆμ", f"{total_answers:,}건") | |
| with pol_col2: | |
| pos_rate = (positive_count / total_answers * 100) if total_answers > 0 else 0 | |
| st.metric("π κΈμ ", f"{positive_count:,}건", f"{pos_rate:.1f}%") | |
| with pol_col3: | |
| neu_rate = (neutral_count / total_answers * 100) if total_answers > 0 else 0 | |
| st.metric("π μ€λ¦½", f"{neutral_count:,}건", f"{neu_rate:.1f}%") | |
| with pol_col4: | |
| neg_rate = (negative_count / total_answers * 100) if total_answers > 0 else 0 | |
| st.metric("π λΆμ ", f"{negative_count:,}건", f"{neg_rate:.1f}%") | |
| def render_feedback_stats(feedback_stats: dict) -> None: | |
| """Render feedback statistics row. | |
| Args: | |
| feedback_stats: Dict with feedback counts and accuracy | |
| """ | |
| 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="μ ν / (μ ν + μ€λ₯) λΉμ¨", | |
| ) | |