mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-18 21:09:00 +00:00
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:
parent
f9f5626ca4
commit
cd00a87db7
@ -921,11 +921,13 @@ class FAISS(VectorStore):
|
|||||||
else:
|
else:
|
||||||
# Default to L2, currently other metric types not initialized.
|
# Default to L2, currently other metric types not initialized.
|
||||||
index = faiss.IndexFlatL2(len(embeddings[0]))
|
index = faiss.IndexFlatL2(len(embeddings[0]))
|
||||||
|
docstore = kwargs.pop("docstore", InMemoryDocstore())
|
||||||
|
index_to_docstore_id = kwargs.pop("index_to_docstore_id", {})
|
||||||
vecstore = cls(
|
vecstore = cls(
|
||||||
embedding,
|
embedding,
|
||||||
index,
|
index,
|
||||||
InMemoryDocstore(),
|
docstore,
|
||||||
{},
|
index_to_docstore_id,
|
||||||
normalize_L2=normalize_L2,
|
normalize_L2=normalize_L2,
|
||||||
distance_strategy=distance_strategy,
|
distance_strategy=distance_strategy,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
|
Loading…
Reference in New Issue
Block a user