From effc7579ac1d4b8bf5c7e437d55455d9b25b7097 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Mon, 24 Jun 2024 17:27:14 -0700 Subject: [PATCH] fix install on python 3.8 --- .circleci/config.yml | 2 +- litellm/caching.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f939fed0040..fc0bb5b9857 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -89,7 +89,7 @@ jobs: name: Linting Testing command: | cd litellm - python -m pip install types-requests types-setuptools types-redis types-PyYAML + python -m pip install types-requests types-setuptools types-redis types-PyYAML types-cachetools if ! python -m mypy . --ignore-missing-imports; then echo "mypy detected errors" exit 1 diff --git a/litellm/caching.py b/litellm/caching.py index c46dd3af8b4..78b4bd27083 100644 --- a/litellm/caching.py +++ b/litellm/caching.py @@ -17,7 +17,6 @@ import traceback from datetime import timedelta from typing import Any, BinaryIO, List, Literal, Optional, Union -from cachetools import LRUCache from openai._models import BaseModel as OpenAIObject import litellm @@ -69,6 +68,8 @@ class InMemoryCache(BaseCache): """ max_size_in_memory [int]: Maximum number of items in cache. done to prevent memory leaks. Use 200 items as a default """ + from cachetools import LRUCache + self.max_size_in_memory = max_size_in_memory or 200 self.cache_dict: LRUCache = LRUCache(maxsize=self.max_size_in_memory) self.ttl_dict: LRUCache = LRUCache(maxsize=self.max_size_in_memory)