Added support for pydantic v2 in addition to pydantic v1. Contributed by Maxwell G (@gotmax23).