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
This commit is contained in:
Kapil Sachdeva 2024-02-12 21:51:55 -06:00 committed by GitHub
parent f9f5626ca4
commit cd00a87db7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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,