From 457a4730b22f99ffde101f3f3d314a7efb58444d Mon Sep 17 00:00:00 2001 From: German Martin Date: Wed, 26 Jul 2023 13:48:55 -0300 Subject: [PATCH] Fix the mangling issue on several VectorStores child classes. (#8274) - Description: Fix mangling issue affecting a couple of VectorStore classes including Redis. - Issue: https://github.com/langchain-ai/langchain/issues/8185 - @rlancemartin This is a simple issue but I lack of some context in the original implementation. My changes perhaps are not the definitive fix but to start a quick discussion. @hinthornw Tagging you since one of your changes introduced this [here.](https://github.com/langchain-ai/langchain/commit/c38965fcba42eadb3bc72754defbedef100f6ed0) --- libs/langchain/langchain/vectorstores/base.py | 4 ++-- libs/langchain/langchain/vectorstores/redis.py | 2 +- libs/langchain/langchain/vectorstores/singlestoredb.py | 2 +- libs/langchain/langchain/vectorstores/vectara.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libs/langchain/langchain/vectorstores/base.py b/libs/langchain/langchain/vectorstores/base.py index 7b69d3a437..e00b2db783 100644 --- a/libs/langchain/langchain/vectorstores/base.py +++ b/libs/langchain/langchain/vectorstores/base.py @@ -446,7 +446,7 @@ class VectorStore(ABC): """Return VectorStore initialized from texts and embeddings.""" raise NotImplementedError - def __get_retriever_tags(self) -> List[str]: + def _get_retriever_tags(self) -> List[str]: """Get tags for retriever.""" tags = [self.__class__.__name__] if self.embeddings: @@ -455,7 +455,7 @@ class VectorStore(ABC): def as_retriever(self, **kwargs: Any) -> VectorStoreRetriever: tags = kwargs.pop("tags", None) or [] - tags.extend(self.__get_retriever_tags()) + tags.extend(self._get_retriever_tags()) return VectorStoreRetriever(vectorstore=self, **kwargs, tags=tags) diff --git a/libs/langchain/langchain/vectorstores/redis.py b/libs/langchain/langchain/vectorstores/redis.py index 2151ad63ab..f6ed5c4011 100644 --- a/libs/langchain/langchain/vectorstores/redis.py +++ b/libs/langchain/langchain/vectorstores/redis.py @@ -607,7 +607,7 @@ class Redis(VectorStore): def as_retriever(self, **kwargs: Any) -> RedisVectorStoreRetriever: tags = kwargs.pop("tags", None) or [] - tags.extend(self.__get_retriever_tags()) + tags.extend(self._get_retriever_tags()) return RedisVectorStoreRetriever(vectorstore=self, **kwargs, tags=tags) diff --git a/libs/langchain/langchain/vectorstores/singlestoredb.py b/libs/langchain/langchain/vectorstores/singlestoredb.py index 44549a9a0d..7c05778c83 100644 --- a/libs/langchain/langchain/vectorstores/singlestoredb.py +++ b/libs/langchain/langchain/vectorstores/singlestoredb.py @@ -446,7 +446,7 @@ class SingleStoreDB(VectorStore): def as_retriever(self, **kwargs: Any) -> SingleStoreDBRetriever: tags = kwargs.pop("tags", None) or [] - tags.extend(self.__get_retriever_tags()) + tags.extend(self._get_retriever_tags()) return SingleStoreDBRetriever(vectorstore=self, **kwargs, tags=tags) diff --git a/libs/langchain/langchain/vectorstores/vectara.py b/libs/langchain/langchain/vectorstores/vectara.py index ed819244d3..97ce9656d8 100644 --- a/libs/langchain/langchain/vectorstores/vectara.py +++ b/libs/langchain/langchain/vectorstores/vectara.py @@ -409,7 +409,7 @@ class Vectara(VectorStore): def as_retriever(self, **kwargs: Any) -> VectaraRetriever: tags = kwargs.pop("tags", None) or [] - tags.extend(self.__get_retriever_tags()) + tags.extend(self._get_retriever_tags()) return VectaraRetriever(vectorstore=self, **kwargs, tags=tags)