Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a clear() method to VectorStoreRetrieverMemory with FAISS vector store #10169

Closed
wants to merge 7 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion libs/langchain/langchain/memory/vectorstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,14 @@ def save_context(self, inputs: Dict[str, Any], outputs: Dict[str, str]) -> None:
self.retriever.add_documents(documents)

def clear(self) -> None:
"""Nothing to clear."""
"""Only for faiss vectorstore """
"""Clear the chat_history in faiss vector_store"""
if self.retriever.__dict__['tags'] == ['FAISS']:
self.retriever.vectorstore.delete(self.check_history_id())
else:
raise NotImplementedError("clear method must be implemented by faiss vector store.")
def check_history_id(self) -> List[str]:
"""Check the existed history memory in the faiss retrieval VectorStore."""
return list(
self.retriever.vectorstore.__dict__["index_to_docstore_id"].values()
)
Loading