Spaces:
Running
Running
Upload 4 files
Browse files- .gitattributes +2 -0
- Site List.xlsx +3 -0
- app.py +494 -0
- requirements.txt +7 -0
- template.pptx +3 -0
.gitattributes
CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
Site[[:space:]]List.xlsx filter=lfs diff=lfs merge=lfs -text
|
37 |
+
template.pptx filter=lfs diff=lfs merge=lfs -text
|
Site List.xlsx
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a043f6d5c7757b519f69aef807f9310aa01914845c3fb9832a3592d7fce4be61
|
3 |
+
size 8414272
|
app.py
ADDED
@@ -0,0 +1,494 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Import package and module
|
2 |
+
import gradio as gr
|
3 |
+
import pandas as pd
|
4 |
+
from transformers import pipeline
|
5 |
+
from g4f.client import Client
|
6 |
+
|
7 |
+
|
8 |
+
# /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
9 |
+
|
10 |
+
|
11 |
+
# Initialize GPT-4 Client
|
12 |
+
client = Client()
|
13 |
+
|
14 |
+
|
15 |
+
# Function for answering questions using GPT-4
|
16 |
+
def process_notes(notes):
|
17 |
+
questions = [
|
18 |
+
"Sebutkan Kendala Customer? (Contoh jawaban yang benar -> sinyal inet tidak stabil, all app, 1-2 bar E, in/outdoor sama, no ybs saja)", # detail_complain
|
19 |
+
"Siapa Nama Customer? (Contoh jawaban yang benar -> Damelia)", # customer_name
|
20 |
+
"Berapa Nomor MSISDN Yang Bermasalah: (Contoh jawaban yang benar -> 6281298765432)", # msisdn
|
21 |
+
"Kapan Tanggal/Jam Kejadian? (Contoh jawaban yang benar -> 20/12/2024 11:24 - 15:24)", # tanggal_kejadian
|
22 |
+
"Dimana Lokasi Pelanggan (alamat)? (Contoh jawaban yang benar -> Jl. Bambu Kuning No.33, Bojonggede, Kecamatan Bojonggede, Kabupaten Bogor, Jawa Barat 16922)", # location
|
23 |
+
# "Apakah mode jaringan (4G/3G/2G)?", # mode_jaringan
|
24 |
+
# "Apakah Tier pelanggan (Silver/Gold/Platinum/Diamond)?", # tipe_pelanggan
|
25 |
+
]
|
26 |
+
|
27 |
+
answers = []
|
28 |
+
for q in questions:
|
29 |
+
prompt = f"[Language: Bahasa Indonesia] Jawab singkat dan langsung: {q} {notes}"
|
30 |
+
response = client.chat.completions.create(model="gpt-4o-mini", messages=[{"role": "user", "content": prompt}])
|
31 |
+
answers.append(response.choices[0].message.content.strip())
|
32 |
+
return answers
|
33 |
+
|
34 |
+
|
35 |
+
|
36 |
+
# Function for generating report
|
37 |
+
def generate_report(no_ticket, detail_complain, customer_name, msisdn, tanggal_kejadian, remedy_submit_time, severity,
|
38 |
+
location, long_lat, mode_jaringan, kategori_keluhan, tipe_pelanggan, device, profile_check,
|
39 |
+
imsi_bcp_choice, site_name, availability, alarm_impact, accessibility_issue, high_prb_dl,
|
40 |
+
high_max_user, high_ul_interference, transport_issue_pl, transport_issue_tnl, transport_issue_latency,
|
41 |
+
status, av_status, orbit_byu, rsrp_rsrq, hc_site, suspect_issue, action_plan):
|
42 |
+
|
43 |
+
# Report format
|
44 |
+
report = f"""
|
45 |
+
No. Ticket: {no_ticket}
|
46 |
+
Detail Complaint: {detail_complain}
|
47 |
+
Nama: {customer_name}
|
48 |
+
MSISDN: {msisdn}
|
49 |
+
Tanggal Kejadian: {tanggal_kejadian}
|
50 |
+
Remedy Submit Time: {remedy_submit_time}
|
51 |
+
Severity: {severity}
|
52 |
+
------------------
|
53 |
+
Location: {location}
|
54 |
+
Long Lat: {long_lat} (perkiraan lokasi pelanggan)
|
55 |
+
------------------
|
56 |
+
Mode Jaringan: {mode_jaringan}
|
57 |
+
Kategori Keluhan: {kategori_keluhan}
|
58 |
+
Tipe Pelanggan: {tipe_pelanggan}
|
59 |
+
Device: {device}
|
60 |
+
------------------
|
61 |
+
1. Profile Check:
|
62 |
+
{profile_check}
|
63 |
+
------------------
|
64 |
+
2. Healty Check:
|
65 |
+
#4G: {site_name}
|
66 |
+
- Availability - {availability}
|
67 |
+
- Alarm impact service - {alarm_impact}
|
68 |
+
- Accessibility issue - {accessibility_issue}
|
69 |
+
- High PRB DL - {high_prb_dl}
|
70 |
+
- High Max user - {high_max_user}
|
71 |
+
- High Ul Interference - {high_ul_interference}
|
72 |
+
- Transport issue based on PL - {transport_issue_pl}
|
73 |
+
- Transport issue based on TNL - {transport_issue_tnl}
|
74 |
+
- Transport issue based on latency - {transport_issue_latency}
|
75 |
+
------------------
|
76 |
+
3. Parameter Check:
|
77 |
+
- {site_name}, Status: {status}, Av. Status: {av_status}
|
78 |
+
- All Parameter Standard and Proper
|
79 |
+
------------------
|
80 |
+
4. Finding:
|
81 |
+
- Pelanggan {orbit_byu}HVC {tipe_pelanggan} berkendala {detail_complain}
|
82 |
+
- Site terdekat dengan pelanggan adalah {site_name}
|
83 |
+
{imsi_bcp(imsi_bcp_choice, site_name)}
|
84 |
+
- {rsrp_rsrq}
|
85 |
+
- Hasil HC {site_name} {hc_site}
|
86 |
+
------------------
|
87 |
+
5. Suspect Issue :
|
88 |
+
- {suspect_issue}
|
89 |
+
------------------
|
90 |
+
6. Action Plan:
|
91 |
+
- {action_plan}
|
92 |
+
------------------
|
93 |
+
Terima kasih
|
94 |
+
"""
|
95 |
+
# Remove extra spaces in the output
|
96 |
+
return "\n".join([line.strip() for line in report.splitlines() if line.strip()])
|
97 |
+
|
98 |
+
|
99 |
+
|
100 |
+
# Function for determining IMSI or BCP
|
101 |
+
def imsi_bcp(imsi_bcp_choice, site_name):
|
102 |
+
# Simplified conditional return
|
103 |
+
return (
|
104 |
+
f"- Hasil IMSI tercover {site_name}" if imsi_bcp_choice == "IMSI" else
|
105 |
+
f"- Hasil IMSI no record\n- Hasil BCP tercover {site_name}" if imsi_bcp_choice == "BCP (IMSI no record)" else
|
106 |
+
f"- Hasil IMSI tercover {site_name}\n- Hasil BCP tercover {site_name}" if imsi_bcp_choice == "IMSI & BCP" else ""
|
107 |
+
)
|
108 |
+
|
109 |
+
|
110 |
+
|
111 |
+
# Interface for tab 1
|
112 |
+
with gr.Blocks() as tab1:
|
113 |
+
# Input for notes
|
114 |
+
notes = gr.Textbox(label="Notes", max_lines = 5)
|
115 |
+
# Submit button for notes
|
116 |
+
with gr.Row():
|
117 |
+
reset1 = gr.ClearButton(components=[notes], value="Reset")
|
118 |
+
submit1 = gr.Button("Submit Notes", variant="primary")
|
119 |
+
|
120 |
+
# Input for generate report
|
121 |
+
with gr.Row():
|
122 |
+
with gr.Column():
|
123 |
+
no_ticket = gr.Textbox(label="No. Ticket", placeholder="INCxxx", lines=1)
|
124 |
+
detail_complain = gr.Textbox(label="Detail Complaint", placeholder="Internet Lambat")
|
125 |
+
customer_name = gr.Textbox(label="Nama", placeholder="Damelia", lines=1)
|
126 |
+
msisdn = gr.Textbox(label="MSISDN", placeholder="62xxx", lines=1)
|
127 |
+
tanggal_kejadian = gr.Textbox(label="Tanggal Kejadian", placeholder="1 Januari 2001", lines=1)
|
128 |
+
remedy_submit_time = gr.Textbox(label="Remedy Submit Time", placeholder="01/01/2001 01:00:00 AM", lines=1)
|
129 |
+
severity = gr.Radio(["Low", "Medium", "High"], label="Severity", value="Low")
|
130 |
+
orbit_byu = gr.Radio(["", "ORBIT ", "BYU "], label="ORBIT / BYU", value="")
|
131 |
+
|
132 |
+
with gr.Column():
|
133 |
+
location = gr.Textbox(label="Location", placeholder="Jalan xxx No.1 RT/RW")
|
134 |
+
long_lat = gr.Textbox(label="Long Lat", placeholder="-6.123456, 106.123456", lines=1)
|
135 |
+
mode_jaringan = gr.Radio(["4G", "3G", "2G"], label="Mode Jaringan", value="4G")
|
136 |
+
kategori_keluhan = gr.Radio(["Data", "Coverage", "Voice"], label="Kategori Keluhan", value="Data")
|
137 |
+
tipe_pelanggan = gr.Radio(["Silver", "Gold", "Platinum", "Diamond"], label="Tipe Pelanggan", value="Gold")
|
138 |
+
device = gr.Textbox(label="Device", placeholder="iPhone 15 Pro Max", value="-")
|
139 |
+
profile_check = gr.Textbox(label="Profile Check", value="* SIM Capability : USIM\n* Barring Status PS : No Barring\n* Barring Status CS : No Barring\n* Quota Status : OK", max_lines=5)
|
140 |
+
|
141 |
+
with gr.Row():
|
142 |
+
with gr.Column():
|
143 |
+
imsi_bcp_choice = gr.Radio(["IMSI", "BCP (IMSI no record)", "IMSI & BCP"], label="Trace dari IMSI / BCP", value="IMSI")
|
144 |
+
site_name = gr.Textbox(label="Site Name", placeholder="X_JXX000MXX_Nama-DXX_MX00")
|
145 |
+
status = gr.Radio(["Enable", "Disable", "Unknown"], label="Status", value="Enable")
|
146 |
+
av_status = gr.Radio(["Normal", "Invalid", "Unknown"], label="Av. Status", value="Normal")
|
147 |
+
rsrp_rsrq = gr.Textbox(label="RSRP & RSRQ", value="RSRP -106 dBm & RSRQ -12 dB")
|
148 |
+
|
149 |
+
with gr.Column():
|
150 |
+
availability = gr.Radio(["Safe", "Not Safe"], label="Availability", value="Safe")
|
151 |
+
alarm_impact = gr.Radio(["Safe", "Not Safe"], label="Alarm Impact", value="Safe")
|
152 |
+
accessibility_issue = gr.Radio(["Safe", "Not Safe"], label="Accessibility Issue", value="Safe")
|
153 |
+
high_prb_dl = gr.Radio(["Safe", "Not Safe"], label="High PRB DL", value="Safe")
|
154 |
+
high_max_user = gr.Radio(["Safe", "Not Safe"], label="High Max User", value="Safe")
|
155 |
+
|
156 |
+
with gr.Column():
|
157 |
+
high_ul_interference = gr.Radio(["Safe", "Not Safe"], label="High UL Interference", value="Safe")
|
158 |
+
transport_issue_pl = gr.Radio(["Safe", "Not Safe"], label="Transport Issue PL", value="Safe")
|
159 |
+
transport_issue_tnl = gr.Radio(["Safe", "Not Safe"], label="Transport Issue TNL", value="Safe")
|
160 |
+
transport_issue_latency = gr.Radio(["Safe", "Not Safe"], label="Transport Issue Latency", value="Safe")
|
161 |
+
hc_site = gr.Textbox(label="HC Site", value="dalam kondisi KPI normal")
|
162 |
+
|
163 |
+
with gr.Row():
|
164 |
+
suspect_issue = gr.Dropdown(["Low coverage", "Quality Problem", "No Dominant Coverage", "High PRB", "Availability Problem", "Trans TNL", "Trans Packet Loss", "Alarm Problem", "Trans Alarm", "High UL Interference", "High VSWR", "Site Dismantle", "IT Problem", "Others"], label="Suspect Issue", value="Low coverage")
|
165 |
+
action_plan = gr.Dropdown(["Optimasi", "Troubleshoot", "User Education", "Reengineering", "ESCALATED TO HQ"], label="Action Plan", value="Optimasi")
|
166 |
+
|
167 |
+
# Inputs list of generate report
|
168 |
+
fields_generate_report = [no_ticket, detail_complain, customer_name, msisdn, tanggal_kejadian, remedy_submit_time, severity,
|
169 |
+
location, long_lat, mode_jaringan, kategori_keluhan, tipe_pelanggan, device, profile_check,
|
170 |
+
imsi_bcp_choice, site_name, availability, alarm_impact, accessibility_issue, high_prb_dl,
|
171 |
+
high_max_user, high_ul_interference, transport_issue_pl, transport_issue_tnl, transport_issue_latency,
|
172 |
+
status, av_status, orbit_byu, rsrp_rsrq, hc_site, suspect_issue, action_plan]
|
173 |
+
|
174 |
+
# Submit button for generate report
|
175 |
+
with gr.Row():
|
176 |
+
reset2 = gr.ClearButton(components=[*fields_generate_report], value="Reset")
|
177 |
+
submit2 = gr.Button("Generate Report", variant="primary")
|
178 |
+
|
179 |
+
# For showing the output
|
180 |
+
output = gr.Textbox(label="Report", interactive=True, lines=0)
|
181 |
+
|
182 |
+
# Function for PPT
|
183 |
+
download_button = gr.File(label="Download Template PPT", value="template.pptx")
|
184 |
+
|
185 |
+
# Process button for notes using GPT-4
|
186 |
+
submit1.click(process_notes, inputs=notes, outputs=[detail_complain, customer_name, msisdn, tanggal_kejadian, location])
|
187 |
+
# submit1.click(process_notes, inputs=notes, outputs=[detail_complain, customer_name, msisdn, tanggal_kejadian, location, mode_jaringan, tipe_pelanggan])
|
188 |
+
# Process button for generating report
|
189 |
+
submit2.click(generate_report, inputs=fields_generate_report, outputs=output)
|
190 |
+
|
191 |
+
|
192 |
+
# /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
193 |
+
|
194 |
+
|
195 |
+
# Function for creating HTML imsi table
|
196 |
+
def imsi_df_style(df, table_id="imsi-table"):
|
197 |
+
# Convert DataFrame to HTML table with custom classes
|
198 |
+
html = df.to_html(classes='table table-bordered',
|
199 |
+
border=0,
|
200 |
+
index=False,
|
201 |
+
table_id=table_id)
|
202 |
+
|
203 |
+
# Custom CSS for the table
|
204 |
+
custom_css = """
|
205 |
+
<style>
|
206 |
+
body {
|
207 |
+
font-family: 'Calibri', sans-serif;
|
208 |
+
font-size: 5px;
|
209 |
+
}
|
210 |
+
#table-container {
|
211 |
+
max-height: 600px;
|
212 |
+
overflow-y: auto;
|
213 |
+
position: relative;
|
214 |
+
}
|
215 |
+
#imsi-table {
|
216 |
+
width: 100%;
|
217 |
+
border-collapse: collapse;
|
218 |
+
}
|
219 |
+
#imsi-table th {
|
220 |
+
position: sticky;
|
221 |
+
top: 0;
|
222 |
+
background-color: #FFFF00;
|
223 |
+
color: black;
|
224 |
+
padding: 2px;
|
225 |
+
font-weight: normal;
|
226 |
+
border: 1px solid #d6d6d6;
|
227 |
+
z-index: 1;
|
228 |
+
}
|
229 |
+
#imsi-table td {
|
230 |
+
background-color: white;
|
231 |
+
color: black;
|
232 |
+
padding: 2px;
|
233 |
+
border: 1px solid #d6d6d6;
|
234 |
+
}
|
235 |
+
</style>
|
236 |
+
"""
|
237 |
+
|
238 |
+
# Wrap the table in a container
|
239 |
+
wrapped_html = f'<div id="table-container">{html}</div>'
|
240 |
+
return custom_css + wrapped_html
|
241 |
+
|
242 |
+
|
243 |
+
|
244 |
+
# OOP for tab 2: IMSI Trace
|
245 |
+
# class IMSIReportStyler:
|
246 |
+
# def __init__(self, df, table_id="imsi-table"):
|
247 |
+
# self.df = df
|
248 |
+
# self.table_id = table_id
|
249 |
+
# self.html = None
|
250 |
+
|
251 |
+
# def generate_html(self):
|
252 |
+
# self.html = self.df.to_html(
|
253 |
+
# classes='table table-bordered',
|
254 |
+
# border=0,
|
255 |
+
# index=False,
|
256 |
+
# table_id=self.table_id
|
257 |
+
# )
|
258 |
+
|
259 |
+
# def apply_css(self):
|
260 |
+
# custom_css = """
|
261 |
+
# <style>
|
262 |
+
# body {
|
263 |
+
# font-family: 'Calibri', sans-serif;
|
264 |
+
# font-size: 5px;
|
265 |
+
# }
|
266 |
+
# #table-container {
|
267 |
+
# max-height: 600px;
|
268 |
+
# overflow-y: auto;
|
269 |
+
# position: relative;
|
270 |
+
# }
|
271 |
+
# #imsi-table {
|
272 |
+
# width: 100%;
|
273 |
+
# border-collapse: collapse;
|
274 |
+
# }
|
275 |
+
# #imsi-table th {
|
276 |
+
# position: sticky;
|
277 |
+
# top: 0;
|
278 |
+
# background-color: #FFFF00;
|
279 |
+
# color: black;
|
280 |
+
# padding: 2px;
|
281 |
+
# font-weight: normal;
|
282 |
+
# border: 1px solid #d6d6d6;
|
283 |
+
# z-index: 1;
|
284 |
+
# }
|
285 |
+
# #imsi-table td {
|
286 |
+
# background-color: white;
|
287 |
+
# color: black;
|
288 |
+
# padding: 2px;
|
289 |
+
# border: 1px solid #d6d6d6;
|
290 |
+
# }
|
291 |
+
# </style>
|
292 |
+
# """
|
293 |
+
# self.html = custom_css + f'<div id="table-container">{self.html}</div>'
|
294 |
+
|
295 |
+
# def style_report(self):
|
296 |
+
# self.generate_html()
|
297 |
+
# self.apply_css()
|
298 |
+
# return self.html
|
299 |
+
|
300 |
+
|
301 |
+
|
302 |
+
# Function for tab 2: IMSI Trace
|
303 |
+
def imsi_trace(file):
|
304 |
+
# Load IMSI data
|
305 |
+
imsi = pd.read_csv(file.name).sort_values('Start Time', ascending=False)
|
306 |
+
|
307 |
+
# Group and calculate statistics
|
308 |
+
count_df = imsi.groupby('Start Cell Name').size().reset_index(name='Count of Start Cell Name').sort_values(by='Count of Start Cell Name', ascending=False)
|
309 |
+
avg_df = imsi.groupby('Start Cell Name')[['Start RxLev/RSCP/RSRP (dBm)', 'Start RxQual/ECN0/RSRQ (dB)']].mean().reset_index()
|
310 |
+
result_df = pd.merge(count_df, avg_df, on='Start Cell Name', how='inner')
|
311 |
+
|
312 |
+
# Select columns for filtered data
|
313 |
+
filtered_imsi = imsi[['Start Time', 'MSISDN', 'Technology', 'Call Type', 'Start Cell Name', 'Start Latitude', 'Start Longtitude', 'Start RxLev/RSCP/RSRP (dBm)', 'Start RxQual/ECN0/RSRQ (dB)']]
|
314 |
+
|
315 |
+
# Write to Excel with colored headers
|
316 |
+
writer = pd.ExcelWriter('hasil_imsi.xlsx', engine='xlsxwriter')
|
317 |
+
filtered_imsi.to_excel(writer, sheet_name='Data IMSI', index=False)
|
318 |
+
workbook = writer.book
|
319 |
+
worksheet = writer.sheets['Data IMSI']
|
320 |
+
|
321 |
+
# Define header format
|
322 |
+
header_format = workbook.add_format({'valign': 'center', 'fg_color': '#FFFF00', 'font_color': "black", 'border': 1})
|
323 |
+
|
324 |
+
# Apply header format using list comprehension
|
325 |
+
[worksheet.write(0, col_num, value, header_format) for col_num, value in enumerate(filtered_imsi.columns)]
|
326 |
+
|
327 |
+
writer.close()
|
328 |
+
|
329 |
+
# Convert to HTML table with custom CSS
|
330 |
+
imsi_output = imsi_df_style(filtered_imsi)
|
331 |
+
|
332 |
+
# styler = IMSIReportStyler(filtered_imsi)
|
333 |
+
# imsi_output = styler.style_report()
|
334 |
+
|
335 |
+
return result_df, imsi_output, "hasil_imsi.xlsx"
|
336 |
+
|
337 |
+
|
338 |
+
|
339 |
+
# Interface for tab 2
|
340 |
+
with gr.Blocks() as tab2:
|
341 |
+
with gr.Row():
|
342 |
+
with gr.Column(scale=1/4):
|
343 |
+
file_input = gr.File(label="Upload CSV")
|
344 |
+
with gr.Row():
|
345 |
+
submit_btn = gr.Button("Submit", variant="primary")
|
346 |
+
reset_btn = gr.ClearButton([file_input], value="Reset")
|
347 |
+
dw_filtered_imsi = gr.File(label="Download Filtered IMSI")
|
348 |
+
with gr.Column(scale=3/4):
|
349 |
+
pivoted_imsi = gr.Dataframe(label="Pivoted Data")
|
350 |
+
filtered_imsi = gr.HTML(label="Filtered Data")
|
351 |
+
|
352 |
+
submit_btn.click(fn=imsi_trace, inputs=file_input, outputs=[pivoted_imsi, filtered_imsi, dw_filtered_imsi])
|
353 |
+
|
354 |
+
|
355 |
+
# /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
356 |
+
|
357 |
+
|
358 |
+
# Function for creating HTML imsi table
|
359 |
+
def bcp_df_style(df, table_id="bcp-table"):
|
360 |
+
# Convert DataFrame to HTML table with custom classes
|
361 |
+
html = df.to_html(classes='table table-bordered',
|
362 |
+
border=0,
|
363 |
+
index=False,
|
364 |
+
table_id=table_id)
|
365 |
+
|
366 |
+
# Custom CSS for the table
|
367 |
+
custom_css = """
|
368 |
+
<style>
|
369 |
+
body {
|
370 |
+
font-family: 'Calibri', sans-serif;
|
371 |
+
font-size: 5px;
|
372 |
+
}
|
373 |
+
#table-container {
|
374 |
+
max-height: 600px;
|
375 |
+
overflow-y: auto;
|
376 |
+
position: relative;
|
377 |
+
}
|
378 |
+
#bcp-table {
|
379 |
+
width: 100%;
|
380 |
+
border-collapse: collapse;
|
381 |
+
}
|
382 |
+
#bcp-table th {
|
383 |
+
position: sticky;
|
384 |
+
top: 0;
|
385 |
+
background-color: #2f75b5;
|
386 |
+
color: white;
|
387 |
+
padding: 2px;
|
388 |
+
font-weight: bold;
|
389 |
+
border: 1px solid #d6d6d6;
|
390 |
+
z-index: 1;
|
391 |
+
text-align: center;
|
392 |
+
}
|
393 |
+
#bcp-table th:nth-last-child(2),
|
394 |
+
#bcp-table th:nth-last-child(1) {
|
395 |
+
background-color: #ffd966;
|
396 |
+
}
|
397 |
+
#bcp-table td {
|
398 |
+
background-color: white;
|
399 |
+
color: black;
|
400 |
+
padding: 2px;
|
401 |
+
border: 1px solid #d6d6d6;
|
402 |
+
white-space: nowrap;
|
403 |
+
overflow: hidden;
|
404 |
+
}
|
405 |
+
#bcp-table td:nth-child(n+3):nth-child(-n+12) {
|
406 |
+
overflow: hidden;
|
407 |
+
text-overflow: ellipsis;
|
408 |
+
max-width: 120px;
|
409 |
+
}
|
410 |
+
</style>
|
411 |
+
"""
|
412 |
+
|
413 |
+
# Wrap the table in a container
|
414 |
+
wrapped_html = f'<div id="table-container">{html}</div>'
|
415 |
+
return custom_css + wrapped_html
|
416 |
+
|
417 |
+
|
418 |
+
|
419 |
+
# Function for tab 3: BCP Trace
|
420 |
+
def bcp_trace(file):
|
421 |
+
# Load site list and BCP data
|
422 |
+
bcp_site_list = pd.read_excel("Site List.xlsx", sheet_name="Site List")
|
423 |
+
# bcp = pd.read_csv(file.name, sep=",").iloc[:, :-1].sort_values('Timestamp ', ascending=False)
|
424 |
+
bcp = pd.read_csv(file.name, sep=",").sort_values('Timestamp ', ascending=False)
|
425 |
+
bcp['RAT '] = bcp['RAT '].replace('5G-NSA', '4G')
|
426 |
+
|
427 |
+
# Calculate LAC-CI
|
428 |
+
bcp['LAC-CI'] = bcp.apply(lambda row: int(row['CGI '][11:17] + row['CGI '][-2:]) if row['RAT '] == '4G' else int(row['CGI '][-9:]), axis=1)
|
429 |
+
|
430 |
+
# Map site names
|
431 |
+
dict_site_name = bcp_site_list.set_index('LACCI')['cellname'].to_dict()
|
432 |
+
bcp['SITE NAME'] = bcp['LAC-CI'].map(dict_site_name)
|
433 |
+
|
434 |
+
# Select and sort columns
|
435 |
+
bcp = bcp[['Timestamp ', 'Source ', 'CGI ', 'RAT ', 'Village ', 'LAC ', 'CI/ECI ', 'City ', 'Province ', 'Region ', 'Geolocation ', 'Country ', 'LAC-CI', 'SITE NAME']]
|
436 |
+
|
437 |
+
# Write to Excel with colored headers
|
438 |
+
writer = pd.ExcelWriter('hasil_bcp.xlsx', engine='xlsxwriter')
|
439 |
+
bcp.to_excel(writer, sheet_name='Data BCP', index=False)
|
440 |
+
workbook = writer.book
|
441 |
+
worksheet = writer.sheets['Data BCP']
|
442 |
+
|
443 |
+
# Define header colors
|
444 |
+
header_format_1 = workbook.add_format({'bold': True, 'valign': 'center', 'fg_color': '#2f75b5', 'font_color': "#FFFFFF", 'border': 1})
|
445 |
+
header_format_2 = workbook.add_format({'bold': True, 'valign': 'center', 'fg_color': '#ffd966', 'font_color': "#FFFFFF", 'border': 1})
|
446 |
+
|
447 |
+
# Apply header colors using list comprehension
|
448 |
+
[worksheet.write(0, col_num, value, header_format_1 if value in ['Timestamp ', 'Source ', 'CGI ', 'RAT ', 'Village ', 'LAC ', 'CI/ECI ', 'City ', 'Province ', 'Region ', 'Geolocation ', 'Country '] else header_format_2) for col_num, value in enumerate(bcp.columns)]
|
449 |
+
|
450 |
+
writer.close()
|
451 |
+
|
452 |
+
# Group and count site names
|
453 |
+
count_df = bcp.groupby('SITE NAME').size().reset_index(name='Count of SITE NAME').sort_values(by='Count of SITE NAME', ascending=False)
|
454 |
+
|
455 |
+
# Convert to HTML table with custom CSS
|
456 |
+
bcp_output = bcp_df_style(bcp)
|
457 |
+
|
458 |
+
return count_df, bcp_output, "hasil_bcp.xlsx"
|
459 |
+
|
460 |
+
|
461 |
+
|
462 |
+
# Interface for tab 3
|
463 |
+
with gr.Blocks() as tab3:
|
464 |
+
with gr.Row():
|
465 |
+
with gr.Column(scale=1/4):
|
466 |
+
file_input = gr.File(label="Upload CSV")
|
467 |
+
with gr.Row():
|
468 |
+
submit_btn = gr.Button("Submit", variant="primary")
|
469 |
+
reset_btn = gr.ClearButton([file_input], value="Reset")
|
470 |
+
dw_filtered_bcp = gr.File(label="Download Filtered BCP")
|
471 |
+
with gr.Column(scale=3/4):
|
472 |
+
pivoted_bcp = gr.Dataframe(label="Pivoted Data")
|
473 |
+
filtered_bcp = gr.HTML(label="Filtered Data")
|
474 |
+
|
475 |
+
submit_btn.click(fn=bcp_trace, inputs=file_input, outputs=[pivoted_bcp, filtered_bcp, dw_filtered_bcp])
|
476 |
+
|
477 |
+
|
478 |
+
# /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
479 |
+
|
480 |
+
|
481 |
+
# Fuction for VIP and Non-Remedy
|
482 |
+
|
483 |
+
|
484 |
+
# /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
485 |
+
|
486 |
+
|
487 |
+
# Combine all tabs
|
488 |
+
demo = gr.TabbedInterface(
|
489 |
+
[tab1, tab2, tab3],
|
490 |
+
["Generate Report", "IMSI Trace", "BCP Trace"],
|
491 |
+
# theme=gr.themes.Glass(),
|
492 |
+
)
|
493 |
+
demo.launch(share=True)
|
494 |
+
|
requirements.txt
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
pandas
|
3 |
+
transformers
|
4 |
+
torch
|
5 |
+
openpyxl
|
6 |
+
xlsxwriter
|
7 |
+
g4f[all]
|
template.pptx
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b5f75aba8296c6706c5de0fe83ce3740dd05a7cdc6fb73baa8c83f99717359aa
|
3 |
+
size 151363
|