Feliciano Long commited on
Commit
f60fb0f
·
unverified ·
1 Parent(s): 07cd8f7

修复最终finish_reason未更新的问题 (#96)

Browse files

最后一个chunk中,finish_reason: stop,更新标签状态后再break

Files changed (1) hide show
  1. ChuanhuChatbot.py +3 -0
ChuanhuChatbot.py CHANGED
@@ -151,6 +151,9 @@ def predict(inputs, top_p, temperature, openai_api_key, chatbot=[], history=[],
151
  # decode each line as response data is in bytes
152
  try:
153
  if len(json.loads(chunk.decode()[6:])['choices'][0]["delta"]) == 0:
 
 
 
154
  break
155
  except Exception as e:
156
  traceback.print_exc()
 
151
  # decode each line as response data is in bytes
152
  try:
153
  if len(json.loads(chunk.decode()[6:])['choices'][0]["delta"]) == 0:
154
+ chunkjson = json.loads(chunk.decode()[6:])
155
+ status_text = f"id: {chunked['id']}, finish_reason: {chunkjson['choices'][0]['finish_reason']}"
156
+ yield chatbot, history, status_text
157
  break
158
  except Exception as e:
159
  traceback.print_exc()