Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
class SimpleChatBot:
|
| 4 |
def __init__(self):
|
|
@@ -16,14 +17,14 @@ chatbot = SimpleChatBot()
|
|
| 16 |
|
| 17 |
def respond(message, chat_history):
|
| 18 |
response = chatbot.get_response(message)
|
| 19 |
-
chat_history.append(
|
| 20 |
-
chat_history.append(
|
| 21 |
return chat_history, ""
|
| 22 |
|
| 23 |
with gr.Blocks(title="簡單的Gradio聊天機器人") as demo:
|
| 24 |
gr.Markdown("# 簡單的Gradio聊天機器人")
|
| 25 |
|
| 26 |
-
chatbot_interface = gr.Chatbot()
|
| 27 |
|
| 28 |
with gr.Row():
|
| 29 |
user_input = gr.Textbox(placeholder="輸入訊息...", label="你的訊息")
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import random
|
| 3 |
|
| 4 |
class SimpleChatBot:
|
| 5 |
def __init__(self):
|
|
|
|
| 17 |
|
| 18 |
def respond(message, chat_history):
|
| 19 |
response = chatbot.get_response(message)
|
| 20 |
+
chat_history.append({"role": "user", "content": message})
|
| 21 |
+
chat_history.append({"role": "assistant", "content": response})
|
| 22 |
return chat_history, ""
|
| 23 |
|
| 24 |
with gr.Blocks(title="簡單的Gradio聊天機器人") as demo:
|
| 25 |
gr.Markdown("# 簡單的Gradio聊天機器人")
|
| 26 |
|
| 27 |
+
chatbot_interface = gr.Chatbot(type="messages")
|
| 28 |
|
| 29 |
with gr.Row():
|
| 30 |
user_input = gr.Textbox(placeholder="輸入訊息...", label="你的訊息")
|