Spaces:
Running
on
Zero
Running
on
Zero
File size: 1,167 Bytes
8a142a6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
import gradio as gr
from .context_processor import get_context_html
def toggle_context_display(example, current_state):
"""
Toggles between full context and highlights display.
Parameters:
- example: The current example data
- current_state: Boolean indicating if full context is already shown
Returns:
- Updated context HTML and toggle button text
"""
new_state = not current_state
# UPDATED: Changed button text based on new state
button_text = "Show Highlights" if new_state else "Show Full Context"
context_html = get_context_html(example, show_full=new_state)
# Add or remove the showing-full class to the button
elem_classes = ["context-toggle-button"]
if new_state:
elem_classes.append("showing-full")
# Return the values as list in the expected order, not as a dictionary
return new_state, gr.update(value=context_html), gr.update(value=button_text, elem_classes=elem_classes)
def update_feedback(choice):
"""Updates the feedback list state when checkbox selections change."""
# Return the value directly, not as a dictionary
return choice |