[PR #17772] [CLOSED] feat: implement multi-tenancy mode for milvus #40173

Closed
opened 2026-04-25 12:35:18 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/17772
Author: @Classic298
Created: 9/26/2025
Status: Closed

Base: devHead: feat/milvus-multitenancy


📝 Commits (1)

  • fd88b0e feat: implement multi-tenancy mode for milvus

📊 Changes

5 files changed (+327 additions, -56 deletions)

View changed files

📝 backend/open_webui/config.py (+2 -0)
📝 backend/open_webui/retrieval/utils.py (+80 -14)
📝 backend/open_webui/retrieval/vector/dbs/milvus.py (+169 -25)
📝 backend/open_webui/routers/knowledge.py (+41 -13)
📝 backend/open_webui/routers/retrieval.py (+35 -4)

📄 Description

This commit introduces a new multi-tenancy mode for the Milvus vector database integration, mirroring the existing architecture for Qdrant. This addresses scalability concerns by preventing the creation of an excessive number of collections.

When MILVUS_MODE is set to multitenancy, the system now uses a small set of shared collections (e.g., knowledge, files) and leverages Milvus partitions to ensure data isolation.

Key changes:

  • Added MILVUS_MODE and MILVUS_EMBEDDING_DIMENSION environment variables to config.py.
  • Refactored milvus.py to pre-create shared collections with partitioning enabled at startup.
  • Centralized collection and partition mapping logic in utils.py.
  • Updated all search, query, and deletion operations to be partition-aware, ensuring data is correctly isolated and managed.
  • Corrected deletion logic to cleanly drop partitions when resources are deleted.

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/17772 **Author:** [@Classic298](https://github.com/Classic298) **Created:** 9/26/2025 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `feat/milvus-multitenancy` --- ### 📝 Commits (1) - [`fd88b0e`](https://github.com/open-webui/open-webui/commit/fd88b0e93daa5087526914f400c833dfdb25d19d) feat: implement multi-tenancy mode for milvus ### 📊 Changes **5 files changed** (+327 additions, -56 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/config.py` (+2 -0) 📝 `backend/open_webui/retrieval/utils.py` (+80 -14) 📝 `backend/open_webui/retrieval/vector/dbs/milvus.py` (+169 -25) 📝 `backend/open_webui/routers/knowledge.py` (+41 -13) 📝 `backend/open_webui/routers/retrieval.py` (+35 -4) </details> ### 📄 Description This commit introduces a new multi-tenancy mode for the Milvus vector database integration, mirroring the existing architecture for Qdrant. This addresses scalability concerns by preventing the creation of an excessive number of collections. When `MILVUS_MODE` is set to `multitenancy`, the system now uses a small set of shared collections (e.g., `knowledge`, `files`) and leverages Milvus partitions to ensure data isolation. Key changes: - Added `MILVUS_MODE` and `MILVUS_EMBEDDING_DIMENSION` environment variables to `config.py`. - Refactored `milvus.py` to pre-create shared collections with partitioning enabled at startup. - Centralized collection and partition mapping logic in `utils.py`. - Updated all search, query, and deletion operations to be partition-aware, ensuring data is correctly isolated and managed. - Corrected deletion logic to cleanly drop partitions when resources are deleted. # 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>
GiteaMirror added the pull-request label 2026-04-25 12:35:18 -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#40173