Moonfanz commited on
Commit
25113af
·
verified ·
1 Parent(s): 53d5cbc

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -91,7 +91,7 @@ class ResponseWrapper:
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()
97
  self._total_token_count = self._extract_total_token_count()
@@ -105,7 +105,7 @@ class ResponseWrapper:
105
  return part['text']
106
  return None
107
  except (KeyError, IndexError):
108
- return None
109
 
110
  def _extract_text(self) -> str:
111
  try:
 
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()
97
  self._total_token_count = self._extract_total_token_count()
 
105
  return part['text']
106
  return None
107
  except (KeyError, IndexError):
108
+ return None
109
 
110
  def _extract_text(self) -> str:
111
  try: