interface
Browse files- interface.py +18 -0
interface.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from bot.chat import bot
|
| 3 |
+
|
| 4 |
+
def create_interface():
|
| 5 |
+
with gr.Blocks() as demo:
|
| 6 |
+
chatbot = gr.Chatbot()
|
| 7 |
+
msg = gr.Textbox()
|
| 8 |
+
clear = gr.Button("Clear")
|
| 9 |
+
|
| 10 |
+
def user(user_message, history):
|
| 11 |
+
return "", history + [[user_message, None]]
|
| 12 |
+
|
| 13 |
+
msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
|
| 14 |
+
bot, chatbot, chatbot
|
| 15 |
+
)
|
| 16 |
+
clear.click(lambda: None, None, chatbot, queue=False)
|
| 17 |
+
|
| 18 |
+
return demo
|