Merge branch 'dev' of https://github.com/MaiM-with-u/MaiBot into dev
This commit is contained in:
@@ -201,7 +201,8 @@ class EmbeddingStore:
|
|||||||
"""从文件中加载"""
|
"""从文件中加载"""
|
||||||
if not os.path.exists(self.embedding_file_path):
|
if not os.path.exists(self.embedding_file_path):
|
||||||
raise Exception(f"文件{self.embedding_file_path}不存在")
|
raise Exception(f"文件{self.embedding_file_path}不存在")
|
||||||
logger.info(f"正在从文件{self.embedding_file_path}中加载{self.namespace}嵌入库")
|
logger.info("正在加载嵌入库...")
|
||||||
|
logger.debug(f"正在从文件{self.embedding_file_path}中加载{self.namespace}嵌入库")
|
||||||
data_frame = pd.read_parquet(self.embedding_file_path, engine="pyarrow")
|
data_frame = pd.read_parquet(self.embedding_file_path, engine="pyarrow")
|
||||||
total = len(data_frame)
|
total = len(data_frame)
|
||||||
with Progress(
|
with Progress(
|
||||||
@@ -224,13 +225,15 @@ class EmbeddingStore:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
if os.path.exists(self.index_file_path):
|
if os.path.exists(self.index_file_path):
|
||||||
logger.info(f"正在从文件{self.index_file_path}中加载{self.namespace}嵌入库的FaissIndex")
|
logger.info(f"正在加载{self.namespace}嵌入库的FaissIndex...")
|
||||||
|
logger.debug(f"正在从文件{self.index_file_path}中加载{self.namespace}嵌入库的FaissIndex")
|
||||||
self.faiss_index = faiss.read_index(self.index_file_path)
|
self.faiss_index = faiss.read_index(self.index_file_path)
|
||||||
logger.info(f"{self.namespace}嵌入库的FaissIndex加载成功")
|
logger.info(f"{self.namespace}嵌入库的FaissIndex加载成功")
|
||||||
else:
|
else:
|
||||||
raise Exception(f"文件{self.index_file_path}不存在")
|
raise Exception(f"文件{self.index_file_path}不存在")
|
||||||
if os.path.exists(self.idx2hash_file_path):
|
if os.path.exists(self.idx2hash_file_path):
|
||||||
logger.info(f"正在从文件{self.idx2hash_file_path}中加载{self.namespace}嵌入库的idx2hash映射")
|
logger.info(f"正在加载{self.namespace}嵌入库的idx2hash映射...")
|
||||||
|
logger.debug(f"正在从文件{self.idx2hash_file_path}中加载{self.namespace}嵌入库的idx2hash映射")
|
||||||
with open(self.idx2hash_file_path, "r") as f:
|
with open(self.idx2hash_file_path, "r") as f:
|
||||||
self.idx2hash = json.load(f)
|
self.idx2hash = json.load(f)
|
||||||
logger.info(f"{self.namespace}嵌入库的idx2hash映射加载成功")
|
logger.info(f"{self.namespace}嵌入库的idx2hash映射加载成功")
|
||||||
@@ -342,8 +345,6 @@ class EmbeddingManager:
|
|||||||
|
|
||||||
def load_from_file(self):
|
def load_from_file(self):
|
||||||
"""从文件加载"""
|
"""从文件加载"""
|
||||||
if not self.check_all_embedding_model_consistency():
|
|
||||||
raise Exception("嵌入模型与本地存储不一致,请检查模型设置或清空嵌入库后重试。")
|
|
||||||
self.paragraphs_embedding_store.load_from_file()
|
self.paragraphs_embedding_store.load_from_file()
|
||||||
self.entities_embedding_store.load_from_file()
|
self.entities_embedding_store.load_from_file()
|
||||||
self.relation_embedding_store.load_from_file()
|
self.relation_embedding_store.load_from_file()
|
||||||
|
|||||||
Reference in New Issue
Block a user