mirror of
https://github.com/ParisNeo/lollms.git
synced 2024-12-19 04:37:54 +00:00
Update app.py
This commit is contained in:
parent
cc7269869a
commit
95f59598fd
@ -91,39 +91,6 @@ class LollmsApplication(LoLLMsCom):
|
||||
self.ttm = None
|
||||
self.ttv = None
|
||||
|
||||
try:
|
||||
self.load_rag_dbs()
|
||||
except Exception as ex:
|
||||
trace_exception(ex)
|
||||
for entry in self.config.rag_databases:
|
||||
try:
|
||||
if "mounted" in entry:
|
||||
parts = entry.split("::")
|
||||
database_name = parts[0]
|
||||
database_path = parts[1]
|
||||
|
||||
if not PackageManager.check_package_installed_with_version("lollmsvectordb","0.5.1"):
|
||||
PackageManager.install_or_update("lollmsvectordb")
|
||||
from lollmsvectordb import VectorDatabase
|
||||
from lollmsvectordb.text_document_loader import TextDocumentsLoader
|
||||
from lollmsvectordb.lollms_tokenizers.tiktoken_tokenizer import TikTokenTokenizer
|
||||
|
||||
if self.config.rag_vectorizer == "bert":
|
||||
self.backup_trust_store()
|
||||
from lollmsvectordb.lollms_vectorizers.bert_vectorizer import BERTVectorizer
|
||||
v = BERTVectorizer()
|
||||
self.restore_trust_store()
|
||||
|
||||
elif self.config.rag_vectorizer == "tfidf":
|
||||
from lollmsvectordb.lollms_vectorizers.tfidf_vectorizer import TFIDFVectorizer
|
||||
v = TFIDFVectorizer()
|
||||
|
||||
vdb = VectorDatabase(Path(database_path)/"db_name.sqlite", v, self.model if self.model else TikTokenTokenizer(), n_neighbors=self.config.rag_n_chunks)
|
||||
vdb.build_index()
|
||||
self.active_rag_dbs.append({"name":database_name,"path":database_path,"vectorizer":vdb})
|
||||
self.config.save_config()
|
||||
except Exception as ex:
|
||||
trace_exception(ex)
|
||||
self.rt_com = None
|
||||
if not free_mode:
|
||||
try:
|
||||
@ -191,6 +158,41 @@ class LollmsApplication(LoLLMsCom):
|
||||
self.mount_personalities()
|
||||
self.mount_extensions()
|
||||
|
||||
try:
|
||||
self.load_rag_dbs()
|
||||
except Exception as ex:
|
||||
trace_exception(ex)
|
||||
for entry in self.config.rag_databases:
|
||||
try:
|
||||
if "mounted" in entry:
|
||||
parts = entry.split("::")
|
||||
database_name = parts[0]
|
||||
database_path = parts[1]
|
||||
|
||||
if not PackageManager.check_package_installed_with_version("lollmsvectordb","0.5.1"):
|
||||
PackageManager.install_or_update("lollmsvectordb")
|
||||
from lollmsvectordb import VectorDatabase
|
||||
from lollmsvectordb.text_document_loader import TextDocumentsLoader
|
||||
from lollmsvectordb.lollms_tokenizers.tiktoken_tokenizer import TikTokenTokenizer
|
||||
|
||||
if self.config.rag_vectorizer == "bert":
|
||||
self.backup_trust_store()
|
||||
from lollmsvectordb.lollms_vectorizers.bert_vectorizer import BERTVectorizer
|
||||
v = BERTVectorizer()
|
||||
self.restore_trust_store()
|
||||
|
||||
elif self.config.rag_vectorizer == "tfidf":
|
||||
from lollmsvectordb.lollms_vectorizers.tfidf_vectorizer import TFIDFVectorizer
|
||||
v = TFIDFVectorizer()
|
||||
|
||||
vdb = VectorDatabase(Path(database_path)/"db_name.sqlite", v, self.model if self.model else TikTokenTokenizer(), n_neighbors=self.config.rag_n_chunks)
|
||||
vdb.build_index()
|
||||
self.active_rag_dbs.append({"name":database_name,"path":database_path,"vectorizer":vdb})
|
||||
self.config.save_config()
|
||||
except Exception as ex:
|
||||
trace_exception(ex)
|
||||
|
||||
|
||||
def backup_trust_store(self):
|
||||
self.bk_store = None
|
||||
if 'REQUESTS_CA_BUNDLE' in os.environ:
|
||||
|
Loading…
Reference in New Issue
Block a user