Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -43,9 +43,13 @@ def chat_fn(message, history):
|
|
43 |
stop=["<|user|>", "<|assistant|>"],
|
44 |
)
|
45 |
reply = response["choices"][0]["message"]["content"].strip()
|
46 |
-
|
47 |
-
|
|
|
|
|
48 |
|
|
|
|
|
49 |
|
50 |
# --- Giao diện Gradio ---
|
51 |
gr.ChatInterface(
|
@@ -54,4 +58,4 @@ gr.ChatInterface(
|
|
54 |
title="🤖 Chatbot Phi-2 (Tiếng Việt)",
|
55 |
description="Trợ lý AI tiếng Việt chạy bằng Phi-2 - GGUF (nhẹ, nhanh, tiết kiệm RAM)",
|
56 |
theme="soft",
|
57 |
-
).launch()
|
|
|
43 |
stop=["<|user|>", "<|assistant|>"],
|
44 |
)
|
45 |
reply = response["choices"][0]["message"]["content"].strip()
|
46 |
+
|
47 |
+
# Nếu reply trống, trả về câu mặc định
|
48 |
+
if not reply:
|
49 |
+
reply = "Xin lỗi, mình chưa hiểu yêu cầu của bạn. Bạn có thể hỏi lại nhé!"
|
50 |
|
51 |
+
history.append((message, reply))
|
52 |
+
return history
|
53 |
|
54 |
# --- Giao diện Gradio ---
|
55 |
gr.ChatInterface(
|
|
|
58 |
title="🤖 Chatbot Phi-2 (Tiếng Việt)",
|
59 |
description="Trợ lý AI tiếng Việt chạy bằng Phi-2 - GGUF (nhẹ, nhanh, tiết kiệm RAM)",
|
60 |
theme="soft",
|
61 |
+
).launch(share=True)
|