Tuchuanhuhuhu commited on
Commit
9d79c5d
·
1 Parent(s): 43d181b

JSON解析出错时显示完整的错误

Browse files
Files changed (1) hide show
  1. utils.py +3 -1
utils.py CHANGED
@@ -156,6 +156,7 @@ def stream_predict(openai_api_key, system_prompt, history, inputs, chatbot, all_
156
  return
157
 
158
  yield get_return_value()
 
159
 
160
  for chunk in tqdm(response.iter_lines()):
161
  if counter == 0:
@@ -170,7 +171,8 @@ def stream_predict(openai_api_key, system_prompt, history, inputs, chatbot, all_
170
  chunk = json.loads(chunk[6:])
171
  except json.JSONDecodeError:
172
  print(chunk)
173
- status_text = f"JSON解析错误。请重置对话。收到的内容: {chunk}"
 
174
  yield get_return_value()
175
  continue
176
  # decode each line as response data is in bytes
 
156
  return
157
 
158
  yield get_return_value()
159
+ error_json_str = ""
160
 
161
  for chunk in tqdm(response.iter_lines()):
162
  if counter == 0:
 
171
  chunk = json.loads(chunk[6:])
172
  except json.JSONDecodeError:
173
  print(chunk)
174
+ error_json_str += chunk
175
+ status_text = f"JSON解析错误。请重置对话。收到的内容: {error_json_str}"
176
  yield get_return_value()
177
  continue
178
  # decode each line as response data is in bytes