Commit
Β·
c467e42
1
Parent(s):
7e4257e
update app
Browse files- app.py +63 -26
- ticket-predictions.csv +5 -3
app.py
CHANGED
@@ -84,24 +84,46 @@ def gradio_predict(option, text_input, file_input):
|
|
84 |
def clear_inputs():
|
85 |
return "Enter Text", "", None, "", None
|
86 |
|
87 |
-
|
88 |
-
# Custom CSS for Better UI Scaling
|
89 |
custom_css = """
|
90 |
-
.gradio-container {
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
#
|
100 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
"""
|
102 |
-
|
103 |
# Gradio App UI
|
104 |
-
with gr.Blocks(css=
|
105 |
gr.Markdown(
|
106 |
"""
|
107 |
# AI Solution for Defect Ticket Classification
|
@@ -111,25 +133,38 @@ with gr.Blocks(css=custom_css1) as app:
|
|
111 |
**Model:** Fine-tuned **RoBERTa** for classification.
|
112 |
|
113 |
Enter ticket Description/Comment/Summary or upload a **CSV file** to predict Assigned Teams & Team Emails.
|
114 |
-
|
115 |
""",
|
116 |
elem_id="title"
|
117 |
)
|
118 |
|
119 |
with gr.Row():
|
120 |
-
with gr.Column(scale=
|
121 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
|
|
|
123 |
text_input = gr.Textbox(
|
124 |
label="Enter Ticket Description/Comment/Summary (One per line)",
|
|
|
125 |
lines=6,
|
126 |
-
placeholder="Example:\n - Database performance issue\n - Login fails for admin users..."
|
|
|
127 |
)
|
128 |
|
129 |
-
file_input = gr.File(
|
|
|
|
|
|
|
|
|
|
|
130 |
|
131 |
-
with gr.Column(scale=
|
132 |
-
gr.Markdown("## Prediction Results")
|
133 |
results_output = gr.Markdown(elem_id="results-box", visible=True)
|
134 |
download_csv = gr.File(label="π₯ Download Predictions CSV", interactive=False)
|
135 |
|
@@ -137,16 +172,18 @@ with gr.Blocks(css=custom_css1) as app:
|
|
137 |
predict_btn = gr.Button("PREDICT", variant="primary")
|
138 |
clear_btn = gr.Button("CLEAR", variant="secondary")
|
139 |
|
140 |
-
#
|
141 |
def toggle_input(selected_option):
|
142 |
-
|
|
|
|
|
|
|
143 |
|
144 |
option.change(fn=toggle_input, inputs=[option], outputs=[text_input, file_input])
|
145 |
-
|
146 |
predict_btn.click(fn=gradio_predict, inputs=[option, text_input, file_input], outputs=[results_output, download_csv])
|
147 |
clear_btn.click(fn=clear_inputs, inputs=[], outputs=[option, text_input, file_input, results_output, download_csv])
|
148 |
|
149 |
-
|
150 |
gr.Markdown("---")
|
151 |
gr.Markdown(
|
152 |
"<p style='text-align: center;color: gray;'>"
|
|
|
84 |
def clear_inputs():
|
85 |
return "Enter Text", "", None, "", None
|
86 |
|
87 |
+
# Custom CSS for improved UI and fixed input container sizes
|
|
|
88 |
custom_css = """
|
89 |
+
.gradio-container {
|
90 |
+
max-width: 1000px !important;
|
91 |
+
margin: auto !important;
|
92 |
+
}
|
93 |
+
#title {
|
94 |
+
text-align: center;
|
95 |
+
font-size: 26px !important;
|
96 |
+
font-weight: bold;
|
97 |
+
}
|
98 |
+
#predict-button, #clear-button, #download-button {
|
99 |
+
width: 100% !important;
|
100 |
+
height: 55px !important;
|
101 |
+
font-size: 18px !important;
|
102 |
+
}
|
103 |
+
#results-box {
|
104 |
+
height: 350px !important;
|
105 |
+
overflow-y: auto !important;
|
106 |
+
background: #f9f9f9;
|
107 |
+
padding: 15px;
|
108 |
+
border-radius: 10px;
|
109 |
+
font-size: 16px;
|
110 |
+
}
|
111 |
+
/* Reduce vertical padding for the radio component */
|
112 |
+
#choose_input_method {
|
113 |
+
padding-top: 5px !important;
|
114 |
+
padding-bottom: 5px !important;
|
115 |
+
}
|
116 |
+
/* Force both input components to have the same min-height */
|
117 |
+
#text_input, #file_input {
|
118 |
+
min-height: 200px !important;
|
119 |
+
/* Optionally add a consistent border and padding to match styling */
|
120 |
+
border: 1px solid #ccc;
|
121 |
+
padding: 10px;
|
122 |
+
}
|
123 |
"""
|
124 |
+
|
125 |
# Gradio App UI
|
126 |
+
with gr.Blocks(css=custom_css) as app:
|
127 |
gr.Markdown(
|
128 |
"""
|
129 |
# AI Solution for Defect Ticket Classification
|
|
|
133 |
**Model:** Fine-tuned **RoBERTa** for classification.
|
134 |
|
135 |
Enter ticket Description/Comment/Summary or upload a **CSV file** to predict Assigned Teams & Team Emails.
|
|
|
136 |
""",
|
137 |
elem_id="title"
|
138 |
)
|
139 |
|
140 |
with gr.Row():
|
141 |
+
with gr.Column(scale=1):
|
142 |
+
# Radio component with elem_id for CSS targeting
|
143 |
+
option = gr.Radio(
|
144 |
+
["Enter Text", "Upload CSV"],
|
145 |
+
label="π Choose Input Method",
|
146 |
+
value="Enter Text",
|
147 |
+
elem_id="choose_input_method"
|
148 |
+
)
|
149 |
|
150 |
+
# Both inputs are given an element id to force consistent dimensions.
|
151 |
text_input = gr.Textbox(
|
152 |
label="Enter Ticket Description/Comment/Summary (One per line)",
|
153 |
+
visible=True,
|
154 |
lines=6,
|
155 |
+
placeholder="Example:\n - Database performance issue\n - Login fails for admin users...",
|
156 |
+
elem_id="text_input"
|
157 |
)
|
158 |
|
159 |
+
file_input = gr.File(
|
160 |
+
label="π Upload CSV (Optional)",
|
161 |
+
type="filepath",
|
162 |
+
visible=False,
|
163 |
+
elem_id="file_input"
|
164 |
+
)
|
165 |
|
166 |
+
with gr.Column(scale=1):
|
167 |
+
gr.Markdown("## Prediction Results")
|
168 |
results_output = gr.Markdown(elem_id="results-box", visible=True)
|
169 |
download_csv = gr.File(label="π₯ Download Predictions CSV", interactive=False)
|
170 |
|
|
|
172 |
predict_btn = gr.Button("PREDICT", variant="primary")
|
173 |
clear_btn = gr.Button("CLEAR", variant="secondary")
|
174 |
|
175 |
+
# Toggle the visibility of input components to ensure consistent sizing
|
176 |
def toggle_input(selected_option):
|
177 |
+
if selected_option == "Enter Text":
|
178 |
+
return gr.update(visible=True), gr.update(visible=False)
|
179 |
+
else:
|
180 |
+
return gr.update(visible=False), gr.update(visible=True)
|
181 |
|
182 |
option.change(fn=toggle_input, inputs=[option], outputs=[text_input, file_input])
|
|
|
183 |
predict_btn.click(fn=gradio_predict, inputs=[option, text_input, file_input], outputs=[results_output, download_csv])
|
184 |
clear_btn.click(fn=clear_inputs, inputs=[], outputs=[option, text_input, file_input, results_output, download_csv])
|
185 |
|
186 |
+
# Footer view
|
187 |
gr.Markdown("---")
|
188 |
gr.Markdown(
|
189 |
"<p style='text-align: center;color: gray;'>"
|
ticket-predictions.csv
CHANGED
@@ -1,4 +1,6 @@
|
|
1 |
Index,Description,Assigned Team,Team Email
|
2 |
-
1,
|
3 |
-
2,
|
4 |
-
3,
|
|
|
|
|
|
1 |
Index,Description,Assigned Team,Team Email
|
2 |
+
1,Database queries not optimized for large datasets.,Code Review Team,[email protected]
|
3 |
+
2,User authentication fails when accessing restricted sections.,Functional Team,functional[email protected]
|
4 |
+
3,High CPU utilization leading to system overheating and slow performance.,Performance Team,performance[email protected]
|
5 |
+
4,System crashes due to misconfigured runtime environments.,Infrastructure Team,[email protected]
|
6 |
+
5,Unauthorized access detected in restricted sections of the application.,Security Team,[email protected]
|