浏览代码

chore(api): improve type hints for BaseNode and its subclasses (#15826)

tags/1.1.0
QuantumGhost 7 个月前
父节点
当前提交
23ed3a520b
没有帐户链接到提交者的电子邮件

+ 2
- 2
api/core/workflow/nodes/base/node.py 查看文件





class BaseNode(Generic[GenericNodeData]): class BaseNode(Generic[GenericNodeData]):
_node_data_cls: type[BaseNodeData]
_node_data_cls: type[GenericNodeData]
_node_type: NodeType _node_type: NodeType


def __init__( def __init__(
self.node_id = node_id self.node_id = node_id


node_data = self._node_data_cls.model_validate(config.get("data", {})) node_data = self._node_data_cls.model_validate(config.get("data", {}))
self.node_data = cast(GenericNodeData, node_data)
self.node_data = node_data


@abstractmethod @abstractmethod
def _run(self) -> NodeRunResult | Generator[Union[NodeEvent, "InNodeEvent"], None, None]: def _run(self) -> NodeRunResult | Generator[Union[NodeEvent, "InNodeEvent"], None, None]:

+ 1
- 1
api/core/workflow/nodes/iteration/iteration_start_node.py 查看文件

from models.workflow import WorkflowNodeExecutionStatus from models.workflow import WorkflowNodeExecutionStatus




class IterationStartNode(BaseNode):
class IterationStartNode(BaseNode[IterationStartNodeData]):
""" """
Iteration Start Node. Iteration Start Node.
""" """

+ 1
- 1
api/core/workflow/nodes/loop/loop_start_node.py 查看文件

from models.workflow import WorkflowNodeExecutionStatus from models.workflow import WorkflowNodeExecutionStatus




class LoopStartNode(BaseNode):
class LoopStartNode(BaseNode[LoopStartNodeData]):
""" """
Loop Start Node. Loop Start Node.
""" """

+ 2
- 2
api/core/workflow/nodes/variable_assigner/v1/node.py 查看文件

from core.variables import SegmentType, Variable from core.variables import SegmentType, Variable
from core.workflow.entities.node_entities import NodeRunResult from core.workflow.entities.node_entities import NodeRunResult
from core.workflow.nodes.base import BaseNode, BaseNodeData
from core.workflow.nodes.base import BaseNode
from core.workflow.nodes.enums import NodeType from core.workflow.nodes.enums import NodeType
from core.workflow.nodes.variable_assigner.common import helpers as common_helpers from core.workflow.nodes.variable_assigner.common import helpers as common_helpers
from core.workflow.nodes.variable_assigner.common.exc import VariableOperatorNodeError from core.workflow.nodes.variable_assigner.common.exc import VariableOperatorNodeError




class VariableAssignerNode(BaseNode[VariableAssignerData]): class VariableAssignerNode(BaseNode[VariableAssignerData]):
_node_data_cls: type[BaseNodeData] = VariableAssignerData
_node_data_cls = VariableAssignerData
_node_type = NodeType.VARIABLE_ASSIGNER _node_type = NodeType.VARIABLE_ASSIGNER


def _run(self) -> NodeRunResult: def _run(self) -> NodeRunResult:

正在加载...
取消
保存