Tuchuanhuhuhu commited on
Commit
d41e0f0
·
1 Parent(s): a216d66

修复用户输入的内容换行过多的问题

Browse files
Files changed (1) hide show
  1. ChuanhuChatbot.py +4 -4
ChuanhuChatbot.py CHANGED
@@ -140,7 +140,7 @@ def predict(inputs, top_p, temperature, openai_api_key, chatbot=[], history=[],
140
 
141
  counter = 0
142
  if stream:
143
- chatbot.append((history[-1], ""))
144
  for chunk in response.iter_lines():
145
  if counter == 0:
146
  counter += 1
@@ -173,7 +173,7 @@ def predict(inputs, top_p, temperature, openai_api_key, chatbot=[], history=[],
173
  history.append(" " + partial_words)
174
  else:
175
  history[-1] = partial_words
176
- chatbot[-1] = (history[-2], parse_text(history[-1]))
177
  token_counter += 1
178
  yield chatbot, history, status_text
179
  else:
@@ -181,10 +181,10 @@ def predict(inputs, top_p, temperature, openai_api_key, chatbot=[], history=[],
181
  responsejson = json.loads(response.text)
182
  content = responsejson["choices"][0]["message"]["content"]
183
  history.append(content)
184
- chatbot.append((history[-2], parse_text(content)))
185
  status_text = "精简完成"
186
  except:
187
- chatbot.append((history[-1], "☹️发生了错误,请检查网络连接或者稍后再试。"))
188
  status_text = "status: ERROR"
189
  yield chatbot, history, status_text
190
 
 
140
 
141
  counter = 0
142
  if stream:
143
+ chatbot.append((parse_text(history[-1]), ""))
144
  for chunk in response.iter_lines():
145
  if counter == 0:
146
  counter += 1
 
173
  history.append(" " + partial_words)
174
  else:
175
  history[-1] = partial_words
176
+ chatbot[-1] = (parse_text(history[-2]), parse_text(history[-1]))
177
  token_counter += 1
178
  yield chatbot, history, status_text
179
  else:
 
181
  responsejson = json.loads(response.text)
182
  content = responsejson["choices"][0]["message"]["content"]
183
  history.append(content)
184
+ chatbot.append((parse_text(history[-2]), parse_text(content)))
185
  status_text = "精简完成"
186
  except:
187
+ chatbot.append((parse_text(history[-1]), "☹️发生了错误,请检查网络连接或者稍后再试。"))
188
  status_text = "status: ERROR"
189
  yield chatbot, history, status_text
190