3v324v23 commited on
Commit
d26fa46
1 Parent(s): da19fa1

http post error show

Browse files
Files changed (1) hide show
  1. predict.py +6 -2
predict.py CHANGED
@@ -126,7 +126,7 @@ def predict(inputs, top_p, temperature, chatbot=[], history=[], system_prompt=''
126
 
127
  except Exception as e:
128
  traceback.print_exc()
129
- yield chatbot, history, "Json解析不合常规,很可能是文本过长"
130
  chunk = get_full_error(chunk, stream_response)
131
  error_msg = chunk.decode()
132
  if "reduce the length" in error_msg:
@@ -134,7 +134,11 @@ def predict(inputs, top_p, temperature, chatbot=[], history=[], system_prompt=''
134
  history = []
135
  elif "Incorrect API key" in error_msg:
136
  chatbot[-1] = (chatbot[-1][0], "[Local Message] Incorrect API key provided.")
137
- yield chatbot, history, "Json解析不合常规,很可能是文本过长" + error_msg
 
 
 
 
138
  return
139
 
140
  def generate_payload(inputs, top_p, temperature, history, system_prompt, stream):
 
126
 
127
  except Exception as e:
128
  traceback.print_exc()
129
+ yield chatbot, history, "Json解析不合常规"
130
  chunk = get_full_error(chunk, stream_response)
131
  error_msg = chunk.decode()
132
  if "reduce the length" in error_msg:
 
134
  history = []
135
  elif "Incorrect API key" in error_msg:
136
  chatbot[-1] = (chatbot[-1][0], "[Local Message] Incorrect API key provided.")
137
+ else:
138
+ from toolbox import regular_txt_to_markdown
139
+ tb_str = regular_txt_to_markdown(traceback.format_exc())
140
+ chatbot[-1] = (chatbot[-1][0], f"[Local Message] Json Error \n\n {tb_str} \n\n {regular_txt_to_markdown(chunk.decode()[4:])}")
141
+ yield chatbot, history, "Json解析不合常规" + error_msg
142
  return
143
 
144
  def generate_payload(inputs, top_p, temperature, history, system_prompt, stream):