CoolFace
Apppublic

ysharma/dummy_chatinterface

sourceHugging Facemitupdated 3y agoView on Hugging Face
0likes
app.py28 linesDownload Raw Back to root
1import gradio as gr2import gradio as gr3import random4import time5 6CSS ="""7.contain { display: flex; flex-direction: column; }8.gradio-container { height: 100vh !important; }9#component-0 { height: 100%; }10#chat { flex-grow: 1; overflow: auto;}11"""12 13with gr.Blocks(css = CSS) as demo:14    chatbot = gr.Chatbot(elem_id='chat')15    msg = gr.Textbox()16    clear = gr.ClearButton([msg, chatbot])17 18    def respond(message, chat_history):19        bot_message = random.choice(["How are you?", "I love you", "I'm very hungry"])20        chat_history.append((message, bot_message))21        time.sleep(2)22        return "", chat_history23 24    msg.submit(respond, [msg, chatbot], [msg, chatbot])25 26demo.launch()27 28