Originally created by @pablocerdeira on GitHub (Feb 4, 2025).
Issue Description
I’m using OpenWeb-UI with Milvus as the vector database. When attempting to upload files, I encounter the following error:
ERROR [pymilvus.decorators] RPC error: [create_index], <MilvusException: (code=65535, message=invalid index type: HNSW, local mode only support FLAT IVF_FLAT AUTOINDEX: )>
Even after configuring docker-compose.yml to use a supported index (FLAT, IVF_FLAT, or AUTOINDEX), OpenWeb-UI always attempts to create the index using HNSW, which is not supported in standalone mode for Milvus.
Steps to Reproduce
1. Set up OpenWeb-UI with Milvus in standalone mode.
2. Configure docker-compose.yml with the appropriate settings:
3. Upload a file via OpenWeb-UI.
4. The error occurs, and indexing fails because OpenWeb-UI ignores the settings and forces HNSW.
Expected Behavior
OpenWeb-UI should respect the configuration defined in environment variables (VECTOR_INDEX_TYPE and MILVUS_COLLECTION_PARAMS) and allow users to select a compatible index type.
Environment
• OS: Linux (Docker)
• Vector Database: Milvus 2.3.5 standalone
• Index settings in docker-compose.yml: AUTOINDEX, FLAT, or IVF_FLAT
• OpenWeb-UI Version: ghcr.io/open-webui/open-webui:main
Cause of the Issue
The HNSW index type is hardcoded inside milvus.py:
index_params.add_index(
field_name="vector",
index_type="HNSW", # This should be configurable
metric_type="COSINE",
params={"M": 16, "efConstruction": 100},
)
Suggested Fix
Modify the code to read the index type from environment variables (VECTOR_INDEX_TYPE and MILVUS_COLLECTION_PARAMS), ensuring flexibility for different Milvus configurations.
Proposed Fix:
import os
index_type = os.getenv("VECTOR_INDEX_TYPE", "IVF_FLAT") # Default to IVF_FLAT if not set
index_params.add_index(
field_name="vector",
index_type=index_type,
metric_type="COSINE",
params={"nlist": 100} if index_type == "IVF_FLAT" else {},
)
This change ensures that users can define their desired index type without modifying the source code manually.
Temporary Workaround
To work around this issue without modifying the container’s source code, I copied the milvus.py file to the host and mounted it inside the container using docker-compose.yml:
This ensures that the watchtower auto-update mechanism does not override my fix. However, the ideal solution is for OpenWeb-UI to respect environment variables and allow proper Milvus configuration.
Request
Please update the code so that the index type can be set via environment variables, ensuring compatibility with different Milvus modes.
Originally created by @pablocerdeira on GitHub (Feb 4, 2025).
**Issue Description**
I’m using OpenWeb-UI with Milvus as the vector database. When attempting to upload files, I encounter the following error:
`ERROR [pymilvus.decorators] RPC error: [create_index], <MilvusException: (code=65535, message=invalid index type: HNSW, local mode only support FLAT IVF_FLAT AUTOINDEX: )>`
Even after configuring docker-compose.yml to use a supported index (FLAT, IVF_FLAT, or AUTOINDEX), OpenWeb-UI always attempts to create the index using HNSW, which is not supported in standalone mode for Milvus.
**Steps to Reproduce**
1. Set up OpenWeb-UI with Milvus in standalone mode.
2. Configure docker-compose.yml with the appropriate settings:
```
environment:
VECTOR_DB: "milvus"
MILVUS_HOST: "milvus-standalone"
MILVUS_PORT: "19530"
RAG_INDEX_TYPE: "AUTOINDEX"
VECTOR_INDEX_TYPE: "IVF_FLAT"
MILVUS_COLLECTION_PARAMS: '{"index_type": "IVF_FLAT", "metric_type": "L2"}'
```
3. Upload a file via OpenWeb-UI.
4. The error occurs, and indexing fails because OpenWeb-UI ignores the settings and forces HNSW.
**Expected Behavior**
OpenWeb-UI should respect the configuration defined in environment variables (VECTOR_INDEX_TYPE and MILVUS_COLLECTION_PARAMS) and allow users to select a compatible index type.
**Environment**
• OS: Linux (Docker)
• Vector Database: Milvus 2.3.5 standalone
• Index settings in docker-compose.yml: AUTOINDEX, FLAT, or IVF_FLAT
• OpenWeb-UI Version: ghcr.io/open-webui/open-webui:main
**Cause of the Issue**
The HNSW index type is hardcoded inside [milvus.py](https://github.com/open-webui/open-webui/blob/main/backend/open_webui/retrieval/vector/dbs/milvus.py):
```
index_params.add_index(
field_name="vector",
index_type="HNSW", # This should be configurable
metric_type="COSINE",
params={"M": 16, "efConstruction": 100},
)
```
**Suggested Fix**
Modify the code to read the index type from environment variables (VECTOR_INDEX_TYPE and MILVUS_COLLECTION_PARAMS), ensuring flexibility for different Milvus configurations.
**Proposed Fix:**
```
import os
index_type = os.getenv("VECTOR_INDEX_TYPE", "IVF_FLAT") # Default to IVF_FLAT if not set
index_params.add_index(
field_name="vector",
index_type=index_type,
metric_type="COSINE",
params={"nlist": 100} if index_type == "IVF_FLAT" else {},
)
```
This change ensures that users can define their desired index type without modifying the source code manually.
**Temporary Workaround**
To work around this issue without modifying the container’s source code, I copied the milvus.py file to the host and mounted it inside the container using docker-compose.yml:
```
volumes:
- ./milvus.py:/app/backend/open_webui/retrieval/vector/dbs/milvus.py:ro
```
This ensures that the watchtower auto-update mechanism does not override my fix. However, the ideal solution is for OpenWeb-UI to respect environment variables and allow proper Milvus configuration.
**Request**
Please update the code so that the index type can be set via environment variables, ensuring compatibility with different Milvus modes.
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.
Originally created by @pablocerdeira on GitHub (Feb 4, 2025).
Issue Description
I’m using OpenWeb-UI with Milvus as the vector database. When attempting to upload files, I encounter the following error:
ERROR [pymilvus.decorators] RPC error: [create_index], <MilvusException: (code=65535, message=invalid index type: HNSW, local mode only support FLAT IVF_FLAT AUTOINDEX: )>Even after configuring docker-compose.yml to use a supported index (FLAT, IVF_FLAT, or AUTOINDEX), OpenWeb-UI always attempts to create the index using HNSW, which is not supported in standalone mode for Milvus.
Steps to Reproduce
1. Set up OpenWeb-UI with Milvus in standalone mode.
2. Configure docker-compose.yml with the appropriate settings:
Expected Behavior
OpenWeb-UI should respect the configuration defined in environment variables (VECTOR_INDEX_TYPE and MILVUS_COLLECTION_PARAMS) and allow users to select a compatible index type.
Environment
• OS: Linux (Docker)
• Vector Database: Milvus 2.3.5 standalone
• Index settings in docker-compose.yml: AUTOINDEX, FLAT, or IVF_FLAT
• OpenWeb-UI Version: ghcr.io/open-webui/open-webui:main
Cause of the Issue
The HNSW index type is hardcoded inside milvus.py:
Suggested Fix
Modify the code to read the index type from environment variables (VECTOR_INDEX_TYPE and MILVUS_COLLECTION_PARAMS), ensuring flexibility for different Milvus configurations.
Proposed Fix:
This change ensures that users can define their desired index type without modifying the source code manually.
Temporary Workaround
To work around this issue without modifying the container’s source code, I copied the milvus.py file to the host and mounted it inside the container using docker-compose.yml:
This ensures that the watchtower auto-update mechanism does not override my fix. However, the ideal solution is for OpenWeb-UI to respect environment variables and allow proper Milvus configuration.
Request
Please update the code so that the index type can be set via environment variables, ensuring compatibility with different Milvus modes.