mirror of
https://github.com/open-webui/open-webui.git
synced 2026-11-24 14:30:20 -05:00
refac
This commit is contained in:
1 parent
1a7a13dc06
commit
269b1bcc2b
3 files changed
+37
-22
No files matched your search
@@ -471,7 +471,7 @@
|
||||
$: contextThreshold = contextCompactionEnabled
|
||||
? (getContextThreshold(
|
||||
atSelectedModel?.id ?? selectedModels.find((id) => id),
|
||||
$models,
|
||||
$models ?? [],
|
||||
params
|
||||
) ??
|
||||
serverContextUsage?.threshold ??
|
||||
@@ -508,7 +508,8 @@
|
||||
const currentModels = atSelectedModel?.id ? [atSelectedModel.id] : selectedModels;
|
||||
const allModelsSupportWebSearch =
|
||||
currentModels.filter(
|
||||
(model) => ($models ?? []).find((m) => m.id === model)?.info?.meta?.capabilities?.web_search ?? true
|
||||
(model) =>
|
||||
($models ?? []).find((m) => m.id === model)?.info?.meta?.capabilities?.web_search ?? true
|
||||
).length === currentModels.length;
|
||||
|
||||
webSearchActive = Boolean(
|
||||
@@ -1410,7 +1411,9 @@
|
||||
)
|
||||
return;
|
||||
|
||||
const currentModels: any[] = modelIds.map((id) => ($models ?? []).find((model) => model.id === id));
|
||||
const currentModels: any[] = modelIds.map((id) =>
|
||||
($models ?? []).find((model) => model.id === id)
|
||||
);
|
||||
if (!currentModels.length || currentModels.some((model) => !model)) return;
|
||||
const supports = (feature: string) =>
|
||||
currentModels.every((model) => model.info?.meta?.capabilities?.[feature] ?? true);
|
||||
@@ -3088,7 +3091,8 @@
|
||||
|
||||
// Unavailable models filtering
|
||||
selectedModels = selectedModels.filter(
|
||||
(modelId) => modelId.startsWith('agent:') || ($models ?? []).map((m) => m.id).includes(modelId)
|
||||
(modelId) =>
|
||||
modelId.startsWith('agent:') || ($models ?? []).map((m) => m.id).includes(modelId)
|
||||
);
|
||||
} else {
|
||||
if (destinationFolder) {
|
||||
@@ -3290,7 +3294,9 @@
|
||||
}
|
||||
|
||||
selectedModels = selectedModels.map((modelId) =>
|
||||
modelId.startsWith('agent:') || ($models ?? []).map((m) => m.id).includes(modelId) ? modelId : ''
|
||||
modelId.startsWith('agent:') || ($models ?? []).map((m) => m.id).includes(modelId)
|
||||
? modelId
|
||||
: ''
|
||||
);
|
||||
|
||||
await tick();
|
||||
@@ -3391,7 +3397,8 @@
|
||||
// An empty model list is not evidence that the chat's models are gone.
|
||||
if (($models ?? []).length > 0) {
|
||||
selectedModels = selectedModels.filter(
|
||||
(modelId) => modelId.startsWith('agent:') || ($models ?? []).map((m) => m.id).includes(modelId)
|
||||
(modelId) =>
|
||||
modelId.startsWith('agent:') || ($models ?? []).map((m) => m.id).includes(modelId)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4634,7 +4641,9 @@
|
||||
return { status: 'rejected' };
|
||||
|
||||
const _selectedModels = selectedModels.map((modelId) =>
|
||||
modelId.startsWith('agent:') || ($models ?? []).map((m) => m.id).includes(modelId) ? modelId : ''
|
||||
modelId.startsWith('agent:') || ($models ?? []).map((m) => m.id).includes(modelId)
|
||||
? modelId
|
||||
: ''
|
||||
);
|
||||
|
||||
if (!equal(selectedModels, _selectedModels)) {
|
||||
|
||||
@@ -196,8 +196,8 @@
|
||||
$: selectedModelIds = atSelectedModel !== undefined ? [atSelectedModel.id] : selectedModels;
|
||||
$: hasChatVariables = selectedModelIds.some(
|
||||
(modelId) =>
|
||||
(($models ?? []).find((model) => model.id === modelId)?.info?.meta?.chat_variables_schema?.fields
|
||||
?.length ?? 0) > 0
|
||||
(($models ?? []).find((model) => model.id === modelId)?.info?.meta?.chat_variables_schema
|
||||
?.fields?.length ?? 0) > 0
|
||||
);
|
||||
|
||||
export let history;
|
||||
@@ -3058,18 +3058,20 @@
|
||||
</div>
|
||||
|
||||
<div class="self-end flex space-x-1 mr-1 min-w-0 gap-[0.03125rem]">
|
||||
<div class="flex min-w-0 max-w-[10rem] items-center sm:max-w-[13rem]">
|
||||
<ModelSelector
|
||||
bind:this={modelSelector}
|
||||
multipleEnabled={multipleModels}
|
||||
bind:selectedModels
|
||||
{onModelSelect}
|
||||
showSetDefault={!history?.currentId}
|
||||
placement="auto"
|
||||
align="end"
|
||||
triggerClassName="items-center gap-1.5 rounded-lg pl-2 pr-1.5 py-1 text-[0.8125rem] font-normal text-base-600 transition-colors duration-100 hover:bg-base-50/40 hover:text-base-700 dark:text-base-300 dark:hover:bg-base-800/40 dark:hover:text-base-200"
|
||||
/>
|
||||
</div>
|
||||
{#if $models !== null}
|
||||
<div class="flex min-w-0 max-w-[10rem] items-center sm:max-w-[13rem]">
|
||||
<ModelSelector
|
||||
bind:this={modelSelector}
|
||||
multipleEnabled={multipleModels}
|
||||
bind:selectedModels
|
||||
{onModelSelect}
|
||||
showSetDefault={!history?.currentId}
|
||||
placement="auto"
|
||||
align="end"
|
||||
triggerClassName="items-center gap-1.5 rounded-lg pl-2 pr-1.5 py-1 text-[0.8125rem] font-normal text-base-600 transition-colors duration-100 hover:bg-base-50/40 hover:text-base-700 dark:text-base-300 dark:hover:bg-base-800/40 dark:hover:text-base-200"
|
||||
/>
|
||||
</div>
|
||||
{/if}
|
||||
<ModelControls
|
||||
selectedModels={selectedModelIds}
|
||||
bind:chatFiles
|
||||
|
||||
@@ -258,7 +258,11 @@
|
||||
setBanners().catch((e) => console.error('Failed to load banners:', e)),
|
||||
setTools().catch((e) => console.error('Failed to load tools:', e)),
|
||||
setUserSettings(),
|
||||
setModels().catch((e) => console.error('Failed to load models:', e)),
|
||||
setModels().catch((e) => {
|
||||
console.error('Failed to load models:', e);
|
||||
// Loaded, with nothing to list: null would mean the list is still on its way.
|
||||
models.update((list) => list ?? []);
|
||||
}),
|
||||
refreshMachines().catch((e) => console.error('Failed to load machines:', e))
|
||||
]);
|
||||
} catch (e) {
|
||||
|
||||
Reference in new issue
Block a user