YC-Chen commited on
Commit
f7bf665
1 Parent(s): 58f35de

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -9
app.py CHANGED
@@ -154,15 +154,10 @@ with gr.Blocks() as demo:
154
  if system_prompt:
155
  chat_data.append({"role": "system", "content": system_prompt})
156
  for user_msg, assistant_msg in history:
157
- if user_msg is not None:
158
- chat_data.append({"role": "user", "content": user_msg})
159
- if assistant_msg is not None:
160
- chat_data.append({"role": "assistant", "content": assistant_msg})
161
- try:
162
- message = tokenizer.apply_chat_template(chat_data, tokenize=False)
163
- except Exception as e:
164
- print(chat_data)
165
- raise Exception('prompt template error')
166
  message = message[3:] # remove SOT token
167
 
168
  if len(message) > MAX_INPUT_LENGTH:
 
154
  if system_prompt:
155
  chat_data.append({"role": "system", "content": system_prompt})
156
  for user_msg, assistant_msg in history:
157
+ chat_data.append({"role": "user", "content": user_msg if user_msg is not None else ''})
158
+ chat_data.append({"role": "assistant", "content": assistant_msg if assistant_msg is not None else ''})
159
+
160
+ message = tokenizer.apply_chat_template(chat_data, tokenize=False)
 
 
 
 
 
161
  message = message[3:] # remove SOT token
162
 
163
  if len(message) > MAX_INPUT_LENGTH: