From ccacc09ff04850bd7db96b0aea01129a9152602d Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 25 Mar 2025 13:28:53 -1000 Subject: [PATCH] refactor: Reorder model listing and expand fuzzy matching --- aider/main.py | 10 +++++----- aider/models.py | 5 ++++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/aider/main.py b/aider/main.py index a52d04aeb..a2a19577d 100644 --- a/aider/main.py +++ b/aider/main.py @@ -714,11 +714,6 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F if args.check_update: check_version(io, verbose=args.verbose) - if args.list_models: - models.print_matching_models(io, args.list_models) - analytics.event("exit", reason="Listed models") - return 0 - if args.git: git_root = setup_git(git_root, io) if args.gitignore: @@ -738,6 +733,11 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F register_models(git_root, args.model_settings_file, io, verbose=args.verbose) register_litellm_models(git_root, args.model_metadata_file, io, verbose=args.verbose) + if args.list_models: + models.print_matching_models(io, args.list_models) + analytics.event("exit", reason="Listed models") + return 0 + # Process any command line aliases if args.alias: for alias_def in args.alias: diff --git a/aider/models.py b/aider/models.py index a711065ee..f09e1d2fc 100644 --- a/aider/models.py +++ b/aider/models.py @@ -975,7 +975,10 @@ def fuzzy_match_models(name): name = name.lower() chat_models = set() - for orig_model, attrs in litellm.model_cost.items(): + model_metadata = list(litellm.model_cost.items()) + model_metadata += list(model_info_manager.local_model_metadata.items()) + + for orig_model, attrs in model_metadata: model = orig_model.lower() if attrs.get("mode") != "chat": continue