mirror of
https://github.com/open-webui/open-webui
synced 2025-06-13 01:43:37 +00:00
refac
This commit is contained in:
parent
50bc6d9b12
commit
363ac35c09
@ -790,8 +790,8 @@ async def process_chat_payload(request, form_data, user, metadata, model):
|
|||||||
),
|
),
|
||||||
form_data["messages"],
|
form_data["messages"],
|
||||||
)
|
)
|
||||||
if "thinking" in features:
|
if "reasoning" in features:
|
||||||
form_data["enable_thinking"] = features["thinking"]
|
form_data["enable_thinking"] = features["reasoning"]
|
||||||
form_data["chat_template_kwargs"] = {
|
form_data["chat_template_kwargs"] = {
|
||||||
"enable_thinking": features["thinking"]
|
"enable_thinking": features["thinking"]
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@
|
|||||||
let imageGenerationEnabled = false;
|
let imageGenerationEnabled = false;
|
||||||
let webSearchEnabled = false;
|
let webSearchEnabled = false;
|
||||||
let codeInterpreterEnabled = false;
|
let codeInterpreterEnabled = false;
|
||||||
let thinkingEnabled = false;
|
let reasoningEnabled = false;
|
||||||
|
|
||||||
let chat = null;
|
let chat = null;
|
||||||
let tags = [];
|
let tags = [];
|
||||||
@ -148,7 +148,7 @@
|
|||||||
files = [];
|
files = [];
|
||||||
selectedToolIds = [];
|
selectedToolIds = [];
|
||||||
webSearchEnabled = false;
|
webSearchEnabled = false;
|
||||||
thinkingEnabled = false;
|
reasoningEnabled = false;
|
||||||
imageGenerationEnabled = false;
|
imageGenerationEnabled = false;
|
||||||
|
|
||||||
if (localStorage.getItem(`chat-input${chatIdProp ? `-${chatIdProp}` : ''}`)) {
|
if (localStorage.getItem(`chat-input${chatIdProp ? `-${chatIdProp}` : ''}`)) {
|
||||||
@ -162,7 +162,7 @@
|
|||||||
files = input.files;
|
files = input.files;
|
||||||
selectedToolIds = input.selectedToolIds;
|
selectedToolIds = input.selectedToolIds;
|
||||||
webSearchEnabled = input.webSearchEnabled;
|
webSearchEnabled = input.webSearchEnabled;
|
||||||
thinkingEnabled = input.thinkingEnabled;
|
reasoningEnabled = input.reasoningEnabled;
|
||||||
imageGenerationEnabled = input.imageGenerationEnabled;
|
imageGenerationEnabled = input.imageGenerationEnabled;
|
||||||
codeInterpreterEnabled = input.codeInterpreterEnabled;
|
codeInterpreterEnabled = input.codeInterpreterEnabled;
|
||||||
}
|
}
|
||||||
@ -428,7 +428,7 @@
|
|||||||
files = [];
|
files = [];
|
||||||
selectedToolIds = [];
|
selectedToolIds = [];
|
||||||
webSearchEnabled = false;
|
webSearchEnabled = false;
|
||||||
thinkingEnabled = false;
|
reasoningEnabled = false;
|
||||||
imageGenerationEnabled = false;
|
imageGenerationEnabled = false;
|
||||||
codeInterpreterEnabled = false;
|
codeInterpreterEnabled = false;
|
||||||
|
|
||||||
@ -444,7 +444,7 @@
|
|||||||
webSearchEnabled = input.webSearchEnabled;
|
webSearchEnabled = input.webSearchEnabled;
|
||||||
imageGenerationEnabled = input.imageGenerationEnabled;
|
imageGenerationEnabled = input.imageGenerationEnabled;
|
||||||
codeInterpreterEnabled = input.codeInterpreterEnabled;
|
codeInterpreterEnabled = input.codeInterpreterEnabled;
|
||||||
thinkingEnabled = input.thinkingEnabled;
|
reasoningEnabled = input.reasoningEnabled;
|
||||||
}
|
}
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
@ -753,8 +753,8 @@
|
|||||||
webSearchEnabled = true;
|
webSearchEnabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($page.url.searchParams.get('thinking') === 'true') {
|
if ($page.url.searchParams.get('reasoning') === 'true') {
|
||||||
thinkingEnabled = true;
|
reasoningEnabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($page.url.searchParams.get('image-generation') === 'true') {
|
if ($page.url.searchParams.get('image-generation') === 'true') {
|
||||||
@ -1645,7 +1645,7 @@
|
|||||||
($user?.role === 'admin' || $user?.permissions?.features?.web_search)
|
($user?.role === 'admin' || $user?.permissions?.features?.web_search)
|
||||||
? webSearchEnabled || ($settings?.webSearch ?? false) === 'always'
|
? webSearchEnabled || ($settings?.webSearch ?? false) === 'always'
|
||||||
: false,
|
: false,
|
||||||
thinking: thinkingEnabled
|
reasoning: reasoningEnabled
|
||||||
},
|
},
|
||||||
variables: {
|
variables: {
|
||||||
...getPromptVariables(
|
...getPromptVariables(
|
||||||
@ -2071,7 +2071,7 @@
|
|||||||
bind:imageGenerationEnabled
|
bind:imageGenerationEnabled
|
||||||
bind:codeInterpreterEnabled
|
bind:codeInterpreterEnabled
|
||||||
bind:webSearchEnabled
|
bind:webSearchEnabled
|
||||||
bind:thinkingEnabled
|
bind:reasoningEnabled
|
||||||
bind:atSelectedModel
|
bind:atSelectedModel
|
||||||
toolServers={$toolServers}
|
toolServers={$toolServers}
|
||||||
transparentBackground={$settings?.backgroundImageUrl ?? false}
|
transparentBackground={$settings?.backgroundImageUrl ?? false}
|
||||||
@ -2128,7 +2128,7 @@
|
|||||||
bind:imageGenerationEnabled
|
bind:imageGenerationEnabled
|
||||||
bind:codeInterpreterEnabled
|
bind:codeInterpreterEnabled
|
||||||
bind:webSearchEnabled
|
bind:webSearchEnabled
|
||||||
bind:thinkingEnabled
|
bind:reasoningEnabled
|
||||||
bind:atSelectedModel
|
bind:atSelectedModel
|
||||||
transparentBackground={$settings?.backgroundImageUrl ?? false}
|
transparentBackground={$settings?.backgroundImageUrl ?? false}
|
||||||
toolServers={$toolServers}
|
toolServers={$toolServers}
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
import VoiceRecording from './MessageInput/VoiceRecording.svelte';
|
import VoiceRecording from './MessageInput/VoiceRecording.svelte';
|
||||||
import FilesOverlay from './MessageInput/FilesOverlay.svelte';
|
import FilesOverlay from './MessageInput/FilesOverlay.svelte';
|
||||||
import Commands from './MessageInput/Commands.svelte';
|
import Commands from './MessageInput/Commands.svelte';
|
||||||
|
import ToolServersModal from './ToolServersModal.svelte';
|
||||||
|
|
||||||
import RichTextInput from '../common/RichTextInput.svelte';
|
import RichTextInput from '../common/RichTextInput.svelte';
|
||||||
import Tooltip from '../common/Tooltip.svelte';
|
import Tooltip from '../common/Tooltip.svelte';
|
||||||
@ -47,13 +48,12 @@
|
|||||||
import XMark from '../icons/XMark.svelte';
|
import XMark from '../icons/XMark.svelte';
|
||||||
import Headphone from '../icons/Headphone.svelte';
|
import Headphone from '../icons/Headphone.svelte';
|
||||||
import GlobeAlt from '../icons/GlobeAlt.svelte';
|
import GlobeAlt from '../icons/GlobeAlt.svelte';
|
||||||
import Thinking from "../icons/Thinking.svelte";
|
|
||||||
import PhotoSolid from '../icons/PhotoSolid.svelte';
|
|
||||||
import Photo from '../icons/Photo.svelte';
|
import Photo from '../icons/Photo.svelte';
|
||||||
import CommandLine from '../icons/CommandLine.svelte';
|
import LightBlub from '../icons/LightBlub.svelte';
|
||||||
import { KokoroWorker } from '$lib/workers/KokoroWorker';
|
|
||||||
import ToolServersModal from './ToolServersModal.svelte';
|
|
||||||
import Wrench from '../icons/Wrench.svelte';
|
import Wrench from '../icons/Wrench.svelte';
|
||||||
|
import CommandLine from '../icons/CommandLine.svelte';
|
||||||
|
|
||||||
|
import { KokoroWorker } from '$lib/workers/KokoroWorker';
|
||||||
|
|
||||||
const i18n = getContext('i18n');
|
const i18n = getContext('i18n');
|
||||||
|
|
||||||
@ -84,7 +84,7 @@
|
|||||||
export let imageGenerationEnabled = false;
|
export let imageGenerationEnabled = false;
|
||||||
export let webSearchEnabled = false;
|
export let webSearchEnabled = false;
|
||||||
export let codeInterpreterEnabled = false;
|
export let codeInterpreterEnabled = false;
|
||||||
export let thinkingEnabled = false;
|
export let reasoningEnabled = false;
|
||||||
|
|
||||||
$: onChange({
|
$: onChange({
|
||||||
prompt,
|
prompt,
|
||||||
@ -93,7 +93,7 @@
|
|||||||
imageGenerationEnabled,
|
imageGenerationEnabled,
|
||||||
webSearchEnabled,
|
webSearchEnabled,
|
||||||
codeInterpreterEnabled,
|
codeInterpreterEnabled,
|
||||||
thinkingEnabled
|
reasoningEnabled
|
||||||
});
|
});
|
||||||
|
|
||||||
let showTools = false;
|
let showTools = false;
|
||||||
@ -120,9 +120,10 @@
|
|||||||
(model) => $models.find((m) => m.id === model)?.info?.meta?.capabilities?.vision ?? true
|
(model) => $models.find((m) => m.id === model)?.info?.meta?.capabilities?.vision ?? true
|
||||||
);
|
);
|
||||||
|
|
||||||
let switchThinkingCapableModels = [];
|
let reasoningCapableModels = [];
|
||||||
$: switchThinkingCapableModels = $models.filter((model) => model.info?.meta?.capabilities?.switch_thinking ?? false)
|
$: reasoningCapableModels = $models
|
||||||
.map((model) => model.id)
|
.filter((model) => model.info?.meta?.capabilities?.reasoning ?? false)
|
||||||
|
.map((model) => model.id);
|
||||||
|
|
||||||
const scrollToBottom = () => {
|
const scrollToBottom = () => {
|
||||||
const element = document.getElementById('messages-container');
|
const element = document.getElementById('messages-container');
|
||||||
@ -780,7 +781,7 @@
|
|||||||
selectedToolIds = [];
|
selectedToolIds = [];
|
||||||
webSearchEnabled = false;
|
webSearchEnabled = false;
|
||||||
imageGenerationEnabled = false;
|
imageGenerationEnabled = false;
|
||||||
thinkingEnabled = false;
|
reasoningEnabled = false;
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
on:paste={async (e) => {
|
on:paste={async (e) => {
|
||||||
@ -1004,7 +1005,7 @@
|
|||||||
selectedToolIds = [];
|
selectedToolIds = [];
|
||||||
webSearchEnabled = false;
|
webSearchEnabled = false;
|
||||||
imageGenerationEnabled = false;
|
imageGenerationEnabled = false;
|
||||||
thinkingEnabled = false;
|
reasoningEnabled = false;
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
rows="1"
|
rows="1"
|
||||||
@ -1152,19 +1153,19 @@
|
|||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if $_user}
|
{#if $_user}
|
||||||
{#if selectedModels.length > 0 && selectedModels.some((model) => switchThinkingCapableModels.includes(model))}
|
{#if selectedModels.length > 0 && selectedModels.some( (model) => reasoningCapableModels.includes(model) )}
|
||||||
<Tooltip content={$i18n.t('Thinking')} placement="top">
|
<Tooltip content={$i18n.t('Think before responding')} placement="top">
|
||||||
<button
|
<button
|
||||||
on:click|preventDefault={() => (thinkingEnabled = !thinkingEnabled)}
|
on:click|preventDefault={() => (reasoningEnabled = !reasoningEnabled)}
|
||||||
type="button"
|
type="button"
|
||||||
class="px-1.5 @xl:px-2.5 py-1.5 flex gap-1.5 items-center text-sm rounded-full font-medium transition-colors duration-300 focus:outline-hidden max-w-full overflow-hidden border {thinkingEnabled
|
class="px-1.5 @xl:px-2.5 py-1.5 flex gap-1.5 items-center text-sm rounded-full font-medium transition-colors duration-300 focus:outline-hidden max-w-full overflow-hidden border {reasoningEnabled
|
||||||
? 'bg-blue-100 dark:bg-blue-500/20 border-blue-400/20 text-blue-500 dark:text-blue-400'
|
? 'bg-blue-100 dark:bg-blue-500/20 border-blue-400/20 text-blue-500 dark:text-blue-400'
|
||||||
: 'bg-transparent border-transparent text-gray-600 dark:text-gray-300 border-gray-200 hover:bg-gray-100 dark:hover:bg-gray-800'}"
|
: 'bg-transparent border-transparent text-gray-600 dark:text-gray-300 border-gray-200 hover:bg-gray-100 dark:hover:bg-gray-800'}"
|
||||||
>
|
>
|
||||||
<Thinking className="size-5" strokeWidth="1.75" />
|
<LightBlub className="size-5" strokeWidth="1.75" />
|
||||||
<span
|
<span
|
||||||
class="hidden @xl:block whitespace-nowrap overflow-hidden text-ellipsis translate-y-[0.5px]"
|
class="hidden @xl:block whitespace-nowrap overflow-hidden text-ellipsis translate-y-[0.5px]"
|
||||||
>{$i18n.t('Thinking')}</span
|
>{$i18n.t('Reason')}</span
|
||||||
>
|
>
|
||||||
</button>
|
</button>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
export let imageGenerationEnabled = false;
|
export let imageGenerationEnabled = false;
|
||||||
export let codeInterpreterEnabled = false;
|
export let codeInterpreterEnabled = false;
|
||||||
export let webSearchEnabled = false;
|
export let webSearchEnabled = false;
|
||||||
export let thinkingEnabled = false;
|
export let reasoningEnabled = false;
|
||||||
|
|
||||||
export let toolServers = [];
|
export let toolServers = [];
|
||||||
|
|
||||||
@ -196,7 +196,7 @@
|
|||||||
bind:imageGenerationEnabled
|
bind:imageGenerationEnabled
|
||||||
bind:codeInterpreterEnabled
|
bind:codeInterpreterEnabled
|
||||||
bind:webSearchEnabled
|
bind:webSearchEnabled
|
||||||
bind:thinkingEnabled
|
bind:reasoningEnabled
|
||||||
bind:atSelectedModel
|
bind:atSelectedModel
|
||||||
{toolServers}
|
{toolServers}
|
||||||
{transparentBackground}
|
{transparentBackground}
|
||||||
|
@ -12,14 +12,16 @@
|
|||||||
'Sends `stream_options: { include_usage: true }` in the request.\nSupported providers will return token usage information in the response when set.'
|
'Sends `stream_options: { include_usage: true }` in the request.\nSupported providers will return token usage information in the response when set.'
|
||||||
),
|
),
|
||||||
citations: $i18n.t('Displays citations in the response'),
|
citations: $i18n.t('Displays citations in the response'),
|
||||||
switch_thinking: $i18n.t('Sends `enable_thinking: true` in the request. \nSupported toggle providers will return thinking content')
|
reasoning: $i18n.t(
|
||||||
|
'Sends `enable_thinking: true` in the request. \nSupported toggle providers will return thinking content'
|
||||||
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
export let capabilities: {
|
export let capabilities: {
|
||||||
vision?: boolean;
|
vision?: boolean;
|
||||||
usage?: boolean;
|
usage?: boolean;
|
||||||
citations?: boolean;
|
citations?: boolean;
|
||||||
switch_thinking?: boolean;
|
reasoning?: boolean;
|
||||||
} = {};
|
} = {};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -77,9 +77,9 @@
|
|||||||
};
|
};
|
||||||
let capabilities = {
|
let capabilities = {
|
||||||
vision: true,
|
vision: true,
|
||||||
usage: undefined,
|
|
||||||
citations: true,
|
citations: true,
|
||||||
switch_thinking: false,
|
usage: undefined,
|
||||||
|
reasoning: false
|
||||||
};
|
};
|
||||||
|
|
||||||
let knowledge = [];
|
let knowledge = [];
|
||||||
|
Loading…
Reference in New Issue
Block a user