界面已本地化;技能介绍与说明文档按所选语言由 AI 自动翻译,代码、命令、路径和专业术语保留原文,以原作者文档为准。
探索技能
效率与协作 · SKILL.md

pocketflow

pocketflow

【效率与协作】Use PocketFlow, a tiny Python graph framework for LLM applications, agents, workflows, RAG, batch processing, async orchestration, and supporting utilities.

独立 GitHub 快照 · 自动分类 · 以原作者文档为准

技能说明

GitHub

name: pocketflow description: "Use PocketFlow, a tiny Python graph framework for LLM applications, agents, workflows, RAG, batch processing, async orchestration, and supporting utilities." metadata: disco-role: operating disable-model-invocation: true license: MIT

PocketFlow Repo Skill

Use this skill when a task asks to build, debug, review, or explain a PocketFlow application or to translate an LLM-system design into PocketFlow nodes and flows. PocketFlow is intentionally minimal: the installed package exposes a compact graph runtime with no built-in LLM provider, vector database, search, UI, audio, or tracing integration. Those integrations live in user utilities that PocketFlow nodes call.

Fast recognition

Read this skill when the user mentions any of these signals:

  • pocketflow, Pocket Flow, or a 100-line LLM framework.
  • Node, Flow, BatchNode, BatchFlow, AsyncNode, AsyncFlow, AsyncParallelBatchNode, or AsyncParallelBatchFlow in a graph-orchestration context.
  • A Python LLM app with prep -> exec -> post, a shared dictionary, action strings, graph transitions, or node - "action" >> other_node syntax.
  • Building lightweight agents, RAG, map-reduce, structured-output, streaming, FastAPI background jobs, voice/chat workflows, or coding-agent loops without a large framework.

Minimal install and import check

pip install pocketflow
python - <<'PY'
from pocketflow import Node, Flow
class Start(Node):
    def prep(self, shared):
        shared["seen"] = True
start = Start()
Flow(start=start).run({})
print("pocketflow import ok")
PY

For development from source, an editable install is also valid. The public package version captured for this skill is 0.0.3; see repo provenance for the source snapshot.

Route by task

If the task is about...Read
Public runtime classes, prep/exec/post, transitions, retries, fallback, nested flows, sync/async, batch/parallel behavior, or unit-test-like API debuggingcore-abstraction
Designing an LLM app architecture, deciding between workflow/agent/RAG/map-reduce/structured-output/multi-agent patterns, or using cookbook-style recipesdesign-patterns
Implementing provider wrappers, search/embedding/vector/TTS/database utilities, graph visualization, logging/tracing, chunking, streaming, or external dependency safetyutilities
Cross-cutting install/import/provider/config mistakes before choosing a sub-skilltroubleshooting
Router placement, source snapshot, or staleness checksrepo provenance and routing metadata

PocketFlow mental model

  1. A node has three optional phases. prep(shared) reads and prepares data, exec(prep_res) performs compute and is the only phase retried, and post(shared, prep_res, exec_res) writes results and returns the next action.
  2. A flow follows action strings. a >> b is the default transition. a - "search" >> b is a named transition. If post() returns None, PocketFlow looks for the default successor.
  3. The shared store is the durable data contract. Most task state should be in a user-designed dictionary or persistence layer. Nodes communicate by reading/writing it.
  4. Params are per-run identifiers. BatchFlow.prep() returns parameter dictionaries; child nodes read them from self.params. Do not use params as mutable shared state.
  5. PocketFlow is not an integration framework. LLM calls, embeddings, vector search, DB queries, speech, UI, and observability are ordinary utility functions invoked by nodes.
  6. Start simple. For a new LLM system, write a short design document first, then implement utilities, shared-store schema, nodes, and flows.

Common safe checks

Boundaries and caveats

  • Do not claim PocketFlow automatically manages prompts, memory, tools, provider retries, callbacks, vector indexes, web servers, tracing, or credentials. Implement those explicitly as utilities and shared-store fields.
  • Avoid writing giant exec() methods that read/write global state; put input selection in prep() and result persistence in post().
  • Do not run credentialed cookbook-style examples unless the user has provided required keys and approved network or service side effects.
  • AsyncParallelBatchNode and AsyncParallelBatchFlow overlap independent async work; they are not CPU-parallel execution engines.
  • If a task is primarily about maintaining this repository source code rather than using PocketFlow as a package, also apply normal Python repository maintenance practices.
我的收藏