diff --git a/aider/commands.py b/aider/commands.py index 3b6f359d5..ed81c54ca 100644 --- a/aider/commands.py +++ b/aider/commands.py @@ -8,7 +8,7 @@ import git import openai from prompt_toolkit.completion import Completion -from aider import prompts, voice +from aider import models, prompts, voice from aider.scrape import Scraper from aider.utils import is_image_file @@ -28,6 +28,16 @@ class Commands: self.voice_language = voice_language + def cmd_model(self, args): + "Search the list of available models" + + args = args.strip() + + if args: + models.print_matching_models(self.io, args) + else: + self.io.tool_output("Use `/model ` to show models which match") + def cmd_web(self, args): "Use headless selenium to scrape a webpage and add the content to the chat" url = args.strip() diff --git a/aider/main.py b/aider/main.py index 193f29f89..11e0143cb 100644 --- a/aider/main.py +++ b/aider/main.py @@ -270,17 +270,7 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F return 0 if not update_available else 1 if args.models: - matches = models.fuzzy_match_models(args.models) - if matches: - io.tool_output(f'Models which match "{args.models}":') - for model in matches: - fq, m = model - if fq == m: - io.tool_output(f"- {m}") - else: - io.tool_output(f"- {m} ({fq})") - else: - io.tool_output(f'No models match "{args.models}".') + models.print_matching_models(io, args.models) return 0 if args.git: diff --git a/aider/models.py b/aider/models.py index 59976f2b1..c7f127705 100644 --- a/aider/models.py +++ b/aider/models.py @@ -409,6 +409,20 @@ def fuzzy_match_models(name): return list(zip(matching_models, matching_models)) +def print_matching_models(io, search): + matches = fuzzy_match_models(search) + if matches: + io.tool_output(f'Models which match "{search}":') + for model in matches: + fq, m = model + if fq == m: + io.tool_output(f"- {m}") + else: + io.tool_output(f"- {m} ({fq})") + else: + io.tool_output(f'No models match "{search}".') + + def main(): if len(sys.argv) != 2: print("Usage: python models.py ")