enh: reintroduce model order/default models

This commit is contained in:
Timothy Jaeryang Baek
2024-11-26 00:55:58 -08:00
parent 29fac5ecca
commit 5fac25a002
12 changed files with 407 additions and 66 deletions

View File

@@ -1194,6 +1194,14 @@ async def get_models(user=Depends(get_verified_user)):
if "pipeline" not in model or model["pipeline"].get("type", None) != "filter"
]
model_order_list = webui_app.state.config.MODEL_ORDER_LIST
if model_order_list:
model_order_dict = {model_id: i for i, model_id in enumerate(model_order_list)}
# Sort models by order list priority, with fallback for those not in the list
models.sort(
key=lambda x: (model_order_dict.get(x["id"], float("inf")), x["name"])
)
# Filter out models that the user does not have access to
if user.role == "user":
filtered_models = []