From 2e246869d07929f5dcd841c50cf7d3b1ade96282 Mon Sep 17 00:00:00 2001 From: Ori Kotek Date: Thu, 20 Jul 2023 15:02:34 +0300 Subject: [PATCH] Retry on rate limit error on OpenAI calls --- pr_agent/algo/ai_handler.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pr_agent/algo/ai_handler.py b/pr_agent/algo/ai_handler.py index 085d9ba6..8ab22e05 100644 --- a/pr_agent/algo/ai_handler.py +++ b/pr_agent/algo/ai_handler.py @@ -72,6 +72,9 @@ class AiHandler: except (RateLimitError) as e: logging.error("Rate limit error during OpenAI inference: ", e) raise + except (Exception) as e: + logging.error("Unknown error during OpenAI inference: ", e) + raise TryAgain from e if response is None or len(response.choices) == 0: raise TryAgain resp = response.choices[0]['message']['content']