mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-30 17:24:59 +00:00
refactor: Improve model info retrieval logic in ModelInfoManager
This commit is contained in:
parent
2e97fcc47f
commit
1f39c7ef0d
1 changed files with 13 additions and 11 deletions
|
@ -775,18 +775,20 @@ class ModelInfoManager:
|
||||||
return dict()
|
return dict()
|
||||||
|
|
||||||
def get_model_info(self, model):
|
def get_model_info(self, model):
|
||||||
if not litellm._lazy_module:
|
cached_info = self.get_model_from_cached_json_db(model)
|
||||||
info = self.get_model_from_cached_json_db(model)
|
|
||||||
if info:
|
|
||||||
return info
|
|
||||||
|
|
||||||
# If all else fails, do it the slow way...
|
litellm_info = None
|
||||||
|
if litellm._lazy_module or not cached_info:
|
||||||
try:
|
try:
|
||||||
return litellm.get_model_info(model)
|
litellm_info = litellm.get_model_info(model)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
if "model_prices_and_context_window.json" not in str(ex):
|
if "model_prices_and_context_window.json" not in str(ex):
|
||||||
print(str(ex))
|
print(str(ex))
|
||||||
return dict()
|
|
||||||
|
if litellm_info:
|
||||||
|
return litellm_info
|
||||||
|
|
||||||
|
return cached_info
|
||||||
|
|
||||||
|
|
||||||
model_info_manager = ModelInfoManager()
|
model_info_manager = ModelInfoManager()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue