This commit introduces a scalable, multi-tenant architecture for Milvus, mirroring the existing Qdrant implementation. When enabled via the ENABLE_MILVUS_MULTITENANCY_MODE environment variable, this mode utilizes a fixed set of shared collections instead of creating a new collection for each resource.
Data isolation is achieved by adding a resource_id to each vector's metadata and applying a filter expression (expr) to all database operations. This prevents the proliferation of collections, which can lead to performance degradation and resource exhaustion in large-scale deployments.
The implementation includes:
A new milvus_multitenancy.py module with the multi-tenant client.
Configuration variables in config.py to enable the mode and define the collection prefix.
Updated logic in the factory.py to conditionally select the appropriate Milvus client.
Pull Request Checklist
Note to first-time contributors: Please open a discussion post in Discussions and describe your changes before submitting a pull request.
Before submitting, make sure you've checked the following:
Target branch: Please verify that the pull request targets the dev branch.
Description: Provide a concise description of the changes made in this pull request.
Changelog: Ensure a changelog entry following the format of Keep a Changelog is added at the bottom of the PR description.
Documentation: Have you updated relevant documentation Open WebUI Docs, or other documentation sources?
Dependencies: Are there any new dependencies? Have you updated the dependency versions in the documentation?
Testing: Have you written and run sufficient tests to validate the changes?
Code review: Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards?
Prefix: To clearly categorize this pull request, prefix the pull request title using one of the following:
feat: Introduces a new feature or enhancement to the codebase
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.
## 📋 Pull Request Information
**Original PR:** https://github.com/open-webui/open-webui/pull/17776
**Author:** [@Classic298](https://github.com/Classic298)
**Created:** 9/26/2025
**Status:** ❌ Closed
**Base:** `dev` ← **Head:** `feat/milvus-multitenancy-1`
---
### 📝 Commits (3)
- [`e0ec1d0`](https://github.com/open-webui/open-webui/commit/e0ec1d0c069a1d04ba8f22738aaace4d8b5a42de) feat: Implement Milvus multi-tenancy mode
- [`4fdfd35`](https://github.com/open-webui/open-webui/commit/4fdfd357bb5acfc7350587faa7e8a01f2946b3bd) Merge branch 'dev' into feat/milvus-multitenancy-1
- [`e677c9b`](https://github.com/open-webui/open-webui/commit/e677c9ba9a9adc0bf1315921f104fa40aabb183c) feat: Implement Milvus multi-tenancy mode
### 📊 Changes
**22 files changed** (+482 additions, -349 deletions)
<details>
<summary>View changed files</summary>
📝 `backend/open_webui/config.py` (+4 -9)
📝 `backend/open_webui/retrieval/vector/dbs/milvus.py` (+4 -12)
➕ `backend/open_webui/retrieval/vector/dbs/milvus_multitenancy.py` (+281 -0)
📝 `backend/open_webui/retrieval/vector/factory.py` (+14 -3)
📝 `backend/open_webui/routers/configs.py` (+29 -30)
📝 `backend/open_webui/routers/notes.py` (+0 -12)
📝 `backend/open_webui/routers/users.py` (+0 -1)
📝 `backend/open_webui/utils/middleware.py` (+1 -99)
📝 `backend/open_webui/utils/oauth.py` (+5 -17)
📝 `src/lib/apis/files/index.ts` (+1 -1)
📝 `src/lib/components/admin/Settings/Evaluations/Model.svelte` (+1 -1)
📝 `src/lib/components/admin/Users/Groups/Permissions.svelte` (+1 -9)
📝 `src/lib/components/chat/MessageInput.svelte` (+12 -12)
📝 `src/lib/components/chat/MessageInput/IntegrationsMenu.svelte` (+21 -3)
📝 `src/lib/components/chat/ModelSelector.svelte` (+1 -1)
📝 `src/lib/components/chat/ModelSelector/Selector.svelte` (+13 -15)
➖ `src/lib/components/icons/Knobs.svelte` (+0 -24)
📝 `src/lib/components/workspace/Models.svelte` (+10 -12)
📝 `src/lib/i18n/locales/de-DE/translation.json` (+41 -41)
📝 `src/lib/i18n/locales/pt-BR/translation.json` (+23 -23)
_...and 2 more files_
</details>
### 📄 Description
This commit introduces a scalable, multi-tenant architecture for Milvus, mirroring the existing Qdrant implementation. When enabled via the `ENABLE_MILVUS_MULTITENANCY_MODE` environment variable, this mode utilizes a fixed set of shared collections instead of creating a new collection for each resource.
Data isolation is achieved by adding a `resource_id` to each vector's metadata and applying a filter expression (`expr`) to all database operations. This prevents the proliferation of collections, which can lead to performance degradation and resource exhaustion in large-scale deployments.
The implementation includes:
- A new `milvus_multitenancy.py` module with the multi-tenant client.
- Configuration variables in `config.py` to enable the mode and define the collection prefix.
- Updated logic in the `factory.py` to conditionally select the appropriate Milvus client.
# Pull Request Checklist
### Note to first-time contributors: Please open a discussion post in [Discussions](https://github.com/open-webui/open-webui/discussions) and describe your changes before submitting a pull request.
**Before submitting, make sure you've checked the following:**
- [X] **Target branch:** Please verify that the pull request targets the `dev` branch.
- [X] **Description:** Provide a concise description of the changes made in this pull request.
- [X] **Changelog:** Ensure a changelog entry following the format of [Keep a Changelog](https://keepachangelog.com/) is added at the bottom of the PR description.
- [X] **Documentation:** Have you updated relevant documentation [Open WebUI Docs](https://github.com/open-webui/docs), or other documentation sources?
- [X] **Dependencies:** Are there any new dependencies? Have you updated the dependency versions in the documentation?
- [ ] **Testing:** Have you written and run sufficient tests to validate the changes?
- [ ] **Code review:** Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards?
- [X] **Prefix:** To clearly categorize this pull request, prefix the pull request title using one of the following:
- **feat**: Introduces a new feature or enhancement to the codebase
### Contributor License Agreement
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.
---
<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/17776
Author: @Classic298
Created: 9/26/2025
Status: ❌ Closed
Base:
dev← Head:feat/milvus-multitenancy-1📝 Commits (3)
e0ec1d0feat: Implement Milvus multi-tenancy mode4fdfd35Merge branch 'dev' into feat/milvus-multitenancy-1e677c9bfeat: Implement Milvus multi-tenancy mode📊 Changes
22 files changed (+482 additions, -349 deletions)
View changed files
📝
backend/open_webui/config.py(+4 -9)📝
backend/open_webui/retrieval/vector/dbs/milvus.py(+4 -12)➕
backend/open_webui/retrieval/vector/dbs/milvus_multitenancy.py(+281 -0)📝
backend/open_webui/retrieval/vector/factory.py(+14 -3)📝
backend/open_webui/routers/configs.py(+29 -30)📝
backend/open_webui/routers/notes.py(+0 -12)📝
backend/open_webui/routers/users.py(+0 -1)📝
backend/open_webui/utils/middleware.py(+1 -99)📝
backend/open_webui/utils/oauth.py(+5 -17)📝
src/lib/apis/files/index.ts(+1 -1)📝
src/lib/components/admin/Settings/Evaluations/Model.svelte(+1 -1)📝
src/lib/components/admin/Users/Groups/Permissions.svelte(+1 -9)📝
src/lib/components/chat/MessageInput.svelte(+12 -12)📝
src/lib/components/chat/MessageInput/IntegrationsMenu.svelte(+21 -3)📝
src/lib/components/chat/ModelSelector.svelte(+1 -1)📝
src/lib/components/chat/ModelSelector/Selector.svelte(+13 -15)➖
src/lib/components/icons/Knobs.svelte(+0 -24)📝
src/lib/components/workspace/Models.svelte(+10 -12)📝
src/lib/i18n/locales/de-DE/translation.json(+41 -41)📝
src/lib/i18n/locales/pt-BR/translation.json(+23 -23)...and 2 more files
📄 Description
This commit introduces a scalable, multi-tenant architecture for Milvus, mirroring the existing Qdrant implementation. When enabled via the
ENABLE_MILVUS_MULTITENANCY_MODEenvironment variable, this mode utilizes a fixed set of shared collections instead of creating a new collection for each resource.Data isolation is achieved by adding a
resource_idto each vector's metadata and applying a filter expression (expr) to all database operations. This prevents the proliferation of collections, which can lead to performance degradation and resource exhaustion in large-scale deployments.The implementation includes:
milvus_multitenancy.pymodule with the multi-tenant client.config.pyto enable the mode and define the collection prefix.factory.pyto conditionally select the appropriate Milvus client.Pull Request Checklist
Note to first-time contributors: Please open a discussion post in Discussions and describe your changes before submitting a pull request.
Before submitting, make sure you've checked the following:
devbranch.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.