Tuchuanhuhuhu commited on
Commit
157f174
1 Parent(s): 29cce21

修复history重复的问题,fix #156

Browse files
Files changed (1) hide show
  1. utils.py +6 -3
utils.py CHANGED
@@ -224,10 +224,13 @@ def predict(openai_api_key, system_prompt, history, inputs, chatbot, all_token_c
224
  if len(openai_api_key) != 51:
225
  status_text = standard_error_msg + no_apikey_msg
226
  print(status_text)
227
- history.append(construct_user(inputs))
228
- history.append("")
229
  chatbot.append((parse_text(inputs), ""))
230
- all_token_counts.append(0)
 
 
 
 
 
231
  yield chatbot, history, status_text, all_token_counts
232
  return
233
  yield chatbot, history, "开始生成回答……", all_token_counts
 
224
  if len(openai_api_key) != 51:
225
  status_text = standard_error_msg + no_apikey_msg
226
  print(status_text)
 
 
227
  chatbot.append((parse_text(inputs), ""))
228
+ if len(history) == 0:
229
+ history.append(construct_user(inputs))
230
+ history.append("")
231
+ all_token_counts.append(0)
232
+ else:
233
+ history[-2] = construct_user(inputs)
234
  yield chatbot, history, status_text, all_token_counts
235
  return
236
  yield chatbot, history, "开始生成回答……", all_token_counts