From 0481ad7c2e876bc8f8ef697e93ce3efb54edd9e1 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Fri, 4 Dec 2026 06:30:25 +0400 Subject: [PATCH] refac --- backend/open_webui/config.py | 20 +- backend/open_webui/models/config.py | 2 +- backend/open_webui/routers/tasks.py | 102 ++-- .../open_webui/utils/context_compaction.py | 26 +- backend/open_webui/utils/middleware.py | 26 +- backend/open_webui/utils/task.py | 20 +- .../admin/Settings/AdminTabIcon.svelte | 2 +- .../components/admin/Settings/Tasks.svelte | 34 +- .../admin/Users/Groups/EditGroupModal.svelte | 16 +- .../admin/Users/Groups/General.svelte | 210 +++------ .../admin/Users/Groups/Permissions.svelte | 444 +++++++++--------- src/lib/components/chat/SettingsModal.svelte | 16 +- src/lib/i18n/locales/ar-BH/translation.json | 15 +- src/lib/i18n/locales/ar/translation.json | 15 +- src/lib/i18n/locales/az-AZ/translation.json | 15 +- src/lib/i18n/locales/bg-BG/translation.json | 15 +- src/lib/i18n/locales/bn-BD/translation.json | 15 +- src/lib/i18n/locales/bo-TB/translation.json | 15 +- src/lib/i18n/locales/bs-BA/translation.json | 15 +- src/lib/i18n/locales/ca-ES/translation.json | 15 +- src/lib/i18n/locales/ceb-PH/translation.json | 15 +- src/lib/i18n/locales/cs-CZ/translation.json | 15 +- src/lib/i18n/locales/da-DK/translation.json | 15 +- src/lib/i18n/locales/de-DE/translation.json | 15 +- src/lib/i18n/locales/dg-DG/translation.json | 15 +- src/lib/i18n/locales/el-GR/translation.json | 15 +- src/lib/i18n/locales/en-GB/translation.json | 15 +- src/lib/i18n/locales/en-US/translation.json | 15 +- src/lib/i18n/locales/es-ES/translation.json | 15 +- src/lib/i18n/locales/et-EE/translation.json | 15 +- src/lib/i18n/locales/eu-ES/translation.json | 15 +- src/lib/i18n/locales/fa-IR/translation.json | 15 +- src/lib/i18n/locales/fi-FI/translation.json | 15 +- src/lib/i18n/locales/fil-PH/translation.json | 15 +- src/lib/i18n/locales/fo-FO/translation.json | 15 +- src/lib/i18n/locales/fr-CA/translation.json | 15 +- src/lib/i18n/locales/fr-FR/translation.json | 15 +- src/lib/i18n/locales/gl-ES/translation.json | 15 +- src/lib/i18n/locales/he-IL/translation.json | 15 +- src/lib/i18n/locales/hi-IN/translation.json | 15 +- src/lib/i18n/locales/hr-HR/translation.json | 15 +- src/lib/i18n/locales/hu-HU/translation.json | 15 +- src/lib/i18n/locales/id-ID/translation.json | 15 +- src/lib/i18n/locales/ie-GA/translation.json | 15 +- src/lib/i18n/locales/it-IT/translation.json | 15 +- src/lib/i18n/locales/ja-JP/translation.json | 15 +- src/lib/i18n/locales/ka-GE/translation.json | 15 +- src/lib/i18n/locales/kab-DZ/translation.json | 15 +- src/lib/i18n/locales/ko-KR/translation.json | 15 +- src/lib/i18n/locales/lt-LT/translation.json | 15 +- src/lib/i18n/locales/lv-LV/translation.json | 15 +- src/lib/i18n/locales/ms-MY/translation.json | 15 +- src/lib/i18n/locales/nb-NO/translation.json | 15 +- src/lib/i18n/locales/nl-NL/translation.json | 15 +- src/lib/i18n/locales/pa-IN/translation.json | 15 +- src/lib/i18n/locales/pl-PL/translation.json | 15 +- src/lib/i18n/locales/pt-BR/translation.json | 15 +- src/lib/i18n/locales/pt-PT/translation.json | 15 +- src/lib/i18n/locales/ro-RO/translation.json | 15 +- src/lib/i18n/locales/ru-RU/translation.json | 15 +- src/lib/i18n/locales/sk-SK/translation.json | 15 +- src/lib/i18n/locales/sl-SI/translation.json | 15 +- src/lib/i18n/locales/sr-RS/translation.json | 15 +- src/lib/i18n/locales/sv-SE/translation.json | 15 +- src/lib/i18n/locales/ta-IN/translation.json | 15 +- src/lib/i18n/locales/th-TH/translation.json | 15 +- src/lib/i18n/locales/tk-TM/translation.json | 15 +- src/lib/i18n/locales/tr-TR/translation.json | 15 +- src/lib/i18n/locales/ug-CN/translation.json | 15 +- src/lib/i18n/locales/uk-UA/translation.json | 15 +- src/lib/i18n/locales/ur-PK/translation.json | 15 +- .../i18n/locales/uz-Cyrl-UZ/translation.json | 15 +- .../i18n/locales/uz-Latn-UZ/translation.json | 15 +- src/lib/i18n/locales/vi-VN/translation.json | 15 +- src/lib/i18n/locales/zh-CN/translation.json | 15 +- src/lib/i18n/locales/zh-TW/translation.json | 15 +- src/lib/utils/settings-routes.ts | 5 +- 77 files changed, 816 insertions(+), 1067 deletions(-) diff --git a/backend/open_webui/config.py b/backend/open_webui/config.py index c51b3c6aa5..6c03030e85 100644 --- a/backend/open_webui/config.py +++ b/backend/open_webui/config.py @@ -43,6 +43,7 @@ from open_webui.utils.json_codec import JSONCodec async def seed_registered_defaults(): await Config.rename_prefix('rag.web', 'web') await Config.rename_prefix('terminal_server', 'machines') # Terminals became Machines + await Config.rename_prefix('task.model', 'system_model') # Task Model became System Model await Config.repair_config_rows() await Config.seed_defaults(DEFAULT_CONFIG) @@ -2259,17 +2260,18 @@ ADMIN_EMAIL = os.getenv('ADMIN_EMAIL', None) # Tasks -TASK_MODEL = os.getenv('TASK_MODEL', '') +# SYSTEM MODEL (formerly Task Model: stored rows are renamed on load; the TASK_MODEL* variables are fallbacks) +SYSTEM_MODEL = os.getenv('SYSTEM_MODEL') or os.getenv('TASK_MODEL', '') -TASK_MODEL_EXTERNAL = os.getenv('TASK_MODEL_EXTERNAL', '') +SYSTEM_MODEL_EXTERNAL = os.getenv('SYSTEM_MODEL_EXTERNAL') or os.getenv('TASK_MODEL_EXTERNAL', '') try: - task_model_params = JSONCodec.loads(os.getenv('TASK_MODEL_PARAMS', '{}')) + system_model_params = JSONCodec.loads(os.getenv('SYSTEM_MODEL_PARAMS') or os.getenv('TASK_MODEL_PARAMS', '{}')) except Exception as e: - log.exception(f'Error loading TASK_MODEL_PARAMS: {e}') - task_model_params = {} + log.exception(f'Error loading SYSTEM_MODEL_PARAMS: {e}') + system_model_params = {} -TASK_MODEL_PARAMS = task_model_params +SYSTEM_MODEL_PARAMS = system_model_params CONTEXT_COMPACTION_MODEL = os.getenv('CONTEXT_COMPACTION_MODEL', '') @@ -3330,9 +3332,9 @@ DEFAULT_CONFIG = { 'ui.banners': WEBUI_BANNERS, 'auth.admin.show': SHOW_ADMIN_DETAILS, 'auth.admin.email': ADMIN_EMAIL, - 'task.model.default': TASK_MODEL, - 'task.model.external': TASK_MODEL_EXTERNAL, - 'task.model.params': TASK_MODEL_PARAMS, + 'system_model.default': SYSTEM_MODEL, + 'system_model.external': SYSTEM_MODEL_EXTERNAL, + 'system_model.params': SYSTEM_MODEL_PARAMS, 'chat.context_compaction.model': CONTEXT_COMPACTION_MODEL, 'chat.context_compaction.enable': ENABLE_CONTEXT_COMPACTION, 'chat.context_compaction.token_threshold': CONTEXT_COMPACTION_TOKEN_THRESHOLD, diff --git a/backend/open_webui/models/config.py b/backend/open_webui/models/config.py index 3d00c528f6..b59c67c5d6 100644 --- a/backend/open_webui/models/config.py +++ b/backend/open_webui/models/config.py @@ -35,7 +35,7 @@ DICT_CONFIG_KEY_ALIASES = { 'audio.realtime.input_params': ('AUDIO_REALTIME_INPUT_PARAMS',), 'models.default_metadata': ('DEFAULT_MODEL_METADATA',), 'models.default_params': ('DEFAULT_MODEL_PARAMS',), - 'task.model.params': ('TASK_MODEL_PARAMS',), + 'system_model.params': ('TASK_MODEL_PARAMS',), 'ui.default_interface_settings': ('DEFAULT_INTERFACE_SETTINGS',), 'user.permissions': ('USER_PERMISSIONS',), } diff --git a/backend/open_webui/routers/tasks.py b/backend/open_webui/routers/tasks.py index 9345f7832a..a56623a81e 100644 --- a/backend/open_webui/routers/tasks.py +++ b/backend/open_webui/routers/tasks.py @@ -27,7 +27,7 @@ from open_webui.utils.task import ( autocomplete_generation_template, emoji_generation_template, follow_up_generation_template, - get_task_model_id, + get_system_model_id, image_prompt_generation_template, moa_response_generation_template, query_generation_template, @@ -41,9 +41,9 @@ log = logging.getLogger(__name__) router = APIRouter() TASK_CONFIG_KEYS = { - 'TASK_MODEL': 'task.model.default', - 'TASK_MODEL_EXTERNAL': 'task.model.external', - 'TASK_MODEL_PARAMS': 'task.model.params', + 'SYSTEM_MODEL': 'system_model.default', + 'SYSTEM_MODEL_EXTERNAL': 'system_model.external', + 'SYSTEM_MODEL_PARAMS': 'system_model.params', 'TITLE_GENERATION_PROMPT_TEMPLATE': 'task.title.prompt_template', 'IMAGE_PROMPT_GENERATION_PROMPT_TEMPLATE': 'task.image.prompt_template', 'ENABLE_AUTOCOMPLETE_GENERATION': 'task.autocomplete.enable', @@ -72,28 +72,28 @@ def config_updates(data: dict, key_map: dict[str, str]) -> dict: return {key_map[field]: value for field, value in data.items() if field in key_map} -def apply_task_model_params(payload: dict, models: dict, task_model_id: str, params: dict | None = None) -> dict: - model = models.get(payload.get('model')) or models.get(task_model_id) +def apply_system_model_params(payload: dict, models: dict, system_model_id: str, params: dict | None = None) -> dict: + model = models.get(payload.get('model')) or models.get(system_model_id) if not model or (not params and not payload.get('params')): return payload return apply_params_to_form_data(payload, model, params or None) -async def get_task_model_generation_config(default_model_id: str, models) -> tuple[str, dict]: +async def get_system_model_generation_config(default_model_id: str, models) -> tuple[str, dict]: config = await Config.get_many( - 'task.model.default', - 'task.model.external', - 'task.model.params', + 'system_model.default', + 'system_model.external', + 'system_model.params', ) - params = config.get('task.model.params') or {} + params = config.get('system_model.params') or {} if not isinstance(params, dict): params = {} return ( - get_task_model_id( + get_system_model_id( default_model_id, - config.get('task.model.default'), - config.get('task.model.external'), + config.get('system_model.default'), + config.get('system_model.external'), models, ), {key: value for key, value in params.items() if value is not None and value != ''}, @@ -109,9 +109,9 @@ async def get_task_config(request: Request, user=Depends(get_verified_user)): class TaskConfigForm(BaseModel): - TASK_MODEL: Optional[str] - TASK_MODEL_EXTERNAL: Optional[str] - TASK_MODEL_PARAMS: dict | None = None + SYSTEM_MODEL: Optional[str] + SYSTEM_MODEL_EXTERNAL: Optional[str] + SYSTEM_MODEL_PARAMS: dict | None = None ENABLE_TITLE_GENERATION: bool TITLE_GENERATION_PROMPT_TEMPLATE: str IMAGE_PROMPT_GENERATION_PROMPT_TEMPLATE: str @@ -161,11 +161,11 @@ async def generate_title(request: Request, form_data: dict, user=Depends(get_ver detail=ERROR_MESSAGES.MODEL_NOT_FOUND(), ) - task_model_id, task_model_params = await get_task_model_generation_config(model_id, models) - if task_model_id not in models or task_model_id.startswith('agent:'): - return JSONResponse(content={'detail': 'No task model configured for agent chat titles'}) + system_model_id, system_model_params = await get_system_model_generation_config(model_id, models) + if system_model_id not in models or system_model_id.startswith('agent:'): + return JSONResponse(content={'detail': 'No system model configured for agent chat titles'}) - log.debug('generating chat title using model %s for user %s ', task_model_id, user.email) + log.debug('generating chat title using model %s for user %s ', system_model_id, user.email) title_template = await Config.get('task.title.prompt_template') if title_template != '': @@ -174,12 +174,12 @@ async def generate_title(request: Request, form_data: dict, user=Depends(get_ver template = DEFAULT_TITLE_GENERATION_PROMPT_TEMPLATE content = await title_generation_template(template, form_data['messages'], user) - task_model_params = task_model_params or { - 'max_tokens': models[task_model_id].get('info', {}).get('params', {}).get('max_tokens', 1000) + system_model_params = system_model_params or { + 'max_tokens': models[system_model_id].get('info', {}).get('params', {}).get('max_tokens', 1000) } payload = { - 'model': task_model_id, + 'model': system_model_id, 'messages': [{'role': 'user', 'content': content}], 'stream': False, 'metadata': { @@ -196,7 +196,7 @@ async def generate_title(request: Request, form_data: dict, user=Depends(get_ver except Exception as e: raise e - payload = apply_task_model_params(payload, models, task_model_id, task_model_params) + payload = apply_system_model_params(payload, models, system_model_id, system_model_params) try: return await generate_chat_completion(request, form_data=payload, user=user) @@ -225,9 +225,9 @@ async def generate_follow_ups(request: Request, form_data: dict, user=Depends(ge detail=ERROR_MESSAGES.MODEL_NOT_FOUND(), ) - task_model_id, task_model_params = await get_task_model_generation_config(model_id, models) + system_model_id, system_model_params = await get_system_model_generation_config(model_id, models) - log.debug('generating chat title using model %s for user %s ', task_model_id, user.email) + log.debug('generating chat title using model %s for user %s ', system_model_id, user.email) follow_up_template = await Config.get('task.follow_up.prompt_template') if follow_up_template != '': @@ -240,7 +240,7 @@ async def generate_follow_ups(request: Request, form_data: dict, user=Depends(ge ) payload = { - 'model': task_model_id, + 'model': system_model_id, 'messages': [{'role': 'user', 'content': content}], 'stream': False, 'metadata': { @@ -257,7 +257,7 @@ async def generate_follow_ups(request: Request, form_data: dict, user=Depends(ge except Exception as e: raise e - payload = apply_task_model_params(payload, models, task_model_id, task_model_params) + payload = apply_system_model_params(payload, models, system_model_id, system_model_params) try: return await generate_chat_completion(request, form_data=payload, user=user) @@ -286,9 +286,9 @@ async def generate_chat_tags(request: Request, form_data: dict, user=Depends(get detail=ERROR_MESSAGES.MODEL_NOT_FOUND(), ) - task_model_id, task_model_params = await get_task_model_generation_config(model_id, models) + system_model_id, system_model_params = await get_system_model_generation_config(model_id, models) - log.debug('generating chat tags using model %s for user %s ', task_model_id, user.email) + log.debug('generating chat tags using model %s for user %s ', system_model_id, user.email) tags_template = await Config.get('task.tags.prompt_template') if tags_template != '': @@ -299,7 +299,7 @@ async def generate_chat_tags(request: Request, form_data: dict, user=Depends(get content = await tags_generation_template(template, form_data['messages'], user) payload = { - 'model': task_model_id, + 'model': system_model_id, 'messages': [{'role': 'user', 'content': content}], 'stream': False, 'metadata': { @@ -316,7 +316,7 @@ async def generate_chat_tags(request: Request, form_data: dict, user=Depends(get except Exception as e: raise e - payload = apply_task_model_params(payload, models, task_model_id, task_model_params) + payload = apply_system_model_params(payload, models, system_model_id, system_model_params) try: return await generate_chat_completion(request, form_data=payload, user=user) @@ -339,9 +339,9 @@ async def generate_image_prompt(request: Request, form_data: dict, user=Depends( detail=ERROR_MESSAGES.MODEL_NOT_FOUND(), ) - task_model_id, task_model_params = await get_task_model_generation_config(model_id, models) + system_model_id, system_model_params = await get_system_model_generation_config(model_id, models) - log.debug('generating image prompt using model %s for user %s ', task_model_id, user.email) + log.debug('generating image prompt using model %s for user %s ', system_model_id, user.email) image_prompt_template = await Config.get('task.image.prompt_template') if image_prompt_template != '': @@ -352,7 +352,7 @@ async def generate_image_prompt(request: Request, form_data: dict, user=Depends( content = await image_prompt_generation_template(template, form_data['messages'], user) payload = { - 'model': task_model_id, + 'model': system_model_id, 'messages': [{'role': 'user', 'content': content}], 'stream': False, 'metadata': { @@ -369,7 +369,7 @@ async def generate_image_prompt(request: Request, form_data: dict, user=Depends( except Exception as e: raise e - payload = apply_task_model_params(payload, models, task_model_id, task_model_params) + payload = apply_system_model_params(payload, models, system_model_id, system_model_params) try: return await generate_chat_completion(request, form_data=payload, user=user) @@ -410,9 +410,9 @@ async def generate_queries(request: Request, form_data: dict, user=Depends(get_v detail=ERROR_MESSAGES.MODEL_NOT_FOUND(), ) - task_model_id, task_model_params = await get_task_model_generation_config(model_id, models) + system_model_id, system_model_params = await get_system_model_generation_config(model_id, models) - log.debug('generating %s queries using model %s for user %s', type, task_model_id, user.email) + log.debug('generating %s queries using model %s for user %s', type, system_model_id, user.email) query_template = await Config.get('task.query.prompt_template') if query_template.strip() != '': @@ -423,7 +423,7 @@ async def generate_queries(request: Request, form_data: dict, user=Depends(get_v content = await query_generation_template(template, form_data['messages'], user) payload = { - 'model': task_model_id, + 'model': system_model_id, 'messages': [{'role': 'user', 'content': content}], 'stream': False, 'metadata': { @@ -440,7 +440,7 @@ async def generate_queries(request: Request, form_data: dict, user=Depends(get_v except Exception as e: raise e - payload = apply_task_model_params(payload, models, task_model_id, task_model_params) + payload = apply_system_model_params(payload, models, system_model_id, system_model_params) try: return await generate_chat_completion(request, form_data=payload, user=user) @@ -480,11 +480,11 @@ async def generate_autocompletion(request: Request, form_data: dict, user=Depend detail=ERROR_MESSAGES.MODEL_NOT_FOUND(), ) - task_model_id, task_model_params = await get_task_model_generation_config(model_id, models) - if task_model_id not in models or task_model_id.startswith('agent:'): - return JSONResponse(content={'detail': 'No task model configured for agent autocompletion'}) + system_model_id, system_model_params = await get_system_model_generation_config(model_id, models) + if system_model_id not in models or system_model_id.startswith('agent:'): + return JSONResponse(content={'detail': 'No system model configured for agent autocompletion'}) - log.debug('generating autocompletion using model %s for user %s', task_model_id, user.email) + log.debug('generating autocompletion using model %s for user %s', system_model_id, user.email) autocomplete_template = await Config.get('task.autocomplete.prompt_template') if autocomplete_template.strip() != '': @@ -495,7 +495,7 @@ async def generate_autocompletion(request: Request, form_data: dict, user=Depend content = await autocomplete_generation_template(template, prompt, messages, type, user) payload = { - 'model': task_model_id, + 'model': system_model_id, 'messages': [{'role': 'user', 'content': content}], 'stream': False, 'metadata': { @@ -512,7 +512,7 @@ async def generate_autocompletion(request: Request, form_data: dict, user=Depend except Exception as e: raise e - payload = apply_task_model_params(payload, models, task_model_id, task_model_params) + payload = apply_system_model_params(payload, models, system_model_id, system_model_params) try: return await generate_chat_completion(request, form_data=payload, user=user) @@ -535,16 +535,16 @@ async def generate_emoji(request: Request, form_data: dict, user=Depends(get_ver detail=ERROR_MESSAGES.MODEL_NOT_FOUND(), ) - task_model_id, _ = await get_task_model_generation_config(model_id, models) + system_model_id, _ = await get_system_model_generation_config(model_id, models) - log.debug('generating emoji using model %s for user %s ', task_model_id, user.email) + log.debug('generating emoji using model %s for user %s ', system_model_id, user.email) template = DEFAULT_EMOJI_GENERATION_PROMPT_TEMPLATE content = await emoji_generation_template(template, form_data['prompt'], user) payload = { - 'model': task_model_id, + 'model': system_model_id, 'messages': [{'role': 'user', 'content': content}], 'stream': False, 'metadata': { @@ -561,7 +561,7 @@ async def generate_emoji(request: Request, form_data: dict, user=Depends(get_ver except Exception as e: raise e - payload = apply_task_model_params(payload, models, task_model_id, {'max_tokens': 4}) + payload = apply_system_model_params(payload, models, system_model_id, {'max_tokens': 4}) try: return await generate_chat_completion(request, form_data=payload, user=user) diff --git a/backend/open_webui/utils/context_compaction.py b/backend/open_webui/utils/context_compaction.py index bc396707eb..1314ef1600 100644 --- a/backend/open_webui/utils/context_compaction.py +++ b/backend/open_webui/utils/context_compaction.py @@ -417,12 +417,12 @@ async def _generate_summary( models = await add_tether_model(request, user, model_id, models) task_config = await Config.get_many( - 'task.model.params', + 'system_model.params', 'chat.context_compaction.model', ) context_compaction_model = task_config.get('chat.context_compaction.model') - task_model_id = context_compaction_model if context_compaction_model in models else model_id - if task_model_id not in models: + compaction_model_id = context_compaction_model if context_compaction_model in models else model_id + if compaction_model_id not in models: raise ValueError('No available model for context compaction') summary_prompt_template = summary_prompt_template.strip() or DEFAULT_CONTEXT_COMPACTION_PROMPT @@ -453,10 +453,12 @@ async def _generate_summary( prompt = prompt_variables_template(prompt, {'{{PREVIOUS_SUMMARY}}': summary or ''}) return await prompt_template(prompt, user) - task_model_params = task_config.get('task.model.params') or {} - if not isinstance(task_model_params, dict): - task_model_params = {} - task_model_params = {key: value for key, value in task_model_params.items() if value is not None and value != ''} + system_model_params = task_config.get('system_model.params') or {} + if not isinstance(system_model_params, dict): + system_model_params = {} + system_model_params = { + key: value for key, value in system_model_params.items() if value is not None and value != '' + } metadata = { **(request.state.metadata if hasattr(request.state, 'metadata') else {}), @@ -467,7 +469,7 @@ async def _generate_summary( # A repeated or transformed boundary cannot safely identify the history to discard. if ( form_data - and task_model_id == model_id + and compaction_model_id == model_id and has_unique_prefix and sum(_message_prefix(message) == boundary_prefix for message in form_data['messages']) == 1 ): @@ -486,7 +488,7 @@ async def _generate_summary( ) ) payload = { - 'model': task_model_id, + 'model': compaction_model_id, 'messages': [*copy.deepcopy(form_data['messages']), {'role': 'user', 'content': prompt}], 'stream': False, 'metadata': metadata, @@ -496,7 +498,7 @@ async def _generate_summary( try: response = await generate_chat_completion( request, - form_data=apply_params_to_form_data(payload, models[task_model_id], task_model_params), + form_data=apply_params_to_form_data(payload, models[compaction_model_id], system_model_params), user=user, bypass_system_prompt=bypass_system_prompt, ) @@ -508,13 +510,13 @@ async def _generate_summary( prompt = await render_prompt(summary_prompt_template) payload = { - 'model': task_model_id, + 'model': compaction_model_id, 'messages': [{'role': 'user', 'content': prompt}], 'stream': False, 'metadata': metadata, } - payload = apply_params_to_form_data(payload, models[task_model_id], task_model_params) + payload = apply_params_to_form_data(payload, models[compaction_model_id], system_model_params) response = await generate_chat_completion(request, form_data=payload, user=user) text = _response_text(response).strip() if text: diff --git a/backend/open_webui/utils/middleware.py b/backend/open_webui/utils/middleware.py index c0ebf6aeec..f96c0be969 100644 --- a/backend/open_webui/utils/middleware.py +++ b/backend/open_webui/utils/middleware.py @@ -160,7 +160,7 @@ from open_webui.utils.skills import ( strip_skill_mentions, ) from open_webui.utils.task import ( - get_task_model_id, + get_system_model_id, parse_follow_ups, rag_template, tools_function_calling_generation_template, @@ -1267,7 +1267,7 @@ async def chat_completion_tools_handler( content = response['choices'][0]['message']['content'] return content - def get_tools_function_calling_payload(messages, task_model_id, content): + def get_tools_function_calling_payload(messages, system_model_id, content): user_message = get_last_user_message(messages) if user_message and messages and messages[-1]['role'] == 'user': @@ -1282,7 +1282,7 @@ async def chat_completion_tools_handler( prompt = f'History:\n{chat_history}\nQuery: {user_message}' if chat_history else f'Query: {user_message}' return { - 'model': task_model_id, + 'model': system_model_id, 'messages': [ {'role': 'system', 'content': content}, {'role': 'user', 'content': prompt}, @@ -1297,14 +1297,14 @@ async def chat_completion_tools_handler( # One batched SELECT instead of four sequential round trips. task_config = await Config.get_many( - 'task.model.default', - 'task.model.external', + 'system_model.default', + 'system_model.external', 'task.tools.prompt_template', ) - task_model_id = get_task_model_id( + system_model_id = get_system_model_id( body['model'], - task_config.get('task.model.default'), - task_config.get('task.model.external'), + task_config.get('system_model.default'), + task_config.get('system_model.external'), models, ) @@ -1321,7 +1321,7 @@ async def chat_completion_tools_handler( template = DEFAULT_TOOLS_FUNCTION_CALLING_PROMPT_TEMPLATE tools_function_calling_prompt = tools_function_calling_generation_template(template, tools_specs) - payload = get_tools_function_calling_payload(body['messages'], task_model_id, tools_function_calling_prompt) + payload = get_tools_function_calling_payload(body['messages'], system_model_id, tools_function_calling_prompt) try: response = await generate_chat_completion(request, form_data=payload, user=user) @@ -2519,10 +2519,10 @@ async def process_chat_payload(request, form_data, user, metadata, model): models = await add_tether_model(request, user, form_data.get('model')) - task_model_id = get_task_model_id( + system_model_id = get_system_model_id( form_data['model'], - await Config.get('task.model.default'), - await Config.get('task.model.external'), + await Config.get('system_model.default'), + await Config.get('system_model.external'), models, ) @@ -3003,7 +3003,7 @@ async def process_chat_payload(request, form_data, user, metadata, model): user, { **extra_params, - '__model__': models[task_model_id], + '__model__': models[system_model_id], '__messages__': form_data['messages'], '__files__': metadata.get('files') or [], }, diff --git a/backend/open_webui/utils/task.py b/backend/open_webui/utils/task.py index d34bec0f65..2fa371cb9b 100644 --- a/backend/open_webui/utils/task.py +++ b/backend/open_webui/utils/task.py @@ -14,27 +14,27 @@ log = logging.getLogger(__name__) # Let the right tool be given for the work at hand, # not the one that flatters, but the one that serves. -def get_task_model_id(default_model_id: str, task_model: str, task_model_external: str, models) -> str: +def get_system_model_id(default_model_id: str, system_model: str, system_model_external: str, models) -> str: if default_model_id.startswith('agent:'): # Agent sessions cannot serve ordinary completion requests for background tasks. return next( ( model - for model in (task_model_external, task_model) + for model in (system_model_external, system_model) if model and model in models and not model.startswith('agent:') ), default_model_id, ) - task_model_id = default_model_id - # Use an available task model override for the local or external connection. - if models.get(task_model_id, {}).get('connection_type') == 'local': - if task_model and task_model in models: - task_model_id = task_model + system_model_id = default_model_id + # Use an available system model override for the local or external connection. + if models.get(system_model_id, {}).get('connection_type') == 'local': + if system_model and system_model in models: + system_model_id = system_model else: - if task_model_external and task_model_external in models: - task_model_id = task_model_external + if system_model_external and system_model_external in models: + system_model_id = system_model_external - return task_model_id + return system_model_id def prompt_variables_template(template: str, variables: dict[str, str]) -> str: diff --git a/src/lib/components/admin/Settings/AdminTabIcon.svelte b/src/lib/components/admin/Settings/AdminTabIcon.svelte index bedc3e6079..20c76693f1 100644 --- a/src/lib/components/admin/Settings/AdminTabIcon.svelte +++ b/src/lib/components/admin/Settings/AdminTabIcon.svelte @@ -30,7 +30,7 @@ {:else if id === 'features'} -{:else if id === 'tasks'} +{:else if id === 'system-model'} {:else if id === 'users'} diff --git a/src/lib/components/admin/Settings/Tasks.svelte b/src/lib/components/admin/Settings/Tasks.svelte index e84a16310b..a3b3219189 100644 --- a/src/lib/components/admin/Settings/Tasks.svelte +++ b/src/lib/components/admin/Settings/Tasks.svelte @@ -31,12 +31,12 @@ $: dirty = getChangedKeys(savedConfig, settings).length > 0; $: settings = { ...taskConfig, - TASK_MODEL_PARAMS: configuredParams(taskConfig?.TASK_MODEL_PARAMS) + SYSTEM_MODEL_PARAMS: configuredParams(taskConfig?.SYSTEM_MODEL_PARAMS) }; $: settingLabels = { - TASK_MODEL: $i18n.t('settings.admin.interface.localTaskModel.label'), - TASK_MODEL_EXTERNAL: $i18n.t('settings.admin.interface.externalTaskModel.label'), - TASK_MODEL_PARAMS: $i18n.t('settings.admin.interface.taskModelParameters.label'), + SYSTEM_MODEL: $i18n.t('settings.admin.interface.localSystemModel.label'), + SYSTEM_MODEL_EXTERNAL: $i18n.t('settings.admin.interface.externalSystemModel.label'), + SYSTEM_MODEL_PARAMS: $i18n.t('settings.admin.interface.systemModelParameters.label'), ENABLE_TITLE_GENERATION: $i18n.t('settings.admin.interface.titleGeneration.label'), TITLE_GENERATION_PROMPT_TEMPLATE: $i18n.t( 'settings.admin.interface.titleGenerationPrompt.label' @@ -119,7 +119,7 @@ try { taskConfig = await updateTaskConfig(localStorage.token, { ...taskConfig, - TASK_MODEL_PARAMS: configuredParams(taskConfig.TASK_MODEL_PARAMS) + SYSTEM_MODEL_PARAMS: configuredParams(taskConfig.SYSTEM_MODEL_PARAMS) }); await appConfig.set(await getBackendConfig()); await tick(); @@ -145,7 +145,7 @@ getBaseModels(localStorage.token), getModels(localStorage.token) ]); - taskConfig.TASK_MODEL_PARAMS = taskConfig.TASK_MODEL_PARAMS ?? {}; + taskConfig.SYSTEM_MODEL_PARAMS = taskConfig.SYSTEM_MODEL_PARAMS ?? {}; baseModels = baseModels.filter((model: any) => !isMachine(model.owned_by)); models = baseModels.map((m: any) => { const workspaceModel = workspaceModels.find((wm: any) => wm.id === m.id); @@ -178,25 +178,25 @@
- {$i18n.t('settings.admin.interface.taskModel.label')} + {$i18n.t('settings.admin.interface.systemModel.label')}
- {$i18n.t('settings.admin.interface.taskModel.description')} + {$i18n.t('settings.admin.interface.systemModel.description')}
{ - taskConfig.TASK_MODEL = normalizeModelSelection(taskConfig.TASK_MODEL); + taskConfig.SYSTEM_MODEL = normalizeModelSelection(taskConfig.SYSTEM_MODEL); }} > @@ -210,17 +210,17 @@ { - taskConfig.TASK_MODEL_EXTERNAL = normalizeModelSelection( - taskConfig.TASK_MODEL_EXTERNAL + taskConfig.SYSTEM_MODEL_EXTERNAL = normalizeModelSelection( + taskConfig.SYSTEM_MODEL_EXTERNAL ); }} > @@ -244,7 +244,7 @@ }} > - {$i18n.t('settings.admin.interface.taskModelParameters.label')} + {$i18n.t('settings.admin.interface.systemModelParameters.label')} {showTaskParameters ? $i18n.t('Close') : $i18n.t('Configure')} @@ -256,7 +256,7 @@
{/if} diff --git a/src/lib/components/admin/Users/Groups/EditGroupModal.svelte b/src/lib/components/admin/Users/Groups/EditGroupModal.svelte index 120667a4f8..935e08ee4b 100644 --- a/src/lib/components/admin/Users/Groups/EditGroupModal.svelte +++ b/src/lib/components/admin/Users/Groups/EditGroupModal.svelte @@ -277,10 +277,6 @@ bind:name bind:description bind:data - {edit} - onDelete={() => { - showDeleteConfirmDialog = true; - }} /> {:else if selectedTab == 'permissions'} {#if custom && parent_group_id} @@ -336,7 +332,17 @@ class="flex shrink-0 items-center justify-between gap-1.5 px-4 pt-3 pb-4 text-sm font-normal" >
- {#if selectedTab === 'permissions'} + {#if selectedTab === 'general' && edit && custom} + + {:else if selectedTab === 'permissions'} >('i18n'); export let name = ''; - export let color = ''; export let description = ''; export let data: Record = {}; - export let edit = false; export let groupId: string | undefined = undefined; export let groups: import('../Groups.svelte').GroupListItem[] = []; export let parent_group_id: string | null = null; @@ -74,34 +73,41 @@ } let inheritedModelIds: string[] = []; let inheritedModelSource = ''; - export let onDelete: Function = () => {}; -
-
- - -
- -
-
+ +
+ +
-
-
- - - +
+ +