update MyFAISS.py
This commit is contained in:
parent
0ad63aee63
commit
d7039d05a1
|
|
@ -129,8 +129,10 @@ class MyFAISS(FAISS, VectorStore):
|
||||||
if len(ids) == 0:
|
if len(ids) == 0:
|
||||||
return f"docs delete fail"
|
return f"docs delete fail"
|
||||||
else:
|
else:
|
||||||
|
_reversed_index = {v: k for k, v in self.index_to_docstore_id.items()}
|
||||||
|
index_to_delete = [_reversed_index[i] for i in ids]
|
||||||
# 从 self.index 中删除对应id
|
# 从 self.index 中删除对应id
|
||||||
self.index.remove_ids(np.array(ids, dtype=np.int64))
|
self.index.remove_ids(np.array(index_to_delete, dtype=np.int64))
|
||||||
for id in ids:
|
for id in ids:
|
||||||
index = list(self.index_to_docstore_id.keys())[list(self.index_to_docstore_id.values()).index(id)]
|
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.index_to_docstore_id.pop(index)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue