This commit is contained in:
parent
6f521287c0
commit
96d3bffb4b
|
|
@ -95,8 +95,15 @@ def build_user_index(user_id: str):
|
||||||
service_context=service_context,
|
service_context=service_context,
|
||||||
storage_context=storage_context
|
storage_context=storage_context
|
||||||
)
|
)
|
||||||
storage_context.persist(persist_dir=persist_dir) # 使用 `storage_context.persist()` 保存索引
|
|
||||||
logger.info(f"索引已保存到 {persist_dir}")
|
# 保存 Faiss 索引为文件,使用正确的路径
|
||||||
|
faiss_index_file = os.path.join(persist_dir, "index.faiss")
|
||||||
|
faiss.write_index(faiss_index, faiss_index_file) # 使用 Faiss 的 write_index 方法保存索引
|
||||||
|
logger.info(f"Faiss 索引已保存到 {faiss_index_file}")
|
||||||
|
|
||||||
|
# 使用 storage_context.persist() 保存其他索引数据
|
||||||
|
storage_context.persist(persist_dir=persist_dir)
|
||||||
|
logger.info(f"索引数据已保存到 {persist_dir}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"索引构建失败: {e}")
|
logger.error(f"索引构建失败: {e}")
|
||||||
raise HTTPException(status_code=500, detail="索引构建失败")
|
raise HTTPException(status_code=500, detail="索引构建失败")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue