mirror of
https://github.com/langgenius/dify.git
synced 2026-05-03 08:58:09 +08:00
add updated_at to sync workflow api
This commit is contained in:
@ -1,21 +1,25 @@
|
||||
from abc import abstractmethod
|
||||
from typing import Optional
|
||||
|
||||
from core.workflow.callbacks.base_callback import BaseWorkflowCallback
|
||||
from core.workflow.entities.base_node_data_entities import BaseNodeData
|
||||
from core.workflow.entities.node_entities import NodeType
|
||||
from core.workflow.entities.variable_pool import VariablePool
|
||||
|
||||
|
||||
class BaseNode:
|
||||
_node_type: NodeType
|
||||
_node_data_cls: type[BaseNodeData]
|
||||
_node_type: NodeType
|
||||
|
||||
node_id: str
|
||||
node_data: BaseNodeData
|
||||
|
||||
def __init__(self, config: dict) -> None:
|
||||
self._node_id = config.get("id")
|
||||
if not self._node_id:
|
||||
self.node_id = config.get("id")
|
||||
if not self.node_id:
|
||||
raise ValueError("Node ID is required.")
|
||||
|
||||
self._node_data = self._node_data_cls(**config.get("data", {}))
|
||||
self.node_data = self._node_data_cls(**config.get("data", {}))
|
||||
|
||||
@abstractmethod
|
||||
def _run(self, variable_pool: Optional[VariablePool] = None,
|
||||
@ -29,11 +33,13 @@ class BaseNode:
|
||||
raise NotImplementedError
|
||||
|
||||
def run(self, variable_pool: Optional[VariablePool] = None,
|
||||
run_args: Optional[dict] = None) -> dict:
|
||||
run_args: Optional[dict] = None,
|
||||
callbacks: list[BaseWorkflowCallback] = None) -> dict:
|
||||
"""
|
||||
Run node entry
|
||||
:param variable_pool: variable pool
|
||||
:param run_args: run args
|
||||
:param callbacks: callbacks
|
||||
:return:
|
||||
"""
|
||||
if variable_pool is None and run_args is None:
|
||||
@ -52,3 +58,11 @@ class BaseNode:
|
||||
:return:
|
||||
"""
|
||||
return {}
|
||||
|
||||
@property
|
||||
def node_type(self) -> NodeType:
|
||||
"""
|
||||
Get node type
|
||||
:return:
|
||||
"""
|
||||
return self._node_type
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
from typing import Optional
|
||||
|
||||
from core.app.app_config.entities import VariableEntity
|
||||
from core.workflow.entities.base_node_data_entities import BaseNodeData
|
||||
from core.workflow.entities.node_entities import NodeType
|
||||
@ -22,6 +20,4 @@ class StartNodeData(BaseNodeData):
|
||||
"""
|
||||
type: str = NodeType.START.value
|
||||
|
||||
title: str
|
||||
desc: Optional[str] = None
|
||||
variables: list[VariableEntity] = []
|
||||
|
||||
@ -7,8 +7,8 @@ from core.workflow.nodes.start.entities import StartNodeData
|
||||
|
||||
|
||||
class StartNode(BaseNode):
|
||||
_node_type = NodeType.START
|
||||
_node_data_cls = StartNodeData
|
||||
node_type = NodeType.START
|
||||
|
||||
def _run(self, variable_pool: Optional[VariablePool] = None,
|
||||
run_args: Optional[dict] = None) -> dict:
|
||||
|
||||
Reference in New Issue
Block a user