feat: 添加强制停止MAI Bot的API接口(半成品),优化嵌入数据目录路径处理

This commit is contained in:
墨梓柒
2025-05-07 00:21:04 +08:00
parent ca55d646e1
commit 1e2cdeeea5
5 changed files with 49 additions and 9 deletions

View File

@@ -28,6 +28,8 @@ from rich.progress import (
install(extra_lines=3)
ROOT_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "..", ".."))
EMBEDDING_DATA_DIR = os.path.join(ROOT_PATH, "data", "embedding") if global_config["persistence"]["embedding_data_dir"] is None else os.path.join(ROOT_PATH, global_config["persistence"]["embedding_data_dir"])
EMBEDDING_DATA_DIR_STR = str(EMBEDDING_DATA_DIR).replace("\\", "/")
TOTAL_EMBEDDING_TIMES = 3 # 统计嵌入次数
# 嵌入模型测试字符串,测试模型一致性,来自开发群的聊天记录
@@ -288,17 +290,17 @@ class EmbeddingManager:
self.paragraphs_embedding_store = EmbeddingStore(
llm_client,
PG_NAMESPACE,
global_config["persistence"]["embedding_data_dir"],
EMBEDDING_DATA_DIR_STR,
)
self.entities_embedding_store = EmbeddingStore(
llm_client,
ENT_NAMESPACE,
global_config["persistence"]["embedding_data_dir"],
EMBEDDING_DATA_DIR_STR,
)
self.relation_embedding_store = EmbeddingStore(
llm_client,
REL_NAMESPACE,
global_config["persistence"]["embedding_data_dir"],
EMBEDDING_DATA_DIR_STR,
)
self.stored_pg_hashes = set()

View File

@@ -30,8 +30,9 @@ from .lpmmconfig import (
)
from .global_logger import logger
ROOT_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "..", ".."))
KG_DIR = os.path.join(ROOT_PATH, "data/rag") if global_config["persistence"]["rag_data_dir"] is None else os.path.join(ROOT_PATH, global_config["persistence"]["rag_data_dir"])
KG_DIR_STR = str(KG_DIR).replace("\\", "/")
class KGManager:
def __init__(self):
# 会被保存的字段
@@ -43,7 +44,7 @@ class KGManager:
self.graph = di_graph.DiGraph()
# 持久化相关
self.dir_path = global_config["persistence"]["rag_data_dir"]
self.dir_path = KG_DIR_STR
self.graph_data_path = self.dir_path + "/" + RAG_GRAPH_NAMESPACE + ".graphml"
self.ent_cnt_data_path = self.dir_path + "/" + RAG_ENT_CNT_NAMESPACE + ".parquet"
self.pg_hash_file_path = self.dir_path + "/" + RAG_PG_HASH_NAMESPACE + ".json"