Skip to content

The agent engineering platform.

community[patch] - in FAISS vector store, support passing custom DocStore implementation when using from_xxx methods (#16801)

Kapil Sachdevacd00a87db732
diff --git a/libs/community/langchain_community/vectorstores/faiss.py b/libs/community/langchain_community/vectorstores/faiss.py
index 1617a8c36b..4a7d65f912 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,