提交 58d6a9a0 作者: imClumsyPanda

update MyFAISS with method mentioned in…

update MyFAISS with method mentioned in https://github.com/imClumsyPanda/langchain-ChatGLM/issues/613#issuecomment-1590460465
上级 a55aab49
...@@ -5,6 +5,7 @@ from typing import Any, Callable, List, Tuple, Dict ...@@ -5,6 +5,7 @@ from typing import Any, Callable, List, Tuple, Dict
from langchain.docstore.base import Docstore from langchain.docstore.base import Docstore
from langchain.docstore.document import Document from langchain.docstore.document import Document
import numpy as np import numpy as np
import copy
class MyFAISS(FAISS, VectorStore): class MyFAISS(FAISS, VectorStore):
...@@ -95,7 +96,8 @@ class MyFAISS(FAISS, VectorStore): ...@@ -95,7 +96,8 @@ class MyFAISS(FAISS, VectorStore):
for id in id_seq: for id in id_seq:
if id == id_seq[0]: if id == id_seq[0]:
_id = self.index_to_docstore_id[id] _id = self.index_to_docstore_id[id]
doc = self.docstore.search(_id) # doc = self.docstore.search(_id)
doc = copy.deepcopy(self.docstore.search(_id))
else: else:
_id0 = self.index_to_docstore_id[id] _id0 = self.index_to_docstore_id[id]
doc0 = self.docstore.search(_id0) doc0 = self.docstore.search(_id0)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论