Spaces:
Build error
Build error
File size: 678 Bytes
908351f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
from transformers import StoppingCriteria
import sys
# Handle termination signal
def signal_handler(sig, frame):
print("\nTermination signal received. Shutting down Gradio interface.")
sys.exit(0)
# Custom stopping criteria
class StopOnTokens(StoppingCriteria):
def __call__(self, input_ids, scores, **kwargs):
stop_ids = [29, 0] # Define specific stop token IDs
return input_ids[0][-1] in stop_ids
# Toggle task selection
def toggle_selection(current_task, new_task):
"""Toggle task selection: deselect if clicked again, otherwise update selection."""
updated_task = "" if current_task == new_task else new_task
return updated_task
|