refactor: Simplify exception handling and remove redundant validation in LiteLLMExceptions

This commit is contained in:
Paul Gauthier 2025-02-06 09:53:42 -08:00 committed by Paul Gauthier (aider)
parent b9e15a1340
commit 46058c275c
2 changed files with 6 additions and 3 deletions

View file

@ -65,9 +65,10 @@ class LiteLLMExceptions:
if var not in self.exception_info:
raise ValueError(f"{var} is in litellm but not in aider's exceptions list")
ex = getattr(litellm, var)
dump(var, ex)
self.exceptions[ex] = self.exception_info[var]
for var in self.exception_info:
ex = getattr(litellm, var)
dump(var, ex)
self.exceptions[ex] = self.exception_info[var]
def exceptions_tuple(self):
return tuple(self.exceptions)

View file

@ -613,6 +613,7 @@ class Model(ModelSettings):
if "deepseek-reasoner" in self.name:
messages = ensure_alternating_roles(messages)
retry_delay = 0.125
while True:
try:
kwargs = {
@ -620,6 +621,7 @@ class Model(ModelSettings):
"functions": None,
"stream": False,
}
_hash, response = self.send_completion(**kwargs)
if not response or not hasattr(response, "choices") or not response.choices:
return None