Skip to content

Commit

Permalink
correct timeout error
Browse files Browse the repository at this point in the history
  • Loading branch information
saum7800 committed Apr 15, 2024
1 parent 85753e4 commit 50d20de
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions prompt2model/utils/api_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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}",
}
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 50d20de

Please sign in to comment.