diff --git a/backend/open_webui/functions.py b/backend/open_webui/functions.py index d102263cb3..316efe18e7 100644 --- a/backend/open_webui/functions.py +++ b/backend/open_webui/functions.py @@ -86,6 +86,10 @@ async def get_function_models(request): try: function_module = get_function_module_by_id(request, pipe.id) + has_user_valves = False + if hasattr(function_module, "UserValves"): + has_user_valves = True + # Check if function is a manifold if hasattr(function_module, "pipes"): sub_pipes = [] @@ -124,6 +128,7 @@ async def get_function_models(request): "created": pipe.created_at, "owned_by": "openai", "pipe": pipe_flag, + "has_user_valves": has_user_valves, } ) else: @@ -141,6 +146,7 @@ async def get_function_models(request): "created": pipe.created_at, "owned_by": "openai", "pipe": pipe_flag, + "has_user_valves": has_user_valves, } ) except Exception as e: diff --git a/backend/open_webui/utils/models.py b/backend/open_webui/utils/models.py index 7e69661f56..587e2a2c7d 100644 --- a/backend/open_webui/utils/models.py +++ b/backend/open_webui/utils/models.py @@ -263,6 +263,7 @@ async def get_all_models(request, refresh: bool = False, user: UserModel = None) "icon": function.meta.manifest.get("icon_url", None) or getattr(module, "icon_url", None) or getattr(module, "icon", None), + "has_user_valves": hasattr(module, "UserValves"), } ] diff --git a/src/lib/components/chat/MessageInput.svelte b/src/lib/components/chat/MessageInput.svelte index c4b2d4520d..4bcdbc30ca 100644 --- a/src/lib/components/chat/MessageInput.svelte +++ b/src/lib/components/chat/MessageInput.svelte @@ -78,6 +78,8 @@ import { getSuggestionRenderer } from '../common/RichTextInput/suggestions'; import CommandSuggestionList from './MessageInput/CommandSuggestionList.svelte'; + import Knobs from '../icons/Knobs.svelte'; + import ValvesModal from '../workspace/common/ValvesModal.svelte'; const i18n = getContext('i18n'); @@ -112,6 +114,10 @@ let inputVariables = {}; let inputVariableValues = {}; + let showValvesModal = false; + let selectedValvesType = 'tool'; // 'tool' or 'function' + let selectedValvesItemId = null; + $: onChange({ prompt, files: files @@ -932,6 +938,16 @@ onSave={inputVariablesModalCallback} /> + { + await tick(); + }} +/> + {#if loaded}
@@ -1449,6 +1465,12 @@ bind:webSearchEnabled bind:imageGenerationEnabled bind:codeInterpreterEnabled + onShowValves={(e) => { + const { type, id } = e; + selectedValvesType = type; + selectedValvesItemId = id; + showValvesModal = true; + }} onClose={async () => { await tick(); @@ -1465,6 +1487,24 @@ {/if} + {#if selectedModelIds.length === 1 && $models.find((m) => m.id === selectedModelIds[0])?.has_user_valves} +
+ + + +
+ {/if} +
{#if (selectedToolIds ?? []).length > 0} - { - await tick(); - }} -/> - { @@ -192,6 +177,27 @@
+ {#if filter?.has_user_valves} +
+ + + +
+ {/if} +
{ e.stopPropagation(); e.preventDefault(); - selectedValvesType = 'tool'; - selectedValvesItemId = toolId; - showValvesModal = true; + onShowValves({ + type: 'tool', + id: toolId + }); }} > diff --git a/src/lib/components/chat/Navbar.svelte b/src/lib/components/chat/Navbar.svelte index 3a2ca32fba..c8939892dd 100644 --- a/src/lib/components/chat/Navbar.svelte +++ b/src/lib/components/chat/Navbar.svelte @@ -37,6 +37,7 @@ import EllipsisHorizontal from '../icons/EllipsisHorizontal.svelte'; import ChatPlus from '../icons/ChatPlus.svelte'; import ChatCheck from '../icons/ChatCheck.svelte'; + import Knobs from '../icons/Knobs.svelte'; const i18n = getContext('i18n'); @@ -210,7 +211,7 @@ aria-label="Controls" >
- +
@@ -255,7 +256,7 @@
{#if !history.currentId && !$chatId && ($banners.length > 0 || ($config?.license_metadata?.type ?? null) === 'trial' || (($config?.license_metadata?.seats ?? null) !== null && $config?.user_count > $config?.license_metadata?.seats))} -
+
{#if ($config?.license_metadata?.type ?? null) === 'trial'} - - - + + + - - - + + + diff --git a/src/routes/(app)/admin/functions/create/+page.svelte b/src/routes/(app)/admin/functions/create/+page.svelte index f7d2a78040..bb13a759fd 100644 --- a/src/routes/(app)/admin/functions/create/+page.svelte +++ b/src/routes/(app)/admin/functions/create/+page.svelte @@ -91,7 +91,7 @@ {#if mounted} {#key func?.content} -
+
{#if func} -
+