from colorama import Style, Fore import sys import gradio as gr import tty import termios def generate_progress_html(percent): return f"""
""" def get_char(): """Read a single character from standard input without echo.""" fd = sys.stdin.fileno() old_settings = termios.tcgetattr(fd) try: tty.setraw(sys.stdin.fileno()) char = sys.stdin.read(1) finally: termios.tcsetattr(fd, termios.TCSADRAIN, old_settings) return char def get_multiline_input(): """Ask the human user_input till they press Ctrl+B.""" print(Fore.BLUE + 'Enter your multiline text and press Ctrl+B when you are done:') user_input = [] current_line = [] line_num = 1 print(f"{line_num}> ", end='', flush=True) while True: char = get_char() if ord(char) == 2: # Ctrl+B break elif char == '\r' or char == '\n': # Enter key line = ''.join(current_line) user_input.append(line) current_line = [] line_num += 1 print(f"\n{line_num}> ", end='', flush=True) elif char == '\x7f': # Backspace if current_line: current_line.pop() # Move cursor back, overwrite with space, move back again print('\b \b', end='', flush=True) else: current_line.append(char) print(char, end='', flush=True) print('\n\n') return '\n'.join(user_input) def system_update(update_message): print(Style.RESET_ALL+ Fore.YELLOW + f"{update_message}") def system_sub_update(update_message): print(Style.RESET_ALL+ Fore.CYAN + f"{update_message}") def system_output(update_message): print(Style.RESET_ALL+ Fore.GREEN + + f"{update_message}") def system_error(update_message): print(Style.RESET_ALL + Fore.RED + f"{update_message}")