From 52c73390f8425f6e83b672c3dd44c6bf1176c919 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Fri, 23 Jan 2026 01:44:48 +0400 Subject: [PATCH] refac --- backend/open_webui/utils/tools.py | 34 +++++++++++-------- .../workspace/Models/BuiltinTools.svelte | 12 +++++++ 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/backend/open_webui/utils/tools.py b/backend/open_webui/utils/tools.py index 59fd75dad..b2f95a829 100644 --- a/backend/open_webui/utils/tools.py +++ b/backend/open_webui/utils/tools.py @@ -441,26 +441,32 @@ def get_builtin_tools( if is_builtin_tool_enabled("memory") and features.get("memory"): builtin_functions.extend([search_memories, add_memory, replace_memory_content]) - # Add web search tools if enabled globally AND model has web_search capability - if getattr( - request.app.state.config, "ENABLE_WEB_SEARCH", False - ) and get_model_capability("web_search"): + # Add web search tools if builtin category enabled AND enabled globally AND model has web_search capability + if ( + is_builtin_tool_enabled("web_search") + and getattr(request.app.state.config, "ENABLE_WEB_SEARCH", False) + and get_model_capability("web_search") + ): builtin_functions.extend([search_web, fetch_url]) - # Add image generation/edit tools if enabled globally AND model has image_generation capability - if getattr( - request.app.state.config, "ENABLE_IMAGE_GENERATION", False - ) and get_model_capability("image_generation"): + # Add image generation/edit tools if builtin category enabled AND enabled globally AND model has image_generation capability + if ( + is_builtin_tool_enabled("image_generation") + and getattr(request.app.state.config, "ENABLE_IMAGE_GENERATION", False) + and get_model_capability("image_generation") + ): builtin_functions.append(generate_image) - if getattr( - request.app.state.config, "ENABLE_IMAGE_EDIT", False - ) and get_model_capability("image_generation"): + if ( + is_builtin_tool_enabled("image_generation") + and getattr(request.app.state.config, "ENABLE_IMAGE_EDIT", False) + and get_model_capability("image_generation") + ): builtin_functions.append(edit_image) - # Add code interpreter tool if enabled globally AND model has code_interpreter capability - # Supports both pyodide (via frontend event call) and jupyter engines + # Add code interpreter tool if builtin category enabled AND enabled globally AND model has code_interpreter capability if ( - getattr(request.app.state.config, "ENABLE_CODE_INTERPRETER", True) + is_builtin_tool_enabled("code_interpreter") + and getattr(request.app.state.config, "ENABLE_CODE_INTERPRETER", True) and get_model_capability("code_interpreter") ): builtin_functions.append(execute_code) diff --git a/src/lib/components/workspace/Models/BuiltinTools.svelte b/src/lib/components/workspace/Models/BuiltinTools.svelte index 80587cfcb..b1f925302 100644 --- a/src/lib/components/workspace/Models/BuiltinTools.svelte +++ b/src/lib/components/workspace/Models/BuiltinTools.svelte @@ -30,6 +30,18 @@ channels: { label: $i18n.t('Channels'), description: $i18n.t('Search channels and channel messages') + }, + web_search: { + label: $i18n.t('Web Search'), + description: $i18n.t('Search the web and fetch URLs') + }, + image_generation: { + label: $i18n.t('Image Generation'), + description: $i18n.t('Generate and edit images') + }, + code_interpreter: { + label: $i18n.t('Code Interpreter'), + description: $i18n.t('Execute code') } };