3.1 KiB
3.1 KiB
| layout | title | nav_order |
|---|---|---|
| default | Home | 1 |
Pocket Flow
A 100-line minimalist LLM framework for Agents, Task Decomposition, RAG, etc.
- Lightweight: Just the core graph abstraction in 100 lines. ZERO dependencies, and vendor lock-in.
- Expressive: Everything you love from larger frameworks—(Multi-)Agents, Workflow, RAG, and more.
- Agentic-Coding: Intuitive enough for AI agents to help humans build complex LLM applications.
Core Abstraction
We model the LLM workflow as a Graph + Shared Store:
- Node handles simple (LLM) tasks.
- Flow connects nodes through Actions (labeled edges).
- Shared Store enables communication between nodes within flows.
- Batch nodes/flows allow for data-intensive tasks.
- Async nodes/flows allow waiting for asynchronous tasks.
- (Advanced) Parallel nodes/flows handle I/O-bound tasks.
Design Pattern
From there, it’s easy to implement popular design patterns:
- Agent autonomously makes decisions.
- Workflow chains multiple tasks into pipelines.
- RAG integrates data retrieval with generation.
- Map Reduce splits data tasks into Map and Reduce steps.
- Structured Output formats outputs consistently.
- (Advanced) Multi-Agents coordinate multiple agents.
Utility Function
We DON'T provide built-in utility functions. Instead, please implement your own. I believe it is a bad practice to provide vendor-specific implementations in a general framework:
- Vendor APIs change frequently. Hardcoding them makes maintenance a nightmare.
- You may need flexibility to switch vendors, use fine-tuned models, or deploy local LLMs.
- You may need optimizations like prompt caching, request batching, or response streaming.
However, we provide example implementations for commonly used utility functions.