mirror of
https://github.com/open-webui/open-webui
synced 2025-06-26 18:26:48 +00:00
enh: image generation toggle
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
import GlobeAltSolid from '$lib/components/icons/GlobeAltSolid.svelte';
|
||||
import WrenchSolid from '$lib/components/icons/WrenchSolid.svelte';
|
||||
import CameraSolid from '$lib/components/icons/CameraSolid.svelte';
|
||||
import PhotoSolid from '$lib/components/icons/PhotoSolid.svelte';
|
||||
|
||||
const i18n = getContext('i18n');
|
||||
|
||||
@@ -24,11 +25,25 @@
|
||||
export let selectedToolIds: string[] = [];
|
||||
|
||||
export let webSearchEnabled: boolean;
|
||||
export let imageGenerationEnabled: boolean;
|
||||
|
||||
export let onClose: Function;
|
||||
|
||||
let tools = {};
|
||||
let show = false;
|
||||
|
||||
let showImageGeneration = false;
|
||||
|
||||
$: showImageGeneration =
|
||||
$config?.features?.enable_image_generation &&
|
||||
($user.role === 'admin' || $user?.permissions?.features?.image_generation);
|
||||
|
||||
let showWebSearch = false;
|
||||
|
||||
$: showWebSearch =
|
||||
$config?.features?.enable_web_search &&
|
||||
($user.role === 'admin' || $user?.permissions?.features?.web_search);
|
||||
|
||||
$: if (show) {
|
||||
init();
|
||||
}
|
||||
@@ -63,7 +78,7 @@
|
||||
|
||||
<div slot="content">
|
||||
<DropdownMenu.Content
|
||||
class="w-full max-w-[200px] rounded-xl px-1 py-1 border-gray-300/30 dark:border-gray-700/50 z-50 bg-white dark:bg-gray-850 dark:text-white shadow"
|
||||
class="w-full max-w-[220px] rounded-xl px-1 py-1 border-gray-300/30 dark:border-gray-700/50 z-50 bg-white dark:bg-gray-850 dark:text-white shadow"
|
||||
sideOffset={15}
|
||||
alignOffset={-8}
|
||||
side="top"
|
||||
@@ -114,7 +129,23 @@
|
||||
<hr class="border-black/5 dark:border-white/5 my-1" />
|
||||
{/if}
|
||||
|
||||
{#if $config?.features?.enable_web_search && ($user.role === 'admin' || $user?.permissions?.features?.web_search)}
|
||||
{#if showImageGeneration}
|
||||
<button
|
||||
class="flex w-full justify-between gap-2 items-center px-3 py-2 text-sm font-medium cursor-pointer rounded-xl"
|
||||
on:click={() => {
|
||||
imageGenerationEnabled = !imageGenerationEnabled;
|
||||
}}
|
||||
>
|
||||
<div class="flex-1 flex items-center gap-2">
|
||||
<PhotoSolid />
|
||||
<div class=" line-clamp-1">{$i18n.t('Image')}</div>
|
||||
</div>
|
||||
|
||||
<Switch state={imageGenerationEnabled} />
|
||||
</button>
|
||||
{/if}
|
||||
|
||||
{#if showWebSearch}
|
||||
<button
|
||||
class="flex w-full justify-between gap-2 items-center px-3 py-2 text-sm font-medium cursor-pointer rounded-xl"
|
||||
on:click={() => {
|
||||
@@ -128,7 +159,9 @@
|
||||
|
||||
<Switch state={webSearchEnabled} />
|
||||
</button>
|
||||
{/if}
|
||||
|
||||
{#if showImageGeneration || showWebSearch}
|
||||
<hr class="border-black/5 dark:border-white/5 my-1" />
|
||||
{/if}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user