MCPcopy Index your code
hub / github.com/The-Pocket/PocketFlow

github.com/The-Pocket/PocketFlow @v0.0.0

repository ↗ · DeepWiki ↗ · release v0.0.0 ↗ · + Follow
623 symbols 1,900 edges 110 files 258 documented · 41%
README

License: MIT Docs

Pocket Flow is a 100-line minimalist LLM framework

  • Lightweight: Just 100 lines. Zero bloat, zero dependencies, zero vendor lock-in.

  • Expressive: Everything you love—(Multi-)Agents, Workflow, RAG, and more.

  • Agentic Coding: Let AI Agents (e.g., Cursor AI) build Agents—10x productivity boost!

  • To install, pip install pocketflowor just copy the source code (only 100 lines).

  • To learn more, check out the documentation. For an in-depth design dive, read the essay.

  • 🎉 We now have a discord!

Why Pocket Flow?

Current LLM frameworks are bloated... You only need 100 lines for LLM Framework!

Abstraction App-Specific Wrappers Vendor-Specific Wrappers Lines Size
LangChain Agent, Chain Many

(e.g., QA, Summarization) | Many

(e.g., OpenAI, Pinecone, etc.) | 405K | +166MB | | CrewAI | Agent, Chain | Many

(e.g., FileReadTool, SerperDevTool) | Many

(e.g., OpenAI, Anthropic, Pinecone, etc.) | 18K | +173MB | | SmolAgent | Agent | Some

(e.g., CodeAgent, VisitWebTool) | Some

(e.g., DuckDuckGo, Hugging Face, etc.) | 8K | +198MB | | LangGraph | Agent, Graph | Some

(e.g., Semantic Search) | Some

(e.g., PostgresStore, SqliteSaver, etc.) | 37K | +51MB | | AutoGen | Agent | Some

(e.g., Tool Agent, Chat Agent) | Many [Optional]

(e.g., OpenAI, Pinecone, etc.) | 7K

(core-only) | +26MB

(core-only) | | PocketFlow | Graph | None | None | 100 | +56KB |

How does Pocket Flow work?

The 100 lines capture the core abstraction of LLM frameworks: Graph!

From there, it's easy to implement popular design patterns like (Multi-)Agents, Workflow, RAG, etc.

✨ Below are basic tutorials:

Name Difficulty Description
Chat ☆☆☆

Dummy | A basic chat bot with conversation history | | RAG | ☆☆☆

Dummy | A simple Retrieval-augmented Generation process | | Workflow | ☆☆☆

Dummy | A writing workflow that outlines, writes content, and applies styling | | Map-Reduce | ☆☆☆

Dummy | A resume qualification processor using map-reduce pattern for batch evaluation | | Agent | ☆☆☆

Dummy | A research agent that can search the web and answer questions | | Streaming | ☆☆☆

Dummy | A real-time LLM streaming demo with user interrupt capability | | Multi-Agent | ★☆☆

Beginner | A Taboo word game for asynchronous communication between two agents | | Supervisor | ★☆☆

Beginner | Research agent is getting unreliable... Let's build a supervision process| | Parallel | ★☆☆

Beginner | A parallel execution demo that shows 3x speedup | | Thinking | ★☆☆

Beginner | Solve complex reasoning problems through Chain-of-Thought | | Memory | ★☆☆

Beginner | A chat bot with short-term and long-term memory |

👀 Want to see other tutorials for dummies? Create an issue!

How to Use Pocket Flow?

🚀 Through Agentic Coding—the fastest LLM App development paradigm-where humans design and agents code!

IMAGE ALT TEXT

✨ Below are examples of more complex LLM Apps:

App Name Difficulty Topics Human Design Agent Code
Build Cursor with Cursor

We'll reach the singularity soon ... | ★★★

Advanced | Agent | Design Doc | Flow Code | Ask AI Paul Graham

Ask AI Paul Graham, in case you don't get in | ★★☆

Medium | RAG

Map Reduce

TTS | Design Doc | Flow Code | Youtube Summarizer

Explain YouTube Videos to you like you're 5 | ★☆☆

Beginner | Map Reduce | Design Doc | Flow Code | Cold Opener Generator

Instant icebreakers that turn cold leads hot | ★☆☆

Beginner | Map Reduce

Web Search | Design Doc | Flow Code

Core symbols most depended-on inside this repo

run
called by 62
pocketflow/__init__.py
run_async
called by 30
pocketflow/__init__.py
get_embedding
called by 5
cookbook/pocketflow-rag/utils.py
get_embedding
called by 4
cookbook/pocketflow-chat-memory/utils/get_embedding.py
call_llm
called by 4
cookbook/pocketflow-workflow/utils.py
prep_async
called by 4
pocketflow/__init__.py
post_async
called by 4
pocketflow/__init__.py
call_llm
called by 3
cookbook/pocketflow-multi-agent/utils.py

Shape

Method 389
Class 149
Function 85

Languages

Python100%

Modules by API surface

pocketflow/__init__.py53 symbols
tests/test_fall_back.py43 symbols
tests/test_batch_flow.py30 symbols
tests/test_async_batch_flow.py28 symbols
tests/test_async_parallel_batch_flow.py23 symbols
tests/test_async_flow.py21 symbols
tests/test_flow_basic.py19 symbols
tests/test_async_parallel_batch_node.py18 symbols
cookbook/pocketflow-tool-pdf-vision/nodes.py17 symbols
cookbook/pocketflow-supervisor/nodes.py16 symbols
cookbook/pocketflow-rag/nodes.py16 symbols
cookbook/pocketflow-parallel-batch-flow/nodes.py16 symbols

Dependencies from manifests, versioned

Pillow10.0.0 · 1×
PyMuPDF1.22.0 · 1×
aiohttp3.8.0 · 1×
anthropic0.15.0 · 1×
beautifulsoup44.12.0 · 1×
duckduckgo-search7.5.2 · 1×
faiss-cpu1.7.0 · 1×
google-search-results2.4.2 · 1×
numpy1.20.0 · 1×
openai1.0.0 · 1×
pandas2.0.0 · 1×
pocketflow0.0.5 · 1×

For agents

$ claude mcp add PocketFlow \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact