Spaces:
Sleeping
Sleeping
Feliciano Long
commited on
修复最终finish_reason未更新的问题 (#96)
Browse files最后一个chunk中,finish_reason: stop,更新标签状态后再break
- 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()
|