Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,18 +4,11 @@ import agent
|
|
| 4 |
|
| 5 |
# --------- Hàm xử lý chat ----------
|
| 6 |
def respond(user_message, chat_history):
|
| 7 |
-
if not user_message:
|
| 8 |
return chat_history, gr.update(value="")
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
chat_history
|
| 12 |
-
|
| 13 |
-
# Lấy phản hồi từ agent
|
| 14 |
-
bot_reply = agent.chat_with_agent(user_message)
|
| 15 |
-
|
| 16 |
-
# Thêm tin nhắn bot
|
| 17 |
-
chat_history.append({"role": "assistant", "content": bot_reply})
|
| 18 |
-
|
| 19 |
return chat_history, gr.update(value="")
|
| 20 |
|
| 21 |
def clear_chat():
|
|
@@ -37,7 +30,6 @@ with gr.Blocks(theme=gr.themes.Default()) as demo:
|
|
| 37 |
|
| 38 |
|
| 39 |
chatbot = gr.Chatbot(
|
| 40 |
-
type="messages",
|
| 41 |
label="Chatbot",
|
| 42 |
height=420,
|
| 43 |
# show_copy_button=True, # cho phép copy nội dung nhanh
|
|
|
|
| 4 |
|
| 5 |
# --------- Hàm xử lý chat ----------
|
| 6 |
def respond(user_message, chat_history):
|
| 7 |
+
if not user_message or not user_message:
|
| 8 |
return chat_history, gr.update(value="")
|
| 9 |
+
user_bubble = f"{user_message}🧑"
|
| 10 |
+
bot_reply = f"🤖 {agent.chat_with_agent(user_message)}"
|
| 11 |
+
chat_history = chat_history + [(user_bubble, bot_reply)]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
return chat_history, gr.update(value="")
|
| 13 |
|
| 14 |
def clear_chat():
|
|
|
|
| 30 |
|
| 31 |
|
| 32 |
chatbot = gr.Chatbot(
|
|
|
|
| 33 |
label="Chatbot",
|
| 34 |
height=420,
|
| 35 |
# show_copy_button=True, # cho phép copy nội dung nhanh
|