run-llama / llama_index

LlamaIndex is a data framework for your LLM applications
https://docs.llamaindex.ai
MIT License
35.51k stars 5.01k forks source link

Getting type = vector_store_dict[TYPE_KEY] KeyError: 'type' error only on streamlit cloud #1228

Closed ghost closed 1 year ago

ghost commented 1 year ago

hello, I'm getting this error with my app only when I run it on streamlit cloud and couldn't resolve it, what might be causing it?

Collecting usage statistics. To deactivate, set browser.gatherUsageStats to False.

2023-04-17 23:08:01.114 Uncaught app exception

Traceback (most recent call last):

File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 565, in _run_script

exec(code, module.dict) File "/app/chat6529/6529GPT.py", line 99, in

st.session_state.response_text, st.session_state.similarity_score = process_question(query) File "/app/chat6529/6529GPT.py", line 54, in process_question

index = GPTSimpleVectorIndex.load_from_disk(input_index) File "/home/appuser/venv/lib/python3.9/site-packages/llama_index/indices/base.py", line 364, in load_from_disk

return cls.load_from_string(file_contents, **kwargs) File "/home/appuser/venv/lib/python3.9/site-packages/llama_index/indices/base.py", line 340, in load_from_string

return cls.load_from_dict(result_dict, **kwargs) File "/home/appuser/venv/lib/python3.9/site-packages/llama_index/indices/vector_store/base.py", line 260, in load_from_dict

vector_store = load_vector_store_from_dict( File "/home/appuser/venv/lib/python3.9/site-packages/llama_index/vector_stores/registry.py", line 52, in load_vector_store_from_dict

type = vector_store_dict[TYPE_KEY] KeyError: 'type'

markusantonuis commented 1 year ago

I am also getting this exact same error with GPTSimpleVectorIndex despite it working fine up until yesterday. Win10, Python 311, llama-index-0.5.17

jerryjliu commented 1 year ago

We recently changed the way we save/load vector stores from disk - sorry about that

@mfelat out of curiosity, is it expensive to rebuild the vector index?

ghost commented 1 year ago

no not expensive, but the interesting part is, it works on my mac without an error. how can I reindex the file?

jerryjliu commented 1 year ago

Rebuild the index from the existing set of documents e.g. create a new index

ghost commented 1 year ago

Rebuild the index from the existing set of documents e.g. create a new index

fixed the issue by downgrading the llama_index to 0.4.40. not sure if this is the best way, if I reindex with the latest version would it be better?

IAmStoxe commented 1 year ago

I just spent about $250 indexing a library of legal documents. How can I migrate?

splendourbell commented 1 year ago

修改了后,感觉效果不行了

markusantonuis commented 1 year ago

Is there still a need to rebuild the index to fix this issue? I would prefer to wait until there is a clear resolution.

ghost commented 1 year ago

as a workaround, I downgraded the llama_index to 0.4.40, but if the newer version of indexing provides better quality, I could reindex. I'd appreciate any feedback on that.

markusantonuis commented 1 year ago

I downgraded like you suggested and that works, thanks! Got an unusual warning from openai: UserWarning: You are trying to use a chat model. This way of initializing it is no longer supported. Instead, please use: from langchain.chat_models import ChatOpenAI

ghost commented 1 year ago

from langchain.chat_models import ChatOpenAI

this is for indexing I think, right? so we probably need to reindex as I'm using gpt-3.5-turbo for completinons

markusantonuis commented 1 year ago

from langchain.chat_models import ChatOpenAI

this is for indexing I think, right? so we probably need to reindex as I'm using gpt-3.5-turbo for completinons

That was for querying only, using GPT3.5. I indexed the documents using the default (ADA2) weeks ago. I haven't tried reindexing yet.

mfittko commented 1 year ago

same, would be cool if we could get a hint on how to migrate the index files.

Martok88 commented 1 year ago

I experienced this issue as well, after upgrading to the latest version. A migration tool would be ideal, to avoid the cost of recreating indexes. I was also wondering, will there be any similar problems with the upcoming 0.6 version?

dosubot[bot] commented 1 year ago

Hi, @mfelat! I'm here to help the LlamaIndex team manage their backlog and I wanted to let you know that we are marking this issue as stale.

Based on my understanding, the issue titled "Getting type = vector_store_dict[TYPE_KEY] KeyError: 'type' error only on streamlit cloud" is about an error that occurs when running an app on Streamlit Cloud. Users have reported a KeyError related to the 'type' key in the vector_store_dict. Some users have found a workaround by downgrading the llama_index package, but there is a discussion about the need to reindex with the latest version for better quality. Additionally, there are requests for a migration tool to avoid recreating indexes and concerns about potential problems with the upcoming 0.6 version.

Before we proceed, we would like to confirm if this issue is still relevant to the latest version of the LlamaIndex repository. If it is, please let us know by commenting on this issue. Otherwise, feel free to close the issue yourself or it will be automatically closed in 7 days.

Thank you for your understanding and we appreciate your contribution to the LlamaIndex project!