This commit is contained in:
hailin 2025-05-10 13:18:50 +08:00
parent cae4dd103e
commit 55678fece8
1 changed files with 4 additions and 4 deletions

View File

@ -177,7 +177,6 @@ def build_user_index(user_id: str):
# 持久化存储之后,加载已保存的存储上下文信息
logger.info(f"开始加载持久化存储的数据...")
@ -191,20 +190,21 @@ def build_user_index(user_id: str):
# 创建一个新的 StorageContext 实例,使用相同的目录
storage_context = StorageContext.from_defaults(
persist_dir=persist_dir, # 使用与之前相同的目录
vector_store=vector_store, # 使用 Faiss 向量存储
llm=None # 明确指定不使用 LLM
vector_store=vector_store # 使用 Faiss 向量存储
)
# 确认存储是否加载成功,检查索引数据
logger.info("已成功加载存储上下文。")
# 创建 ServiceContext显式禁用 LLM
service_context = ServiceContext.from_defaults(llm=None)
# 使用 load_index_from_storage 加载索引
loaded_index = load_index_from_storage(storage_context)
# 检查加载后的索引
logger.info(f"加载的索引数量: {len(loaded_index.get_documents())}")
except Exception as e:
logger.error(f"索引构建失败: {e}")
raise HTTPException(status_code=500, detail="索引构建失败")