Skip to content

Commit

Permalink
adding add_documents and aadd_documents to class RedisVectorStoreRetr…
Browse files Browse the repository at this point in the history
…iever (langchain-ai#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
  • Loading branch information
risingsunomi authored and samching committed May 1, 2023
1 parent 638e142 commit 181eecd
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions langchain/vectorstores/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,3 +461,13 @@ def get_relevant_documents(self, query: str) -> List[Document]:

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)

0 comments on commit 181eecd

Please sign in to comment.