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

Cannot use non-vectorstore retrievers in LangChainKnowledgeBase #1096

Open
Joelius300 opened this issue Aug 15, 2024 · 0 comments · May be fixed by #1097
Open

Cannot use non-vectorstore retrievers in LangChainKnowledgeBase #1096

Joelius300 opened this issue Aug 15, 2024 · 0 comments · May be fixed by #1097

Comments

@Joelius300
Copy link

Joelius300 commented Aug 15, 2024

LangChainKnowledgeBase works great when you already have a LangChain-based retrieval setup that uses vectorstores, but when you want something more basic, like a TFIDFRetriever, you cannot use it because of an instance check.

if not isinstance(self.retriever, VectorStoreRetriever):
raise ValueError(f"Retriever is not of type VectorStoreRetriever: {self.retriever}")

Looking at the source of VectorStoreRetriever, it doesn't override the invoke method, which is the only one the LangChainKnowledgeBase uses (here specifically).

After some manual testing for confirmation, I believe it would be best to relax the check to BaseRetriever instead, which defines/implements1 the required invoke method. What do you think? :)

Footnotes

  1. technically, it's already defined by Runnable, but I would argue it makes much more sense semantically to do an instance check on BaseRetriever.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant