[PR #23517] [CLOSED] feat: add a configurable limit for how many model can be prompted in a chat #82105

Closed
opened 2026-05-13 16:33:37 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/23517
Author: @lorenzophys
Created: 4/8/2026
Status: Closed

Base: devHead: max-chat-models


📝 Commits (1)

  • 5b3f4c4 feat: 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_MODELS environment 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

  • New MAX_CHAT_MODELS PersistentConfig entry, readable from the MAX_CHAT_MODELS environment variable (empty = unlimited)
  • Initialized app.state.config.MAX_CHAT_MODELS on startup
  • Exposed max_chat_models in the GET /api/config features response so the frontend can read it
  • Added MAX_CHAT_MODELS to the GET /auths/admin/config response so the value is loaded in the admin panel
  • Added MAX_CHAT_MODELS field to the AdminConfig Pydantic model
  • Saved the value in POST /auths/admin/config (casted to int, or '' for unlimited)
  • Included MAX_CHAT_MODELS in the POST response
  • Added max_chat_models?: number to the features block of the Config type.
  • New number input field "Max Chat Models" below the "Folder Max File Count" field, following the same pattern: min="1", placeholder "Leave empty for unlimited", linked to adminConfig.MAX_CHAT_MODELS
  • The "Add Model" button is hidden when the number of selected models reaches the MAX_CHAT_MODELS
  • When loading a chat, selectedModels is trimmed to max_chat_models if 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_COUNT so that it blends nicely with the existing code.

Breaking Changes

  • None, the default is unlimited as it is now

Test

Build the container with MAX_CHAT_MODELS=3 and you get this:

Screenshot 2026-04-08 at 20 31 27

If I try to set the value to zero it won't let me and will explain why

Screenshot 2026-04-08 at 20 32 06

Note that after adding the third model the plus sign disappears making it impossible to add more.

Screenshot 2026-04-08 at 20 13 44

Contributor License Agreement

Note

Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/23517 **Author:** [@lorenzophys](https://github.com/lorenzophys) **Created:** 4/8/2026 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `max-chat-models` --- ### 📝 Commits (1) - [`5b3f4c4`](https://github.com/open-webui/open-webui/commit/5b3f4c4db667211cde7b0251c3fad727b3f6a8a0) feat: add a configurable limit for how many model can be prompted in a chat ### 📊 Changes **7 files changed** (+44 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `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) </details> ### 📄 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_MODELS` environment 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 - New `MAX_CHAT_MODELS` `PersistentConfig` entry, readable from the `MAX_CHAT_MODELS` environment variable (empty = unlimited) - Initialized `app.state.config.MAX_CHAT_MODELS` on startup - Exposed `max_chat_models` in the `GET /api/config` features response so the frontend can read it - Added `MAX_CHAT_MODELS` to the `GET /auths/admin/config` response so the value is loaded in the admin panel - Added `MAX_CHAT_MODELS` field to the `AdminConfig` Pydantic model - Saved the value in `POST /auths/admin/config` (casted to int, or `''` for unlimited) - Included `MAX_CHAT_MODELS` in the `POST` response - Added `max_chat_models?: number` to the `features` block of the `Config` type. - New number input field "Max Chat Models" below the "Folder Max File Count" field, following the same pattern: min="1", placeholder "Leave empty for unlimited", linked to `adminConfig.MAX_CHAT_MODELS` - The "Add Model" button is hidden when the number of selected models reaches the `MAX_CHAT_MODELS` - When loading a chat, `selectedModels` is trimmed to `max_chat_models` if 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_COUNT` so that it blends nicely with the existing code. ### Breaking Changes - None, the default is unlimited as it is now --- ### Test Build the container with `MAX_CHAT_MODELS=3` and you get this: <img width="1231" height="593" alt="Screenshot 2026-04-08 at 20 31 27" src="https://github.com/user-attachments/assets/507a3478-b0cd-4cf6-ad10-e2a8f8acc515" /> If I try to set the value to zero it won't let me and will explain why <img width="705" height="131" alt="Screenshot 2026-04-08 at 20 32 06" src="https://github.com/user-attachments/assets/24e5737d-9c1a-4fa9-aa00-815eda14b0b7" /> Note that after adding the third model the plus sign disappears making it impossible to add more. <img width="1189" height="745" alt="Screenshot 2026-04-08 at 20 13 44" src="https://github.com/user-attachments/assets/1e8b5e5d-98c1-42e3-80c0-fbdb06d14691" /> ### Contributor License Agreement <!-- 🚨 DO NOT DELETE THE TEXT BELOW 🚨 Keep the "Contributor License Agreement" confirmation text intact. Deleting it will trigger the CLA-Bot to INVALIDATE your PR. Your PR will NOT be reviewed or merged until you check the box below confirming that you have read and agree to the terms of the CLA. --> - [x] By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. > [!NOTE] > Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-13 16:33:37 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#82105