Spaces:
Running
Running
refactor: reorganize verification modes and add Edit Enhanced Datasets tab
Browse files- Add new 'Edit Enhanced Datasets' tab to main menu for dataset management
- Replace 'Enhanced Datasets' mode with 'Standard Verification' in Enhanced Verification
- Create standalone dataset_editor_interface.py for dataset editing functionality
- Remove dataset editing from Enhanced Verification (now in separate tab)
- Update mode selection to show: Standard Verification, Manual Input, File Upload
- Clean up unused event handlers and references
src/interface/dataset_editor_interface.py
ADDED
|
@@ -0,0 +1,370 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# dataset_editor_interface.py
|
| 2 |
+
"""
|
| 3 |
+
Dataset Editor Interface for Enhanced Datasets.
|
| 4 |
+
|
| 5 |
+
Provides a standalone interface for editing test datasets with full CRUD operations.
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
import gradio as gr
|
| 9 |
+
from typing import List, Dict, Tuple, Optional, Any
|
| 10 |
+
from datetime import datetime
|
| 11 |
+
import uuid
|
| 12 |
+
|
| 13 |
+
from src.core.verification_models import TestMessage, TestDataset
|
| 14 |
+
from src.interface.enhanced_dataset_interface import EnhancedDatasetInterfaceController
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
def create_dataset_editor_interface() -> gr.Blocks:
|
| 18 |
+
"""
|
| 19 |
+
Create the dataset editor interface.
|
| 20 |
+
|
| 21 |
+
Returns:
|
| 22 |
+
Gradio Blocks component for dataset editing
|
| 23 |
+
"""
|
| 24 |
+
with gr.Blocks(title="Edit Enhanced Datasets") as interface:
|
| 25 |
+
# Initialize controller
|
| 26 |
+
dataset_controller = EnhancedDatasetInterfaceController()
|
| 27 |
+
|
| 28 |
+
# Pre-load dataset choices for initialization
|
| 29 |
+
try:
|
| 30 |
+
initial_choices, _, _, _ = dataset_controller.initialize_interface()
|
| 31 |
+
except Exception:
|
| 32 |
+
initial_choices = []
|
| 33 |
+
|
| 34 |
+
# Application state
|
| 35 |
+
current_dataset_state = gr.State(value=None)
|
| 36 |
+
editing_dataset_state = gr.State(value=None)
|
| 37 |
+
|
| 38 |
+
# Header
|
| 39 |
+
gr.Markdown("# ✏️ Edit Enhanced Datasets")
|
| 40 |
+
gr.Markdown("Manage and customize test datasets for verification. Add, modify, or delete test cases to create datasets tailored to your testing needs.")
|
| 41 |
+
|
| 42 |
+
# Dataset selection interface
|
| 43 |
+
with gr.Row():
|
| 44 |
+
with gr.Column(scale=2):
|
| 45 |
+
gr.Markdown("## 📋 Select Dataset")
|
| 46 |
+
|
| 47 |
+
dataset_selector = gr.Dropdown(
|
| 48 |
+
choices=initial_choices,
|
| 49 |
+
value=initial_choices[0] if initial_choices else None,
|
| 50 |
+
label="Available Datasets",
|
| 51 |
+
info="Choose a dataset to edit",
|
| 52 |
+
interactive=True
|
| 53 |
+
)
|
| 54 |
+
|
| 55 |
+
with gr.Row():
|
| 56 |
+
edit_dataset_btn = gr.Button("✏️ Edit Dataset", variant="primary", scale=2)
|
| 57 |
+
create_dataset_btn = gr.Button("➕ Create New Dataset", variant="secondary", scale=1)
|
| 58 |
+
|
| 59 |
+
with gr.Column(scale=1):
|
| 60 |
+
gr.Markdown("## 📊 Dataset Information")
|
| 61 |
+
dataset_info_display = gr.Markdown(
|
| 62 |
+
"Select a dataset to view details",
|
| 63 |
+
label="Dataset Details"
|
| 64 |
+
)
|
| 65 |
+
|
| 66 |
+
# Create new dataset section (initially hidden)
|
| 67 |
+
create_section = gr.Row(visible=False)
|
| 68 |
+
with create_section:
|
| 69 |
+
with gr.Column():
|
| 70 |
+
gr.Markdown("## ➕ Create New Dataset")
|
| 71 |
+
|
| 72 |
+
with gr.Row():
|
| 73 |
+
with gr.Column(scale=2):
|
| 74 |
+
new_dataset_name = gr.Textbox(
|
| 75 |
+
label="Dataset Name",
|
| 76 |
+
placeholder="Enter dataset name...",
|
| 77 |
+
interactive=True
|
| 78 |
+
)
|
| 79 |
+
with gr.Column(scale=2):
|
| 80 |
+
new_dataset_description = gr.Textbox(
|
| 81 |
+
label="Description",
|
| 82 |
+
placeholder="Describe the dataset purpose...",
|
| 83 |
+
interactive=True
|
| 84 |
+
)
|
| 85 |
+
with gr.Column(scale=1):
|
| 86 |
+
template_selector = gr.Dropdown(
|
| 87 |
+
choices=["", "empty", "mixed_sample"],
|
| 88 |
+
label="Template",
|
| 89 |
+
value="",
|
| 90 |
+
info="Optional template"
|
| 91 |
+
)
|
| 92 |
+
|
| 93 |
+
with gr.Row():
|
| 94 |
+
create_confirm_btn = gr.Button("✅ Create Dataset", variant="primary")
|
| 95 |
+
create_cancel_btn = gr.Button("❌ Cancel", variant="secondary")
|
| 96 |
+
|
| 97 |
+
# Edit Dataset interface (initially hidden)
|
| 98 |
+
edit_section = gr.Row(visible=False)
|
| 99 |
+
with edit_section:
|
| 100 |
+
with gr.Column():
|
| 101 |
+
gr.Markdown("## ✏️ Edit Dataset")
|
| 102 |
+
|
| 103 |
+
# Dataset actions
|
| 104 |
+
with gr.Row():
|
| 105 |
+
save_dataset_btn = gr.Button("💾 Save Changes", variant="primary")
|
| 106 |
+
close_edit_btn = gr.Button("✖️ Close Editor", variant="secondary")
|
| 107 |
+
|
| 108 |
+
# Test cases display
|
| 109 |
+
test_cases_display = gr.HTML(
|
| 110 |
+
value="<p>Loading test cases...</p>",
|
| 111 |
+
label="Test Cases"
|
| 112 |
+
)
|
| 113 |
+
|
| 114 |
+
gr.Markdown("### ➕ Add New Test Case")
|
| 115 |
+
with gr.Row():
|
| 116 |
+
with gr.Column(scale=3):
|
| 117 |
+
new_message_text = gr.Textbox(
|
| 118 |
+
label="Message Text",
|
| 119 |
+
placeholder="Enter the test message...",
|
| 120 |
+
lines=3,
|
| 121 |
+
interactive=True
|
| 122 |
+
)
|
| 123 |
+
with gr.Column(scale=1):
|
| 124 |
+
new_message_classification = gr.Radio(
|
| 125 |
+
choices=["green", "yellow", "red"],
|
| 126 |
+
label="Expected Classification",
|
| 127 |
+
value="yellow"
|
| 128 |
+
)
|
| 129 |
+
|
| 130 |
+
with gr.Row():
|
| 131 |
+
add_test_case_btn = gr.Button("➕ Add Test Case", variant="primary")
|
| 132 |
+
clear_form_btn = gr.Button("🗑️ Clear Form", variant="secondary")
|
| 133 |
+
|
| 134 |
+
# Status message
|
| 135 |
+
status_message = gr.Markdown("", visible=True)
|
| 136 |
+
|
| 137 |
+
# Event handlers
|
| 138 |
+
def on_dataset_selection_change(dataset_selection):
|
| 139 |
+
"""Handle dataset selection change."""
|
| 140 |
+
try:
|
| 141 |
+
dataset_info, dataset_obj = dataset_controller.get_dataset_info(dataset_selection)
|
| 142 |
+
return (
|
| 143 |
+
dataset_info, # dataset_info_display
|
| 144 |
+
dataset_obj # current_dataset_state
|
| 145 |
+
)
|
| 146 |
+
except Exception as e:
|
| 147 |
+
return (
|
| 148 |
+
f"❌ Error loading dataset info: {str(e)}", # dataset_info_display
|
| 149 |
+
None # current_dataset_state
|
| 150 |
+
)
|
| 151 |
+
|
| 152 |
+
def on_edit_dataset(current_dataset):
|
| 153 |
+
"""Handle edit dataset button."""
|
| 154 |
+
try:
|
| 155 |
+
if not current_dataset:
|
| 156 |
+
return (
|
| 157 |
+
gr.Row(visible=False), # edit_section
|
| 158 |
+
"", # test_cases_display
|
| 159 |
+
current_dataset, # editing_dataset_state
|
| 160 |
+
"❌ No dataset selected for editing" # status_message
|
| 161 |
+
)
|
| 162 |
+
|
| 163 |
+
# Render test cases HTML
|
| 164 |
+
test_cases_html = dataset_controller.render_test_cases_display(current_dataset)
|
| 165 |
+
|
| 166 |
+
return (
|
| 167 |
+
gr.Row(visible=True), # edit_section
|
| 168 |
+
test_cases_html, # test_cases_display
|
| 169 |
+
current_dataset, # editing_dataset_state
|
| 170 |
+
f"✏️ Editing dataset: '{current_dataset.name}'" # status_message
|
| 171 |
+
)
|
| 172 |
+
except Exception as e:
|
| 173 |
+
return (
|
| 174 |
+
gr.Row(visible=False), # edit_section
|
| 175 |
+
"", # test_cases_display
|
| 176 |
+
None, # editing_dataset_state
|
| 177 |
+
f"❌ Error accessing dataset for editing: {str(e)}" # status_message
|
| 178 |
+
)
|
| 179 |
+
|
| 180 |
+
def on_close_edit():
|
| 181 |
+
"""Close the edit section."""
|
| 182 |
+
return (
|
| 183 |
+
gr.Row(visible=False), # edit_section
|
| 184 |
+
"", # new_message_text (clear)
|
| 185 |
+
"yellow", # new_message_classification (reset)
|
| 186 |
+
"✅ Editor closed" # status_message
|
| 187 |
+
)
|
| 188 |
+
|
| 189 |
+
def on_show_create():
|
| 190 |
+
"""Show create dataset section."""
|
| 191 |
+
return (
|
| 192 |
+
gr.Row(visible=True), # create_section
|
| 193 |
+
"➕ Create a new dataset" # status_message
|
| 194 |
+
)
|
| 195 |
+
|
| 196 |
+
def on_cancel_create():
|
| 197 |
+
"""Cancel create dataset."""
|
| 198 |
+
return (
|
| 199 |
+
gr.Row(visible=False), # create_section
|
| 200 |
+
"", # new_dataset_name (clear)
|
| 201 |
+
"", # new_dataset_description (clear)
|
| 202 |
+
"", # template_selector (reset)
|
| 203 |
+
"❌ Dataset creation cancelled" # status_message
|
| 204 |
+
)
|
| 205 |
+
|
| 206 |
+
def on_create_dataset(name, description, template):
|
| 207 |
+
"""Create a new dataset."""
|
| 208 |
+
try:
|
| 209 |
+
success, message, new_dataset = dataset_controller.create_new_dataset(
|
| 210 |
+
name, description, template if template else None
|
| 211 |
+
)
|
| 212 |
+
|
| 213 |
+
if success:
|
| 214 |
+
# Refresh dataset choices
|
| 215 |
+
updated_choices, _, _, _ = dataset_controller.initialize_interface()
|
| 216 |
+
|
| 217 |
+
return (
|
| 218 |
+
gr.Row(visible=False), # create_section
|
| 219 |
+
gr.update(choices=updated_choices, value=f"{new_dataset.name} ({new_dataset.message_count} messages)"), # dataset_selector
|
| 220 |
+
"", # new_dataset_name (clear)
|
| 221 |
+
"", # new_dataset_description (clear)
|
| 222 |
+
"", # template_selector (reset)
|
| 223 |
+
new_dataset, # current_dataset_state
|
| 224 |
+
message # status_message
|
| 225 |
+
)
|
| 226 |
+
else:
|
| 227 |
+
return (
|
| 228 |
+
gr.Row(visible=True), # create_section (keep visible)
|
| 229 |
+
gr.update(), # dataset_selector (no change)
|
| 230 |
+
name, # new_dataset_name (keep)
|
| 231 |
+
description, # new_dataset_description (keep)
|
| 232 |
+
template, # template_selector (keep)
|
| 233 |
+
None, # current_dataset_state
|
| 234 |
+
message # status_message
|
| 235 |
+
)
|
| 236 |
+
except Exception as e:
|
| 237 |
+
return (
|
| 238 |
+
gr.Row(visible=True), # create_section (keep visible)
|
| 239 |
+
gr.update(), # dataset_selector (no change)
|
| 240 |
+
name, # new_dataset_name (keep)
|
| 241 |
+
description, # new_dataset_description (keep)
|
| 242 |
+
template, # template_selector (keep)
|
| 243 |
+
None, # current_dataset_state
|
| 244 |
+
f"❌ Error creating dataset: {str(e)}" # status_message
|
| 245 |
+
)
|
| 246 |
+
|
| 247 |
+
def on_add_test_case(editing_dataset, message_text, classification):
|
| 248 |
+
"""Add a new test case to the dataset."""
|
| 249 |
+
try:
|
| 250 |
+
if not editing_dataset:
|
| 251 |
+
return (
|
| 252 |
+
"", # test_cases_display
|
| 253 |
+
editing_dataset, # editing_dataset_state
|
| 254 |
+
message_text, # new_message_text (keep)
|
| 255 |
+
classification, # new_message_classification (keep)
|
| 256 |
+
"❌ No dataset being edited" # status_message
|
| 257 |
+
)
|
| 258 |
+
|
| 259 |
+
if not message_text or not message_text.strip():
|
| 260 |
+
return (
|
| 261 |
+
dataset_controller.render_test_cases_display(editing_dataset), # test_cases_display
|
| 262 |
+
editing_dataset, # editing_dataset_state
|
| 263 |
+
message_text, # new_message_text (keep)
|
| 264 |
+
classification, # new_message_classification (keep)
|
| 265 |
+
"❌ Message text is required" # status_message
|
| 266 |
+
)
|
| 267 |
+
|
| 268 |
+
# Add test case
|
| 269 |
+
success, message, updated_dataset = dataset_controller.add_test_case(
|
| 270 |
+
editing_dataset, message_text.strip(), classification
|
| 271 |
+
)
|
| 272 |
+
|
| 273 |
+
if success:
|
| 274 |
+
# Render updated test cases
|
| 275 |
+
test_cases_html = dataset_controller.render_test_cases_display(updated_dataset)
|
| 276 |
+
return (
|
| 277 |
+
test_cases_html, # test_cases_display
|
| 278 |
+
updated_dataset, # editing_dataset_state
|
| 279 |
+
"", # new_message_text (clear)
|
| 280 |
+
"yellow", # new_message_classification (reset)
|
| 281 |
+
message # status_message
|
| 282 |
+
)
|
| 283 |
+
else:
|
| 284 |
+
return (
|
| 285 |
+
dataset_controller.render_test_cases_display(editing_dataset), # test_cases_display
|
| 286 |
+
editing_dataset, # editing_dataset_state
|
| 287 |
+
message_text, # new_message_text (keep)
|
| 288 |
+
classification, # new_message_classification (keep)
|
| 289 |
+
message # status_message
|
| 290 |
+
)
|
| 291 |
+
except Exception as e:
|
| 292 |
+
return (
|
| 293 |
+
"", # test_cases_display
|
| 294 |
+
editing_dataset, # editing_dataset_state
|
| 295 |
+
message_text, # new_message_text (keep)
|
| 296 |
+
classification, # new_message_classification (keep)
|
| 297 |
+
f"❌ Error adding test case: {str(e)}" # status_message
|
| 298 |
+
)
|
| 299 |
+
|
| 300 |
+
def on_clear_form():
|
| 301 |
+
"""Clear the add test case form."""
|
| 302 |
+
return (
|
| 303 |
+
"", # new_message_text
|
| 304 |
+
"yellow", # new_message_classification
|
| 305 |
+
"🗑️ Form cleared" # status_message
|
| 306 |
+
)
|
| 307 |
+
|
| 308 |
+
def on_save_dataset(editing_dataset):
|
| 309 |
+
"""Save the current dataset."""
|
| 310 |
+
try:
|
| 311 |
+
if not editing_dataset:
|
| 312 |
+
return "❌ No dataset being edited"
|
| 313 |
+
|
| 314 |
+
success, message = dataset_controller.save_dataset(editing_dataset)
|
| 315 |
+
return message
|
| 316 |
+
except Exception as e:
|
| 317 |
+
return f"❌ Error saving dataset: {str(e)}"
|
| 318 |
+
|
| 319 |
+
# Bind event handlers
|
| 320 |
+
dataset_selector.change(
|
| 321 |
+
on_dataset_selection_change,
|
| 322 |
+
inputs=[dataset_selector],
|
| 323 |
+
outputs=[dataset_info_display, current_dataset_state]
|
| 324 |
+
)
|
| 325 |
+
|
| 326 |
+
edit_dataset_btn.click(
|
| 327 |
+
on_edit_dataset,
|
| 328 |
+
inputs=[current_dataset_state],
|
| 329 |
+
outputs=[edit_section, test_cases_display, editing_dataset_state, status_message]
|
| 330 |
+
)
|
| 331 |
+
|
| 332 |
+
create_dataset_btn.click(
|
| 333 |
+
on_show_create,
|
| 334 |
+
outputs=[create_section, status_message]
|
| 335 |
+
)
|
| 336 |
+
|
| 337 |
+
create_cancel_btn.click(
|
| 338 |
+
on_cancel_create,
|
| 339 |
+
outputs=[create_section, new_dataset_name, new_dataset_description, template_selector, status_message]
|
| 340 |
+
)
|
| 341 |
+
|
| 342 |
+
create_confirm_btn.click(
|
| 343 |
+
on_create_dataset,
|
| 344 |
+
inputs=[new_dataset_name, new_dataset_description, template_selector],
|
| 345 |
+
outputs=[create_section, dataset_selector, new_dataset_name, new_dataset_description, template_selector, current_dataset_state, status_message]
|
| 346 |
+
)
|
| 347 |
+
|
| 348 |
+
close_edit_btn.click(
|
| 349 |
+
on_close_edit,
|
| 350 |
+
outputs=[edit_section, new_message_text, new_message_classification, status_message]
|
| 351 |
+
)
|
| 352 |
+
|
| 353 |
+
add_test_case_btn.click(
|
| 354 |
+
on_add_test_case,
|
| 355 |
+
inputs=[editing_dataset_state, new_message_text, new_message_classification],
|
| 356 |
+
outputs=[test_cases_display, editing_dataset_state, new_message_text, new_message_classification, status_message]
|
| 357 |
+
)
|
| 358 |
+
|
| 359 |
+
clear_form_btn.click(
|
| 360 |
+
on_clear_form,
|
| 361 |
+
outputs=[new_message_text, new_message_classification, status_message]
|
| 362 |
+
)
|
| 363 |
+
|
| 364 |
+
save_dataset_btn.click(
|
| 365 |
+
on_save_dataset,
|
| 366 |
+
inputs=[editing_dataset_state],
|
| 367 |
+
outputs=[status_message]
|
| 368 |
+
)
|
| 369 |
+
|
| 370 |
+
return interface
|
src/interface/enhanced_verification_interface.py
CHANGED
|
@@ -120,18 +120,20 @@ class EnhancedVerificationInterface:
|
|
| 120 |
gr.Markdown("## 🎯 Select Verification Mode")
|
| 121 |
|
| 122 |
with gr.Row():
|
| 123 |
-
# Enhanced Dataset
|
| 124 |
with gr.Column(scale=1):
|
| 125 |
-
|
| 126 |
-
gr.Markdown(
|
| 127 |
-
gr.Markdown(mode_info["description"])
|
| 128 |
|
| 129 |
gr.Markdown("**Features:**")
|
| 130 |
-
|
| 131 |
-
|
|
|
|
|
|
|
|
|
|
| 132 |
|
| 133 |
-
|
| 134 |
-
|
| 135 |
variant="primary",
|
| 136 |
size="lg"
|
| 137 |
)
|
|
@@ -195,15 +197,16 @@ class EnhancedVerificationInterface:
|
|
| 195 |
)
|
| 196 |
|
| 197 |
# Individual mode interfaces (initially hidden)
|
| 198 |
-
|
| 199 |
-
|
|
|
|
| 200 |
with gr.Column():
|
| 201 |
-
gr.Markdown("#
|
| 202 |
-
gr.Markdown("
|
| 203 |
-
|
| 204 |
gr.Markdown("---")
|
| 205 |
|
| 206 |
-
# Create dataset interface components
|
| 207 |
from src.interface.enhanced_dataset_interface import EnhancedDatasetInterfaceController
|
| 208 |
dataset_controller = EnhancedDatasetInterfaceController()
|
| 209 |
|
|
@@ -216,19 +219,17 @@ class EnhancedVerificationInterface:
|
|
| 216 |
# Dataset selection interface
|
| 217 |
with gr.Row():
|
| 218 |
with gr.Column(scale=2):
|
| 219 |
-
gr.Markdown("##
|
| 220 |
|
| 221 |
dataset_selector = gr.Dropdown(
|
| 222 |
choices=initial_choices,
|
| 223 |
value=initial_choices[0] if initial_choices else None,
|
| 224 |
label="Available Datasets",
|
| 225 |
-
info="Choose a dataset to verify
|
| 226 |
interactive=True
|
| 227 |
)
|
| 228 |
|
| 229 |
-
|
| 230 |
-
load_dataset_btn = gr.Button("📥 Load Dataset", variant="primary", scale=2)
|
| 231 |
-
edit_dataset_btn = gr.Button("✏️ Edit Dataset", variant="secondary", scale=1)
|
| 232 |
|
| 233 |
with gr.Column(scale=1):
|
| 234 |
gr.Markdown("## 📊 Dataset Information")
|
|
@@ -265,45 +266,12 @@ class EnhancedVerificationInterface:
|
|
| 265 |
label="Progress"
|
| 266 |
)
|
| 267 |
|
| 268 |
-
# Edit Dataset interface (initially hidden)
|
| 269 |
-
edit_section = gr.Row(visible=False)
|
| 270 |
-
with edit_section:
|
| 271 |
-
with gr.Column():
|
| 272 |
-
gr.Markdown("## ✏️ Edit Dataset")
|
| 273 |
-
|
| 274 |
-
# Test cases display
|
| 275 |
-
test_cases_display = gr.HTML(
|
| 276 |
-
value="<p>Loading test cases...</p>",
|
| 277 |
-
label="Test Cases"
|
| 278 |
-
)
|
| 279 |
-
|
| 280 |
-
gr.Markdown("### ➕ Add New Test Case")
|
| 281 |
-
with gr.Row():
|
| 282 |
-
with gr.Column(scale=3):
|
| 283 |
-
new_message_text = gr.Textbox(
|
| 284 |
-
label="Message Text",
|
| 285 |
-
placeholder="Enter the test message...",
|
| 286 |
-
lines=3,
|
| 287 |
-
interactive=True
|
| 288 |
-
)
|
| 289 |
-
with gr.Column(scale=1):
|
| 290 |
-
new_message_classification = gr.Radio(
|
| 291 |
-
choices=["green", "yellow", "red"],
|
| 292 |
-
label="Expected Classification",
|
| 293 |
-
value="yellow"
|
| 294 |
-
)
|
| 295 |
-
|
| 296 |
-
with gr.Row():
|
| 297 |
-
add_test_case_btn = gr.Button("➕ Add Test Case", variant="primary")
|
| 298 |
-
close_edit_btn = gr.Button("✖️ Close Editor", variant="secondary")
|
| 299 |
-
|
| 300 |
# Status message for dataset interface
|
| 301 |
dataset_status_message = gr.Markdown("", visible=True)
|
| 302 |
|
| 303 |
# Dataset state
|
| 304 |
current_dataset_state = gr.State(value=None)
|
| 305 |
verification_session_state = gr.State(value=None)
|
| 306 |
-
editing_dataset_state = gr.State(value=None)
|
| 307 |
|
| 308 |
manual_input_interface = gr.Row(visible=False)
|
| 309 |
with manual_input_interface:
|
|
@@ -418,20 +386,25 @@ class EnhancedVerificationInterface:
|
|
| 418 |
|
| 419 |
# Update interface visibility
|
| 420 |
mode_selection_visible = mode_type is None
|
| 421 |
-
|
| 422 |
manual_input_visible = mode_type == "manual_input"
|
| 423 |
file_upload_visible = mode_type == "file_upload"
|
| 424 |
|
| 425 |
# Create status message
|
| 426 |
if mode_type:
|
| 427 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 428 |
status_msg = f"✅ Switched to {mode_title} mode"
|
| 429 |
else:
|
| 430 |
status_msg = "✅ Returned to mode selection"
|
| 431 |
|
| 432 |
return (
|
| 433 |
gr.Row(visible=mode_selection_visible), # Mode selection section
|
| 434 |
-
gr.Row(visible=
|
| 435 |
gr.Row(visible=manual_input_visible), # Manual input interface
|
| 436 |
gr.Row(visible=file_upload_visible), # File upload interface
|
| 437 |
gr.Row(visible=False), # Hide confirmation dialog
|
|
@@ -445,7 +418,7 @@ class EnhancedVerificationInterface:
|
|
| 445 |
except Exception as e:
|
| 446 |
return (
|
| 447 |
gr.Row(visible=True), # Show mode selection on error
|
| 448 |
-
gr.Row(visible=False), # Hide
|
| 449 |
gr.Row(visible=False), # Hide manual input
|
| 450 |
gr.Row(visible=False), # Hide file upload
|
| 451 |
gr.Row(visible=False), # Hide confirmation dialog
|
|
@@ -523,25 +496,30 @@ class EnhancedVerificationInterface:
|
|
| 523 |
def direct_mode_switch(mode_type: str):
|
| 524 |
"""Directly switch to a mode without confirmation."""
|
| 525 |
mode_selection_visible = False
|
| 526 |
-
|
| 527 |
manual_input_visible = mode_type == "manual_input"
|
| 528 |
file_upload_visible = mode_type == "file_upload"
|
| 529 |
|
| 530 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 531 |
status_msg = f"✅ Switched to {mode_title} mode"
|
| 532 |
|
| 533 |
return (
|
| 534 |
gr.Row(visible=mode_selection_visible), # mode_selection_section
|
| 535 |
-
gr.Row(visible=
|
| 536 |
gr.Row(visible=manual_input_visible), # manual_input_interface
|
| 537 |
gr.Row(visible=file_upload_visible), # file_upload_interface
|
| 538 |
mode_type, # current_mode_state
|
| 539 |
status_msg # status_message
|
| 540 |
)
|
| 541 |
|
| 542 |
-
# Special function for
|
| 543 |
-
def
|
| 544 |
-
"""Switch to
|
| 545 |
try:
|
| 546 |
# Get first dataset info for display
|
| 547 |
dataset_choices, _, _, _ = dataset_controller.initialize_interface()
|
|
@@ -554,33 +532,33 @@ class EnhancedVerificationInterface:
|
|
| 554 |
|
| 555 |
return (
|
| 556 |
gr.Row(visible=False), # mode_selection_section
|
| 557 |
-
gr.Row(visible=True), #
|
| 558 |
gr.Row(visible=False), # manual_input_interface
|
| 559 |
gr.Row(visible=False), # file_upload_interface
|
| 560 |
-
"
|
| 561 |
-
"✅ Switched to
|
| 562 |
dataset_info, # dataset_info_display
|
| 563 |
first_dataset # current_dataset_state
|
| 564 |
)
|
| 565 |
except Exception as e:
|
| 566 |
return (
|
| 567 |
gr.Row(visible=False), # mode_selection_section
|
| 568 |
-
gr.Row(visible=True), #
|
| 569 |
gr.Row(visible=False), # manual_input_interface
|
| 570 |
gr.Row(visible=False), # file_upload_interface
|
| 571 |
-
"
|
| 572 |
-
f"❌ Error initializing
|
| 573 |
"Error loading datasets", # dataset_info_display
|
| 574 |
None # current_dataset_state
|
| 575 |
)
|
| 576 |
|
| 577 |
# Bind mode selection buttons
|
| 578 |
-
|
| 579 |
-
|
| 580 |
inputs=[],
|
| 581 |
outputs=[
|
| 582 |
mode_selection_section,
|
| 583 |
-
|
| 584 |
manual_input_interface,
|
| 585 |
file_upload_interface,
|
| 586 |
current_mode_state,
|
|
@@ -595,7 +573,7 @@ class EnhancedVerificationInterface:
|
|
| 595 |
inputs=[],
|
| 596 |
outputs=[
|
| 597 |
mode_selection_section,
|
| 598 |
-
|
| 599 |
manual_input_interface,
|
| 600 |
file_upload_interface,
|
| 601 |
current_mode_state,
|
|
@@ -608,7 +586,7 @@ class EnhancedVerificationInterface:
|
|
| 608 |
inputs=[],
|
| 609 |
outputs=[
|
| 610 |
mode_selection_section,
|
| 611 |
-
|
| 612 |
manual_input_interface,
|
| 613 |
file_upload_interface,
|
| 614 |
current_mode_state,
|
|
@@ -622,7 +600,7 @@ class EnhancedVerificationInterface:
|
|
| 622 |
inputs=[pending_mode_switch_state, current_session_state],
|
| 623 |
outputs=[
|
| 624 |
mode_selection_section,
|
| 625 |
-
|
| 626 |
manual_input_interface,
|
| 627 |
file_upload_interface,
|
| 628 |
mode_switch_dialog,
|
|
@@ -639,7 +617,7 @@ class EnhancedVerificationInterface:
|
|
| 639 |
inputs=[pending_mode_switch_state, current_session_state],
|
| 640 |
outputs=[
|
| 641 |
mode_selection_section,
|
| 642 |
-
|
| 643 |
manual_input_interface,
|
| 644 |
file_upload_interface,
|
| 645 |
mode_switch_dialog,
|
|
@@ -671,7 +649,7 @@ class EnhancedVerificationInterface:
|
|
| 671 |
"""Return to mode selection screen."""
|
| 672 |
return (
|
| 673 |
gr.Row(visible=True), # mode_selection_section
|
| 674 |
-
gr.Row(visible=False), #
|
| 675 |
gr.Row(visible=False), # manual_input_interface
|
| 676 |
gr.Row(visible=False), # file_upload_interface
|
| 677 |
None, # current_mode_state
|
|
@@ -679,11 +657,11 @@ class EnhancedVerificationInterface:
|
|
| 679 |
)
|
| 680 |
|
| 681 |
# Bind Back buttons for each mode
|
| 682 |
-
|
| 683 |
go_back_to_mode_selection,
|
| 684 |
outputs=[
|
| 685 |
mode_selection_section,
|
| 686 |
-
|
| 687 |
manual_input_interface,
|
| 688 |
file_upload_interface,
|
| 689 |
current_mode_state,
|
|
@@ -695,7 +673,7 @@ class EnhancedVerificationInterface:
|
|
| 695 |
go_back_to_mode_selection,
|
| 696 |
outputs=[
|
| 697 |
mode_selection_section,
|
| 698 |
-
|
| 699 |
manual_input_interface,
|
| 700 |
file_upload_interface,
|
| 701 |
current_mode_state,
|
|
@@ -707,7 +685,7 @@ class EnhancedVerificationInterface:
|
|
| 707 |
go_back_to_mode_selection,
|
| 708 |
outputs=[
|
| 709 |
mode_selection_section,
|
| 710 |
-
|
| 711 |
manual_input_interface,
|
| 712 |
file_upload_interface,
|
| 713 |
current_mode_state,
|
|
@@ -771,84 +749,6 @@ class EnhancedVerificationInterface:
|
|
| 771 |
f"❌ Error loading dataset: {str(e)}" # dataset_status_message
|
| 772 |
)
|
| 773 |
|
| 774 |
-
def on_edit_dataset(current_dataset):
|
| 775 |
-
"""Handle edit dataset button."""
|
| 776 |
-
try:
|
| 777 |
-
if not current_dataset:
|
| 778 |
-
return (
|
| 779 |
-
gr.Row(visible=False), # edit_section
|
| 780 |
-
"", # test_cases_display
|
| 781 |
-
current_dataset, # editing_dataset_state
|
| 782 |
-
"❌ No dataset selected for editing" # dataset_status_message
|
| 783 |
-
)
|
| 784 |
-
|
| 785 |
-
# Render test cases HTML
|
| 786 |
-
test_cases_html = dataset_controller.render_test_cases_display(current_dataset)
|
| 787 |
-
|
| 788 |
-
return (
|
| 789 |
-
gr.Row(visible=True), # edit_section
|
| 790 |
-
test_cases_html, # test_cases_display
|
| 791 |
-
current_dataset, # editing_dataset_state
|
| 792 |
-
f"✏️ Editing dataset: '{current_dataset.name}'" # dataset_status_message
|
| 793 |
-
)
|
| 794 |
-
except Exception as e:
|
| 795 |
-
return (
|
| 796 |
-
gr.Row(visible=False), # edit_section
|
| 797 |
-
"", # test_cases_display
|
| 798 |
-
None, # editing_dataset_state
|
| 799 |
-
f"❌ Error accessing dataset for editing: {str(e)}" # dataset_status_message
|
| 800 |
-
)
|
| 801 |
-
|
| 802 |
-
def on_close_edit():
|
| 803 |
-
"""Close the edit section."""
|
| 804 |
-
return (
|
| 805 |
-
gr.Row(visible=False), # edit_section
|
| 806 |
-
"✅ Editor closed" # dataset_status_message
|
| 807 |
-
)
|
| 808 |
-
|
| 809 |
-
def on_add_test_case(editing_dataset, message_text, classification):
|
| 810 |
-
"""Add a new test case to the dataset."""
|
| 811 |
-
try:
|
| 812 |
-
if not editing_dataset:
|
| 813 |
-
return (
|
| 814 |
-
"", # test_cases_display
|
| 815 |
-
editing_dataset, # editing_dataset_state
|
| 816 |
-
"❌ No dataset being edited" # dataset_status_message
|
| 817 |
-
)
|
| 818 |
-
|
| 819 |
-
if not message_text or not message_text.strip():
|
| 820 |
-
return (
|
| 821 |
-
dataset_controller.render_test_cases_display(editing_dataset), # test_cases_display
|
| 822 |
-
editing_dataset, # editing_dataset_state
|
| 823 |
-
"❌ Message text is required" # dataset_status_message
|
| 824 |
-
)
|
| 825 |
-
|
| 826 |
-
# Add test case
|
| 827 |
-
success, message, updated_dataset = dataset_controller.add_test_case(
|
| 828 |
-
editing_dataset, message_text.strip(), classification
|
| 829 |
-
)
|
| 830 |
-
|
| 831 |
-
if success:
|
| 832 |
-
# Render updated test cases
|
| 833 |
-
test_cases_html = dataset_controller.render_test_cases_display(updated_dataset)
|
| 834 |
-
return (
|
| 835 |
-
test_cases_html, # test_cases_display
|
| 836 |
-
updated_dataset, # editing_dataset_state
|
| 837 |
-
message # dataset_status_message
|
| 838 |
-
)
|
| 839 |
-
else:
|
| 840 |
-
return (
|
| 841 |
-
dataset_controller.render_test_cases_display(editing_dataset), # test_cases_display
|
| 842 |
-
editing_dataset, # editing_dataset_state
|
| 843 |
-
message # dataset_status_message
|
| 844 |
-
)
|
| 845 |
-
except Exception as e:
|
| 846 |
-
return (
|
| 847 |
-
"", # test_cases_display
|
| 848 |
-
editing_dataset, # editing_dataset_state
|
| 849 |
-
f"❌ Error adding test case: {str(e)}" # dataset_status_message
|
| 850 |
-
)
|
| 851 |
-
|
| 852 |
def on_start_verification(current_dataset, verifier_name):
|
| 853 |
"""Handle starting verification session."""
|
| 854 |
try:
|
|
@@ -891,23 +791,6 @@ class EnhancedVerificationInterface:
|
|
| 891 |
outputs=[verification_section, dataset_status_message]
|
| 892 |
)
|
| 893 |
|
| 894 |
-
edit_dataset_btn.click(
|
| 895 |
-
on_edit_dataset,
|
| 896 |
-
inputs=[current_dataset_state],
|
| 897 |
-
outputs=[edit_section, test_cases_display, editing_dataset_state, dataset_status_message]
|
| 898 |
-
)
|
| 899 |
-
|
| 900 |
-
close_edit_btn.click(
|
| 901 |
-
on_close_edit,
|
| 902 |
-
outputs=[edit_section, dataset_status_message]
|
| 903 |
-
)
|
| 904 |
-
|
| 905 |
-
add_test_case_btn.click(
|
| 906 |
-
on_add_test_case,
|
| 907 |
-
inputs=[editing_dataset_state, new_message_text, new_message_classification],
|
| 908 |
-
outputs=[test_cases_display, editing_dataset_state, dataset_status_message]
|
| 909 |
-
)
|
| 910 |
-
|
| 911 |
start_verification_btn.click(
|
| 912 |
on_start_verification,
|
| 913 |
inputs=[current_dataset_state, verifier_name_input],
|
|
|
|
| 120 |
gr.Markdown("## 🎯 Select Verification Mode")
|
| 121 |
|
| 122 |
with gr.Row():
|
| 123 |
+
# Standard Verification Mode (replaced Enhanced Dataset)
|
| 124 |
with gr.Column(scale=1):
|
| 125 |
+
gr.Markdown("### ✓ Standard Verification")
|
| 126 |
+
gr.Markdown("Use predefined test datasets to verify classifier accuracy. Quick and straightforward verification workflow.")
|
|
|
|
| 127 |
|
| 128 |
gr.Markdown("**Features:**")
|
| 129 |
+
gr.Markdown("• Pre-classified test datasets")
|
| 130 |
+
gr.Markdown("• Step-by-step message review")
|
| 131 |
+
gr.Markdown("• Accuracy tracking and statistics")
|
| 132 |
+
gr.Markdown("• Export verification results")
|
| 133 |
+
gr.Markdown("• Session progress preservation")
|
| 134 |
|
| 135 |
+
standard_verification_btn = gr.Button(
|
| 136 |
+
"✓ Start Standard Verification",
|
| 137 |
variant="primary",
|
| 138 |
size="lg"
|
| 139 |
)
|
|
|
|
| 197 |
)
|
| 198 |
|
| 199 |
# Individual mode interfaces (initially hidden)
|
| 200 |
+
# Standard Verification interface (replaced Enhanced Dataset)
|
| 201 |
+
standard_verification_interface = gr.Row(visible=False)
|
| 202 |
+
with standard_verification_interface:
|
| 203 |
with gr.Column():
|
| 204 |
+
gr.Markdown("# ✓ Standard Verification Mode")
|
| 205 |
+
gr.Markdown("Review classified messages and provide feedback to improve the spiritual distress classifier.")
|
| 206 |
+
back_from_standard_btn = gr.Button("← Back to Mode Selection", size="sm")
|
| 207 |
gr.Markdown("---")
|
| 208 |
|
| 209 |
+
# Create dataset interface components
|
| 210 |
from src.interface.enhanced_dataset_interface import EnhancedDatasetInterfaceController
|
| 211 |
dataset_controller = EnhancedDatasetInterfaceController()
|
| 212 |
|
|
|
|
| 219 |
# Dataset selection interface
|
| 220 |
with gr.Row():
|
| 221 |
with gr.Column(scale=2):
|
| 222 |
+
gr.Markdown("## 📊 Select Dataset")
|
| 223 |
|
| 224 |
dataset_selector = gr.Dropdown(
|
| 225 |
choices=initial_choices,
|
| 226 |
value=initial_choices[0] if initial_choices else None,
|
| 227 |
label="Available Datasets",
|
| 228 |
+
info="Choose a dataset to verify",
|
| 229 |
interactive=True
|
| 230 |
)
|
| 231 |
|
| 232 |
+
load_dataset_btn = gr.Button("📥 Load Dataset", variant="primary")
|
|
|
|
|
|
|
| 233 |
|
| 234 |
with gr.Column(scale=1):
|
| 235 |
gr.Markdown("## 📊 Dataset Information")
|
|
|
|
| 266 |
label="Progress"
|
| 267 |
)
|
| 268 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 269 |
# Status message for dataset interface
|
| 270 |
dataset_status_message = gr.Markdown("", visible=True)
|
| 271 |
|
| 272 |
# Dataset state
|
| 273 |
current_dataset_state = gr.State(value=None)
|
| 274 |
verification_session_state = gr.State(value=None)
|
|
|
|
| 275 |
|
| 276 |
manual_input_interface = gr.Row(visible=False)
|
| 277 |
with manual_input_interface:
|
|
|
|
| 386 |
|
| 387 |
# Update interface visibility
|
| 388 |
mode_selection_visible = mode_type is None
|
| 389 |
+
standard_verification_visible = mode_type == "standard_verification"
|
| 390 |
manual_input_visible = mode_type == "manual_input"
|
| 391 |
file_upload_visible = mode_type == "file_upload"
|
| 392 |
|
| 393 |
# Create status message
|
| 394 |
if mode_type:
|
| 395 |
+
mode_titles = {
|
| 396 |
+
"standard_verification": "Standard Verification",
|
| 397 |
+
"manual_input": "Manual Input",
|
| 398 |
+
"file_upload": "File Upload"
|
| 399 |
+
}
|
| 400 |
+
mode_title = mode_titles.get(mode_type, 'Unknown')
|
| 401 |
status_msg = f"✅ Switched to {mode_title} mode"
|
| 402 |
else:
|
| 403 |
status_msg = "✅ Returned to mode selection"
|
| 404 |
|
| 405 |
return (
|
| 406 |
gr.Row(visible=mode_selection_visible), # Mode selection section
|
| 407 |
+
gr.Row(visible=standard_verification_visible), # Standard verification interface
|
| 408 |
gr.Row(visible=manual_input_visible), # Manual input interface
|
| 409 |
gr.Row(visible=file_upload_visible), # File upload interface
|
| 410 |
gr.Row(visible=False), # Hide confirmation dialog
|
|
|
|
| 418 |
except Exception as e:
|
| 419 |
return (
|
| 420 |
gr.Row(visible=True), # Show mode selection on error
|
| 421 |
+
gr.Row(visible=False), # Hide standard verification
|
| 422 |
gr.Row(visible=False), # Hide manual input
|
| 423 |
gr.Row(visible=False), # Hide file upload
|
| 424 |
gr.Row(visible=False), # Hide confirmation dialog
|
|
|
|
| 496 |
def direct_mode_switch(mode_type: str):
|
| 497 |
"""Directly switch to a mode without confirmation."""
|
| 498 |
mode_selection_visible = False
|
| 499 |
+
standard_verification_visible = mode_type == "standard_verification"
|
| 500 |
manual_input_visible = mode_type == "manual_input"
|
| 501 |
file_upload_visible = mode_type == "file_upload"
|
| 502 |
|
| 503 |
+
mode_titles = {
|
| 504 |
+
"standard_verification": "Standard Verification",
|
| 505 |
+
"manual_input": "Manual Input",
|
| 506 |
+
"file_upload": "File Upload"
|
| 507 |
+
}
|
| 508 |
+
mode_title = mode_titles.get(mode_type, 'Unknown')
|
| 509 |
status_msg = f"✅ Switched to {mode_title} mode"
|
| 510 |
|
| 511 |
return (
|
| 512 |
gr.Row(visible=mode_selection_visible), # mode_selection_section
|
| 513 |
+
gr.Row(visible=standard_verification_visible), # standard_verification_interface
|
| 514 |
gr.Row(visible=manual_input_visible), # manual_input_interface
|
| 515 |
gr.Row(visible=file_upload_visible), # file_upload_interface
|
| 516 |
mode_type, # current_mode_state
|
| 517 |
status_msg # status_message
|
| 518 |
)
|
| 519 |
|
| 520 |
+
# Special function for standard verification mode initialization
|
| 521 |
+
def switch_to_standard_verification():
|
| 522 |
+
"""Switch to standard verification mode with proper initialization."""
|
| 523 |
try:
|
| 524 |
# Get first dataset info for display
|
| 525 |
dataset_choices, _, _, _ = dataset_controller.initialize_interface()
|
|
|
|
| 532 |
|
| 533 |
return (
|
| 534 |
gr.Row(visible=False), # mode_selection_section
|
| 535 |
+
gr.Row(visible=True), # standard_verification_interface
|
| 536 |
gr.Row(visible=False), # manual_input_interface
|
| 537 |
gr.Row(visible=False), # file_upload_interface
|
| 538 |
+
"standard_verification", # current_mode_state
|
| 539 |
+
"✅ Switched to Standard Verification mode", # status_message
|
| 540 |
dataset_info, # dataset_info_display
|
| 541 |
first_dataset # current_dataset_state
|
| 542 |
)
|
| 543 |
except Exception as e:
|
| 544 |
return (
|
| 545 |
gr.Row(visible=False), # mode_selection_section
|
| 546 |
+
gr.Row(visible=True), # standard_verification_interface
|
| 547 |
gr.Row(visible=False), # manual_input_interface
|
| 548 |
gr.Row(visible=False), # file_upload_interface
|
| 549 |
+
"standard_verification", # current_mode_state
|
| 550 |
+
f"❌ Error initializing verification mode: {str(e)}", # status_message
|
| 551 |
"Error loading datasets", # dataset_info_display
|
| 552 |
None # current_dataset_state
|
| 553 |
)
|
| 554 |
|
| 555 |
# Bind mode selection buttons
|
| 556 |
+
standard_verification_btn.click(
|
| 557 |
+
switch_to_standard_verification,
|
| 558 |
inputs=[],
|
| 559 |
outputs=[
|
| 560 |
mode_selection_section,
|
| 561 |
+
standard_verification_interface,
|
| 562 |
manual_input_interface,
|
| 563 |
file_upload_interface,
|
| 564 |
current_mode_state,
|
|
|
|
| 573 |
inputs=[],
|
| 574 |
outputs=[
|
| 575 |
mode_selection_section,
|
| 576 |
+
standard_verification_interface,
|
| 577 |
manual_input_interface,
|
| 578 |
file_upload_interface,
|
| 579 |
current_mode_state,
|
|
|
|
| 586 |
inputs=[],
|
| 587 |
outputs=[
|
| 588 |
mode_selection_section,
|
| 589 |
+
standard_verification_interface,
|
| 590 |
manual_input_interface,
|
| 591 |
file_upload_interface,
|
| 592 |
current_mode_state,
|
|
|
|
| 600 |
inputs=[pending_mode_switch_state, current_session_state],
|
| 601 |
outputs=[
|
| 602 |
mode_selection_section,
|
| 603 |
+
standard_verification_interface,
|
| 604 |
manual_input_interface,
|
| 605 |
file_upload_interface,
|
| 606 |
mode_switch_dialog,
|
|
|
|
| 617 |
inputs=[pending_mode_switch_state, current_session_state],
|
| 618 |
outputs=[
|
| 619 |
mode_selection_section,
|
| 620 |
+
standard_verification_interface,
|
| 621 |
manual_input_interface,
|
| 622 |
file_upload_interface,
|
| 623 |
mode_switch_dialog,
|
|
|
|
| 649 |
"""Return to mode selection screen."""
|
| 650 |
return (
|
| 651 |
gr.Row(visible=True), # mode_selection_section
|
| 652 |
+
gr.Row(visible=False), # standard_verification_interface
|
| 653 |
gr.Row(visible=False), # manual_input_interface
|
| 654 |
gr.Row(visible=False), # file_upload_interface
|
| 655 |
None, # current_mode_state
|
|
|
|
| 657 |
)
|
| 658 |
|
| 659 |
# Bind Back buttons for each mode
|
| 660 |
+
back_from_standard_btn.click(
|
| 661 |
go_back_to_mode_selection,
|
| 662 |
outputs=[
|
| 663 |
mode_selection_section,
|
| 664 |
+
standard_verification_interface,
|
| 665 |
manual_input_interface,
|
| 666 |
file_upload_interface,
|
| 667 |
current_mode_state,
|
|
|
|
| 673 |
go_back_to_mode_selection,
|
| 674 |
outputs=[
|
| 675 |
mode_selection_section,
|
| 676 |
+
standard_verification_interface,
|
| 677 |
manual_input_interface,
|
| 678 |
file_upload_interface,
|
| 679 |
current_mode_state,
|
|
|
|
| 685 |
go_back_to_mode_selection,
|
| 686 |
outputs=[
|
| 687 |
mode_selection_section,
|
| 688 |
+
standard_verification_interface,
|
| 689 |
manual_input_interface,
|
| 690 |
file_upload_interface,
|
| 691 |
current_mode_state,
|
|
|
|
| 749 |
f"❌ Error loading dataset: {str(e)}" # dataset_status_message
|
| 750 |
)
|
| 751 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 752 |
def on_start_verification(current_dataset, verifier_name):
|
| 753 |
"""Handle starting verification session."""
|
| 754 |
try:
|
|
|
|
| 791 |
outputs=[verification_section, dataset_status_message]
|
| 792 |
)
|
| 793 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 794 |
start_verification_btn.click(
|
| 795 |
on_start_verification,
|
| 796 |
inputs=[current_dataset_state, verifier_name_input],
|
src/interface/simplified_gradio_app.py
CHANGED
|
@@ -138,6 +138,11 @@ def create_simplified_interface():
|
|
| 138 |
""")
|
| 139 |
enhanced_verification_interface = create_enhanced_verification_tab()
|
| 140 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
# Standard Verification Mode tab (conditionally shown based on feature flag)
|
| 142 |
if is_feature_enabled("standard_verification_enabled"):
|
| 143 |
with gr.TabItem("✓ Standard Verification", id="verification"):
|
|
|
|
| 138 |
""")
|
| 139 |
enhanced_verification_interface = create_enhanced_verification_tab()
|
| 140 |
|
| 141 |
+
# Edit Enhanced Datasets tab
|
| 142 |
+
with gr.TabItem("✏️ Edit Enhanced Datasets", id="edit_datasets"):
|
| 143 |
+
from src.interface.dataset_editor_interface import create_dataset_editor_interface
|
| 144 |
+
dataset_editor_interface = create_dataset_editor_interface()
|
| 145 |
+
|
| 146 |
# Standard Verification Mode tab (conditionally shown based on feature flag)
|
| 147 |
if is_feature_enabled("standard_verification_enabled"):
|
| 148 |
with gr.TabItem("✓ Standard Verification", id="verification"):
|