Spaces:
Runtime error
Runtime error
Mustafa Öztürk commited on
Commit ·
67e1e39
1
Parent(s): 625d4d3
fix(ui): map INSULT/HIGH verdicts correctly
Browse files
app.py
CHANGED
|
@@ -181,13 +181,13 @@ hr { border-color:#1e2d45 !important; }
|
|
| 181 |
API_URL = "http://127.0.0.1:8000/analyze"
|
| 182 |
|
| 183 |
VERDICT_COLORS = {
|
| 184 |
-
"High": "#e03030",
|
| 185 |
-
"Medium": "#d4a017",
|
| 186 |
-
"Low": "#8030d4",
|
| 187 |
-
"None": "#2ea84a",
|
| 188 |
"CRITICAL": "#e03030",
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
}
|
| 190 |
-
VERDICT_ICONS = {"
|
| 191 |
|
| 192 |
if "last_latency_ms" not in st.session_state:
|
| 193 |
st.session_state["last_latency_ms"] = None
|
|
@@ -241,6 +241,8 @@ def verdict_css_class(decision):
|
|
| 241 |
d = decision.upper()
|
| 242 |
if "TEMIZ" in d or "CLEAR" in d:
|
| 243 |
return "TEMIZ"
|
|
|
|
|
|
|
| 244 |
if "NEFRET" in d or "IDENTITY" in d:
|
| 245 |
return "NEFRET"
|
| 246 |
if "KÜFÜR" in d or "KUFUR" in d or "PROFANITY" in d:
|
|
@@ -640,6 +642,7 @@ with tab1:
|
|
| 640 |
decision = r.get("decision", "—")
|
| 641 |
reason = r.get("reason", "—")
|
| 642 |
risk = r.get("risk_level", "None")
|
|
|
|
| 643 |
lang = r.get("language", platform_dil).upper()
|
| 644 |
cleaned = r.get("cleaned_text", "")
|
| 645 |
details = r.get("details", {})
|
|
@@ -655,8 +658,8 @@ with tab1:
|
|
| 655 |
"timestamp": backend_perf.get("timestamp", time.strftime("%H:%M:%S")),
|
| 656 |
}
|
| 657 |
vcls = verdict_css_class(decision)
|
| 658 |
-
vcolor = VERDICT_COLORS.get(
|
| 659 |
-
vicon = VERDICT_ICONS.get(
|
| 660 |
|
| 661 |
st.markdown(
|
| 662 |
f"""<div class="verdict-card verdict-{vcls}">
|
|
@@ -669,7 +672,13 @@ with tab1:
|
|
| 669 |
)
|
| 670 |
|
| 671 |
lat_class = "low" if latency < 200 else ("med" if latency < 500 else "high")
|
| 672 |
-
risk_class = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 673 |
st.markdown(
|
| 674 |
f"""<div class="metric-row">
|
| 675 |
<div class="metric-card"><div class="metric-label">Risk Seviyesi</div><div class="metric-value {risk_class}">{risk}</div></div>
|
|
|
|
| 181 |
API_URL = "http://127.0.0.1:8000/analyze"
|
| 182 |
|
| 183 |
VERDICT_COLORS = {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 184 |
"CRITICAL": "#e03030",
|
| 185 |
+
"HIGH": "#e07020",
|
| 186 |
+
"MEDIUM": "#d4a017",
|
| 187 |
+
"LOW": "#3a7bd4",
|
| 188 |
+
"NONE": "#2ea84a",
|
| 189 |
}
|
| 190 |
+
VERDICT_ICONS = {"CRITICAL": "🚨", "HIGH": "🤬", "MEDIUM": "◆", "LOW": "▲", "NONE": "✓"}
|
| 191 |
|
| 192 |
if "last_latency_ms" not in st.session_state:
|
| 193 |
st.session_state["last_latency_ms"] = None
|
|
|
|
| 241 |
d = decision.upper()
|
| 242 |
if "TEMIZ" in d or "CLEAR" in d:
|
| 243 |
return "TEMIZ"
|
| 244 |
+
if "HAKARET" in d or "INSULT" in d:
|
| 245 |
+
return "SALDIRGAN"
|
| 246 |
if "NEFRET" in d or "IDENTITY" in d:
|
| 247 |
return "NEFRET"
|
| 248 |
if "KÜFÜR" in d or "KUFUR" in d or "PROFANITY" in d:
|
|
|
|
| 642 |
decision = r.get("decision", "—")
|
| 643 |
reason = r.get("reason", "—")
|
| 644 |
risk = r.get("risk_level", "None")
|
| 645 |
+
risk_u = str(risk).upper()
|
| 646 |
lang = r.get("language", platform_dil).upper()
|
| 647 |
cleaned = r.get("cleaned_text", "")
|
| 648 |
details = r.get("details", {})
|
|
|
|
| 658 |
"timestamp": backend_perf.get("timestamp", time.strftime("%H:%M:%S")),
|
| 659 |
}
|
| 660 |
vcls = verdict_css_class(decision)
|
| 661 |
+
vcolor = VERDICT_COLORS.get(risk_u, "#2ea84a")
|
| 662 |
+
vicon = VERDICT_ICONS.get(risk_u, "✓")
|
| 663 |
|
| 664 |
st.markdown(
|
| 665 |
f"""<div class="verdict-card verdict-{vcls}">
|
|
|
|
| 672 |
)
|
| 673 |
|
| 674 |
lat_class = "low" if latency < 200 else ("med" if latency < 500 else "high")
|
| 675 |
+
risk_class = {
|
| 676 |
+
"CRITICAL": "high",
|
| 677 |
+
"HIGH": "high",
|
| 678 |
+
"MEDIUM": "med",
|
| 679 |
+
"LOW": "med",
|
| 680 |
+
"NONE": "low",
|
| 681 |
+
}.get(risk_u, "low")
|
| 682 |
st.markdown(
|
| 683 |
f"""<div class="metric-row">
|
| 684 |
<div class="metric-card"><div class="metric-label">Risk Seviyesi</div><div class="metric-value {risk_class}">{risk}</div></div>
|