mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-17 01:55:01 +00:00
Added --models
This commit is contained in:
parent
9971547e8f
commit
25b8d6fec8
3 changed files with 58 additions and 15 deletions
|
@ -176,6 +176,11 @@ def main(argv=None, input=None, output=None, force_git_root=None):
|
|||
default=default_model,
|
||||
help=f"Specify the model to use for the main chat (default: {default_model})",
|
||||
)
|
||||
core_group.add_argument(
|
||||
"--models",
|
||||
metavar="MODEL",
|
||||
help="List known models which match the (partial) MODEL name",
|
||||
)
|
||||
opus_model = "claude-3-opus-20240229"
|
||||
core_group.add_argument(
|
||||
"--opus",
|
||||
|
@ -564,6 +569,16 @@ def main(argv=None, input=None, output=None, force_git_root=None):
|
|||
args.pretty = False
|
||||
io.tool_output("VSCode terminal detected, pretty output has been disabled.")
|
||||
|
||||
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:
|
||||
io.tool_output(f"- {model}")
|
||||
else:
|
||||
io.tool_output(f'No models match "{args.models}".')
|
||||
return 0
|
||||
|
||||
if args.git:
|
||||
git_root = setup_git(git_root, io)
|
||||
if args.gitignore:
|
||||
|
|
|
@ -355,19 +355,29 @@ def sanity_check_model(io, model):
|
|||
|
||||
|
||||
def fuzzy_match_models(name):
|
||||
models = litellm.model_cost.keys()
|
||||
chat_models = [
|
||||
model for model, attrs in litellm.model_cost.items() if attrs.get("mode") == "chat"
|
||||
]
|
||||
|
||||
# Check for exact match first
|
||||
if name in models:
|
||||
return [name]
|
||||
# exactly matching model
|
||||
matching_models = [model for model in chat_models if name == model]
|
||||
if matching_models:
|
||||
return matching_models
|
||||
|
||||
# Check for models containing the name
|
||||
matching_models = [model for model in models if name in model]
|
||||
# exactly matching provider
|
||||
matching_models = [
|
||||
model for model in chat_models if litellm.model_cost[model]["litellm_provider"] == name
|
||||
]
|
||||
if matching_models:
|
||||
return matching_models
|
||||
|
||||
# If no matches found, check for slight misspellings
|
||||
if not matching_models:
|
||||
matching_models = difflib.get_close_matches(name, models, n=3, cutoff=0.8)
|
||||
# Check for model names containing the name
|
||||
matching_models = [model for model in chat_models if name in model]
|
||||
if matching_models:
|
||||
return matching_models
|
||||
|
||||
# Check for slight misspellings
|
||||
matching_models = difflib.get_close_matches(name, chat_models, n=3, cutoff=0.8)
|
||||
return matching_models
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue