mirror of
https://github.com/open-webui/open-webui
synced 2025-06-15 19:05:04 +00:00
56 lines
1.9 KiB
Python
56 lines
1.9 KiB
Python
from open_webui.retrieval.vector.main import VectorDBBase
|
|
from open_webui.retrieval.vector.type import VectorType
|
|
from open_webui.config import VECTOR_DB, ENABLE_QDRANT_MULTITENANCY_MODE
|
|
|
|
|
|
class Vector:
|
|
|
|
@staticmethod
|
|
def get_vector(vector_type: str) -> VectorDBBase:
|
|
"""
|
|
get vector db instance by vector type
|
|
"""
|
|
match vector_type:
|
|
case VectorType.MILVUS:
|
|
from open_webui.retrieval.vector.dbs.milvus import MilvusClient
|
|
|
|
return MilvusClient()
|
|
case VectorType.QDRANT:
|
|
if ENABLE_QDRANT_MULTITENANCY_MODE:
|
|
from open_webui.retrieval.vector.dbs.qdrant_multitenancy import (
|
|
QdrantClient,
|
|
)
|
|
|
|
return QdrantClient()
|
|
else:
|
|
from open_webui.retrieval.vector.dbs.qdrant import QdrantClient
|
|
|
|
return QdrantClient()
|
|
case VectorType.PINECONE:
|
|
from open_webui.retrieval.vector.dbs.pinecone import PineconeClient
|
|
|
|
return PineconeClient()
|
|
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()
|
|
case _:
|
|
raise ValueError(f"Unsupported vector type: {vector_type}")
|
|
|
|
|
|
VECTOR_DB_CLIENT = Vector.get_vector(VECTOR_DB)
|