added autocomplete for model names

This commit is contained in:
Paul Gauthier 2024-04-30 16:29:10 -07:00
parent 8e9a00006b
commit 665b9044c8

View file

@ -5,6 +5,7 @@ import sys
from pathlib import Path
import git
import litellm
import openai
from prompt_toolkit.completion import Completion
@ -14,6 +15,8 @@ from aider.utils import is_image_file
from .dump import dump # noqa: F401
litellm.suppress_debug_info = True
class SwitchModel(Exception):
def __init__(self, model):
@ -41,6 +44,12 @@ class Commands:
models.sanity_check_models(self.io, model)
raise SwitchModel(model)
def completions_model(self, partial):
models = litellm.model_cost.keys()
for model in models:
if partial.lower() in model.lower():
yield Completion(model, start_position=-len(partial))
def cmd_models(self, args):
"Search the list of available models"