allow get_available_models() and get_available_ggufs() to find models recursively

This commit is contained in:
Googolplexed0 2025-01-22 03:30:48 -05:00
parent 39799adc47
commit 37cf3ae194
No known key found for this signature in database

View File

@ -74,20 +74,24 @@ def natural_keys(text):
def get_available_models():
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(item.name)
for dirpath, _, files in os.walk(Path(f'{shared.args.model_dir}/'), followlinks=True):
for file in files:
if not file.lower().endswith(('.txt', '-np', '.pt', '.json', '.yaml', '.py', '.gguf')) and 'llama-tokenizer' not in file.lower():
display_name = os.path.relpath(dirpath, Path(f'{shared.args.model_dir}/'))
if display_name not in model_list:
model_list.append(display_name)
return ['None'] + sorted(model_list, key=natural_keys)
return ['None'] + sorted(model_list + get_available_ggufs(), key=natural_keys)
def get_available_ggufs():
model_list = []
for item in Path(f'{shared.args.model_dir}/').glob('*'):
if item.is_file() and item.name.lower().endswith(".gguf"):
model_list.append(item.name)
for dirpath, _, files in os.walk(Path(f'{shared.args.model_dir}/'), followlinks=True):
for file in files:
if file.lower().endswith(".gguf"):
model_list.append(os.path.relpath(Path(dirpath).joinpath(file), Path(f'{shared.args.model_dir}/')))
return ['None'] + sorted(model_list, key=natural_keys)
return sorted(model_list, key=natural_keys)
def get_available_presets():