streamlit borks sys.path, causes import("litellm") to load our litellm.py; fix

This commit is contained in:
Paul Gauthier 2024-07-03 21:32:50 -03:00
parent aaceec1e1f
commit 9d02628cf8
8 changed files with 11 additions and 10 deletions

29
aider/llm.py Normal file
View file

@ -0,0 +1,29 @@
import importlib
import os
import warnings
warnings.filterwarnings("ignore", category=UserWarning, module="pydantic")
os.environ["OR_SITE_URL"] = "http://aider.chat"
os.environ["OR_APP_NAME"] = "Aider"
# `import litellm` takes 1.5 seconds, defer it!
class LazyLiteLLM:
def __init__(self):
self._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
return getattr(self._lazy_module, name)
litellm = LazyLiteLLM()
__all__ = [litellm]