Retry (with fallback) on Gemini fails with internal server error

Khoj should use a fallback model when available to retry request if
calls to Gemini fail with internal server error.
This commit is contained in:
Debanjum
2026-01-06 12:13:35 -08:00
parent 1fd6e16cff
commit 9cbf620e45

View File

@@ -144,7 +144,7 @@ def is_retryable_exception(exception: BaseException) -> bool:
# Google/Gemini exceptions # Google/Gemini exceptions
if isinstance(exception, (gerrors.APIError, gerrors.ClientError)): if isinstance(exception, (gerrors.APIError, gerrors.ClientError)):
# Check for specific error codes that are retryable # Check for specific error codes that are retryable
if hasattr(exception, "code") and exception.code in [429, 502, 503, 504]: if hasattr(exception, "code") and exception.code in [429, 500, 502, 503, 504]:
return True return True
# Network errors # Network errors