소스 검색

fix: user direct connections

Timothy Jaeryang Baek 2 달 전
부모
커밋
f20b7c2f33
1개의 변경된 파일7개의 추가작업 그리고 8개의 파일을 삭제
  1. 7 8
      backend/open_webui/utils/chat.py

+ 7 - 8
backend/open_webui/utils/chat.py

@@ -187,19 +187,18 @@ async def generate_chat_completion(
 
 
     model = models[model_id]
     model = models[model_id]
 
 
-    # Check if user has access to the model
-    if not bypass_filter and user.role == "user":
-        try:
-            check_model_access(user, model)
-        except Exception as e:
-            raise e
-
     if getattr(request.state, "direct", False):
     if getattr(request.state, "direct", False):
         return await generate_direct_chat_completion(
         return await generate_direct_chat_completion(
             request, form_data, user=user, models=models
             request, form_data, user=user, models=models
         )
         )
-
     else:
     else:
+        # Check if user has access to the model
+        if not bypass_filter and user.role == "user":
+            try:
+                check_model_access(user, model)
+            except Exception as e:
+                raise e
+
         if model["owned_by"] == "arena":
         if model["owned_by"] == "arena":
             model_ids = model.get("info", {}).get("meta", {}).get("model_ids")
             model_ids = model.get("info", {}).get("meta", {}).get("model_ids")
             filter_mode = model.get("info", {}).get("meta", {}).get("filter_mode")
             filter_mode = model.get("info", {}).get("meta", {}).get("filter_mode")