@@ -358,15 +358,17 @@ def remove(
358358 typer .echo ("No models found to remove." )
359359 return
360360
361+ # Build a mapping from display name to path for selection
362+ model_path_by_name = {model .name : model for _model_type , model in available_models }
363+
361364 to_delete = []
362365 # Scenario #1: User provided model names to delete
363366 if model_names :
364367 # Validate and filter models to delete based on provided names
365368 missing_models = []
366369 for name in model_names :
367- model_path = model_dir / name
368- if model_path .exists ():
369- to_delete .append (model_path )
370+ if name in model_path_by_name :
371+ to_delete .append (model_path_by_name [name ])
370372 else :
371373 missing_models .append (name )
372374
@@ -377,11 +379,11 @@ def remove(
377379
378380 # Scenario #2: User did not provide model names, prompt for selection
379381 else :
380- selections = ui .prompt_multi_select ("Select models to delete:" , [ model . name for model in available_models ] )
382+ selections = ui .prompt_multi_select ("Select models to delete:" , list ( model_path_by_name . keys ()) )
381383 if not selections :
382384 typer .echo ("No models selected for deletion." )
383385 return
384- to_delete = [model_dir / selection for selection in selections ]
386+ to_delete = [model_path_by_name [ selection ] for selection in selections ]
385387
386388 # Confirm deletion
387389 if to_delete and (
@@ -394,9 +396,29 @@ def remove(
394396 typer .echo ("Deletion canceled." )
395397
396398
397- def list_models (path : pathlib .Path ) -> list :
398- """List all models in the specified directory."""
399- return [file for file in path .iterdir () if file .is_file ()]
399+ def list_models (path : pathlib .Path ) -> list [tuple [str , pathlib .Path ]]:
400+ """List all models in the specified directory and its subdirectories.
401+
402+ Returns a list of tuples (model_type, file_path) where model_type is the
403+ subdirectory name with '_models' suffix stripped if present.
404+ Files directly in the models directory have an empty type.
405+ """
406+ models = []
407+ if not path .exists ():
408+ return models
409+
410+ for item in path .iterdir ():
411+ if item .is_file ():
412+ # Files directly in the models directory
413+ models .append (("" , item ))
414+ elif item .is_dir ():
415+ # For subdirectories, find all .safetensors files recursively
416+ model_type = item .name
417+ if model_type .endswith ("_models" ):
418+ model_type = model_type [:- 7 ] # Strip "_models" suffix
419+ for safetensor in item .rglob ("*.safetensors" ):
420+ models .append ((model_type , safetensor ))
421+ return models
400422
401423
402424@app .command ("list" )
@@ -418,6 +440,6 @@ def list_command(
418440 return
419441
420442 # Prepare data for table display
421- data = [(model .name , f"{ model .stat ().st_size // 1024 } KB" ) for model in models ]
422- column_names = ["Model Name" , "Size" ]
443+ data = [(model_type , model .name , f"{ model .stat ().st_size // 1024 } KB" ) for model_type , model in models ]
444+ column_names = ["Type" , " Model Name" , "Size" ]
423445 ui .display_table (data , column_names )
0 commit comments