mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-02 02:34:59 +00:00
refactor: Optimize exception lookup using a set in LiteLLMExceptions
This commit is contained in:
parent
3714f9fdbd
commit
5e4852bd32
1 changed files with 6 additions and 5 deletions
|
@ -51,6 +51,7 @@ EXCEPTIONS = [
|
||||||
|
|
||||||
class LiteLLMExceptions:
|
class LiteLLMExceptions:
|
||||||
exceptions = dict()
|
exceptions = dict()
|
||||||
|
exception_names = {exi.name for exi in EXCEPTIONS}
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._load()
|
self._load()
|
||||||
|
@ -63,11 +64,11 @@ class LiteLLMExceptions:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
ex_info = None
|
ex_info = None
|
||||||
# collect these names into a set once, above ai!
|
if var in self.exception_names:
|
||||||
for exi in EXCEPTIONS:
|
for exi in EXCEPTIONS:
|
||||||
if var == exi.name:
|
if var == exi.name:
|
||||||
ex_info = exi
|
ex_info = exi
|
||||||
break
|
break
|
||||||
|
|
||||||
if strict and not ex_info:
|
if strict and not ex_info:
|
||||||
raise ValueError(f"{var} is in litellm but not in aider's exceptions list")
|
raise ValueError(f"{var} is in litellm but not in aider's exceptions list")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue