1414@backoff .on_exception (
1515 wait_gen = backoff .expo ,
1616 exception = (
17- openai .error .ServiceUnavailableError ,
18- openai .error .APIError ,
19- openai .error .RateLimitError ,
20- openai .error .APIConnectionError ,
21- openai .error .Timeout ,
17+ openai .APIError ,
18+ openai .APIStatusError ,
19+ openai .RateLimitError ,
20+ openai .APITimeoutError ,
21+ openai .APIConnectionError ,
22+ openai .InternalServerError ,
2223 ),
2324 max_value = 60 ,
2425 factor = 1.5 ,
@@ -31,7 +32,7 @@ def openai_completion_create_retrying(*args, **kwargs):
3132 result = openai .Completion .create (* args , ** kwargs )
3233 if "error" in result :
3334 logging .warning (result )
34- raise openai .error . APIError (result ["error" ])
35+ raise openai .APIError (result ["error" ])
3536 return result
3637
3738
@@ -52,11 +53,12 @@ def request_with_timeout(func, *args, timeout=EVALS_THREAD_TIMEOUT, **kwargs):
5253@backoff .on_exception (
5354 wait_gen = backoff .expo ,
5455 exception = (
55- openai .error .ServiceUnavailableError ,
56- openai .error .APIError ,
57- openai .error .RateLimitError ,
58- openai .error .APIConnectionError ,
59- openai .error .Timeout ,
56+ openai .APIError ,
57+ openai .APIStatusError ,
58+ openai .RateLimitError ,
59+ openai .APITimeoutError ,
60+ openai .APIConnectionError ,
61+ openai .InternalServerError ,
6062 ),
6163 max_value = 60 ,
6264 factor = 1.5 ,
@@ -69,5 +71,5 @@ def openai_chat_completion_create_retrying(*args, **kwargs):
6971 result = request_with_timeout (openai .ChatCompletion .create , * args , ** kwargs )
7072 if "error" in result :
7173 logging .warning (result )
72- raise openai .error . APIError (result ["error" ])
74+ raise openai .APIError (result ["error" ])
7375 return result
0 commit comments