This commit is contained in:
Paul Gauthier 2024-10-31 11:44:24 -07:00
parent ba7656bc1c
commit 2817766cf5

View file

@ -638,7 +638,6 @@ class ModelInfoManager:
"model_prices_and_context_window.json" "model_prices_and_context_window.json"
) )
CACHE_TTL = 60 * 60 * 24 # 24 hours CACHE_TTL = 60 * 60 * 24 # 24 hours
content = None
def __init__(self): def __init__(self):
self.cache_dir = Path.home() / ".aider" / "caches" self.cache_dir = Path.home() / ".aider" / "caches"
@ -657,19 +656,18 @@ class ModelInfoManager:
pass pass
def _update_cache(self): def _update_cache(self):
if not litellm._lazy_module: try:
try: import requests
import requests
response = requests.get(self.MODEL_INFO_URL, timeout=5) response = requests.get(self.MODEL_INFO_URL, timeout=5)
if response.status_code == 200: if response.status_code == 200:
self.content = response.json() self.content = response.json()
try: try:
self.cache_file.write_text(json.dumps(self.content, indent=4)) self.cache_file.write_text(json.dumps(self.content, indent=4))
except OSError: except OSError:
pass pass
except Exception as ex: except Exception as ex:
print(str(ex)) print(str(ex))
def get_model_from_cached_json_db(self, model): def get_model_from_cached_json_db(self, model):
if not self.content: if not self.content: