Spaces:
Sleeping
Sleeping
Fix tab structure in simplified_gradio_app.py
Browse files- Fix indentation for Standard Verification tab content
- All UI elements now properly nested inside their TabItem
- Resolves duplicate tabs issue in the interface
- Tabs now switch correctly between modes
- src/interface/simplified_gradio_app.py +110 -110
src/interface/simplified_gradio_app.py
CHANGED
|
@@ -154,122 +154,122 @@ def create_simplified_interface():
|
|
| 154 |
dataset editing, manual input testing, and batch file uploads.
|
| 155 |
</div>
|
| 156 |
""")
|
| 157 |
-
|
| 158 |
-
gr.Markdown("# β Verify Classifier Accuracy")
|
| 159 |
-
gr.Markdown("Review classified messages and provide feedback to improve the spiritual distress classifier.")
|
| 160 |
-
|
| 161 |
-
# Dataset selector section
|
| 162 |
-
with gr.Row():
|
| 163 |
-
with gr.Column(scale=2):
|
| 164 |
-
gr.Markdown("## π Select Dataset")
|
| 165 |
-
dataset_selector = VerificationUIComponents.create_dataset_selector_component()
|
| 166 |
-
load_dataset_btn = gr.Button("π₯ Load Dataset", variant="primary", scale=1)
|
| 167 |
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
value="Select a dataset to begin verification",
|
| 171 |
-
label="Dataset Info"
|
| 172 |
-
)
|
| 173 |
-
|
| 174 |
-
# Message review section - MUST be created outside with statement to control visibility
|
| 175 |
-
message_review_section = gr.Row(visible=False)
|
| 176 |
-
with message_review_section:
|
| 177 |
-
with gr.Column(scale=2):
|
| 178 |
-
# Progress display
|
| 179 |
-
progress_display = VerificationUIComponents.create_progress_display()
|
| 180 |
-
|
| 181 |
-
# Message review components
|
| 182 |
-
message_text, decision_badge, confidence, indicators = VerificationUIComponents.create_message_review_component()
|
| 183 |
-
|
| 184 |
-
# Feedback buttons
|
| 185 |
-
with gr.Row():
|
| 186 |
-
correct_btn, incorrect_btn = VerificationUIComponents.create_feedback_buttons()
|
| 187 |
-
|
| 188 |
-
# Correction selector (initially hidden)
|
| 189 |
-
correction_section = gr.Row(visible=False)
|
| 190 |
-
with correction_section:
|
| 191 |
-
correction_selector, notes_field = VerificationUIComponents.create_correction_selector()
|
| 192 |
-
|
| 193 |
-
# Submit correction button
|
| 194 |
-
submit_correction_row = gr.Row(visible=False)
|
| 195 |
-
with submit_correction_row:
|
| 196 |
-
submit_correction_btn = gr.Button("β Submit Correction", variant="primary", scale=2)
|
| 197 |
-
cancel_correction_btn = gr.Button("β Cancel", scale=1)
|
| 198 |
-
|
| 199 |
-
# Navigation buttons
|
| 200 |
-
with gr.Row():
|
| 201 |
-
prev_btn = gr.Button("β¬
οΈ Previous", scale=1)
|
| 202 |
-
skip_btn = gr.Button("βοΈ Skip", scale=1)
|
| 203 |
-
next_btn = gr.Button("Next β‘οΈ", scale=1)
|
| 204 |
-
|
| 205 |
-
# Save results button - using DownloadButton for Hugging Face compatibility
|
| 206 |
-
with gr.Row():
|
| 207 |
-
save_results_btn = gr.DownloadButton("πΎ Download Results (CSV)", variant="primary", scale=2)
|
| 208 |
-
clear_session_btn = gr.Button("ποΈ Clear Session", scale=1)
|
| 209 |
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
# Summary card
|
| 218 |
-
summary_card = VerificationUIComponents.create_summary_card_component()
|
| 219 |
-
|
| 220 |
-
# Chaplain Feedback Section - for displaying classification flows and collecting feedback
|
| 221 |
-
chaplain_feedback_section = gr.Row(visible=False)
|
| 222 |
-
with chaplain_feedback_section:
|
| 223 |
-
with gr.Column(scale=2):
|
| 224 |
-
# Classification flow display
|
| 225 |
-
flow_badge, flow_explanation, flow_content, flow_indicators = ChaplainFeedbackUIComponents.create_classification_flow_display()
|
| 226 |
-
|
| 227 |
-
# Tagging interface - returns individual components
|
| 228 |
-
(is_correct, subcategory, correct_classification,
|
| 229 |
-
question_issues, question_comments,
|
| 230 |
-
referral_issues, referral_comments,
|
| 231 |
-
indicator_issues, indicator_comments, general_notes) = ChaplainFeedbackUIComponents.create_tagging_interface()
|
| 232 |
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
|
|
|
| 237 |
|
| 238 |
-
with
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 251 |
|
| 252 |
-
with gr.
|
| 253 |
-
|
| 254 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 255 |
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 273 |
|
| 274 |
# Chat tab
|
| 275 |
with gr.TabItem("π¬ Chat", id="chat"):
|
|
|
|
| 154 |
dataset editing, manual input testing, and batch file uploads.
|
| 155 |
</div>
|
| 156 |
""")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 157 |
|
| 158 |
+
gr.Markdown("# β Verify Classifier Accuracy")
|
| 159 |
+
gr.Markdown("Review classified messages and provide feedback to improve the spiritual distress classifier.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 160 |
|
| 161 |
+
# Dataset selector section
|
| 162 |
+
with gr.Row():
|
| 163 |
+
with gr.Column(scale=2):
|
| 164 |
+
gr.Markdown("## π Select Dataset")
|
| 165 |
+
dataset_selector = VerificationUIComponents.create_dataset_selector_component()
|
| 166 |
+
load_dataset_btn = gr.Button("π₯ Load Dataset", variant="primary", scale=1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 167 |
|
| 168 |
+
with gr.Column(scale=1):
|
| 169 |
+
dataset_info = gr.Markdown(
|
| 170 |
+
value="Select a dataset to begin verification",
|
| 171 |
+
label="Dataset Info"
|
| 172 |
+
)
|
| 173 |
|
| 174 |
+
# Message review section - MUST be created outside with statement to control visibility
|
| 175 |
+
message_review_section = gr.Row(visible=False)
|
| 176 |
+
with message_review_section:
|
| 177 |
+
with gr.Column(scale=2):
|
| 178 |
+
# Progress display
|
| 179 |
+
progress_display = VerificationUIComponents.create_progress_display()
|
| 180 |
+
|
| 181 |
+
# Message review components
|
| 182 |
+
message_text, decision_badge, confidence, indicators = VerificationUIComponents.create_message_review_component()
|
| 183 |
+
|
| 184 |
+
# Feedback buttons
|
| 185 |
+
with gr.Row():
|
| 186 |
+
correct_btn, incorrect_btn = VerificationUIComponents.create_feedback_buttons()
|
| 187 |
+
|
| 188 |
+
# Correction selector (initially hidden)
|
| 189 |
+
correction_section = gr.Row(visible=False)
|
| 190 |
+
with correction_section:
|
| 191 |
+
correction_selector, notes_field = VerificationUIComponents.create_correction_selector()
|
| 192 |
+
|
| 193 |
+
# Submit correction button
|
| 194 |
+
submit_correction_row = gr.Row(visible=False)
|
| 195 |
+
with submit_correction_row:
|
| 196 |
+
submit_correction_btn = gr.Button("β Submit Correction", variant="primary", scale=2)
|
| 197 |
+
cancel_correction_btn = gr.Button("β Cancel", scale=1)
|
| 198 |
+
|
| 199 |
+
# Navigation buttons
|
| 200 |
+
with gr.Row():
|
| 201 |
+
prev_btn = gr.Button("β¬
οΈ Previous", scale=1)
|
| 202 |
+
skip_btn = gr.Button("βοΈ Skip", scale=1)
|
| 203 |
+
next_btn = gr.Button("Next β‘οΈ", scale=1)
|
| 204 |
+
|
| 205 |
+
# Save results button - using DownloadButton for Hugging Face compatibility
|
| 206 |
+
with gr.Row():
|
| 207 |
+
save_results_btn = gr.DownloadButton("πΎ Download Results (CSV)", variant="primary", scale=2)
|
| 208 |
+
clear_session_btn = gr.Button("ποΈ Clear Session", scale=1)
|
| 209 |
|
| 210 |
+
with gr.Column(scale=1):
|
| 211 |
+
# Statistics panel
|
| 212 |
+
correct_count_display, incorrect_count_display, accuracy_display = VerificationUIComponents.create_statistics_panel()
|
| 213 |
+
|
| 214 |
+
# Breakdown by type
|
| 215 |
+
breakdown_display = VerificationUIComponents.create_breakdown_by_type_component()
|
| 216 |
+
|
| 217 |
+
# Summary card
|
| 218 |
+
summary_card = VerificationUIComponents.create_summary_card_component()
|
| 219 |
+
|
| 220 |
+
# Chaplain Feedback Section - for displaying classification flows and collecting feedback
|
| 221 |
+
chaplain_feedback_section = gr.Row(visible=False)
|
| 222 |
+
with chaplain_feedback_section:
|
| 223 |
+
with gr.Column(scale=2):
|
| 224 |
+
# Classification flow display
|
| 225 |
+
flow_badge, flow_explanation, flow_content, flow_indicators = ChaplainFeedbackUIComponents.create_classification_flow_display()
|
| 226 |
+
|
| 227 |
+
# Tagging interface - returns individual components
|
| 228 |
+
(is_correct, subcategory, correct_classification,
|
| 229 |
+
question_issues, question_comments,
|
| 230 |
+
referral_issues, referral_comments,
|
| 231 |
+
indicator_issues, indicator_comments, general_notes) = ChaplainFeedbackUIComponents.create_tagging_interface()
|
| 232 |
+
|
| 233 |
+
# Submit feedback button
|
| 234 |
+
with gr.Row():
|
| 235 |
+
submit_feedback_btn = gr.Button("β Submit Feedback", variant="primary", scale=2)
|
| 236 |
+
skip_feedback_btn = gr.Button("βοΈ Skip Feedback", scale=1)
|
| 237 |
|
| 238 |
+
with gr.Column(scale=1):
|
| 239 |
+
# Error pattern summary
|
| 240 |
+
error_patterns, subcategory_breakdown, recommendations = ChaplainFeedbackUIComponents.create_error_pattern_summary()
|
| 241 |
+
|
| 242 |
+
# Results section
|
| 243 |
+
with gr.Row(visible=False) as results_section:
|
| 244 |
+
with gr.Column():
|
| 245 |
+
gr.Markdown("## π Verification Complete")
|
| 246 |
+
|
| 247 |
+
results_summary = gr.Markdown(
|
| 248 |
+
value="Session summary will appear here",
|
| 249 |
+
label="Results Summary"
|
| 250 |
+
)
|
| 251 |
+
|
| 252 |
+
with gr.Row():
|
| 253 |
+
download_csv_btn = gr.Button("π₯ Download Results (CSV)", variant="primary", scale=2)
|
| 254 |
+
new_dataset_btn = gr.Button("π Load Another Dataset", scale=1)
|
| 255 |
+
|
| 256 |
+
csv_download = gr.File(
|
| 257 |
+
label="CSV Download",
|
| 258 |
+
visible=False
|
| 259 |
+
)
|
| 260 |
+
|
| 261 |
+
# Error message display
|
| 262 |
+
error_message = gr.Markdown(
|
| 263 |
+
value="",
|
| 264 |
+
visible=True,
|
| 265 |
+
label="Status"
|
| 266 |
+
)
|
| 267 |
+
|
| 268 |
+
# Hidden state for tracking
|
| 269 |
+
current_message_index = gr.State(value=0)
|
| 270 |
+
current_dataset_id = gr.State(value=None)
|
| 271 |
+
message_queue = gr.State(value=[])
|
| 272 |
+
verification_records = gr.State(value=[])
|
| 273 |
|
| 274 |
# Chat tab
|
| 275 |
with gr.TabItem("π¬ Chat", id="chat"):
|