Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -26,8 +26,9 @@ llm = Llama(
|
|
26 |
)
|
27 |
|
28 |
# --- Hàm chat ---
|
29 |
-
def chat_fn(message, history
|
30 |
-
|
|
|
31 |
system_prompt = {"role": "system", "content": "Bạn là một trợ lý AI giao tiếp bằng tiếng Việt, trả lời tự nhiên và thân thiện."}
|
32 |
messages = [system_prompt]
|
33 |
for user_msg, bot_msg in history:
|
@@ -42,8 +43,9 @@ def chat_fn(message, history=None):
|
|
42 |
stop=["<|user|>", "<|assistant|>"],
|
43 |
)
|
44 |
reply = response["choices"][0]["message"]["content"].strip()
|
45 |
-
history.append((message, reply))
|
46 |
-
return
|
|
|
47 |
|
48 |
# --- Giao diện Gradio ---
|
49 |
gr.ChatInterface(
|
|
|
26 |
)
|
27 |
|
28 |
# --- Hàm chat ---
|
29 |
+
def chat_fn(message, history):
|
30 |
+
if history is None:
|
31 |
+
history = []
|
32 |
system_prompt = {"role": "system", "content": "Bạn là một trợ lý AI giao tiếp bằng tiếng Việt, trả lời tự nhiên và thân thiện."}
|
33 |
messages = [system_prompt]
|
34 |
for user_msg, bot_msg in history:
|
|
|
43 |
stop=["<|user|>", "<|assistant|>"],
|
44 |
)
|
45 |
reply = response["choices"][0]["message"]["content"].strip()
|
46 |
+
history.append((message, reply)) # Thêm vào lịch sử
|
47 |
+
return history # Trả về toàn bộ history
|
48 |
+
|
49 |
|
50 |
# --- Giao diện Gradio ---
|
51 |
gr.ChatInterface(
|