Skip to content

Commit

Permalink
retry on status 500 response
Browse files Browse the repository at this point in the history
  • Loading branch information
phelps-sg committed Jul 18, 2023
1 parent b12f50b commit b6e8496
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/openai_pygenerator/openai_pygenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def generate_completions(
APIError,
ServiceUnavailableError,
) as err:
if isinstance(err, APIError) and not (err.http_status in [524, 502]):
if isinstance(err, APIError) and not (err.http_status in [524, 502, 500]):
raise
logger.warning("Error returned from openai API: %s", err)
logger.debug("retries = %d", retries)
Expand Down
1 change: 1 addition & 0 deletions tests/test_gpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def test_generate_completion(mock_openai, mock_sleep, error):
[
RateLimitError("rate limited", http_status=429),
APIError("Gateway Timeout", http_status=524),
APIError("Server shutdown", http_status=500),
ServiceUnavailableError("Service unavailable"),
urlex.ReadTimeoutError("test-pool", "http://test", "read timeout"),
openai.error.Timeout,
Expand Down

0 comments on commit b6e8496

Please sign in to comment.