mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(mm): hide missing models from API response
Check if the model file exists. If not, omit it from the list of models. Closes #6117
This commit is contained in:
parent
8584171a49
commit
d8258c8e2a
@ -117,10 +117,14 @@ async def list_model_records(
|
|||||||
found_models.extend(
|
found_models.extend(
|
||||||
record_store.search_by_attr(model_type=model_type, model_name=model_name, model_format=model_format)
|
record_store.search_by_attr(model_type=model_type, model_name=model_name, model_format=model_format)
|
||||||
)
|
)
|
||||||
for model in found_models:
|
|
||||||
|
models_path = ApiDependencies.invoker.services.configuration.models_path
|
||||||
|
existant_models = [m for m in found_models if (models_path / m.path).exists()]
|
||||||
|
|
||||||
|
for model in existant_models:
|
||||||
cover_image = ApiDependencies.invoker.services.model_images.get_url(model.key)
|
cover_image = ApiDependencies.invoker.services.model_images.get_url(model.key)
|
||||||
model.cover_image = cover_image
|
model.cover_image = cover_image
|
||||||
return ModelsList(models=found_models)
|
return ModelsList(models=existant_models)
|
||||||
|
|
||||||
|
|
||||||
@model_manager_router.get(
|
@model_manager_router.get(
|
||||||
|
Loading…
Reference in New Issue
Block a user