mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-21 09:01:47 -05:00
[PR #23517] [CLOSED] feat: add a configurable limit for how many model can be prompted in a chat #82105
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/23517
Author: @lorenzophys
Created: 4/8/2026
Status: ❌ Closed
Base:
dev← Head:max-chat-models📝 Commits (1)
5b3f4c4feat: add a configurable limit for how many model can be prompted in a chat📊 Changes
7 files changed (+44 additions, -1 deletions)
View changed files
📝
backend/open_webui/config.py(+6 -0)📝
backend/open_webui/main.py(+3 -0)📝
backend/open_webui/routers/auths.py(+6 -0)📝
src/lib/components/admin/Settings/General.svelte(+22 -0)📝
src/lib/components/chat/Chat.svelte(+5 -0)📝
src/lib/components/chat/ModelSelector.svelte(+1 -1)📝
src/lib/stores/index.ts(+1 -0)📄 Description
Description
This PR adds a configurable limit on the number of models that can be used simultaneously in a single chat. By default the limit is unlimited, preserving existing behavior. The number of models can be specified via the
MAX_CHAT_MODELSenvironment variable or from the Admin Panel > Settings > General under "Features".The reason for this is that having the possibility to prompt unlimited models simultaneously, some users will use this feature to the maximum of its capacity generating high cost and big headaches. We have it written in the guidelines to use max 3 models, but nobody reads the guidelines :)
Added
MAX_CHAT_MODELSPersistentConfigentry, readable from theMAX_CHAT_MODELSenvironment variable (empty = unlimited)app.state.config.MAX_CHAT_MODELSon startupmax_chat_modelsin theGET /api/configfeatures response so the frontend can read itMAX_CHAT_MODELSto theGET /auths/admin/configresponse so the value is loaded in the admin panelMAX_CHAT_MODELSfield to theAdminConfigPydantic modelPOST /auths/admin/config(casted to int, or''for unlimited)MAX_CHAT_MODELSin thePOSTresponsemax_chat_models?: numberto thefeaturesblock of theConfigtype.adminConfig.MAX_CHAT_MODELSMAX_CHAT_MODELSselectedModelsis trimmed tomax_chat_modelsif the saved chat contains more models than the current limit allows. It handles a specific case when a chat was saved when the limit was higher, and later an admin lowers the limit. This way there is no way of going around the limit.Note
I made this feature as similar as possible to the
FOLDER_MAX_FILE_COUNTso that it blends nicely with the existing code.Breaking Changes
Test
Build the container with
MAX_CHAT_MODELS=3and you get this:If I try to set the value to zero it won't let me and will explain why
Note that after adding the third model the plus sign disappears making it impossible to add more.
Contributor License Agreement
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.