Spaces:
Running
on
Zero
Running
on
Zero
| 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 |