diff --git a/prompt2model/utils/api_tools.py b/prompt2model/utils/api_tools.py index 139f5c24f..fb3e8d17f 100644 --- a/prompt2model/utils/api_tools.py +++ b/prompt2model/utils/api_tools.py @@ -19,7 +19,7 @@ # so openai errors are valid even when using other services. API_ERRORS = ( openai.APIError, - openai.Timeout, + openai.APITimeoutError, openai.RateLimitError, openai.BadRequestError, openai.APIStatusError, @@ -31,7 +31,7 @@ openai.BadRequestError: "API Invalid Request: Prompt was filtered", openai.RateLimitError: "API rate limit exceeded. Sleeping for 10 seconds.", openai.APIConnectionError: "Error Communicating with API", - openai.Timeout: "API Timeout Error: API Timeout", + openai.APITimeoutError: "API Timeout Error: API Timeout", openai.APIStatusError: "API service unavailable error: {e}", openai.APIError: "API error: {e}", } @@ -230,7 +230,7 @@ def handle_api_error(e) -> None: raise e if isinstance( e, - (openai.APIError, openai.Timeout, openai.RateLimitError), + (openai.APIError, openai.APITimeoutError, openai.RateLimitError), ): # For these errors, OpenAI recommends waiting before retrying. time.sleep(1)