Find answers from the community

Updated 2 months ago

Why similarity_top_k can be set directly when initializing a VectorStoreIndex as a query engine but not as a chat engine

Is there a reason why similarity_top_k can be set directly when initializing a VectorStoreIndex as a query engine but not as a chat engine?
L
b
6 comments
Curious why you think it can't?
I was looking at the code for BaseChatEngine, SimpleChatEngine and ContextChatEngine and couldn't find the parameter setting for it.

However, looking at RetrieverQueryEngine, I notice it's not there either. I always saw top_k set when the index is used as a query engine, so I just assumed it'd be in the __init__ method, but I guess it's buried in the **kwargs or something.
I tried to backtrace the code all the way to ReActAgent and AgentRunner and cannot find where similarity_top_k is finally used.
I think I found it. It's passed into the as_retriever() method in VectorStoreIndex, which is called by both as_query_engine() and as_chat_engine() in BaseIndex.

Holy, Jesus ... wonder how I missed it πŸ˜†
You got it! πŸ’ͺ
Bit of a rabbit hole I know lol
Add a reply
Sign up and join the conversation on Discord