Canvas Architecture#
RAGFlow supports two distinct canvas types — AgentCanvas and DataflowCanvas — that share the same DSL wire format and database table but differ in purpose, seed structure, component set, and model configuration behavior.
Canvas Type Enum#
The distinction is encoded in two enums:
-
Frontend —
AgentCategoryinweb/src/constants/agent.tsx:AgentCategory.AgentCanvas = 'agent_canvas'AgentCategory.DataflowCanvas = 'dataflow_canvas'
-
Backend —
CanvasCategoryinapi/db/__init__.py:CanvasCategory.Agent = "agent_canvas"CanvasCategory.DataFlow = "dataflow_canvas"
The canvas_category field on UserCanvas (database column, max_length=32, default="agent_canvas") stores this value and is indexed for efficient filtering. CanvasCategory.Agent is the default for new canvases created via the API.
Creation and DSL Initialization#
When a new canvas is created, useCreateAgentOrPipeline passes isAgent (derived from FlowType in the creation form) to initialEmptyDsl, which selects the appropriate seed:
| Canvas Type | Seed Object | Entry Node | Initial Components |
|---|---|---|---|
| AgentCanvas | EmptyDsl | begin (beginNode) | Begin component, empty globals with all sys.* keys |
| DataflowCanvas | DataflowEmptyDsl | File (beginNode) | File + Parser components connected by an edge |
The DataflowCanvas seed pre-wires a File→Parser edge and seeds initialParserValues into the Parser node's form data . The AgentCanvas seed initializes the full globals map (sys.query, sys.user_id, sys.conversation_turns, sys.files, sys.history, sys.date) ; the DataflowCanvas seed sets globals: {}.
Import detection: inferIsAgentFromImport detects canvas type from an uploaded DSL file by checking if graph nodes include both File and Parser operators (dataflow) — defaulting to agent if ambiguous.
DSL Structure (Shared Wire Format)#
Both canvas types use the same canonical DSL shape :
{
globals, graph: { nodes, edges }, // React-Flow layout surface
variables, components, // execution topology
path, retrieval, history
}
The frontend rebuilds components from graph on every save; the backend reads components only and ignores graph. The graph block is the single source of truth for import/export.
DSL transformations are handled by four functions in dsl-bridge.ts:
| Function | Direction |
|---|---|
initialEmptyDsl(isAgent) | Creates a blank seed DSL |
importDsl(raw, isAgent) | Uploaded JSON → renderable DSL |
dslToGraph(dsl) | Server DSL → React-Flow nodes/edges |
graphToDsl(nodes, edges, oldDsl) | React-Flow state → saveable DSL |
Component Set Differences#
The Operator enum defines all component types for both canvas types in a single enum. DataflowCanvas-specific operators are: File, Parser, Tokenizer, TokenChunker, TitleChunker, Extractor, Compilation . The pipeline operator form dispatcher PipelineOperatorForm routes to these dedicated forms (Parser, TokenChunker, TitleChunker, Extractor, Tokenizer) — it returns null for any unrecognized operator, so AgentCanvas-only operators don't render in the pipeline panel.
LLM Model Configuration#
AgentCanvas LLM configuration is set globally at the canvas level via initialLlmBaseValues :
temperature: 0.1, top_p: 0.3, frequency_penalty: 0.7, presence_penalty: 0.4, max_tokens: 256
DataflowCanvas pipeline components that require LLM access (e.g., Extractor) configure the model per-component. The Extractor form embeds LlmSettingSchema — a Zod schema combining llm_id, generation parameters, and enable/disable flags — directly into each node's form. The LargeModelFormField component renders the model picker with a filter dropdown that scopes the model list to all, Chat, or Image2text types.
initialExtractorValues spreads initialLlmBaseValues and adds field_name: 'summary', auto_keywords: 0, auto_questions: 0 as pipeline-specific defaults.
Key Source Files#
| File | Role |
|---|---|
web/src/constants/agent.tsx | AgentCategory enum, EmptyDsl, Operator enum, initialLlmBaseValues |
web/src/pages/agents/constant.ts | FlowType enum (Agent / Flow) used in the creation form |
web/src/pages/agent/empty-dsl.ts | DataflowEmptyDsl seed |
web/src/pages/agent/utils/dsl-bridge.ts | DSL ↔ graph conversion, import/export, type detection |
web/src/pages/agents/hooks/use-create-agent.ts | Creation hook wiring FlowType → canvas_category + seed DSL |
web/src/components/pipeline-operator-tabs/pipeline-operator-form.tsx | Pipeline component form dispatcher |
web/src/pages/agent/form/extractor-form/index.tsx | Example pipeline component with per-node LLM selection |
web/src/components/large-model-form-field.tsx | Shared LLM model picker used in pipeline component forms |
web/src/pages/agent/constant/pipeline.tsx | Pipeline component initial values and enums |
api/db/__init__.py | Backend CanvasCategory enum |