Skip to content

Commit 2006d7f

Browse files
committed
feat(lite): add FlowLLM Lite CLI runner with BaseFlow and BaseConfig
- Introduce flowllm.lite module with BaseConfig and BaseFlow classes - Add CLI interface with 'fl' command for lightweight flow execution - Implement flow registration system with @register decorator - Create demo flow example showing config-driven execution - Add comprehensive README documentation for FlowLLM Lite usage - Register 'fl' command in pyproject.toml with claude-agent-sdk dependency - Remove unused file I/O constants from flowllm/constants.py - Update main README with minimal CLI flow section and improved formatting
1 parent ca41cf2 commit 2006d7f

8 files changed

Lines changed: 345 additions & 75 deletions

File tree

README.md

Lines changed: 48 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,29 @@
1818
<strong>FlowLLM: Build LLM applications with ease.</strong><br>
1919
</p>
2020

21-
FlowLLM is a configuration-driven LLM application framework that organizes workflows, service entrypoints, and long-lived components with **Service, Job, Step, and Component**.
21+
FlowLLM is a configuration-driven LLM application framework that organizes workflows, service entrypoints, and
22+
long-lived components with **Service, Job, Step, and Component**.
2223

23-
## Core Features
24+
## Core Features
2425

2526
- **Configuration-driven**: Starts from `flowllm/config/default.yaml`, with config files and dot-notation overrides.
2627
- **Unified path**: `CLI / Client -> Service -> Application -> Job -> Step -> Component`.
2728
- **Flexible Jobs**: Supports sync, streaming, background, and scheduled tasks exposed through HTTP or MCP.
28-
- **Pluggable components**: Extend Steps, Services, Clients, LLMs, Embeddings, Embedding Stores, and Agent Wrappers through registry `R`.
29+
- **Pluggable components**: Extend Steps, Services, Clients, LLMs, Embeddings, Embedding Stores, and Agent Wrappers
30+
through registry `R`.
31+
32+
## 🆕 Minimal CLI Flow
33+
34+
FlowLLM also includes `flowllm.lite`, a tiny local CLI flow runner for scripts that do not need the full service
35+
framework.
36+
It maps `fl --action --field value` to a Pydantic config and a small ordered `BaseFlow`.
37+
See [FlowLLM Lite](flowllm/lite/README.md) for the full minimal CLI flow design.
2938

3039
<p align="center">
3140
<img src="docs/figure/flowllm-architecture.svg" alt="FlowLLM Architecture" width="92%">
3241
</p>
3342

34-
## Quick Start
43+
## 🚀 Quick Start
3544

3645
### Installation
3746

@@ -63,7 +72,8 @@ pip install -e ".[full]"
6372
flowllm start
6473
```
6574

66-
The default service address is `127.0.0.1:2333`, and the default workspace is `.flowllm/`. Startup automatically creates:
75+
The default service address is `127.0.0.1:2333`, and the default workspace is `.flowllm/`. Startup automatically
76+
creates:
6777

6878
```text
6979
.flowllm/
@@ -80,7 +90,7 @@ flowllm start workspace_dir=/tmp/flowllm-demo service.host=127.0.0.1 service.por
8090

8191
See the [Quick Start](docs/en/quick_start.md) for more startup and invocation examples.
8292

83-
## Calling Jobs
93+
## 🧩 Calling Jobs
8494

8595
After the service starts, CLI commands other than `start` call server-side Jobs with the same name through the client:
8696

@@ -112,18 +122,19 @@ curl -N http://127.0.0.1:2333/stream_demo \
112122

113123
Built-in Jobs:
114124

115-
| Job | Backend | Description |
116-
| --- | --- | --- |
117-
| `version` | `base` | Returns the FlowLLM package version. |
118-
| `health_check` | `base` | Returns a component health-check summary. |
119-
| `help` | `base` | Lists registered Jobs and their metadata. |
120-
| `demo` | `base` | Two-step echo example. |
121-
| `add` | `base` | Adds two numbers. |
122-
| `stream_demo` | `stream` | Streams the input text character by character. |
125+
| Job | Backend | Description |
126+
|----------------|----------|------------------------------------------------|
127+
| `version` | `base` | Returns the FlowLLM package version. |
128+
| `health_check` | `base` | Returns a component health-check summary. |
129+
| `help` | `base` | Lists registered Jobs and their metadata. |
130+
| `demo` | `base` | Two-step echo example. |
131+
| `add` | `base` | Adds two numbers. |
132+
| `stream_demo` | `stream` | Streams the input text character by character. |
123133

124-
## Configuration
134+
## ⚙️ Configuration
125135

126-
The default configuration is located at `flowllm/config/default.yaml`. Root configuration sections include application parameters, service, Jobs, and Components:
136+
The default configuration is located at `flowllm/config/default.yaml`. Root configuration sections include application
137+
parameters, service, Jobs, and Components:
127138

128139
```yaml
129140
service:
@@ -159,24 +170,25 @@ You can also specify a YAML or JSON configuration file:
159170
flowllm start config=/path/to/app.yaml
160171
```
161172

162-
Configuration parsing supports `${VAR}`, `${VAR:-default}`, booleans, numbers, JSON lists and dictionaries, and automatic `null` conversion.
173+
Configuration parsing supports `${VAR}`, `${VAR:-default}`, booleans, numbers, JSON lists and dictionaries, and
174+
automatic `null` conversion.
163175

164-
## Code Framework
176+
## 🏗️ Code Framework
165177

166178
FlowLLM's core layering is:
167179

168180
```text
169181
CLI / Client -> Service -> Application -> Job -> Step -> Component
170182
```
171183

172-
| Layer | Role |
173-
| --- | --- |
184+
| Layer | Role |
185+
|---------------|---------------------------------------------------------------------------------------------------------------------------------|
174186
| `Application` | Loads configuration, creates the workspace, assembles Service, Components, and Jobs, and starts lifecycles in dependency order. |
175-
| `Service` | Exposes servable Jobs as HTTP routes or MCP tools. |
176-
| `Job` | Orchestrates externally callable capabilities or background processes by executing Steps in order. |
177-
| `Step` | Atomic workflow operation that reads and writes `RuntimeContext`, `Response`, and streaming queues. |
178-
| `Component` | Long-lived infrastructure such as LLMs, Embeddings, Embedding Stores, and Agent Wrappers. |
179-
| `Registry` | Global registry `R`, which looks up implementations by `(component_type, backend_name)`. |
187+
| `Service` | Exposes servable Jobs as HTTP routes or MCP tools. |
188+
| `Job` | Orchestrates externally callable capabilities or background processes by executing Steps in order. |
189+
| `Step` | Atomic workflow operation that reads and writes `RuntimeContext`, `Response`, and streaming queues. |
190+
| `Component` | Long-lived infrastructure such as LLMs, Embeddings, Embedding Stores, and Agent Wrappers. |
191+
| `Registry` | Global registry `R`, which looks up implementations by `(component_type, backend_name)`. |
180192

181193
Minimal example for adding a Step:
182194

@@ -211,11 +223,13 @@ jobs:
211223
- backend: reverse_step
212224
```
213225

214-
After adding an implementation, make sure the module is imported in the package `__init__.py`; otherwise, the registration decorator will not run. See the [code framework](docs/en/framework.md) for details.
226+
After adding an implementation, make sure the module is imported in the package `__init__.py`; otherwise, the
227+
registration decorator will not run. See the [code framework](docs/en/framework.md) for details.
215228

216-
## MCP Service
229+
## 🔌 MCP Service
217230

218-
When the service backend is set to `mcp`, FlowLLM exposes non-streaming Jobs with `enable_serve: true` as MCP tools. `StreamJob` is not exposed by MCP Service.
231+
When the service backend is set to `mcp`, FlowLLM exposes non-streaming Jobs with `enable_serve: true` as MCP tools.
232+
`StreamJob` is not exposed by MCP Service.
219233

220234
```yaml
221235
service:
@@ -227,26 +241,27 @@ service:
227241

228242
MCP transport supports `stdio`, `sse`, and `streamable-http`.
229243

230-
## Documentation
244+
## 📚 Documentation
231245

232246
- [Quick Start](docs/en/quick_start.md)
233247
- [Code Framework](docs/en/framework.md)
234248
- [Contributing](docs/en/contributing.md)
235249
- [FlowLLM Development Skill](skills/flowllm_dev/SKILL.md)
236250

237-
## Open Source and Contributing
251+
## 🤝 Open Source and Contributing
238252

239-
FlowLLM is licensed under Apache 2.0. Before contributing, read the [contribution guide](docs/en/contributing.md) and [development skill](skills/flowllm_dev/SKILL.md), then run:
253+
FlowLLM is licensed under Apache 2.0. Before contributing, read the [contribution guide](docs/en/contributing.md)
254+
and [development skill](skills/flowllm_dev/SKILL.md), then run:
240255

241256
```bash
242257
pre-commit run --all-files
243258
pytest
244259
```
245260

246-
## License
261+
## 📄 License
247262

248263
This project is open source under the Apache License 2.0. See [LICENSE](./LICENSE) for details.
249264

250-
## Star History
265+
## Star History
251266

252267
[![Star History Chart](https://api.star-history.com/svg?repos=flowllm-ai/flowllm&type=Date)](https://www.star-history.com/#flowllm-ai/flowllm&Date)

README_ZH.md

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,24 @@
2020

2121
FlowLLM 是一个配置驱动的 LLM 应用框架,用 **Service、Job、Step、Component** 组织工作流、服务入口和长期组件。
2222

23-
## 核心特性
23+
## 核心特性
2424

2525
- **配置驱动**:默认从 `flowllm/config/default.yaml` 启动,支持配置文件和 dot notation 覆盖。
2626
- **统一链路**`CLI / Client -> Service -> Application -> Job -> Step -> Component`
2727
- **多种 Job 形态**:支持同步、流式、后台和定时任务,并可通过 HTTP 或 MCP 暴露。
2828
- **可插拔组件**:通过注册表 `R` 扩展 Step、Service、Client、LLM、Embedding、Embedding Store 和 Agent Wrapper。
2929

30+
## 🆕 极简 CLI Flow
31+
32+
FlowLLM 也包含 `flowllm.lite`,这是一个极简的本地 CLI flow 运行器,适合不需要完整服务框架的脚本场景。
33+
它把 `fl --action --field value` 映射到 Pydantic config 和一个顺序执行的 `BaseFlow`
34+
完整设计见 [FlowLLM Lite](flowllm/lite/README.md)
35+
3036
<p align="center">
3137
<img src="docs/figure/flowllm-architecture.svg" alt="FlowLLM Architecture" width="92%">
3238
</p>
3339

34-
## 快速开始
40+
## 🚀 快速开始
3541

3642
### 安装
3743

@@ -80,7 +86,7 @@ flowllm start workspace_dir=/tmp/flowllm-demo service.host=127.0.0.1 service.por
8086

8187
更多启动和调用示例见 [快速开始](docs/zh/quick_start.md)
8288

83-
## 调用 Job
89+
## 🧩 调用 Job
8490

8591
启动服务后,CLI 的非 `start` 命令会通过 client 调用服务端同名 Job:
8692

@@ -112,16 +118,16 @@ curl -N http://127.0.0.1:2333/stream_demo \
112118

113119
内置 Job:
114120

115-
| Job | backend | 说明 |
116-
| --- | --- | --- |
117-
| `version` | `base` | 返回 FlowLLM 包版本。 |
118-
| `health_check` | `base` | 返回组件健康检查摘要。 |
119-
| `help` | `base` | 列出已注册 Job 及其 metadata。 |
120-
| `demo` | `base` | 两步 echo 示例。 |
121-
| `add` | `base` | 两数相加示例。 |
122-
| `stream_demo` | `stream` | 将输入按字符流式输出。 |
121+
| Job | backend | 说明 |
122+
|----------------|----------|------------------------|
123+
| `version` | `base` | 返回 FlowLLM 包版本。 |
124+
| `health_check` | `base` | 返回组件健康检查摘要。 |
125+
| `help` | `base` | 列出已注册 Job 及其 metadata。 |
126+
| `demo` | `base` | 两步 echo 示例。 |
127+
| `add` | `base` | 两数相加示例。 |
128+
| `stream_demo` | `stream` | 将输入按字符流式输出。 |
123129

124-
## 配置
130+
## ⚙️ 配置
125131

126132
默认配置位于 `flowllm/config/default.yaml`。配置根节点包括应用参数、服务、Job 和 Component:
127133

@@ -161,22 +167,22 @@ flowllm start config=/path/to/app.yaml
161167

162168
配置解析支持 `${VAR}`、`${VAR:-default}`、bool、数字、JSON list/dict 和 `null` 自动转换。
163169

164-
## 代码框架
170+
## 🏗️ 代码框架
165171

166172
FlowLLM 的核心分层如下:
167173

168174
```text
169175
CLI / Client -> Service -> Application -> Job -> Step -> Component
170176
```
171177

172-
| 层级 | 作用 |
173-
| --- | --- |
178+
| 层级 | 作用 |
179+
|---------------|------------------------------------------------------------|
174180
| `Application` | 加载配置,创建 workspace,装配 Service、Component 和 Job,并按依赖顺序启动生命周期。 |
175-
| `Service` | 将可服务的 Job 暴露为 HTTP 路由或 MCP 工具。 |
176-
| `Job` | 外部可调用能力或后台流程的编排单元,按顺序执行 Step。 |
177-
| `Step` | 工作流原子操作,读写 `RuntimeContext`、`Response` 和流式队列。 |
178-
| `Component` | 长期存在的基础设施,例如 LLM、Embedding、Embedding Store、Agent Wrapper。 |
179-
| `Registry` | 全局注册表 `R`,按 `(component_type, backend_name)` 查找实现。 |
181+
| `Service` | 将可服务的 Job 暴露为 HTTP 路由或 MCP 工具。 |
182+
| `Job` | 外部可调用能力或后台流程的编排单元,按顺序执行 Step。 |
183+
| `Step` | 工作流原子操作,读写 `RuntimeContext`、`Response` 和流式队列。 |
184+
| `Component` | 长期存在的基础设施,例如 LLM、Embedding、Embedding Store、Agent Wrapper。 |
185+
| `Registry` | 全局注册表 `R`,按 `(component_type, backend_name)` 查找实现。 |
180186

181187
新增 Step 的最小示例:
182188

@@ -213,9 +219,10 @@ jobs:
213219

214220
新增实现后要确保模块在包的 `__init__.py` 中被 import,否则注册装饰器不会执行。更多细节见 [代码框架](docs/zh/framework.md)。
215221

216-
## MCP 服务
222+
## 🔌 MCP 服务
217223

218-
将 service backend 改成 `mcp` 后,FlowLLM 会把非流式、`enable_serve: true` 的 Job 暴露为 MCP tool。`StreamJob` 不会被 MCP Service 暴露。
224+
将 service backend 改成 `mcp` 后,FlowLLM 会把非流式、`enable_serve: true` 的 Job 暴露为 MCP tool。`StreamJob` 不会被 MCP
225+
Service 暴露。
219226

220227
```yaml
221228
service:
@@ -227,26 +234,27 @@ service:
227234

228235
MCP transport 支持 `stdio`、`sse` 和 `streamable-http`。
229236

230-
## 文档
237+
## 📚 文档
231238

232239
- [快速开始](docs/zh/quick_start.md)
233240
- [代码框架](docs/zh/framework.md)
234241
- [开源与贡献](docs/zh/contributing.md)
235242
- [FlowLLM 开发 Skill](skills/flowllm_dev/SKILL.md)
236243

237-
## 开源与贡献
244+
## 🤝 开源与贡献
238245

239-
FlowLLM 使用 Apache 2.0 许可证。贡献前请阅读 [贡献指南](docs/zh/contributing.md) 和 [开发 Skill](skills/flowllm_dev/SKILL.md),并尽量运行:
246+
FlowLLM 使用 Apache 2.0 许可证。贡献前请阅读 [贡献指南](docs/zh/contributing.md)
247+
和 [开发 Skill](skills/flowllm_dev/SKILL.md),并尽量运行:
240248

241249
```bash
242250
pre-commit run --all-files
243251
pytest
244252
```
245253

246-
## License
254+
## 📄 License
247255

248256
This project is open source under the Apache License 2.0. See [LICENSE](./LICENSE) for details.
249257

250-
## Star 历史
258+
## Star 历史
251259

252260
[![Star History Chart](https://api.star-history.com/svg?repos=flowllm-ai/flowllm&type=Date)](https://www.star-history.com/#flowllm-ai/flowllm&Date)

flowllm/constants.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,3 @@
55
FLOWLLM_DEFAULT_HOST = "127.0.0.1"
66

77
FLOWLLM_DEFAULT_PORT = 2333
8-
9-
# File IO limits and truncation marker.
10-
DEFAULT_MAX_BYTES = 50 * 1024
11-
MAX_FILE_READ_BYTES = 200 * 1024 * 1024
12-
TRUNCATION_NOTICE_MARKER = "<<TRUNCATION_NOTICE>>"
13-
14-
# Oversized images return path & metadata only (no base64).
15-
DEFAULT_MAX_IMAGE_BYTES = 5 * 1024 * 1024

flowllm/lite/README.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# FlowLLM Lite
2+
3+
`flowllm.lite` is a tiny local CLI flow runner. It is intentionally separate from the full FlowLLM application framework.
4+
5+
It keeps only four concepts:
6+
7+
- `BaseConfig`: define input parameters with Pydantic.
8+
- `BaseFlow`: hold `config` and `context`, then execute steps in order.
9+
- `register`: bind an action name to a flow class.
10+
- `fl`: read an action and CLI arguments, run the flow, and print JSON output.
11+
12+
## Usage
13+
14+
```shell
15+
fl --list
16+
fl --demo --x 1 --y 2
17+
```
18+
19+
Output:
20+
21+
```json
22+
{"result": 3}
23+
```
24+
25+
The command format is:
26+
27+
```shell
28+
fl --action --field value --another-field value
29+
```
30+
31+
Rules:
32+
33+
- The first argument is the action and must look like `--action`.
34+
- The remaining arguments must appear in pairs: `--field value`.
35+
- `-` in CLI argument names is converted to `_` in Python field names.
36+
- Values are read as strings first, then converted by Pydantic through `BaseConfig`.
37+
- The final result only includes fields declared in `output_keys`.
38+
39+
## Writing a Flow
40+
41+
```python
42+
from flowllm.lite import BaseConfig, BaseFlow, register
43+
44+
45+
class AddConfig(BaseConfig):
46+
x: int
47+
y: int
48+
49+
50+
@register("add")
51+
class AddFlow(BaseFlow[AddConfig]):
52+
output_keys = ["result"]
53+
54+
def build_steps(self):
55+
return [self.add]
56+
57+
def add(self):
58+
self.context["result"] = self.config.x + self.config.y
59+
```
60+
61+
Run it:
62+
63+
```shell
64+
fl --add --x 1 --y 2
65+
```
66+
67+
## Design Constraints
68+
69+
Lite flow is designed to be direct to read and easy to change:
70+
71+
- One flow class maps to one action.
72+
- One step is a zero-argument method that reads from `self.config`.
73+
- Steps pass intermediate values through `self.context`.
74+
- `build_steps()` declares execution order explicitly.
75+
- `output_keys` declares final output explicitly.
76+
77+
This implementation does not handle service startup, remote calls, plugin orchestration, complex dependency injection, or streaming protocols. Use the full FlowLLM framework when those capabilities are needed.

0 commit comments

Comments
 (0)