yukio-takagi / openai_ESG-bot_004

0 stars 0 forks source link

Streamlit で ESG-index.json 内の Key Error #1

Open yukio-takagi opened 1 year ago

yukio-takagi commented 1 year ago

llama_index のバージョンにより、streamlit で稼働できない。 原因は ESG-index.json 内の Key Error

> 2023-04-21 07:56:13.996 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/openai_esg-bot_004/ESG-app.py", line 26, in <module>
>     index = GPTSimpleVectorIndex.load_from_disk("ESG-index.json", service_context = service_context)
>   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 263, in load_from_dict
>     return super().load_from_dict(result_dict, vector_store=vector_store, **kwargs)
>   File "/home/appuser/venv/lib/python3.9/site-packages/llama_index/indices/base.py", line 316, in load_from_dict
>     docstore = DocumentStore.load_from_dict(result_dict[DOCSTORE_KEY])
>   File "/home/appuser/venv/lib/python3.9/site-packages/llama_index/docstore.py", line 72, in load_from_dict
>     for doc_id, doc_dict in docs_dict["docs"].items():
> KeyError: 'docs'
> 

下記をみると、llama_index0.4.36 にダウングレードする対処があるようだが、そうすると、Service_context が使えなくなる

https://github.com/jerryjliu/llama_index/issues/964

yukio-takagi commented 1 year ago

ダウングレードしたときのエラーは下記

[08:18:40] 🔄 Updated app!
2023-04-21 08:18:41.529 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/openai_esg-bot_004/ESG-app.py", line 4, in <module>
    from llama_index import GPTSimpleVectorIndex, SimpleDirectoryReader, ServiceContext, PromptHelper
ImportError: cannot import name 'ServiceContext' from 'llama_index' (/home/appuser/venv/lib/python3.9/site-packages/llama_index/__init__.py)
2023-04-21 08:18:41.529 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/openai_esg-bot_004/ESG-app.py", line 4, in <module>
    from llama_index import GPTSimpleVectorIndex, SimpleDirectoryReader, ServiceContext, PromptHelper
ImportError: cannot import name 'ServiceContext' from 'llama_index' (/home/appuser/venv/lib/python3.9/site-packages/llama_index/__init__.py)