Implementation:Langgenius Dify Pipeline Graph Configuration
| Knowledge Sources | Dify |
|---|---|
| Domains | RAG, Pipeline, Frontend |
| Last Updated | 2026-02-12 00:00 GMT |
Overview
Description
Pipeline Graph Configuration documents the type system and data structures that define configurable parameters for RAG pipeline graph nodes in Dify. The core type is RAGPipelineVariable, which provides a schema-driven approach to declaring what inputs each node in the pipeline graph accepts. This type system bridges the backend's parameter definitions with the frontend's dynamic form rendering.
The implementation includes:
- RAGPipelineVariable -- The primary type defining a single configurable parameter within a pipeline node. Each variable specifies its owning node, input type, label, validation rules, and UI hints.
- PipelineInputVarType -- An enum of supported variable types that map to specific form field controls.
- VAR_TYPE_MAP -- A mapping from
PipelineInputVarTypetoBaseFieldType, translating backend variable types to frontend form field implementations. - ChunkingMode -- An enum defining the three supported document chunking strategies.
Usage
These types are used throughout the pipeline editor and configuration panels to:
- Define the shape of parameter responses from the processing and pre-processing parameter endpoints.
- Drive dynamic form generation in node configuration panels.
- Validate user inputs against the declared constraints (required, max_length, options).
- Associate parameters with their owning nodes in multi-node pipeline graphs.
Code Reference
Source Location
web/models/pipeline.ts, lines 116--172
Signature
export enum PipelineInputVarType {
textInput = 'text-input',
paragraph = 'paragraph',
select = 'select',
number = 'number',
singleFile = 'file',
multiFiles = 'file-list',
checkbox = 'checkbox',
}
export const VAR_TYPE_MAP: Record<PipelineInputVarType, BaseFieldType> = {
[PipelineInputVarType.textInput]: BaseFieldType.textInput,
[PipelineInputVarType.paragraph]: BaseFieldType.paragraph,
[PipelineInputVarType.select]: BaseFieldType.select,
[PipelineInputVarType.singleFile]: BaseFieldType.file,
[PipelineInputVarType.multiFiles]: BaseFieldType.fileList,
[PipelineInputVarType.number]: BaseFieldType.numberInput,
[PipelineInputVarType.checkbox]: BaseFieldType.checkbox,
}
export type RAGPipelineVariable = {
belong_to_node_id: string
type: PipelineInputVarType
label: string
variable: string
max_length?: number
default_value?: string
placeholder?: string
unit?: string
required: boolean
tooltips?: string
options?: string[]
allowed_file_upload_methods?: TransferMethod[]
allowed_file_types?: SupportUploadFileTypes[]
allowed_file_extensions?: string[]
}
export type InputVar = Omit<RAGPipelineVariable, 'belong_to_node_id'>
export type RAGPipelineVariables = RAGPipelineVariable[]
The ChunkingMode enum (defined in web/models/datasets.ts):
export enum ChunkingMode {
text = 'text_model', // General text chunking
qa = 'qa_model', // QA pair chunking
parentChild = 'hierarchical_model', // Parent-Child hierarchical chunking
}
Import
import type {
RAGPipelineVariable,
RAGPipelineVariables,
InputVar,
PipelineInputVarType,
} from '@/models/pipeline'
import { VAR_TYPE_MAP } from '@/models/pipeline'
import { ChunkingMode } from '@/models/datasets'
I/O Contract
RAGPipelineVariable Fields
| Field | Type | Required | Description |
|---|---|---|---|
| belong_to_node_id | string |
Yes | ID of the owning node, or 'shared' for pipeline-level variables
|
| type | PipelineInputVarType |
Yes | Input type: text-input, paragraph, select, number, file, file-list, or checkbox
|
| label | string |
Yes | Human-readable label for display |
| variable | string |
Yes | Machine-readable variable name used in API requests |
| max_length | number |
No | Maximum character length for text inputs |
| default_value | string |
No | Default value pre-populated in the form |
| placeholder | string |
No | Placeholder text for empty input fields |
| unit | string |
No | Unit label for numeric inputs (e.g., "tokens", "characters") |
| required | boolean |
Yes | Whether the parameter is mandatory |
| tooltips | string |
No | Help text shown on hover |
| options | string[] |
No | Available choices for select-type variables |
| allowed_file_upload_methods | TransferMethod[] |
No | Permitted file upload methods for file-type variables |
| allowed_file_types | SupportUploadFileTypes[] |
No | Allowed MIME types for file uploads |
| allowed_file_extensions | string[] |
No | Allowed file extensions for file uploads |
PipelineInputVarType to BaseFieldType Mapping
| PipelineInputVarType | BaseFieldType | Form Control |
|---|---|---|
text-input |
textInput |
Single-line text field |
paragraph |
paragraph |
Multi-line textarea |
select |
select |
Dropdown selector |
number |
numberInput |
Numeric input with optional unit |
file |
file |
Single file upload |
file-list |
fileList |
Multiple file upload |
checkbox |
checkbox |
Boolean checkbox |
Usage Examples
import type { RAGPipelineVariable } from '@/models/pipeline'
import { VAR_TYPE_MAP, PipelineInputVarType } from '@/models/pipeline'
import { BaseFieldType } from '@/app/components/base/form/form-scenarios/base/types'
// Map a pipeline variable to a form field type
function getFieldType(variable: RAGPipelineVariable): BaseFieldType {
return VAR_TYPE_MAP[variable.type]
}
// Render dynamic form fields from pipeline variables
function renderNodeConfig(variables: RAGPipelineVariable[], nodeId: string) {
const nodeVars = variables.filter(v => v.belong_to_node_id === nodeId)
return nodeVars.map(v => ({
fieldType: VAR_TYPE_MAP[v.type],
label: v.label,
name: v.variable,
required: v.required,
defaultValue: v.default_value,
placeholder: v.placeholder,
options: v.options,
maxLength: v.max_length,
}))
}
// Check chunking mode from a pipeline template
import { ChunkingMode } from '@/models/datasets'
function isHierarchicalChunking(mode: ChunkingMode): boolean {
return mode === ChunkingMode.parentChild
}