Skip to content

Commit

Permalink
fix: stop using pkg_resources
Browse files Browse the repository at this point in the history
  • Loading branch information
aleclarson committed Apr 12, 2024
1 parent fa4cbaf commit d1ce887
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
12 changes: 5 additions & 7 deletions aider/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from aider.io import InputOutput
from aider.repo import GitRepo
from aider.versioncheck import check_version
from aider.models.litellm import LITELLM_VERSION
from aider.models.litellm import LITELLM_SPEC

from .dump import dump # noqa: F401

Expand Down Expand Up @@ -571,8 +571,8 @@ def scrub_sensitive_info(text):

elif not (args.openai_api_key or args.openai_api_base) and \
args.model is not None and \
LITELLM_VERSION is not None:
io.tool_output(f"OpenAI key not provided, using LiteLLM v{LITELLM_VERSION} instead.")
LITELLM_SPEC is not None:
io.tool_output(f"OpenAI key not provided, using LiteLLM instead.")
args.litellm = True

elif not args.openai_api_key:
Expand All @@ -586,15 +586,13 @@ def scrub_sensitive_info(text):
args.model = default_model

if args.litellm:
import importlib
spec = importlib.util.find_spec("litellm")
if spec is None:
if LITELLM_SPEC is None:
io.tool_error("LiteLLM is not installed. Install it with `pip install litellm`.")
return 1

io.tool_output("LiteLLM is enabled.")

packageRootDir = os.path.dirname(spec.origin)
packageRootDir = os.path.dirname(LITELLM_SPEC.origin)
modelPricesBackupName = "model_prices_and_context_window_backup.json"
modelPricesPath = os.path.join(packageRootDir, modelPricesBackupName)

Expand Down
8 changes: 2 additions & 6 deletions aider/models/litellm.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import pkg_resources
import importlib
import logging
import tiktoken

Expand All @@ -7,11 +7,7 @@
logging.basicConfig(level=logging.INFO, format="%(message)s")
logger = logging.getLogger("aider-litellm")

LITELLM_VERSION = None
try:
LITELLM_VERSION = pkg_resources.get_distribution("litellm").version
except pkg_resources.DistributionNotFound:
pass
LITELLM_SPEC = importlib.util.find_spec("litellm")

model_aliases = {
# claude-3
Expand Down

0 comments on commit d1ce887

Please sign in to comment.