Spaces:
Paused
Paused
Download backend/open_webui/apps/webui/routers/evaluations.py from Manjuc21/open-webui: direct link, hf CLI and curl.
- Browser
- Download file 1.5 kB
-
https://huggingface.co/spaces/Manjuc21/open-webui/resolve/main/backend/open_webui/apps/webui/routers/evaluations.py
- Command line
-
hf download hf://spaces/Manjuc21/open-webui/backend/open_webui/apps/webui/routers/evaluations.py
-
curl -L -o evaluations.py https://huggingface.co/spaces/Manjuc21/open-webui/resolve/main/backend/open_webui/apps/webui/routers/evaluations.py
1.5 kB
| from typing import Optional | |
| from fastapi import APIRouter, Depends, HTTPException, status, Request | |
| from pydantic import BaseModel | |
| from open_webui.constants import ERROR_MESSAGES | |
| from open_webui.utils.utils import get_admin_user, get_verified_user | |
| router = APIRouter() | |
| ############################ | |
| # GetConfig | |
| ############################ | |
| async def get_config(request: Request, user=Depends(get_admin_user)): | |
| return { | |
| "ENABLE_EVALUATION_ARENA_MODELS": request.app.state.config.ENABLE_EVALUATION_ARENA_MODELS, | |
| "EVALUATION_ARENA_MODELS": request.app.state.config.EVALUATION_ARENA_MODELS, | |
| } | |
| ############################ | |
| # UpdateConfig | |
| ############################ | |
| class UpdateConfigForm(BaseModel): | |
| ENABLE_EVALUATION_ARENA_MODELS: Optional[bool] = None | |
| EVALUATION_ARENA_MODELS: Optional[list[dict]] = None | |
| async def update_config( | |
| request: Request, | |
| form_data: UpdateConfigForm, | |
| user=Depends(get_admin_user), | |
| ): | |
| config = request.app.state.config | |
| if form_data.ENABLE_EVALUATION_ARENA_MODELS is not None: | |
| config.ENABLE_EVALUATION_ARENA_MODELS = form_data.ENABLE_EVALUATION_ARENA_MODELS | |
| if form_data.EVALUATION_ARENA_MODELS is not None: | |
| config.EVALUATION_ARENA_MODELS = form_data.EVALUATION_ARENA_MODELS | |
| return { | |
| "ENABLE_EVALUATION_ARENA_MODELS": config.ENABLE_EVALUATION_ARENA_MODELS, | |
| "EVALUATION_ARENA_MODELS": config.EVALUATION_ARENA_MODELS, | |
| } | |