[BUG] LlamaIndex returns "Cannot initialize VectorStoreIndex without nodes or indexStruct" with vector store retriever
Describe the bug Create a brand new deployment of Flowise with no data, ideally a brand new docker image with local database storage.
Setup a vector store retriever flow with LlamaIndex as per below, then ask a question to it. Do not first run an upsert, just ask a question immediately.
You will get the error:
2024-03-05 17:32:01 [ERROR]: [server]: Error: Error: Cannot initialize VectorStoreIndex without nodes or indexStruct
Error: Error: Cannot initialize VectorStoreIndex without nodes or indexStruct
at buildFlow (E:\git\Flowise\packages\server\dist\utils\index.js:333:19)
at async App.buildChatflow (E:\git\Flowise\packages\server\dist\index.js:1734:40)
at async E:\git\Flowise\packages\server\dist\index.js:1161:13
To Reproduce Steps to reproduce the behavior:
- Create this flow:
Or import the JSON file: llamaIndex test Chatflow.json
Try to ask any question.
Expected behavior This should probably work.
Screenshots
Flow llamaIndex test Chatflow.json
Setup Using latest build from the repo, built locally on Windows.
Note the query engine appears to have the same issue, so presumably this is a problem with the simplestore node.
I replicated the same issue with a fresh Docker image, so it's not the pathing on Windows (vectorstore has the wrong / in the path, but that doesn't seem to be the issue given the same thing happens on Docker Linux image).
Okay I figured it out.
This only fails the very first time, before the database has been created. It won't create the database if the call to do the embeddings comes in the prediction call. If you first run the upsert, then do the query, it will succeed.
What's more, all subsequent calls, even with new chatflows, documents and other things will upsert correctly on-the-fly once the database has been created.
so if we do the upsert first then query, it works fine?
I believe it would, yes. As a note this is what the LangChain nodes do, at least if you use the in-memory vector store.
A prediction will cause an upsert.
Only issue is there's no way to delete the previous entries, I opened a discussion about that since it will grow indefinitely (at least with SimpleStore).