Moonfanz commited on
Commit
9ac5435
·
verified ·
1 Parent(s): 18ba7ec

Upload 4 files

Browse files
Files changed (1) hide show
  1. app.py +1 -2
app.py CHANGED
@@ -91,7 +91,6 @@ class ResponseWrapper:
91
  self._text = self._extract_text()
92
  self._finish_reason = self._extract_finish_reason()
93
  if self.finish_reason != "STOP":
94
- # 抛出错误
95
  raise BlockedPromptException(f"生成文本失败: {self.finish_reason}")
96
  self._prompt_token_count = self._extract_prompt_token_count()
97
  self._candidates_token_count = self._extract_candidates_token_count()
@@ -446,7 +445,7 @@ def chat_completions():
446
  return 1, ResponseWrapper(response.json())
447
  except requests.exceptions.RequestException as e:
448
  return handle_api_error(e, attempt)
449
- except StopCandidateException as e:
450
  return handle_api_error(e, attempt)
451
 
452
  def generate_stream(response):
 
91
  self._text = self._extract_text()
92
  self._finish_reason = self._extract_finish_reason()
93
  if self.finish_reason != "STOP":
 
94
  raise BlockedPromptException(f"生成文本失败: {self.finish_reason}")
95
  self._prompt_token_count = self._extract_prompt_token_count()
96
  self._candidates_token_count = self._extract_candidates_token_count()
 
445
  return 1, ResponseWrapper(response.json())
446
  except requests.exceptions.RequestException as e:
447
  return handle_api_error(e, attempt)
448
+ except (StopCandidateException, BlockedPromptException) as e:
449
  return handle_api_error(e, attempt)
450
 
451
  def generate_stream(response):