NeMo-Guardrails
NeMo-Guardrails copied to clipboard
feature: Update Pydantic to v2.10.5 and remove Deprecated validators
Did you check the docs?
- [x] I have read all the NeMo-Guardrails docs
Is your feature request related to a problem? Please describe.
I suggest to keep up with the latest Pydantic versions since the model_validators that are used inside the library (e.g. nemoguardrails /rails/llm/config.py:975) are deprecated.
Here is an example of the warnings when using the latest Pydantic version (v2.10.5):
nemoguardrails/rails/llm/config.py:975: PydanticDeprecatedSince20: Pydantic V1 style @root_validator validators are deprecated. You should migrate to Pydantic V2 style @model_validator validators, see the migration guide for more details. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.9/migration/ @root_validator(pre=True, allow_reuse=True)
Describe the solution you'd like
Update the @root_validator to Pydantic V2 style @model_validator validators.
Describe alternatives you've considered
No relevant alternatives, just update the library.
Additional context
No response
Thank you @LukeKan 👍🏻 Indeed we should upgrade to v2. I think it was not done completely due to backward compatibility reasons but we should be able to do it now.
@Pouyanpi hi, I tried to raise a PR for this issue, can you help take a look... thanks a lot... https://github.com/NVIDIA/NeMo-Guardrails/pull/967
Thank you @xiaobo8204 , I'll review your PR soon.
@Pouyanpi sure, updated the PR with the review feedback, thanks a lot...