报错 - llama-index pydantic error | arbitrary_types_allowed | PydanticUserError

server/2024/12/21 23:03:50/

国庆节前使用 LiteLLMEmbedding 设置 llama-index Settings.embed_model 还好好的,回来后,就就报错,试着降级 llama-index 也无用;设置 Settings.llm 也是好好地。

解决方法:conda 重新创建环境后,在安装 llama-index 就好了

具体原因还没找到


我的报错信息如下:

1008

 As of langchain-core 0.3.0, LangChain uses pydantic v2 internally. The langchain_core.pydantic_v1 module was a compatibility shim for pydantic v1, and should no longer be used. Please update the code to import from Pydantic directly.For example, replace imports like: `from langchain_core.pydantic_v1 import BaseModel`
with: `from pydantic import BaseModel`
or the v1 compatibility namespace if you are working in a code base that has not been fully upgraded to pydantic 2 yet. 	from pydantic.v1 import BaseModelfrom langchain.agents.agent import (
Traceback (most recent call last):File "<stdin>", line 1, in <module>File "/Users/xx/miniconda3/lib/python3.11/site-packages/llama_index/core/settings.py", line 74, in embed_modelself._embed_model = resolve_embed_model(embed_model)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "/Users/xx/miniconda3/lib/python3.11/site-packages/llama_index/core/embeddings/utils.py", line 39, in resolve_embed_modelfrom llama_index.core.bridge.langchain import Embeddings as LCEmbeddingsFile "/Users/xx/miniconda3/lib/python3.11/site-packages/llama_index/core/bridge/langchain.py", line 2, in <module>from langchain.agents import (File "/Users/xx/miniconda3/lib/python3.11/site-packages/langchain/agents/__init__.py", line 40, in <module>from langchain.agents.agent import (File "/Users/xx/miniconda3/lib/python3.11/site-packages/langchain/agents/agent.py", line 639, in <module>class LLMSingleActionAgent(BaseSingleActionAgent):File "/Users/xx/miniconda3/lib/python3.11/site-packages/pydantic/v1/main.py", line 197, in __new__fields[ann_name] = ModelField.infer(^^^^^^^^^^^^^^^^^File "/Users/xx/miniconda3/lib/python3.11/site-packages/pydantic/v1/fields.py", line 504, in inferreturn cls(^^^^File "/Users/xx/miniconda3/lib/python3.11/site-packages/pydantic/v1/fields.py", line 434, in __init__self.prepare()File "/Users/xx/miniconda3/lib/python3.11/site-packages/pydantic/v1/fields.py", line 555, in prepareself.populate_validators()File "/Users/xx/miniconda3/lib/python3.11/site-packages/pydantic/v1/fields.py", line 829, in populate_validators*(get_validators() if get_validators else list(find_validators(self.type_, self.model_config))),^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "/Users/xx/miniconda3/lib/python3.11/site-packages/pydantic/v1/validators.py", line 765, in find_validatorsraise RuntimeError(f'no validator found for {type_}, see `arbitrary_types_allowed` in Config')
RuntimeError: no validator found for <class 'langchain.chains.llm.LLMChain'>, see `arbitrary_types_allowed` in Config

升级 langchain 从 0.2 到 0.3 后,依然报错

/Users/xx/miniconda3/lib/python3.11/site-packages/langchain/chains/api/base.py:56: LangChainDeprecationWarning: As of langchain-core 0.3.0, LangChain uses pydantic v2 internally. The langchain_core.pydantic_v1 module was a compatibility shim for pydantic v1, and should no longer be used. Please update the code to import from Pydantic directly.For example, replace imports like: `from langchain_core.pydantic_v1 import BaseModel`
with: `from pydantic import BaseModel`
or the v1 compatibility namespace if you are working in a code base that has not been fully upgraded to pydantic 2 yet. 	from pydantic.v1 import BaseModelfrom langchain_community.utilities.requests import TextRequestsWrapper
/Users/xx/miniconda3/lib/python3.11/site-packages/pydantic/_internal/_config.py:341: UserWarning: Valid config keys have changed in V2:
* 'allow_population_by_field_name' has been renamed to 'populate_by_name'warnings.warn(message, UserWarning)
Traceback (most recent call last):File "<stdin>", line 1, in <module>File "/Users/xx/miniconda3/lib/python3.11/site-packages/llama_index/core/settings.py", line 74, in embed_modelself._embed_model = resolve_embed_model(embed_model)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "/Users/xx/miniconda3/lib/python3.11/site-packages/llama_index/core/embeddings/utils.py", line 39, in resolve_embed_modelfrom llama_index.core.bridge.langchain import Embeddings as LCEmbeddingsFile "/Users/xx/miniconda3/lib/python3.11/site-packages/llama_index/core/bridge/langchain.py", line 66, in <module>from langchain_community.chat_models import (File "<frozen importlib._bootstrap>", line 1229, in _handle_fromlistFile "/Users/xx/miniconda3/lib/python3.11/site-packages/langchain_community/chat_models/__init__.py", line 301, in __getattr__module = importlib.import_module(_module_lookup[name])^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "/Users/xx/miniconda3/lib/python3.11/importlib/__init__.py", line 126, in import_modulereturn _bootstrap._gcd_import(name[level:], package, level)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "/Users/xx/miniconda3/lib/python3.11/site-packages/langchain_community/chat_models/anyscale.py", line 31, in <module>class ChatAnyscale(ChatOpenAI):File "/Users/xx/miniconda3/lib/python3.11/site-packages/pydantic/_internal/_model_construction.py", line 224, in __new__complete_model_class(File "/Users/xx/miniconda3/lib/python3.11/site-packages/pydantic/_internal/_model_construction.py", line 577, in complete_model_classschema = cls.__get_pydantic_core_schema__(cls, handler)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "/Users/xx/miniconda3/lib/python3.11/site-packages/pydantic/main.py", line 671, in __get_pydantic_core_schema__return handler(source)^^^^^^^^^^^^^^^File "/Users/xx/miniconda3/lib/python3.11/site-packages/pydantic/_internal/_schema_generation_shared.py", line 83, in __call__schema = self._handler(source_type)^^^^^^^^^^^^^^^^^^^^^^^^^^File "/Users/xx/miniconda3/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py", line 655, in generate_schemaschema = self._generate_schema_inner(obj)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "/Users/xx/miniconda3/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py", line 924, in _generate_schema_innerreturn self._model_schema(obj)^^^^^^^^^^^^^^^^^^^^^^^File "/Users/xx/miniconda3/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py", line 739, in _model_schema{k: self._generate_md_field_schema(k, v, decorators) for k, v in fields.items()},^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "/Users/xx/miniconda3/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py", line 739, in <dictcomp>{k: self._generate_md_field_schema(k, v, decorators) for k, v in fields.items()},^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "/Users/xx/miniconda3/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py", line 1115, in _generate_md_field_schemacommon_field = self._common_field_schema(name, field_info, decorators)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "/Users/xx/miniconda3/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py", line 1308, in _common_field_schemaschema = self._apply_annotations(^^^^^^^^^^^^^^^^^^^^^^^^File "/Users/xx/miniconda3/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py", line 2107, in _apply_annotationsschema = get_inner_schema(source_type)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "/Users/xx/miniconda3/lib/python3.11/site-packages/pydantic/_internal/_schema_generation_shared.py", line 83, in __call__schema = self._handler(source_type)^^^^^^^^^^^^^^^^^^^^^^^^^^File "/Users/xx/miniconda3/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py", line 2091, in inner_handlermetadata_js_function = _extract_get_pydantic_json_schema(obj, schema)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "/Users/xx/miniconda3/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py", line 2447, in _extract_get_pydantic_json_schemaraise PydanticUserError(
pydantic.errors.PydanticUserError: The `__modify_schema__` method is not supported in Pydantic v2. Use `__get_pydantic_json_schema__` instead in class `SecretStr`.For further information visit https://errors.pydantic.dev/2.9/u/custom-json-schema

2024-10-08(二)


http://www.ppmy.cn/server/129519.html

相关文章

HarmonyOS Next元服务开发快速入门案例

项目代码gitee地址&#xff1a; (HarmonyOS Next 元服务开发快速入门: HarmonyOS Next 元服务开发快速入门 - Gitee.com) 开源协议使用&#xff1a;Apache License 2.0 &#xff0c;代码包支持免费使用&#xff0c;可进行二次开发后选择开源或闭源。 一、创建项目 1.创建项目&…

C++ 语言特性23 - thread_local

一&#xff1a;概述 thread_local 是 C11 引入的用于声明线程局部存储的存储类型说明符。它可以用来声明一个变量&#xff0c;使其在每个线程中有独立的实例&#xff0c;这样每个线程对该变量的修改都只会影响自己的副本&#xff0c;而不会影响其他线程的值。 thread_local 修饰…

初始Linux(二)基础命令

前言&#xff1a; 之前那一篇我们已经介绍了一部分的基础命令&#xff0c;当然那只不过是九牛一毛&#xff0c;本篇我们继续介绍一些比较重要且需要掌握的基础命令。 mv命令&#xff1a; 其实这个命令有两个功能&#xff0c;一个是移动&#xff08;剪切&#xff09;文件&#…

Oracle创建用户报错-ORA-65096: invalid common user or role name

问题描述 ORA-65096: invalid common user or role name 原因分析 这可能是创建角色的容器为cdb导致&#xff0c;当然如果想继续执行&#xff0c;可以在角色名前加C##或者c##&#xff0c;但是这样会导致用户名多了c##&#xff0c;我们不要这样的用户名 解决步骤 用sysdba 登录&…

机器学习框架

引言 机器学习的定义和重要性 机器学习是人工智能的一个分支&#xff0c;它使计算机系统能够从数据中学习并改进其性能&#xff0c;而无需进行明确的编程。通过机器学习&#xff0c;计算机可以识别模式、做出预测、并执行复杂的任务&#xff0c;如图像识别、自然语言处理、推…

Java Set 的介绍与实现原理

什么是 Set 在 Java 中&#xff0c;Set 是一种集合类型&#xff0c;它不允许重复的元素。Set 接口是 Java Collections Framework 的一部分&#xff0c;主要用于存储不重复的值。常见的实现类包括 HashSet、LinkedHashSet 和 TreeSet。 实现原理 1. HashSet HashSet 是最常…

知识图谱入门——5:Neo4j Desktop安装和使用手册(小白向:Cypher 查询语言:逐步教程!Neo4j 优缺点分析)

Neo4j简介 Neo4j 是一个基于图结构的 NoSQL 数据库&#xff0c;专门用于存储、查询和管理图形数据。它的核心思想是使用节点、关系和属性来描述数据。图数据库非常适合那些需要处理复杂关系的数据集&#xff0c;如社交网络、推荐系统、知识图谱等领域。 与传统的关系型数据库…

ESP32-C3实现GPIO输入-判断高低电平

在 ESP32-C3 上实现 GPIO 输入并判断电平状态相对简单。以下是如何在 Arduino IDE 中配置 GPIO 作为输入&#xff0c;并在循环中检查电平状态的步骤&#xff1a; 1. 定义 GPIO 管脚 首先&#xff0c;定义你将要使用的 GPIO 管脚号。 #define GPIO_INPUT_PIN 2 // 定义一个 GP…