Principle:1Panel dev MaxKB Linear Pipeline Execution
| Knowledge Sources | |
|---|---|
| Domains | Chat_Pipeline, Design_Patterns |
| Last Updated | 2026-10-10 00:00 GMT |
Overview
A sequential execution pattern that processes chat requests through an ordered chain of steps, with each step reading from and writing to a shared context dictionary.
Description
Linear Pipeline Execution is MaxKB's original chat processing architecture (supplemented by the newer flow-based WorkflowManage). The PipelineManage class assembles step classes via a fluent builder pattern and executes them in order. Each step implements the IBaseChatPipelineStep interface with an `execute()` method and a `run()` wrapper that provides the pipeline context. The pipeline for RAG chat consists of four steps:
- ResetProblemStep — Optimizes the user question using an LLM
- SearchDatasetStep — Searches knowledge bases for relevant paragraphs
- GenerateHumanMessageStep — Builds the LLM message list with knowledge context
- ChatStep — Invokes the LLM with streaming and delivers the response
A shared `context` dict carries data between steps (question, paragraphs, message list, tokens).
Usage
Use this principle when designing:
- Sequential chat processing pipelines
- Builder-pattern-based pipeline assembly
- Step-based request processing with shared context
Theoretical Basis
The pipeline pattern follows Chain of Responsibility with ordered steps:
# Abstract algorithm description (NOT real implementation)
class Pipeline:
def __init__(self, steps):
self.steps = [step() for step in steps] # Instantiate classes
self.context = {}
def run(self, initial_context):
self.context.update(initial_context)
for step in self.steps:
step.run(self) # Step reads/writes self.context
# Builder for fluent assembly:
pipeline = (Pipeline.builder()
.append_step(ResetProblemStep)
.append_step(SearchDatasetStep)
.append_step(GenerateHumanMessageStep)
.append_step(ChatStep)
.build())
pipeline.run(context)