mirror of
https://github.com/open-webui/open-webui.git
synced 2026-03-22 14:13:08 -05:00
[PR #18573] [CLOSED] feat: Add Chat Context Awareness #11634
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/18573
Author: @Davixk
Created: 10/24/2025
Status: ❌ Closed
Base:
dev← Head:feat/add-chats-context📝 Commits (3)
e0f0351feat(chat-context): add configurable chat context injection5f212b6refactor(admin-settings): improve chat context UX with tooltips9f2f9c4refactor(middleware): centralize message content cleaning📊 Changes
6 files changed (+307 additions, -6 deletions)
View changed files
📝
backend/open_webui/config.py(+18 -0)📝
backend/open_webui/main.py(+11 -0)📝
backend/open_webui/routers/auths.py(+13 -0)📝
backend/open_webui/utils/middleware.py(+178 -6)📝
src/lib/components/admin/Settings/General.svelte(+83 -0)📝
src/lib/components/chat/Chat.svelte(+4 -0)📄 Description
Changelog Entry
Description
Implements automatic Chat Context injection that adds recent or pinned chat history to conversation context.
I believe this feature will enhance the user experience by personalizing model context. Find an example in the screenshot below.
Added
ENABLE_CHAT_CONTEXT,CHAT_CONTEXT_MODE,CHAT_CONTEXT_TOP_Kinconfig.pychat_context_handler()inutils/middleware.pysupporting:General.svelte: enable toggle, mode dropdown, top K inputChat.svelte: checks$config.chat_context.enable/api/configendpointChanged
AdminConfigmodel now includes chat context fieldsget_admin_config()andupdate_admin_config()handle chat context settingschat_context_handler()when feature enabledAdditional Information
Design decisions:
Chat format injected:
```json
[
{
"title": "Chat Title",
"created_at": "2024-01-15T10:30:00-0500",
"updated_at": "2024-01-15T11:45:00-0500",
"first_user_message": "...",
"last_messages": {
"user": "...",
"assistant": "..."
}
}
]
```
Testing: Manual testing of enable/disable, mode switching, top K validation, pinned empty/full, recent mode, config persistence, feature flag, JSON structure, multimodal handling.
Screenshots or Videos
Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.