refactor: Optimize exception lookup using a set in LiteLLMExceptions

This commit is contained in:
Paul Gauthier (aider) 2025-02-06 09:49:40 -08:00
parent 3714f9fdbd
commit 5e4852bd32

View file

@ -51,6 +51,7 @@ EXCEPTIONS = [
class LiteLLMExceptions:
exceptions = dict()
exception_names = {exi.name for exi in EXCEPTIONS}
def __init__(self):
self._load()
@ -63,7 +64,7 @@ class LiteLLMExceptions:
continue
ex_info = None
# collect these names into a set once, above ai!
if var in self.exception_names:
for exi in EXCEPTIONS:
if var == exi.name:
ex_info = exi