瀏覽代碼

fix: improve model sorting by handling missing names

Chono N 1 月之前
父節點
當前提交
23575825a1
共有 1 個文件被更改,包括 4 次插入1 次删除
  1. 4 1
      backend/open_webui/main.py

+ 4 - 1
backend/open_webui/main.py

@@ -1317,7 +1317,10 @@ async def get_models(
         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"])
+            key=lambda x: (
+                model_order_dict.get(x.get("id"), float("inf")),
+                (x.get("name") or "").lower()
+            )
         )
 
     # Filter out models that the user does not have access to