pydantic.errors.PydanticUserError: If you use `@root_validator`

报错

使用langchain时,import langchain时报错内容如下:

python 复制代码
pydantic.errors.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.7/u/root-validator-pre-skip

解决

pydantic的版本问题,将pydantic库的版本降低到1.10.13,pydantic_core等相关依赖库的版本也会自动降低。

python 复制代码
pip install pydantic==1.10.13 -i  https://pypi.tuna.tsinghua.edu.cn/simple
相关推荐
一木 之林24 分钟前
LangChain 第8章 记忆系统:短期/长期记忆与 PostgreSQL 持久化
数据库·postgresql·langchain
SkyWalking中文站1 小时前
从模型输入到文件变更:追踪 AgentCore 上的 LangGraph Agent
langchain·aigc·ai编程
BD_Marathon3 小时前
使用@tool装饰器定义工具:args_schema
langchain
BD_Marathon16 小时前
工具的定义方式2:使用@tool装饰器(推荐)
langchain
爱泡脚的鸡腿17 小时前
langchain学习-D1-了解langchain家族与rag
langchain
读书读傻了哟18 小时前
langfuse部署相关
langchain·language model·langfuse
小易老师AI实战20 小时前
LangChain + MCP 协议:Agent 接入联网搜索(Tavily MCP)完整实践
langchain·agent·ai智能体·大模型应用·mcp·联网搜索
hackchen1 天前
LangChain 学习第 2 课 - 提示词模板(Prompt Template)
学习·langchain·prompt
for_ever_love__1 天前
LangChain 1.0 迁移指南:哪些 API 变了,怎么改
chatgpt·langchain·升级·新版本·迁移·变化·1.0
for_ever_love__1 天前
LangChain 结构化输出:让模型稳定吐出符合 schema 的 JSON
langchain·json