I want the characters of the answer to appear gradually, not to receive the whole answer at once. I tried my code below and several variations but didn’t work
import gradio as gr
def user(user_message, history):
return gradio.Interface.update_input(value="", interactive=False), history + [[user_message, None]]
def bot(history):
bot_message = random.choice(["How are you?", "I love you", "I'm very hungry"])
history[-1][1] = "" # Reset the bot's message
for character in bot_message:
history[-1][1] += character
time.sleep(0.05)
yield history
time.sleep(0.2) # Add a pause between characters
iface = gr.Interface(fn=user, inputs="text", outputs="text", css=css, interface_size=(100, 200))
iface.queue().launch()```