用途
Data Flow 是 MOOLLM 中用于构建处理流水线(processing pipeline)的一种模式。它的核心口号是:“Rooms are nodes. Exits are edges. Thrown objects are messages.”(房间是节点,出口是边,抛出的对象是消息。)其基本思路是把文件系统本身当作数据流网络,用房间和对象来组织处理流程。
主要能力
该模式将处理流程映射为以下结构:
- 房间(Rooms)是处理阶段,即节点(nodes)。
- 出口(Exits)连接各个阶段,即边(edges)。
- 对象(Objects)作为消息在流程中流动。
- THROW 通过出口发送对象。
- INBOX 接收传入的对象。
- OUTBOX 暂存待发出的对象。
使用方式
命令
| 命令 | 效果 |
|---|---|
| THROW obj exit | 通过出口将对象发送到目标位置 |
| INBOX | 列出等待处理的项目 |
| NEXT | 从收件箱取出下一个项目(FIFO) |
| PEEK | 查看下一个项目但不取出 |
| STAGE obj exit | 将对象加入发件箱,供稍后抛出 |
| FLUSH | 抛出所有已暂存的对象 |
| FLUSH exit | 抛出指定出口的已暂存对象 |
房间结构
stage/
├── ROOM.yml # Config and processor definition
├── inbox/ # Incoming queue (FIFO)
├── outbox/ # Staged for batch throwing
└── door-next/ # Exit to next stage
处理器类型
脚本(确定性):
processor:
type: script
command: "python parse.py ${input}"
LLM(语义):
processor:
type: llm
prompt: |
Analyze this document:
- Extract key entities
- Summarize in 3 sentences
混合:
processor:
type: hybrid
pre_process: "extract.py ${input}"
llm_prompt: "Analyze extracted data"
post_process: "format.py ${output}"
可以混合搭配:用 LLM 进行推理,用脚本进行转换。
示例流水线
uploads/ # Raw files land here
├── inbox/
│ ├── doc-001.pdf
│ └── doc-002.pdf
└── door-parser/
parser/ # Extract text
├── script: parse.py
└── door-analyzer/
analyzer/ # LLM analyzes
├── prompt: "Summarize..."
├── door-output/
└── door-errors/
output/ # Final results
└── inbox/
├── doc-001-summary.yml
└── doc-002-summary.yml
处理循环
> ENTER parser
Inbox: 2 items waiting.
> NEXT
Processing doc-001.pdf...
Text extracted.
> STAGE doc-001.txt door-analyzer
Staged.
> FLUSH
Throwing 2 items through door-analyzer...
扇出(一对多)
routing_rules:
- if: "priority == 'high'"
throw_to: door-fast-track
- if: "type == 'archive'"
throw_to: door-archive
- default: door-standard
扇入(多对一)
batch_size: 10
on_batch_complete: |
Combine all results
Generate summary report
THROW report.yml door-output
Kilroy 映射
| MOOLLM | Kilroy |
|---|---|
| Room | Node |
| Exit | Edge |
| THROW | Message passing |
| inbox/ | Input queue |
| Script processor | Deterministic module |
| LLM processor | LLM node |
适用场景
该模式适合用房间和对象来组织多阶段处理流程,例如文档解析、文本提取、LLM 分析、结果汇总等流水线任务。通过扇出和扇入规则,可以处理一对多路由和多对一批量合并等拓扑结构。
限制
资料中未提供关于性能、并发、错误处理、依赖环境或具体实现细节的更多说明。