Implementation:1Panel dev MaxKB get node
| Knowledge Sources | |
|---|---|
| Domains | Workflow, Design_Patterns |
| Last Updated | 2026-10-10 00:00 GMT |
Overview
Concrete factory function that instantiates the correct workflow node class by type and workflow mode, provided by MaxKB.
Description
The get_node function is the central factory for node instantiation in the flow engine. It looks up the node type (e.g., `ai-chat-node`, `search-dataset-node`, `condition-node`) and workflow mode (e.g., `application`, `knowledge`, `tool`) in the node_map registry, which is built at import time from the node_list of all registered BaseXxxNode classes. Each node class declares its `type` and `support` (list of workflow modes) attributes. The factory returns the class (not an instance); callers construct it with the graph node, workflow params, and the parent WorkflowManage.
Usage
Import this function when you need to:
- Instantiate a workflow node by its type string
- Look up which node class handles a given type/mode combination
Code Reference
Source Location
- Repository: MaxKB
- File: apps/application/flow/step_node/__init__.py
Signature
node_list = [
BaseStartStepNode, BaseChatNode, BaseSearchKnowledgeNode,
BaseSearchDocumentNode, BaseQuestionNode, BaseConditionNode,
BaseReplyNode, BaseToolNodeNode, BaseToolLibNodeNode,
BaseRerankerNode, BaseApplicationNode, BaseDocumentExtractNode,
BaseImageUnderstandNode, BaseFormNode, BaseSpeechToTextNode,
BaseTextToSpeechNode, BaseImageGenerateNode, BaseVariableAssignNode,
BaseMcpNode, BaseTextToVideoNode, BaseImageToVideoNode,
BaseVideoUnderstandNode, BaseIntentNode, BaseLoopNode,
BaseLoopStartStepNode, BaseLoopContinueNode, BaseLoopBreakNode,
BaseVariableSplittingNode, BaseParameterExtractionNode,
BaseVariableAggregationNode, BaseDataSourceLocalNode,
BaseDataSourceWebNode, BaseKnowledgeWriteNode, BaseDocumentSplitNode,
BaseToolStartStepNode, BaseToolWorkflowLibNodeNode,
]
node_map = {n.type: {w: n for w in n.support} for n in node_list}
def get_node(node_type: str, workflow_model: str) -> Type[INode]:
"""Return the node class for the given type and workflow mode."""
Import
from application.flow.step_node import get_node
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| node_type | str | Yes | Node type string (e.g., 'ai-chat-node', 'search-dataset-node') |
| workflow_model | str | Yes | Workflow mode string (e.g., 'application', 'knowledge', 'tool') |
Outputs
| Name | Type | Description |
|---|---|---|
| returns | Type[INode] | The node class; caller instantiates with (node, params, workflow_manage) |
Usage Examples
Instantiating a Node
from application.flow.step_node import get_node
# Get the class for an AI chat node in application mode
node_class = get_node('ai-chat-node', 'application')
# Instantiate with graph node, workflow params, and parent engine
node_instance = node_class(graph_node, workflow_params, workflow_manage)