From cd00a87db732687d0d6a9ffdc1eb9f6f5ebc49b6 Mon Sep 17 00:00:00 2001 From: Kapil Sachdeva Date: Mon, 12 Feb 2024 21:51:55 -0600 Subject: [PATCH] community[patch] - in FAISS vector store, support passing custom DocStore implementation when using from_xxx methods (#16801) - **Description:** The from__xx methods of FAISS class have hardcoded InMemoryStore implementation and thereby not let users pass a custom DocStore implementation, - **Issue:** no referenced issue, - **Dependencies:** none, - **Twitter handle:** ksachdeva --- libs/community/langchain_community/vectorstores/faiss.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libs/community/langchain_community/vectorstores/faiss.py b/libs/community/langchain_community/vectorstores/faiss.py index 1617a8c36bb..4a7d65f9120 100644 --- a/libs/community/langchain_community/vectorstores/faiss.py +++ b/libs/community/langchain_community/vectorstores/faiss.py @@ -921,11 +921,13 @@ class FAISS(VectorStore): else: # Default to L2, currently other metric types not initialized. index = faiss.IndexFlatL2(len(embeddings[0])) + docstore = kwargs.pop("docstore", InMemoryDocstore()) + index_to_docstore_id = kwargs.pop("index_to_docstore_id", {}) vecstore = cls( embedding, index, - InMemoryDocstore(), - {}, + docstore, + index_to_docstore_id, normalize_L2=normalize_L2, distance_strategy=distance_strategy, **kwargs,