mirror of
http://112.124.100.131/huang.ze/ebiz-dify-ai.git
synced 2025-12-11 03:46:52 +08:00
fix(core): Reorder field_validator and classmethod to fit Pydantic V2. (#5257)
This commit is contained in:
@@ -14,9 +14,9 @@ class ToolEntity(BaseModel):
|
||||
tool_label: str # redundancy
|
||||
tool_configurations: dict[str, Any]
|
||||
|
||||
@classmethod
|
||||
@field_validator('tool_configurations', mode='before')
|
||||
def validate_tool_configurations(cls, value, values: ValidationInfo) -> dict[str, Any]:
|
||||
@classmethod
|
||||
def validate_tool_configurations(cls, value, values: ValidationInfo):
|
||||
if not isinstance(value, dict):
|
||||
raise ValueError('tool_configurations must be a dictionary')
|
||||
|
||||
@@ -32,8 +32,8 @@ class ToolNodeData(BaseNodeData, ToolEntity):
|
||||
value: Union[Any, list[str]]
|
||||
type: Literal['mixed', 'variable', 'constant']
|
||||
|
||||
@classmethod
|
||||
@field_validator('type', mode='before')
|
||||
@classmethod
|
||||
def check_type(cls, value, validation_info: ValidationInfo):
|
||||
typ = value
|
||||
value = validation_info.data.get('value')
|
||||
|
||||
Reference in New Issue
Block a user