diff --git a/backend/config.py b/backend/config.py index e10d23dca..729ecb2ca 100644 --- a/backend/config.py +++ b/backend/config.py @@ -808,10 +808,24 @@ USER_PERMISSIONS_CHAT_DELETION = ( os.environ.get("USER_PERMISSIONS_CHAT_DELETION", "True").lower() == "true" ) +USER_PERMISSIONS_CHAT_EDITING = ( + os.environ.get("USER_PERMISSIONS_CHAT_EDITING", "True").lower() == "true" +) + +USER_PERMISSIONS_CHAT_TEMPORARY = ( + os.environ.get("USER_PERMISSIONS_CHAT_TEMPORARY", "True").lower() == "true" +) + USER_PERMISSIONS = PersistentConfig( "USER_PERMISSIONS", "ui.user_permissions", - {"chat": {"deletion": USER_PERMISSIONS_CHAT_DELETION}}, + { + "chat": { + "deletion": USER_PERMISSIONS_CHAT_DELETION, + "editing": USER_PERMISSIONS_CHAT_EDITING, + "temporary": USER_PERMISSIONS_CHAT_TEMPORARY, + } + }, ) ENABLE_MODEL_FILTER = PersistentConfig( diff --git a/backend/main.py b/backend/main.py index f516bae35..fbd6a9439 100644 --- a/backend/main.py +++ b/backend/main.py @@ -68,6 +68,7 @@ from utils.utils import ( get_http_authorization_cred, get_password_hash, create_token, + decode_token, ) from utils.task import ( title_generation_template, @@ -1957,41 +1958,61 @@ async def update_pipeline_valves( @app.get("/api/config") -async def get_app_config(): +async def get_app_config(request: Request): + user = None + if "token" in request.cookies: + token = request.cookies.get("token") + data = decode_token(token) + if data is not None and "id" in data: + user = Users.get_user_by_id(data["id"]) + return { "status": True, "name": WEBUI_NAME, "version": VERSION, "default_locale": str(DEFAULT_LOCALE), - "default_models": webui_app.state.config.DEFAULT_MODELS, - "default_prompt_suggestions": webui_app.state.config.DEFAULT_PROMPT_SUGGESTIONS, - "features": { - "auth": WEBUI_AUTH, - "auth_trusted_header": bool(webui_app.state.AUTH_TRUSTED_EMAIL_HEADER), - "enable_signup": webui_app.state.config.ENABLE_SIGNUP, - "enable_login_form": webui_app.state.config.ENABLE_LOGIN_FORM, - "enable_web_search": rag_app.state.config.ENABLE_RAG_WEB_SEARCH, - "enable_image_generation": images_app.state.config.ENABLED, - "enable_community_sharing": webui_app.state.config.ENABLE_COMMUNITY_SHARING, - "enable_message_rating": webui_app.state.config.ENABLE_MESSAGE_RATING, - "enable_admin_export": ENABLE_ADMIN_EXPORT, - "enable_admin_chat_access": ENABLE_ADMIN_CHAT_ACCESS, - }, - "audio": { - "tts": { - "engine": audio_app.state.config.TTS_ENGINE, - "voice": audio_app.state.config.TTS_VOICE, - }, - "stt": { - "engine": audio_app.state.config.STT_ENGINE, - }, - }, "oauth": { "providers": { name: config.get("name", name) for name, config in OAUTH_PROVIDERS.items() } }, + "features": { + "auth": WEBUI_AUTH, + "auth_trusted_header": bool(webui_app.state.AUTH_TRUSTED_EMAIL_HEADER), + "enable_signup": webui_app.state.config.ENABLE_SIGNUP, + "enable_login_form": webui_app.state.config.ENABLE_LOGIN_FORM, + **( + { + "enable_web_search": rag_app.state.config.ENABLE_RAG_WEB_SEARCH, + "enable_image_generation": images_app.state.config.ENABLED, + "enable_community_sharing": webui_app.state.config.ENABLE_COMMUNITY_SHARING, + "enable_message_rating": webui_app.state.config.ENABLE_MESSAGE_RATING, + "enable_admin_export": ENABLE_ADMIN_EXPORT, + "enable_admin_chat_access": ENABLE_ADMIN_CHAT_ACCESS, + } + if user is not None + else {} + ), + }, + **( + { + "default_models": webui_app.state.config.DEFAULT_MODELS, + "default_prompt_suggestions": webui_app.state.config.DEFAULT_PROMPT_SUGGESTIONS, + "audio": { + "tts": { + "engine": audio_app.state.config.TTS_ENGINE, + "voice": audio_app.state.config.TTS_VOICE, + }, + "stt": { + "engine": audio_app.state.config.STT_ENGINE, + }, + }, + "permissions": {**webui_app.state.config.USER_PERMISSIONS}, + } + if user is not None + else {} + ), } diff --git a/src/lib/apis/index.ts b/src/lib/apis/index.ts index fc01c209d..0b4b9f148 100644 --- a/src/lib/apis/index.ts +++ b/src/lib/apis/index.ts @@ -665,6 +665,7 @@ export const getBackendConfig = async () => { const res = await fetch(`${WEBUI_BASE_URL}/api/config`, { method: 'GET', + credentials: 'include', headers: { 'Content-Type': 'application/json' } diff --git a/src/lib/components/admin/Settings/Users.svelte b/src/lib/components/admin/Settings/Users.svelte index d9d537c54..b23705c8a 100644 --- a/src/lib/components/admin/Settings/Users.svelte +++ b/src/lib/components/admin/Settings/Users.svelte @@ -18,7 +18,9 @@ let whitelistModels = ['']; let permissions = { chat: { - deletion: true + deletion: true, + edit: true, + temporary: true } }; @@ -92,6 +94,88 @@ {/if} + +