update MyFAISS.py and cli_demo.py
This commit is contained in:
parent
00cb7bf598
commit
2eb35291b2
|
|
@ -35,7 +35,7 @@ def main():
|
|||
# filepath错误的返回为None, 如果直接用原先的vs_path,_ = local_doc_qa.init_knowledge_vector_store(filepath)
|
||||
# 会直接导致TypeError: cannot unpack non-iterable NoneType object而使得程序直接退出
|
||||
# 因此需要先加一层判断,保证程序能继续运行
|
||||
temp,loaded_files = local_doc_qa.init_knowledge_vector_store(filepath)
|
||||
temp, loaded_files = local_doc_qa.init_knowledge_vector_store(filepath)
|
||||
if temp is not None:
|
||||
vs_path = temp
|
||||
# 如果loaded_files和len(filepath)不一致,则说明部分文件没有加载成功
|
||||
|
|
|
|||
|
|
@ -129,12 +129,12 @@ class MyFAISS(FAISS, VectorStore):
|
|||
if len(ids) == 0:
|
||||
return f"docs delete fail"
|
||||
else:
|
||||
# 从 self.index 中删除对应id
|
||||
self.index.remove_ids(np.array(ids, dtype=np.int64))
|
||||
for id in ids:
|
||||
index = list(self.index_to_docstore_id.keys())[list(self.index_to_docstore_id.values()).index(id)]
|
||||
self.index_to_docstore_id.pop(index)
|
||||
self.docstore._dict.pop(id)
|
||||
# TODO: 从 self.index 中删除对应id
|
||||
# self.index.reset()
|
||||
self.save_local(vs_path)
|
||||
return f"docs delete success"
|
||||
except Exception as e:
|
||||
|
|
|
|||
Loading…
Reference in New Issue