英文:
Deploying (and hosting) a LangChain code on StreamLit throws PydanticUserError
问题
我使用LangChain、OpenAI(嵌入和LLM)以及Chroma(用于存储向量嵌入)构建了一个PDF文档问答系统,并使用StreamLit创建了用户界面(UI)。我尝试使用StreamLit云服务部署和托管Web应用程序。在安装所有必需的库和软件包后,Web应用程序抛出了以下错误:
PydanticUserError: 如果您使用`@root_validator`并且pre=False(默认设置),则必须指定`skip_on_failure=True`。请注意,`@root_validator`已弃用,应替换为`@model_validator`。有关更多信息,请访问https://errors.pydantic.dev/2.0.2/u/root-validator-pre-skip
随后是一个Traceback(回溯):
Traceback:
File "/opt/render/project/src/.venv/lib/python3.7/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 552, in _run_script
exec(code, module.__dict__)
File "/opt/render/project/src/app.py", line 3, in <module>
from langchain.document_loaders import PyMuPDFLoader, PyPDFLoader
File "/opt/render/project/src/.venv/lib/python3.7/site-packages/langchain/__init__.py", line 8, in <module>
from langchain.agents import MRKLChain, ReActChain, SelfAskWithSearchChain
File "/opt/render/project/src/.venv/lib/python3.7/site-packages/langchain/agents/__init__.py", line 2, in <module>
from langchain.agents.agent import Agent
File "/opt/render/project/src/.venv/lib/python3.7/site-packages/langchain/agents/agent.py", line 10, in <module>
from langchain.chains.base import Chain
File "/opt/render/project/src/.venv/lib/python3.7/site-packages/langchain/chains/__init__.py", line 2, in <module>
from langchain.chains.conversation.base import ConversationChain
File "/opt/render/project/src/.venv/lib/python3.7/site-packages/langchain/chains/conversation/base.py", line 7, in <module>
from langchain.chains.conversation.memory import ConversationBufferMemory
File "/opt/render/project/src/.venv/lib/python3.7/site-packages/langchain/chains/conversation/memory.py", line 7, in <module>
from langchain.chains.conversation.prompt import SUMMARY_PROMPT
File "/opt/render/project/src/.venv/lib/python3.7/site-packages/langchain/chains/conversation/prompt.py", line 2, in <module>
from langchain.prompts.prompt import PromptTemplate
File "/opt/render/project/src/.venv/lib/python3.7/site-packages/langchain/prompts/__init__.py", line 2, in <module>
from langchain.prompts.base import BasePromptTemplate
File "/opt/render/project/src/.venv/lib/python3.7/site-packages/langchain/prompts/base.py", line 35, in <module>
class BasePromptTemplate(BaseModel, ABC):
File "/opt/render/project/src/.venv/lib/python3.7/site-packages/langchain/prompts/base.py", line 41, in BasePromptTemplate
@root_validator()
File "/opt/render/project/src/.venv/lib/python3.7/site-packages/pydantic/deprecated/class_validators.py", line 231, in root_validator
code='root-validator-pre-skip',
如何处理这个错误,尽管我相信我已安装了所有必要的库和兼容版本?
我尝试查看错误显示的URL,但找不到足够好的内容来调试错误。
英文:
I built a pdf document question-answering using LangChain, OpenAI (embeddings and LLM) and Chroma (for storing the vector embeddings) and UI with StreamLit. I am trying to deploy and host the webapp using StreamLit cloud services. And on installing all the required libraries and packages, the webapp throws an error:
PydanticUserError: If you use `@root_validator` with pre=False (the default) you MUST specify `skip_on_failure=True`. Note that `@root_validator` is deprecated and should be replaced with `@model_validator`. For further information visit https://errors.pydantic.dev/2.0.2/u/root-validator-pre-skip
followed by a Traceback:
Traceback:
File "/opt/render/project/src/.venv/lib/python3.7/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 552, in _run_script
exec(code, module.__dict__)
File "/opt/render/project/src/app.py", line 3, in <module>
from langchain.document_loaders import PyMuPDFLoader, PyPDFLoader
File "/opt/render/project/src/.venv/lib/python3.7/site-packages/langchain/__init__.py", line 8, in <module>
from langchain.agents import MRKLChain, ReActChain, SelfAskWithSearchChain
File "/opt/render/project/src/.venv/lib/python3.7/site-packages/langchain/agents/__init__.py", line 2, in <module>
from langchain.agents.agent import Agent
File "/opt/render/project/src/.venv/lib/python3.7/site-packages/langchain/agents/agent.py", line 10, in <module>
from langchain.chains.base import Chain
File "/opt/render/project/src/.venv/lib/python3.7/site-packages/langchain/chains/__init__.py", line 2, in <module>
from langchain.chains.conversation.base import ConversationChain
File "/opt/render/project/src/.venv/lib/python3.7/site-packages/langchain/chains/conversation/base.py", line 7, in <module>
from langchain.chains.conversation.memory import ConversationBufferMemory
File "/opt/render/project/src/.venv/lib/python3.7/site-packages/langchain/chains/conversation/memory.py", line 7, in <module>
from langchain.chains.conversation.prompt import SUMMARY_PROMPT
File "/opt/render/project/src/.venv/lib/python3.7/site-packages/langchain/chains/conversation/prompt.py", line 2, in <module>
from langchain.prompts.prompt import PromptTemplate
File "/opt/render/project/src/.venv/lib/python3.7/site-packages/langchain/prompts/__init__.py", line 2, in <module>
from langchain.prompts.base import BasePromptTemplate
File "/opt/render/project/src/.venv/lib/python3.7/site-packages/langchain/prompts/base.py", line 35, in <module>
class BasePromptTemplate(BaseModel, ABC):
File "/opt/render/project/src/.venv/lib/python3.7/site-packages/langchain/prompts/base.py", line 41, in BasePromptTemplate
@root_validator()
File "/opt/render/project/src/.venv/lib/python3.7/site-packages/pydantic/deprecated/class_validators.py", line 231, in root_validator
code='root-validator-pre-skip',
How to deal with this error, although I believe I have installed all the necessary packages with compatible versions?
I am trying to see the url that the error shows but could not find anything good enough to debug the error.
答案1
得分: 1
尝试这个:
pip install ydata-profiling
英文:
Try this:
pip install ydata-profiling
答案2
得分: 0
我一直在阅读这个帖子并尝试不同版本的langchain和pydantic。在Pydantic 1.10.9和Langchain 0.0.231上仍然失败。
链接:https://stackoverflow.com/questions/76614379/roo-validator-error-when-importing-langchain-text-splitter-python
英文:
I have been reading this thread and trying different versions of langchain an pydantic. Still failing with Pydantic 1.10.9 and Langchain 0.0.231.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论