Initialize the Meta Faiss vectorstore. Code modified based on langchain. Args: embedding_provider: Embedding provider. memory_path: Path to the store memory. index: Faiss index. index_to_key: Mapping from index to key.
(
self,
embedding_dim: int,
memory_path: str,
index: Optional[Any] = None,
index_to_key: Optional[Dict[int, str]] = None,
)
| 41 | |
| 42 | class FAISS(VectorStore): |
| 43 | def __init__( |
| 44 | self, |
| 45 | embedding_dim: int, |
| 46 | memory_path: str, |
| 47 | index: Optional[Any] = None, |
| 48 | index_to_key: Optional[Dict[int, str]] = None, |
| 49 | ) -> None: |
| 50 | """Initialize the Meta Faiss vectorstore. |
| 51 | Code modified based on langchain. |
| 52 | |
| 53 | Args: |
| 54 | embedding_provider: Embedding provider. |
| 55 | memory_path: Path to the store memory. |
| 56 | index: Faiss index. |
| 57 | index_to_key: Mapping from index to key. |
| 58 | """ |
| 59 | faiss = dependable_faiss_import() |
| 60 | if index is None: |
| 61 | self.index = faiss.IndexFlatL2(embedding_dim) |
| 62 | if index_to_key is None: |
| 63 | self.index_to_key = {} |
| 64 | self.memory_path = memory_path |
| 65 | |
| 66 | def add_embeddings( |
| 67 | self, |
nothing calls this directly
no test coverage detected