Spaces:
Sleeping
Sleeping
Fix mode switching in enhanced verification interface
Browse files- Fix output mismatch in mode selection buttons (was returning 10 values, expected 6)
- Create direct_mode_switch helper function for simple mode switching
- Update all mode selection buttons to use consistent outputs
- Properly update interface visibility when switching modes
- Resolves 'A function returned too many output values' warning
src/interface/enhanced_verification_interface.py
CHANGED
|
@@ -265,7 +265,17 @@ class EnhancedVerificationInterface:
|
|
| 265 |
)
|
| 266 |
else:
|
| 267 |
# Direct switch (no progress to preserve)
|
| 268 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 269 |
|
| 270 |
except Exception as e:
|
| 271 |
return (
|
|
@@ -391,42 +401,62 @@ class EnhancedVerificationInterface:
|
|
| 391 |
]
|
| 392 |
)
|
| 393 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 394 |
# Bind mode selection buttons
|
| 395 |
enhanced_dataset_btn.click(
|
| 396 |
-
lambda
|
| 397 |
-
inputs=[
|
| 398 |
outputs=[
|
| 399 |
-
|
| 400 |
-
|
| 401 |
-
|
|
|
|
| 402 |
current_mode_state,
|
| 403 |
-
current_session_state,
|
| 404 |
status_message
|
| 405 |
]
|
| 406 |
)
|
| 407 |
|
| 408 |
manual_input_btn.click(
|
| 409 |
-
lambda
|
| 410 |
-
inputs=[
|
| 411 |
outputs=[
|
| 412 |
-
|
| 413 |
-
|
| 414 |
-
|
|
|
|
| 415 |
current_mode_state,
|
| 416 |
-
current_session_state,
|
| 417 |
status_message
|
| 418 |
]
|
| 419 |
)
|
| 420 |
|
| 421 |
file_upload_btn.click(
|
| 422 |
-
lambda
|
| 423 |
-
inputs=[
|
| 424 |
outputs=[
|
| 425 |
-
|
| 426 |
-
|
| 427 |
-
|
|
|
|
| 428 |
current_mode_state,
|
| 429 |
-
current_session_state,
|
| 430 |
status_message
|
| 431 |
]
|
| 432 |
)
|
|
|
|
| 265 |
)
|
| 266 |
else:
|
| 267 |
# Direct switch (no progress to preserve)
|
| 268 |
+
# Return only the 6 values expected by the button click handler
|
| 269 |
+
result = perform_mode_switch(mode_type, current_session_val)
|
| 270 |
+
# Extract only the values needed for the 6-output handler
|
| 271 |
+
return (
|
| 272 |
+
result[4], # mode_switch_dialog visibility
|
| 273 |
+
result[5], # switch_warning_text
|
| 274 |
+
result[6], # pending_mode_switch_state
|
| 275 |
+
result[7], # current_mode_state
|
| 276 |
+
result[8], # current_session_state
|
| 277 |
+
result[9] # status_message
|
| 278 |
+
)
|
| 279 |
|
| 280 |
except Exception as e:
|
| 281 |
return (
|
|
|
|
| 401 |
]
|
| 402 |
)
|
| 403 |
|
| 404 |
+
# Helper function for direct mode switch (no confirmation needed)
|
| 405 |
+
def direct_mode_switch(mode_type: str):
|
| 406 |
+
"""Directly switch to a mode without confirmation."""
|
| 407 |
+
mode_selection_visible = False
|
| 408 |
+
enhanced_dataset_visible = mode_type == "enhanced_dataset"
|
| 409 |
+
manual_input_visible = mode_type == "manual_input"
|
| 410 |
+
file_upload_visible = mode_type == "file_upload"
|
| 411 |
+
|
| 412 |
+
mode_title = EnhancedVerificationUIComponents.MODE_OPTIONS.get(mode_type, {}).get('title', 'Unknown')
|
| 413 |
+
status_msg = f"✅ Switched to {mode_title} mode"
|
| 414 |
+
|
| 415 |
+
return (
|
| 416 |
+
gr.Row(visible=mode_selection_visible), # mode_selection_section
|
| 417 |
+
gr.Row(visible=enhanced_dataset_visible), # enhanced_dataset_interface
|
| 418 |
+
gr.Row(visible=manual_input_visible), # manual_input_interface
|
| 419 |
+
gr.Row(visible=file_upload_visible), # file_upload_interface
|
| 420 |
+
mode_type, # current_mode_state
|
| 421 |
+
status_msg # status_message
|
| 422 |
+
)
|
| 423 |
+
|
| 424 |
# Bind mode selection buttons
|
| 425 |
enhanced_dataset_btn.click(
|
| 426 |
+
lambda: direct_mode_switch("enhanced_dataset"),
|
| 427 |
+
inputs=[],
|
| 428 |
outputs=[
|
| 429 |
+
mode_selection_section,
|
| 430 |
+
enhanced_dataset_interface,
|
| 431 |
+
manual_input_interface,
|
| 432 |
+
file_upload_interface,
|
| 433 |
current_mode_state,
|
|
|
|
| 434 |
status_message
|
| 435 |
]
|
| 436 |
)
|
| 437 |
|
| 438 |
manual_input_btn.click(
|
| 439 |
+
lambda: direct_mode_switch("manual_input"),
|
| 440 |
+
inputs=[],
|
| 441 |
outputs=[
|
| 442 |
+
mode_selection_section,
|
| 443 |
+
enhanced_dataset_interface,
|
| 444 |
+
manual_input_interface,
|
| 445 |
+
file_upload_interface,
|
| 446 |
current_mode_state,
|
|
|
|
| 447 |
status_message
|
| 448 |
]
|
| 449 |
)
|
| 450 |
|
| 451 |
file_upload_btn.click(
|
| 452 |
+
lambda: direct_mode_switch("file_upload"),
|
| 453 |
+
inputs=[],
|
| 454 |
outputs=[
|
| 455 |
+
mode_selection_section,
|
| 456 |
+
enhanced_dataset_interface,
|
| 457 |
+
manual_input_interface,
|
| 458 |
+
file_upload_interface,
|
| 459 |
current_mode_state,
|
|
|
|
| 460 |
status_message
|
| 461 |
]
|
| 462 |
)
|