mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-14 21:35:19 +00:00
feat: 记忆功能支持在新对话决定是否启用
This commit is contained in:
parent
fbaa3327c4
commit
87a44a2ecb
4 changed files with 46 additions and 1 deletions
|
|
@ -129,6 +129,7 @@
|
||||||
let imageGenerationEnabled = false;
|
let imageGenerationEnabled = false;
|
||||||
let webSearchEnabled = false;
|
let webSearchEnabled = false;
|
||||||
let codeInterpreterEnabled = false;
|
let codeInterpreterEnabled = false;
|
||||||
|
let memoryEnabled = true;
|
||||||
|
|
||||||
let showCommands = false;
|
let showCommands = false;
|
||||||
|
|
||||||
|
|
@ -166,6 +167,7 @@
|
||||||
selectedFilterIds = [];
|
selectedFilterIds = [];
|
||||||
webSearchEnabled = false;
|
webSearchEnabled = false;
|
||||||
imageGenerationEnabled = false;
|
imageGenerationEnabled = false;
|
||||||
|
memoryEnabled = true;
|
||||||
|
|
||||||
const storageChatInput = sessionStorage.getItem(
|
const storageChatInput = sessionStorage.getItem(
|
||||||
`chat-input${chatIdProp ? `-${chatIdProp}` : ''}`
|
`chat-input${chatIdProp ? `-${chatIdProp}` : ''}`
|
||||||
|
|
@ -190,6 +192,7 @@
|
||||||
webSearchEnabled = input.webSearchEnabled;
|
webSearchEnabled = input.webSearchEnabled;
|
||||||
imageGenerationEnabled = input.imageGenerationEnabled;
|
imageGenerationEnabled = input.imageGenerationEnabled;
|
||||||
codeInterpreterEnabled = input.codeInterpreterEnabled;
|
codeInterpreterEnabled = input.codeInterpreterEnabled;
|
||||||
|
memoryEnabled = input.memoryEnabled;
|
||||||
}
|
}
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
|
@ -250,6 +253,7 @@
|
||||||
webSearchEnabled = false;
|
webSearchEnabled = false;
|
||||||
imageGenerationEnabled = false;
|
imageGenerationEnabled = false;
|
||||||
codeInterpreterEnabled = false;
|
codeInterpreterEnabled = false;
|
||||||
|
memoryEnabled = true;
|
||||||
|
|
||||||
setDefaults();
|
setDefaults();
|
||||||
};
|
};
|
||||||
|
|
@ -296,6 +300,10 @@
|
||||||
if (model.info?.meta?.capabilities?.['code_interpreter']) {
|
if (model.info?.meta?.capabilities?.['code_interpreter']) {
|
||||||
codeInterpreterEnabled = model.info.meta.defaultFeatureIds.includes('code_interpreter');
|
codeInterpreterEnabled = model.info.meta.defaultFeatureIds.includes('code_interpreter');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (model.info?.meta?.capabilities?.['memory']) {
|
||||||
|
memoryEnabled = model.info.meta.defaultFeatureIds.includes('memory');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -559,6 +567,7 @@
|
||||||
webSearchEnabled = false;
|
webSearchEnabled = false;
|
||||||
imageGenerationEnabled = false;
|
imageGenerationEnabled = false;
|
||||||
codeInterpreterEnabled = false;
|
codeInterpreterEnabled = false;
|
||||||
|
memoryEnabled = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const input = JSON.parse(storageChatInput);
|
const input = JSON.parse(storageChatInput);
|
||||||
|
|
@ -571,6 +580,7 @@
|
||||||
webSearchEnabled = input.webSearchEnabled;
|
webSearchEnabled = input.webSearchEnabled;
|
||||||
imageGenerationEnabled = input.imageGenerationEnabled;
|
imageGenerationEnabled = input.imageGenerationEnabled;
|
||||||
codeInterpreterEnabled = input.codeInterpreterEnabled;
|
codeInterpreterEnabled = input.codeInterpreterEnabled;
|
||||||
|
memoryEnabled = input.memoryEnabled;
|
||||||
}
|
}
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
|
@ -1749,6 +1759,11 @@
|
||||||
features = { ...features, memory: true };
|
features = { ...features, memory: true };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 如果用户手动切换了记忆开关,覆盖全局设置
|
||||||
|
if (memoryEnabled !== undefined && memoryEnabled !== ($settings?.memory ?? false)) {
|
||||||
|
features = { ...features, memory: memoryEnabled };
|
||||||
|
}
|
||||||
|
|
||||||
return features;
|
return features;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -2454,6 +2469,7 @@
|
||||||
bind:imageGenerationEnabled
|
bind:imageGenerationEnabled
|
||||||
bind:codeInterpreterEnabled
|
bind:codeInterpreterEnabled
|
||||||
bind:webSearchEnabled
|
bind:webSearchEnabled
|
||||||
|
bind:memoryEnabled
|
||||||
bind:atSelectedModel
|
bind:atSelectedModel
|
||||||
bind:showCommands
|
bind:showCommands
|
||||||
toolServers={$toolServers}
|
toolServers={$toolServers}
|
||||||
|
|
@ -2506,6 +2522,7 @@
|
||||||
bind:imageGenerationEnabled
|
bind:imageGenerationEnabled
|
||||||
bind:codeInterpreterEnabled
|
bind:codeInterpreterEnabled
|
||||||
bind:webSearchEnabled
|
bind:webSearchEnabled
|
||||||
|
bind:memoryEnabled
|
||||||
bind:atSelectedModel
|
bind:atSelectedModel
|
||||||
bind:showCommands
|
bind:showCommands
|
||||||
toolServers={$toolServers}
|
toolServers={$toolServers}
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,7 @@
|
||||||
import Tooltip from '../common/Tooltip.svelte';
|
import Tooltip from '../common/Tooltip.svelte';
|
||||||
import FileItem from '../common/FileItem.svelte';
|
import FileItem from '../common/FileItem.svelte';
|
||||||
import Image from '../common/Image.svelte';
|
import Image from '../common/Image.svelte';
|
||||||
|
import Switch from '../common/Switch.svelte';
|
||||||
|
|
||||||
import XMark from '../icons/XMark.svelte';
|
import XMark from '../icons/XMark.svelte';
|
||||||
import Headphone from '../icons/Headphone.svelte';
|
import Headphone from '../icons/Headphone.svelte';
|
||||||
|
|
@ -108,6 +109,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 memoryEnabled = false;
|
||||||
|
|
||||||
let showInputVariablesModal = false;
|
let showInputVariablesModal = false;
|
||||||
let inputVariablesModalCallback = (variableValues) => {};
|
let inputVariablesModalCallback = (variableValues) => {};
|
||||||
|
|
@ -138,7 +140,8 @@
|
||||||
selectedFilterIds,
|
selectedFilterIds,
|
||||||
imageGenerationEnabled,
|
imageGenerationEnabled,
|
||||||
webSearchEnabled,
|
webSearchEnabled,
|
||||||
codeInterpreterEnabled
|
codeInterpreterEnabled,
|
||||||
|
memoryEnabled
|
||||||
});
|
});
|
||||||
|
|
||||||
const inputVariableHandler = async (text: string): Promise<string> => {
|
const inputVariableHandler = async (text: string): Promise<string> => {
|
||||||
|
|
@ -475,6 +478,9 @@
|
||||||
$config?.features?.enable_code_interpreter &&
|
$config?.features?.enable_code_interpreter &&
|
||||||
($_user.role === 'admin' || $_user?.permissions?.features?.code_interpreter);
|
($_user.role === 'admin' || $_user?.permissions?.features?.code_interpreter);
|
||||||
|
|
||||||
|
let showMemoryButton = false;
|
||||||
|
$: showMemoryButton = $settings?.memory !== undefined;
|
||||||
|
|
||||||
const scrollToBottom = () => {
|
const scrollToBottom = () => {
|
||||||
const element = document.getElementById('messages-container');
|
const element = document.getElementById('messages-container');
|
||||||
element.scrollTo({
|
element.scrollTo({
|
||||||
|
|
@ -1330,6 +1336,7 @@
|
||||||
webSearchEnabled = false;
|
webSearchEnabled = false;
|
||||||
imageGenerationEnabled = false;
|
imageGenerationEnabled = false;
|
||||||
codeInterpreterEnabled = false;
|
codeInterpreterEnabled = false;
|
||||||
|
memoryEnabled = false;
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
on:paste={async (e) => {
|
on:paste={async (e) => {
|
||||||
|
|
@ -1471,6 +1478,7 @@
|
||||||
bind:webSearchEnabled
|
bind:webSearchEnabled
|
||||||
bind:imageGenerationEnabled
|
bind:imageGenerationEnabled
|
||||||
bind:codeInterpreterEnabled
|
bind:codeInterpreterEnabled
|
||||||
|
bind:memoryEnabled
|
||||||
closeOnOutsideClick={integrationsMenuCloseOnOutsideClick}
|
closeOnOutsideClick={integrationsMenuCloseOnOutsideClick}
|
||||||
onShowValves={(e) => {
|
onShowValves={(e) => {
|
||||||
const { type, id } = e;
|
const { type, id } = e;
|
||||||
|
|
@ -1495,6 +1503,23 @@
|
||||||
</IntegrationsMenu>
|
</IntegrationsMenu>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
{#if showMemoryButton}
|
||||||
|
<div
|
||||||
|
class="flex items-center gap-2 bg-transparent hover:bg-gray-50 dark:hover:bg-gray-800 rounded-full px-2.5 py-1.5 transition"
|
||||||
|
>
|
||||||
|
<div class="flex items-center gap-1.5 text-gray-700 dark:text-gray-300">
|
||||||
|
<Sparkles className="size-4" strokeWidth="1.5" />
|
||||||
|
<span class="text-sm">{$i18n.t('Memory')}</span>
|
||||||
|
</div>
|
||||||
|
<Switch
|
||||||
|
bind:state={memoryEnabled}
|
||||||
|
on:change={async () => {
|
||||||
|
await tick();
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
{#if selectedModelIds.length === 1 && $models.find((m) => m.id === selectedModelIds[0])?.has_user_valves}
|
{#if selectedModelIds.length === 1 && $models.find((m) => m.id === selectedModelIds[0])?.has_user_valves}
|
||||||
<div class="ml-1 flex gap-1.5">
|
<div class="ml-1 flex gap-1.5">
|
||||||
<Tooltip content={$i18n.t('Valves')} placement="top">
|
<Tooltip content={$i18n.t('Valves')} placement="top">
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@
|
||||||
export let imageGenerationEnabled = false;
|
export let imageGenerationEnabled = false;
|
||||||
export let showCodeInterpreterButton = false;
|
export let showCodeInterpreterButton = false;
|
||||||
export let codeInterpreterEnabled = false;
|
export let codeInterpreterEnabled = false;
|
||||||
|
export let memoryEnabled = false;
|
||||||
|
|
||||||
export let onShowValves: Function;
|
export let onShowValves: Function;
|
||||||
export let onClose: Function;
|
export let onClose: Function;
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,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 memoryEnabled = false;
|
||||||
|
|
||||||
export let onSelect = (e) => {};
|
export let onSelect = (e) => {};
|
||||||
export let onChange = (e) => {};
|
export let onChange = (e) => {};
|
||||||
|
|
@ -213,6 +214,7 @@
|
||||||
bind:imageGenerationEnabled
|
bind:imageGenerationEnabled
|
||||||
bind:codeInterpreterEnabled
|
bind:codeInterpreterEnabled
|
||||||
bind:webSearchEnabled
|
bind:webSearchEnabled
|
||||||
|
bind:memoryEnabled
|
||||||
bind:atSelectedModel
|
bind:atSelectedModel
|
||||||
bind:showCommands
|
bind:showCommands
|
||||||
{toolServers}
|
{toolServers}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue