Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| def diagnose_network( | |
| availability, comcase, module_stolen, site_dismantle, blacksite, force_majeure, | |
| trans_alarm, trans_pl, trans_tnl, ul_interference, vswr, alarm_problem, | |
| rsrp, rsrq, prb, max_user, active_user_max, no_dominant, | |
| cssr, profile, simcard, ue, it_problem, core | |
| ): | |
| root_cause, sub_root_cause, action = "", "", "" | |
| rsrp = float(rsrp) | |
| rsrq = float(rsrq) | |
| if availability == "Not Safe": | |
| root_cause = "Availability" | |
| sub_root_cause = "Availability Problem" | |
| action = "π οΈ Troubleshoot" | |
| elif comcase == "Not Safe": | |
| root_cause = "Availability" | |
| sub_root_cause = "Comcase" | |
| action = "π Recovery" | |
| elif module_stolen == "Not Safe": | |
| root_cause = "Availability" | |
| sub_root_cause = "Module Stolen" | |
| action = "π Recovery" | |
| elif site_dismantle == "Not Safe": | |
| root_cause = "Availability" | |
| sub_root_cause = "Site Dismantle" | |
| action = "β‘Percepatan Relokasi" | |
| elif blacksite == "Not Safe": | |
| root_cause = "Availability" | |
| sub_root_cause = "Blacksite" | |
| action = "Optimization" | |
| elif force_majeure == "Not Safe": | |
| root_cause = "Availability" | |
| sub_root_cause = "Force Majeure" | |
| action = "π οΈ Troubleshoot" | |
| elif trans_alarm == "Not Safe": | |
| root_cause = "Quality" | |
| sub_root_cause = "Trans Alarm" | |
| action = "π οΈ Troubleshoot" | |
| elif trans_pl == "Not Safe": | |
| root_cause = "Quality" | |
| sub_root_cause = "Trans Packet Loss" | |
| action = "π οΈ Troubleshoot" | |
| elif trans_tnl == "Not Safe": | |
| root_cause = "Quality" | |
| sub_root_cause = "Trans TNL" | |
| action = "π οΈ Troubleshoot" | |
| elif ul_interference == "Not Safe": | |
| root_cause = "Quality" | |
| sub_root_cause = "High UL Interference" | |
| action = "π οΈ Troubleshoot" | |
| elif vswr == "Not Safe": | |
| root_cause = "Quality" | |
| sub_root_cause = "High VSWR" | |
| action = "π οΈ Troubleshoot" | |
| elif alarm_problem == "Not Safe": | |
| root_cause = "Quality" | |
| sub_root_cause = "Alarm Problem" | |
| action = "π οΈ Troubleshoot" | |
| elif rsrp < -105: | |
| root_cause = "Coverage" | |
| sub_root_cause = "Low Coverage" | |
| action = "πΆ Optimization" | |
| elif prb == "Not Safe": | |
| root_cause = "Capacity" | |
| sub_root_cause = "High PRB" | |
| action = "πΆ Optimization" | |
| elif max_user == "Not Safe": | |
| root_cause = "Capacity" | |
| sub_root_cause = "High Max User" | |
| action = "πΆ Optimization" | |
| elif active_user_max == "Not Safe": | |
| root_cause = "Capacity" | |
| sub_root_cause = "High Active User" | |
| action = "πΆ Optimization" | |
| elif no_dominant == "Yes": | |
| root_cause = "Quality" | |
| sub_root_cause = "No Dominant Coverage" | |
| action = "πΆ Optimization" | |
| elif cssr == "Not Safe": | |
| root_cause = "Quality" | |
| sub_root_cause = "Performance Problem" | |
| action = "πΆ Optimization" | |
| elif profile == "Not Safe": | |
| root_cause = "Others" | |
| sub_root_cause = "Profile Problem" | |
| action = "π€ Escalated to HQ" | |
| elif simcard == "Not Safe": | |
| root_cause = "Others" | |
| sub_root_cause = "Simcard Problem" | |
| action = "π¨βπ« User Education" | |
| elif ue == "Not Safe": | |
| root_cause = "Others" | |
| sub_root_cause = "UE Problem" | |
| action = "π¨βπ« User Education" | |
| elif it_problem == "Not Safe": | |
| root_cause = "Others" | |
| sub_root_cause = "IT Problem" | |
| action = "π€ Escalated to HQ" | |
| elif core == "Not Safe": | |
| root_cause = "Others" | |
| sub_root_cause = "Core Problem" | |
| action = "π οΈ Troubleshoot" | |
| elif rsrq < -15: | |
| root_cause = "Quality" | |
| sub_root_cause = "Quality Problem" | |
| action = "πΆ Optimization" | |
| else: | |
| root_cause = "Quality" | |
| sub_root_cause = "Quality (Network Normal)" | |
| action = "β Optimization" | |
| return f"Root Cause: {root_cause}\nSub Root Cause: {sub_root_cause}\nAction: {action}" | |
| with gr.Blocks(theme=gr.themes.Ocean()) as demo: | |
| gr.Markdown("# π Network Issue Diagnoser") | |
| gr.Markdown("A simple tool to analyze **telecommunication KPIs** and detect issues. This is an early version based on **ifβelse rules**. Future plan: extend to **AI-driven predictive diagnosis**.") | |
| with gr.Row(): | |
| with gr.Column(): | |
| availability = gr.Radio(["Safe", "Not Safe"], label="Availability", value="Safe") | |
| comcase = gr.Radio(["Safe", "Not Safe"], label="Comcase", value="Safe") | |
| module_stolen = gr.Radio(["Safe", "Not Safe"], label="Module Stolen", value="Safe") | |
| site_dismantle = gr.Radio(["Safe", "Not Safe"], label="Site Dismantle", value="Safe") | |
| blacksite = gr.Radio(["Safe", "Not Safe"], label="Blacksite", value="Safe") | |
| force_majeure = gr.Radio(["Safe", "Not Safe"], label="Force Majeure", value="Safe") | |
| trans_alarm = gr.Radio(["Safe", "Not Safe"], label="Trans Alarm", value="Safe") | |
| trans_pl = gr.Radio(["Safe", "Not Safe"], label="Trans Packet Loss (>0.1%)", value="Safe") | |
| with gr.Column(): | |
| trans_tnl = gr.Radio(["Safe", "Not Safe"], label="Trans TNL (>500)", value="Safe") | |
| ul_interference = gr.Radio(["Safe", "Not Safe"], label="UL Interference (>-100)", value="Safe") | |
| vswr = gr.Radio(["Safe", "Not Safe"], label="VSWR (>140)", value="Safe") | |
| alarm_problem = gr.Radio(["Safe", "Not Safe"], label="Alarm Problem", value="Safe") | |
| rsrp = gr.Textbox(label="RSRP (>-105 dBm)", value="-100") | |
| rsrq = gr.Textbox(label="RSRQ (>-15 dB)", value="-10") | |
| prb = gr.Radio(["Safe", "Not Safe"], label="PRB Usage (>90%)", value="Safe") | |
| max_user = gr.Radio(["Safe", "Not Safe"], label="Max User (>150)", value="Safe") | |
| with gr.Column(): | |
| active_user_max = gr.Radio(["Safe", "Not Safe"], label="Active User Max (>20)", value="Safe") | |
| no_dominant = gr.Radio(["No", "Yes"], label="No Dominant Coverage", value="No") | |
| cssr = gr.Radio(["Safe", "Not Safe"], label="CSSR", value="Safe") | |
| profile = gr.Radio(["Safe", "Not Safe"], label="Profile Problem", value="Safe") | |
| simcard = gr.Radio(["Safe", "Not Safe"], label="Simcard Problem", value="Safe") | |
| ue = gr.Radio(["Safe", "Not Safe"], label="UE Problem", value="Safe") | |
| it_problem = gr.Radio(["Safe", "Not Safe"], label="IT Problem", value="Safe") | |
| core = gr.Radio(["Safe", "Not Safe"], label="Core Problem", value="Safe") | |
| submit = gr.Button("Submit") | |
| output = gr.Textbox(label="π Diagnosis Result", interactive=True, lines=5) | |
| submit.click( | |
| diagnose_network, | |
| inputs=[ | |
| availability, comcase, module_stolen, site_dismantle, blacksite, force_majeure, | |
| trans_alarm, trans_pl, trans_tnl, ul_interference, vswr, alarm_problem, rsrp, rsrq, prb, max_user, active_user_max, no_dominant, | |
| cssr, profile, simcard, ue, it_problem, core | |
| ], | |
| outputs=output | |
| ) | |
| demo.launch() |