From 9e36d7b82c482a3ef5ed08c2b1399150eec503a7 Mon Sep 17 00:00:00 2001 From: Vincent Date: Tue, 25 Apr 2023 16:53:20 -0400 Subject: [PATCH] adding add_documents and aadd_documents to class RedisVectorStoreRetriever (#3419) Ran into this issue In vectorstores/redis.py when trying to use the AutoGPT agent with redis vector store. The error I received was ` langchain/experimental/autonomous_agents/autogpt/agent.py", line 134, in run self.memory.add_documents([Document(page_content=memory_to_add)]) AttributeError: 'RedisVectorStoreRetriever' object has no attribute 'add_documents' ` Added the needed function to the class RedisVectorStoreRetriever which did not have the functionality like the base VectorStoreRetriever in vectorstores/base.py that, for example, vectorstores/faiss.py has --- langchain/vectorstores/redis.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/langchain/vectorstores/redis.py b/langchain/vectorstores/redis.py index 986ee877..a015bba9 100644 --- a/langchain/vectorstores/redis.py +++ b/langchain/vectorstores/redis.py @@ -461,3 +461,13 @@ class RedisVectorStoreRetriever(BaseRetriever, BaseModel): async def aget_relevant_documents(self, query: str) -> List[Document]: raise NotImplementedError("RedisVectorStoreRetriever does not support async") + + def add_documents(self, documents: List[Document], **kwargs: Any) -> List[str]: + """Add documents to vectorstore.""" + return self.vectorstore.add_documents(documents, **kwargs) + + async def aadd_documents( + self, documents: List[Document], **kwargs: Any + ) -> List[str]: + """Add documents to vectorstore.""" + return await self.vectorstore.aadd_documents(documents, **kwargs)