Update app.py
Browse files4 unmodified lines567891011121 unmodified line14151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162631 unmodified line65666768697071724 unmodified lines777879808182838485868788899091929394959697988 unmodified lines1071081091101111121131141152 unmodified lines1181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631643 unmodified lines1681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612628 unmodified lines2712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083094 unmodified lines# ─── Page config ──────────────────────────────────────────────────────────────st.set_page_config(page_title="Fraud Detection — Multi-Model",page_icon="🛡️",layout="wide",initial_sidebar_state="expanded",)1 unmodified line# ─── Styling ──────────────────────────────────────────────────────────────────st.markdown("""<style>/* Feed card base */.tx-card {padding: 10px 14px;border-radius: 8px;border: 0.5px solid #e2e8f0;margin-bottom: 6px;background: #ffffff;font-size: 13px;}.tx-card.fraud { border-left: 3px solid #ef4444; background: #fff5f5; }.tx-card.alert { border-left: 3px solid #f59e0b; background: #fffbeb; }.tx-card.rule1 { border-left: 3px solid #8b5cf6; background: #f5f3ff; }.tx-card.pass { border-left: 3px solid #22c55e; background: #f0fdf4; }.badge {display: inline-block;font-size: 11px;font-weight: 600;padding: 2px 8px;border-radius: 100px;margin-right: 4px;}.badge-block { background:#ef4444; color:#fff; }.badge-alert { background:#f59e0b; color:#fff; }.badge-rule1 { background:#8b5cf6; color:#fff; }.badge-pass { background:#22c55e; color:#fff; }.score-row { font-size: 11px; color: #64748b; margin-top: 4px; }.tx-meta { font-size: 11px; color: #94a3b8; margin-top: 2px; }.alert-card {padding: 10px 12px;border-radius: 8px;border: 0.5px solid;margin-bottom: 8px;font-size: 12px;}.alert-card.block { border-color:#ef4444; background:#fff5f5; }.alert-card.otp { border-color:#f59e0b; background:#fffbeb; }.alert-card.rule { border-color:#8b5cf6; background:#f5f3ff; }/* KPI strip */.kpi-val { font-size: 28px; font-weight: 600; }.kpi-lbl { font-size: 12px; color: #64748b; }</style>""", unsafe_allow_html=True)1 unmodified linedef _init():st.session_state.setdefault("running", False)st.session_state.setdefault("accounts", [])st.session_state.setdefault("feed", []) # list of scored tx dictsst.session_state.setdefault("alerts", []) # fraud/alert onlyst.session_state.setdefault("step", 1)st.session_state.setdefault("tx_counter", 1)st.session_state.setdefault("total_tx", 0)4 unmodified lines_init()# ─── Sidebar ───────────────────────────────────────────────────���──────────────with st.sidebar:st.markdown("### Fraud Detection\n**Multi-Model System**")st.caption("Sender × Payee ensemble · 3-layer pipeline")st.divider()speed = st.slider("Speed (seconds / transaction)", 0.3, 3.0, 1.0, 0.1)fraud_pct = st.slider("High-risk account ratio (%)", 5, 40, 12, 1)n_accs = st.slider("Accounts to monitor", 3, 8, 5, 1)st.divider()col1, col2 = st.columns(2)start_btn = col1.button("▶ Start", use_container_width=True, type="primary")stop_btn = col2.button("⏹ Stop", use_container_width=True)reset_btn = st.button("↺ Reset session", use_container_width=True)if start_btn:seed = random.randint(0, 99999)8 unmodified linesst.session_state.total_alert = 0st.session_state.total_pass = 0st.session_state.amount_risk = 0.0if stop_btn:st.session_state.running = Falseif reset_btn:for k in ["running","accounts","feed","alerts","step","tx_counter",2 unmodified lines_init()st.rerun()st.divider()st.markdown("**Thresholds**")st.markdown("🔴 Block `≥ 0.80` \n🟡 Alert+OTP `≥ 0.50` \n🟢 Pass `< 0.50`")st.divider()st.markdown("**Accounts**")for acc in st.session_state.accounts:icon = {"normal": "🟢", "alert": "🟡", "blocked": "🔴"}.get(acc["status"], "⚪")risk_tag = {"low": "", "medium": " ⚠️", "high": " 🔥"}.get(acc["risk_level"], "")st.caption(f"{icon} `{acc['account_id']}` {acc['risk_level']}{risk_tag}")st.divider()st.link_button("GitHub — Fraud-Detection-Multi-Model","https://github.com/PlamGG/Fraud-Detection-Multi-Model-",use_container_width=True,)# ─── Main header ─────────────────────────────────────────────────────────────st.markdown("## Fraud Detection — Multi-Model · Live Monitor")status_txt = "🟢 Running" if st.session_state.running else "⏸ Paused"st.caption(f"{status_txt} · Model version 2026-05-24 · w\\* = 0.30 · Ensemble: Model A × Model B")# ─── KPI strip ───────────────────────────────────────────────────────────────k1, k2, k3, k4, k5 = st.columns(5)k1.metric("Total transactions", st.session_state.total_tx)k2.metric("Blocked", st.session_state.total_block, delta=None)k3.metric("Alert+OTP", st.session_state.total_alert, delta=None)k4.metric("Passed", st.session_state.total_pass, delta=None)k5.metric("Amount at risk (฿)",f"{st.session_state.amount_risk:,.0f}")st.divider()# ─── Two-column layout ────────────────────────────────────────────────────────feed_col, alert_col = st.columns([3, 2], gap="medium")feed_placeholder = feed_col.empty()alert_placeholder = alert_col.empty()# ─── Render helpers ───────────────────────────────────────────────────────────def _decision_class(tx: dict) -> str:d = tx["decision"]if "Rule" in d: return "rule1"3 unmodified linesdef _badge(tx: dict) -> str:d = tx["decision"]if "Rule" in d: return '<span class="badge badge-rule1">Rule 1</span>'if "Block" in d: return '<span class="badge badge-block">Block</span>'if "Alert" in d: return '<span class="badge badge-alert">Alert+OTP</span>'return '<span class="badge badge-pass">Pass</span>'def render_feed(feed: list):html = ""for tx in feed[:40]:cls = _decision_class(tx)badge = _badge(tx)score_color = ("#ef4444" if tx["final_score"] >= 0.8 else"#f59e0b" if tx["final_score"] >= 0.5 else"#22c55e")flags = []if tx["rule1"]: flags.append("Accessibility+Remote")if tx["rule2"]: flags.append("Hesitation+NewRecipient")flag_txt = " · ".join(flags) if flags else "No hard rule"html += f"""<div class="tx-card {cls}"><div style="display:flex;justify-content:space-between;align-items:center"><div>{badge} <strong>{tx['tx_id']}</strong></div><div style="font-weight:600">฿ {tx['amount']:,.0f}</div></div><div class="tx-meta">{tx['account_id']} → {tx['dest_id']} · step {tx['step']}</div><div class="score-row">Model A: <b>{tx['prob_a']:.3f}</b> Model B: <b>{tx['prob_b']:.3f}</b> Score: <b style="color:{score_color}">{tx['final_score']:.3f}</b> · {flag_txt}</div></div>"""return htmldef render_alerts(alerts: list):html = ""for tx in alerts[:25]:d = tx["decision"]if "Rule" in d:cls, label = "rule", "Rule 1 — Hard Block"detail = "Accessibility Service + Remote Access Application both active. Blocked before ML scoring."elif "Block" in d:cls, label = "block", "Block"detail = f"Ensemble score {tx['final_score']:.3f} ≥ 0.80. Model A={tx['prob_a']:.3f} · Model B={tx['prob_b']:.3f}."else:cls, label = "otp", "Alert + OTP"detail = f"Score {tx['final_score']:.3f} ≥ 0.50. OTP challenge triggered."html += f"""<div class="alert-card {cls}"><div style="display:flex;align-items:center;gap:6px;margin-bottom:4px"><span class="badge badge-{'rule1' if cls=='rule' else cls}">{label}</span><strong style="font-size:12px">{tx['tx_id']} · {tx['account_id']}</strong></div><div style="font-size:11px;color:#374151">{detail}</div><div style="font-size:10px;color:#94a3b8;margin-top:3px">฿ {tx['amount']:,.0f} · step {tx['step']} · {tx['layer']}</div></div>"""return html# ─── Simulation loop ──────────────────────────────────────────────────────────if st.session_state.running and st.session_state.accounts:while st.session_state.running:# Pick a random accountaccount = random.choice(st.session_state.accounts)# Generate + scoreraw_tx = generate_transaction(account,step=st.session_state.step,tx_counter=st.session_state.tx_counter,)tx = score_transaction(raw_tx)# Update account statusd = tx["decision"]if "Block" in d:account["status"] = "blocked"elif "Alert" in d:account["status"] = "alert"# Prepend to feed (newest first)st.session_state.feed = [tx] + st.session_state.feedst.session_state.total_tx += 1st.session_state.tx_counter += 18 unmodified lineselse:st.session_state.total_pass += 1# Advance step every 6 transactionsif st.session_state.tx_counter % 6 == 0:st.session_state.step += 1# Renderwith feed_placeholder.container():st.markdown("#### Transaction feed")st.caption("Newest first · showing last 40")st.markdown(render_feed(st.session_state.feed), unsafe_allow_html=True)with alert_placeholder.container():n_alerts = len(st.session_state.alerts)st.markdown(f"#### Alerts ({n_alerts})")st.caption("Ordered by detection time")if st.session_state.alerts:st.markdown(render_alerts(st.session_state.alerts), unsafe_allow_html=True)else:st.info("No alerts yet.")time.sleep(speed)else:# Static render when not runningwith feed_placeholder.container():st.markdown("#### Transaction feed")if st.session_state.feed:st.markdown(render_feed(st.session_state.feed), unsafe_allow_html=True)else:st.info("Press **▶ Start** in the sidebar to begin the simulation.")with alert_placeholder.container():st.markdown(f"#### Alerts ({len(st.session_state.alerts)})")if st.session_state.alerts:st.markdown(render_alerts(st.session_state.alerts), unsafe_allow_html=True)else:st.info("No alerts yet.")4 unmodified lines567891011121 unmodified line14151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495961 unmodified line98991001011021031041054 unmodified lines1101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551568 unmodified lines1651661671681691701711721731741752 unmodified lines1781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112123 unmodified lines2162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043058 unmodified lines3143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433444 unmodified lines# ─── Page config ──────────────────────────────────────────────────────────────st.set_page_config(page_title="Fraud Detection — Bank Monitor",page_icon="🏛️",layout="wide",initial_sidebar_state="expanded",)1 unmodified line# ─── Styling ──────────────────────────────────────────────────────────────────st.markdown("""<style>/* App Background & Base Typography */.stApp { background-color: #f8fafc; }/* Control Panel Bar */.control-bar {background: #ffffff;padding: 12px 20px;border-radius: 12px;border: 1px solid #e2e8f0;margin-bottom: 16px;box-shadow: 0 1px 3px rgba(0,0,0,0.05);}/* Feed card base (Bank Style) */.tx-card {padding: 12px 16px;border-radius: 8px;border: 1px solid #e2e8f0;margin-bottom: 8px;background: #ffffff;font-size: 13px;transition: all 0.2s;}.tx-card:hover { transform: translateY(-1px); box-shadow: 0 2px 4px rgba(0,0,0,0.05); }.tx-card.fraud { border-left: 4px solid #dc2626; background: #fef2f2; }.tx-card.alert { border-left: 4px solid #d97706; background: #fffbeb; }.tx-card.rule1 { border-left: 4px solid #7c3aed; background: #f5f3ff; }.tx-card.pass { border-left: 4px solid #16a34a; background: #f0fdf4; }/* Badges */.badge {display: inline-block;font-size: 11px;font-weight: 600;padding: 2px 8px;border-radius: 4px;margin-right: 6px;}.badge-block { background:#dc2626; color:#fff; }.badge-alert { background:#d97706; color:#fff; }.badge-rule1 { background:#7c3aed; color:#fff; }.badge-pass { background:#16a34a; color:#fff; }.score-row { font-size: 11px; color: #475569; margin-top: 6px; border-top: 1px dashed #e2e8f0; padding-top: 4px; }.tx-meta { font-size: 11px; color: #64748b; margin-top: 4px; }/* Alert Card */.alert-card {padding: 12px;border-radius: 8px;border: 1px solid;margin-bottom: 8px;font-size: 12px;animation: pulse 2s infinite;}.alert-card.block { border-color:#fca5a5; background:#fff5f5; }.alert-card.otp { border-color:#fde047; background:#fffbeb; }.alert-card.rule { border-color:#c084fc; background:#f5f3ff; }/* GitHub Custom Card */.github-card {background: #0f172a;color: #ffffff;padding: 14px;border-radius: 8px;margin-top: 20px;border: 1px solid #1e293b;}.github-card a {color: #38bdf8 !important;text-decoration: none;font-weight: 600;display: flex;align-items: center;gap: 8px;}.github-card a:hover { text-decoration: underline; }</style>""", unsafe_allow_html=True)1 unmodified linedef _init():st.session_state.setdefault("running", False)st.session_state.setdefault("accounts", [])st.session_state.setdefault("feed", [])st.session_state.setdefault("alerts", [])st.session_state.setdefault("step", 1)st.session_state.setdefault("tx_counter", 1)st.session_state.setdefault("total_tx", 0)4 unmodified lines_init()# ─── Sidebar (Settings Only) ──────────────────────────────────────────────────with st.sidebar:st.markdown("### 🏛️ Simulation Settings")st.caption("Configure environment parameters before starting.")st.divider()speed = st.slider("Transmission Speed (sec/tx)", 0.3, 3.0, 1.0, 0.1)fraud_pct = st.slider("High-Risk Target Ratio (%)", 5, 40, 12, 1)n_accs = st.slider("Monitored Accounts", 3, 8, 5, 1)st.divider()st.markdown("**System Thresholds**")st.markdown("🔴 **Critical Block** `≥ 0.80` \n🟡 **Challenge OTP** `≥ 0.50` \n🟢 **Auto Pass** `< 0.50`")# Push GitHub to the absolute bottom of sidebarst.markdown("""<div class="github-card"><p style="margin:0 0 8px 0; font-size:12px; color:#94a3b8;">Want to learn more?</p><a href="https://github.com/PlamGG/Fraud-Detection-Multi-Model-" target="_blank"><svg height="20" width="20" viewBox="0 0 16 16" fill="currentColor" style="color:white;"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"></path></svg>Read Technical Docs</a></div>""", unsafe_allow_html=True)# ─── Main Header & Compact Control Panel ──────────────────────────────────────title_col, ctrl_col = st.columns([2, 1], gap="small")with title_col:st.markdown("## 🏛️ Fraud Analytics — Multi-Model Engine")status_color = "green" if st.session_state.running else "orange"status_txt = "Active Monitoring" if st.session_state.running else "System Paused"st.markdown(f"<span style='color:{status_color}; font-weight:600;'>● {status_txt}</span> · Core v2026 · Ensemble Pipeline", unsafe_allow_html=True)with ctrl_col:# Compact horizontal buttons right next to the titlest.markdown("<div style='padding-top: 15px;'></div>", unsafe_allow_html=True)c1, c2, c3 = st.columns(3)start_btn = c1.button("▶ Start", use_container_width=True, type="primary")stop_btn = c2.button("⏹ Stop", use_container_width=True)reset_btn = c3.button("↺ Reset", use_container_width=True)if start_btn:seed = random.randint(0, 99999)8 unmodified linesst.session_state.total_alert = 0st.session_state.total_pass = 0st.session_state.amount_risk = 0.0st.rerun()if stop_btn:st.session_state.running = Falsest.rerun()if reset_btn:for k in ["running","accounts","feed","alerts","step","tx_counter",2 unmodified lines_init()st.rerun()st.divider()# ─── Split Row: Financial Metrics (65%) & Target Watchlist (35%) ─────────────metric_col, watchlist_col = st.columns([65, 35], gap="medium")with metric_col:m1, m2, m3, m4 = st.columns(4)m1.metric("Total Processed", f"{st.session_state.total_tx} tx")m2.metric("Critical Blocked", st.session_state.total_block)m3.metric("OTP Challenged", st.session_state.total_alert)m4.metric("Risk Exposure", f"฿{st.session_state.amount_risk:,.0f}")with watchlist_col:st.markdown("<p style='font-size:12px; font-weight:600; color:#64748b; margin:0 0 4px 0;'>🎯 High-Risk Watchlist</p>", unsafe_allow_html=True)if st.session_state.accounts:acc_html = "<div style='display:flex; flex-wrap:wrap; gap:6px;'>"for acc in st.session_state.accounts:icon = {"normal": "🟢", "alert": "🟡", "blocked": "🔴"}.get(acc["status"], "⚪")color = {"low": "#e2e8f0", "medium": "#fef3c7", "high": "#fee2e2"}.get(acc["risk_level"], "#e2e8f0")border = {"low": "#cbd5e1", "medium": "#fcd34d", "high": "#fca5a5"}.get(acc["risk_level"], "#cbd5e1")acc_html += f"<span style='background:{color}; border:1px solid {border}; padding:2px 6px; border-radius:4px; font-size:11px; font-family:monospace;'>{icon} {acc['account_id']}</span>"acc_html += "</div>"st.markdown(acc_html, unsafe_allow_html=True)else:st.caption("No accounts initialized. Press Start.")st.markdown("<br>", unsafe_allow_html=True)# ─── Render Helpers ───────────────────────────────────────────────────────────def _decision_class(tx: dict) -> str:d = tx["decision"]if "Rule" in d: return "rule1"3 unmodified linesdef _badge(tx: dict) -> str:d = tx["decision"]if "Rule" in d: return '<span class="badge badge-rule1">RULE BLOCK</span>'if "Block" in d: return '<span class="badge badge-block">ML BLOCK</span>'if "Alert" in d: return '<span class="badge badge-alert">CHALLENGE OTP</span>'return '<span class="badge badge-pass">PASSED</span>'def render_feed(feed: list):html = ""for tx in feed[:40]:cls = _decision_class(tx)badge = _badge(tx)score_color = "#dc2626" if tx["final_score"] >= 0.8 else "#d97706" if tx["final_score"] >= 0.5 else "#16a34a"flags = [f for f, active in [("Accessibility+Remote", tx["rule1"]), ("Hesitation+NewRecipient", tx["rule2"])] if active]flag_txt = " · ".join(flags) if flags else "No Rules Triggered"html += f"""<div class="tx-card {cls}"><div style="display:flex;justify-content:space-between;align-items:center"><div>{badge} <strong style="font-family:monospace;">{tx['tx_id']}</strong></div><div style="font-weight:700; font-size:14px; color:#1e293b;">฿ {tx['amount']:,.0f}</div></div><div class="tx-meta">Origin: <code style="background:#f1f5f9;padding:2px 4px;border-radius:3px;">{tx['account_id']}</code> → Destination: <code style="background:#f1f5f9;padding:2px 4px;border-radius:3px;">{tx['dest_id']}</code> · Step {tx['step']}</div><div class="score-row">Model A (Behavior): <b>{tx['prob_a']:.2f}</b> |Model B (Receiver): <b>{tx['prob_b']:.2f}</b> |Ensemble Score: <b style="color:{score_color}">{tx['final_score']:.2f}</b><span style="float:right; color:#64748b;">⚠️ {flag_txt}</span></div></div>"""return htmldef render_alerts(alerts: list):html = ""for tx in alerts[:25]:d = tx["decision"]if "Rule" in d:cls, label = "rule", "Rule 1 — Hard Block"detail = "Accessibility Service + Remote Access active. Aborted before ML."elif "Block" in d:cls, label = "block", "Ensemble Block"detail = f"Score {tx['final_score']:.2f} ≥ 0.80 [A:{tx['prob_a']:.2f} · B:{tx['prob_b']:.2f}]."else:cls, label = "otp", "OTP Challenge Triggered"detail = f"Score {tx['final_score']:.2f} ≥ 0.50. Transaction held for verification."html += f"""<div class="alert-card {cls}"><div style="display:flex;align-items:center;gap:6px;margin-bottom:6px"><span class="badge badge-{'rule1' if cls=='rule' else cls}">{label.upper()}</span><strong style="font-family:monospace;">{tx['tx_id']}</strong></div><div style="font-size:11px;color:#334155;font-weight:500;">{detail}</div><div style="font-size:10px;color:#64748b;margin-top:6px;background:rgba(255,255,255,0.5);padding:3px 6px;border-radius:4px;">Account: {tx['account_id']} · Value: ฿{tx['amount']:,.0f} · {tx['layer']}</div></div>"""return html# ─── TWO-COLUMN FIXED HEIGHT CONTAINERS ──────────────────────────────────────feed_col, alert_col = st.columns([3, 2], gap="medium")# Simulation Loop & Renderingif st.session_state.running and st.session_state.accounts:# 1. Create Fixed-Height Containers that auto-scroll internallywith feed_col:st.markdown("#### ⏱️ Real-Time Transaction Feed")st.caption("All processed traffic · Newest on top")feed_placeholder = st.container(height=520) # <-- ล็อคความสูงหน้าจอที่นี่with alert_col:st.markdown(f"#### 🚨 Incident Alerts Queue ({len(st.session_state.alerts)})")st.caption("High-risk anomalies requiring intervention")alert_placeholder = st.container(height=520) # <-- ล็อคความสูงหน้าจอที่นี่# 2. Run simulation loopwhile st.session_state.running:account = random.choice(st.session_state.accounts)raw_tx = generate_transaction(account, step=st.session_state.step, tx_counter=st.session_state.tx_counter)tx = score_transaction(raw_tx)d = tx["decision"]if "Block" in d: account["status"] = "blocked"elif "Alert" in d: account["status"] = "alert"st.session_state.feed = [tx] + st.session_state.feedst.session_state.total_tx += 1st.session_state.tx_counter += 18 unmodified lineselse:st.session_state.total_pass += 1if st.session_state.tx_counter % 6 == 0:st.session_state.step += 1# Render dynamically inside the locked height boxesfeed_placeholder.markdown(render_feed(st.session_state.feed), unsafe_allow_html=True)if st.session_state.alerts:alert_placeholder.markdown(render_alerts(st.session_state.alerts), unsafe_allow_html=True)else:alert_placeholder.info("Monitoring active. No anomalies detected yet.")time.sleep(speed)else:# Static render when simulation is not runningwith feed_col:st.markdown("#### ⏱️ Real-Time Transaction Feed")with st.container(height=520):if st.session_state.feed:st.markdown(render_feed(st.session_state.feed), unsafe_allow_html=True)else:st.info("System Ready. Click **▶ Start** to initiate live monitoring feed.")with alert_col:st.markdown(f"#### 🚨 Incident Alerts Queue ({len(st.session_state.alerts)})")with st.container(height=520):if st.session_state.alerts:st.markdown(render_alerts(st.session_state.alerts), unsafe_allow_html=True)else:st.info("No active alerts. Operational status normal.")
app.py+192-157