From 9a5c9df80905b6139f439ce6f2a7a6b5ad946566 Mon Sep 17 00:00:00 2001 From: Matt Wells Date: Sun, 28 May 2023 17:59:30 +0100 Subject: [PATCH] Fixes iter error in FAISS add_embeddings call (#5367) # Remove re-use of iter within add_embeddings causing error As reported in https://github.com/hwchase17/langchain/issues/5336 there is an issue currently involving the atempted re-use of an iterator within the FAISS vectorstore adapter Fixes # https://github.com/hwchase17/langchain/issues/5336 ## Who can review? Community members can review the PR once tests pass. Tag maintainers/contributors who might be interested: VectorStores / Retrievers / Memory - @dev2049 --- langchain/vectorstores/faiss.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/langchain/vectorstores/faiss.py b/langchain/vectorstores/faiss.py index 6945f0cc..cf170287 100644 --- a/langchain/vectorstores/faiss.py +++ b/langchain/vectorstores/faiss.py @@ -175,9 +175,8 @@ class FAISS(VectorStore): f"adding items, which {self.docstore} does not" ) # Embed and create the documents. + texts, embeddings = zip(*text_embeddings) - texts = [te[0] for te in text_embeddings] - embeddings = [te[1] for te in text_embeddings] return self.__add(texts, embeddings, metadatas=metadatas, ids=ids, **kwargs) def similarity_search_with_score_by_vector(