PydanticUserError:如果您将 `@root_validator` 与 pre=False (默认)一起使用,则必须指定 `skip_on_failure=True`

问题描述 投票:0回答:1

我想在 google colab 中执行此代码,但出现以下错误:

from llama_index.prompts.prompts import SimpleInputPrompt

# Create a system prompt 
system_prompt = """[INST] <>
more string here.<>
"""

query_wrapper_prompt = SimpleInputPrompt("{query_str} [/INST]")

错误:

/usr/local/lib/python3.10/dist-packages/pydantic/_internal/_config.py:269: UserWarning: Valid config keys have changed in V2:
* 'allow_population_by_field_name' has been renamed to 'populate_by_name'
  warnings.warn(message, UserWarning)
---------------------------------------------------------------------------
PydanticUserError                         Traceback (most recent call last)
<ipython-input-36-c45796b371fe> in <cell line: 3>()
      1 # Import the prompt wrapper...
      2 # but for llama index
----> 3 from llama_index.prompts.prompts import SimpleInputPrompt
      4 # Create a system prompt
      5 system_prompt = """[INST] <>

6 frames
/usr/local/lib/python3.10/dist-packages/pydantic/deprecated/class_validators.py in root_validator(pre, skip_on_failure, allow_reuse, *__args)
    226     mode: Literal['before', 'after'] = 'before' if pre is True else 'after'
    227     if pre is False and skip_on_failure is not True:
--> 228         raise PydanticUserError(
    229             'If you use `@root_validator` with pre=False (the default) you MUST specify `skip_on_failure=True`.'
    230             ' Note that `@root_validator` is deprecated and should be replaced with `@model_validator`.',

PydanticUserError: If you use `@root_validator` with pre=False (the default) you MUST specify `skip_on_failure=True`. Note that `@root_validator` is deprecated and should be replaced with `@model_validator`.

For further information visit https://errors.pydantic.dev/2.1.1/u/root-validator-pre-skip

如果我点击链接,我的情况就没有解决方案。 我该如何解决这个问题?

谢谢转发。

python prompt pydantic llama-index
1个回答
0
投票

在我的环境中,我有

pip list | grep pydantic
pydantic                     2.2.1

我通过降级

pydantic
版本来解决问题

pip install pydantic==1.10.9
© www.soinside.com 2019 - 2024. All rights reserved.