Skip to content

Commit 4067e35

Browse files
committed
refac
1 parent 651a02e commit 4067e35

5 files changed

Lines changed: 18 additions & 1 deletion

File tree

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ OPENAI_API_KEY=''
1313
# CORS_ALLOW_ORIGIN='http://localhost:5173;http://localhost:8080'
1414
CORS_ALLOW_ORIGIN='*'
1515

16+
# Set to false to keep memory tools enabled without adding memory context to the system context.
17+
ENABLE_MEMORY_SYSTEM_CONTEXT=true
18+
1619
# For production you should set this to match the proxy configuration (127.0.0.1)
1720
FORWARDED_ALLOW_IPS='*'
1821

backend/open_webui/config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ def reachable(host: str, port: int) -> bool:
394394
ENABLE_CODE_INTERPRETER = os.getenv('ENABLE_CODE_INTERPRETER', 'True').lower() == 'true'
395395

396396
ENABLE_MEMORIES = os.getenv('ENABLE_MEMORIES', 'True').lower() == 'true'
397+
ENABLE_MEMORY_SYSTEM_CONTEXT = os.getenv('ENABLE_MEMORY_SYSTEM_CONTEXT', 'True').lower() == 'true'
397398
ENABLE_MEMORY_BACKGROUND_REVIEW = os.getenv('ENABLE_MEMORY_BACKGROUND_REVIEW', 'False').lower() == 'true'
398399
MEMORIES_REVIEW_INTERVAL_TURNS = int(os.getenv('MEMORIES_REVIEW_INTERVAL_TURNS', '10'))
399400
MEMORIES_USER_CHAR_LIMIT = int(os.getenv('MEMORIES_USER_CHAR_LIMIT', '2000'))
@@ -2741,6 +2742,7 @@ def feishu_oauth_register(oauth: OAuth):
27412742
'code_execution.jupyter.timeout': CODE_EXECUTION_JUPYTER_TIMEOUT,
27422743
'code_interpreter.enable': ENABLE_CODE_INTERPRETER,
27432744
'memories.enable': ENABLE_MEMORIES,
2745+
'memories.system_context.enable': ENABLE_MEMORY_SYSTEM_CONTEXT,
27442746
'memories.background_review.enable': ENABLE_MEMORY_BACKGROUND_REVIEW,
27452747
'memories.review_interval_turns': MEMORIES_REVIEW_INTERVAL_TURNS,
27462748
'memories.user_char_limit': MEMORIES_USER_CHAR_LIMIT,

backend/open_webui/routers/auths.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
'ENABLE_CHANNELS': 'channels.enable',
106106
'ENABLE_CALENDAR': 'calendar.enable',
107107
'ENABLE_MEMORIES': 'memories.enable',
108+
'ENABLE_MEMORY_SYSTEM_CONTEXT': 'memories.system_context.enable',
108109
'ENABLE_NOTES': 'notes.enable',
109110
'ENABLE_USER_WEBHOOKS': 'ui.enable_user_webhooks',
110111
'ENABLE_USER_STATUS': 'users.enable_status',
@@ -1142,6 +1143,7 @@ class AdminConfig(BaseModel):
11421143
ENABLE_CHANNELS: bool
11431144
ENABLE_CALENDAR: bool
11441145
ENABLE_MEMORIES: bool
1146+
ENABLE_MEMORY_SYSTEM_CONTEXT: bool
11451147
ENABLE_NOTES: bool
11461148
ENABLE_USER_WEBHOOKS: bool
11471149
ENABLE_USER_STATUS: bool

backend/open_webui/utils/middleware.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2427,7 +2427,7 @@ async def process_chat_payload(request, form_data, user, metadata, model):
24272427
form_data['messages'],
24282428
)
24292429

2430-
if 'memory' in features and features['memory']:
2430+
if 'memory' in features and features['memory'] and await Config.get('memories.system_context.enable'):
24312431
form_data = await add_memory_context(request, form_data, user, model)
24322432

24332433
if 'web_search' in features and features['web_search']:

src/lib/components/admin/Settings/General.svelte

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,16 @@
297297
<Switch bind:state={adminConfig.ENABLE_MEMORIES} />
298298
</div>
299299

300+
{#if adminConfig.ENABLE_MEMORIES}
301+
<div class="mb-2.5 flex w-full items-center justify-between pr-2 pl-4">
302+
<div class=" self-center text-xs font-medium text-gray-500 dark:text-gray-400">
303+
{$i18n.t('Memory System Context')}
304+
</div>
305+
306+
<Switch bind:state={adminConfig.ENABLE_MEMORY_SYSTEM_CONTEXT} />
307+
</div>
308+
{/if}
309+
300310
<div class="mb-2.5 flex w-full items-center justify-between pr-2">
301311
<div class=" self-center text-xs font-medium">
302312
{$i18n.t('Notes')}

0 commit comments

Comments
 (0)