File size: 542 Bytes
9de5a7b a4ba9e3 9de5a7b a4ba9e3 9de5a7b a4ba9e3 9de5a7b a4ba9e3 9de5a7b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
import time
import gradio as gr
# Define a function that streams the message back to the user one character at a time
def slow_echo(message, history):
for i in range(len(message)):
time.sleep(0.05) # Simulate a delay for each character
yield "You typed: " + message[:i + 1] # Yield the message up to the current character
# Create a Gradio ChatInterface with the slow_echo function
demo = gr.ChatInterface(slow_echo, type="messages")
# Launch the Gradio app
if __name__ == "__main__":
demo.launch(show_error=True) |