← プロジェクト一覧に戻る

PocketFlow

フレームワーク全体が約100行。一度に読み切れる代わりに、その外側はすべて自分で書く

MIT
スター
11.1k
フォーク
1.2k
オープンIssue
75
最終コミット
2026年7月26日

PocketFlowとは

PocketFlowは、中身を最後まで見通せないフレームワークへの反動として作られています。全体は依存関係のない約100行です。ノードは、必要なものを集める・処理する・次を決める、という3段階で1つの仕事をこなし、ノードが返した文字列がどのエッジをたどるかを決めます。ノード同士はただの辞書を1つ共有します。フレームワークと呼べるのはここまでです。モデルを呼ぶクライアントも、提供元ごとのエラーに対する再試行の方針も、実行記録の仕組みもありません。それらは自分で書くことになり、参考資料の役割は動く例を集めたクックブックが担います。他人の大きな設定を読むより、小さなコードを自分で持つほうがよいと考える人に向いています。

PocketFlowで何ができますか?

  • フレームワーク全体を一度に読み切る — 依存関係のない約100行なので、挙動が気になったときに課題管理を検索するのではなく、その場でコードを見て答えられます。
  • ノードは3つの段階に分かれる — 入力を集める処理、実際の処理、次を決める処理が別のメソッドになっており、モデルを呼ぶ部分に周辺の帳簿づけが混ざりません。
  • 名前を返して経路を決める — ノードが返した文字列が次のエッジを選びます。分岐や繰り返しを、判断が実際に行われる場所にそのまま書けます。
  • ノードごとに再試行と代替結果を持つ — 各ノードに試行回数と失敗時の代替結果を設定できるため、不安定な処理が1つあっても流れ全体が止まりません。
  • 同じ形のまま一括処理と非同期に広げる — ノードとフローという同じ考え方のまま、多数の項目をまとめて処理する版と、遅い呼び出しを並行して待つ版が用意されています。

PocketFlowを選ぶ前に

  • モデルを包む層がありません。APIの呼び出し、提供元ごとの流量制限やエラー形式への対処、実行内容の記録は、すべて自分で書いて保守することになります。
  • 資料は参照マニュアルではなく、動く例を集めたクックブックです。例に無いことを知りたい場合、仕様書の役割を果たすのは100行のソースそのものです。

よくある質問

PocketFlowは商用利用できますか?

PocketFlowはMITライセンスで公開されています。OSI承認のオープンソースライセンスで、商用利用が認められています。

PocketFlowはどの形で使えますか?

PocketFlowはローカル実行・セルフホストの形で利用できます。

ドキュメント

The-Pocket/PocketFlow のREADMEより転載(MIT)。 原文を読む ↗

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

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!

AbstractionApp-Specific WrappersVendor-Specific WrappersLinesSize
LangChainAgent, ChainMany (e.g., QA, Summarization)Many (e.g., OpenAI, Pinecone, etc.)405K+166MB
CrewAIAgent, ChainMany (e.g., FileReadTool, SerperDevTool)Many (e.g., OpenAI, Anthropic, Pinecone, etc.)18K+173MB
SmolAgentAgentSome (e.g., CodeAgent, VisitWebTool)Some (e.g., DuckDuckGo, Hugging Face, etc.)8K+198MB
LangGraphAgent, GraphSome (e.g., Semantic Search)Some (e.g., PostgresStore, SqliteSaver, etc.) 37K+51MB
AutoGenAgentSome (e.g., Tool Agent, Chat Agent)Many [Optional] (e.g., OpenAI, Pinecone, etc.)7K (core-only)+26MB (core-only)
PocketFlowGraphNoneNone100+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.

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

✨ Below are examples of more complex LLM Apps:

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

PocketFlow
AIに聞く
GitHub