ganchengguang commited on
Commit
cccefce
1 Parent(s): ad0aa53

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -21,11 +21,13 @@ options = {
21
  # 定义聊天函数
22
  def respond(message, language, task, max_tokens):
23
  # 初始化对话历史
24
- messages = [{"role": "system", "content": "You are a friendly Chatbot."}]
25
- messages.append({"role": "user", "content": message + " " + options[language][task]})
 
 
26
 
27
  # 编码输入
28
- inputs = tokenizer(message + " " + options[language][task], return_tensors="pt", padding=True, truncation=True)
29
  # 生成回复
30
  outputs = model.generate(
31
  inputs["input_ids"],
 
21
  # 定义聊天函数
22
  def respond(message, language, task, max_tokens):
23
  # 初始化对话历史
24
+ system_message = "You are a friendly Chatbot."
25
+ messages = [{"role": "system", "content": system_message}]
26
+ user_message = message + " " + options[language][task]
27
+ messages.append({"role": "user", "content": user_message})
28
 
29
  # 编码输入
30
+ inputs = tokenizer(user_message, return_tensors="pt", padding=True, truncation=True)
31
  # 生成回复
32
  outputs = model.generate(
33
  inputs["input_ids"],