diff --git a/aider/llm.py b/aider/llm.py index 82f86027a..f65398729 100644 --- a/aider/llm.py +++ b/aider/llm.py @@ -11,19 +11,22 @@ os.environ["OR_APP_NAME"] = "Aider" class LazyLiteLLM: - def __init__(self): - self._lazy_module = None + _lazy_module = None def __getattr__(self, name): - if self._lazy_module is None: - self._lazy_module = importlib.import_module("litellm") - - self._lazy_module.suppress_debug_info = True - self._lazy_module.set_verbose = False - self._lazy_module.drop_params = True - + self._load_litellm() return getattr(self._lazy_module, name) + def _load_litellm(self): + if self._lazy_module is not None: + return + + self._lazy_module = importlib.import_module("litellm") + + self._lazy_module.suppress_debug_info = True + self._lazy_module.set_verbose = False + self._lazy_module.drop_params = True + litellm = LazyLiteLLM() diff --git a/aider/main.py b/aider/main.py index f5e26a863..ea1c622f8 100644 --- a/aider/main.py +++ b/aider/main.py @@ -327,7 +327,8 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F if not args.verify_ssl: import httpx - litellm.client_session = httpx.Client(verify=False) + litellm._load_litellm() + litellm._lazy_module.client_session = httpx.Client(verify=False) if args.dark_mode: args.user_input_color = "#32FF32"