From 46058c275cc19e536697cba73d541afb48b3ccab Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 6 Feb 2025 09:53:42 -0800 Subject: [PATCH] refactor: Simplify exception handling and remove redundant validation in LiteLLMExceptions --- aider/exceptions.py | 7 ++++--- aider/models.py | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/aider/exceptions.py b/aider/exceptions.py index 8a19d32b1..36cdaf0b6 100644 --- a/aider/exceptions.py +++ b/aider/exceptions.py @@ -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) diff --git a/aider/models.py b/aider/models.py index cd1656d94..a064ddc78 100644 --- a/aider/models.py +++ b/aider/models.py @@ -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