enh: models endpoint optimization

Co-Authored-By: Classic298 <27028174+Classic298@users.noreply.github.com>

#20010
This commit is contained in:
Timothy Jaeryang Baek
2025-12-21 15:43:02 +04:00
parent 53c1ca64b7
commit 0dd2cfe1f2
2 changed files with 15 additions and 1 deletions

View File

@@ -357,6 +357,14 @@ class ModelsTable:
except Exception:
return None
def get_models_by_ids(self, ids: list[str]) -> list[ModelModel]:
try:
with get_db() as db:
models = db.query(Model).filter(Model.id.in_(ids)).all()
return [ModelModel.model_validate(model) for model in models]
except Exception:
return []
def toggle_model_by_id(self, id: str) -> Optional[ModelModel]:
with get_db() as db:
try: