GaiZhenbiao / ChuanhuChatGPT

GUI for ChatGPT API and many LLMs. Supports agents, file-based QA, GPT finetuning and query with web search. All with a neat UI.
https://huggingface.co/spaces/JohnSmith9982/ChuanhuChatGPT
GNU General Public License v3.0
15.24k stars 2.3k forks source link

[远程部署]: 更新最新版启动报错:ImportError: cannot import name 'BaseLanguageModel' from 'langchain.schema' (/usr/local/lib/python3.10/dist-packages/langchain/schema.py) #763

Closed oiuv closed 1 year ago

oiuv commented 1 year ago

是否已存在现有反馈与解答?

是否是一个代理配置相关的疑问?

错误描述

启动失败,提示ImportError

$ python3 ChuanhuChatbot.py
Traceback (most recent call last):
  File "/root/ChuanhuChatGPT/ChuanhuChatbot.py", line 12, in <module>
    from modules.overwrites import *
  File "/root/ChuanhuChatGPT/modules/overwrites.py", line 4, in <module>
    from llama_index import Prompt
  File "/usr/local/lib/python3.10/dist-packages/llama_index/__init__.py", line 18, in <module>
    from llama_index.indices.common.struct_store.base import SQLDocumentContextBuilder
  File "/usr/local/lib/python3.10/dist-packages/llama_index/indices/__init__.py", line 4, in <module>
    from llama_index.indices.keyword_table.base import GPTKeywordTableIndex
  File "/usr/local/lib/python3.10/dist-packages/llama_index/indices/keyword_table/__init__.py", line 4, in <module>
    from llama_index.indices.keyword_table.base import GPTKeywordTableIndex
  File "/usr/local/lib/python3.10/dist-packages/llama_index/indices/keyword_table/base.py", line 17, in <module>
    from llama_index.indices.base import BaseGPTIndex, QueryMap
  File "/usr/local/lib/python3.10/dist-packages/llama_index/indices/base.py", line 16, in <module>
    from llama_index.indices.query.base import BaseGPTIndexQuery
  File "/usr/local/lib/python3.10/dist-packages/llama_index/indices/query/base.py", line 18, in <module>
    from llama_index.indices.postprocessor.node import (
  File "/usr/local/lib/python3.10/dist-packages/llama_index/indices/postprocessor/__init__.py", line 5, in <module>
    from llama_index.indices.postprocessor.node import (
  File "/usr/local/lib/python3.10/dist-packages/llama_index/indices/postprocessor/node.py", line 11, in <module>
    from llama_index.indices.response.type import ResponseMode
  File "/usr/local/lib/python3.10/dist-packages/llama_index/indices/response/__init__.py", line 4, in <module>
    from llama_index.indices.response.response_builder import (
  File "/usr/local/lib/python3.10/dist-packages/llama_index/indices/response/response_builder.py", line 17, in <module>
    from llama_index.indices.common_tree.base import GPTTreeIndexBuilder
  File "/usr/local/lib/python3.10/dist-packages/llama_index/indices/common_tree/base.py", line 13, in <module>
    from llama_index.indices.service_context import ServiceContext
  File "/usr/local/lib/python3.10/dist-packages/llama_index/indices/service_context.py", line 6, in <module>
    from llama_index.indices.prompt_helper import PromptHelper
  File "/usr/local/lib/python3.10/dist-packages/llama_index/indices/prompt_helper.py", line 12, in <module>
    from llama_index.langchain_helpers.chain_wrapper import LLMPredictor
  File "/usr/local/lib/python3.10/dist-packages/llama_index/langchain_helpers/chain_wrapper.py", line 6, in <module>
    from llama_index.llm_predictor.base import (  # noqa: F401
  File "/usr/local/lib/python3.10/dist-packages/llama_index/llm_predictor/__init__.py", line 4, in <module>
    from llama_index.llm_predictor.base import LLMPredictor
  File "/usr/local/lib/python3.10/dist-packages/llama_index/llm_predictor/base.py", line 12, in <module>
    from langchain.schema import BaseLanguageModel
ImportError: cannot import name 'BaseLanguageModel' from 'langchain.schema' (/usr/local/lib/python3.10/dist-packages/langchain/schema.py)

复现操作

本来正常的,只是 git pull 到最新版,并且使用 pip install -r requirements.txt 更新了依赖,再启动就报错了。

错误日志

python3 ChuanhuChatbot.py
Traceback (most recent call last):
  File "/root/ChuanhuChatGPT/ChuanhuChatbot.py", line 12, in <module>
    from modules.overwrites import *
  File "/root/ChuanhuChatGPT/modules/overwrites.py", line 4, in <module>
    from llama_index import Prompt
  File "/usr/local/lib/python3.10/dist-packages/llama_index/__init__.py", line 18, in <module>
    from llama_index.indices.common.struct_store.base import SQLDocumentContextBuilder
  File "/usr/local/lib/python3.10/dist-packages/llama_index/indices/__init__.py", line 4, in <module>
    from llama_index.indices.keyword_table.base import GPTKeywordTableIndex
  File "/usr/local/lib/python3.10/dist-packages/llama_index/indices/keyword_table/__init__.py", line 4, in <module>
    from llama_index.indices.keyword_table.base import GPTKeywordTableIndex
  File "/usr/local/lib/python3.10/dist-packages/llama_index/indices/keyword_table/base.py", line 17, in <module>
    from llama_index.indices.base import BaseGPTIndex, QueryMap
  File "/usr/local/lib/python3.10/dist-packages/llama_index/indices/base.py", line 16, in <module>
    from llama_index.indices.query.base import BaseGPTIndexQuery
  File "/usr/local/lib/python3.10/dist-packages/llama_index/indices/query/base.py", line 18, in <module>
    from llama_index.indices.postprocessor.node import (
  File "/usr/local/lib/python3.10/dist-packages/llama_index/indices/postprocessor/__init__.py", line 5, in <module>
    from llama_index.indices.postprocessor.node import (
  File "/usr/local/lib/python3.10/dist-packages/llama_index/indices/postprocessor/node.py", line 11, in <module>
    from llama_index.indices.response.type import ResponseMode
  File "/usr/local/lib/python3.10/dist-packages/llama_index/indices/response/__init__.py", line 4, in <module>
    from llama_index.indices.response.response_builder import (
  File "/usr/local/lib/python3.10/dist-packages/llama_index/indices/response/response_builder.py", line 17, in <module>
    from llama_index.indices.common_tree.base import GPTTreeIndexBuilder
  File "/usr/local/lib/python3.10/dist-packages/llama_index/indices/common_tree/base.py", line 13, in <module>
    from llama_index.indices.service_context import ServiceContext
  File "/usr/local/lib/python3.10/dist-packages/llama_index/indices/service_context.py", line 6, in <module>
    from llama_index.indices.prompt_helper import PromptHelper
  File "/usr/local/lib/python3.10/dist-packages/llama_index/indices/prompt_helper.py", line 12, in <module>
    from llama_index.langchain_helpers.chain_wrapper import LLMPredictor
  File "/usr/local/lib/python3.10/dist-packages/llama_index/langchain_helpers/chain_wrapper.py", line 6, in <module>
    from llama_index.llm_predictor.base import (  # noqa: F401
  File "/usr/local/lib/python3.10/dist-packages/llama_index/llm_predictor/__init__.py", line 4, in <module>
    from llama_index.llm_predictor.base import LLMPredictor
  File "/usr/local/lib/python3.10/dist-packages/llama_index/llm_predictor/base.py", line 12, in <module>
    from langchain.schema import BaseLanguageModel
ImportError: cannot import name 'BaseLanguageModel' from 'langchain.schema' (/usr/local/lib/python3.10/dist-packages/langchain/schema.py)

运行环境

补充说明

pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. llama-index 0.5.25 requires langchain==0.0.142, but you have langchain 0.0.170 which is incompatible.

检查日志有这个问题,版本冲突,如果改0.0.142也不行~

GaiZhenbiao commented 1 year ago

请使用最新版代码。我删除了llama index这个依赖。

oiuv commented 1 year ago

请使用最新版代码。我删除了llama index这个依赖。

我pull的就是最新版,你看看 modules/overwrites.py 这个文件中还有这个包呢,我试着把这个包注释了,可以启动,但会话又会报错。这个依赖没有处理干净。

GaiZhenbiao commented 1 year ago

现在应该没问题了,我新创建了一个虚拟环境测试没问题。