[Update] Support new error code for Bailing model (#1702)

* support new error code

* fix the lint problems
This commit is contained in:
Yi Ding 2024-11-20 16:40:22 +08:00 committed by GitHub
parent ff831b153e
commit 05044dfaf2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2,6 +2,7 @@ import concurrent
import concurrent.futures
import os
import socket
import time
import traceback
from typing import Dict, List, Optional, Union
@ -20,6 +21,8 @@ from .base_api import BaseAPIModel
PromptType = Union[PromptList, str]
BAILING_RETRY_DELAY: int = 30
class HTTPAdapterWithSocketOptions(HTTPAdapter):
@ -200,6 +203,9 @@ class BailingAPI(BaseAPIModel):
break # success
elif response.status_code == 426:
retry_num += 1 # retry
elif response.status_code in [429, 500, 504]:
time.sleep(BAILING_RETRY_DELAY)
retry_num += 1 # retry
else:
raise ValueError(f'Status code = {response.status_code}')
else: