From 701c23180a432243c52a0e5fcb8ead020dcd045a Mon Sep 17 00:00:00 2001 From: "Joel L." Date: Thu, 15 Aug 2024 18:55:35 +0200 Subject: [PATCH] Relax instance check from VectorStoreRetriever to BaseRetriever --- phi/knowledge/langchain.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phi/knowledge/langchain.py b/phi/knowledge/langchain.py index 5e64a1a45..18ba9940a 100644 --- a/phi/knowledge/langchain.py +++ b/phi/knowledge/langchain.py @@ -17,7 +17,7 @@ def search(self, query: str, num_documents: Optional[int] = None) -> List[Docume """Returns relevant documents matching the query""" try: - from langchain_core.vectorstores import VectorStoreRetriever + from langchain_core.retrievers import BaseRetriever from langchain_core.documents import Document as LangChainDocument except ImportError: raise ImportError( @@ -34,8 +34,8 @@ def search(self, query: str, num_documents: Optional[int] = None) -> List[Docume logger.error("No retriever provided") return [] - if not isinstance(self.retriever, VectorStoreRetriever): - raise ValueError(f"Retriever is not of type VectorStoreRetriever: {self.retriever}") + if not isinstance(self.retriever, BaseRetriever): + raise ValueError(f"Retriever is not of type BaseRetriever: {self.retriever}") _num_documents = num_documents or self.num_documents logger.debug(f"Getting {_num_documents} relevant documents for query: {query}")