PocketFlow

PocketFlow is a minimalist LLM framework with just 100 lines of code, designed for efficiency and flexibility.

<div align="center"> <img src="https://github.com/The-Pocket/.github/raw/main/assets/title.png" alt="Pocket Flow – 100-line minimalist LLM framework" width="600"/> </div> <!-- For translation, replace English with [English](https://github.com/The-Pocket/PocketFlow/blob/main/README.md), and remove the link for the target language. -->

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

License: MIT Docs <a href="https://discord.gg/hUHHE9Sa6T"> <img src="https://img.shields.io/discord/1346833819172601907?logo=discord&style=flat"> </a>

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!

Get started with Pocket Flow:

Why Pocket Flow?

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

<div align="center"> <img src="https://github.com/The-Pocket/.github/raw/main/assets/meme.jpg" width="400"/>
AbstractionApp-Specific WrappersVendor-Specific WrappersLinesSize
LangChainAgent, ChainMany <br><sup><sub>(e.g., QA, Summarization)</sub></sup>Many <br><sup><sub>(e.g., OpenAI, Pinecone, etc.)</sub></sup>405K+166MB
CrewAIAgent, ChainMany <br><sup><sub>(e.g., FileReadTool, SerperDevTool)</sub></sup>Many <br><sup><sub>(e.g., OpenAI, Anthropic, Pinecone, etc.)</sub></sup>18K+173MB
SmolAgentAgentSome <br><sup><sub>(e.g., CodeAgent, VisitWebTool)</sub></sup>Some <br><sup><sub>(e.g., DuckDuckGo, Hugging Face, etc.)</sub></sup>8K+198MB
LangGraphAgent, GraphSome <br><sup><sub>(e.g., Semantic Search)</sub></sup>Some <br><sup><sub>(e.g., PostgresStore, SqliteSaver, etc.) </sub></sup>37K+51MB
AutoGenAgentSome <br><sup><sub>(e.g., Tool Agent, Chat Agent)</sub></sup>Many <sup><sub>[Optional]<br> (e.g., OpenAI, Pinecone, etc.)</sub></sup>7K <br><sup><sub>(core-only)</sub></sup>+26MB <br><sup><sub>(core-only)</sub></sup>
PocketFlowGraphNoneNone100+56KB
</div>

How does Pocket Flow work?

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

<div align="center"> <img src="https://github.com/The-Pocket/.github/raw/main/assets/abstraction.png" width="900"/> </div> <br>

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

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

👀 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!

<br> <div align="center"> <a href="https://zacharyhuang.substack.com/p/agentic-coding-the-most-fun-way-to" target="_blank"> <img src="https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F423a39af-49e8-483b-bc5a-88cc764350c6_1050x588.png" width="700" alt="IMAGE ALT TEXT" style="cursor: pointer;"> </a> </div> <br>

✨ Below are examples of more complex LLM Apps:

<div align="center">
App NameDifficultyTopicsHuman DesignAgent Code
Website Chatbot <br> <sup><sub>Turn your website into a 24/7 customer support genius</sup></sub>★★☆ <br> MediumAgent <br> RAGDesign DocFlow Code
Danganronpa Simulator <br> <sup><sub>Forget the Turing test. Danganronpa, the ultimate AI experiment!</sup></sub>★★★ <br> AdvancedWorkflow <br> AgentDesign DocFlow Code
Codebase Knowledge Builder <br> <sup><sub>Life's too short to stare at others' code in confusion</sup></sub>★★☆ <br> MediumWorkflowDesign DocFlow Code
Build Cursor with Cursor <br> <sup><sub>We'll reach the singularity soon ...</sup></sub>★★★ <br> AdvancedAgentDesign DocFlow Code
Ask AI Paul Graham <br> <sup><sub>Ask AI Paul Graham, in case you don't get in</sup></sub>★★☆ <br> MediumRAG <br> Map Reduce <br> TTSDesign DocFlow Code
Youtube Summarizer <br> <sup><sub> Explain YouTube Videos to you like you're 5 </sup></sub>★☆☆ <br> BeginnerMap ReduceDesign DocFlow Code
Cold Opener Generator <br> <sup><sub> Instant icebreakers that turn cold leads hot </sup></sub>★☆☆ <br> BeginnerMap Reduce <br> Web SearchDesign DocFlow Code
</div>
  • Want to learn Agentic Coding?

    • Check out my YouTube for video tutorial on how some apps above are made!

    • Want to build your own LLM App? Read this post! Start with this template!