This commit is contained in:
Timothy Jaeryang Baek
2026-04-19 22:33:32 +09:00
parent 98c4f264e4
commit 42694c7c0c
10 changed files with 42 additions and 8 deletions
+6
View File
@@ -1630,6 +1630,12 @@ ENABLE_CALENDAR = PersistentConfig(
os.environ.get('ENABLE_CALENDAR', 'True').lower() == 'true',
)
ENABLE_AUTOMATIONS = PersistentConfig(
'ENABLE_AUTOMATIONS',
'automations.enable',
os.environ.get('ENABLE_AUTOMATIONS', 'True').lower() == 'true',
)
AUTOMATION_MAX_COUNT = PersistentConfig(
'AUTOMATION_MAX_COUNT',
'automations.max_count',
+3
View File
@@ -393,6 +393,7 @@ from open_webui.config import (
API_KEYS_ALLOWED_ENDPOINTS,
ENABLE_FOLDERS,
FOLDER_MAX_FILE_COUNT,
ENABLE_AUTOMATIONS,
AUTOMATION_MAX_COUNT,
AUTOMATION_MIN_INTERVAL,
ENABLE_CHANNELS,
@@ -900,6 +901,7 @@ app.state.config.BANNERS = WEBUI_BANNERS
app.state.config.ENABLE_FOLDERS = ENABLE_FOLDERS
app.state.config.FOLDER_MAX_FILE_COUNT = FOLDER_MAX_FILE_COUNT
app.state.config.ENABLE_AUTOMATIONS = ENABLE_AUTOMATIONS
app.state.config.AUTOMATION_MAX_COUNT = AUTOMATION_MAX_COUNT
app.state.config.AUTOMATION_MIN_INTERVAL = AUTOMATION_MIN_INTERVAL
app.state.config.ENABLE_CHANNELS = ENABLE_CHANNELS
@@ -2221,6 +2223,7 @@ async def get_app_config(request: Request):
'folder_max_file_count': app.state.config.FOLDER_MAX_FILE_COUNT,
'enable_channels': app.state.config.ENABLE_CHANNELS,
'enable_calendar': app.state.config.ENABLE_CALENDAR,
'enable_automations': app.state.config.ENABLE_AUTOMATIONS,
'enable_notes': app.state.config.ENABLE_NOTES,
'enable_web_search': app.state.config.ENABLE_WEB_SEARCH,
'enable_code_execution': app.state.config.ENABLE_CODE_EXECUTION,
+4
View File
@@ -971,6 +971,7 @@ async def get_admin_config(request: Request, user=Depends(get_admin_user)):
'FOLDER_MAX_FILE_COUNT': request.app.state.config.FOLDER_MAX_FILE_COUNT,
'AUTOMATION_MAX_COUNT': request.app.state.config.AUTOMATION_MAX_COUNT,
'AUTOMATION_MIN_INTERVAL': request.app.state.config.AUTOMATION_MIN_INTERVAL,
'ENABLE_AUTOMATIONS': request.app.state.config.ENABLE_AUTOMATIONS,
'ENABLE_CHANNELS': request.app.state.config.ENABLE_CHANNELS,
'ENABLE_CALENDAR': request.app.state.config.ENABLE_CALENDAR,
'ENABLE_MEMORIES': request.app.state.config.ENABLE_MEMORIES,
@@ -1000,6 +1001,7 @@ class AdminConfig(BaseModel):
FOLDER_MAX_FILE_COUNT: Optional[int | str] = None
AUTOMATION_MAX_COUNT: Optional[int | str] = None
AUTOMATION_MIN_INTERVAL: Optional[int | str] = None
ENABLE_AUTOMATIONS: bool
ENABLE_CHANNELS: bool
ENABLE_CALENDAR: bool
ENABLE_MEMORIES: bool
@@ -1032,6 +1034,7 @@ async def update_admin_config(request: Request, form_data: AdminConfig, user=Dep
request.app.state.config.AUTOMATION_MIN_INTERVAL = (
int(form_data.AUTOMATION_MIN_INTERVAL) if form_data.AUTOMATION_MIN_INTERVAL else ''
)
request.app.state.config.ENABLE_AUTOMATIONS = form_data.ENABLE_AUTOMATIONS
request.app.state.config.ENABLE_CHANNELS = form_data.ENABLE_CHANNELS
request.app.state.config.ENABLE_CALENDAR = form_data.ENABLE_CALENDAR
request.app.state.config.ENABLE_MEMORIES = form_data.ENABLE_MEMORIES
@@ -1076,6 +1079,7 @@ async def update_admin_config(request: Request, form_data: AdminConfig, user=Dep
'FOLDER_MAX_FILE_COUNT': request.app.state.config.FOLDER_MAX_FILE_COUNT,
'AUTOMATION_MAX_COUNT': request.app.state.config.AUTOMATION_MAX_COUNT,
'AUTOMATION_MIN_INTERVAL': request.app.state.config.AUTOMATION_MIN_INTERVAL,
'ENABLE_AUTOMATIONS': request.app.state.config.ENABLE_AUTOMATIONS,
'ENABLE_CHANNELS': request.app.state.config.ENABLE_CHANNELS,
'ENABLE_CALENDAR': request.app.state.config.ENABLE_CALENDAR,
'ENABLE_MEMORIES': request.app.state.config.ENABLE_MEMORIES,
@@ -39,6 +39,11 @@ PAGE_ITEM_COUNT = 30
async def check_automations_permission(request, user):
if not request.app.state.config.ENABLE_AUTOMATIONS:
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail=ERROR_MESSAGES.UNAUTHORIZED,
)
if user.role != 'admin' and not await has_permission(
user.id, 'features.automations', request.app.state.config.USER_PERMISSIONS
):
+4
View File
@@ -126,6 +126,10 @@ async def automation_worker_loop(app) -> None:
log.info(f'Automation worker started (poll interval: {AUTOMATION_POLL_INTERVAL}s)')
while True:
try:
if not getattr(app.state.config, 'ENABLE_AUTOMATIONS', False):
await asyncio.sleep(AUTOMATION_POLL_INTERVAL)
continue
async with get_async_db() as db:
batch = await Automations.claim_due(int(time.time_ns()), limit=10, db=db)
if batch:
+5 -1
View File
@@ -551,7 +551,11 @@ async def get_builtin_tools(
builtin_functions.extend([create_tasks, update_task])
# Automation tools - create and manage scheduled automations from chat
if is_builtin_tool_enabled('automations') and await has_user_permission('automations'):
if (
is_builtin_tool_enabled('automations')
and getattr(request.app.state.config, 'ENABLE_AUTOMATIONS', False)
and await has_user_permission('automations')
):
builtin_functions.extend(
[create_automation, update_automation, list_automations, toggle_automation, delete_automation]
)
@@ -740,6 +740,14 @@
</div>
{/if}
<div class="mb-2.5 flex w-full items-center justify-between pr-2">
<div class=" self-center text-xs font-medium">
{$i18n.t('Memories')} ({$i18n.t('Beta')})
</div>
<Switch bind:state={adminConfig.ENABLE_MEMORIES} />
</div>
<div class="mb-2.5 flex w-full items-center justify-between pr-2">
<div class=" self-center text-xs font-medium">
{$i18n.t('Notes')} ({$i18n.t('Beta')})
@@ -758,7 +766,7 @@
<div class="mb-2.5 flex w-full items-center justify-between pr-2">
<div class=" self-center text-xs font-medium">
{$i18n.t('Calendar')} ({$i18n.t('Beta')})
{$i18n.t('Calendar')}
</div>
<Switch bind:state={adminConfig.ENABLE_CALENDAR} />
@@ -766,10 +774,10 @@
<div class="mb-2.5 flex w-full items-center justify-between pr-2">
<div class=" self-center text-xs font-medium">
{$i18n.t('Memories')} ({$i18n.t('Beta')})
{$i18n.t('Automations')}
</div>
<Switch bind:state={adminConfig.ENABLE_MEMORIES} />
<Switch bind:state={adminConfig.ENABLE_AUTOMATIONS} />
</div>
<div class="mb-2.5 flex w-full items-center justify-between pr-2">
@@ -214,7 +214,7 @@
<div class=" self-center truncate">{$i18n.t('Settings')}</div>
</button>
{#if $user?.role === 'admin' || $user?.permissions?.features?.automations}
{#if $config?.features?.enable_automations && ($user?.role === 'admin' || $user?.permissions?.features?.automations)}
<a
href="/automations"
draggable="false"
+1 -1
View File
@@ -165,7 +165,7 @@
};
onMount(async () => {
if ($user?.role !== 'admin' && !($user?.permissions?.features?.automations ?? false)) {
if (!$config?.features?.enable_automations || ($user?.role !== 'admin' && !($user?.permissions?.features?.automations ?? false))) {
goto('/');
return;
}
@@ -4,7 +4,7 @@
import { onMount, getContext } from 'svelte';
import { page } from '$app/stores';
import { user, showSidebar } from '$lib/stores';
import { user, showSidebar, config } from '$lib/stores';
import { getAutomationById } from '$lib/apis/automations';
import AutomationEditor from '$lib/components/automations/AutomationEditor.svelte';
@@ -18,7 +18,7 @@
$: automationId = $page.params.id;
onMount(async () => {
if ($user?.role !== 'admin' && !($user?.permissions?.features?.automations ?? false)) {
if (!$config?.features?.enable_automations || ($user?.role !== 'admin' && !($user?.permissions?.features?.automations ?? false))) {
goto('/');
return;
}