Refactor the /v1/models endpoint

This commit is contained in:
oobabooga 2023-11-07 19:59:27 -08:00
parent 1b69694fe9
commit 43c53a7820
3 changed files with 28 additions and 80 deletions

View file

@ -71,12 +71,12 @@ def natural_keys(text):
def get_available_models():
model_list = ['None']
model_list = []
for item in list(Path(f'{shared.args.model_dir}/').glob('*')):
if not item.name.endswith(('.txt', '-np', '.pt', '.json', '.yaml', '.py')) and 'llama-tokenizer' not in item.name:
model_list.append(re.sub('.pth$', '', item.name))
return sorted(model_list, key=natural_keys)
return ['None'] + sorted(model_list, key=natural_keys)
def get_available_presets():