Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
fix(core): Reorder `field_validator` and `classmethod` to fit Pydantic V2. (#5257)
-LAN-5a99aeb86409
diff --git a/.github/workflows/style.yml b/.github/workflows/style.ymlindex cb5400b918b..cc4302117f8 100644--- a/.github/workflows/style.yml+++ b/.github/workflows/style.yml@@ -39,7 +39,7 @@ jobs:- name: Ruff checkif: steps.changed-files.outputs.any_changed == 'true'- run: poetry run -C api ruff check --preview ./api+ run: poetry run -C api ruff check ./api- name: Dotenv checkif: steps.changed-files.outputs.any_changed == 'true'diff --git a/api/core/app/entities/queue_entities.py b/api/core/app/entities/queue_entities.pyindex b7e8a3a73e6..15348251f2d 100644--- a/api/core/app/entities/queue_entities.py+++ b/api/core/app/entities/queue_entities.py@@ -77,8 +77,8 @@ class QueueIterationNextEvent(AppQueueEvent):node_run_index: intoutput: Optional[Any] = None # output for the current iteration- @classmethod@field_validator('output', mode='before')+ @classmethoddef set_output(cls, v):"""Set outputdiff --git a/api/core/model_runtime/entities/message_entities.py b/api/core/model_runtime/entities/message_entities.pyindex 2d32ce85c01..e8e6963b56d 100644--- a/api/core/model_runtime/entities/message_entities.py+++ b/api/core/model_runtime/entities/message_entities.py@@ -124,6 +124,7 @@ class AssistantPromptMessage(PromptMessage):function: ToolCallFunction@field_validator('id', mode='before')+ @classmethoddef transform_id_to_str(cls, value) -> str:if not isinstance(value, str):return str(value)diff --git a/api/core/tools/provider/builtin/twilio/tools/send_message.py b/api/core/tools/provider/builtin/twilio/tools/send_message.pyindex 48ce7d839bb..1c52589956c 100644--- a/api/core/tools/provider/builtin/twilio/tools/send_message.py+++ b/api/core/tools/provider/builtin/twilio/tools/send_message.py@@ -32,8 +32,8 @@ class TwilioAPIWrapper(BaseModel):must be empty."""- @classmethod@field_validator('client', mode='before')+ @classmethoddef set_validator(cls, values: dict) -> dict:"""Validate that api key and python package exists in environment."""try:diff --git a/api/core/tools/tool/builtin_tool.py b/api/core/tools/tool/builtin_tool.pyindex 1ed05c112f2..ad7a88838b1 100644--- a/api/core/tools/tool/builtin_tool.py+++ b/api/core/tools/tool/builtin_tool.py@@ -66,7 +66,7 @@ class BuiltinTool(Tool):tenant_id=self.runtime.tenant_id,prompt_messages=prompt_messages)-+def summary(self, user_id: str, content: str) -> str:max_tokens = self.get_max_tokens()diff --git a/api/core/tools/tool/tool.py b/api/core/tools/tool/tool.pyindex b48daf0c52b..6eba5bcb7f1 100644--- a/api/core/tools/tool/tool.py+++ b/api/core/tools/tool/tool.py@@ -32,8 +32,8 @@ class Tool(BaseModel, ABC):# pydantic configsmodel_config = ConfigDict(protected_namespaces=())- @classmethod@field_validator('parameters', mode='before')+ @classmethoddef set_parameters(cls, v, validation_info: ValidationInfo) -> list[ToolParameter]:return v or []diff --git a/api/core/workflow/nodes/http_request/entities.py b/api/core/workflow/nodes/http_request/entities.pyindex 981e3fcc682..c027f9fd29b 100644--- a/api/core/workflow/nodes/http_request/entities.py+++ b/api/core/workflow/nodes/http_request/entities.py@@ -1,7 +1,7 @@import osfrom typing import Literal, Optional, Union-from pydantic import BaseModel, field_validator+from pydantic import BaseModel, ValidationInfo, field_validatorfrom core.workflow.entities.base_node_data_entities import BaseNodeData@@ -24,13 +24,13 @@ class HttpRequestNodeData(BaseNodeData):type: Literal['no-auth', 'api-key']config: Optional[Config]- @classmethod@field_validator('config', mode='before')- def check_config(cls, v, values):+ @classmethod+ def check_config(cls, v: Config, values: ValidationInfo):"""Check config, if type is no-auth, config should be None, otherwise it should be a dict."""- if values['type'] == 'no-auth':+ if values.data['type'] == 'no-auth':return Noneelse:if not v or not isinstance(v, dict):diff --git a/api/core/workflow/nodes/parameter_extractor/entities.py b/api/core/workflow/nodes/parameter_extractor/entities.pyindex 83702eae412..7bb123b1267 100644--- a/api/core/workflow/nodes/parameter_extractor/entities.py+++ b/api/core/workflow/nodes/parameter_extractor/entities.py@@ -25,8 +25,8 @@ class ParameterConfig(BaseModel):description: strrequired: bool- @classmethod@field_validator('name', mode='before')+ @classmethoddef validate_name(cls, value) -> str:if not value:raise ValueError('Parameter name is required')@@ -45,8 +45,8 @@ class ParameterExtractorNodeData(BaseNodeData):memory: Optional[MemoryConfig] = Nonereasoning_mode: Literal['function_call', 'prompt']- @classmethod@field_validator('reasoning_mode', mode='before')+ @classmethoddef set_reasoning_mode(cls, v) -> str:return v or 'function_call'diff --git a/api/core/workflow/nodes/tool/entities.py b/api/core/workflow/nodes/tool/entities.pyindex 72825d7cc3d..2e4743c4832 100644--- a/api/core/workflow/nodes/tool/entities.py+++ b/api/core/workflow/nodes/tool/entities.py@@ -14,9 +14,9 @@ class ToolEntity(BaseModel):tool_label: str # redundancytool_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')+ @classmethoddef check_type(cls, value, validation_info: ValidationInfo):typ = valuevalue = validation_info.data.get('value')diff --git a/api/pyproject.toml b/api/pyproject.tomlindex b56556a62b0..a01975cc7a0 100644--- a/api/pyproject.toml+++ b/api/pyproject.toml@@ -7,6 +7,7 @@ exclude = [line-length = 120[tool.ruff.lint]+preview = trueselect = ["B", # flake8-bugbear rules"F", # pyflakes rulesdiff --git a/dev/reformat b/dev/reformatindex 844bfbef583..ebee1efb40a 100755--- a/dev/reformat+++ b/dev/reformat@@ -9,7 +9,7 @@ if ! command -v ruff &> /dev/null; thenfi# run ruff linter-ruff check --fix --preview ./api+ruff check --fix ./api# env files linting relies on `dotenv-linter` in pathif ! command -v dotenv-linter &> /dev/null; then