2025-05-12 23:15:32 +08:00
|
|
|
from open_webui.retrieval.vector.main import VectorDBBase
|
|
|
|
from open_webui.retrieval.vector.type import VectorType
|
2025-09-28 17:06:29 +08:00
|
|
|
from open_webui.config import (
|
|
|
|
VECTOR_DB,
|
|
|
|
ENABLE_QDRANT_MULTITENANCY_MODE,
|
|
|
|
ENABLE_MILVUS_MULTITENANCY_MODE,
|
|
|
|
)
|
2025-05-12 23:15:32 +08:00
|
|
|
|
|
|
|
|
|
|
|
class Vector:
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def get_vector(vector_type: str) -> VectorDBBase:
|
|
|
|
"""
|
|
|
|
get vector db instance by vector type
|
|
|
|
"""
|
|
|
|
match vector_type:
|
|
|
|
case VectorType.MILVUS:
|
2025-09-28 17:06:29 +08:00
|
|
|
if ENABLE_MILVUS_MULTITENANCY_MODE:
|
|
|
|
from open_webui.retrieval.vector.dbs.milvus_multitenancy import (
|
|
|
|
MilvusClient,
|
|
|
|
)
|
2025-05-12 23:15:32 +08:00
|
|
|
|
2025-09-28 17:06:29 +08:00
|
|
|
return MilvusClient()
|
|
|
|
else:
|
|
|
|
from open_webui.retrieval.vector.dbs.milvus import MilvusClient
|
2025-09-29 13:58:21 +08:00
|
|
|
|
2025-09-28 17:06:29 +08:00
|
|
|
return MilvusClient()
|
2025-05-12 23:15:32 +08:00
|
|
|
case VectorType.QDRANT:
|
2025-05-15 17:09:24 +08:00
|
|
|
if ENABLE_QDRANT_MULTITENANCY_MODE:
|
2025-05-17 05:00:37 +08:00
|
|
|
from open_webui.retrieval.vector.dbs.qdrant_multitenancy import (
|
|
|
|
QdrantClient,
|
|
|
|
)
|
2025-05-12 23:15:32 +08:00
|
|
|
|
2025-05-15 09:50:56 +08:00
|
|
|
return QdrantClient()
|
|
|
|
else:
|
|
|
|
from open_webui.retrieval.vector.dbs.qdrant import QdrantClient
|
|
|
|
|
|
|
|
return QdrantClient()
|
2025-05-12 23:15:32 +08:00
|
|
|
case VectorType.PINECONE:
|
|
|
|
from open_webui.retrieval.vector.dbs.pinecone import PineconeClient
|
|
|
|
|
|
|
|
return PineconeClient()
|
2025-07-16 11:20:54 +08:00
|
|
|
case VectorType.S3VECTOR:
|
2025-07-23 11:36:35 +08:00
|
|
|
from open_webui.retrieval.vector.dbs.s3vector import S3VectorClient
|
2025-07-23 12:46:00 +08:00
|
|
|
|
2025-07-16 11:20:54 +08:00
|
|
|
return S3VectorClient()
|
2025-05-12 23:15:32 +08:00
|
|
|
case VectorType.OPENSEARCH:
|
|
|
|
from open_webui.retrieval.vector.dbs.opensearch import OpenSearchClient
|
|
|
|
|
|
|
|
return OpenSearchClient()
|
|
|
|
case VectorType.PGVECTOR:
|
|
|
|
from open_webui.retrieval.vector.dbs.pgvector import PgvectorClient
|
|
|
|
|
|
|
|
return PgvectorClient()
|
|
|
|
case VectorType.ELASTICSEARCH:
|
|
|
|
from open_webui.retrieval.vector.dbs.elasticsearch import (
|
|
|
|
ElasticsearchClient,
|
|
|
|
)
|
|
|
|
|
|
|
|
return ElasticsearchClient()
|
|
|
|
case VectorType.CHROMA:
|
|
|
|
from open_webui.retrieval.vector.dbs.chroma import ChromaClient
|
|
|
|
|
|
|
|
return ChromaClient()
|
2025-07-07 13:58:02 +08:00
|
|
|
case VectorType.ORACLE23AI:
|
|
|
|
from open_webui.retrieval.vector.dbs.oracle23ai import Oracle23aiClient
|
|
|
|
|
|
|
|
return Oracle23aiClient()
|
2025-05-12 23:15:32 +08:00
|
|
|
case _:
|
|
|
|
raise ValueError(f"Unsupported vector type: {vector_type}")
|
|
|
|
|
|
|
|
|
|
|
|
VECTOR_DB_CLIENT = Vector.get_vector(VECTOR_DB)
|