mirror of
https://github.com/open-webui/open-webui
synced 2025-04-26 01:00:20 +00:00
fix: BYPASS_MODEL_ACCESS_CONTROL env var
This commit is contained in:
parent
2db837cab4
commit
1349c6049e
@ -432,6 +432,7 @@ async def get_ollama_versions(url_idx: Optional[int] = None):
|
|||||||
else:
|
else:
|
||||||
return {"version": False}
|
return {"version": False}
|
||||||
|
|
||||||
|
|
||||||
@app.get("/api/ps")
|
@app.get("/api/ps")
|
||||||
async def get_ollama_loaded_models(user=Depends(get_verified_user)):
|
async def get_ollama_loaded_models(user=Depends(get_verified_user)):
|
||||||
"""
|
"""
|
||||||
@ -966,6 +967,9 @@ async def generate_chat_completion(
|
|||||||
user=Depends(get_verified_user),
|
user=Depends(get_verified_user),
|
||||||
bypass_filter: Optional[bool] = False,
|
bypass_filter: Optional[bool] = False,
|
||||||
):
|
):
|
||||||
|
if BYPASS_MODEL_ACCESS_CONTROL:
|
||||||
|
bypass_filter = True
|
||||||
|
|
||||||
payload = {**form_data.model_dump(exclude_none=True)}
|
payload = {**form_data.model_dump(exclude_none=True)}
|
||||||
log.debug(f"generate_chat_completion() - 1.payload = {payload}")
|
log.debug(f"generate_chat_completion() - 1.payload = {payload}")
|
||||||
if "metadata" in payload:
|
if "metadata" in payload:
|
||||||
@ -1090,7 +1094,7 @@ async def generate_openai_completion(
|
|||||||
payload = apply_model_params_to_body_openai(params, payload)
|
payload = apply_model_params_to_body_openai(params, payload)
|
||||||
|
|
||||||
# Check if user has access to the model
|
# Check if user has access to the model
|
||||||
if user.role == "user" and not BYPASS_MODEL_ACCESS_CONTROL:
|
if user.role == "user":
|
||||||
if not (
|
if not (
|
||||||
user.id == model_info.user_id
|
user.id == model_info.user_id
|
||||||
or has_access(
|
or has_access(
|
||||||
@ -1163,7 +1167,7 @@ async def generate_openai_chat_completion(
|
|||||||
payload = apply_model_system_prompt_to_body(params, payload, user)
|
payload = apply_model_system_prompt_to_body(params, payload, user)
|
||||||
|
|
||||||
# Check if user has access to the model
|
# Check if user has access to the model
|
||||||
if user.role == "user" and not BYPASS_MODEL_ACCESS_CONTROL:
|
if user.role == "user":
|
||||||
if not (
|
if not (
|
||||||
user.id == model_info.user_id
|
user.id == model_info.user_id
|
||||||
or has_access(
|
or has_access(
|
||||||
|
@ -1265,6 +1265,9 @@ async def get_base_models(user=Depends(get_admin_user)):
|
|||||||
async def generate_chat_completions(
|
async def generate_chat_completions(
|
||||||
form_data: dict, user=Depends(get_verified_user), bypass_filter: bool = False
|
form_data: dict, user=Depends(get_verified_user), bypass_filter: bool = False
|
||||||
):
|
):
|
||||||
|
if BYPASS_MODEL_ACCESS_CONTROL:
|
||||||
|
bypass_filter = True
|
||||||
|
|
||||||
model_list = await get_all_models()
|
model_list = await get_all_models()
|
||||||
models = {model["id"]: model for model in model_list}
|
models = {model["id"]: model for model in model_list}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user