wxywb / history_rag

841 stars 109 forks source link

ImportError: cannot import name 'ServiceContext' from 'llama_index' (unknown location) #41

Open Snake-Konginchrist opened 7 months ago

Snake-Konginchrist commented 7 months ago

按照步骤安装完成,运行时报错: (history-rag) ubuntu@SKTech-Shanghai:/var/www/history_rag$ python cli.py --cfg cfgs/config_qwen.yaml Traceback (most recent call last): File "/var/www/history_rag/cli.py", line 1, in from executor import MilvusExecutor File "/var/www/history_rag/executor.py", line 12, in from llama_index import ServiceContext, StorageContext ImportError: cannot import name 'ServiceContext' from 'llama_index' (unknown location)

Snake-Konginchrist commented 7 months ago

按照一些方法,llama_index已经更新到0.10.5版本了,仍然出现此问题,Python版本是3.10.12

wxywb commented 7 months ago

你先试一下这个版本?llama-index 0.9.39,虽然 'llama_index' (unknown location)这个未知位置引起了我的注意。

Snake-Konginchrist commented 7 months ago

感谢,问题已解决,看来真的是版本更迭的问题。

zizu2024 commented 7 months ago

大神好,我在windows下遇到了同样的问题,请教如何回退版本,是否需要删除镜像重新编译,本人是小白,麻烦指教详细步骤,多谢!

wxywb commented 7 months ago

大神好,我在windows下遇到了同样的问题,请教如何回退版本,是否需要删除镜像重新编译,本人是小白,麻烦指教详细步骤,多谢! 试一下

pip install llama-index==0.9.39
PaperPlaneDeemo commented 7 months ago

今天也遇到了相同的问题,llama_index版本是0.10.6

wxywb commented 7 months ago

我会升级到更高版本的llama_index

iwill220182 commented 4 months ago

Traceback (most recent call last): File "/Users/lianmingzhang/WorkSpace/PyCharm/llama-study/LamaIndex/RagDemo.py", line 31, in response = query_engine.query("根据上下文内容,告诉我什么是: Training Hardware?") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/anaconda3/envs/pytonh_3_11_9/lib/python3.11/site-packages/llama_index/core/instrumentation/dispatcher.py", line 274, in wrapper result = func(*args, kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/opt/anaconda3/envs/pytonh_3_11_9/lib/python3.11/site-packages/llama_index/core/base/base_query_engine.py", line 53, in query query_result = self._query(str_or_query_bundle) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/anaconda3/envs/pytonh_3_11_9/lib/python3.11/site-packages/llama_index/core/instrumentation/dispatcher.py", line 274, in wrapper result = func(*args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/opt/anaconda3/envs/pytonh_3_11_9/lib/python3.11/site-packages/llama_index/core/query_engine/retriever_query_engine.py", line 190, in _query response = self._response_synthesizer.synthesize( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/anaconda3/envs/pytonh_3_11_9/lib/python3.11/site-packages/llama_index/core/instrumentation/dispatcher.py", line 274, in wrapper result = func(args, kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/opt/anaconda3/envs/pytonh_3_11_9/lib/python3.11/site-packages/llama_index/core/response_synthesizers/base.py", line 242, in synthesize response_str = self.get_response( ^^^^^^^^^^^^^^^^^^ File "/opt/anaconda3/envs/pytonh_3_11_9/lib/python3.11/site-packages/llama_index/core/response_synthesizers/tree_summarize.py", line 169, in get_response response = self._llm.predict( ^^^^^^^^^^^^^^^^^^ File "/opt/anaconda3/envs/pytonh_3_11_9/lib/python3.11/site-packages/llama_index/legacy/llms/llm.py", line 239, in predict chat_response = self.chat(messages) ^^^^^^^^^^^^^^^^^^^ File "/opt/anaconda3/envs/pytonh_3_11_9/lib/python3.11/site-packages/llama_index/legacy/llms/base.py", line 91, in wrapped_llm_chat with wrapper_logic(_self) as callback_manager: File "/opt/anaconda3/envs/pytonh_3_11_9/lib/python3.11/contextlib.py", line 137, in enter return next(self.gen) ^^^^^^^^^^^^^^ File "/opt/anaconda3/envs/pytonh_3_11_9/lib/python3.11/site-packages/llama_index/legacy/llms/base.py", line 37, in wrapper_logic raise ValueError( ValueError: Cannot use llm_chat_callback on an instance without a callback_manager attribute.

进程已结束,退出代码为 1