mintheinwin commited on
Commit
c467e42
Β·
1 Parent(s): 7e4257e

update app

Browse files
Files changed (2) hide show
  1. app.py +63 -26
  2. 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 { max-width: 1400px !important; margin: auto !important; }
91
- #title { text-align: center; font-size: 26px !important; font-weight: bold; }
92
- #predict-button, #clear-button, #download-button { width: 100% !important; height: 55px !important; font-size: 18px !important; }
93
- #results-box { height: 350px !important; overflow-y: auto !important; background: #f9f9f9; padding: 15px; border-radius: 10px; font-size: 16px; }
94
- """
95
- custom_css1 = """
96
- .gradio-container { max-width: 1400px !important; margin: auto !important; }
97
- #title { text-align: center; font-size: 26px !important; font-weight: bold; }
98
- #predict-button, #clear-button, #download-button { width: 100% !important; height: 55px !important; font-size: 18px !important; }
99
- #results-box { height: 350px !important; overflow-y: auto !important; background: #f9f9f9; padding: 15px; border-radius: 10px; font-size: 16px; }
100
- #download-csv-file input { height: 30px !important; font-size: 14px !important; padding: 5px !important; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  """
102
- #".gradio-container {max-width: 1500px; margin: auto;}"
103
  # Gradio App UI
104
- with gr.Blocks(css=custom_css1) as app:
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=3):
121
- option = gr.Radio(["Enter Text", "Upload CSV"], label="πŸ“ Choose Input Method", value="Enter Text")
 
 
 
 
 
 
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(label="πŸ“‚ Upload CSV (Optional)", type="filepath", visible=False)
 
 
 
 
 
130
 
131
- with gr.Column(scale=3):
132
- gr.Markdown("## Prediction Results") # **Title for 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
- # Logic for Showing/ Hiding Input Fields
141
  def toggle_input(selected_option):
142
- return gr.update(visible=(selected_option == "Enter Text")), gr.update(visible=(selected_option == "Upload CSV"))
 
 
 
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
- # Footer view
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,Incorrect error handling in exception module.,Code Review Team,[email protected]
3
- 2,Implement input sanitization to prevent injection attacks.,Code Review Team,codereview[email protected]
4
- 3,Error Handling Needs Improvement,Code Review Team,codereview[email protected]
 
 
 
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]