mirror of
https://github.com/gradio-app/gradio.git
synced 2025-02-11 11:19:58 +08:00
* multimodal chatbot * notebook * fix tests * Update demo/chatbot_multimodal/run.py Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * fix notebook * changelog * Update CHANGELOG.md * Update gradio/components.py * Update gradio/components.py * Update gradio/components.py * fixing security issue * updating demo * formatting * demo notebooks * changes * typing * changes * changes * changes * add test * fixes * renaming demos * fixed demo * fixes * fix demos * chatbot --------- Co-authored-by: Abubakar Abid <abubakar@huggingface.co> Co-authored-by: Ali Abid <aabid94@gmail.com>
26 lines
613 B
Python
26 lines
613 B
Python
import gradio as gr
|
|
import random
|
|
import time
|
|
|
|
with gr.Blocks() as demo:
|
|
chatbot = gr.Chatbot()
|
|
msg = gr.Textbox()
|
|
clear = gr.Button("Clear")
|
|
|
|
def user(user_message, history):
|
|
return "", history + [[user_message, None]]
|
|
|
|
def bot(history):
|
|
bot_message = random.choice(["Yes", "No"])
|
|
history[-1][1] = bot_message
|
|
time.sleep(1)
|
|
return history
|
|
|
|
msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
|
|
bot, chatbot, chatbot
|
|
)
|
|
clear.click(lambda: None, None, chatbot, queue=False)
|
|
|
|
if __name__ == "__main__":
|
|
demo.launch()
|