pydantic.errors.PydanticUserError: A non-annotated attribute was detected: type = 'image'. All model fields require a type annotation; if type is not meant to be a field, you may be able to resolve this error by annotating it as a ClassVar or updating model_config['ignored_types'].
For further information visit https://errors.pydantic.dev/2.8/u/model-field-missing-annotation
在pydantic2.8版本中Pydantic 要求所有模型字段都有类型注释。如果 type 是非字段属性,则应将其注释为 ClassVar。
作者的pydantic 版本应该是先前的,需要手动将model中的两个类修改成如下:
在使用作者代码时出现此报错
在pydantic2.8版本中Pydantic 要求所有模型字段都有类型注释。如果 type 是非字段属性,则应将其注释为 ClassVar。 作者的pydantic 版本应该是先前的,需要手动将model中的两个类修改成如下: