mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(api): simplifiy list_model_records
handler
This commit is contained in:
parent
bc64cde6f9
commit
7cdd7b6ad7
@ -42,15 +42,12 @@ async def list_model_records(
|
|||||||
"""Get a list of models."""
|
"""Get a list of models."""
|
||||||
record_store = ApiDependencies.invoker.services.model_records
|
record_store = ApiDependencies.invoker.services.model_records
|
||||||
if base_models and len(base_models) > 0:
|
if base_models and len(base_models) > 0:
|
||||||
models_raw = []
|
found_models: list[AnyModelConfig] = []
|
||||||
for base_model in base_models:
|
for base_model in base_models:
|
||||||
models_raw.extend(
|
found_models.extend(record_store.search_by_attr(base_model=base_model, model_type=model_type))
|
||||||
[x.model_dump() for x in record_store.search_by_attr(base_model=base_model, model_type=model_type)]
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
models_raw = [x.model_dump() for x in record_store.search_by_attr(model_type=model_type)]
|
found_models = record_store.search_by_attr(model_type=model_type)
|
||||||
models = ModelsListValidator.validate_python({"models": models_raw})
|
return ModelsList(models=found_models)
|
||||||
return models
|
|
||||||
|
|
||||||
|
|
||||||
@model_records_router.get(
|
@model_records_router.get(
|
||||||
|
Loading…
Reference in New Issue
Block a user