Spaces:
Runtime error
Runtime error
import gradio as gr | |
import random | |
import time | |
with gr.Blocks() as demo: | |
chatbot = gr.Chatbot() | |
btn = gr.Button(value="Submit") | |
btn.visible = False | |
msg = gr.Textbox() | |
clear = gr.ClearButton([msg, chatbot]) | |
def respond(message, chat_history): | |
# bot_message = random.choice(["How are you?", "I love you", "I'm very hungry"]) | |
bot_message = "Hello! Click the link below:<br><a href='https://www.baidu.com' target='_blank'>Visit Example.com</a>" | |
chat_history.append((message, bot_message)) | |
time.sleep(2) | |
print(chat_history) | |
btn.visible = True | |
gr.update(value="", interactive=True) | |
return "", chat_history,btn | |
msg.submit(respond, [msg, chatbot], [msg, chatbot]) | |
if __name__ == "__main__": | |
demo.launch() | |