admin管理员组文章数量:1122846
I have a package (llama_index
) in my project which uses a bunch of pydantic classes. I have been using this dependency without any issues for a couple days. Now today, all of a sudden, I try to run one of my scripts, and it throws an error when trying to import
from llama_index.core.schema import Document, TextNode
Here is the main part of the error message
schema
raise PydanticSchemaGenerationError(
pydantic.errors.PydanticSchemaGenerationError: Unable to generate pydantic-core schema for typing.AsyncGenerator[str, NoneType]. Set `arbitrary_types_allowed=True` in the model_config to ignore this error or implement `__get_pydantic_core_schema__` on your type to fully support it.
If you got this error by calling handler(<some type>) within `__get_pydantic_core_schema__` then you likely need to call `handler.generate_schema(<some type>)` since we do not call `__get_pydantic_core_schema__` on `<some type>` otherwise to avoid infinite recursion.
For further information visit /2.10/u/schema-for-unknown-type
I would understand what to do if this was one of my classes throwing this error (just add in the class attribute of arbitrary_types_allowed=True
).
But this is springing up from a class in the llama_index package, which up until now was working without any issues
File "/home/stevea/repos/interne/document-processing/.venv/lib/python3.12/site-packages/llama_index/core/instrumentation/events/query.py", line 21, in <module>
class QueryEndEvent(BaseEvent):
File "/home/stevea/repos/interne/document-processing/.venv/lib/python3.12/site-packages/pydantic/_internal/_model_construction.py", line 226, in __new__
complete_model_class(
File "/home/stevea/repos/interne/document-processing/.venv/lib/python3.12/site-packages/pydantic/_internal/_model_construction.py", line 658, in complete_model_class
schema = cls.__get_pydantic_core_schema__(cls, handler)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I suspect that it may have to do with the pydantic version I am running being incompatible with the llama_index package, but I checked my poetry lock file and the package is in line with the one I have installed
[[package]]
name = "llama-index-core"
version = "0.11.23"
description = "Interface between LLMs and your data"
optional = false
python-versions = "<4.0,>=3.8.1"
files = [
{file = "llama_index_core-0.11.23-py3-none-any.whl", hash = "sha256:25a0cb4a055bfb348655ca4acd1b475529bd8537a7b81874ef14ed13f56e06c1"},
{file = "llama_index_core-0.11.23.tar.gz", hash = "sha256:e150859696a0eae169fe19323f46e9a31af2c12c3182012e4d0353ea8eb06d24"},
]
[package.dependencies]
...
pydantic = ">=2.7.0,<3.0.0"
My installed version:
[[package]]
name = "pydantic"
version = "2.10.0"
description = "Data validation using Python type hints"
optional = false
python-versions = ">=3.8"
And I've also checked the history of my poetry file and none of the pydantic stuff has changed since I initially created the venv. At this point I don't understand what could be causing this or how I can fix it. I've tried re-installing the venv but no luck...
本文标签: pythonPydantic throwing pydanticerrorsPydanticSchemaGenerationError all of a suddenStack Overflow
版权声明:本文标题:python - Pydantic throwing pydantic.errors.PydanticSchemaGenerationError all of a sudden - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736302860a1931684.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论