Merge pull request #5878 from cheahjs/feat/lazy-load-new-imports-for-mem

perf: lazy load big dependencies to reduce min memory usage
This commit is contained in:
Timothy Jaeryang Baek 2024-10-03 00:15:03 +02:00 committed by GitHub
commit f19b61307d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 7 deletions

View File

@ -15,9 +15,6 @@ from pydantic import BaseModel
from open_webui.apps.retrieval.vector.connector import VECTOR_DB_CLIENT
# Information retrieval models
from open_webui.apps.retrieval.models.colbert import ColBERT
# Document loaders
from open_webui.apps.retrieval.loaders.main import Loader
@ -192,6 +189,8 @@ def update_reranking_model(
if reranking_model:
if any(model in reranking_model for model in ["jinaai/jina-colbert-v2"]):
try:
from open_webui.apps.retrieval.models.colbert import ColBERT
app.state.sentence_transformer_rf = ColBERT(
get_model_path(reranking_model, auto_update),
env="docker" if DOCKER else None,

View File

@ -1,10 +1,10 @@
from open_webui.apps.retrieval.vector.dbs.chroma import ChromaClient
from open_webui.apps.retrieval.vector.dbs.milvus import MilvusClient
from open_webui.config import VECTOR_DB
if VECTOR_DB == "milvus":
from open_webui.apps.retrieval.vector.dbs.milvus import MilvusClient
VECTOR_DB_CLIENT = MilvusClient()
else:
from open_webui.apps.retrieval.vector.dbs.chroma import ChromaClient
VECTOR_DB_CLIENT = ChromaClient()