ThongCoding commited on
Commit
6f0dccd
·
verified ·
1 Parent(s): 2912d03

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -26,8 +26,9 @@ llm = Llama(
26
  )
27
 
28
  # --- Hàm chat ---
29
- def chat_fn(message, history=None):
30
- history = history or []
 
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 reply, history
 
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(