Skip to content

KeyError with MultiQueryRetriever and Custom Prompt for Fetching data from ChromaDB #28169

Answered by feijoes
AbdelazimLokma asked this question in Q&A
Discussion options

You must be logged in to vote

@AbdelazimLokma I was checking the documentation and found out that the default generate_queries implementation (thats is executed from the retriever.invoke) puts all the inputs inside { 'question': question }.

(Yes, the typing is str, but the "question" is actually the dictionary you pass in the invoke method.)

I'm not entirely sure why it does that for now, but one possible solution is to create a custom MultiQueryRetriever and override the default generate_queries with your own implementation. Basically, just use self.llm_chain.invoke(question).

Here's an example:

from langchain_core.callbacks import CallbackManagerForRetrieverRun  # Only necessary for type hint
from typing import List  

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@AbdelazimLokma
Comment options

@feijoes
Comment options

Answer selected by AbdelazimLokma
@AbdelazimLokma
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants