Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -14,8 +14,11 @@ class SimpleChatBot:
|
|
14 |
|
15 |
chatbot = SimpleChatBot()
|
16 |
|
17 |
-
def respond(message):
|
18 |
-
|
|
|
|
|
|
|
19 |
|
20 |
with gr.Blocks(title="簡單的Gradio聊天機器人") as demo:
|
21 |
gr.Markdown("# 簡單的Gradio聊天機器人")
|
@@ -26,6 +29,6 @@ with gr.Blocks(title="簡單的Gradio聊天機器人") as demo:
|
|
26 |
user_input = gr.Textbox(placeholder="輸入訊息...", label="你的訊息")
|
27 |
send_button = gr.Button("發送")
|
28 |
|
29 |
-
send_button.click(respond, inputs=user_input, outputs=chatbot_interface)
|
30 |
|
31 |
-
demo.launch()
|
|
|
14 |
|
15 |
chatbot = SimpleChatBot()
|
16 |
|
17 |
+
def respond(message, chat_history):
|
18 |
+
response = chatbot.get_response(message)
|
19 |
+
chat_history.append(("用戶", message))
|
20 |
+
chat_history.append(("機器人", response))
|
21 |
+
return chat_history, ""
|
22 |
|
23 |
with gr.Blocks(title="簡單的Gradio聊天機器人") as demo:
|
24 |
gr.Markdown("# 簡單的Gradio聊天機器人")
|
|
|
29 |
user_input = gr.Textbox(placeholder="輸入訊息...", label="你的訊息")
|
30 |
send_button = gr.Button("發送")
|
31 |
|
32 |
+
send_button.click(respond, inputs=[user_input, chatbot_interface], outputs=[chatbot_interface, user_input])
|
33 |
|
34 |
+
demo.launch(share=True)
|