mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-05 04:05:04 +00:00
refactor: Convert exception_names to dict mapping names to ExInfo
This commit is contained in:
parent
af8bdcd9e0
commit
419952f33b
1 changed files with 8 additions and 7 deletions
|
@ -52,7 +52,7 @@ EXCEPTIONS = [
|
||||||
|
|
||||||
class LiteLLMExceptions:
|
class LiteLLMExceptions:
|
||||||
exceptions = dict()
|
exceptions = dict()
|
||||||
exception_names = {exi.name for exi in EXCEPTIONS}
|
exception_info = {exi.name: exi for exi in EXCEPTIONS}
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._load()
|
self._load()
|
||||||
|
@ -61,12 +61,13 @@ class LiteLLMExceptions:
|
||||||
import litellm
|
import litellm
|
||||||
|
|
||||||
for var in dir(litellm):
|
for var in dir(litellm):
|
||||||
if var.endswith("Error") and var not in self.exception_names:
|
if var.endswith("Error"):
|
||||||
raise ValueError(f"{var} is in litellm but not in aider's exceptions list")
|
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)
|
ex = getattr(litellm, var)
|
||||||
self.exceptions[ex] = ex_info
|
dump(var, ex)
|
||||||
|
self.exceptions[ex] = self.exception_info[var]
|
||||||
|
|
||||||
def exceptions_tuple(self):
|
def exceptions_tuple(self):
|
||||||
return tuple(self.exceptions)
|
return tuple(self.exceptions)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue