fix: Flip logic in get_model_info

This commit is contained in:
Paul Gauthier (aider) 2024-08-25 07:57:20 -07:00
parent fa7d92a117
commit 5e8f9f72cc

View file

@ -452,7 +452,13 @@ class Model(ModelSettings):
self.get_weak_model(weak_model) self.get_weak_model(weak_model)
def get_model_info(self, model): def get_model_info(self, model):
if not litellm._lazy_module: if litellm._lazy_module:
# Do it the slow way...
try:
return litellm.get_model_info(model)
except Exception:
return dict()
cache_dir = Path.home() / ".aider" / "caches" cache_dir = Path.home() / ".aider" / "caches"
cache_file = cache_dir / "model_prices_and_context_window.json" cache_file = cache_dir / "model_prices_and_context_window.json"
cache_dir.mkdir(parents=True, exist_ok=True) cache_dir.mkdir(parents=True, exist_ok=True)
@ -497,7 +503,7 @@ class Model(ModelSettings):
except Exception: except Exception:
pass # If there's any error, fall back to the slow way pass # If there's any error, fall back to the slow way
# Do it the slow way... # If all else fails, do it the slow way...
try: try:
return litellm.get_model_info(model) return litellm.get_model_info(model)
except Exception: except Exception: