Spaces:
Building
Building
Upload 4 files
Browse files
app.py
CHANGED
@@ -234,9 +234,11 @@ def handle_api_error(error, attempt):
|
|
234 |
|
235 |
elif isinstance(error, generation_types.BlockedPromptException):
|
236 |
try:
|
237 |
-
full_reason_str = error.args[0]
|
238 |
-
|
239 |
-
|
|
|
|
|
240 |
|
241 |
if block_reason_str == "SAFETY":
|
242 |
logger.warning(f"提示因安全原因被阻止")
|
|
|
234 |
|
235 |
elif isinstance(error, generation_types.BlockedPromptException):
|
236 |
try:
|
237 |
+
full_reason_str = str(error.args[0])
|
238 |
+
|
239 |
+
if "block_reason:" in full_reason_str:
|
240 |
+
start_index = full_reason_str.find("block_reason:") + len("block_reason:")
|
241 |
+
block_reason_str = full_reason_str[start_index:].strip()
|
242 |
|
243 |
if block_reason_str == "SAFETY":
|
244 |
logger.warning(f"提示因安全原因被阻止")
|