mirror of
https://git.mirrors.martin98.com/https://github.com/open-webui/open-webui
synced 2025-08-20 05:19:10 +08:00
refac: always on web search
This commit is contained in:
parent
336984c254
commit
d4a18a5765
@ -117,7 +117,7 @@
|
|||||||
|
|
||||||
let selectedToolIds = [];
|
let selectedToolIds = [];
|
||||||
let imageGenerationEnabled = false;
|
let imageGenerationEnabled = false;
|
||||||
let webSearchEnabled = $settings?.alwaysOnWebSearch ?? false;
|
let webSearchEnabled = false;
|
||||||
let codeInterpreterEnabled = false;
|
let codeInterpreterEnabled = false;
|
||||||
let chat = null;
|
let chat = null;
|
||||||
let tags = [];
|
let tags = [];
|
||||||
@ -143,7 +143,7 @@
|
|||||||
prompt = '';
|
prompt = '';
|
||||||
files = [];
|
files = [];
|
||||||
selectedToolIds = [];
|
selectedToolIds = [];
|
||||||
|
webSearchEnabled = false;
|
||||||
imageGenerationEnabled = false;
|
imageGenerationEnabled = false;
|
||||||
|
|
||||||
if (chatIdProp && (await loadChat())) {
|
if (chatIdProp && (await loadChat())) {
|
||||||
@ -718,7 +718,7 @@
|
|||||||
if ($page.url.searchParams.get('web-search') === 'true') {
|
if ($page.url.searchParams.get('web-search') === 'true') {
|
||||||
webSearchEnabled = true;
|
webSearchEnabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($page.url.searchParams.get('image-generation') === 'true') {
|
if ($page.url.searchParams.get('image-generation') === 'true') {
|
||||||
imageGenerationEnabled = true;
|
imageGenerationEnabled = true;
|
||||||
}
|
}
|
||||||
@ -1550,9 +1550,20 @@
|
|||||||
tool_ids: selectedToolIds.length > 0 ? selectedToolIds : undefined,
|
tool_ids: selectedToolIds.length > 0 ? selectedToolIds : undefined,
|
||||||
|
|
||||||
features: {
|
features: {
|
||||||
image_generation: imageGenerationEnabled,
|
image_generation:
|
||||||
code_interpreter: codeInterpreterEnabled,
|
$config?.features?.enable_image_generation &&
|
||||||
web_search: webSearchEnabled
|
($user.role === 'admin' || $user?.permissions?.features?.image_generation)
|
||||||
|
? imageGenerationEnabled
|
||||||
|
: false,
|
||||||
|
code_interpreter:
|
||||||
|
$user.role === 'admin' || $user?.permissions?.features?.code_interpreter
|
||||||
|
? codeInterpreterEnabled
|
||||||
|
: false,
|
||||||
|
web_search:
|
||||||
|
$config?.features?.enable_web_search &&
|
||||||
|
($user.role === 'admin' || $user?.permissions?.features?.web_search)
|
||||||
|
? webSearchEnabled || ($settings?.webSearch ?? false) === 'always'
|
||||||
|
: false
|
||||||
},
|
},
|
||||||
variables: {
|
variables: {
|
||||||
...getPromptVariables(
|
...getPromptVariables(
|
||||||
|
@ -390,7 +390,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="w-full relative">
|
<div class="w-full relative">
|
||||||
{#if atSelectedModel !== undefined || selectedToolIds.length > 0 || webSearchEnabled || imageGenerationEnabled || codeInterpreterEnabled}
|
{#if atSelectedModel !== undefined || selectedToolIds.length > 0 || webSearchEnabled || ($settings?.webSearch ?? false) === 'always' || imageGenerationEnabled || codeInterpreterEnabled}
|
||||||
<div
|
<div
|
||||||
class="px-3 pb-0.5 pt-1.5 text-left w-full flex flex-col absolute bottom-0 left-0 right-0 bg-gradient-to-t from-white dark:from-gray-900 z-10"
|
class="px-3 pb-0.5 pt-1.5 text-left w-full flex flex-col absolute bottom-0 left-0 right-0 bg-gradient-to-t from-white dark:from-gray-900 z-10"
|
||||||
>
|
>
|
||||||
@ -426,7 +426,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if webSearchEnabled}
|
{#if webSearchEnabled || ($settings?.webSearch ?? false) === 'always'}
|
||||||
<div class="flex items-center justify-between w-full">
|
<div class="flex items-center justify-between w-full">
|
||||||
<div class="flex items-center gap-2.5 text-sm dark:text-gray-500">
|
<div class="flex items-center gap-2.5 text-sm dark:text-gray-500">
|
||||||
<div class="pl-1">
|
<div class="pl-1">
|
||||||
@ -1135,7 +1135,8 @@
|
|||||||
<button
|
<button
|
||||||
on:click|preventDefault={() => (webSearchEnabled = !webSearchEnabled)}
|
on:click|preventDefault={() => (webSearchEnabled = !webSearchEnabled)}
|
||||||
type="button"
|
type="button"
|
||||||
class="px-1.5 sm:px-2.5 py-1.5 flex gap-1.5 items-center text-sm rounded-full font-medium transition-colors duration-300 focus:outline-none max-w-full overflow-hidden {webSearchEnabled
|
class="px-1.5 sm:px-2.5 py-1.5 flex gap-1.5 items-center text-sm rounded-full font-medium transition-colors duration-300 focus:outline-none max-w-full overflow-hidden {webSearchEnabled ||
|
||||||
|
($settings?.webSearch ?? false) === 'always'
|
||||||
? 'bg-blue-100 dark:bg-blue-500/20 text-blue-500 dark:text-blue-400'
|
? 'bg-blue-100 dark:bg-blue-500/20 text-blue-500 dark:text-blue-400'
|
||||||
: 'bg-transparent text-gray-600 dark:text-gray-400 border-gray-200 hover:bg-gray-100 dark:hover:bg-gray-800'}"
|
: 'bg-transparent text-gray-600 dark:text-gray-400 border-gray-200 hover:bg-gray-100 dark:hover:bg-gray-800'}"
|
||||||
>
|
>
|
||||||
@ -1243,7 +1244,8 @@
|
|||||||
<div class=" flex items-center">
|
<div class=" flex items-center">
|
||||||
<Tooltip content={$i18n.t('Call')}>
|
<Tooltip content={$i18n.t('Call')}>
|
||||||
<button
|
<button
|
||||||
class=" {webSearchEnabled
|
class=" {webSearchEnabled ||
|
||||||
|
($settings?.webSearch ?? false) === 'always'
|
||||||
? 'bg-blue-500 text-white hover:bg-blue-400 '
|
? 'bg-blue-500 text-white hover:bg-blue-400 '
|
||||||
: 'bg-black text-white hover:bg-gray-900 dark:bg-white dark:text-black dark:hover:bg-gray-100'} transition rounded-full p-1.5 self-center"
|
: 'bg-black text-white hover:bg-gray-900 dark:bg-white dark:text-black dark:hover:bg-gray-100'} transition rounded-full p-1.5 self-center"
|
||||||
type="button"
|
type="button"
|
||||||
@ -1298,7 +1300,7 @@
|
|||||||
<button
|
<button
|
||||||
id="send-message-button"
|
id="send-message-button"
|
||||||
class="{prompt !== ''
|
class="{prompt !== ''
|
||||||
? webSearchEnabled
|
? webSearchEnabled || ($settings?.webSearch ?? false) === 'always'
|
||||||
? 'bg-blue-500 text-white hover:bg-blue-400 '
|
? 'bg-blue-500 text-white hover:bg-blue-400 '
|
||||||
: 'bg-black text-white hover:bg-gray-900 dark:bg-white dark:text-black dark:hover:bg-gray-100 '
|
: 'bg-black text-white hover:bg-gray-900 dark:bg-white dark:text-black dark:hover:bg-gray-100 '
|
||||||
: 'text-white bg-gray-200 dark:text-gray-900 dark:bg-gray-700 disabled'} transition rounded-full p-1.5 self-center"
|
: 'text-white bg-gray-200 dark:text-gray-900 dark:bg-gray-700 disabled'} transition rounded-full p-1.5 self-center"
|
||||||
|
@ -52,7 +52,7 @@
|
|||||||
let voiceInterruption = false;
|
let voiceInterruption = false;
|
||||||
let hapticFeedback = false;
|
let hapticFeedback = false;
|
||||||
|
|
||||||
let alwaysOnWebSearch = false;
|
let webSearch = null;
|
||||||
|
|
||||||
const toggleSplitLargeChunks = async () => {
|
const toggleSplitLargeChunks = async () => {
|
||||||
splitLargeChunks = !splitLargeChunks;
|
splitLargeChunks = !splitLargeChunks;
|
||||||
@ -200,9 +200,9 @@
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const toggleAlwaysOnWebSearch = async () => {
|
const toggleWebSearch = async () => {
|
||||||
alwaysOnWebSearch = !alwaysOnWebSearch;
|
webSearch = webSearch === null ? 'always' : null;
|
||||||
saveSettings({ alwaysOnWebSearch });
|
saveSettings({ webSearch: webSearch });
|
||||||
};
|
};
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
@ -242,8 +242,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
backgroundImageUrl = $settings.backgroundImageUrl ?? null;
|
backgroundImageUrl = $settings.backgroundImageUrl ?? null;
|
||||||
|
webSearch = $settings.webSearch ?? null;
|
||||||
alwaysOnWebSearch = $settings.alwaysOnWebSearch ?? false;
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -677,19 +676,19 @@
|
|||||||
|
|
||||||
<div>
|
<div>
|
||||||
<div class=" py-0.5 flex w-full justify-between">
|
<div class=" py-0.5 flex w-full justify-between">
|
||||||
<div class=" self-center text-xs">{$i18n.t('Always-On Web Search')}</div>
|
<div class=" self-center text-xs">{$i18n.t('Web Search in Chat')}</div>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
class="p-1 px-3 text-xs flex rounded transition"
|
class="p-1 px-3 text-xs flex rounded transition"
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
toggleAlwaysOnWebSearch();
|
toggleWebSearch();
|
||||||
}}
|
}}
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
{#if alwaysOnWebSearch === true}
|
{#if webSearch === 'always'}
|
||||||
<span class="ml-2 self-center">{$i18n.t('On')}</span>
|
<span class="ml-2 self-center">{$i18n.t('Always')}</span>
|
||||||
{:else}
|
{:else}
|
||||||
<span class="ml-2 self-center">{$i18n.t('Off')}</span>
|
<span class="ml-2 self-center">{$i18n.t('Default')}</span>
|
||||||
{/if}
|
{/if}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user