mirror of
https://github.com/open-webui/open-webui.git
synced 2026-11-18 10:01:33 +00:00
fix: send the new model's web search default after an in-chat model switch
Switching the model in an open chat sent the previous model's web search state with the next message, while the composer toggle showed the new model's default. Switching to a model with web search on by default showed the toggle on and sent web_search: false, and switching away from one showed it off and sent true. Waiting before sending did not help. The value sent with the request is worked out by a reactive statement near the top of the file, and the new model's defaults are applied by another one further down. Svelte runs reactive statements that do not depend on each other in source order, so the value was worked out from the previous model's state and not again after the defaults changed. Both web search statements now sit below the model-change statement, so the defaults are in place first. Every other reactive statement keeps its order. Moving only the first of the two does nothing, because the compiler pulls it back above the second, which reads its result. Moving the model-change statement up instead also fixes it, but then it runs before the tool approval statement too, and a chat's tool approval choice is no longer restored after an OAuth sign-in redirect. With the web search confirmation turned on, switching to another model that also has web search on by default now asks again if that model has default tools, the same as turning the toggle off and on already does. Fixes #29326
This commit is contained in:
parent
24c01bd76d
commit
d396c3fc02
1 changed files with 19 additions and 19 deletions
|
|
@ -339,21 +339,6 @@
|
|||
let pendingWebSearchPrompt: string | null = null;
|
||||
let webSearchConfirmed = false;
|
||||
|
||||
$: {
|
||||
const currentModels = atSelectedModel?.id ? [atSelectedModel.id] : selectedModels;
|
||||
const allModelsSupportWebSearch =
|
||||
currentModels.filter(
|
||||
(model) => $models.find((m) => m.id === model)?.info?.meta?.capabilities?.web_search ?? true
|
||||
).length === currentModels.length;
|
||||
|
||||
webSearchActive = Boolean(
|
||||
$config?.features?.enable_web_search &&
|
||||
($user?.role === 'admin' || $user?.permissions?.features?.web_search) &&
|
||||
(webSearchEnabled ||
|
||||
(allModelsSupportWebSearch && ($settings?.webSearch ?? false) === 'always'))
|
||||
);
|
||||
}
|
||||
|
||||
const openWebSearchConfirm = () => {
|
||||
window.setTimeout(() => {
|
||||
showWebSearchConfirm = true;
|
||||
|
|
@ -374,10 +359,6 @@
|
|||
showWebSearchConfirm = false;
|
||||
};
|
||||
|
||||
$: if (!webSearchActive) {
|
||||
resetWebSearchConfirmation();
|
||||
}
|
||||
|
||||
let showCommands = false;
|
||||
|
||||
let generating = false;
|
||||
|
|
@ -743,6 +724,25 @@
|
|||
oldSelectedModelIds = structuredClone(selectedModelIds);
|
||||
};
|
||||
|
||||
$: {
|
||||
const currentModels = atSelectedModel?.id ? [atSelectedModel.id] : selectedModels;
|
||||
const allModelsSupportWebSearch =
|
||||
currentModels.filter(
|
||||
(model) => $models.find((m) => m.id === model)?.info?.meta?.capabilities?.web_search ?? true
|
||||
).length === currentModels.length;
|
||||
|
||||
webSearchActive = Boolean(
|
||||
$config?.features?.enable_web_search &&
|
||||
($user?.role === 'admin' || $user?.permissions?.features?.web_search) &&
|
||||
(webSearchEnabled ||
|
||||
(allModelsSupportWebSearch && ($settings?.webSearch ?? false) === 'always'))
|
||||
);
|
||||
}
|
||||
|
||||
$: if (!webSearchActive) {
|
||||
resetWebSearchConfirmation();
|
||||
}
|
||||
|
||||
const mergeFiles = (current, incoming) => {
|
||||
const seen = new Set();
|
||||
return [...(incoming ?? []), ...(current ?? [])].filter((file) => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue