feat(workflow): add support for notes nodes
This commit is contained in:
@@ -8,34 +8,59 @@ from typing import Any
|
|||||||
from urllib.parse import quote
|
from urllib.parse import quote
|
||||||
|
|
||||||
from app.core.workflow.adapters.base_converter import BaseConverter
|
from app.core.workflow.adapters.base_converter import BaseConverter
|
||||||
from app.core.workflow.adapters.errors import UnsupportVariableType, UnknowModelWarning, ExceptionDefineition, \
|
from app.core.workflow.adapters.errors import (
|
||||||
|
UnsupportVariableType,
|
||||||
|
UnknowModelWarning,
|
||||||
|
ExceptionDefineition,
|
||||||
ExceptionType
|
ExceptionType
|
||||||
from app.core.workflow.nodes.assigner import AssignerNodeConfig
|
)
|
||||||
from app.core.workflow.nodes.assigner.config import AssignmentItem
|
from app.core.workflow.nodes.assigner.config import AssignmentItem
|
||||||
from app.core.workflow.nodes.base_config import VariableDefinition, BaseNodeConfig
|
from app.core.workflow.nodes.base_config import VariableDefinition, BaseNodeConfig
|
||||||
from app.core.workflow.nodes.code import CodeNodeConfig
|
|
||||||
from app.core.workflow.nodes.code.config import InputVariable, OutputVariable
|
from app.core.workflow.nodes.code.config import InputVariable, OutputVariable
|
||||||
from app.core.workflow.nodes.configs import StartNodeConfig, LLMNodeConfig
|
from app.core.workflow.nodes.configs import (
|
||||||
from app.core.workflow.nodes.cycle_graph import LoopNodeConfig, IterationNodeConfig
|
StartNodeConfig,
|
||||||
from app.core.workflow.nodes.cycle_graph.config import ConditionDetail as LoopConditionDetail, ConditionsConfig, \
|
LLMNodeConfig,
|
||||||
|
AssignerNodeConfig,
|
||||||
|
CodeNodeConfig,
|
||||||
|
LoopNodeConfig,
|
||||||
|
IterationNodeConfig,
|
||||||
|
EndNodeConfig,
|
||||||
|
HttpRequestNodeConfig,
|
||||||
|
IfElseNodeConfig,
|
||||||
|
JinjaRenderNodeConfig,
|
||||||
|
KnowledgeRetrievalNodeConfig,
|
||||||
|
NoteNodeConfig,
|
||||||
|
ParameterExtractorNodeConfig,
|
||||||
|
QuestionClassifierNodeConfig,
|
||||||
|
VariableAggregatorNodeConfig
|
||||||
|
)
|
||||||
|
from app.core.workflow.nodes.cycle_graph.config import (
|
||||||
|
ConditionDetail as LoopConditionDetail,
|
||||||
|
ConditionsConfig,
|
||||||
CycleVariable
|
CycleVariable
|
||||||
from app.core.workflow.nodes.end import EndNodeConfig
|
)
|
||||||
from app.core.workflow.nodes.enums import ValueInputType, ComparisonOperator, AssignmentOperator, HttpAuthType, \
|
from app.core.workflow.nodes.enums import (
|
||||||
HttpContentType, HttpErrorHandle
|
ValueInputType,
|
||||||
from app.core.workflow.nodes.http_request import HttpRequestNodeConfig
|
ComparisonOperator,
|
||||||
from app.core.workflow.nodes.http_request.config import HttpAuthConfig, HttpContentTypeConfig, HttpFormData, \
|
AssignmentOperator,
|
||||||
HttpTimeOutConfig, HttpRetryConfig, HttpErrorDefaultTamplete, HttpErrorHandleConfig
|
HttpAuthType,
|
||||||
from app.core.workflow.nodes.if_else import IfElseNodeConfig
|
HttpContentType,
|
||||||
|
HttpErrorHandle
|
||||||
|
)
|
||||||
|
from app.core.workflow.nodes.http_request.config import (
|
||||||
|
HttpAuthConfig,
|
||||||
|
HttpContentTypeConfig,
|
||||||
|
HttpFormData,
|
||||||
|
HttpTimeOutConfig,
|
||||||
|
HttpRetryConfig,
|
||||||
|
HttpErrorDefaultTamplete,
|
||||||
|
HttpErrorHandleConfig
|
||||||
|
)
|
||||||
from app.core.workflow.nodes.if_else.config import ConditionDetail, ConditionBranchConfig
|
from app.core.workflow.nodes.if_else.config import ConditionDetail, ConditionBranchConfig
|
||||||
from app.core.workflow.nodes.jinja_render import JinjaRenderNodeConfig
|
|
||||||
from app.core.workflow.nodes.jinja_render.config import VariablesMappingConfig
|
from app.core.workflow.nodes.jinja_render.config import VariablesMappingConfig
|
||||||
from app.core.workflow.nodes.knowledge import KnowledgeRetrievalNodeConfig
|
|
||||||
from app.core.workflow.nodes.llm.config import MemoryWindowSetting, MessageConfig
|
from app.core.workflow.nodes.llm.config import MemoryWindowSetting, MessageConfig
|
||||||
from app.core.workflow.nodes.parameter_extractor import ParameterExtractorNodeConfig
|
|
||||||
from app.core.workflow.nodes.parameter_extractor.config import ParamsConfig
|
from app.core.workflow.nodes.parameter_extractor.config import ParamsConfig
|
||||||
from app.core.workflow.nodes.question_classifier import QuestionClassifierNodeConfig
|
|
||||||
from app.core.workflow.nodes.question_classifier.config import ClassifierConfig
|
from app.core.workflow.nodes.question_classifier.config import ClassifierConfig
|
||||||
from app.core.workflow.nodes.variable_aggregator import VariableAggregatorNodeConfig
|
|
||||||
from app.core.workflow.variable.base_variable import VariableType, DEFAULT_VALUE
|
from app.core.workflow.variable.base_variable import VariableType, DEFAULT_VALUE
|
||||||
|
|
||||||
|
|
||||||
@@ -63,6 +88,7 @@ class DifyConverter(BaseConverter):
|
|||||||
"question-classifier": self.convert_question_classifier_node_config,
|
"question-classifier": self.convert_question_classifier_node_config,
|
||||||
"variable-aggregator": self.convert_variable_aggregator_node_config,
|
"variable-aggregator": self.convert_variable_aggregator_node_config,
|
||||||
"tool": self.convert_tool_node_config,
|
"tool": self.convert_tool_node_config,
|
||||||
|
"": self.convert_notes_config,
|
||||||
"loop-start": lambda x: {},
|
"loop-start": lambda x: {},
|
||||||
"iteration-start": lambda x: {},
|
"iteration-start": lambda x: {},
|
||||||
"loop-end": lambda x: {},
|
"loop-end": lambda x: {},
|
||||||
@@ -732,3 +758,12 @@ class DifyConverter(BaseConverter):
|
|||||||
detail=f"Please reconfigure the tool node.",
|
detail=f"Please reconfigure the tool node.",
|
||||||
))
|
))
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def convert_notes_config(node: dict):
|
||||||
|
node_data = node["data"]
|
||||||
|
result = NoteNodeConfig.model_construct(
|
||||||
|
author=node_data.get("author", ""),
|
||||||
|
text=node_data.get("text", "")
|
||||||
|
).model_dump()
|
||||||
|
return result
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ class DifyAdapter(BasePlatformAdapter, DifyConverter):
|
|||||||
type=ExceptionType.NODE,
|
type=ExceptionType.NODE,
|
||||||
node_id=node["id"],
|
node_id=node["id"],
|
||||||
node_name=node["data"]["title"],
|
node_name=node["data"]["title"],
|
||||||
detail=f"node type {node_type if node_type else 'notes'} is unsupported",
|
detail=f"node type {node_type} is unsupported",
|
||||||
))
|
))
|
||||||
return converter(node)
|
return converter(node)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ from app.core.workflow.nodes.question_classifier.config import QuestionClassifie
|
|||||||
from app.core.workflow.nodes.start.config import StartNodeConfig
|
from app.core.workflow.nodes.start.config import StartNodeConfig
|
||||||
from app.core.workflow.nodes.tool.config import ToolNodeConfig
|
from app.core.workflow.nodes.tool.config import ToolNodeConfig
|
||||||
from app.core.workflow.nodes.variable_aggregator.config import VariableAggregatorNodeConfig
|
from app.core.workflow.nodes.variable_aggregator.config import VariableAggregatorNodeConfig
|
||||||
|
from app.core.workflow.nodes.notes.config import NoteNodeConfig
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
# 基础类
|
# 基础类
|
||||||
@@ -47,5 +48,6 @@ __all__ = [
|
|||||||
"ToolNodeConfig",
|
"ToolNodeConfig",
|
||||||
"MemoryReadNodeConfig",
|
"MemoryReadNodeConfig",
|
||||||
"MemoryWriteNodeConfig",
|
"MemoryWriteNodeConfig",
|
||||||
"CodeNodeConfig"
|
"CodeNodeConfig",
|
||||||
|
"NoteNodeConfig"
|
||||||
]
|
]
|
||||||
|
|||||||
0
api/app/core/workflow/nodes/notes/__init__.py
Normal file
0
api/app/core/workflow/nodes/notes/__init__.py
Normal file
8
api/app/core/workflow/nodes/notes/config.py
Normal file
8
api/app/core/workflow/nodes/notes/config.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
from pydantic import Field
|
||||||
|
|
||||||
|
from app.core.workflow.nodes.base_config import BaseNodeConfig
|
||||||
|
|
||||||
|
|
||||||
|
class NoteNodeConfig(BaseNodeConfig):
|
||||||
|
author: str = Field(..., description="author")
|
||||||
|
text: str = Field(..., description="note context")
|
||||||
Reference in New Issue
Block a user