PocketFlow README

The project's README from github.com/The-Pocket/PocketFlow. As one markdown file: README.md.

Pocket Flow – 100-line minimalist LLM framework

English | 中文 | Español | 日本語 | Deutsch | Русский | Português | Français | 한국어

License: MIT Docs

Pocket Flow is a 100-line minimalist LLM framework

Get started with Pocket Flow:

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
Structured Output ☆☆☆ Dummy Extracting structured data from resumes by prompting
Workflow ☆☆☆ Dummy A writing workflow that outlines, writes content, and applies styling
Agent ☆☆☆ Dummy A research agent that can search the web and answer questions
RAG ☆☆☆ Dummy A simple Retrieval-augmented Generation process
Batch ☆☆☆ Dummy A batch processor that translates markdown into multiple languages
Streaming ☆☆☆ Dummy A real-time LLM streaming demo with user interrupt capability
Chat Guardrail ☆☆☆ Dummy A travel advisor chatbot that only processes travel-related queries
Majority Vote ☆☆☆ Dummy Improve reasoning accuracy by aggregating multiple solution attempts
Map-Reduce ☆☆☆ Dummy Batch resume qualification using map-reduce pattern
CLI HITL ☆☆☆ Dummy A command-line joke generator with human-in-the-loop feedback
Multi-Agent ★☆☆ Beginner A Taboo word game for async communication between 2 agents
Supervisor ★☆☆ Beginner Research agent is getting unreliable... Let's build a supervision process
Parallel ★☆☆ Beginner A parallel execution demo that shows 3x speedup
Parallel Flow ★☆☆ Beginner A parallel image processing showing 8x speedup
Thinking ★☆☆ Beginner Solve complex reasoning problems through Chain-of-Thought
Memory ★☆☆ Beginner A chat bot with short-term and long-term memory
Text2SQL ★☆☆ Beginner Convert natural language to SQL queries with an auto-debug loop
Code Generator ★☆☆ Beginner Generate test cases, implement solutions, and iteratively improve code
MCP ★☆☆ Beginner Agent using Model Context Protocol for numerical operations
Agent Skills ★☆☆ Beginner Route requests to reusable markdown skills and apply them in an agent flow
A2A ★☆☆ Beginner Agent wrapped with A2A protocol for inter-agent communication
Streamlit FSM ★☆☆ Beginner Streamlit app with finite state machine for HITL image generation
FastAPI WebSocket ★☆☆ Beginner Real-time chat interface with streaming LLM responses via WebSocket
FastAPI Background ★☆☆ Beginner FastAPI app with background jobs and real-time progress via SSE
Voice Chat ★☆☆ Beginner An interactive voice chat application with VAD, STT, LLM, and TTS.
Judge ★☆☆ Beginner LLM-as-Judge evaluator-optimizer loop for iterative content refinement
Debate ★☆☆ Beginner Adversarial reasoning with two advocates and an impartial judge
Agentic RAG ★☆☆ Beginner Agent-driven RAG that decides which documents to read
Self-Healing Mermaid ★☆☆ Beginner Generate Mermaid diagrams with automatic error recovery
Heartbeat ★☆☆ Beginner ClawBot-like always-on periodic monitoring with nested flows
Lead Generation ★★☆ Intermediate Sales pipeline: scrape, enrich, score, and personalize emails
Newsletter ★★☆ Intermediate AI newsletter curation: search, filter, summarize, and format
Invoice Processing ★★☆ Intermediate Extract and validate invoice data from PDFs using vision
NotebookLM ★★☆ Intermediate Turn documents into a podcast with two AI hosts
Deep Research ★★☆ Intermediate Recursive map-reduce research with iterative refinement
Coding Agent ★★★ Advanced Production coding agent with 6 tools, memory, and patch-as-subflow

👀 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
Website Chatbot
Turn your website into a 24/7 customer support genius
★★☆
Medium
Agent
RAG
Design Doc Flow Code
Danganronpa Simulator
Forget the Turing test. Danganronpa, the ultimate AI experiment!
★★★
Advanced
Workflow
Agent
Design Doc Flow Code
Codebase Knowledge Builder
Life's too short to stare at others' code in confusion
★★☆
Medium
Workflow Design Doc Flow 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

PocketFlow (The-Pocket/PocketFlow)

Searching Database…

这是什么?Pocket Flow 是一个极简的 LLM 框架,只有 100 行代码,围绕单一的 Graph 抽象构建。无需沉重的依赖,也不必受制于某一家厂商,就能搭建智能体、工作流和 RAG 流程。
它是像 LangChain 那样的完整 LLM 框架,还是更精简的东西?它是一个精简的框架,而不是应用:整个引擎只有 100 行代码,实现了单一的 Graph 抽象,没有多余的东西,也零依赖。项目自己的对比表显示,LangChain 有 405K 行代码,CrewAI 的占用空间超过 173MB。
我怎么把它加到项目里?安装即可,或者直接把 100 行的源文件复制到你的代码库中。核心很小,可以直接内置,所以无需配置什么真正的软件包。
使用它还需要其他 LLM 库吗?不需要,PocketFlow 在设计上就是零依赖。你可以自己调用 LLM 客户端,再把它们接入 Graph。
它会像其他框架那样自带现成的应用或厂商封装吗?不会。项目自己的对比表显示,PocketFlow 没有针对特定应用的封装(如问答、摘要),也没有针对特定厂商的封装(如 OpenAI、Pinecone 等)。这一点与 LangChain 或 CrewAI 不同,所以你需要在 Graph 抽象之上自己实现这些模式。
什么是 “Agentic Coding”?这是 PocketFlow 倡导的工作方式:由人通过设计文档来设计系统,再由 Cursor AI 等 AI 编程智能体编写实际的流程代码。项目宣称这种方式可带来 10 倍的效率提升。
PocketFlow 只能用 Python 吗?核心框架是用 Python 写的,但项目还维护了 TypeScript、Java、C++、Go、Rust 和 PHP 的移植版本。
开箱即用能做些什么?仓库提供了数十个教程和示例应用,涵盖聊天机器人、RAG、多智能体游戏、map-reduce 批处理任务、文本转 SQL、语音聊天,以及可用于生产环境的编程智能体,难度从 Dummy 到 Advanced 不等。
它有社区吗?有的。有一个供开发者交流 PocketFlow 开发经验的 Discord 服务器,还有一个 YouTube 频道,展示了如何用智能体式编程制作多个示例应用。
Creator
The-Pocket
Size
50.6 MB
Stars
11.3K
Updated
CommitJul 26
Age
1y
Commits · 90 Days